ConfigurationFileFormat.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. using System.Collections.Generic;
  2. using System.IO;
  3. using Ryujinx.Common.Configuration;
  4. using Ryujinx.Common.Configuration.Hid;
  5. using Ryujinx.Common.Logging;
  6. using Ryujinx.Common.Utilities;
  7. using Ryujinx.Configuration.System;
  8. using Ryujinx.Configuration.Ui;
  9. namespace Ryujinx.Configuration
  10. {
  11. public class ConfigurationFileFormat
  12. {
  13. /// <summary>
  14. /// The current version of the file format
  15. /// </summary>
  16. public const int CurrentVersion = 27;
  17. public int Version { get; set; }
  18. /// <summary>
  19. /// Enables or disables logging to a file on disk
  20. /// </summary>
  21. public bool EnableFileLog { get; set; }
  22. /// <summary>
  23. /// Resolution Scale. An integer scale applied to applicable render targets. Values 1-4, or -1 to use a custom floating point scale instead.
  24. /// </summary>
  25. public int ResScale { get; set; }
  26. /// <summary>
  27. /// Custom Resolution Scale. A custom floating point scale applied to applicable render targets. Only active when Resolution Scale is -1.
  28. /// </summary>
  29. public float ResScaleCustom { get; set; }
  30. /// <summary>
  31. /// Max Anisotropy. Values range from 0 - 16. Set to -1 to let the game decide.
  32. /// </summary>
  33. public float MaxAnisotropy { get; set; }
  34. /// <summary>
  35. /// Aspect Ratio applied to the renderer window.
  36. /// </summary>
  37. public AspectRatio AspectRatio { get; set; }
  38. /// <summary>
  39. /// Dumps shaders in this local directory
  40. /// </summary>
  41. public string GraphicsShadersDumpPath { get; set; }
  42. /// <summary>
  43. /// Enables printing debug log messages
  44. /// </summary>
  45. public bool LoggingEnableDebug { get; set; }
  46. /// <summary>
  47. /// Enables printing stub log messages
  48. /// </summary>
  49. public bool LoggingEnableStub { get; set; }
  50. /// <summary>
  51. /// Enables printing info log messages
  52. /// </summary>
  53. public bool LoggingEnableInfo { get; set; }
  54. /// <summary>
  55. /// Enables printing warning log messages
  56. /// </summary>
  57. public bool LoggingEnableWarn { get; set; }
  58. /// <summary>
  59. /// Enables printing error log messages
  60. /// </summary>
  61. public bool LoggingEnableError { get; set; }
  62. /// <summary>
  63. /// Enables printing guest log messages
  64. /// </summary>
  65. public bool LoggingEnableGuest { get; set; }
  66. /// <summary>
  67. /// Enables printing FS access log messages
  68. /// </summary>
  69. public bool LoggingEnableFsAccessLog { get; set; }
  70. /// <summary>
  71. /// Controls which log messages are written to the log targets
  72. /// </summary>
  73. public LogClass[] LoggingFilteredClasses { get; set; }
  74. /// <summary>
  75. /// Change Graphics API debug log level
  76. /// </summary>
  77. public GraphicsDebugLevel LoggingGraphicsDebugLevel { get; set; }
  78. /// <summary>
  79. /// Change System Language
  80. /// </summary>
  81. public Language SystemLanguage { get; set; }
  82. /// <summary>
  83. /// Change System Region
  84. /// </summary>
  85. public Region SystemRegion { get; set; }
  86. /// <summary>
  87. /// Change System TimeZone
  88. /// </summary>
  89. public string SystemTimeZone { get; set; }
  90. /// <summary>
  91. /// Change System Time Offset in seconds
  92. /// </summary>
  93. public long SystemTimeOffset { get; set; }
  94. /// <summary>
  95. /// Enables or disables Docked Mode
  96. /// </summary>
  97. public bool DockedMode { get; set; }
  98. /// <summary>
  99. /// Enables or disables Discord Rich Presence
  100. /// </summary>
  101. public bool EnableDiscordIntegration { get; set; }
  102. /// <summary>
  103. /// Checks for updates when Ryujinx starts when enabled
  104. /// </summary>
  105. public bool CheckUpdatesOnStart { get; set; }
  106. /// <summary>
  107. /// Show "Confirm Exit" Dialog
  108. /// </summary>
  109. public bool ShowConfirmExit { get; set; }
  110. /// <summary>
  111. /// Hide Cursor on Idle
  112. /// </summary>
  113. public bool HideCursorOnIdle { get; set; }
  114. /// <summary>
  115. /// Enables or disables Vertical Sync
  116. /// </summary>
  117. public bool EnableVsync { get; set; }
  118. /// <summary>
  119. /// Enables or disables Shader cache
  120. /// </summary>
  121. public bool EnableShaderCache { get; set; }
  122. /// <summary>
  123. /// Enables or disables multi-core scheduling of threads
  124. /// </summary>
  125. public bool EnableMulticoreScheduling { get; set; }
  126. /// <summary>
  127. /// Enables or disables profiled translation cache persistency
  128. /// </summary>
  129. public bool EnablePtc { get; set; }
  130. /// <summary>
  131. /// Enables integrity checks on Game content files
  132. /// </summary>
  133. public bool EnableFsIntegrityChecks { get; set; }
  134. /// <summary>
  135. /// Enables FS access log output to the console. Possible modes are 0-3
  136. /// </summary>
  137. public int FsGlobalAccessLogMode { get; set; }
  138. /// <summary>
  139. /// The selected audio backend
  140. /// </summary>
  141. public AudioBackend AudioBackend { get; set; }
  142. /// <summary>
  143. /// The selected memory manager mode
  144. /// </summary>
  145. public MemoryManagerMode MemoryManagerMode { get; set; }
  146. /// <summary>
  147. /// Expands the RAM amount on the emulated system from 4GB to 6GB
  148. /// </summary>
  149. public bool ExpandRam { get; set; }
  150. /// <summary>
  151. /// Enable or disable ignoring missing services
  152. /// </summary>
  153. public bool IgnoreMissingServices { get; set; }
  154. /// <summary>
  155. /// Used to toggle columns in the GUI
  156. /// </summary>
  157. public GuiColumns GuiColumns { get; set; }
  158. /// <summary>
  159. /// Used to configure column sort settings in the GUI
  160. /// </summary>
  161. public ColumnSort ColumnSort { get; set; }
  162. /// <summary>
  163. /// A list of directories containing games to be used to load games into the games list
  164. /// </summary>
  165. public List<string> GameDirs { get; set; }
  166. /// <summary>
  167. /// Enable or disable custom themes in the GUI
  168. /// </summary>
  169. public bool EnableCustomTheme { get; set; }
  170. /// <summary>
  171. /// Path to custom GUI theme
  172. /// </summary>
  173. public string CustomThemePath { get; set; }
  174. /// <summary>
  175. /// Start games in fullscreen mode
  176. /// </summary>
  177. public bool StartFullscreen { get; set; }
  178. /// <summary>
  179. /// Enable or disable keyboard support (Independent from controllers binding)
  180. /// </summary>
  181. public bool EnableKeyboard { get; set; }
  182. /// <summary>
  183. /// Enable or disable mouse support (Independent from controllers binding)
  184. /// </summary>
  185. public bool EnableMouse { get; set; }
  186. /// <summary>
  187. /// Hotkey Keyboard Bindings
  188. /// </summary>
  189. public KeyboardHotkeys Hotkeys { get; set; }
  190. /// <summary>
  191. /// Legacy keyboard control bindings
  192. /// </summary>
  193. /// <remarks>Kept for file format compatibility (to avoid possible failure when parsing configuration on old versions)</remarks>
  194. /// TODO: Remove this when those older versions aren't in use anymore.
  195. public List<object> KeyboardConfig { get; set; }
  196. /// <summary>
  197. /// Legacy controller control bindings
  198. /// </summary>
  199. /// <remarks>Kept for file format compatibility (to avoid possible failure when parsing configuration on old versions)</remarks>
  200. /// TODO: Remove this when those older versions aren't in use anymore.
  201. public List<object> ControllerConfig { get; set; }
  202. /// <summary>
  203. /// Input configurations
  204. /// </summary>
  205. public List<InputConfig> InputConfig { get; set; }
  206. /// <summary>
  207. /// Loads a configuration file from disk
  208. /// </summary>
  209. /// <param name="path">The path to the JSON configuration file</param>
  210. public static bool TryLoad(string path, out ConfigurationFileFormat configurationFileFormat)
  211. {
  212. try
  213. {
  214. configurationFileFormat = JsonHelper.DeserializeFromFile<ConfigurationFileFormat>(path);
  215. return true;
  216. }
  217. catch
  218. {
  219. configurationFileFormat = null;
  220. return false;
  221. }
  222. }
  223. /// <summary>
  224. /// Save a configuration file to disk
  225. /// </summary>
  226. /// <param name="path">The path to the JSON configuration file</param>
  227. public void SaveConfig(string path)
  228. {
  229. using FileStream fileStream = File.Create(path, 4096, FileOptions.WriteThrough);
  230. JsonHelper.Serialize(fileStream, this, true);
  231. }
  232. }
  233. }