ConfigurationState.cs 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258
  1. using Ryujinx.Common;
  2. using Ryujinx.Common.Configuration;
  3. using Ryujinx.Common.Configuration.Hid;
  4. using Ryujinx.Common.Configuration.Hid.Controller;
  5. using Ryujinx.Common.Configuration.Hid.Keyboard;
  6. using Ryujinx.Common.Logging;
  7. using Ryujinx.Ui.Common.Configuration.System;
  8. using Ryujinx.Ui.Common.Configuration.Ui;
  9. using Ryujinx.Ui.Common.Helper;
  10. using System;
  11. using System.Collections.Generic;
  12. namespace Ryujinx.Ui.Common.Configuration
  13. {
  14. public class ConfigurationState
  15. {
  16. /// <summary>
  17. /// UI configuration section
  18. /// </summary>
  19. public class UiSection
  20. {
  21. public class Columns
  22. {
  23. public ReactiveObject<bool> FavColumn { get; private set; }
  24. public ReactiveObject<bool> IconColumn { get; private set; }
  25. public ReactiveObject<bool> AppColumn { get; private set; }
  26. public ReactiveObject<bool> DevColumn { get; private set; }
  27. public ReactiveObject<bool> VersionColumn { get; private set; }
  28. public ReactiveObject<bool> TimePlayedColumn { get; private set; }
  29. public ReactiveObject<bool> LastPlayedColumn { get; private set; }
  30. public ReactiveObject<bool> FileExtColumn { get; private set; }
  31. public ReactiveObject<bool> FileSizeColumn { get; private set; }
  32. public ReactiveObject<bool> PathColumn { get; private set; }
  33. public Columns()
  34. {
  35. FavColumn = new ReactiveObject<bool>();
  36. IconColumn = new ReactiveObject<bool>();
  37. AppColumn = new ReactiveObject<bool>();
  38. DevColumn = new ReactiveObject<bool>();
  39. VersionColumn = new ReactiveObject<bool>();
  40. TimePlayedColumn = new ReactiveObject<bool>();
  41. LastPlayedColumn = new ReactiveObject<bool>();
  42. FileExtColumn = new ReactiveObject<bool>();
  43. FileSizeColumn = new ReactiveObject<bool>();
  44. PathColumn = new ReactiveObject<bool>();
  45. }
  46. }
  47. public class ColumnSortSettings
  48. {
  49. public ReactiveObject<int> SortColumnId { get; private set; }
  50. public ReactiveObject<bool> SortAscending { get; private set; }
  51. public ColumnSortSettings()
  52. {
  53. SortColumnId = new ReactiveObject<int>();
  54. SortAscending = new ReactiveObject<bool>();
  55. }
  56. }
  57. /// <summary>
  58. /// Used to toggle columns in the GUI
  59. /// </summary>
  60. public Columns GuiColumns { get; private set; }
  61. /// <summary>
  62. /// Used to configure column sort settings in the GUI
  63. /// </summary>
  64. public ColumnSortSettings ColumnSort { get; private set; }
  65. /// <summary>
  66. /// A list of directories containing games to be used to load games into the games list
  67. /// </summary>
  68. public ReactiveObject<List<string>> GameDirs { get; private set; }
  69. /// <summary>
  70. /// Language Code for the UI
  71. /// </summary>
  72. public ReactiveObject<string> LanguageCode { get; private set; }
  73. /// <summary>
  74. /// Enable or disable custom themes in the GUI
  75. /// </summary>
  76. public ReactiveObject<bool> EnableCustomTheme { get; private set; }
  77. /// <summary>
  78. /// Path to custom GUI theme
  79. /// </summary>
  80. public ReactiveObject<string> CustomThemePath { get; private set; }
  81. /// <summary>
  82. /// Selects the base style
  83. /// </summary>
  84. public ReactiveObject<string> BaseStyle { get; private set; }
  85. /// <summary>
  86. /// Start games in fullscreen mode
  87. /// </summary>
  88. public ReactiveObject<bool> StartFullscreen { get; private set; }
  89. /// <summary>
  90. /// Hide / Show Console Window
  91. /// </summary>
  92. public ReactiveObject<bool> ShowConsole { get; private set; }
  93. /// <summary>
  94. /// View Mode of the Game list
  95. /// </summary>
  96. public ReactiveObject<int> GameListViewMode { get; private set; }
  97. /// <summary>
  98. /// Show application name in Grid Mode
  99. /// </summary>
  100. public ReactiveObject<bool> ShowNames { get; private set; }
  101. /// <summary>
  102. /// Sets App Icon Size in Grid Mode
  103. /// </summary>
  104. public ReactiveObject<int> GridSize { get; private set; }
  105. /// <summary>
  106. /// Sorts Apps in Grid Mode
  107. /// </summary>
  108. public ReactiveObject<int> ApplicationSort { get; private set; }
  109. /// <summary>
  110. /// Sets if Grid is ordered in Ascending Order
  111. /// </summary>
  112. public ReactiveObject<bool> IsAscendingOrder { get; private set; }
  113. public UiSection()
  114. {
  115. GuiColumns = new Columns();
  116. ColumnSort = new ColumnSortSettings();
  117. GameDirs = new ReactiveObject<List<string>>();
  118. EnableCustomTheme = new ReactiveObject<bool>();
  119. CustomThemePath = new ReactiveObject<string>();
  120. BaseStyle = new ReactiveObject<string>();
  121. StartFullscreen = new ReactiveObject<bool>();
  122. GameListViewMode = new ReactiveObject<int>();
  123. ShowNames = new ReactiveObject<bool>();
  124. GridSize = new ReactiveObject<int>();
  125. ApplicationSort = new ReactiveObject<int>();
  126. IsAscendingOrder = new ReactiveObject<bool>();
  127. LanguageCode = new ReactiveObject<string>();
  128. ShowConsole = new ReactiveObject<bool>();
  129. ShowConsole.Event += static (s, e) => { ConsoleHelper.SetConsoleWindowState(e.NewValue); };
  130. }
  131. }
  132. /// <summary>
  133. /// Logger configuration section
  134. /// </summary>
  135. public class LoggerSection
  136. {
  137. /// <summary>
  138. /// Enables printing debug log messages
  139. /// </summary>
  140. public ReactiveObject<bool> EnableDebug { get; private set; }
  141. /// <summary>
  142. /// Enables printing stub log messages
  143. /// </summary>
  144. public ReactiveObject<bool> EnableStub { get; private set; }
  145. /// <summary>
  146. /// Enables printing info log messages
  147. /// </summary>
  148. public ReactiveObject<bool> EnableInfo { get; private set; }
  149. /// <summary>
  150. /// Enables printing warning log messages
  151. /// </summary>
  152. public ReactiveObject<bool> EnableWarn { get; private set; }
  153. /// <summary>
  154. /// Enables printing error log messages
  155. /// </summary>
  156. public ReactiveObject<bool> EnableError { get; private set; }
  157. /// <summary>
  158. /// Enables printing trace log messages
  159. /// </summary>
  160. public ReactiveObject<bool> EnableTrace { get; private set; }
  161. /// <summary>
  162. /// Enables printing guest log messages
  163. /// </summary>
  164. public ReactiveObject<bool> EnableGuest { get; private set; }
  165. /// <summary>
  166. /// Enables printing FS access log messages
  167. /// </summary>
  168. public ReactiveObject<bool> EnableFsAccessLog { get; private set; }
  169. /// <summary>
  170. /// Controls which log messages are written to the log targets
  171. /// </summary>
  172. public ReactiveObject<LogClass[]> FilteredClasses { get; private set; }
  173. /// <summary>
  174. /// Enables or disables logging to a file on disk
  175. /// </summary>
  176. public ReactiveObject<bool> EnableFileLog { get; private set; }
  177. /// <summary>
  178. /// Controls which OpenGL log messages are recorded in the log
  179. /// </summary>
  180. public ReactiveObject<GraphicsDebugLevel> GraphicsDebugLevel { get; private set; }
  181. public LoggerSection()
  182. {
  183. EnableDebug = new ReactiveObject<bool>();
  184. EnableStub = new ReactiveObject<bool>();
  185. EnableInfo = new ReactiveObject<bool>();
  186. EnableWarn = new ReactiveObject<bool>();
  187. EnableError = new ReactiveObject<bool>();
  188. EnableTrace = new ReactiveObject<bool>();
  189. EnableGuest = new ReactiveObject<bool>();
  190. EnableFsAccessLog = new ReactiveObject<bool>();
  191. FilteredClasses = new ReactiveObject<LogClass[]>();
  192. EnableFileLog = new ReactiveObject<bool>();
  193. EnableFileLog.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableFileLog));
  194. GraphicsDebugLevel = new ReactiveObject<GraphicsDebugLevel>();
  195. }
  196. }
  197. /// <summary>
  198. /// System configuration section
  199. /// </summary>
  200. public class SystemSection
  201. {
  202. /// <summary>
  203. /// Change System Language
  204. /// </summary>
  205. public ReactiveObject<Language> Language { get; private set; }
  206. /// <summary>
  207. /// Change System Region
  208. /// </summary>
  209. public ReactiveObject<Region> Region { get; private set; }
  210. /// <summary>
  211. /// Change System TimeZone
  212. /// </summary>
  213. public ReactiveObject<string> TimeZone { get; private set; }
  214. /// <summary>
  215. /// System Time Offset in Seconds
  216. /// </summary>
  217. public ReactiveObject<long> SystemTimeOffset { get; private set; }
  218. /// <summary>
  219. /// Enables or disables Docked Mode
  220. /// </summary>
  221. public ReactiveObject<bool> EnableDockedMode { get; private set; }
  222. /// <summary>
  223. /// Enables or disables profiled translation cache persistency
  224. /// </summary>
  225. public ReactiveObject<bool> EnablePtc { get; private set; }
  226. /// <summary>
  227. /// Enables or disables guest Internet access
  228. /// </summary>
  229. public ReactiveObject<bool> EnableInternetAccess { get; private set; }
  230. /// <summary>
  231. /// Enables integrity checks on Game content files
  232. /// </summary>
  233. public ReactiveObject<bool> EnableFsIntegrityChecks { get; private set; }
  234. /// <summary>
  235. /// Enables FS access log output to the console. Possible modes are 0-3
  236. /// </summary>
  237. public ReactiveObject<int> FsGlobalAccessLogMode { get; private set; }
  238. /// <summary>
  239. /// The selected audio backend
  240. /// </summary>
  241. public ReactiveObject<AudioBackend> AudioBackend { get; private set; }
  242. /// <summary>
  243. /// The audio backend volume
  244. /// </summary>
  245. public ReactiveObject<float> AudioVolume { get; private set; }
  246. /// <summary>
  247. /// The selected memory manager mode
  248. /// </summary>
  249. public ReactiveObject<MemoryManagerMode> MemoryManagerMode { get; private set; }
  250. /// <summary>
  251. /// Defines the amount of RAM available on the emulated system, and how it is distributed
  252. /// </summary>
  253. public ReactiveObject<bool> ExpandRam { get; private set; }
  254. /// <summary>
  255. /// Enable or disable ignoring missing services
  256. /// </summary>
  257. public ReactiveObject<bool> IgnoreMissingServices { get; private set; }
  258. public SystemSection()
  259. {
  260. Language = new ReactiveObject<Language>();
  261. Region = new ReactiveObject<Region>();
  262. TimeZone = new ReactiveObject<string>();
  263. SystemTimeOffset = new ReactiveObject<long>();
  264. EnableDockedMode = new ReactiveObject<bool>();
  265. EnableDockedMode.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableDockedMode));
  266. EnablePtc = new ReactiveObject<bool>();
  267. EnablePtc.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnablePtc));
  268. EnableInternetAccess = new ReactiveObject<bool>();
  269. EnableInternetAccess.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableInternetAccess));
  270. EnableFsIntegrityChecks = new ReactiveObject<bool>();
  271. EnableFsIntegrityChecks.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableFsIntegrityChecks));
  272. FsGlobalAccessLogMode = new ReactiveObject<int>();
  273. FsGlobalAccessLogMode.Event += static (sender, e) => LogValueChange(sender, e, nameof(FsGlobalAccessLogMode));
  274. AudioBackend = new ReactiveObject<AudioBackend>();
  275. AudioBackend.Event += static (sender, e) => LogValueChange(sender, e, nameof(AudioBackend));
  276. MemoryManagerMode = new ReactiveObject<MemoryManagerMode>();
  277. MemoryManagerMode.Event += static (sender, e) => LogValueChange(sender, e, nameof(MemoryManagerMode));
  278. ExpandRam = new ReactiveObject<bool>();
  279. ExpandRam.Event += static (sender, e) => LogValueChange(sender, e, nameof(ExpandRam));
  280. IgnoreMissingServices = new ReactiveObject<bool>();
  281. IgnoreMissingServices.Event += static (sender, e) => LogValueChange(sender, e, nameof(IgnoreMissingServices));
  282. AudioVolume = new ReactiveObject<float>();
  283. AudioVolume.Event += static (sender, e) => LogValueChange(sender, e, nameof(AudioVolume));
  284. }
  285. }
  286. /// <summary>
  287. /// Hid configuration section
  288. /// </summary>
  289. public class HidSection
  290. {
  291. /// <summary>
  292. /// Enable or disable keyboard support (Independent from controllers binding)
  293. /// </summary>
  294. public ReactiveObject<bool> EnableKeyboard { get; private set; }
  295. /// <summary>
  296. /// Enable or disable mouse support (Independent from controllers binding)
  297. /// </summary>
  298. public ReactiveObject<bool> EnableMouse { get; private set; }
  299. /// <summary>
  300. /// Hotkey Keyboard Bindings
  301. /// </summary>
  302. public ReactiveObject<KeyboardHotkeys> Hotkeys { get; private set; }
  303. /// <summary>
  304. /// Input device configuration.
  305. /// NOTE: This ReactiveObject won't issue an event when the List has elements added or removed.
  306. /// TODO: Implement a ReactiveList class.
  307. /// </summary>
  308. public ReactiveObject<List<InputConfig>> InputConfig { get; private set; }
  309. public HidSection()
  310. {
  311. EnableKeyboard = new ReactiveObject<bool>();
  312. EnableMouse = new ReactiveObject<bool>();
  313. Hotkeys = new ReactiveObject<KeyboardHotkeys>();
  314. InputConfig = new ReactiveObject<List<InputConfig>>();
  315. }
  316. }
  317. /// <summary>
  318. /// Graphics configuration section
  319. /// </summary>
  320. public class GraphicsSection
  321. {
  322. /// <summary>
  323. /// Whether or not backend threading is enabled. The "Auto" setting will determine whether threading should be enabled at runtime.
  324. /// </summary>
  325. public ReactiveObject<BackendThreading> BackendThreading { get; private set; }
  326. /// <summary>
  327. /// Max Anisotropy. Values range from 0 - 16. Set to -1 to let the game decide.
  328. /// </summary>
  329. public ReactiveObject<float> MaxAnisotropy { get; private set; }
  330. /// <summary>
  331. /// Aspect Ratio applied to the renderer window.
  332. /// </summary>
  333. public ReactiveObject<AspectRatio> AspectRatio { get; private set; }
  334. /// <summary>
  335. /// Resolution Scale. An integer scale applied to applicable render targets. Values 1-4, or -1 to use a custom floating point scale instead.
  336. /// </summary>
  337. public ReactiveObject<int> ResScale { get; private set; }
  338. /// <summary>
  339. /// Custom Resolution Scale. A custom floating point scale applied to applicable render targets. Only active when Resolution Scale is -1.
  340. /// </summary>
  341. public ReactiveObject<float> ResScaleCustom { get; private set; }
  342. /// <summary>
  343. /// Dumps shaders in this local directory
  344. /// </summary>
  345. public ReactiveObject<string> ShadersDumpPath { get; private set; }
  346. /// <summary>
  347. /// Enables or disables Vertical Sync
  348. /// </summary>
  349. public ReactiveObject<bool> EnableVsync { get; private set; }
  350. /// <summary>
  351. /// Enables or disables Shader cache
  352. /// </summary>
  353. public ReactiveObject<bool> EnableShaderCache { get; private set; }
  354. /// <summary>
  355. /// Enables or disables texture recompression
  356. /// </summary>
  357. public ReactiveObject<bool> EnableTextureRecompression { get; private set; }
  358. /// <summary>
  359. /// Graphics backend
  360. /// </summary>
  361. public ReactiveObject<GraphicsBackend> GraphicsBackend { get; private set; }
  362. /// <summary>
  363. /// Preferred GPU
  364. /// </summary>
  365. public ReactiveObject<string> PreferredGpu { get; private set; }
  366. public GraphicsSection()
  367. {
  368. BackendThreading = new ReactiveObject<BackendThreading>();
  369. BackendThreading.Event += static (sender, e) => LogValueChange(sender, e, nameof(BackendThreading));
  370. ResScale = new ReactiveObject<int>();
  371. ResScale.Event += static (sender, e) => LogValueChange(sender, e, nameof(ResScale));
  372. ResScaleCustom = new ReactiveObject<float>();
  373. ResScaleCustom.Event += static (sender, e) => LogValueChange(sender, e, nameof(ResScaleCustom));
  374. MaxAnisotropy = new ReactiveObject<float>();
  375. MaxAnisotropy.Event += static (sender, e) => LogValueChange(sender, e, nameof(MaxAnisotropy));
  376. AspectRatio = new ReactiveObject<AspectRatio>();
  377. AspectRatio.Event += static (sender, e) => LogValueChange(sender, e, nameof(AspectRatio));
  378. ShadersDumpPath = new ReactiveObject<string>();
  379. EnableVsync = new ReactiveObject<bool>();
  380. EnableVsync.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableVsync));
  381. EnableShaderCache = new ReactiveObject<bool>();
  382. EnableShaderCache.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableShaderCache));
  383. EnableTextureRecompression = new ReactiveObject<bool>();
  384. EnableTextureRecompression.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableTextureRecompression));
  385. GraphicsBackend = new ReactiveObject<GraphicsBackend>();
  386. GraphicsBackend.Event += static (sender, e) => LogValueChange(sender, e, nameof(GraphicsBackend));
  387. PreferredGpu = new ReactiveObject<string>();
  388. PreferredGpu.Event += static (sender, e) => LogValueChange(sender, e, nameof(PreferredGpu));
  389. }
  390. }
  391. /// <summary>
  392. /// The default configuration instance
  393. /// </summary>
  394. public static ConfigurationState Instance { get; private set; }
  395. /// <summary>
  396. /// The Ui section
  397. /// </summary>
  398. public UiSection Ui { get; private set; }
  399. /// <summary>
  400. /// The Logger section
  401. /// </summary>
  402. public LoggerSection Logger { get; private set; }
  403. /// <summary>
  404. /// The System section
  405. /// </summary>
  406. public SystemSection System { get; private set; }
  407. /// <summary>
  408. /// The Graphics section
  409. /// </summary>
  410. public GraphicsSection Graphics { get; private set; }
  411. /// <summary>
  412. /// The Hid section
  413. /// </summary>
  414. public HidSection Hid { get; private set; }
  415. /// <summary>
  416. /// Enables or disables Discord Rich Presence
  417. /// </summary>
  418. public ReactiveObject<bool> EnableDiscordIntegration { get; private set; }
  419. /// <summary>
  420. /// Checks for updates when Ryujinx starts when enabled
  421. /// </summary>
  422. public ReactiveObject<bool> CheckUpdatesOnStart { get; private set; }
  423. /// <summary>
  424. /// Show "Confirm Exit" Dialog
  425. /// </summary>
  426. public ReactiveObject<bool> ShowConfirmExit { get; private set; }
  427. /// <summary>
  428. /// Hide Cursor on Idle
  429. /// </summary>
  430. public ReactiveObject<bool> HideCursorOnIdle { get; private set; }
  431. private ConfigurationState()
  432. {
  433. Ui = new UiSection();
  434. Logger = new LoggerSection();
  435. System = new SystemSection();
  436. Graphics = new GraphicsSection();
  437. Hid = new HidSection();
  438. EnableDiscordIntegration = new ReactiveObject<bool>();
  439. CheckUpdatesOnStart = new ReactiveObject<bool>();
  440. ShowConfirmExit = new ReactiveObject<bool>();
  441. HideCursorOnIdle = new ReactiveObject<bool>();
  442. }
  443. public ConfigurationFileFormat ToFileFormat()
  444. {
  445. ConfigurationFileFormat configurationFile = new ConfigurationFileFormat
  446. {
  447. Version = ConfigurationFileFormat.CurrentVersion,
  448. BackendThreading = Graphics.BackendThreading,
  449. EnableFileLog = Logger.EnableFileLog,
  450. ResScale = Graphics.ResScale,
  451. ResScaleCustom = Graphics.ResScaleCustom,
  452. MaxAnisotropy = Graphics.MaxAnisotropy,
  453. AspectRatio = Graphics.AspectRatio,
  454. GraphicsShadersDumpPath = Graphics.ShadersDumpPath,
  455. LoggingEnableDebug = Logger.EnableDebug,
  456. LoggingEnableStub = Logger.EnableStub,
  457. LoggingEnableInfo = Logger.EnableInfo,
  458. LoggingEnableWarn = Logger.EnableWarn,
  459. LoggingEnableError = Logger.EnableError,
  460. LoggingEnableTrace = Logger.EnableTrace,
  461. LoggingEnableGuest = Logger.EnableGuest,
  462. LoggingEnableFsAccessLog = Logger.EnableFsAccessLog,
  463. LoggingFilteredClasses = Logger.FilteredClasses,
  464. LoggingGraphicsDebugLevel = Logger.GraphicsDebugLevel,
  465. SystemLanguage = System.Language,
  466. SystemRegion = System.Region,
  467. SystemTimeZone = System.TimeZone,
  468. SystemTimeOffset = System.SystemTimeOffset,
  469. DockedMode = System.EnableDockedMode,
  470. EnableDiscordIntegration = EnableDiscordIntegration,
  471. CheckUpdatesOnStart = CheckUpdatesOnStart,
  472. ShowConfirmExit = ShowConfirmExit,
  473. HideCursorOnIdle = HideCursorOnIdle,
  474. EnableVsync = Graphics.EnableVsync,
  475. EnableShaderCache = Graphics.EnableShaderCache,
  476. EnableTextureRecompression = Graphics.EnableTextureRecompression,
  477. EnablePtc = System.EnablePtc,
  478. EnableInternetAccess = System.EnableInternetAccess,
  479. EnableFsIntegrityChecks = System.EnableFsIntegrityChecks,
  480. FsGlobalAccessLogMode = System.FsGlobalAccessLogMode,
  481. AudioBackend = System.AudioBackend,
  482. AudioVolume = System.AudioVolume,
  483. MemoryManagerMode = System.MemoryManagerMode,
  484. ExpandRam = System.ExpandRam,
  485. IgnoreMissingServices = System.IgnoreMissingServices,
  486. GuiColumns = new GuiColumns
  487. {
  488. FavColumn = Ui.GuiColumns.FavColumn,
  489. IconColumn = Ui.GuiColumns.IconColumn,
  490. AppColumn = Ui.GuiColumns.AppColumn,
  491. DevColumn = Ui.GuiColumns.DevColumn,
  492. VersionColumn = Ui.GuiColumns.VersionColumn,
  493. TimePlayedColumn = Ui.GuiColumns.TimePlayedColumn,
  494. LastPlayedColumn = Ui.GuiColumns.LastPlayedColumn,
  495. FileExtColumn = Ui.GuiColumns.FileExtColumn,
  496. FileSizeColumn = Ui.GuiColumns.FileSizeColumn,
  497. PathColumn = Ui.GuiColumns.PathColumn
  498. },
  499. ColumnSort = new ColumnSort
  500. {
  501. SortColumnId = Ui.ColumnSort.SortColumnId,
  502. SortAscending = Ui.ColumnSort.SortAscending
  503. },
  504. GameDirs = Ui.GameDirs,
  505. LanguageCode = Ui.LanguageCode,
  506. EnableCustomTheme = Ui.EnableCustomTheme,
  507. CustomThemePath = Ui.CustomThemePath,
  508. BaseStyle = Ui.BaseStyle,
  509. GameListViewMode = Ui.GameListViewMode,
  510. ShowNames = Ui.ShowNames,
  511. GridSize = Ui.GridSize,
  512. ApplicationSort = Ui.ApplicationSort,
  513. IsAscendingOrder = Ui.IsAscendingOrder,
  514. StartFullscreen = Ui.StartFullscreen,
  515. ShowConsole = Ui.ShowConsole,
  516. EnableKeyboard = Hid.EnableKeyboard,
  517. EnableMouse = Hid.EnableMouse,
  518. Hotkeys = Hid.Hotkeys,
  519. KeyboardConfig = new List<object>(),
  520. ControllerConfig = new List<object>(),
  521. InputConfig = Hid.InputConfig,
  522. GraphicsBackend = Graphics.GraphicsBackend,
  523. PreferredGpu = Graphics.PreferredGpu
  524. };
  525. return configurationFile;
  526. }
  527. public void LoadDefault()
  528. {
  529. Logger.EnableFileLog.Value = true;
  530. Graphics.BackendThreading.Value = BackendThreading.Auto;
  531. Graphics.ResScale.Value = 1;
  532. Graphics.ResScaleCustom.Value = 1.0f;
  533. Graphics.MaxAnisotropy.Value = -1.0f;
  534. Graphics.AspectRatio.Value = AspectRatio.Fixed16x9;
  535. Graphics.GraphicsBackend.Value = GraphicsBackend.OpenGl;
  536. Graphics.PreferredGpu.Value = "";
  537. Graphics.ShadersDumpPath.Value = "";
  538. Logger.EnableDebug.Value = false;
  539. Logger.EnableStub.Value = true;
  540. Logger.EnableInfo.Value = true;
  541. Logger.EnableWarn.Value = true;
  542. Logger.EnableError.Value = true;
  543. Logger.EnableTrace.Value = false;
  544. Logger.EnableGuest.Value = true;
  545. Logger.EnableFsAccessLog.Value = false;
  546. Logger.FilteredClasses.Value = Array.Empty<LogClass>();
  547. Logger.GraphicsDebugLevel.Value = GraphicsDebugLevel.None;
  548. System.Language.Value = Language.AmericanEnglish;
  549. System.Region.Value = Region.USA;
  550. System.TimeZone.Value = "UTC";
  551. System.SystemTimeOffset.Value = 0;
  552. System.EnableDockedMode.Value = true;
  553. EnableDiscordIntegration.Value = true;
  554. CheckUpdatesOnStart.Value = true;
  555. ShowConfirmExit.Value = true;
  556. HideCursorOnIdle.Value = false;
  557. Graphics.EnableVsync.Value = true;
  558. Graphics.EnableShaderCache.Value = true;
  559. Graphics.EnableTextureRecompression.Value = false;
  560. System.EnablePtc.Value = true;
  561. System.EnableInternetAccess.Value = false;
  562. System.EnableFsIntegrityChecks.Value = true;
  563. System.FsGlobalAccessLogMode.Value = 0;
  564. System.AudioBackend.Value = AudioBackend.SDL2;
  565. System.AudioVolume.Value = 1;
  566. System.MemoryManagerMode.Value = MemoryManagerMode.HostMappedUnsafe;
  567. System.ExpandRam.Value = false;
  568. System.IgnoreMissingServices.Value = false;
  569. Ui.GuiColumns.FavColumn.Value = true;
  570. Ui.GuiColumns.IconColumn.Value = true;
  571. Ui.GuiColumns.AppColumn.Value = true;
  572. Ui.GuiColumns.DevColumn.Value = true;
  573. Ui.GuiColumns.VersionColumn.Value = true;
  574. Ui.GuiColumns.TimePlayedColumn.Value = true;
  575. Ui.GuiColumns.LastPlayedColumn.Value = true;
  576. Ui.GuiColumns.FileExtColumn.Value = true;
  577. Ui.GuiColumns.FileSizeColumn.Value = true;
  578. Ui.GuiColumns.PathColumn.Value = true;
  579. Ui.ColumnSort.SortColumnId.Value = 0;
  580. Ui.ColumnSort.SortAscending.Value = false;
  581. Ui.GameDirs.Value = new List<string>();
  582. Ui.EnableCustomTheme.Value = false;
  583. Ui.LanguageCode.Value = "en_US";
  584. Ui.CustomThemePath.Value = "";
  585. Ui.BaseStyle.Value = "Dark";
  586. Ui.GameListViewMode.Value = 0;
  587. Ui.ShowNames.Value = true;
  588. Ui.GridSize.Value = 2;
  589. Ui.ApplicationSort.Value = 0;
  590. Ui.IsAscendingOrder.Value = true;
  591. Ui.StartFullscreen.Value = false;
  592. Ui.ShowConsole.Value = true;
  593. Hid.EnableKeyboard.Value = false;
  594. Hid.EnableMouse.Value = false;
  595. Hid.Hotkeys.Value = new KeyboardHotkeys
  596. {
  597. ToggleVsync = Key.Tab,
  598. ToggleMute = Key.F2,
  599. Screenshot = Key.F8,
  600. ShowUi = Key.F4,
  601. Pause = Key.F5,
  602. ResScaleUp = Key.Unbound,
  603. ResScaleDown = Key.Unbound
  604. };
  605. Hid.InputConfig.Value = new List<InputConfig>
  606. {
  607. new StandardKeyboardInputConfig
  608. {
  609. Version = InputConfig.CurrentVersion,
  610. Backend = InputBackendType.WindowKeyboard,
  611. Id = "0",
  612. PlayerIndex = PlayerIndex.Player1,
  613. ControllerType = ControllerType.JoyconPair,
  614. LeftJoycon = new LeftJoyconCommonConfig<Key>
  615. {
  616. DpadUp = Key.Up,
  617. DpadDown = Key.Down,
  618. DpadLeft = Key.Left,
  619. DpadRight = Key.Right,
  620. ButtonMinus = Key.Minus,
  621. ButtonL = Key.E,
  622. ButtonZl = Key.Q,
  623. ButtonSl = Key.Unbound,
  624. ButtonSr = Key.Unbound
  625. },
  626. LeftJoyconStick = new JoyconConfigKeyboardStick<Key>
  627. {
  628. StickUp = Key.W,
  629. StickDown = Key.S,
  630. StickLeft = Key.A,
  631. StickRight = Key.D,
  632. StickButton = Key.F,
  633. },
  634. RightJoycon = new RightJoyconCommonConfig<Key>
  635. {
  636. ButtonA = Key.Z,
  637. ButtonB = Key.X,
  638. ButtonX = Key.C,
  639. ButtonY = Key.V,
  640. ButtonPlus = Key.Plus,
  641. ButtonR = Key.U,
  642. ButtonZr = Key.O,
  643. ButtonSl = Key.Unbound,
  644. ButtonSr = Key.Unbound
  645. },
  646. RightJoyconStick = new JoyconConfigKeyboardStick<Key>
  647. {
  648. StickUp = Key.I,
  649. StickDown = Key.K,
  650. StickLeft = Key.J,
  651. StickRight = Key.L,
  652. StickButton = Key.H,
  653. }
  654. }
  655. };
  656. }
  657. public ConfigurationLoadResult Load(ConfigurationFileFormat configurationFileFormat, string configurationFilePath)
  658. {
  659. bool configurationFileUpdated = false;
  660. if (configurationFileFormat.Version < 0 || configurationFileFormat.Version > ConfigurationFileFormat.CurrentVersion)
  661. {
  662. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Unsupported configuration version {configurationFileFormat.Version}, loading default.");
  663. LoadDefault();
  664. return ConfigurationLoadResult.NotLoaded;
  665. }
  666. ConfigurationLoadResult result = ConfigurationLoadResult.Success;
  667. if (configurationFileFormat.Version < 2)
  668. {
  669. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 2.");
  670. configurationFileFormat.SystemRegion = Region.USA;
  671. configurationFileUpdated = true;
  672. }
  673. if (configurationFileFormat.Version < 3)
  674. {
  675. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 3.");
  676. configurationFileFormat.SystemTimeZone = "UTC";
  677. configurationFileUpdated = true;
  678. }
  679. if (configurationFileFormat.Version < 4)
  680. {
  681. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 4.");
  682. configurationFileFormat.MaxAnisotropy = -1;
  683. configurationFileUpdated = true;
  684. }
  685. if (configurationFileFormat.Version < 5)
  686. {
  687. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 5.");
  688. configurationFileFormat.SystemTimeOffset = 0;
  689. configurationFileUpdated = true;
  690. }
  691. if (configurationFileFormat.Version < 8)
  692. {
  693. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 8.");
  694. configurationFileFormat.EnablePtc = true;
  695. configurationFileUpdated = true;
  696. }
  697. if (configurationFileFormat.Version < 9)
  698. {
  699. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 9.");
  700. configurationFileFormat.ColumnSort = new ColumnSort
  701. {
  702. SortColumnId = 0,
  703. SortAscending = false
  704. };
  705. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  706. {
  707. ToggleVsync = Key.Tab
  708. };
  709. configurationFileUpdated = true;
  710. }
  711. if (configurationFileFormat.Version < 10)
  712. {
  713. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 10.");
  714. configurationFileFormat.AudioBackend = AudioBackend.OpenAl;
  715. configurationFileUpdated = true;
  716. }
  717. if (configurationFileFormat.Version < 11)
  718. {
  719. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 11.");
  720. configurationFileFormat.ResScale = 1;
  721. configurationFileFormat.ResScaleCustom = 1.0f;
  722. configurationFileUpdated = true;
  723. }
  724. if (configurationFileFormat.Version < 12)
  725. {
  726. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 12.");
  727. configurationFileFormat.LoggingGraphicsDebugLevel = GraphicsDebugLevel.None;
  728. configurationFileUpdated = true;
  729. }
  730. if (configurationFileFormat.Version < 14)
  731. {
  732. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 14.");
  733. configurationFileFormat.CheckUpdatesOnStart = true;
  734. configurationFileUpdated = true;
  735. }
  736. if (configurationFileFormat.Version < 16)
  737. {
  738. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 16.");
  739. configurationFileFormat.EnableShaderCache = true;
  740. configurationFileUpdated = true;
  741. }
  742. if (configurationFileFormat.Version < 17)
  743. {
  744. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 17.");
  745. configurationFileFormat.StartFullscreen = false;
  746. configurationFileUpdated = true;
  747. }
  748. if (configurationFileFormat.Version < 18)
  749. {
  750. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 18.");
  751. configurationFileFormat.AspectRatio = AspectRatio.Fixed16x9;
  752. configurationFileUpdated = true;
  753. }
  754. if (configurationFileFormat.Version < 20)
  755. {
  756. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 20.");
  757. configurationFileFormat.ShowConfirmExit = true;
  758. configurationFileUpdated = true;
  759. }
  760. if (configurationFileFormat.Version < 22)
  761. {
  762. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 22.");
  763. configurationFileFormat.HideCursorOnIdle = false;
  764. configurationFileUpdated = true;
  765. }
  766. if (configurationFileFormat.Version < 24)
  767. {
  768. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 24.");
  769. configurationFileFormat.InputConfig = new List<InputConfig>
  770. {
  771. new StandardKeyboardInputConfig
  772. {
  773. Version = InputConfig.CurrentVersion,
  774. Backend = InputBackendType.WindowKeyboard,
  775. Id = "0",
  776. PlayerIndex = PlayerIndex.Player1,
  777. ControllerType = ControllerType.JoyconPair,
  778. LeftJoycon = new LeftJoyconCommonConfig<Key>
  779. {
  780. DpadUp = Key.Up,
  781. DpadDown = Key.Down,
  782. DpadLeft = Key.Left,
  783. DpadRight = Key.Right,
  784. ButtonMinus = Key.Minus,
  785. ButtonL = Key.E,
  786. ButtonZl = Key.Q,
  787. ButtonSl = Key.Unbound,
  788. ButtonSr = Key.Unbound
  789. },
  790. LeftJoyconStick = new JoyconConfigKeyboardStick<Key>
  791. {
  792. StickUp = Key.W,
  793. StickDown = Key.S,
  794. StickLeft = Key.A,
  795. StickRight = Key.D,
  796. StickButton = Key.F,
  797. },
  798. RightJoycon = new RightJoyconCommonConfig<Key>
  799. {
  800. ButtonA = Key.Z,
  801. ButtonB = Key.X,
  802. ButtonX = Key.C,
  803. ButtonY = Key.V,
  804. ButtonPlus = Key.Plus,
  805. ButtonR = Key.U,
  806. ButtonZr = Key.O,
  807. ButtonSl = Key.Unbound,
  808. ButtonSr = Key.Unbound
  809. },
  810. RightJoyconStick = new JoyconConfigKeyboardStick<Key>
  811. {
  812. StickUp = Key.I,
  813. StickDown = Key.K,
  814. StickLeft = Key.J,
  815. StickRight = Key.L,
  816. StickButton = Key.H,
  817. }
  818. }
  819. };
  820. configurationFileUpdated = true;
  821. }
  822. if (configurationFileFormat.Version < 25)
  823. {
  824. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 25.");
  825. configurationFileUpdated = true;
  826. }
  827. if (configurationFileFormat.Version < 26)
  828. {
  829. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 26.");
  830. configurationFileFormat.MemoryManagerMode = MemoryManagerMode.HostMappedUnsafe;
  831. configurationFileUpdated = true;
  832. }
  833. if (configurationFileFormat.Version < 27)
  834. {
  835. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 27.");
  836. configurationFileFormat.EnableMouse = false;
  837. configurationFileUpdated = true;
  838. }
  839. if (configurationFileFormat.Version < 28)
  840. {
  841. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 28.");
  842. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  843. {
  844. ToggleVsync = Key.Tab,
  845. Screenshot = Key.F8
  846. };
  847. configurationFileUpdated = true;
  848. }
  849. if (configurationFileFormat.Version < 29)
  850. {
  851. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 29.");
  852. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  853. {
  854. ToggleVsync = Key.Tab,
  855. Screenshot = Key.F8,
  856. ShowUi = Key.F4
  857. };
  858. configurationFileUpdated = true;
  859. }
  860. if (configurationFileFormat.Version < 30)
  861. {
  862. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 30.");
  863. foreach(InputConfig config in configurationFileFormat.InputConfig)
  864. {
  865. if (config is StandardControllerInputConfig controllerConfig)
  866. {
  867. controllerConfig.Rumble = new RumbleConfigController
  868. {
  869. EnableRumble = false,
  870. StrongRumble = 1f,
  871. WeakRumble = 1f
  872. };
  873. }
  874. }
  875. configurationFileUpdated = true;
  876. }
  877. if (configurationFileFormat.Version < 31)
  878. {
  879. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 31.");
  880. configurationFileFormat.BackendThreading = BackendThreading.Auto;
  881. configurationFileUpdated = true;
  882. }
  883. if (configurationFileFormat.Version < 32)
  884. {
  885. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 32.");
  886. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  887. {
  888. ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync,
  889. Screenshot = configurationFileFormat.Hotkeys.Screenshot,
  890. ShowUi = configurationFileFormat.Hotkeys.ShowUi,
  891. Pause = Key.F5
  892. };
  893. configurationFileUpdated = true;
  894. }
  895. if (configurationFileFormat.Version < 33)
  896. {
  897. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 33.");
  898. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  899. {
  900. ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync,
  901. Screenshot = configurationFileFormat.Hotkeys.Screenshot,
  902. ShowUi = configurationFileFormat.Hotkeys.ShowUi,
  903. Pause = configurationFileFormat.Hotkeys.Pause,
  904. ToggleMute = Key.F2
  905. };
  906. configurationFileFormat.AudioVolume = 1;
  907. configurationFileUpdated = true;
  908. }
  909. if (configurationFileFormat.Version < 34)
  910. {
  911. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 34.");
  912. configurationFileFormat.EnableInternetAccess = false;
  913. configurationFileUpdated = true;
  914. }
  915. if (configurationFileFormat.Version < 35)
  916. {
  917. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 35.");
  918. foreach (InputConfig config in configurationFileFormat.InputConfig)
  919. {
  920. if (config is StandardControllerInputConfig controllerConfig)
  921. {
  922. controllerConfig.RangeLeft = 1.0f;
  923. controllerConfig.RangeRight = 1.0f;
  924. }
  925. }
  926. configurationFileUpdated = true;
  927. }
  928. if (configurationFileFormat.Version < 36)
  929. {
  930. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 36.");
  931. configurationFileFormat.LoggingEnableTrace = false;
  932. configurationFileUpdated = true;
  933. }
  934. if (configurationFileFormat.Version < 37)
  935. {
  936. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 37.");
  937. configurationFileFormat.ShowConsole = true;
  938. configurationFileUpdated = true;
  939. }
  940. if (configurationFileFormat.Version < 38)
  941. {
  942. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 38.");
  943. configurationFileFormat.BaseStyle = "Dark";
  944. configurationFileFormat.GameListViewMode = 0;
  945. configurationFileFormat.ShowNames = true;
  946. configurationFileFormat.GridSize = 2;
  947. configurationFileFormat.LanguageCode = "en_US";
  948. configurationFileUpdated = true;
  949. }
  950. if (configurationFileFormat.Version < 39)
  951. {
  952. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 39.");
  953. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  954. {
  955. ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync,
  956. Screenshot = configurationFileFormat.Hotkeys.Screenshot,
  957. ShowUi = configurationFileFormat.Hotkeys.ShowUi,
  958. Pause = configurationFileFormat.Hotkeys.Pause,
  959. ToggleMute = configurationFileFormat.Hotkeys.ToggleMute,
  960. ResScaleUp = Key.Unbound,
  961. ResScaleDown = Key.Unbound
  962. };
  963. configurationFileUpdated = true;
  964. }
  965. if (configurationFileFormat.Version < 40)
  966. {
  967. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 40.");
  968. configurationFileFormat.GraphicsBackend = GraphicsBackend.OpenGl;
  969. result |= ConfigurationLoadResult.MigratedFromPreVulkan;
  970. configurationFileUpdated = true;
  971. }
  972. Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog;
  973. Graphics.ResScale.Value = configurationFileFormat.ResScale;
  974. Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom;
  975. Graphics.MaxAnisotropy.Value = configurationFileFormat.MaxAnisotropy;
  976. Graphics.AspectRatio.Value = configurationFileFormat.AspectRatio;
  977. Graphics.ShadersDumpPath.Value = configurationFileFormat.GraphicsShadersDumpPath;
  978. Graphics.BackendThreading.Value = configurationFileFormat.BackendThreading;
  979. Graphics.GraphicsBackend.Value = configurationFileFormat.GraphicsBackend;
  980. Graphics.PreferredGpu.Value = configurationFileFormat.PreferredGpu;
  981. Logger.EnableDebug.Value = configurationFileFormat.LoggingEnableDebug;
  982. Logger.EnableStub.Value = configurationFileFormat.LoggingEnableStub;
  983. Logger.EnableInfo.Value = configurationFileFormat.LoggingEnableInfo;
  984. Logger.EnableWarn.Value = configurationFileFormat.LoggingEnableWarn;
  985. Logger.EnableError.Value = configurationFileFormat.LoggingEnableError;
  986. Logger.EnableTrace.Value = configurationFileFormat.LoggingEnableTrace;
  987. Logger.EnableGuest.Value = configurationFileFormat.LoggingEnableGuest;
  988. Logger.EnableFsAccessLog.Value = configurationFileFormat.LoggingEnableFsAccessLog;
  989. Logger.FilteredClasses.Value = configurationFileFormat.LoggingFilteredClasses;
  990. Logger.GraphicsDebugLevel.Value = configurationFileFormat.LoggingGraphicsDebugLevel;
  991. System.Language.Value = configurationFileFormat.SystemLanguage;
  992. System.Region.Value = configurationFileFormat.SystemRegion;
  993. System.TimeZone.Value = configurationFileFormat.SystemTimeZone;
  994. System.SystemTimeOffset.Value = configurationFileFormat.SystemTimeOffset;
  995. System.EnableDockedMode.Value = configurationFileFormat.DockedMode;
  996. EnableDiscordIntegration.Value = configurationFileFormat.EnableDiscordIntegration;
  997. CheckUpdatesOnStart.Value = configurationFileFormat.CheckUpdatesOnStart;
  998. ShowConfirmExit.Value = configurationFileFormat.ShowConfirmExit;
  999. HideCursorOnIdle.Value = configurationFileFormat.HideCursorOnIdle;
  1000. Graphics.EnableVsync.Value = configurationFileFormat.EnableVsync;
  1001. Graphics.EnableShaderCache.Value = configurationFileFormat.EnableShaderCache;
  1002. Graphics.EnableTextureRecompression.Value = configurationFileFormat.EnableTextureRecompression;
  1003. System.EnablePtc.Value = configurationFileFormat.EnablePtc;
  1004. System.EnableInternetAccess.Value = configurationFileFormat.EnableInternetAccess;
  1005. System.EnableFsIntegrityChecks.Value = configurationFileFormat.EnableFsIntegrityChecks;
  1006. System.FsGlobalAccessLogMode.Value = configurationFileFormat.FsGlobalAccessLogMode;
  1007. System.AudioBackend.Value = configurationFileFormat.AudioBackend;
  1008. System.AudioVolume.Value = configurationFileFormat.AudioVolume;
  1009. System.MemoryManagerMode.Value = configurationFileFormat.MemoryManagerMode;
  1010. System.ExpandRam.Value = configurationFileFormat.ExpandRam;
  1011. System.IgnoreMissingServices.Value = configurationFileFormat.IgnoreMissingServices;
  1012. Ui.GuiColumns.FavColumn.Value = configurationFileFormat.GuiColumns.FavColumn;
  1013. Ui.GuiColumns.IconColumn.Value = configurationFileFormat.GuiColumns.IconColumn;
  1014. Ui.GuiColumns.AppColumn.Value = configurationFileFormat.GuiColumns.AppColumn;
  1015. Ui.GuiColumns.DevColumn.Value = configurationFileFormat.GuiColumns.DevColumn;
  1016. Ui.GuiColumns.VersionColumn.Value = configurationFileFormat.GuiColumns.VersionColumn;
  1017. Ui.GuiColumns.TimePlayedColumn.Value = configurationFileFormat.GuiColumns.TimePlayedColumn;
  1018. Ui.GuiColumns.LastPlayedColumn.Value = configurationFileFormat.GuiColumns.LastPlayedColumn;
  1019. Ui.GuiColumns.FileExtColumn.Value = configurationFileFormat.GuiColumns.FileExtColumn;
  1020. Ui.GuiColumns.FileSizeColumn.Value = configurationFileFormat.GuiColumns.FileSizeColumn;
  1021. Ui.GuiColumns.PathColumn.Value = configurationFileFormat.GuiColumns.PathColumn;
  1022. Ui.ColumnSort.SortColumnId.Value = configurationFileFormat.ColumnSort.SortColumnId;
  1023. Ui.ColumnSort.SortAscending.Value = configurationFileFormat.ColumnSort.SortAscending;
  1024. Ui.GameDirs.Value = configurationFileFormat.GameDirs;
  1025. Ui.EnableCustomTheme.Value = configurationFileFormat.EnableCustomTheme;
  1026. Ui.LanguageCode.Value = configurationFileFormat.LanguageCode;
  1027. Ui.CustomThemePath.Value = configurationFileFormat.CustomThemePath;
  1028. Ui.BaseStyle.Value = configurationFileFormat.BaseStyle;
  1029. Ui.GameListViewMode.Value = configurationFileFormat.GameListViewMode;
  1030. Ui.ShowNames.Value = configurationFileFormat.ShowNames;
  1031. Ui.IsAscendingOrder.Value = configurationFileFormat.IsAscendingOrder;
  1032. Ui.GridSize.Value = configurationFileFormat.GridSize;
  1033. Ui.ApplicationSort.Value = configurationFileFormat.ApplicationSort;
  1034. Ui.StartFullscreen.Value = configurationFileFormat.StartFullscreen;
  1035. Ui.ShowConsole.Value = configurationFileFormat.ShowConsole;
  1036. Hid.EnableKeyboard.Value = configurationFileFormat.EnableKeyboard;
  1037. Hid.EnableMouse.Value = configurationFileFormat.EnableMouse;
  1038. Hid.Hotkeys.Value = configurationFileFormat.Hotkeys;
  1039. Hid.InputConfig.Value = configurationFileFormat.InputConfig;
  1040. if (Hid.InputConfig.Value == null)
  1041. {
  1042. Hid.InputConfig.Value = new List<InputConfig>();
  1043. }
  1044. if (configurationFileUpdated)
  1045. {
  1046. ToFileFormat().SaveConfig(configurationFilePath);
  1047. Ryujinx.Common.Logging.Logger.Notice.Print(LogClass.Application, $"Configuration file updated to version {ConfigurationFileFormat.CurrentVersion}");
  1048. }
  1049. return result;
  1050. }
  1051. private static void LogValueChange<T>(object sender, ReactiveEventArgs<T> eventArgs, string valueName)
  1052. {
  1053. Ryujinx.Common.Logging.Logger.Info?.Print(LogClass.Configuration, $"{valueName} set to: {eventArgs.NewValue}");
  1054. }
  1055. public static void Initialize()
  1056. {
  1057. if (Instance != null)
  1058. {
  1059. throw new InvalidOperationException("Configuration is already initialized");
  1060. }
  1061. Instance = new ConfigurationState();
  1062. }
  1063. }
  1064. }