ConfigurationFileFormat.cs 15 KB

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