ConfigurationFileFormat.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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.IO;
  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 = 41;
  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. /// Dumps shaders in this local directory
  47. /// </summary>
  48. public string GraphicsShadersDumpPath { get; set; }
  49. /// <summary>
  50. /// Enables printing debug log messages
  51. /// </summary>
  52. public bool LoggingEnableDebug { get; set; }
  53. /// <summary>
  54. /// Enables printing stub log messages
  55. /// </summary>
  56. public bool LoggingEnableStub { get; set; }
  57. /// <summary>
  58. /// Enables printing info log messages
  59. /// </summary>
  60. public bool LoggingEnableInfo { get; set; }
  61. /// <summary>
  62. /// Enables printing warning log messages
  63. /// </summary>
  64. public bool LoggingEnableWarn { get; set; }
  65. /// <summary>
  66. /// Enables printing error log messages
  67. /// </summary>
  68. public bool LoggingEnableError { get; set; }
  69. /// <summary>
  70. /// Enables printing trace log messages
  71. /// </summary>
  72. public bool LoggingEnableTrace { get; set; }
  73. /// <summary>
  74. /// Enables printing guest log messages
  75. /// </summary>
  76. public bool LoggingEnableGuest { get; set; }
  77. /// <summary>
  78. /// Enables printing FS access log messages
  79. /// </summary>
  80. public bool LoggingEnableFsAccessLog { get; set; }
  81. /// <summary>
  82. /// Controls which log messages are written to the log targets
  83. /// </summary>
  84. public LogClass[] LoggingFilteredClasses { get; set; }
  85. /// <summary>
  86. /// Change Graphics API debug log level
  87. /// </summary>
  88. public GraphicsDebugLevel LoggingGraphicsDebugLevel { get; set; }
  89. /// <summary>
  90. /// Change System Language
  91. /// </summary>
  92. public Language SystemLanguage { get; set; }
  93. /// <summary>
  94. /// Change System Region
  95. /// </summary>
  96. public Region SystemRegion { get; set; }
  97. /// <summary>
  98. /// Change System TimeZone
  99. /// </summary>
  100. public string SystemTimeZone { get; set; }
  101. /// <summary>
  102. /// Change System Time Offset in seconds
  103. /// </summary>
  104. public long SystemTimeOffset { get; set; }
  105. /// <summary>
  106. /// Enables or disables Docked Mode
  107. /// </summary>
  108. public bool DockedMode { get; set; }
  109. /// <summary>
  110. /// Enables or disables Discord Rich Presence
  111. /// </summary>
  112. public bool EnableDiscordIntegration { get; set; }
  113. /// <summary>
  114. /// Checks for updates when Ryujinx starts when enabled
  115. /// </summary>
  116. public bool CheckUpdatesOnStart { get; set; }
  117. /// <summary>
  118. /// Show "Confirm Exit" Dialog
  119. /// </summary>
  120. public bool ShowConfirmExit { get; set; }
  121. /// <summary>
  122. /// Hide Cursor on Idle
  123. /// </summary>
  124. public bool HideCursorOnIdle { get; set; }
  125. /// <summary>
  126. /// Enables or disables Vertical Sync
  127. /// </summary>
  128. public bool EnableVsync { get; set; }
  129. /// <summary>
  130. /// Enables or disables Shader cache
  131. /// </summary>
  132. public bool EnableShaderCache { get; set; }
  133. /// <summary>
  134. /// Enables or disables texture recompression
  135. /// </summary>
  136. public bool EnableTextureRecompression { get; set; }
  137. /// <summary>
  138. /// Enables or disables profiled translation cache persistency
  139. /// </summary>
  140. public bool EnablePtc { get; set; }
  141. /// <summary>
  142. /// Enables or disables guest Internet access
  143. /// </summary>
  144. public bool EnableInternetAccess { get; set; }
  145. /// <summary>
  146. /// Enables integrity checks on Game content files
  147. /// </summary>
  148. public bool EnableFsIntegrityChecks { get; set; }
  149. /// <summary>
  150. /// Enables FS access log output to the console. Possible modes are 0-3
  151. /// </summary>
  152. public int FsGlobalAccessLogMode { get; set; }
  153. /// <summary>
  154. /// The selected audio backend
  155. /// </summary>
  156. public AudioBackend AudioBackend { get; set; }
  157. /// <summary>
  158. /// The audio volume
  159. /// </summary>
  160. public float AudioVolume { get; set; }
  161. /// <summary>
  162. /// The selected memory manager mode
  163. /// </summary>
  164. public MemoryManagerMode MemoryManagerMode { get; set; }
  165. /// <summary>
  166. /// Expands the RAM amount on the emulated system from 4GB to 6GB
  167. /// </summary>
  168. public bool ExpandRam { get; set; }
  169. /// <summary>
  170. /// Enable or disable ignoring missing services
  171. /// </summary>
  172. public bool IgnoreMissingServices { get; set; }
  173. /// <summary>
  174. /// Used to toggle columns in the GUI
  175. /// </summary>
  176. public GuiColumns GuiColumns { get; set; }
  177. /// <summary>
  178. /// Used to configure column sort settings in the GUI
  179. /// </summary>
  180. public ColumnSort ColumnSort { get; set; }
  181. /// <summary>
  182. /// A list of directories containing games to be used to load games into the games list
  183. /// </summary>
  184. public List<string> GameDirs { get; set; }
  185. /// <summary>
  186. /// Language Code for the UI
  187. /// </summary>
  188. public string LanguageCode { get; set; }
  189. /// <summary>
  190. /// Enable or disable custom themes in the GUI
  191. /// </summary>
  192. public bool EnableCustomTheme { get; set; }
  193. /// <summary>
  194. /// Path to custom GUI theme
  195. /// </summary>
  196. public string CustomThemePath { get; set; }
  197. /// <summary>
  198. /// Chooses the base style // Not Used
  199. /// </summary>
  200. public string BaseStyle { get; set; }
  201. /// <summary>
  202. /// Chooses the view mode of the game list // Not Used
  203. /// </summary>
  204. public int GameListViewMode { get; set; }
  205. /// <summary>
  206. /// Show application name in Grid Mode // Not Used
  207. /// </summary>
  208. public bool ShowNames { get; set; }
  209. /// <summary>
  210. /// Sets App Icon Size // Not Used
  211. /// </summary>
  212. public int GridSize { get; set; }
  213. /// <summary>
  214. /// Sorts Apps in the game list // Not Used
  215. /// </summary>
  216. public int ApplicationSort { get; set; }
  217. /// <summary>
  218. /// Sets if Grid is ordered in Ascending Order // Not Used
  219. /// </summary>
  220. public bool IsAscendingOrder { get; set; }
  221. /// <summary>
  222. /// Start games in fullscreen mode
  223. /// </summary>
  224. public bool StartFullscreen { get; set; }
  225. /// <summary>
  226. /// Show console window
  227. /// </summary>
  228. public bool ShowConsole { get; set; }
  229. /// <summary>
  230. /// Enable or disable keyboard support (Independent from controllers binding)
  231. /// </summary>
  232. public bool EnableKeyboard { get; set; }
  233. /// <summary>
  234. /// Enable or disable mouse support (Independent from controllers binding)
  235. /// </summary>
  236. public bool EnableMouse { get; set; }
  237. /// <summary>
  238. /// Hotkey Keyboard Bindings
  239. /// </summary>
  240. public KeyboardHotkeys Hotkeys { get; set; }
  241. /// <summary>
  242. /// Legacy keyboard control bindings
  243. /// </summary>
  244. /// <remarks>Kept for file format compatibility (to avoid possible failure when parsing configuration on old versions)</remarks>
  245. /// TODO: Remove this when those older versions aren't in use anymore.
  246. public List<object> KeyboardConfig { get; set; }
  247. /// <summary>
  248. /// Legacy controller control bindings
  249. /// </summary>
  250. /// <remarks>Kept for file format compatibility (to avoid possible failure when parsing configuration on old versions)</remarks>
  251. /// TODO: Remove this when those older versions aren't in use anymore.
  252. public List<object> ControllerConfig { get; set; }
  253. /// <summary>
  254. /// Input configurations
  255. /// </summary>
  256. public List<InputConfig> InputConfig { get; set; }
  257. /// <summary>
  258. /// Graphics backend
  259. /// </summary>
  260. public GraphicsBackend GraphicsBackend { get; set; }
  261. /// <summary>
  262. /// Preferred GPU
  263. /// </summary>
  264. public string PreferredGpu { get; set; }
  265. /// <summary>
  266. /// Loads a configuration file from disk
  267. /// </summary>
  268. /// <param name="path">The path to the JSON configuration file</param>
  269. public static bool TryLoad(string path, out ConfigurationFileFormat configurationFileFormat)
  270. {
  271. try
  272. {
  273. configurationFileFormat = JsonHelper.DeserializeFromFile<ConfigurationFileFormat>(path);
  274. return true;
  275. }
  276. catch
  277. {
  278. configurationFileFormat = null;
  279. return false;
  280. }
  281. }
  282. /// <summary>
  283. /// Save a configuration file to disk
  284. /// </summary>
  285. /// <param name="path">The path to the JSON configuration file</param>
  286. public void SaveConfig(string path)
  287. {
  288. using FileStream fileStream = File.Create(path, 4096, FileOptions.WriteThrough);
  289. JsonHelper.Serialize(fileStream, this, true);
  290. }
  291. }
  292. }