ConfigurationState.cs 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295
  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. /// Enables or disables Macro high-level emulation
  360. /// </summary>
  361. public ReactiveObject<bool> EnableMacroHLE { get; private set; }
  362. /// <summary>
  363. /// Graphics backend
  364. /// </summary>
  365. public ReactiveObject<GraphicsBackend> GraphicsBackend { get; private set; }
  366. /// <summary>
  367. /// Preferred GPU
  368. /// </summary>
  369. public ReactiveObject<string> PreferredGpu { get; private set; }
  370. public GraphicsSection()
  371. {
  372. BackendThreading = new ReactiveObject<BackendThreading>();
  373. BackendThreading.Event += static (sender, e) => LogValueChange(sender, e, nameof(BackendThreading));
  374. ResScale = new ReactiveObject<int>();
  375. ResScale.Event += static (sender, e) => LogValueChange(sender, e, nameof(ResScale));
  376. ResScaleCustom = new ReactiveObject<float>();
  377. ResScaleCustom.Event += static (sender, e) => LogValueChange(sender, e, nameof(ResScaleCustom));
  378. MaxAnisotropy = new ReactiveObject<float>();
  379. MaxAnisotropy.Event += static (sender, e) => LogValueChange(sender, e, nameof(MaxAnisotropy));
  380. AspectRatio = new ReactiveObject<AspectRatio>();
  381. AspectRatio.Event += static (sender, e) => LogValueChange(sender, e, nameof(AspectRatio));
  382. ShadersDumpPath = new ReactiveObject<string>();
  383. EnableVsync = new ReactiveObject<bool>();
  384. EnableVsync.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableVsync));
  385. EnableShaderCache = new ReactiveObject<bool>();
  386. EnableShaderCache.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableShaderCache));
  387. EnableTextureRecompression = new ReactiveObject<bool>();
  388. EnableTextureRecompression.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableTextureRecompression));
  389. GraphicsBackend = new ReactiveObject<GraphicsBackend>();
  390. GraphicsBackend.Event += static (sender, e) => LogValueChange(sender, e, nameof(GraphicsBackend));
  391. PreferredGpu = new ReactiveObject<string>();
  392. PreferredGpu.Event += static (sender, e) => LogValueChange(sender, e, nameof(PreferredGpu));
  393. EnableMacroHLE = new ReactiveObject<bool>();
  394. EnableMacroHLE.Event += static (sender, e) => LogValueChange(sender, e, nameof(EnableMacroHLE));
  395. }
  396. }
  397. /// <summary>
  398. /// The default configuration instance
  399. /// </summary>
  400. public static ConfigurationState Instance { get; private set; }
  401. /// <summary>
  402. /// The Ui section
  403. /// </summary>
  404. public UiSection Ui { get; private set; }
  405. /// <summary>
  406. /// The Logger section
  407. /// </summary>
  408. public LoggerSection Logger { get; private set; }
  409. /// <summary>
  410. /// The System section
  411. /// </summary>
  412. public SystemSection System { get; private set; }
  413. /// <summary>
  414. /// The Graphics section
  415. /// </summary>
  416. public GraphicsSection Graphics { get; private set; }
  417. /// <summary>
  418. /// The Hid section
  419. /// </summary>
  420. public HidSection Hid { get; private set; }
  421. /// <summary>
  422. /// Enables or disables Discord Rich Presence
  423. /// </summary>
  424. public ReactiveObject<bool> EnableDiscordIntegration { get; private set; }
  425. /// <summary>
  426. /// Checks for updates when Ryujinx starts when enabled
  427. /// </summary>
  428. public ReactiveObject<bool> CheckUpdatesOnStart { get; private set; }
  429. /// <summary>
  430. /// Show "Confirm Exit" Dialog
  431. /// </summary>
  432. public ReactiveObject<bool> ShowConfirmExit { get; private set; }
  433. /// <summary>
  434. /// Hide Cursor on Idle
  435. /// </summary>
  436. public ReactiveObject<bool> HideCursorOnIdle { get; private set; }
  437. private ConfigurationState()
  438. {
  439. Ui = new UiSection();
  440. Logger = new LoggerSection();
  441. System = new SystemSection();
  442. Graphics = new GraphicsSection();
  443. Hid = new HidSection();
  444. EnableDiscordIntegration = new ReactiveObject<bool>();
  445. CheckUpdatesOnStart = new ReactiveObject<bool>();
  446. ShowConfirmExit = new ReactiveObject<bool>();
  447. HideCursorOnIdle = new ReactiveObject<bool>();
  448. }
  449. public ConfigurationFileFormat ToFileFormat()
  450. {
  451. ConfigurationFileFormat configurationFile = new ConfigurationFileFormat
  452. {
  453. Version = ConfigurationFileFormat.CurrentVersion,
  454. BackendThreading = Graphics.BackendThreading,
  455. EnableFileLog = Logger.EnableFileLog,
  456. ResScale = Graphics.ResScale,
  457. ResScaleCustom = Graphics.ResScaleCustom,
  458. MaxAnisotropy = Graphics.MaxAnisotropy,
  459. AspectRatio = Graphics.AspectRatio,
  460. GraphicsShadersDumpPath = Graphics.ShadersDumpPath,
  461. LoggingEnableDebug = Logger.EnableDebug,
  462. LoggingEnableStub = Logger.EnableStub,
  463. LoggingEnableInfo = Logger.EnableInfo,
  464. LoggingEnableWarn = Logger.EnableWarn,
  465. LoggingEnableError = Logger.EnableError,
  466. LoggingEnableTrace = Logger.EnableTrace,
  467. LoggingEnableGuest = Logger.EnableGuest,
  468. LoggingEnableFsAccessLog = Logger.EnableFsAccessLog,
  469. LoggingFilteredClasses = Logger.FilteredClasses,
  470. LoggingGraphicsDebugLevel = Logger.GraphicsDebugLevel,
  471. SystemLanguage = System.Language,
  472. SystemRegion = System.Region,
  473. SystemTimeZone = System.TimeZone,
  474. SystemTimeOffset = System.SystemTimeOffset,
  475. DockedMode = System.EnableDockedMode,
  476. EnableDiscordIntegration = EnableDiscordIntegration,
  477. CheckUpdatesOnStart = CheckUpdatesOnStart,
  478. ShowConfirmExit = ShowConfirmExit,
  479. HideCursorOnIdle = HideCursorOnIdle,
  480. EnableVsync = Graphics.EnableVsync,
  481. EnableShaderCache = Graphics.EnableShaderCache,
  482. EnableTextureRecompression = Graphics.EnableTextureRecompression,
  483. EnableMacroHLE = Graphics.EnableMacroHLE,
  484. EnablePtc = System.EnablePtc,
  485. EnableInternetAccess = System.EnableInternetAccess,
  486. EnableFsIntegrityChecks = System.EnableFsIntegrityChecks,
  487. FsGlobalAccessLogMode = System.FsGlobalAccessLogMode,
  488. AudioBackend = System.AudioBackend,
  489. AudioVolume = System.AudioVolume,
  490. MemoryManagerMode = System.MemoryManagerMode,
  491. ExpandRam = System.ExpandRam,
  492. IgnoreMissingServices = System.IgnoreMissingServices,
  493. GuiColumns = new GuiColumns
  494. {
  495. FavColumn = Ui.GuiColumns.FavColumn,
  496. IconColumn = Ui.GuiColumns.IconColumn,
  497. AppColumn = Ui.GuiColumns.AppColumn,
  498. DevColumn = Ui.GuiColumns.DevColumn,
  499. VersionColumn = Ui.GuiColumns.VersionColumn,
  500. TimePlayedColumn = Ui.GuiColumns.TimePlayedColumn,
  501. LastPlayedColumn = Ui.GuiColumns.LastPlayedColumn,
  502. FileExtColumn = Ui.GuiColumns.FileExtColumn,
  503. FileSizeColumn = Ui.GuiColumns.FileSizeColumn,
  504. PathColumn = Ui.GuiColumns.PathColumn
  505. },
  506. ColumnSort = new ColumnSort
  507. {
  508. SortColumnId = Ui.ColumnSort.SortColumnId,
  509. SortAscending = Ui.ColumnSort.SortAscending
  510. },
  511. GameDirs = Ui.GameDirs,
  512. LanguageCode = Ui.LanguageCode,
  513. EnableCustomTheme = Ui.EnableCustomTheme,
  514. CustomThemePath = Ui.CustomThemePath,
  515. BaseStyle = Ui.BaseStyle,
  516. GameListViewMode = Ui.GameListViewMode,
  517. ShowNames = Ui.ShowNames,
  518. GridSize = Ui.GridSize,
  519. ApplicationSort = Ui.ApplicationSort,
  520. IsAscendingOrder = Ui.IsAscendingOrder,
  521. StartFullscreen = Ui.StartFullscreen,
  522. ShowConsole = Ui.ShowConsole,
  523. EnableKeyboard = Hid.EnableKeyboard,
  524. EnableMouse = Hid.EnableMouse,
  525. Hotkeys = Hid.Hotkeys,
  526. KeyboardConfig = new List<object>(),
  527. ControllerConfig = new List<object>(),
  528. InputConfig = Hid.InputConfig,
  529. GraphicsBackend = Graphics.GraphicsBackend,
  530. PreferredGpu = Graphics.PreferredGpu
  531. };
  532. return configurationFile;
  533. }
  534. public void LoadDefault()
  535. {
  536. Logger.EnableFileLog.Value = true;
  537. Graphics.BackendThreading.Value = BackendThreading.Auto;
  538. Graphics.ResScale.Value = 1;
  539. Graphics.ResScaleCustom.Value = 1.0f;
  540. Graphics.MaxAnisotropy.Value = -1.0f;
  541. Graphics.AspectRatio.Value = AspectRatio.Fixed16x9;
  542. Graphics.GraphicsBackend.Value = GraphicsBackend.OpenGl;
  543. Graphics.PreferredGpu.Value = "";
  544. Graphics.ShadersDumpPath.Value = "";
  545. Logger.EnableDebug.Value = false;
  546. Logger.EnableStub.Value = true;
  547. Logger.EnableInfo.Value = true;
  548. Logger.EnableWarn.Value = true;
  549. Logger.EnableError.Value = true;
  550. Logger.EnableTrace.Value = false;
  551. Logger.EnableGuest.Value = true;
  552. Logger.EnableFsAccessLog.Value = false;
  553. Logger.FilteredClasses.Value = Array.Empty<LogClass>();
  554. Logger.GraphicsDebugLevel.Value = GraphicsDebugLevel.None;
  555. System.Language.Value = Language.AmericanEnglish;
  556. System.Region.Value = Region.USA;
  557. System.TimeZone.Value = "UTC";
  558. System.SystemTimeOffset.Value = 0;
  559. System.EnableDockedMode.Value = true;
  560. EnableDiscordIntegration.Value = true;
  561. CheckUpdatesOnStart.Value = true;
  562. ShowConfirmExit.Value = true;
  563. HideCursorOnIdle.Value = false;
  564. Graphics.EnableVsync.Value = true;
  565. Graphics.EnableShaderCache.Value = true;
  566. Graphics.EnableTextureRecompression.Value = false;
  567. Graphics.EnableMacroHLE.Value = true;
  568. System.EnablePtc.Value = true;
  569. System.EnableInternetAccess.Value = false;
  570. System.EnableFsIntegrityChecks.Value = true;
  571. System.FsGlobalAccessLogMode.Value = 0;
  572. System.AudioBackend.Value = AudioBackend.SDL2;
  573. System.AudioVolume.Value = 1;
  574. System.MemoryManagerMode.Value = MemoryManagerMode.HostMappedUnsafe;
  575. System.ExpandRam.Value = false;
  576. System.IgnoreMissingServices.Value = false;
  577. Ui.GuiColumns.FavColumn.Value = true;
  578. Ui.GuiColumns.IconColumn.Value = true;
  579. Ui.GuiColumns.AppColumn.Value = true;
  580. Ui.GuiColumns.DevColumn.Value = true;
  581. Ui.GuiColumns.VersionColumn.Value = true;
  582. Ui.GuiColumns.TimePlayedColumn.Value = true;
  583. Ui.GuiColumns.LastPlayedColumn.Value = true;
  584. Ui.GuiColumns.FileExtColumn.Value = true;
  585. Ui.GuiColumns.FileSizeColumn.Value = true;
  586. Ui.GuiColumns.PathColumn.Value = true;
  587. Ui.ColumnSort.SortColumnId.Value = 0;
  588. Ui.ColumnSort.SortAscending.Value = false;
  589. Ui.GameDirs.Value = new List<string>();
  590. Ui.EnableCustomTheme.Value = false;
  591. Ui.LanguageCode.Value = "en_US";
  592. Ui.CustomThemePath.Value = "";
  593. Ui.BaseStyle.Value = "Dark";
  594. Ui.GameListViewMode.Value = 0;
  595. Ui.ShowNames.Value = true;
  596. Ui.GridSize.Value = 2;
  597. Ui.ApplicationSort.Value = 0;
  598. Ui.IsAscendingOrder.Value = true;
  599. Ui.StartFullscreen.Value = false;
  600. Ui.ShowConsole.Value = true;
  601. Hid.EnableKeyboard.Value = false;
  602. Hid.EnableMouse.Value = false;
  603. Hid.Hotkeys.Value = new KeyboardHotkeys
  604. {
  605. ToggleVsync = Key.Tab,
  606. ToggleMute = Key.F2,
  607. Screenshot = Key.F8,
  608. ShowUi = Key.F4,
  609. Pause = Key.F5,
  610. ResScaleUp = Key.Unbound,
  611. ResScaleDown = Key.Unbound,
  612. VolumeUp = Key.Unbound,
  613. VolumeDown = Key.Unbound
  614. };
  615. Hid.InputConfig.Value = new List<InputConfig>
  616. {
  617. new StandardKeyboardInputConfig
  618. {
  619. Version = InputConfig.CurrentVersion,
  620. Backend = InputBackendType.WindowKeyboard,
  621. Id = "0",
  622. PlayerIndex = PlayerIndex.Player1,
  623. ControllerType = ControllerType.JoyconPair,
  624. LeftJoycon = new LeftJoyconCommonConfig<Key>
  625. {
  626. DpadUp = Key.Up,
  627. DpadDown = Key.Down,
  628. DpadLeft = Key.Left,
  629. DpadRight = Key.Right,
  630. ButtonMinus = Key.Minus,
  631. ButtonL = Key.E,
  632. ButtonZl = Key.Q,
  633. ButtonSl = Key.Unbound,
  634. ButtonSr = Key.Unbound
  635. },
  636. LeftJoyconStick = new JoyconConfigKeyboardStick<Key>
  637. {
  638. StickUp = Key.W,
  639. StickDown = Key.S,
  640. StickLeft = Key.A,
  641. StickRight = Key.D,
  642. StickButton = Key.F,
  643. },
  644. RightJoycon = new RightJoyconCommonConfig<Key>
  645. {
  646. ButtonA = Key.Z,
  647. ButtonB = Key.X,
  648. ButtonX = Key.C,
  649. ButtonY = Key.V,
  650. ButtonPlus = Key.Plus,
  651. ButtonR = Key.U,
  652. ButtonZr = Key.O,
  653. ButtonSl = Key.Unbound,
  654. ButtonSr = Key.Unbound
  655. },
  656. RightJoyconStick = new JoyconConfigKeyboardStick<Key>
  657. {
  658. StickUp = Key.I,
  659. StickDown = Key.K,
  660. StickLeft = Key.J,
  661. StickRight = Key.L,
  662. StickButton = Key.H,
  663. }
  664. }
  665. };
  666. }
  667. public ConfigurationLoadResult Load(ConfigurationFileFormat configurationFileFormat, string configurationFilePath)
  668. {
  669. bool configurationFileUpdated = false;
  670. if (configurationFileFormat.Version < 0 || configurationFileFormat.Version > ConfigurationFileFormat.CurrentVersion)
  671. {
  672. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Unsupported configuration version {configurationFileFormat.Version}, loading default.");
  673. LoadDefault();
  674. return ConfigurationLoadResult.NotLoaded;
  675. }
  676. ConfigurationLoadResult result = ConfigurationLoadResult.Success;
  677. if (configurationFileFormat.Version < 2)
  678. {
  679. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 2.");
  680. configurationFileFormat.SystemRegion = Region.USA;
  681. configurationFileUpdated = true;
  682. }
  683. if (configurationFileFormat.Version < 3)
  684. {
  685. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 3.");
  686. configurationFileFormat.SystemTimeZone = "UTC";
  687. configurationFileUpdated = true;
  688. }
  689. if (configurationFileFormat.Version < 4)
  690. {
  691. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 4.");
  692. configurationFileFormat.MaxAnisotropy = -1;
  693. configurationFileUpdated = true;
  694. }
  695. if (configurationFileFormat.Version < 5)
  696. {
  697. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 5.");
  698. configurationFileFormat.SystemTimeOffset = 0;
  699. configurationFileUpdated = true;
  700. }
  701. if (configurationFileFormat.Version < 8)
  702. {
  703. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 8.");
  704. configurationFileFormat.EnablePtc = true;
  705. configurationFileUpdated = true;
  706. }
  707. if (configurationFileFormat.Version < 9)
  708. {
  709. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 9.");
  710. configurationFileFormat.ColumnSort = new ColumnSort
  711. {
  712. SortColumnId = 0,
  713. SortAscending = false
  714. };
  715. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  716. {
  717. ToggleVsync = Key.Tab
  718. };
  719. configurationFileUpdated = true;
  720. }
  721. if (configurationFileFormat.Version < 10)
  722. {
  723. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 10.");
  724. configurationFileFormat.AudioBackend = AudioBackend.OpenAl;
  725. configurationFileUpdated = true;
  726. }
  727. if (configurationFileFormat.Version < 11)
  728. {
  729. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 11.");
  730. configurationFileFormat.ResScale = 1;
  731. configurationFileFormat.ResScaleCustom = 1.0f;
  732. configurationFileUpdated = true;
  733. }
  734. if (configurationFileFormat.Version < 12)
  735. {
  736. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 12.");
  737. configurationFileFormat.LoggingGraphicsDebugLevel = GraphicsDebugLevel.None;
  738. configurationFileUpdated = true;
  739. }
  740. if (configurationFileFormat.Version < 14)
  741. {
  742. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 14.");
  743. configurationFileFormat.CheckUpdatesOnStart = true;
  744. configurationFileUpdated = true;
  745. }
  746. if (configurationFileFormat.Version < 16)
  747. {
  748. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 16.");
  749. configurationFileFormat.EnableShaderCache = true;
  750. configurationFileUpdated = true;
  751. }
  752. if (configurationFileFormat.Version < 17)
  753. {
  754. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 17.");
  755. configurationFileFormat.StartFullscreen = false;
  756. configurationFileUpdated = true;
  757. }
  758. if (configurationFileFormat.Version < 18)
  759. {
  760. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 18.");
  761. configurationFileFormat.AspectRatio = AspectRatio.Fixed16x9;
  762. configurationFileUpdated = true;
  763. }
  764. if (configurationFileFormat.Version < 20)
  765. {
  766. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 20.");
  767. configurationFileFormat.ShowConfirmExit = true;
  768. configurationFileUpdated = true;
  769. }
  770. if (configurationFileFormat.Version < 22)
  771. {
  772. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 22.");
  773. configurationFileFormat.HideCursorOnIdle = false;
  774. configurationFileUpdated = true;
  775. }
  776. if (configurationFileFormat.Version < 24)
  777. {
  778. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 24.");
  779. configurationFileFormat.InputConfig = new List<InputConfig>
  780. {
  781. new StandardKeyboardInputConfig
  782. {
  783. Version = InputConfig.CurrentVersion,
  784. Backend = InputBackendType.WindowKeyboard,
  785. Id = "0",
  786. PlayerIndex = PlayerIndex.Player1,
  787. ControllerType = ControllerType.JoyconPair,
  788. LeftJoycon = new LeftJoyconCommonConfig<Key>
  789. {
  790. DpadUp = Key.Up,
  791. DpadDown = Key.Down,
  792. DpadLeft = Key.Left,
  793. DpadRight = Key.Right,
  794. ButtonMinus = Key.Minus,
  795. ButtonL = Key.E,
  796. ButtonZl = Key.Q,
  797. ButtonSl = Key.Unbound,
  798. ButtonSr = Key.Unbound
  799. },
  800. LeftJoyconStick = new JoyconConfigKeyboardStick<Key>
  801. {
  802. StickUp = Key.W,
  803. StickDown = Key.S,
  804. StickLeft = Key.A,
  805. StickRight = Key.D,
  806. StickButton = Key.F,
  807. },
  808. RightJoycon = new RightJoyconCommonConfig<Key>
  809. {
  810. ButtonA = Key.Z,
  811. ButtonB = Key.X,
  812. ButtonX = Key.C,
  813. ButtonY = Key.V,
  814. ButtonPlus = Key.Plus,
  815. ButtonR = Key.U,
  816. ButtonZr = Key.O,
  817. ButtonSl = Key.Unbound,
  818. ButtonSr = Key.Unbound
  819. },
  820. RightJoyconStick = new JoyconConfigKeyboardStick<Key>
  821. {
  822. StickUp = Key.I,
  823. StickDown = Key.K,
  824. StickLeft = Key.J,
  825. StickRight = Key.L,
  826. StickButton = Key.H,
  827. }
  828. }
  829. };
  830. configurationFileUpdated = true;
  831. }
  832. if (configurationFileFormat.Version < 25)
  833. {
  834. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 25.");
  835. configurationFileUpdated = true;
  836. }
  837. if (configurationFileFormat.Version < 26)
  838. {
  839. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 26.");
  840. configurationFileFormat.MemoryManagerMode = MemoryManagerMode.HostMappedUnsafe;
  841. configurationFileUpdated = true;
  842. }
  843. if (configurationFileFormat.Version < 27)
  844. {
  845. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 27.");
  846. configurationFileFormat.EnableMouse = false;
  847. configurationFileUpdated = true;
  848. }
  849. if (configurationFileFormat.Version < 28)
  850. {
  851. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 28.");
  852. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  853. {
  854. ToggleVsync = Key.Tab,
  855. Screenshot = Key.F8
  856. };
  857. configurationFileUpdated = true;
  858. }
  859. if (configurationFileFormat.Version < 29)
  860. {
  861. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 29.");
  862. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  863. {
  864. ToggleVsync = Key.Tab,
  865. Screenshot = Key.F8,
  866. ShowUi = Key.F4
  867. };
  868. configurationFileUpdated = true;
  869. }
  870. if (configurationFileFormat.Version < 30)
  871. {
  872. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 30.");
  873. foreach(InputConfig config in configurationFileFormat.InputConfig)
  874. {
  875. if (config is StandardControllerInputConfig controllerConfig)
  876. {
  877. controllerConfig.Rumble = new RumbleConfigController
  878. {
  879. EnableRumble = false,
  880. StrongRumble = 1f,
  881. WeakRumble = 1f
  882. };
  883. }
  884. }
  885. configurationFileUpdated = true;
  886. }
  887. if (configurationFileFormat.Version < 31)
  888. {
  889. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 31.");
  890. configurationFileFormat.BackendThreading = BackendThreading.Auto;
  891. configurationFileUpdated = true;
  892. }
  893. if (configurationFileFormat.Version < 32)
  894. {
  895. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 32.");
  896. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  897. {
  898. ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync,
  899. Screenshot = configurationFileFormat.Hotkeys.Screenshot,
  900. ShowUi = configurationFileFormat.Hotkeys.ShowUi,
  901. Pause = Key.F5
  902. };
  903. configurationFileUpdated = true;
  904. }
  905. if (configurationFileFormat.Version < 33)
  906. {
  907. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 33.");
  908. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  909. {
  910. ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync,
  911. Screenshot = configurationFileFormat.Hotkeys.Screenshot,
  912. ShowUi = configurationFileFormat.Hotkeys.ShowUi,
  913. Pause = configurationFileFormat.Hotkeys.Pause,
  914. ToggleMute = Key.F2
  915. };
  916. configurationFileFormat.AudioVolume = 1;
  917. configurationFileUpdated = true;
  918. }
  919. if (configurationFileFormat.Version < 34)
  920. {
  921. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 34.");
  922. configurationFileFormat.EnableInternetAccess = false;
  923. configurationFileUpdated = true;
  924. }
  925. if (configurationFileFormat.Version < 35)
  926. {
  927. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 35.");
  928. foreach (InputConfig config in configurationFileFormat.InputConfig)
  929. {
  930. if (config is StandardControllerInputConfig controllerConfig)
  931. {
  932. controllerConfig.RangeLeft = 1.0f;
  933. controllerConfig.RangeRight = 1.0f;
  934. }
  935. }
  936. configurationFileUpdated = true;
  937. }
  938. if (configurationFileFormat.Version < 36)
  939. {
  940. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 36.");
  941. configurationFileFormat.LoggingEnableTrace = false;
  942. configurationFileUpdated = true;
  943. }
  944. if (configurationFileFormat.Version < 37)
  945. {
  946. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 37.");
  947. configurationFileFormat.ShowConsole = true;
  948. configurationFileUpdated = true;
  949. }
  950. if (configurationFileFormat.Version < 38)
  951. {
  952. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 38.");
  953. configurationFileFormat.BaseStyle = "Dark";
  954. configurationFileFormat.GameListViewMode = 0;
  955. configurationFileFormat.ShowNames = true;
  956. configurationFileFormat.GridSize = 2;
  957. configurationFileFormat.LanguageCode = "en_US";
  958. configurationFileUpdated = true;
  959. }
  960. if (configurationFileFormat.Version < 39)
  961. {
  962. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 39.");
  963. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  964. {
  965. ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync,
  966. Screenshot = configurationFileFormat.Hotkeys.Screenshot,
  967. ShowUi = configurationFileFormat.Hotkeys.ShowUi,
  968. Pause = configurationFileFormat.Hotkeys.Pause,
  969. ToggleMute = configurationFileFormat.Hotkeys.ToggleMute,
  970. ResScaleUp = Key.Unbound,
  971. ResScaleDown = Key.Unbound
  972. };
  973. configurationFileUpdated = true;
  974. }
  975. if (configurationFileFormat.Version < 40)
  976. {
  977. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 40.");
  978. configurationFileFormat.GraphicsBackend = GraphicsBackend.OpenGl;
  979. result |= ConfigurationLoadResult.MigratedFromPreVulkan;
  980. configurationFileUpdated = true;
  981. }
  982. if (configurationFileFormat.Version < 41)
  983. {
  984. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 41.");
  985. configurationFileFormat.Hotkeys = new KeyboardHotkeys
  986. {
  987. ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync,
  988. Screenshot = configurationFileFormat.Hotkeys.Screenshot,
  989. ShowUi = configurationFileFormat.Hotkeys.ShowUi,
  990. Pause = configurationFileFormat.Hotkeys.Pause,
  991. ToggleMute = configurationFileFormat.Hotkeys.ToggleMute,
  992. ResScaleUp = configurationFileFormat.Hotkeys.ResScaleUp,
  993. ResScaleDown = configurationFileFormat.Hotkeys.ResScaleDown,
  994. VolumeUp = Key.Unbound,
  995. VolumeDown = Key.Unbound
  996. };
  997. }
  998. if (configurationFileFormat.Version < 42)
  999. {
  1000. Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 42.");
  1001. configurationFileFormat.EnableMacroHLE = true;
  1002. }
  1003. Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog;
  1004. Graphics.ResScale.Value = configurationFileFormat.ResScale;
  1005. Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom;
  1006. Graphics.MaxAnisotropy.Value = configurationFileFormat.MaxAnisotropy;
  1007. Graphics.AspectRatio.Value = configurationFileFormat.AspectRatio;
  1008. Graphics.ShadersDumpPath.Value = configurationFileFormat.GraphicsShadersDumpPath;
  1009. Graphics.BackendThreading.Value = configurationFileFormat.BackendThreading;
  1010. Graphics.GraphicsBackend.Value = configurationFileFormat.GraphicsBackend;
  1011. Graphics.PreferredGpu.Value = configurationFileFormat.PreferredGpu;
  1012. Logger.EnableDebug.Value = configurationFileFormat.LoggingEnableDebug;
  1013. Logger.EnableStub.Value = configurationFileFormat.LoggingEnableStub;
  1014. Logger.EnableInfo.Value = configurationFileFormat.LoggingEnableInfo;
  1015. Logger.EnableWarn.Value = configurationFileFormat.LoggingEnableWarn;
  1016. Logger.EnableError.Value = configurationFileFormat.LoggingEnableError;
  1017. Logger.EnableTrace.Value = configurationFileFormat.LoggingEnableTrace;
  1018. Logger.EnableGuest.Value = configurationFileFormat.LoggingEnableGuest;
  1019. Logger.EnableFsAccessLog.Value = configurationFileFormat.LoggingEnableFsAccessLog;
  1020. Logger.FilteredClasses.Value = configurationFileFormat.LoggingFilteredClasses;
  1021. Logger.GraphicsDebugLevel.Value = configurationFileFormat.LoggingGraphicsDebugLevel;
  1022. System.Language.Value = configurationFileFormat.SystemLanguage;
  1023. System.Region.Value = configurationFileFormat.SystemRegion;
  1024. System.TimeZone.Value = configurationFileFormat.SystemTimeZone;
  1025. System.SystemTimeOffset.Value = configurationFileFormat.SystemTimeOffset;
  1026. System.EnableDockedMode.Value = configurationFileFormat.DockedMode;
  1027. EnableDiscordIntegration.Value = configurationFileFormat.EnableDiscordIntegration;
  1028. CheckUpdatesOnStart.Value = configurationFileFormat.CheckUpdatesOnStart;
  1029. ShowConfirmExit.Value = configurationFileFormat.ShowConfirmExit;
  1030. HideCursorOnIdle.Value = configurationFileFormat.HideCursorOnIdle;
  1031. Graphics.EnableVsync.Value = configurationFileFormat.EnableVsync;
  1032. Graphics.EnableShaderCache.Value = configurationFileFormat.EnableShaderCache;
  1033. Graphics.EnableTextureRecompression.Value = configurationFileFormat.EnableTextureRecompression;
  1034. Graphics.EnableMacroHLE.Value = configurationFileFormat.EnableMacroHLE;
  1035. System.EnablePtc.Value = configurationFileFormat.EnablePtc;
  1036. System.EnableInternetAccess.Value = configurationFileFormat.EnableInternetAccess;
  1037. System.EnableFsIntegrityChecks.Value = configurationFileFormat.EnableFsIntegrityChecks;
  1038. System.FsGlobalAccessLogMode.Value = configurationFileFormat.FsGlobalAccessLogMode;
  1039. System.AudioBackend.Value = configurationFileFormat.AudioBackend;
  1040. System.AudioVolume.Value = configurationFileFormat.AudioVolume;
  1041. System.MemoryManagerMode.Value = configurationFileFormat.MemoryManagerMode;
  1042. System.ExpandRam.Value = configurationFileFormat.ExpandRam;
  1043. System.IgnoreMissingServices.Value = configurationFileFormat.IgnoreMissingServices;
  1044. Ui.GuiColumns.FavColumn.Value = configurationFileFormat.GuiColumns.FavColumn;
  1045. Ui.GuiColumns.IconColumn.Value = configurationFileFormat.GuiColumns.IconColumn;
  1046. Ui.GuiColumns.AppColumn.Value = configurationFileFormat.GuiColumns.AppColumn;
  1047. Ui.GuiColumns.DevColumn.Value = configurationFileFormat.GuiColumns.DevColumn;
  1048. Ui.GuiColumns.VersionColumn.Value = configurationFileFormat.GuiColumns.VersionColumn;
  1049. Ui.GuiColumns.TimePlayedColumn.Value = configurationFileFormat.GuiColumns.TimePlayedColumn;
  1050. Ui.GuiColumns.LastPlayedColumn.Value = configurationFileFormat.GuiColumns.LastPlayedColumn;
  1051. Ui.GuiColumns.FileExtColumn.Value = configurationFileFormat.GuiColumns.FileExtColumn;
  1052. Ui.GuiColumns.FileSizeColumn.Value = configurationFileFormat.GuiColumns.FileSizeColumn;
  1053. Ui.GuiColumns.PathColumn.Value = configurationFileFormat.GuiColumns.PathColumn;
  1054. Ui.ColumnSort.SortColumnId.Value = configurationFileFormat.ColumnSort.SortColumnId;
  1055. Ui.ColumnSort.SortAscending.Value = configurationFileFormat.ColumnSort.SortAscending;
  1056. Ui.GameDirs.Value = configurationFileFormat.GameDirs;
  1057. Ui.EnableCustomTheme.Value = configurationFileFormat.EnableCustomTheme;
  1058. Ui.LanguageCode.Value = configurationFileFormat.LanguageCode;
  1059. Ui.CustomThemePath.Value = configurationFileFormat.CustomThemePath;
  1060. Ui.BaseStyle.Value = configurationFileFormat.BaseStyle;
  1061. Ui.GameListViewMode.Value = configurationFileFormat.GameListViewMode;
  1062. Ui.ShowNames.Value = configurationFileFormat.ShowNames;
  1063. Ui.IsAscendingOrder.Value = configurationFileFormat.IsAscendingOrder;
  1064. Ui.GridSize.Value = configurationFileFormat.GridSize;
  1065. Ui.ApplicationSort.Value = configurationFileFormat.ApplicationSort;
  1066. Ui.StartFullscreen.Value = configurationFileFormat.StartFullscreen;
  1067. Ui.ShowConsole.Value = configurationFileFormat.ShowConsole;
  1068. Hid.EnableKeyboard.Value = configurationFileFormat.EnableKeyboard;
  1069. Hid.EnableMouse.Value = configurationFileFormat.EnableMouse;
  1070. Hid.Hotkeys.Value = configurationFileFormat.Hotkeys;
  1071. Hid.InputConfig.Value = configurationFileFormat.InputConfig;
  1072. if (Hid.InputConfig.Value == null)
  1073. {
  1074. Hid.InputConfig.Value = new List<InputConfig>();
  1075. }
  1076. if (configurationFileUpdated)
  1077. {
  1078. ToFileFormat().SaveConfig(configurationFilePath);
  1079. Ryujinx.Common.Logging.Logger.Notice.Print(LogClass.Application, $"Configuration file updated to version {ConfigurationFileFormat.CurrentVersion}");
  1080. }
  1081. return result;
  1082. }
  1083. private static void LogValueChange<T>(object sender, ReactiveEventArgs<T> eventArgs, string valueName)
  1084. {
  1085. Ryujinx.Common.Logging.Logger.Info?.Print(LogClass.Configuration, $"{valueName} set to: {eventArgs.NewValue}");
  1086. }
  1087. public static void Initialize()
  1088. {
  1089. if (Instance != null)
  1090. {
  1091. throw new InvalidOperationException("Configuration is already initialized");
  1092. }
  1093. Instance = new ConfigurationState();
  1094. }
  1095. }
  1096. }