/ src / Ryujinx.UI.Common / Configuration / ConfigurationFileFormat.cs
ConfigurationFileFormat.cs
  1  using Ryujinx.Common.Configuration;
  2  using Ryujinx.Common.Configuration.Hid;
  3  using Ryujinx.Common.Configuration.Multiplayer;
  4  using Ryujinx.Common.Logging;
  5  using Ryujinx.Common.Utilities;
  6  using Ryujinx.UI.Common.Configuration.System;
  7  using Ryujinx.UI.Common.Configuration.UI;
  8  using System.Collections.Generic;
  9  using System.Text.Json.Nodes;
 10  
 11  namespace Ryujinx.UI.Common.Configuration
 12  {
 13      public class ConfigurationFileFormat
 14      {
 15          /// <summary>
 16          /// The current version of the file format
 17          /// </summary>
 18          public const int CurrentVersion = 51;
 19  
 20          /// <summary>
 21          /// Version of the configuration file format
 22          /// </summary>
 23          public int Version { get; set; }
 24  
 25          /// <summary>
 26          /// Enables or disables logging to a file on disk
 27          /// </summary>
 28          public bool EnableFileLog { get; set; }
 29  
 30          /// <summary>
 31          /// Whether or not backend threading is enabled. The "Auto" setting will determine whether threading should be enabled at runtime.
 32          /// </summary>
 33          public BackendThreading BackendThreading { get; set; }
 34  
 35          /// <summary>
 36          /// Resolution Scale. An integer scale applied to applicable render targets. Values 1-4, or -1 to use a custom floating point scale instead.
 37          /// </summary>
 38          public int ResScale { get; set; }
 39  
 40          /// <summary>
 41          /// Custom Resolution Scale. A custom floating point scale applied to applicable render targets. Only active when Resolution Scale is -1.
 42          /// </summary>
 43          public float ResScaleCustom { get; set; }
 44  
 45          /// <summary>
 46          /// Max Anisotropy. Values range from 0 - 16. Set to -1 to let the game decide.
 47          /// </summary>
 48          public float MaxAnisotropy { get; set; }
 49  
 50          /// <summary>
 51          /// Aspect Ratio applied to the renderer window.
 52          /// </summary>
 53          public AspectRatio AspectRatio { get; set; }
 54  
 55          /// <summary>
 56          /// Applies anti-aliasing to the renderer.
 57          /// </summary>
 58          public AntiAliasing AntiAliasing { get; set; }
 59  
 60          /// <summary>
 61          /// Sets the framebuffer upscaling type.
 62          /// </summary>
 63          public ScalingFilter ScalingFilter { get; set; }
 64  
 65          /// <summary>
 66          /// Sets the framebuffer upscaling level.
 67          /// </summary>
 68          public int ScalingFilterLevel { get; set; }
 69  
 70          /// <summary>
 71          /// Dumps shaders in this local directory
 72          /// </summary>
 73          public string GraphicsShadersDumpPath { get; set; }
 74  
 75          /// <summary>
 76          /// Enables printing debug log messages
 77          /// </summary>
 78          public bool LoggingEnableDebug { get; set; }
 79  
 80          /// <summary>
 81          /// Enables printing stub log messages
 82          /// </summary>
 83          public bool LoggingEnableStub { get; set; }
 84  
 85          /// <summary>
 86          /// Enables printing info log messages
 87          /// </summary>
 88          public bool LoggingEnableInfo { get; set; }
 89  
 90          /// <summary>
 91          /// Enables printing warning log messages
 92          /// </summary>
 93          public bool LoggingEnableWarn { get; set; }
 94  
 95          /// <summary>
 96          /// Enables printing error log messages
 97          /// </summary>
 98          public bool LoggingEnableError { get; set; }
 99  
100          /// <summary>
101          /// Enables printing trace log messages
102          /// </summary>
103          public bool LoggingEnableTrace { get; set; }
104  
105          /// <summary>
106          /// Enables printing guest log messages
107          /// </summary>
108          public bool LoggingEnableGuest { get; set; }
109  
110          /// <summary>
111          /// Enables printing FS access log messages
112          /// </summary>
113          public bool LoggingEnableFsAccessLog { get; set; }
114  
115          /// <summary>
116          /// Controls which log messages are written to the log targets
117          /// </summary>
118          public LogClass[] LoggingFilteredClasses { get; set; }
119  
120          /// <summary>
121          /// Change Graphics API debug log level
122          /// </summary>
123          public GraphicsDebugLevel LoggingGraphicsDebugLevel { get; set; }
124  
125          /// <summary>
126          /// Change System Language
127          /// </summary>
128          public Language SystemLanguage { get; set; }
129  
130          /// <summary>
131          /// Change System Region
132          /// </summary>
133          public Region SystemRegion { get; set; }
134  
135          /// <summary>
136          /// Change System TimeZone
137          /// </summary>
138          public string SystemTimeZone { get; set; }
139  
140          /// <summary>
141          /// Change System Time Offset in seconds
142          /// </summary>
143          public long SystemTimeOffset { get; set; }
144  
145          /// <summary>
146          /// Enables or disables Docked Mode
147          /// </summary>
148          public bool DockedMode { get; set; }
149  
150          /// <summary>
151          /// Enables or disables Discord Rich Presence
152          /// </summary>
153          public bool EnableDiscordIntegration { get; set; }
154  
155          /// <summary>
156          /// Checks for updates when Ryujinx starts when enabled
157          /// </summary>
158          public bool CheckUpdatesOnStart { get; set; }
159  
160          /// <summary>
161          /// Show "Confirm Exit" Dialog
162          /// </summary>
163          public bool ShowConfirmExit { get; set; }
164  
165          /// <summary>
166          /// Enables or disables save window size, position and state on close.
167          /// </summary>
168          public bool RememberWindowState { get; set; }
169  
170          /// <summary>
171          /// Enables hardware-accelerated rendering for Avalonia
172          /// </summary>
173          public bool EnableHardwareAcceleration { get; set; }
174  
175          /// <summary>
176          /// Whether to hide cursor on idle, always or never
177          /// </summary>
178          public HideCursorMode HideCursor { get; set; }
179  
180          /// <summary>
181          /// Enables or disables Vertical Sync
182          /// </summary>
183          public bool EnableVsync { get; set; }
184  
185          /// <summary>
186          /// Enables or disables Shader cache
187          /// </summary>
188          public bool EnableShaderCache { get; set; }
189  
190          /// <summary>
191          /// Enables or disables texture recompression
192          /// </summary>
193          public bool EnableTextureRecompression { get; set; }
194  
195          /// <summary>
196          /// Enables or disables Macro high-level emulation
197          /// </summary>
198          public bool EnableMacroHLE { get; set; }
199  
200          /// <summary>
201          /// Enables or disables color space passthrough, if available.
202          /// </summary>
203          public bool EnableColorSpacePassthrough { get; set; }
204  
205          /// <summary>
206          /// Enables or disables profiled translation cache persistency
207          /// </summary>
208          public bool EnablePtc { get; set; }
209  
210          /// <summary>
211          /// Enables or disables guest Internet access
212          /// </summary>
213          public bool EnableInternetAccess { get; set; }
214  
215          /// <summary>
216          /// Enables integrity checks on Game content files
217          /// </summary>
218          public bool EnableFsIntegrityChecks { get; set; }
219  
220          /// <summary>
221          /// Enables FS access log output to the console. Possible modes are 0-3
222          /// </summary>
223          public int FsGlobalAccessLogMode { get; set; }
224  
225          /// <summary>
226          /// The selected audio backend
227          /// </summary>
228          public AudioBackend AudioBackend { get; set; }
229  
230          /// <summary>
231          /// The audio volume
232          /// </summary>
233          public float AudioVolume { get; set; }
234  
235          /// <summary>
236          /// The selected memory manager mode
237          /// </summary>
238          public MemoryManagerMode MemoryManagerMode { get; set; }
239  
240          /// <summary>
241          /// Expands the RAM amount on the emulated system from 4GiB to 8GiB
242          /// </summary>
243          public bool ExpandRam { get; set; }
244  
245          /// <summary>
246          /// Enable or disable ignoring missing services
247          /// </summary>
248          public bool IgnoreMissingServices { get; set; }
249  
250          /// <summary>
251          /// Used to toggle columns in the GUI
252          /// </summary>
253          public GuiColumns GuiColumns { get; set; }
254  
255          /// <summary>
256          /// Used to configure column sort settings in the GUI
257          /// </summary>
258          public ColumnSort ColumnSort { get; set; }
259  
260          /// <summary>
261          /// A list of directories containing games to be used to load games into the games list
262          /// </summary>
263          public List<string> GameDirs { get; set; }
264  
265          /// <summary>
266          /// A list of file types to be hidden in the games List
267          /// </summary>
268          public ShownFileTypes ShownFileTypes { get; set; }
269  
270          /// <summary>
271          /// Main window start-up position, size and state
272          /// </summary>
273          public WindowStartup WindowStartup { get; set; }
274  
275          /// <summary>
276          /// Language Code for the UI
277          /// </summary>
278          public string LanguageCode { get; set; }
279  
280          /// <summary>
281          /// Enable or disable custom themes in the GUI
282          /// </summary>
283          public bool EnableCustomTheme { get; set; }
284  
285          /// <summary>
286          /// Path to custom GUI theme
287          /// </summary>
288          public string CustomThemePath { get; set; }
289  
290          /// <summary>
291          /// Chooses the base style // Not Used
292          /// </summary>
293          public string BaseStyle { get; set; }
294  
295          /// <summary>
296          /// Chooses the view mode of the game list // Not Used
297          /// </summary>
298          public int GameListViewMode { get; set; }
299  
300          /// <summary>
301          /// Show application name in Grid Mode // Not Used
302          /// </summary>
303          public bool ShowNames { get; set; }
304  
305          /// <summary>
306          /// Sets App Icon Size // Not Used
307          /// </summary>
308          public int GridSize { get; set; }
309  
310          /// <summary>
311          /// Sorts Apps in the game list // Not Used
312          /// </summary>
313          public int ApplicationSort { get; set; }
314  
315          /// <summary>
316          /// Sets if Grid is ordered in Ascending Order // Not Used
317          /// </summary>
318          public bool IsAscendingOrder { get; set; }
319  
320          /// <summary>
321          /// Start games in fullscreen mode
322          /// </summary>
323          public bool StartFullscreen { get; set; }
324  
325          /// <summary>
326          /// Show console window
327          /// </summary>
328          public bool ShowConsole { get; set; }
329  
330          /// <summary>
331          /// Enable or disable keyboard support (Independent from controllers binding)
332          /// </summary>
333          public bool EnableKeyboard { get; set; }
334  
335          /// <summary>
336          /// Enable or disable mouse support (Independent from controllers binding)
337          /// </summary>
338          public bool EnableMouse { get; set; }
339  
340          /// <summary>
341          /// Hotkey Keyboard Bindings
342          /// </summary>
343          public KeyboardHotkeys Hotkeys { get; set; }
344  
345          /// <summary>
346          /// Legacy keyboard control bindings
347          /// </summary>
348          /// <remarks>Kept for file format compatibility (to avoid possible failure when parsing configuration on old versions)</remarks>
349          /// TODO: Remove this when those older versions aren't in use anymore.
350          public List<JsonObject> KeyboardConfig { get; set; }
351  
352          /// <summary>
353          /// Legacy controller control bindings
354          /// </summary>
355          /// <remarks>Kept for file format compatibility (to avoid possible failure when parsing configuration on old versions)</remarks>
356          /// TODO: Remove this when those older versions aren't in use anymore.
357          public List<JsonObject> ControllerConfig { get; set; }
358  
359          /// <summary>
360          /// Input configurations
361          /// </summary>
362          public List<InputConfig> InputConfig { get; set; }
363  
364          /// <summary>
365          /// Graphics backend
366          /// </summary>
367          public GraphicsBackend GraphicsBackend { get; set; }
368  
369          /// <summary>
370          /// Preferred GPU
371          /// </summary>
372          public string PreferredGpu { get; set; }
373  
374          /// <summary>
375          /// Multiplayer Mode
376          /// </summary>
377          public MultiplayerMode MultiplayerMode { get; set; }
378  
379          /// <summary>
380          /// GUID for the network interface used by LAN (or 0 for default)
381          /// </summary>
382          public string MultiplayerLanInterfaceId { get; set; }
383  
384          /// <summary>
385          /// Uses Hypervisor over JIT if available
386          /// </summary>
387          public bool UseHypervisor { get; set; }
388  
389          /// <summary>
390          /// Loads a configuration file from disk
391          /// </summary>
392          /// <param name="path">The path to the JSON configuration file</param>
393          /// <param name="configurationFileFormat">Parsed configuration file</param>
394          public static bool TryLoad(string path, out ConfigurationFileFormat configurationFileFormat)
395          {
396              try
397              {
398                  configurationFileFormat = JsonHelper.DeserializeFromFile(path, ConfigurationFileFormatSettings.SerializerContext.ConfigurationFileFormat);
399  
400                  return configurationFileFormat.Version != 0;
401              }
402              catch
403              {
404                  configurationFileFormat = null;
405  
406                  return false;
407              }
408          }
409  
410          /// <summary>
411          /// Save a configuration file to disk
412          /// </summary>
413          /// <param name="path">The path to the JSON configuration file</param>
414          public void SaveConfig(string path)
415          {
416              JsonHelper.SerializeToFile(path, this, ConfigurationFileFormatSettings.SerializerContext.ConfigurationFileFormat);
417          }
418      }
419  }