ConfigurationFileFormat.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. using System.Collections.Generic;
  2. using System.IO;
  3. using Ryujinx.Common.Configuration;
  4. using Ryujinx.Common.Configuration.Hid;
  5. using Ryujinx.Common.Logging;
  6. using Ryujinx.Common.Utilities;
  7. using Ryujinx.Configuration.System;
  8. using Ryujinx.Configuration.Ui;
  9. namespace Ryujinx.Configuration
  10. {
  11. public class ConfigurationFileFormat
  12. {
  13. /// <summary>
  14. /// The current version of the file format
  15. /// </summary>
  16. public const int CurrentVersion = 35;
  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 guest log messages
  71. /// </summary>
  72. public bool LoggingEnableGuest { get; set; }
  73. /// <summary>
  74. /// Enables printing FS access log messages
  75. /// </summary>
  76. public bool LoggingEnableFsAccessLog { get; set; }
  77. /// <summary>
  78. /// Controls which log messages are written to the log targets
  79. /// </summary>
  80. public LogClass[] LoggingFilteredClasses { get; set; }
  81. /// <summary>
  82. /// Change Graphics API debug log level
  83. /// </summary>
  84. public GraphicsDebugLevel LoggingGraphicsDebugLevel { get; set; }
  85. /// <summary>
  86. /// Change System Language
  87. /// </summary>
  88. public Language SystemLanguage { get; set; }
  89. /// <summary>
  90. /// Change System Region
  91. /// </summary>
  92. public Region SystemRegion { get; set; }
  93. /// <summary>
  94. /// Change System TimeZone
  95. /// </summary>
  96. public string SystemTimeZone { get; set; }
  97. /// <summary>
  98. /// Change System Time Offset in seconds
  99. /// </summary>
  100. public long SystemTimeOffset { get; set; }
  101. /// <summary>
  102. /// Enables or disables Docked Mode
  103. /// </summary>
  104. public bool DockedMode { get; set; }
  105. /// <summary>
  106. /// Enables or disables Discord Rich Presence
  107. /// </summary>
  108. public bool EnableDiscordIntegration { get; set; }
  109. /// <summary>
  110. /// Checks for updates when Ryujinx starts when enabled
  111. /// </summary>
  112. public bool CheckUpdatesOnStart { get; set; }
  113. /// <summary>
  114. /// Show "Confirm Exit" Dialog
  115. /// </summary>
  116. public bool ShowConfirmExit { get; set; }
  117. /// <summary>
  118. /// Hide Cursor on Idle
  119. /// </summary>
  120. public bool HideCursorOnIdle { get; set; }
  121. /// <summary>
  122. /// Enables or disables Vertical Sync
  123. /// </summary>
  124. public bool EnableVsync { get; set; }
  125. /// <summary>
  126. /// Enables or disables Shader cache
  127. /// </summary>
  128. public bool EnableShaderCache { get; set; }
  129. /// <summary>
  130. /// Enables or disables profiled translation cache persistency
  131. /// </summary>
  132. public bool EnablePtc { get; set; }
  133. /// <summary>
  134. /// Enables or disables guest Internet access
  135. /// </summary>
  136. public bool EnableInternetAccess { get; set; }
  137. /// <summary>
  138. /// Enables integrity checks on Game content files
  139. /// </summary>
  140. public bool EnableFsIntegrityChecks { get; set; }
  141. /// <summary>
  142. /// Enables FS access log output to the console. Possible modes are 0-3
  143. /// </summary>
  144. public int FsGlobalAccessLogMode { get; set; }
  145. /// <summary>
  146. /// The selected audio backend
  147. /// </summary>
  148. public AudioBackend AudioBackend { get; set; }
  149. /// <summary>
  150. /// The audio volume
  151. /// </summary>
  152. public float AudioVolume { get; set; }
  153. /// <summary>
  154. /// The selected memory manager mode
  155. /// </summary>
  156. public MemoryManagerMode MemoryManagerMode { get; set; }
  157. /// <summary>
  158. /// Expands the RAM amount on the emulated system from 4GB to 6GB
  159. /// </summary>
  160. public bool ExpandRam { get; set; }
  161. /// <summary>
  162. /// Enable or disable ignoring missing services
  163. /// </summary>
  164. public bool IgnoreMissingServices { get; set; }
  165. /// <summary>
  166. /// Used to toggle columns in the GUI
  167. /// </summary>
  168. public GuiColumns GuiColumns { get; set; }
  169. /// <summary>
  170. /// Used to configure column sort settings in the GUI
  171. /// </summary>
  172. public ColumnSort ColumnSort { get; set; }
  173. /// <summary>
  174. /// A list of directories containing games to be used to load games into the games list
  175. /// </summary>
  176. public List<string> GameDirs { get; set; }
  177. /// <summary>
  178. /// Enable or disable custom themes in the GUI
  179. /// </summary>
  180. public bool EnableCustomTheme { get; set; }
  181. /// <summary>
  182. /// Path to custom GUI theme
  183. /// </summary>
  184. public string CustomThemePath { get; set; }
  185. /// <summary>
  186. /// Start games in fullscreen mode
  187. /// </summary>
  188. public bool StartFullscreen { get; set; }
  189. /// <summary>
  190. /// Enable or disable keyboard support (Independent from controllers binding)
  191. /// </summary>
  192. public bool EnableKeyboard { get; set; }
  193. /// <summary>
  194. /// Enable or disable mouse support (Independent from controllers binding)
  195. /// </summary>
  196. public bool EnableMouse { get; set; }
  197. /// <summary>
  198. /// Hotkey Keyboard Bindings
  199. /// </summary>
  200. public KeyboardHotkeys Hotkeys { get; set; }
  201. /// <summary>
  202. /// Legacy keyboard control bindings
  203. /// </summary>
  204. /// <remarks>Kept for file format compatibility (to avoid possible failure when parsing configuration on old versions)</remarks>
  205. /// TODO: Remove this when those older versions aren't in use anymore.
  206. public List<object> KeyboardConfig { get; set; }
  207. /// <summary>
  208. /// Legacy controller control bindings
  209. /// </summary>
  210. /// <remarks>Kept for file format compatibility (to avoid possible failure when parsing configuration on old versions)</remarks>
  211. /// TODO: Remove this when those older versions aren't in use anymore.
  212. public List<object> ControllerConfig { get; set; }
  213. /// <summary>
  214. /// Input configurations
  215. /// </summary>
  216. public List<InputConfig> InputConfig { get; set; }
  217. /// <summary>
  218. /// Loads a configuration file from disk
  219. /// </summary>
  220. /// <param name="path">The path to the JSON configuration file</param>
  221. public static bool TryLoad(string path, out ConfigurationFileFormat configurationFileFormat)
  222. {
  223. try
  224. {
  225. configurationFileFormat = JsonHelper.DeserializeFromFile<ConfigurationFileFormat>(path);
  226. return true;
  227. }
  228. catch
  229. {
  230. configurationFileFormat = null;
  231. return false;
  232. }
  233. }
  234. /// <summary>
  235. /// Save a configuration file to disk
  236. /// </summary>
  237. /// <param name="path">The path to the JSON configuration file</param>
  238. public void SaveConfig(string path)
  239. {
  240. using FileStream fileStream = File.Create(path, 4096, FileOptions.WriteThrough);
  241. JsonHelper.Serialize(fileStream, this, true);
  242. }
  243. }
  244. }