ConfigurationFileFormat.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. using Ryujinx.Common.Configuration;
  2. using Ryujinx.Common.Configuration.Hid;
  3. using Ryujinx.Common.Logging;
  4. using Ryujinx.Common.Utilities;
  5. using Ryujinx.Ui.Common.Configuration.System;
  6. using Ryujinx.Ui.Common.Configuration.Ui;
  7. using System.Collections.Generic;
  8. using System.Text.Json.Nodes;
  9. namespace Ryujinx.Ui.Common.Configuration
  10. {
  11. public class ConfigurationFileFormat
  12. {
  13. /// <summary>
  14. /// The current version of the file format
  15. /// </summary>
  16. public const int CurrentVersion = 48;
  17. /// <summary>
  18. /// Version of the configuration file format
  19. /// </summary>
  20. public int Version { get; set; }
  21. /// <summary>
  22. /// Enables or disables logging to a file on disk
  23. /// </summary>
  24. public bool EnableFileLog { get; set; }
  25. /// <summary>
  26. /// Whether or not backend threading is enabled. The "Auto" setting will determine whether threading should be enabled at runtime.
  27. /// </summary>
  28. public BackendThreading BackendThreading { get; set; }
  29. /// <summary>
  30. /// Resolution Scale. An integer scale applied to applicable render targets. Values 1-4, or -1 to use a custom floating point scale instead.
  31. /// </summary>
  32. public int ResScale { get; set; }
  33. /// <summary>
  34. /// Custom Resolution Scale. A custom floating point scale applied to applicable render targets. Only active when Resolution Scale is -1.
  35. /// </summary>
  36. public float ResScaleCustom { get; set; }
  37. /// <summary>
  38. /// Max Anisotropy. Values range from 0 - 16. Set to -1 to let the game decide.
  39. /// </summary>
  40. public float MaxAnisotropy { get; set; }
  41. /// <summary>
  42. /// Aspect Ratio applied to the renderer window.
  43. /// </summary>
  44. public AspectRatio AspectRatio { get; set; }
  45. /// <summary>
  46. /// Applies anti-aliasing to the renderer.
  47. /// </summary>
  48. public AntiAliasing AntiAliasing { get; set; }
  49. /// <summary>
  50. /// Sets the framebuffer upscaling type.
  51. /// </summary>
  52. public ScalingFilter ScalingFilter { get; set; }
  53. /// <summary>
  54. /// Sets the framebuffer upscaling level.
  55. /// </summary>
  56. public int ScalingFilterLevel { get; set; }
  57. /// <summary>
  58. /// Dumps shaders in this local directory
  59. /// </summary>
  60. public string GraphicsShadersDumpPath { get; set; }
  61. /// <summary>
  62. /// Enables printing debug log messages
  63. /// </summary>
  64. public bool LoggingEnableDebug { get; set; }
  65. /// <summary>
  66. /// Enables printing stub log messages
  67. /// </summary>
  68. public bool LoggingEnableStub { get; set; }
  69. /// <summary>
  70. /// Enables printing info log messages
  71. /// </summary>
  72. public bool LoggingEnableInfo { get; set; }
  73. /// <summary>
  74. /// Enables printing warning log messages
  75. /// </summary>
  76. public bool LoggingEnableWarn { get; set; }
  77. /// <summary>
  78. /// Enables printing error log messages
  79. /// </summary>
  80. public bool LoggingEnableError { get; set; }
  81. /// <summary>
  82. /// Enables printing trace log messages
  83. /// </summary>
  84. public bool LoggingEnableTrace { get; set; }
  85. /// <summary>
  86. /// Enables printing guest log messages
  87. /// </summary>
  88. public bool LoggingEnableGuest { get; set; }
  89. /// <summary>
  90. /// Enables printing FS access log messages
  91. /// </summary>
  92. public bool LoggingEnableFsAccessLog { get; set; }
  93. /// <summary>
  94. /// Controls which log messages are written to the log targets
  95. /// </summary>
  96. public LogClass[] LoggingFilteredClasses { get; set; }
  97. /// <summary>
  98. /// Change Graphics API debug log level
  99. /// </summary>
  100. public GraphicsDebugLevel LoggingGraphicsDebugLevel { get; set; }
  101. /// <summary>
  102. /// Change System Language
  103. /// </summary>
  104. public Language SystemLanguage { get; set; }
  105. /// <summary>
  106. /// Change System Region
  107. /// </summary>
  108. public Region SystemRegion { get; set; }
  109. /// <summary>
  110. /// Change System TimeZone
  111. /// </summary>
  112. public string SystemTimeZone { get; set; }
  113. /// <summary>
  114. /// Change System Time Offset in seconds
  115. /// </summary>
  116. public long SystemTimeOffset { get; set; }
  117. /// <summary>
  118. /// Enables or disables Docked Mode
  119. /// </summary>
  120. public bool DockedMode { get; set; }
  121. /// <summary>
  122. /// Enables or disables Discord Rich Presence
  123. /// </summary>
  124. public bool EnableDiscordIntegration { get; set; }
  125. /// <summary>
  126. /// Checks for updates when Ryujinx starts when enabled
  127. /// </summary>
  128. public bool CheckUpdatesOnStart { get; set; }
  129. /// <summary>
  130. /// Show "Confirm Exit" Dialog
  131. /// </summary>
  132. public bool ShowConfirmExit { get; set; }
  133. /// <summary>
  134. /// Whether to hide cursor on idle, always or never
  135. /// </summary>
  136. public HideCursorMode HideCursor { get; set; }
  137. /// <summary>
  138. /// Enables or disables Vertical Sync
  139. /// </summary>
  140. public bool EnableVsync { get; set; }
  141. /// <summary>
  142. /// Enables or disables Shader cache
  143. /// </summary>
  144. public bool EnableShaderCache { get; set; }
  145. /// <summary>
  146. /// Enables or disables texture recompression
  147. /// </summary>
  148. public bool EnableTextureRecompression { get; set; }
  149. /// <summary>
  150. /// Enables or disables Macro high-level emulation
  151. /// </summary>
  152. public bool EnableMacroHLE { get; set; }
  153. /// <summary>
  154. /// Enables or disables color space passthrough, if available.
  155. /// </summary>
  156. public bool EnableColorSpacePassthrough { get; set; }
  157. /// <summary>
  158. /// Enables or disables profiled translation cache persistency
  159. /// </summary>
  160. public bool EnablePtc { get; set; }
  161. /// <summary>
  162. /// Enables or disables guest Internet access
  163. /// </summary>
  164. public bool EnableInternetAccess { get; set; }
  165. /// <summary>
  166. /// Enables integrity checks on Game content files
  167. /// </summary>
  168. public bool EnableFsIntegrityChecks { get; set; }
  169. /// <summary>
  170. /// Enables FS access log output to the console. Possible modes are 0-3
  171. /// </summary>
  172. public int FsGlobalAccessLogMode { get; set; }
  173. /// <summary>
  174. /// The selected audio backend
  175. /// </summary>
  176. public AudioBackend AudioBackend { get; set; }
  177. /// <summary>
  178. /// The audio volume
  179. /// </summary>
  180. public float AudioVolume { get; set; }
  181. /// <summary>
  182. /// The selected memory manager mode
  183. /// </summary>
  184. public MemoryManagerMode MemoryManagerMode { get; set; }
  185. /// <summary>
  186. /// Expands the RAM amount on the emulated system from 4GiB to 6GiB
  187. /// </summary>
  188. public bool ExpandRam { get; set; }
  189. /// <summary>
  190. /// Enable or disable ignoring missing services
  191. /// </summary>
  192. public bool IgnoreMissingServices { get; set; }
  193. /// <summary>
  194. /// Used to toggle columns in the GUI
  195. /// </summary>
  196. public GuiColumns GuiColumns { get; set; }
  197. /// <summary>
  198. /// Used to configure column sort settings in the GUI
  199. /// </summary>
  200. public ColumnSort ColumnSort { get; set; }
  201. /// <summary>
  202. /// A list of directories containing games to be used to load games into the games list
  203. /// </summary>
  204. public List<string> GameDirs { get; set; }
  205. /// <summary>
  206. /// A list of file types to be hidden in the games List
  207. /// </summary>
  208. public ShownFileTypes ShownFileTypes { get; set; }
  209. /// <summary>
  210. /// Main window start-up position, size and state
  211. /// </summary>
  212. public WindowStartup WindowStartup { get; set; }
  213. /// <summary>
  214. /// Language Code for the UI
  215. /// </summary>
  216. public string LanguageCode { get; set; }
  217. /// <summary>
  218. /// Enable or disable custom themes in the GUI
  219. /// </summary>
  220. public bool EnableCustomTheme { get; set; }
  221. /// <summary>
  222. /// Path to custom GUI theme
  223. /// </summary>
  224. public string CustomThemePath { get; set; }
  225. /// <summary>
  226. /// Chooses the base style // Not Used
  227. /// </summary>
  228. public string BaseStyle { get; set; }
  229. /// <summary>
  230. /// Chooses the view mode of the game list // Not Used
  231. /// </summary>
  232. public int GameListViewMode { get; set; }
  233. /// <summary>
  234. /// Show application name in Grid Mode // Not Used
  235. /// </summary>
  236. public bool ShowNames { get; set; }
  237. /// <summary>
  238. /// Sets App Icon Size // Not Used
  239. /// </summary>
  240. public int GridSize { get; set; }
  241. /// <summary>
  242. /// Sorts Apps in the game list // Not Used
  243. /// </summary>
  244. public int ApplicationSort { get; set; }
  245. /// <summary>
  246. /// Sets if Grid is ordered in Ascending Order // Not Used
  247. /// </summary>
  248. public bool IsAscendingOrder { get; set; }
  249. /// <summary>
  250. /// Start games in fullscreen mode
  251. /// </summary>
  252. public bool StartFullscreen { get; set; }
  253. /// <summary>
  254. /// Show console window
  255. /// </summary>
  256. public bool ShowConsole { get; set; }
  257. /// <summary>
  258. /// Enable or disable keyboard support (Independent from controllers binding)
  259. /// </summary>
  260. public bool EnableKeyboard { get; set; }
  261. /// <summary>
  262. /// Enable or disable mouse support (Independent from controllers binding)
  263. /// </summary>
  264. public bool EnableMouse { get; set; }
  265. /// <summary>
  266. /// Hotkey Keyboard Bindings
  267. /// </summary>
  268. public KeyboardHotkeys Hotkeys { get; set; }
  269. /// <summary>
  270. /// Legacy keyboard control bindings
  271. /// </summary>
  272. /// <remarks>Kept for file format compatibility (to avoid possible failure when parsing configuration on old versions)</remarks>
  273. /// TODO: Remove this when those older versions aren't in use anymore.
  274. public List<JsonObject> KeyboardConfig { get; set; }
  275. /// <summary>
  276. /// Legacy controller control bindings
  277. /// </summary>
  278. /// <remarks>Kept for file format compatibility (to avoid possible failure when parsing configuration on old versions)</remarks>
  279. /// TODO: Remove this when those older versions aren't in use anymore.
  280. public List<JsonObject> ControllerConfig { get; set; }
  281. /// <summary>
  282. /// Input configurations
  283. /// </summary>
  284. public List<InputConfig> InputConfig { get; set; }
  285. /// <summary>
  286. /// Graphics backend
  287. /// </summary>
  288. public GraphicsBackend GraphicsBackend { get; set; }
  289. /// <summary>
  290. /// Preferred GPU
  291. /// </summary>
  292. public string PreferredGpu { get; set; }
  293. /// <summary>
  294. /// GUID for the network interface used by LAN (or 0 for default)
  295. /// </summary>
  296. public string MultiplayerLanInterfaceId { get; set; }
  297. /// <summary>
  298. /// Uses Hypervisor over JIT if available
  299. /// </summary>
  300. public bool UseHypervisor { get; set; }
  301. /// <summary>
  302. /// Loads a configuration file from disk
  303. /// </summary>
  304. /// <param name="path">The path to the JSON configuration file</param>
  305. /// <param name="configurationFileFormat">Parsed configuration file</param>
  306. public static bool TryLoad(string path, out ConfigurationFileFormat configurationFileFormat)
  307. {
  308. try
  309. {
  310. configurationFileFormat = JsonHelper.DeserializeFromFile(path, ConfigurationFileFormatSettings.SerializerContext.ConfigurationFileFormat);
  311. return configurationFileFormat.Version != 0;
  312. }
  313. catch
  314. {
  315. configurationFileFormat = null;
  316. return false;
  317. }
  318. }
  319. /// <summary>
  320. /// Save a configuration file to disk
  321. /// </summary>
  322. /// <param name="path">The path to the JSON configuration file</param>
  323. public void SaveConfig(string path)
  324. {
  325. JsonHelper.SerializeToFile(path, this, ConfigurationFileFormatSettings.SerializerContext.ConfigurationFileFormat);
  326. }
  327. }
  328. }