ConfigurationFileFormat.cs 14 KB

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