ConfigurationFileFormat.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  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.Ui.Common.Configuration.System;
  7. using Ryujinx.Ui.Common.Configuration.Ui;
  8. using System.Collections.Generic;
  9. using System.Text.Json.Nodes;
  10. namespace Ryujinx.Ui.Common.Configuration
  11. {
  12. public class ConfigurationFileFormat
  13. {
  14. /// <summary>
  15. /// The current version of the file format
  16. /// </summary>
  17. public const int CurrentVersion = 48;
  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. /// Whether to hide cursor on idle, always or never
  136. /// </summary>
  137. public HideCursorMode HideCursor { get; set; }
  138. /// <summary>
  139. /// Enables or disables Vertical Sync
  140. /// </summary>
  141. public bool EnableVsync { get; set; }
  142. /// <summary>
  143. /// Enables or disables Shader cache
  144. /// </summary>
  145. public bool EnableShaderCache { get; set; }
  146. /// <summary>
  147. /// Enables or disables texture recompression
  148. /// </summary>
  149. public bool EnableTextureRecompression { get; set; }
  150. /// <summary>
  151. /// Enables or disables Macro high-level emulation
  152. /// </summary>
  153. public bool EnableMacroHLE { get; set; }
  154. /// <summary>
  155. /// Enables or disables color space passthrough, if available.
  156. /// </summary>
  157. public bool EnableColorSpacePassthrough { get; set; }
  158. /// <summary>
  159. /// Enables or disables profiled translation cache persistency
  160. /// </summary>
  161. public bool EnablePtc { get; set; }
  162. /// <summary>
  163. /// Enables or disables guest Internet access
  164. /// </summary>
  165. public bool EnableInternetAccess { get; set; }
  166. /// <summary>
  167. /// Enables integrity checks on Game content files
  168. /// </summary>
  169. public bool EnableFsIntegrityChecks { get; set; }
  170. /// <summary>
  171. /// Enables FS access log output to the console. Possible modes are 0-3
  172. /// </summary>
  173. public int FsGlobalAccessLogMode { get; set; }
  174. /// <summary>
  175. /// The selected audio backend
  176. /// </summary>
  177. public AudioBackend AudioBackend { get; set; }
  178. /// <summary>
  179. /// The audio volume
  180. /// </summary>
  181. public float AudioVolume { get; set; }
  182. /// <summary>
  183. /// The selected memory manager mode
  184. /// </summary>
  185. public MemoryManagerMode MemoryManagerMode { get; set; }
  186. /// <summary>
  187. /// Expands the RAM amount on the emulated system from 4GiB to 6GiB
  188. /// </summary>
  189. public bool ExpandRam { get; set; }
  190. /// <summary>
  191. /// Enable or disable ignoring missing services
  192. /// </summary>
  193. public bool IgnoreMissingServices { get; set; }
  194. /// <summary>
  195. /// Used to toggle columns in the GUI
  196. /// </summary>
  197. public GuiColumns GuiColumns { get; set; }
  198. /// <summary>
  199. /// Used to configure column sort settings in the GUI
  200. /// </summary>
  201. public ColumnSort ColumnSort { get; set; }
  202. /// <summary>
  203. /// A list of directories containing games to be used to load games into the games list
  204. /// </summary>
  205. public List<string> GameDirs { get; set; }
  206. /// <summary>
  207. /// A list of file types to be hidden in the games List
  208. /// </summary>
  209. public ShownFileTypes ShownFileTypes { get; set; }
  210. /// <summary>
  211. /// Main window start-up position, size and state
  212. /// </summary>
  213. public WindowStartup WindowStartup { get; set; }
  214. /// <summary>
  215. /// Language Code for the UI
  216. /// </summary>
  217. public string LanguageCode { get; set; }
  218. /// <summary>
  219. /// Enable or disable custom themes in the GUI
  220. /// </summary>
  221. public bool EnableCustomTheme { get; set; }
  222. /// <summary>
  223. /// Path to custom GUI theme
  224. /// </summary>
  225. public string CustomThemePath { get; set; }
  226. /// <summary>
  227. /// Chooses the base style // Not Used
  228. /// </summary>
  229. public string BaseStyle { get; set; }
  230. /// <summary>
  231. /// Chooses the view mode of the game list // Not Used
  232. /// </summary>
  233. public int GameListViewMode { get; set; }
  234. /// <summary>
  235. /// Show application name in Grid Mode // Not Used
  236. /// </summary>
  237. public bool ShowNames { get; set; }
  238. /// <summary>
  239. /// Sets App Icon Size // Not Used
  240. /// </summary>
  241. public int GridSize { get; set; }
  242. /// <summary>
  243. /// Sorts Apps in the game list // Not Used
  244. /// </summary>
  245. public int ApplicationSort { get; set; }
  246. /// <summary>
  247. /// Sets if Grid is ordered in Ascending Order // Not Used
  248. /// </summary>
  249. public bool IsAscendingOrder { get; set; }
  250. /// <summary>
  251. /// Start games in fullscreen mode
  252. /// </summary>
  253. public bool StartFullscreen { get; set; }
  254. /// <summary>
  255. /// Show console window
  256. /// </summary>
  257. public bool ShowConsole { get; set; }
  258. /// <summary>
  259. /// Enable or disable keyboard support (Independent from controllers binding)
  260. /// </summary>
  261. public bool EnableKeyboard { get; set; }
  262. /// <summary>
  263. /// Enable or disable mouse support (Independent from controllers binding)
  264. /// </summary>
  265. public bool EnableMouse { get; set; }
  266. /// <summary>
  267. /// Hotkey Keyboard Bindings
  268. /// </summary>
  269. public KeyboardHotkeys Hotkeys { get; set; }
  270. /// <summary>
  271. /// Legacy keyboard control bindings
  272. /// </summary>
  273. /// <remarks>Kept for file format compatibility (to avoid possible failure when parsing configuration on old versions)</remarks>
  274. /// TODO: Remove this when those older versions aren't in use anymore.
  275. public List<JsonObject> KeyboardConfig { get; set; }
  276. /// <summary>
  277. /// Legacy controller control bindings
  278. /// </summary>
  279. /// <remarks>Kept for file format compatibility (to avoid possible failure when parsing configuration on old versions)</remarks>
  280. /// TODO: Remove this when those older versions aren't in use anymore.
  281. public List<JsonObject> ControllerConfig { get; set; }
  282. /// <summary>
  283. /// Input configurations
  284. /// </summary>
  285. public List<InputConfig> InputConfig { get; set; }
  286. /// <summary>
  287. /// Graphics backend
  288. /// </summary>
  289. public GraphicsBackend GraphicsBackend { get; set; }
  290. /// <summary>
  291. /// Preferred GPU
  292. /// </summary>
  293. public string PreferredGpu { get; set; }
  294. /// <summary>
  295. /// Multiplayer Mode
  296. /// </summary>
  297. public MultiplayerMode MultiplayerMode { get; set; }
  298. /// <summary>
  299. /// GUID for the network interface used by LAN (or 0 for default)
  300. /// </summary>
  301. public string MultiplayerLanInterfaceId { get; set; }
  302. /// <summary>
  303. /// Uses Hypervisor over JIT if available
  304. /// </summary>
  305. public bool UseHypervisor { get; set; }
  306. /// <summary>
  307. /// Loads a configuration file from disk
  308. /// </summary>
  309. /// <param name="path">The path to the JSON configuration file</param>
  310. /// <param name="configurationFileFormat">Parsed configuration file</param>
  311. public static bool TryLoad(string path, out ConfigurationFileFormat configurationFileFormat)
  312. {
  313. try
  314. {
  315. configurationFileFormat = JsonHelper.DeserializeFromFile(path, ConfigurationFileFormatSettings.SerializerContext.ConfigurationFileFormat);
  316. return configurationFileFormat.Version != 0;
  317. }
  318. catch
  319. {
  320. configurationFileFormat = null;
  321. return false;
  322. }
  323. }
  324. /// <summary>
  325. /// Save a configuration file to disk
  326. /// </summary>
  327. /// <param name="path">The path to the JSON configuration file</param>
  328. public void SaveConfig(string path)
  329. {
  330. JsonHelper.SerializeToFile(path, this, ConfigurationFileFormatSettings.SerializerContext.ConfigurationFileFormat);
  331. }
  332. }
  333. }