ConfigurationState.Model.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784
  1. using ARMeilleure;
  2. using Gommon;
  3. using Ryujinx.Ava.Utilities.Configuration.System;
  4. using Ryujinx.Common;
  5. using Ryujinx.Common.Configuration;
  6. using Ryujinx.Common.Configuration.Hid;
  7. using Ryujinx.Common.Configuration.Multiplayer;
  8. using Ryujinx.Common.Helper;
  9. using Ryujinx.Common.Logging;
  10. using Ryujinx.HLE;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. using RyuLogger = Ryujinx.Common.Logging.Logger;
  14. namespace Ryujinx.Ava.Utilities.Configuration
  15. {
  16. public partial class ConfigurationState
  17. {
  18. /// <summary>
  19. /// UI configuration section
  20. /// </summary>
  21. public class UISection
  22. {
  23. public class Columns
  24. {
  25. public ReactiveObject<bool> FavColumn { get; private set; }
  26. public ReactiveObject<bool> IconColumn { get; private set; }
  27. public ReactiveObject<bool> AppColumn { get; private set; }
  28. public ReactiveObject<bool> DevColumn { get; private set; }
  29. public ReactiveObject<bool> VersionColumn { get; private set; }
  30. public ReactiveObject<bool> LdnInfoColumn { get; private set; }
  31. public ReactiveObject<bool> TimePlayedColumn { get; private set; }
  32. public ReactiveObject<bool> LastPlayedColumn { get; private set; }
  33. public ReactiveObject<bool> FileExtColumn { get; private set; }
  34. public ReactiveObject<bool> FileSizeColumn { get; private set; }
  35. public ReactiveObject<bool> PathColumn { get; private set; }
  36. public Columns()
  37. {
  38. FavColumn = new ReactiveObject<bool>();
  39. IconColumn = new ReactiveObject<bool>();
  40. AppColumn = new ReactiveObject<bool>();
  41. DevColumn = new ReactiveObject<bool>();
  42. VersionColumn = new ReactiveObject<bool>();
  43. LdnInfoColumn = new ReactiveObject<bool>();
  44. TimePlayedColumn = new ReactiveObject<bool>();
  45. LastPlayedColumn = new ReactiveObject<bool>();
  46. FileExtColumn = new ReactiveObject<bool>();
  47. FileSizeColumn = new ReactiveObject<bool>();
  48. PathColumn = new ReactiveObject<bool>();
  49. }
  50. }
  51. public class ColumnSortSettings
  52. {
  53. public ReactiveObject<int> SortColumnId { get; private set; }
  54. public ReactiveObject<bool> SortAscending { get; private set; }
  55. public ColumnSortSettings()
  56. {
  57. SortColumnId = new ReactiveObject<int>();
  58. SortAscending = new ReactiveObject<bool>();
  59. }
  60. }
  61. /// <summary>
  62. /// Used to toggle which file types are shown in the UI
  63. /// </summary>
  64. public class ShownFileTypeSettings
  65. {
  66. public ReactiveObject<bool> NSP { get; private set; }
  67. public ReactiveObject<bool> PFS0 { get; private set; }
  68. public ReactiveObject<bool> XCI { get; private set; }
  69. public ReactiveObject<bool> NCA { get; private set; }
  70. public ReactiveObject<bool> NRO { get; private set; }
  71. public ReactiveObject<bool> NSO { get; private set; }
  72. public ShownFileTypeSettings()
  73. {
  74. NSP = new ReactiveObject<bool>();
  75. PFS0 = new ReactiveObject<bool>();
  76. XCI = new ReactiveObject<bool>();
  77. NCA = new ReactiveObject<bool>();
  78. NRO = new ReactiveObject<bool>();
  79. NSO = new ReactiveObject<bool>();
  80. }
  81. }
  82. // <summary>
  83. /// Determines main window start-up position, size and state
  84. ///<summary>
  85. public class WindowStartupSettings
  86. {
  87. public ReactiveObject<int> WindowSizeWidth { get; private set; }
  88. public ReactiveObject<int> WindowSizeHeight { get; private set; }
  89. public ReactiveObject<int> WindowPositionX { get; private set; }
  90. public ReactiveObject<int> WindowPositionY { get; private set; }
  91. public ReactiveObject<bool> WindowMaximized { get; private set; }
  92. public WindowStartupSettings()
  93. {
  94. WindowSizeWidth = new ReactiveObject<int>();
  95. WindowSizeHeight = new ReactiveObject<int>();
  96. WindowPositionX = new ReactiveObject<int>();
  97. WindowPositionY = new ReactiveObject<int>();
  98. WindowMaximized = new ReactiveObject<bool>();
  99. }
  100. }
  101. /// <summary>
  102. /// Used to toggle columns in the GUI
  103. /// </summary>
  104. public Columns GuiColumns { get; private set; }
  105. /// <summary>
  106. /// Used to configure column sort settings in the GUI
  107. /// </summary>
  108. public ColumnSortSettings ColumnSort { get; private set; }
  109. /// <summary>
  110. /// A list of directories containing games to be used to load games into the games list
  111. /// </summary>
  112. public ReactiveObject<List<string>> GameDirs { get; private set; }
  113. /// <summary>
  114. /// A list of directories containing DLC/updates the user wants to autoload during library refreshes
  115. /// </summary>
  116. public ReactiveObject<List<string>> AutoloadDirs { get; private set; }
  117. /// <summary>
  118. /// A list of file types to be hidden in the games List
  119. /// </summary>
  120. public ShownFileTypeSettings ShownFileTypes { get; private set; }
  121. /// <summary>
  122. /// Determines main window start-up position, size and state
  123. /// </summary>
  124. public WindowStartupSettings WindowStartup { get; private set; }
  125. /// <summary>
  126. /// Language Code for the UI
  127. /// </summary>
  128. public ReactiveObject<string> LanguageCode { get; private set; }
  129. /// <summary>
  130. /// Selects the base style
  131. /// </summary>
  132. public ReactiveObject<string> BaseStyle { get; private set; }
  133. /// <summary>
  134. /// Start games in fullscreen mode
  135. /// </summary>
  136. public ReactiveObject<bool> StartFullscreen { get; private set; }
  137. /// <summary>
  138. /// Hide / Show Console Window
  139. /// </summary>
  140. public ReactiveObject<bool> ShowConsole { get; private set; }
  141. /// <summary>
  142. /// View Mode of the Game list
  143. /// </summary>
  144. public ReactiveObject<int> GameListViewMode { get; private set; }
  145. /// <summary>
  146. /// Show application name in Grid Mode
  147. /// </summary>
  148. public ReactiveObject<bool> ShowNames { get; private set; }
  149. /// <summary>
  150. /// Sets App Icon Size in Grid Mode
  151. /// </summary>
  152. public ReactiveObject<int> GridSize { get; private set; }
  153. /// <summary>
  154. /// Sorts Apps in Grid Mode
  155. /// </summary>
  156. public ReactiveObject<int> ApplicationSort { get; private set; }
  157. /// <summary>
  158. /// Sets if Grid is ordered in Ascending Order
  159. /// </summary>
  160. public ReactiveObject<bool> IsAscendingOrder { get; private set; }
  161. public UISection()
  162. {
  163. GuiColumns = new Columns();
  164. ColumnSort = new ColumnSortSettings();
  165. GameDirs = new ReactiveObject<List<string>>();
  166. AutoloadDirs = new ReactiveObject<List<string>>();
  167. ShownFileTypes = new ShownFileTypeSettings();
  168. WindowStartup = new WindowStartupSettings();
  169. BaseStyle = new ReactiveObject<string>();
  170. StartFullscreen = new ReactiveObject<bool>();
  171. GameListViewMode = new ReactiveObject<int>();
  172. ShowNames = new ReactiveObject<bool>();
  173. GridSize = new ReactiveObject<int>();
  174. ApplicationSort = new ReactiveObject<int>();
  175. IsAscendingOrder = new ReactiveObject<bool>();
  176. LanguageCode = new ReactiveObject<string>();
  177. ShowConsole = new ReactiveObject<bool>();
  178. ShowConsole.Event += static (_, e) => ConsoleHelper.SetConsoleWindowState(e.NewValue);
  179. }
  180. }
  181. /// <summary>
  182. /// Logger configuration section
  183. /// </summary>
  184. public class LoggerSection
  185. {
  186. /// <summary>
  187. /// Enables printing debug log messages
  188. /// </summary>
  189. public ReactiveObject<bool> EnableDebug { get; private set; }
  190. /// <summary>
  191. /// Enables printing stub log messages
  192. /// </summary>
  193. public ReactiveObject<bool> EnableStub { get; private set; }
  194. /// <summary>
  195. /// Enables printing info log messages
  196. /// </summary>
  197. public ReactiveObject<bool> EnableInfo { get; private set; }
  198. /// <summary>
  199. /// Enables printing warning log messages
  200. /// </summary>
  201. public ReactiveObject<bool> EnableWarn { get; private set; }
  202. /// <summary>
  203. /// Enables printing error log messages
  204. /// </summary>
  205. public ReactiveObject<bool> EnableError { get; private set; }
  206. /// <summary>
  207. /// Enables printing trace log messages
  208. /// </summary>
  209. public ReactiveObject<bool> EnableTrace { get; private set; }
  210. /// <summary>
  211. /// Enables printing guest log messages
  212. /// </summary>
  213. public ReactiveObject<bool> EnableGuest { get; private set; }
  214. /// <summary>
  215. /// Enables printing FS access log messages
  216. /// </summary>
  217. public ReactiveObject<bool> EnableFsAccessLog { get; private set; }
  218. /// <summary>
  219. /// Controls which log messages are written to the log targets
  220. /// </summary>
  221. public ReactiveObject<LogClass[]> FilteredClasses { get; private set; }
  222. /// <summary>
  223. /// Enables or disables logging to a file on disk
  224. /// </summary>
  225. public ReactiveObject<bool> EnableFileLog { get; private set; }
  226. /// <summary>
  227. /// Controls which OpenGL log messages are recorded in the log
  228. /// </summary>
  229. public ReactiveObject<GraphicsDebugLevel> GraphicsDebugLevel { get; private set; }
  230. public LoggerSection()
  231. {
  232. EnableDebug = new ReactiveObject<bool>();
  233. EnableDebug.LogChangesToValue(nameof(EnableDebug));
  234. EnableStub = new ReactiveObject<bool>();
  235. EnableInfo = new ReactiveObject<bool>();
  236. EnableWarn = new ReactiveObject<bool>();
  237. EnableError = new ReactiveObject<bool>();
  238. EnableTrace = new ReactiveObject<bool>();
  239. EnableGuest = new ReactiveObject<bool>();
  240. EnableFsAccessLog = new ReactiveObject<bool>();
  241. FilteredClasses = new ReactiveObject<LogClass[]>();
  242. EnableFileLog = new ReactiveObject<bool>();
  243. EnableFileLog.LogChangesToValue(nameof(EnableFileLog));
  244. GraphicsDebugLevel = new ReactiveObject<GraphicsDebugLevel>();
  245. }
  246. }
  247. /// <summary>
  248. /// System configuration section
  249. /// </summary>
  250. public class SystemSection
  251. {
  252. /// <summary>
  253. /// Change System Language
  254. /// </summary>
  255. public ReactiveObject<Language> Language { get; private set; }
  256. /// <summary>
  257. /// Change System Region
  258. /// </summary>
  259. public ReactiveObject<Region> Region { get; private set; }
  260. /// <summary>
  261. /// Change System TimeZone
  262. /// </summary>
  263. public ReactiveObject<string> TimeZone { get; private set; }
  264. /// <summary>
  265. /// System Time Offset in Seconds
  266. /// </summary>
  267. public ReactiveObject<long> SystemTimeOffset { get; private set; }
  268. /// <summary>
  269. /// Enables or disables Docked Mode
  270. /// </summary>
  271. public ReactiveObject<bool> EnableDockedMode { get; private set; }
  272. /// <summary>
  273. /// Enables or disables persistent profiled translation cache
  274. /// </summary>
  275. public ReactiveObject<bool> EnablePtc { get; private set; }
  276. /// <summary>
  277. /// Enables or disables low-power persistent profiled translation cache loading
  278. /// </summary>
  279. public ReactiveObject<bool> EnableLowPowerPtc { get; private set; }
  280. /// <summary>
  281. /// Enables or disables guest Internet access
  282. /// </summary>
  283. public ReactiveObject<bool> EnableInternetAccess { get; private set; }
  284. /// <summary>
  285. /// Enables integrity checks on Game content files
  286. /// </summary>
  287. public ReactiveObject<bool> EnableFsIntegrityChecks { get; private set; }
  288. /// <summary>
  289. /// Enables FS access log output to the console. Possible modes are 0-3
  290. /// </summary>
  291. public ReactiveObject<int> FsGlobalAccessLogMode { get; private set; }
  292. /// <summary>
  293. /// The selected audio backend
  294. /// </summary>
  295. public ReactiveObject<AudioBackend> AudioBackend { get; private set; }
  296. /// <summary>
  297. /// The audio backend volume
  298. /// </summary>
  299. public ReactiveObject<float> AudioVolume { get; private set; }
  300. /// <summary>
  301. /// The selected memory manager mode
  302. /// </summary>
  303. public ReactiveObject<MemoryManagerMode> MemoryManagerMode { get; private set; }
  304. /// <summary>
  305. /// Defines the amount of RAM available on the emulated system, and how it is distributed
  306. /// </summary>
  307. public ReactiveObject<MemoryConfiguration> DramSize { get; private set; }
  308. /// <summary>
  309. /// Enable or disable ignoring missing services
  310. /// </summary>
  311. public ReactiveObject<bool> IgnoreMissingServices { get; private set; }
  312. /// <summary>
  313. /// Uses Hypervisor over JIT if available
  314. /// </summary>
  315. public ReactiveObject<bool> UseHypervisor { get; private set; }
  316. public SystemSection()
  317. {
  318. Language = new ReactiveObject<Language>();
  319. Language.LogChangesToValue(nameof(Language));
  320. Region = new ReactiveObject<Region>();
  321. Region.LogChangesToValue(nameof(Region));
  322. TimeZone = new ReactiveObject<string>();
  323. TimeZone.LogChangesToValue(nameof(TimeZone));
  324. SystemTimeOffset = new ReactiveObject<long>();
  325. SystemTimeOffset.LogChangesToValue(nameof(SystemTimeOffset));
  326. EnableDockedMode = new ReactiveObject<bool>();
  327. EnableDockedMode.LogChangesToValue(nameof(EnableDockedMode));
  328. EnablePtc = new ReactiveObject<bool>();
  329. EnablePtc.LogChangesToValue(nameof(EnablePtc));
  330. EnableLowPowerPtc = new ReactiveObject<bool>();
  331. EnableLowPowerPtc.LogChangesToValue(nameof(EnableLowPowerPtc));
  332. EnableLowPowerPtc.Event += (_, evnt)
  333. => Optimizations.LowPower = evnt.NewValue;
  334. EnableInternetAccess = new ReactiveObject<bool>();
  335. EnableInternetAccess.LogChangesToValue(nameof(EnableInternetAccess));
  336. EnableFsIntegrityChecks = new ReactiveObject<bool>();
  337. EnableFsIntegrityChecks.LogChangesToValue(nameof(EnableFsIntegrityChecks));
  338. FsGlobalAccessLogMode = new ReactiveObject<int>();
  339. FsGlobalAccessLogMode.LogChangesToValue(nameof(FsGlobalAccessLogMode));
  340. AudioBackend = new ReactiveObject<AudioBackend>();
  341. AudioBackend.LogChangesToValue(nameof(AudioBackend));
  342. MemoryManagerMode = new ReactiveObject<MemoryManagerMode>();
  343. MemoryManagerMode.LogChangesToValue(nameof(MemoryManagerMode));
  344. DramSize = new ReactiveObject<MemoryConfiguration>();
  345. DramSize.LogChangesToValue(nameof(DramSize));
  346. IgnoreMissingServices = new ReactiveObject<bool>();
  347. IgnoreMissingServices.LogChangesToValue(nameof(IgnoreMissingServices));
  348. AudioVolume = new ReactiveObject<float>();
  349. AudioVolume.LogChangesToValue(nameof(AudioVolume));
  350. UseHypervisor = new ReactiveObject<bool>();
  351. UseHypervisor.LogChangesToValue(nameof(UseHypervisor));
  352. }
  353. }
  354. /// <summary>
  355. /// Hid configuration section
  356. /// </summary>
  357. public class HidSection
  358. {
  359. /// <summary>
  360. /// Enable or disable keyboard support (Independent from controllers binding)
  361. /// </summary>
  362. public ReactiveObject<bool> EnableKeyboard { get; private set; }
  363. /// <summary>
  364. /// Enable or disable mouse support (Independent from controllers binding)
  365. /// </summary>
  366. public ReactiveObject<bool> EnableMouse { get; private set; }
  367. /// <summary>
  368. /// Hotkey Keyboard Bindings
  369. /// </summary>
  370. public ReactiveObject<KeyboardHotkeys> Hotkeys { get; private set; }
  371. /// <summary>
  372. /// Input device configuration.
  373. /// NOTE: This ReactiveObject won't issue an event when the List has elements added or removed.
  374. /// TODO: Implement a ReactiveList class.
  375. /// </summary>
  376. public ReactiveObject<List<InputConfig>> InputConfig { get; private set; }
  377. public HidSection()
  378. {
  379. EnableKeyboard = new ReactiveObject<bool>();
  380. EnableMouse = new ReactiveObject<bool>();
  381. Hotkeys = new ReactiveObject<KeyboardHotkeys>();
  382. InputConfig = new ReactiveObject<List<InputConfig>>();
  383. }
  384. }
  385. /// <summary>
  386. /// Graphics configuration section
  387. /// </summary>
  388. public class GraphicsSection
  389. {
  390. /// <summary>
  391. /// Whether or not backend threading is enabled. The "Auto" setting will determine whether threading should be enabled at runtime.
  392. /// </summary>
  393. public ReactiveObject<BackendThreading> BackendThreading { get; private set; }
  394. /// <summary>
  395. /// Max Anisotropy. Values range from 0 - 16. Set to -1 to let the game decide.
  396. /// </summary>
  397. public ReactiveObject<float> MaxAnisotropy { get; private set; }
  398. /// <summary>
  399. /// Aspect Ratio applied to the renderer window.
  400. /// </summary>
  401. public ReactiveObject<AspectRatio> AspectRatio { get; private set; }
  402. /// <summary>
  403. /// Resolution Scale. An integer scale applied to applicable render targets. Values 1-4, or -1 to use a custom floating point scale instead.
  404. /// </summary>
  405. public ReactiveObject<int> ResScale { get; private set; }
  406. /// <summary>
  407. /// Custom Resolution Scale. A custom floating point scale applied to applicable render targets. Only active when Resolution Scale is -1.
  408. /// </summary>
  409. public ReactiveObject<float> ResScaleCustom { get; private set; }
  410. /// <summary>
  411. /// Dumps shaders in this local directory
  412. /// </summary>
  413. public ReactiveObject<string> ShadersDumpPath { get; private set; }
  414. /// <summary>
  415. /// Toggles the present interval mode. Options are Switch (60Hz), Unbounded (previously Vsync off), and Custom, if enabled.
  416. /// </summary>
  417. public ReactiveObject<VSyncMode> VSyncMode { get; private set; }
  418. /// <summary>
  419. /// Enables or disables the custom present interval mode.
  420. /// </summary>
  421. public ReactiveObject<bool> EnableCustomVSyncInterval { get; private set; }
  422. /// <summary>
  423. /// Changes the custom present interval.
  424. /// </summary>
  425. public ReactiveObject<int> CustomVSyncInterval { get; private set; }
  426. /// <summary>
  427. /// Enables or disables Shader cache
  428. /// </summary>
  429. public ReactiveObject<bool> EnableShaderCache { get; private set; }
  430. /// <summary>
  431. /// Enables or disables texture recompression
  432. /// </summary>
  433. public ReactiveObject<bool> EnableTextureRecompression { get; private set; }
  434. /// <summary>
  435. /// Enables or disables Macro high-level emulation
  436. /// </summary>
  437. public ReactiveObject<bool> EnableMacroHLE { get; private set; }
  438. /// <summary>
  439. /// Enables or disables color space passthrough, if available.
  440. /// </summary>
  441. public ReactiveObject<bool> EnableColorSpacePassthrough { get; private set; }
  442. /// <summary>
  443. /// Graphics backend
  444. /// </summary>
  445. public ReactiveObject<GraphicsBackend> GraphicsBackend { get; private set; }
  446. /// <summary>
  447. /// Applies anti-aliasing to the renderer.
  448. /// </summary>
  449. public ReactiveObject<AntiAliasing> AntiAliasing { get; private set; }
  450. /// <summary>
  451. /// Sets the framebuffer upscaling type.
  452. /// </summary>
  453. public ReactiveObject<ScalingFilter> ScalingFilter { get; private set; }
  454. /// <summary>
  455. /// Sets the framebuffer upscaling level.
  456. /// </summary>
  457. public ReactiveObject<int> ScalingFilterLevel { get; private set; }
  458. /// <summary>
  459. /// Preferred GPU
  460. /// </summary>
  461. public ReactiveObject<string> PreferredGpu { get; private set; }
  462. public GraphicsSection()
  463. {
  464. BackendThreading = new ReactiveObject<BackendThreading>();
  465. BackendThreading.LogChangesToValue(nameof(BackendThreading));
  466. ResScale = new ReactiveObject<int>();
  467. ResScale.LogChangesToValue(nameof(ResScale));
  468. ResScaleCustom = new ReactiveObject<float>();
  469. ResScaleCustom.LogChangesToValue(nameof(ResScaleCustom));
  470. MaxAnisotropy = new ReactiveObject<float>();
  471. MaxAnisotropy.LogChangesToValue(nameof(MaxAnisotropy));
  472. AspectRatio = new ReactiveObject<AspectRatio>();
  473. AspectRatio.LogChangesToValue(nameof(AspectRatio));
  474. ShadersDumpPath = new ReactiveObject<string>();
  475. VSyncMode = new ReactiveObject<VSyncMode>();
  476. VSyncMode.LogChangesToValue(nameof(VSyncMode));
  477. EnableCustomVSyncInterval = new ReactiveObject<bool>();
  478. EnableCustomVSyncInterval.LogChangesToValue(nameof(EnableCustomVSyncInterval));
  479. CustomVSyncInterval = new ReactiveObject<int>();
  480. CustomVSyncInterval.LogChangesToValue(nameof(CustomVSyncInterval));
  481. EnableShaderCache = new ReactiveObject<bool>();
  482. EnableShaderCache.LogChangesToValue(nameof(EnableShaderCache));
  483. EnableTextureRecompression = new ReactiveObject<bool>();
  484. EnableTextureRecompression.LogChangesToValue(nameof(EnableTextureRecompression));
  485. GraphicsBackend = new ReactiveObject<GraphicsBackend>();
  486. GraphicsBackend.LogChangesToValue(nameof(GraphicsBackend));
  487. PreferredGpu = new ReactiveObject<string>();
  488. PreferredGpu.LogChangesToValue(nameof(PreferredGpu));
  489. EnableMacroHLE = new ReactiveObject<bool>();
  490. EnableMacroHLE.LogChangesToValue(nameof(EnableMacroHLE));
  491. EnableColorSpacePassthrough = new ReactiveObject<bool>();
  492. EnableColorSpacePassthrough.LogChangesToValue(nameof(EnableColorSpacePassthrough));
  493. AntiAliasing = new ReactiveObject<AntiAliasing>();
  494. AntiAliasing.LogChangesToValue(nameof(AntiAliasing));
  495. ScalingFilter = new ReactiveObject<ScalingFilter>();
  496. ScalingFilter.LogChangesToValue(nameof(ScalingFilter));
  497. ScalingFilterLevel = new ReactiveObject<int>();
  498. ScalingFilterLevel.LogChangesToValue(nameof(ScalingFilterLevel));
  499. }
  500. }
  501. /// <summary>
  502. /// Multiplayer configuration section
  503. /// </summary>
  504. public class MultiplayerSection
  505. {
  506. /// <summary>
  507. /// GUID for the network interface used by LAN (or 0 for default)
  508. /// </summary>
  509. public ReactiveObject<string> LanInterfaceId { get; private set; }
  510. /// <summary>
  511. /// Multiplayer Mode
  512. /// </summary>
  513. public ReactiveObject<MultiplayerMode> Mode { get; private set; }
  514. /// <summary>
  515. /// Disable P2P
  516. /// </summary>
  517. public ReactiveObject<bool> DisableP2p { get; private set; }
  518. /// <summary>
  519. /// LDN PassPhrase
  520. /// </summary>
  521. public ReactiveObject<string> LdnPassphrase { get; private set; }
  522. /// <summary>
  523. /// LDN Server
  524. /// </summary>
  525. public ReactiveObject<string> LdnServer { get; private set; }
  526. public MultiplayerSection()
  527. {
  528. LanInterfaceId = new ReactiveObject<string>();
  529. Mode = new ReactiveObject<MultiplayerMode>();
  530. Mode.LogChangesToValue(nameof(MultiplayerMode));
  531. DisableP2p = new ReactiveObject<bool>();
  532. DisableP2p.LogChangesToValue(nameof(DisableP2p));
  533. LdnPassphrase = new ReactiveObject<string>();
  534. LdnPassphrase.LogChangesToValue(nameof(LdnPassphrase));
  535. LdnServer = new ReactiveObject<string>();
  536. LdnServer.LogChangesToValue(nameof(LdnServer));
  537. }
  538. }
  539. public class HacksSection
  540. {
  541. /// <summary>
  542. /// Show toggles for dirty hacks in the UI.
  543. /// </summary>
  544. public ReactiveObject<bool> ShowDirtyHacks { get; private set; }
  545. public ReactiveObject<bool> Xc2MenuSoftlockFix { get; private set; }
  546. public ReactiveObject<bool> EnableShaderTranslationDelay { get; private set; }
  547. public ReactiveObject<int> ShaderTranslationDelay { get; private set; }
  548. public HacksSection()
  549. {
  550. ShowDirtyHacks = new ReactiveObject<bool>();
  551. Xc2MenuSoftlockFix = new ReactiveObject<bool>();
  552. Xc2MenuSoftlockFix.Event += HackChanged;
  553. EnableShaderTranslationDelay = new ReactiveObject<bool>();
  554. EnableShaderTranslationDelay.Event += HackChanged;
  555. ShaderTranslationDelay = new ReactiveObject<int>();
  556. }
  557. private void HackChanged(object sender, ReactiveEventArgs<bool> rxe)
  558. {
  559. var newHacks = EnabledHacks.Select(x => x.Hack)
  560. .JoinToString(", ");
  561. if (newHacks != _lastHackCollection)
  562. {
  563. RyuLogger.Info?.Print(LogClass.Configuration,
  564. $"EnabledDirtyHacks set to: [{newHacks}]", "LogValueChange");
  565. _lastHackCollection = newHacks;
  566. }
  567. }
  568. private static string _lastHackCollection;
  569. public EnabledDirtyHack[] EnabledHacks
  570. {
  571. get
  572. {
  573. List<EnabledDirtyHack> enabledHacks = [];
  574. if (Xc2MenuSoftlockFix)
  575. Apply(DirtyHack.Xc2MenuSoftlockFix);
  576. if (EnableShaderTranslationDelay)
  577. Apply(DirtyHack.ShaderTranslationDelay, ShaderTranslationDelay);
  578. return enabledHacks.ToArray();
  579. void Apply(DirtyHack hack, int value = 0)
  580. {
  581. enabledHacks.Add(new EnabledDirtyHack(hack, value));
  582. }
  583. }
  584. }
  585. }
  586. /// <summary>
  587. /// The default configuration instance
  588. /// </summary>
  589. public static ConfigurationState Instance { get; private set; }
  590. /// <summary>
  591. /// The UI section
  592. /// </summary>
  593. public UISection UI { get; private set; }
  594. /// <summary>
  595. /// The Logger section
  596. /// </summary>
  597. public LoggerSection Logger { get; private set; }
  598. /// <summary>
  599. /// The System section
  600. /// </summary>
  601. public SystemSection System { get; private set; }
  602. /// <summary>
  603. /// The Graphics section
  604. /// </summary>
  605. public GraphicsSection Graphics { get; private set; }
  606. /// <summary>
  607. /// The Hid section
  608. /// </summary>
  609. public HidSection Hid { get; private set; }
  610. /// <summary>
  611. /// The Multiplayer section
  612. /// </summary>
  613. public MultiplayerSection Multiplayer { get; private set; }
  614. /// <summary>
  615. /// The Dirty Hacks section
  616. /// </summary>
  617. public HacksSection Hacks { get; private set; }
  618. /// <summary>
  619. /// Enables or disables Discord Rich Presence
  620. /// </summary>
  621. public ReactiveObject<bool> EnableDiscordIntegration { get; private set; }
  622. /// <summary>
  623. /// Checks for updates when Ryujinx starts when enabled
  624. /// </summary>
  625. public ReactiveObject<bool> CheckUpdatesOnStart { get; private set; }
  626. /// <summary>
  627. /// Show "Confirm Exit" Dialog
  628. /// </summary>
  629. public ReactiveObject<bool> ShowConfirmExit { get; private set; }
  630. /// <summary>
  631. /// Ignore Applet
  632. /// </summary>
  633. public ReactiveObject<bool> IgnoreApplet { get; private set; }
  634. /// <summary>
  635. /// Enables or disables save window size, position and state on close.
  636. /// </summary>
  637. public ReactiveObject<bool> RememberWindowState { get; private set; }
  638. /// <summary>
  639. /// Enables or disables the redesigned title bar
  640. /// </summary>
  641. public ReactiveObject<bool> ShowTitleBar { get; private set; }
  642. /// <summary>
  643. /// Enables hardware-accelerated rendering for Avalonia
  644. /// </summary>
  645. public ReactiveObject<bool> EnableHardwareAcceleration { get; private set; }
  646. /// <summary>
  647. /// Hide Cursor on Idle
  648. /// </summary>
  649. public ReactiveObject<HideCursorMode> HideCursor { get; private set; }
  650. private ConfigurationState()
  651. {
  652. UI = new UISection();
  653. Logger = new LoggerSection();
  654. System = new SystemSection();
  655. Graphics = new GraphicsSection();
  656. Hid = new HidSection();
  657. Multiplayer = new MultiplayerSection();
  658. Hacks = new HacksSection();
  659. EnableDiscordIntegration = new ReactiveObject<bool>();
  660. CheckUpdatesOnStart = new ReactiveObject<bool>();
  661. ShowConfirmExit = new ReactiveObject<bool>();
  662. IgnoreApplet = new ReactiveObject<bool>();
  663. IgnoreApplet.LogChangesToValue(nameof(IgnoreApplet));
  664. RememberWindowState = new ReactiveObject<bool>();
  665. ShowTitleBar = new ReactiveObject<bool>();
  666. EnableHardwareAcceleration = new ReactiveObject<bool>();
  667. HideCursor = new ReactiveObject<HideCursorMode>();
  668. }
  669. }
  670. }