2020-12-01 17:02:27 -05:00
using Ryujinx.Common ;
2020-08-02 10:41:24 -04:00
using Ryujinx.Common.Configuration ;
2019-12-21 14:52:31 -05:00
using Ryujinx.Common.Configuration.Hid ;
using Ryujinx.Common.Logging ;
using Ryujinx.Configuration.Hid ;
using Ryujinx.Configuration.System ;
using Ryujinx.Configuration.Ui ;
using System ;
using System.Collections.Generic ;
namespace Ryujinx.Configuration
{
public class ConfigurationState
{
/// <summary>
/// UI configuration section
/// </summary>
public class UiSection
{
public class Columns
{
public ReactiveObject < bool > FavColumn { get ; private set ; }
public ReactiveObject < bool > IconColumn { get ; private set ; }
public ReactiveObject < bool > AppColumn { get ; private set ; }
public ReactiveObject < bool > DevColumn { get ; private set ; }
public ReactiveObject < bool > VersionColumn { get ; private set ; }
public ReactiveObject < bool > TimePlayedColumn { get ; private set ; }
2020-12-09 17:20:05 -05:00
public ReactiveObject < bool > LastPlayedColumn { get ; private set ; }
2019-12-21 14:52:31 -05:00
public ReactiveObject < bool > FileExtColumn { get ; private set ; }
public ReactiveObject < bool > FileSizeColumn { get ; private set ; }
public ReactiveObject < bool > PathColumn { get ; private set ; }
public Columns ( )
{
FavColumn = new ReactiveObject < bool > ( ) ;
IconColumn = new ReactiveObject < bool > ( ) ;
AppColumn = new ReactiveObject < bool > ( ) ;
DevColumn = new ReactiveObject < bool > ( ) ;
VersionColumn = new ReactiveObject < bool > ( ) ;
TimePlayedColumn = new ReactiveObject < bool > ( ) ;
LastPlayedColumn = new ReactiveObject < bool > ( ) ;
FileExtColumn = new ReactiveObject < bool > ( ) ;
FileSizeColumn = new ReactiveObject < bool > ( ) ;
PathColumn = new ReactiveObject < bool > ( ) ;
}
}
2020-06-26 06:30:16 -04:00
public class ColumnSortSettings
{
public ReactiveObject < int > SortColumnId { get ; private set ; }
public ReactiveObject < bool > SortAscending { get ; private set ; }
public ColumnSortSettings ( )
{
SortColumnId = new ReactiveObject < int > ( ) ;
SortAscending = new ReactiveObject < bool > ( ) ;
}
}
2019-12-21 14:52:31 -05:00
/// <summary>
/// Used to toggle columns in the GUI
/// </summary>
public Columns GuiColumns { get ; private set ; }
2020-06-26 06:30:16 -04:00
/// <summary>
/// Used to configure column sort settings in the GUI
/// </summary>
public ColumnSortSettings ColumnSort { get ; private set ; }
2019-12-21 14:52:31 -05:00
/// <summary>
/// A list of directories containing games to be used to load games into the games list
/// </summary>
public ReactiveObject < List < string > > GameDirs { get ; private set ; }
/// <summary>
/// Enable or disable custom themes in the GUI
/// </summary>
public ReactiveObject < bool > EnableCustomTheme { get ; private set ; }
/// <summary>
/// Path to custom GUI theme
/// </summary>
public ReactiveObject < string > CustomThemePath { get ; private set ; }
2020-12-01 17:02:27 -05:00
/// <summary>
/// Start games in fullscreen mode
/// </summary>
public ReactiveObject < bool > StartFullscreen { get ; private set ; }
2019-12-21 14:52:31 -05:00
public UiSection ( )
{
GuiColumns = new Columns ( ) ;
2020-06-26 06:30:16 -04:00
ColumnSort = new ColumnSortSettings ( ) ;
2019-12-21 14:52:31 -05:00
GameDirs = new ReactiveObject < List < string > > ( ) ;
EnableCustomTheme = new ReactiveObject < bool > ( ) ;
CustomThemePath = new ReactiveObject < string > ( ) ;
2020-12-01 17:02:27 -05:00
StartFullscreen = new ReactiveObject < bool > ( ) ;
2019-12-21 14:52:31 -05:00
}
}
/// <summary>
/// Logger configuration section
/// </summary>
public class LoggerSection
{
/// <summary>
/// Enables printing debug log messages
/// </summary>
public ReactiveObject < bool > EnableDebug { get ; private set ; }
/// <summary>
/// Enables printing stub log messages
/// </summary>
public ReactiveObject < bool > EnableStub { get ; private set ; }
/// <summary>
/// Enables printing info log messages
/// </summary>
public ReactiveObject < bool > EnableInfo { get ; private set ; }
/// <summary>
/// Enables printing warning log messages
/// </summary>
public ReactiveObject < bool > EnableWarn { get ; private set ; }
/// <summary>
/// Enables printing error log messages
/// </summary>
public ReactiveObject < bool > EnableError { get ; private set ; }
/// <summary>
/// Enables printing guest log messages
/// </summary>
public ReactiveObject < bool > EnableGuest { get ; private set ; }
/// <summary>
/// Enables printing FS access log messages
/// </summary>
public ReactiveObject < bool > EnableFsAccessLog { get ; private set ; }
/// <summary>
/// Controls which log messages are written to the log targets
/// </summary>
public ReactiveObject < LogClass [ ] > FilteredClasses { get ; private set ; }
/// <summary>
/// Enables or disables logging to a file on disk
/// </summary>
public ReactiveObject < bool > EnableFileLog { get ; private set ; }
2020-08-02 10:41:24 -04:00
/// <summary>
/// Controls which OpenGL log messages are recorded in the log
/// </summary>
public ReactiveObject < GraphicsDebugLevel > GraphicsDebugLevel { get ; private set ; }
2019-12-21 14:52:31 -05:00
public LoggerSection ( )
{
2021-04-13 15:58:47 -04:00
EnableDebug = new ReactiveObject < bool > ( ) ;
EnableStub = new ReactiveObject < bool > ( ) ;
EnableInfo = new ReactiveObject < bool > ( ) ;
EnableWarn = new ReactiveObject < bool > ( ) ;
EnableError = new ReactiveObject < bool > ( ) ;
EnableGuest = new ReactiveObject < bool > ( ) ;
EnableFsAccessLog = new ReactiveObject < bool > ( ) ;
FilteredClasses = new ReactiveObject < LogClass [ ] > ( ) ;
EnableFileLog = new ReactiveObject < bool > ( ) ;
EnableFileLog . Event + = static ( sender , e ) = > LogValueChange ( sender , e , nameof ( EnableFileLog ) ) ;
GraphicsDebugLevel = new ReactiveObject < GraphicsDebugLevel > ( ) ;
2019-12-21 14:52:31 -05:00
}
}
/// <summary>
/// System configuration section
/// </summary>
public class SystemSection
{
/// <summary>
/// Change System Language
/// </summary>
public ReactiveObject < Language > Language { get ; private set ; }
2020-03-19 18:37:55 -04:00
/// <summary>
/// Change System Region
/// </summary>
public ReactiveObject < Region > Region { get ; private set ; }
2020-03-25 18:23:21 -04:00
/// <summary>
/// Change System TimeZone
/// </summary>
public ReactiveObject < string > TimeZone { get ; private set ; }
2020-04-16 19:18:54 -04:00
/// <summary>
2020-05-02 22:00:53 -04:00
/// System Time Offset in Seconds
2020-04-16 19:18:54 -04:00
/// </summary>
public ReactiveObject < long > SystemTimeOffset { get ; private set ; }
2019-12-21 14:52:31 -05:00
/// <summary>
/// Enables or disables Docked Mode
/// </summary>
public ReactiveObject < bool > EnableDockedMode { get ; private set ; }
2020-06-16 14:28:02 -04:00
/// <summary>
/// Enables or disables profiled translation cache persistency
/// </summary>
public ReactiveObject < bool > EnablePtc { get ; private set ; }
2019-12-21 14:52:31 -05:00
/// <summary>
/// Enables integrity checks on Game content files
/// </summary>
public ReactiveObject < bool > EnableFsIntegrityChecks { get ; private set ; }
/// <summary>
/// Enables FS access log output to the console. Possible modes are 0-3
/// </summary>
public ReactiveObject < int > FsGlobalAccessLogMode { get ; private set ; }
2020-07-03 19:16:49 -04:00
/// <summary>
/// The selected audio backend
/// </summary>
public ReactiveObject < AudioBackend > AudioBackend { get ; private set ; }
2021-04-04 08:06:59 -04:00
/// <summary>
/// Defines the amount of RAM available on the emulated system, and how it is distributed
/// </summary>
public ReactiveObject < bool > ExpandRam { get ; private set ; }
2019-12-21 14:52:31 -05:00
/// <summary>
/// Enable or disable ignoring missing services
/// </summary>
public ReactiveObject < bool > IgnoreMissingServices { get ; private set ; }
public SystemSection ( )
{
2021-04-13 15:58:47 -04:00
Language = new ReactiveObject < Language > ( ) ;
Region = new ReactiveObject < Region > ( ) ;
TimeZone = new ReactiveObject < string > ( ) ;
SystemTimeOffset = new ReactiveObject < long > ( ) ;
EnableDockedMode = new ReactiveObject < bool > ( ) ;
EnableDockedMode . Event + = static ( sender , e ) = > LogValueChange ( sender , e , nameof ( EnableDockedMode ) ) ;
EnablePtc = new ReactiveObject < bool > ( ) ;
EnablePtc . Event + = static ( sender , e ) = > LogValueChange ( sender , e , nameof ( EnablePtc ) ) ;
EnableFsIntegrityChecks = new ReactiveObject < bool > ( ) ;
EnableFsIntegrityChecks . Event + = static ( sender , e ) = > LogValueChange ( sender , e , nameof ( EnableFsIntegrityChecks ) ) ;
FsGlobalAccessLogMode = new ReactiveObject < int > ( ) ;
FsGlobalAccessLogMode . Event + = static ( sender , e ) = > LogValueChange ( sender , e , nameof ( FsGlobalAccessLogMode ) ) ;
AudioBackend = new ReactiveObject < AudioBackend > ( ) ;
AudioBackend . Event + = static ( sender , e ) = > LogValueChange ( sender , e , nameof ( AudioBackend ) ) ;
ExpandRam = new ReactiveObject < bool > ( ) ;
ExpandRam . Event + = static ( sender , e ) = > LogValueChange ( sender , e , nameof ( ExpandRam ) ) ;
IgnoreMissingServices = new ReactiveObject < bool > ( ) ;
IgnoreMissingServices . Event + = static ( sender , e ) = > LogValueChange ( sender , e , nameof ( IgnoreMissingServices ) ) ;
2019-12-21 14:52:31 -05:00
}
}
/// <summary>
/// Hid configuration section
/// </summary>
public class HidSection
{
/// <summary>
/// Enable or disable keyboard support (Independent from controllers binding)
/// </summary>
public ReactiveObject < bool > EnableKeyboard { get ; private set ; }
2020-06-26 06:30:16 -04:00
/// <summary>
/// Hotkey Keyboard Bindings
/// </summary>
public ReactiveObject < KeyboardHotkeys > Hotkeys { get ; private set ; }
2019-12-21 14:52:31 -05:00
/// <summary>
2020-05-02 22:00:53 -04:00
/// Input device configuration.
/// NOTE: This ReactiveObject won't issue an event when the List has elements added or removed.
/// TODO: Implement a ReactiveList class.
2019-12-21 14:52:31 -05:00
/// </summary>
2020-05-02 22:00:53 -04:00
public ReactiveObject < List < InputConfig > > InputConfig { get ; private set ; }
2019-12-21 14:52:31 -05:00
public HidSection ( )
{
2020-05-02 22:00:53 -04:00
EnableKeyboard = new ReactiveObject < bool > ( ) ;
2020-06-26 06:30:16 -04:00
Hotkeys = new ReactiveObject < KeyboardHotkeys > ( ) ;
2020-05-02 22:00:53 -04:00
InputConfig = new ReactiveObject < List < InputConfig > > ( ) ;
2019-12-21 14:52:31 -05:00
}
}
/// <summary>
/// Graphics configuration section
/// </summary>
public class GraphicsSection
{
2020-03-30 17:38:52 -04:00
/// <summary>
/// Max Anisotropy. Values range from 0 - 16. Set to -1 to let the game decide.
/// </summary>
public ReactiveObject < float > MaxAnisotropy { get ; private set ; }
2020-12-15 21:19:07 -05:00
/// <summary>
/// Aspect Ratio applied to the renderer window.
/// </summary>
public ReactiveObject < AspectRatio > AspectRatio { get ; private set ; }
2020-07-06 22:41:07 -04:00
/// <summary>
/// Resolution Scale. An integer scale applied to applicable render targets. Values 1-4, or -1 to use a custom floating point scale instead.
/// </summary>
public ReactiveObject < int > ResScale { get ; private set ; }
/// <summary>
/// Custom Resolution Scale. A custom floating point scale applied to applicable render targets. Only active when Resolution Scale is -1.
/// </summary>
public ReactiveObject < float > ResScaleCustom { get ; private set ; }
2019-12-21 14:52:31 -05:00
/// <summary>
/// Dumps shaders in this local directory
/// </summary>
public ReactiveObject < string > ShadersDumpPath { get ; private set ; }
/// <summary>
/// Enables or disables Vertical Sync
/// </summary>
public ReactiveObject < bool > EnableVsync { get ; private set ; }
2020-11-12 18:15:34 -05:00
/// <summary>
/// Enables or disables Shader cache
/// </summary>
public ReactiveObject < bool > EnableShaderCache { get ; private set ; }
2019-12-21 14:52:31 -05:00
public GraphicsSection ( )
{
2021-04-13 15:58:47 -04:00
ResScale = new ReactiveObject < int > ( ) ;
ResScale . Event + = static ( sender , e ) = > LogValueChange ( sender , e , nameof ( ResScale ) ) ;
ResScaleCustom = new ReactiveObject < float > ( ) ;
ResScaleCustom . Event + = static ( sender , e ) = > LogValueChange ( sender , e , nameof ( ResScaleCustom ) ) ;
MaxAnisotropy = new ReactiveObject < float > ( ) ;
MaxAnisotropy . Event + = static ( sender , e ) = > LogValueChange ( sender , e , nameof ( MaxAnisotropy ) ) ;
AspectRatio = new ReactiveObject < AspectRatio > ( ) ;
AspectRatio . Event + = static ( sender , e ) = > LogValueChange ( sender , e , nameof ( AspectRatio ) ) ;
ShadersDumpPath = new ReactiveObject < string > ( ) ;
EnableVsync = new ReactiveObject < bool > ( ) ;
EnableVsync . Event + = static ( sender , e ) = > LogValueChange ( sender , e , nameof ( EnableVsync ) ) ;
EnableShaderCache = new ReactiveObject < bool > ( ) ;
EnableShaderCache . Event + = static ( sender , e ) = > LogValueChange ( sender , e , nameof ( EnableShaderCache ) ) ;
2019-12-21 14:52:31 -05:00
}
}
/// <summary>
/// The default configuration instance
/// </summary>
public static ConfigurationState Instance { get ; private set ; }
/// <summary>
/// The Ui section
/// </summary>
public UiSection Ui { get ; private set ; }
/// <summary>
/// The Logger section
/// </summary>
public LoggerSection Logger { get ; private set ; }
/// <summary>
/// The System section
/// </summary>
public SystemSection System { get ; private set ; }
/// <summary>
/// The Graphics section
/// </summary>
public GraphicsSection Graphics { get ; private set ; }
/// <summary>
/// The Hid section
/// </summary>
public HidSection Hid { get ; private set ; }
/// <summary>
/// Enables or disables Discord Rich Presence
/// </summary>
public ReactiveObject < bool > EnableDiscordIntegration { get ; private set ; }
2020-09-29 16:05:25 -04:00
/// <summary>
/// Checks for updates when Ryujinx starts when enabled
/// </summary>
public ReactiveObject < bool > CheckUpdatesOnStart { get ; private set ; }
2021-01-14 17:30:52 -05:00
/// <summary>
/// Show "Confirm Exit" Dialog
/// </summary>
public ReactiveObject < bool > ShowConfirmExit { get ; private set ; }
2021-02-15 16:48:21 -05:00
/// <summary>
/// Hide Cursor on Idle
/// </summary>
public ReactiveObject < bool > HideCursorOnIdle { get ; private set ; }
2019-12-21 14:52:31 -05:00
private ConfigurationState ( )
{
Ui = new UiSection ( ) ;
Logger = new LoggerSection ( ) ;
System = new SystemSection ( ) ;
Graphics = new GraphicsSection ( ) ;
Hid = new HidSection ( ) ;
EnableDiscordIntegration = new ReactiveObject < bool > ( ) ;
2020-09-29 16:05:25 -04:00
CheckUpdatesOnStart = new ReactiveObject < bool > ( ) ;
2021-01-14 17:30:52 -05:00
ShowConfirmExit = new ReactiveObject < bool > ( ) ;
2021-02-15 16:48:21 -05:00
HideCursorOnIdle = new ReactiveObject < bool > ( ) ;
2019-12-21 14:52:31 -05:00
}
public ConfigurationFileFormat ToFileFormat ( )
{
2020-05-02 22:00:53 -04:00
List < ControllerConfig > controllerConfigList = new List < ControllerConfig > ( ) ;
List < KeyboardConfig > keyboardConfigList = new List < KeyboardConfig > ( ) ;
foreach ( InputConfig inputConfig in Hid . InputConfig . Value )
{
if ( inputConfig is ControllerConfig controllerConfig )
{
controllerConfigList . Add ( controllerConfig ) ;
}
else if ( inputConfig is KeyboardConfig keyboardConfig )
{
keyboardConfigList . Add ( keyboardConfig ) ;
}
}
2019-12-21 14:52:31 -05:00
ConfigurationFileFormat configurationFile = new ConfigurationFileFormat
{
2020-03-25 18:23:21 -04:00
Version = ConfigurationFileFormat . CurrentVersion ,
2020-07-06 22:41:07 -04:00
ResScale = Graphics . ResScale ,
ResScaleCustom = Graphics . ResScaleCustom ,
2020-03-30 17:38:52 -04:00
MaxAnisotropy = Graphics . MaxAnisotropy ,
2020-12-15 21:19:07 -05:00
AspectRatio = Graphics . AspectRatio ,
2019-12-21 14:52:31 -05:00
GraphicsShadersDumpPath = Graphics . ShadersDumpPath ,
LoggingEnableDebug = Logger . EnableDebug ,
LoggingEnableStub = Logger . EnableStub ,
LoggingEnableInfo = Logger . EnableInfo ,
LoggingEnableWarn = Logger . EnableWarn ,
LoggingEnableError = Logger . EnableError ,
LoggingEnableGuest = Logger . EnableGuest ,
LoggingEnableFsAccessLog = Logger . EnableFsAccessLog ,
LoggingFilteredClasses = Logger . FilteredClasses ,
2020-08-02 10:41:24 -04:00
LoggingGraphicsDebugLevel = Logger . GraphicsDebugLevel ,
2019-12-21 14:52:31 -05:00
EnableFileLog = Logger . EnableFileLog ,
SystemLanguage = System . Language ,
2020-03-19 18:37:55 -04:00
SystemRegion = System . Region ,
2020-03-25 18:23:21 -04:00
SystemTimeZone = System . TimeZone ,
2020-04-16 19:18:54 -04:00
SystemTimeOffset = System . SystemTimeOffset ,
2019-12-21 14:52:31 -05:00
DockedMode = System . EnableDockedMode ,
EnableDiscordIntegration = EnableDiscordIntegration ,
2020-09-29 16:05:25 -04:00
CheckUpdatesOnStart = CheckUpdatesOnStart ,
2021-01-14 17:30:52 -05:00
ShowConfirmExit = ShowConfirmExit ,
2021-02-15 16:48:21 -05:00
HideCursorOnIdle = HideCursorOnIdle ,
2019-12-21 14:52:31 -05:00
EnableVsync = Graphics . EnableVsync ,
2020-11-12 18:15:34 -05:00
EnableShaderCache = Graphics . EnableShaderCache ,
2020-06-16 14:28:02 -04:00
EnablePtc = System . EnablePtc ,
2019-12-21 14:52:31 -05:00
EnableFsIntegrityChecks = System . EnableFsIntegrityChecks ,
FsGlobalAccessLogMode = System . FsGlobalAccessLogMode ,
2020-07-03 19:16:49 -04:00
AudioBackend = System . AudioBackend ,
2021-04-04 08:06:59 -04:00
ExpandRam = System . ExpandRam ,
2019-12-21 14:52:31 -05:00
IgnoreMissingServices = System . IgnoreMissingServices ,
2020-06-26 06:30:16 -04:00
GuiColumns = new GuiColumns
2019-12-21 14:52:31 -05:00
{
FavColumn = Ui . GuiColumns . FavColumn ,
IconColumn = Ui . GuiColumns . IconColumn ,
AppColumn = Ui . GuiColumns . AppColumn ,
DevColumn = Ui . GuiColumns . DevColumn ,
VersionColumn = Ui . GuiColumns . VersionColumn ,
TimePlayedColumn = Ui . GuiColumns . TimePlayedColumn ,
LastPlayedColumn = Ui . GuiColumns . LastPlayedColumn ,
FileExtColumn = Ui . GuiColumns . FileExtColumn ,
FileSizeColumn = Ui . GuiColumns . FileSizeColumn ,
PathColumn = Ui . GuiColumns . PathColumn ,
} ,
2020-06-26 06:30:16 -04:00
ColumnSort = new ColumnSort
{
SortColumnId = Ui . ColumnSort . SortColumnId ,
SortAscending = Ui . ColumnSort . SortAscending
} ,
2019-12-21 14:52:31 -05:00
GameDirs = Ui . GameDirs ,
EnableCustomTheme = Ui . EnableCustomTheme ,
CustomThemePath = Ui . CustomThemePath ,
2020-12-01 17:02:27 -05:00
StartFullscreen = Ui . StartFullscreen ,
2019-12-21 14:52:31 -05:00
EnableKeyboard = Hid . EnableKeyboard ,
2020-06-26 06:30:16 -04:00
Hotkeys = Hid . Hotkeys ,
2020-05-02 22:00:53 -04:00
KeyboardConfig = keyboardConfigList ,
ControllerConfig = controllerConfigList
2019-12-21 14:52:31 -05:00
} ;
return configurationFile ;
}
public void LoadDefault ( )
{
2020-07-06 22:41:07 -04:00
Graphics . ResScale . Value = 1 ;
Graphics . ResScaleCustom . Value = 1.0f ;
2020-12-01 15:44:04 -05:00
Graphics . MaxAnisotropy . Value = - 1.0f ;
2020-12-15 21:19:07 -05:00
Graphics . AspectRatio . Value = AspectRatio . Fixed16x9 ;
2019-12-21 14:52:31 -05:00
Graphics . ShadersDumpPath . Value = "" ;
Logger . EnableDebug . Value = false ;
Logger . EnableStub . Value = true ;
Logger . EnableInfo . Value = true ;
Logger . EnableWarn . Value = true ;
Logger . EnableError . Value = true ;
Logger . EnableGuest . Value = true ;
Logger . EnableFsAccessLog . Value = false ;
2020-12-15 21:19:07 -05:00
Logger . FilteredClasses . Value = Array . Empty < LogClass > ( ) ;
2020-08-02 10:41:24 -04:00
Logger . GraphicsDebugLevel . Value = GraphicsDebugLevel . None ;
2019-12-21 14:52:31 -05:00
Logger . EnableFileLog . Value = true ;
System . Language . Value = Language . AmericanEnglish ;
2020-03-19 18:37:55 -04:00
System . Region . Value = Region . USA ;
2020-03-25 18:23:21 -04:00
System . TimeZone . Value = "UTC" ;
2020-04-16 19:18:54 -04:00
System . SystemTimeOffset . Value = 0 ;
2021-01-27 21:55:01 -05:00
System . EnableDockedMode . Value = true ;
2019-12-21 14:52:31 -05:00
EnableDiscordIntegration . Value = true ;
2020-09-29 16:05:25 -04:00
CheckUpdatesOnStart . Value = true ;
2021-01-14 17:30:52 -05:00
ShowConfirmExit . Value = true ;
2021-02-15 16:48:21 -05:00
HideCursorOnIdle . Value = false ;
2019-12-21 14:52:31 -05:00
Graphics . EnableVsync . Value = true ;
2020-11-12 18:15:34 -05:00
Graphics . EnableShaderCache . Value = true ;
2021-01-01 09:36:47 -05:00
System . EnablePtc . Value = true ;
2019-12-21 14:52:31 -05:00
System . EnableFsIntegrityChecks . Value = true ;
System . FsGlobalAccessLogMode . Value = 0 ;
2020-07-03 19:16:49 -04:00
System . AudioBackend . Value = AudioBackend . OpenAl ;
2021-04-04 08:06:59 -04:00
System . ExpandRam . Value = false ;
2019-12-21 14:52:31 -05:00
System . IgnoreMissingServices . Value = false ;
Ui . GuiColumns . FavColumn . Value = true ;
Ui . GuiColumns . IconColumn . Value = true ;
Ui . GuiColumns . AppColumn . Value = true ;
Ui . GuiColumns . DevColumn . Value = true ;
Ui . GuiColumns . VersionColumn . Value = true ;
Ui . GuiColumns . TimePlayedColumn . Value = true ;
Ui . GuiColumns . LastPlayedColumn . Value = true ;
Ui . GuiColumns . FileExtColumn . Value = true ;
Ui . GuiColumns . FileSizeColumn . Value = true ;
Ui . GuiColumns . PathColumn . Value = true ;
2020-06-26 06:30:16 -04:00
Ui . ColumnSort . SortColumnId . Value = 0 ;
Ui . ColumnSort . SortAscending . Value = false ;
2019-12-21 14:52:31 -05:00
Ui . GameDirs . Value = new List < string > ( ) ;
Ui . EnableCustomTheme . Value = false ;
Ui . CustomThemePath . Value = "" ;
2020-12-01 17:02:27 -05:00
Ui . StartFullscreen . Value = false ;
2019-12-21 14:52:31 -05:00
Hid . EnableKeyboard . Value = false ;
2020-06-26 06:30:16 -04:00
Hid . Hotkeys . Value = new KeyboardHotkeys
{
ToggleVsync = Key . Tab
} ;
2020-05-02 22:00:53 -04:00
Hid . InputConfig . Value = new List < InputConfig >
2019-12-21 14:52:31 -05:00
{
2020-05-02 22:00:53 -04:00
new KeyboardConfig
2019-12-21 14:52:31 -05:00
{
2020-05-02 22:00:53 -04:00
Index = 0 ,
ControllerType = ControllerType . JoyconPair ,
PlayerIndex = PlayerIndex . Player1 ,
LeftJoycon = new NpadKeyboardLeft
{
StickUp = Key . W ,
StickDown = Key . S ,
StickLeft = Key . A ,
StickRight = Key . D ,
StickButton = Key . F ,
DPadUp = Key . Up ,
DPadDown = Key . Down ,
DPadLeft = Key . Left ,
DPadRight = Key . Right ,
ButtonMinus = Key . Minus ,
ButtonL = Key . E ,
ButtonZl = Key . Q ,
ButtonSl = Key . Home ,
ButtonSr = Key . End
} ,
RightJoycon = new NpadKeyboardRight
{
StickUp = Key . I ,
StickDown = Key . K ,
StickLeft = Key . J ,
StickRight = Key . L ,
StickButton = Key . H ,
ButtonA = Key . Z ,
ButtonB = Key . X ,
ButtonX = Key . C ,
ButtonY = Key . V ,
ButtonPlus = Key . Plus ,
ButtonR = Key . U ,
ButtonZr = Key . O ,
ButtonSl = Key . PageUp ,
ButtonSr = Key . PageDown
2020-09-29 17:32:42 -04:00
} ,
EnableMotion = false ,
MirrorInput = false ,
Slot = 0 ,
AltSlot = 0 ,
Sensitivity = 100 ,
GyroDeadzone = 1 ,
DsuServerHost = "127.0.0.1" ,
DsuServerPort = 26760
2019-12-21 14:52:31 -05:00
}
} ;
}
2020-03-19 18:37:55 -04:00
public void Load ( ConfigurationFileFormat configurationFileFormat , string configurationFilePath )
2019-12-21 14:52:31 -05:00
{
2020-03-19 18:37:55 -04:00
bool configurationFileUpdated = false ;
2020-03-25 18:23:21 -04:00
if ( configurationFileFormat . Version < 0 | | configurationFileFormat . Version > ConfigurationFileFormat . CurrentVersion )
2019-12-21 14:52:31 -05:00
{
2020-08-03 19:32:53 -04:00
Common . Logging . Logger . Warning ? . Print ( LogClass . Application , $"Unsupported configuration version {configurationFileFormat.Version}, loading default." ) ;
2019-12-21 14:52:31 -05:00
LoadDefault ( ) ;
return ;
}
2020-03-19 18:37:55 -04:00
if ( configurationFileFormat . Version < 2 )
{
2020-08-03 19:32:53 -04:00
Common . Logging . Logger . Warning ? . Print ( LogClass . Application , $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 2." ) ;
2020-03-19 18:37:55 -04:00
configurationFileFormat . SystemRegion = Region . USA ;
configurationFileUpdated = true ;
}
2020-03-25 18:23:21 -04:00
if ( configurationFileFormat . Version < 3 )
{
2020-08-03 19:32:53 -04:00
Common . Logging . Logger . Warning ? . Print ( LogClass . Application , $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 3." ) ;
2020-03-25 18:23:21 -04:00
configurationFileFormat . SystemTimeZone = "UTC" ;
configurationFileUpdated = true ;
}
2020-03-30 17:38:52 -04:00
if ( configurationFileFormat . Version < 4 )
{
2020-08-03 19:32:53 -04:00
Common . Logging . Logger . Warning ? . Print ( LogClass . Application , $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 4." ) ;
2020-03-30 17:38:52 -04:00
configurationFileFormat . MaxAnisotropy = - 1 ;
configurationFileUpdated = true ;
}
2020-04-16 19:18:54 -04:00
if ( configurationFileFormat . Version < 5 )
{
2020-08-03 19:32:53 -04:00
Common . Logging . Logger . Warning ? . Print ( LogClass . Application , $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 5." ) ;
2020-04-16 19:18:54 -04:00
configurationFileFormat . SystemTimeOffset = 0 ;
configurationFileUpdated = true ;
}
2020-05-02 22:00:53 -04:00
if ( configurationFileFormat . Version < 6 )
{
2020-08-03 19:32:53 -04:00
Common . Logging . Logger . Warning ? . Print ( LogClass . Application , $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 6." ) ;
2020-05-02 22:00:53 -04:00
configurationFileFormat . ControllerConfig = new List < ControllerConfig > ( ) ;
2020-07-03 19:16:49 -04:00
configurationFileFormat . KeyboardConfig = new List < KeyboardConfig >
{
2020-05-02 22:00:53 -04:00
new KeyboardConfig
{
Index = 0 ,
ControllerType = ControllerType . JoyconPair ,
PlayerIndex = PlayerIndex . Player1 ,
LeftJoycon = new NpadKeyboardLeft
{
StickUp = Key . W ,
StickDown = Key . S ,
StickLeft = Key . A ,
StickRight = Key . D ,
StickButton = Key . F ,
DPadUp = Key . Up ,
DPadDown = Key . Down ,
DPadLeft = Key . Left ,
DPadRight = Key . Right ,
ButtonMinus = Key . Minus ,
ButtonL = Key . E ,
ButtonZl = Key . Q ,
ButtonSl = Key . Unbound ,
ButtonSr = Key . Unbound
} ,
RightJoycon = new NpadKeyboardRight
{
StickUp = Key . I ,
StickDown = Key . K ,
StickLeft = Key . J ,
StickRight = Key . L ,
StickButton = Key . H ,
ButtonA = Key . Z ,
ButtonB = Key . X ,
ButtonX = Key . C ,
ButtonY = Key . V ,
ButtonPlus = Key . Plus ,
ButtonR = Key . U ,
ButtonZr = Key . O ,
ButtonSl = Key . Unbound ,
ButtonSr = Key . Unbound
2020-09-29 17:32:42 -04:00
} ,
EnableMotion = false ,
MirrorInput = false ,
Slot = 0 ,
AltSlot = 0 ,
Sensitivity = 100 ,
GyroDeadzone = 1 ,
DsuServerHost = "127.0.0.1" ,
DsuServerPort = 26760
2020-05-02 22:00:53 -04:00
}
} ;
configurationFileUpdated = true ;
}
2020-05-03 09:00:29 -04:00
// Only needed for version 6 configurations.
if ( configurationFileFormat . Version = = 6 )
{
2020-08-03 19:32:53 -04:00
Common . Logging . Logger . Warning ? . Print ( LogClass . Application , $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 7." ) ;
2020-05-03 09:00:29 -04:00
for ( int i = 0 ; i < configurationFileFormat . KeyboardConfig . Count ; i + + )
{
if ( configurationFileFormat . KeyboardConfig [ i ] . Index ! = KeyboardConfig . AllKeyboardsIndex )
{
configurationFileFormat . KeyboardConfig [ i ] . Index + + ;
}
}
}
2020-06-16 14:28:02 -04:00
if ( configurationFileFormat . Version < 8 )
{
2020-08-03 19:32:53 -04:00
Common . Logging . Logger . Warning ? . Print ( LogClass . Application , $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 8." ) ;
2020-06-16 14:28:02 -04:00
2021-01-01 09:36:47 -05:00
configurationFileFormat . EnablePtc = true ;
2020-06-16 14:28:02 -04:00
configurationFileUpdated = true ;
}
2020-06-26 06:30:16 -04:00
if ( configurationFileFormat . Version < 9 )
{
2020-08-03 19:32:53 -04:00
Common . Logging . Logger . Warning ? . Print ( LogClass . Application , $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 9." ) ;
2020-06-26 06:30:16 -04:00
configurationFileFormat . ColumnSort = new ColumnSort
{
SortColumnId = 0 ,
SortAscending = false
} ;
configurationFileFormat . Hotkeys = new KeyboardHotkeys
{
ToggleVsync = Key . Tab
} ;
configurationFileUpdated = true ;
}
2020-07-03 19:16:49 -04:00
if ( configurationFileFormat . Version < 10 )
2020-05-02 22:00:53 -04:00
{
2020-08-03 19:32:53 -04:00
Common . Logging . Logger . Warning ? . Print ( LogClass . Application , $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 10." ) ;
2020-07-03 19:16:49 -04:00
configurationFileFormat . AudioBackend = AudioBackend . OpenAl ;
configurationFileUpdated = true ;
2020-05-02 22:00:53 -04:00
}
2020-07-06 22:41:07 -04:00
if ( configurationFileFormat . Version < 11 )
{
2020-08-03 19:32:53 -04:00
Common . Logging . Logger . Warning ? . Print ( LogClass . Application , $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 11." ) ;
2020-07-06 22:41:07 -04:00
configurationFileFormat . ResScale = 1 ;
configurationFileFormat . ResScaleCustom = 1.0f ;
configurationFileUpdated = true ;
}
2020-08-02 10:41:24 -04:00
if ( configurationFileFormat . Version < 12 )
{
2020-08-03 19:32:53 -04:00
Common . Logging . Logger . Warning ? . Print ( LogClass . Application , $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 12." ) ;
2020-08-02 10:41:24 -04:00
configurationFileFormat . LoggingGraphicsDebugLevel = GraphicsDebugLevel . None ;
configurationFileUpdated = true ;
}
2020-09-29 16:05:25 -04:00
if ( configurationFileFormat . Version < 14 )
{
Common . Logging . Logger . Warning ? . Print ( LogClass . Application , $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 14." ) ;
configurationFileFormat . CheckUpdatesOnStart = true ;
configurationFileUpdated = true ;
}
2020-11-12 18:15:34 -05:00
if ( configurationFileFormat . Version < 16 )
{
Common . Logging . Logger . Warning ? . Print ( LogClass . Application , $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 16." ) ;
configurationFileFormat . EnableShaderCache = true ;
configurationFileUpdated = true ;
}
2020-12-01 17:02:27 -05:00
if ( configurationFileFormat . Version < 17 )
{
Common . Logging . Logger . Warning ? . Print ( LogClass . Application , $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 17." ) ;
configurationFileFormat . StartFullscreen = false ;
configurationFileUpdated = true ;
}
2020-12-15 21:19:07 -05:00
if ( configurationFileFormat . Version < 18 )
{
Common . Logging . Logger . Warning ? . Print ( LogClass . Application , $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 18." ) ;
configurationFileFormat . AspectRatio = AspectRatio . Fixed16x9 ;
configurationFileUpdated = true ;
}
2021-01-14 17:30:52 -05:00
if ( configurationFileFormat . Version < 20 )
{
Common . Logging . Logger . Warning ? . Print ( LogClass . Application , $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 20." ) ;
configurationFileFormat . ShowConfirmExit = true ;
configurationFileUpdated = true ;
}
2021-02-15 16:48:21 -05:00
if ( configurationFileFormat . Version < 22 )
{
Common . Logging . Logger . Warning ? . Print ( LogClass . Application , $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 22." ) ;
configurationFileFormat . HideCursorOnIdle = false ;
configurationFileUpdated = true ;
}
2020-07-03 19:16:49 -04:00
List < InputConfig > inputConfig = new List < InputConfig > ( ) ;
inputConfig . AddRange ( configurationFileFormat . ControllerConfig ) ;
inputConfig . AddRange ( configurationFileFormat . KeyboardConfig ) ;
2020-07-06 22:41:07 -04:00
Graphics . ResScale . Value = configurationFileFormat . ResScale ;
Graphics . ResScaleCustom . Value = configurationFileFormat . ResScaleCustom ;
2020-03-30 17:38:52 -04:00
Graphics . MaxAnisotropy . Value = configurationFileFormat . MaxAnisotropy ;
2020-12-15 21:19:07 -05:00
Graphics . AspectRatio . Value = configurationFileFormat . AspectRatio ;
2019-12-21 14:52:31 -05:00
Graphics . ShadersDumpPath . Value = configurationFileFormat . GraphicsShadersDumpPath ;
Logger . EnableDebug . Value = configurationFileFormat . LoggingEnableDebug ;
Logger . EnableStub . Value = configurationFileFormat . LoggingEnableStub ;
Logger . EnableInfo . Value = configurationFileFormat . LoggingEnableInfo ;
Logger . EnableWarn . Value = configurationFileFormat . LoggingEnableWarn ;
Logger . EnableError . Value = configurationFileFormat . LoggingEnableError ;
Logger . EnableGuest . Value = configurationFileFormat . LoggingEnableGuest ;
Logger . EnableFsAccessLog . Value = configurationFileFormat . LoggingEnableFsAccessLog ;
Logger . FilteredClasses . Value = configurationFileFormat . LoggingFilteredClasses ;
2020-08-02 10:41:24 -04:00
Logger . GraphicsDebugLevel . Value = configurationFileFormat . LoggingGraphicsDebugLevel ;
2019-12-21 14:52:31 -05:00
Logger . EnableFileLog . Value = configurationFileFormat . EnableFileLog ;
System . Language . Value = configurationFileFormat . SystemLanguage ;
2020-03-19 18:37:55 -04:00
System . Region . Value = configurationFileFormat . SystemRegion ;
2020-03-25 18:23:21 -04:00
System . TimeZone . Value = configurationFileFormat . SystemTimeZone ;
2020-04-16 19:18:54 -04:00
System . SystemTimeOffset . Value = configurationFileFormat . SystemTimeOffset ;
2019-12-21 14:52:31 -05:00
System . EnableDockedMode . Value = configurationFileFormat . DockedMode ;
EnableDiscordIntegration . Value = configurationFileFormat . EnableDiscordIntegration ;
2020-09-29 16:05:25 -04:00
CheckUpdatesOnStart . Value = configurationFileFormat . CheckUpdatesOnStart ;
2021-01-14 17:30:52 -05:00
ShowConfirmExit . Value = configurationFileFormat . ShowConfirmExit ;
2021-02-15 16:48:21 -05:00
HideCursorOnIdle . Value = configurationFileFormat . HideCursorOnIdle ;
2019-12-21 14:52:31 -05:00
Graphics . EnableVsync . Value = configurationFileFormat . EnableVsync ;
2020-11-12 18:15:34 -05:00
Graphics . EnableShaderCache . Value = configurationFileFormat . EnableShaderCache ;
2020-06-16 14:28:02 -04:00
System . EnablePtc . Value = configurationFileFormat . EnablePtc ;
2019-12-21 14:52:31 -05:00
System . EnableFsIntegrityChecks . Value = configurationFileFormat . EnableFsIntegrityChecks ;
System . FsGlobalAccessLogMode . Value = configurationFileFormat . FsGlobalAccessLogMode ;
2020-07-03 19:16:49 -04:00
System . AudioBackend . Value = configurationFileFormat . AudioBackend ;
2021-04-04 08:06:59 -04:00
System . ExpandRam . Value = configurationFileFormat . ExpandRam ;
2019-12-21 14:52:31 -05:00
System . IgnoreMissingServices . Value = configurationFileFormat . IgnoreMissingServices ;
Ui . GuiColumns . FavColumn . Value = configurationFileFormat . GuiColumns . FavColumn ;
Ui . GuiColumns . IconColumn . Value = configurationFileFormat . GuiColumns . IconColumn ;
Ui . GuiColumns . AppColumn . Value = configurationFileFormat . GuiColumns . AppColumn ;
Ui . GuiColumns . DevColumn . Value = configurationFileFormat . GuiColumns . DevColumn ;
Ui . GuiColumns . VersionColumn . Value = configurationFileFormat . GuiColumns . VersionColumn ;
Ui . GuiColumns . TimePlayedColumn . Value = configurationFileFormat . GuiColumns . TimePlayedColumn ;
Ui . GuiColumns . LastPlayedColumn . Value = configurationFileFormat . GuiColumns . LastPlayedColumn ;
Ui . GuiColumns . FileExtColumn . Value = configurationFileFormat . GuiColumns . FileExtColumn ;
Ui . GuiColumns . FileSizeColumn . Value = configurationFileFormat . GuiColumns . FileSizeColumn ;
Ui . GuiColumns . PathColumn . Value = configurationFileFormat . GuiColumns . PathColumn ;
2020-06-26 06:30:16 -04:00
Ui . ColumnSort . SortColumnId . Value = configurationFileFormat . ColumnSort . SortColumnId ;
Ui . ColumnSort . SortAscending . Value = configurationFileFormat . ColumnSort . SortAscending ;
2019-12-21 14:52:31 -05:00
Ui . GameDirs . Value = configurationFileFormat . GameDirs ;
Ui . EnableCustomTheme . Value = configurationFileFormat . EnableCustomTheme ;
Ui . CustomThemePath . Value = configurationFileFormat . CustomThemePath ;
2020-12-01 17:02:27 -05:00
Ui . StartFullscreen . Value = configurationFileFormat . StartFullscreen ;
2019-12-21 14:52:31 -05:00
Hid . EnableKeyboard . Value = configurationFileFormat . EnableKeyboard ;
2020-06-26 06:30:16 -04:00
Hid . Hotkeys . Value = configurationFileFormat . Hotkeys ;
2020-05-02 22:00:53 -04:00
Hid . InputConfig . Value = inputConfig ;
2020-03-19 18:37:55 -04:00
if ( configurationFileUpdated )
{
ToFileFormat ( ) . SaveConfig ( configurationFilePath ) ;
2020-08-30 12:51:53 -04:00
Common . Logging . Logger . Notice . Print ( LogClass . Application , $"Configuration file updated to version {ConfigurationFileFormat.CurrentVersion}" ) ;
2020-03-19 18:37:55 -04:00
}
2019-12-21 14:52:31 -05:00
}
2021-04-13 15:58:47 -04:00
private static void LogValueChange < T > ( object sender , ReactiveEventArgs < T > eventArgs , string valueName )
{
Common . Logging . Logger . Info ? . Print ( LogClass . Configuration , $"{valueName} set to: {eventArgs.NewValue}" ) ;
}
2019-12-21 14:52:31 -05:00
public static void Initialize ( )
{
if ( Instance ! = null )
{
throw new InvalidOperationException ( "Configuration is already initialized" ) ;
}
Instance = new ConfigurationState ( ) ;
}
}
}