ConfigurationFileFormat.cs 15 KB

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