2014-06-28 20:31:31 +00:00
using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Text ;
using System.Configuration ;
using System.Drawing ;
2014-08-02 22:10:55 +00:00
using System.Windows.Forms ;
2014-06-28 20:31:31 +00:00
namespace SCJMapper_V2
{
2017-04-28 20:26:49 +00:00
sealed class AppSettings : ApplicationSettingsBase , IDisposable
2014-06-28 20:31:31 +00:00
{
2018-01-02 00:45:49 +00:00
FormSettings FS = null ; // Settings form
2014-07-06 00:14:57 +00:00
2018-01-02 00:45:49 +00:00
// Singleton
private static readonly Lazy < AppSettings > m_lazy = new Lazy < AppSettings > ( ( ) = > new AppSettings ( ) ) ;
public static AppSettings Instance { get = > m_lazy . Value ; }
private AppSettings ( )
2014-08-02 20:28:13 +00:00
{
if ( this . FirstRun ) {
2018-01-02 00:45:49 +00:00
// migrate the settings to the new version if the app runs the first time
2014-08-02 20:28:13 +00:00
try {
this . Upgrade ( ) ;
}
catch { }
this . FirstRun = false ;
this . Save ( ) ;
}
2018-01-02 00:45:49 +00:00
if ( string . IsNullOrEmpty ( UseLanguage ) ) {
UseLanguage = SC . SCUiText . Languages . profile . ToString ( ) ; // get a default here
this . Save ( ) ;
}
2014-08-02 20:28:13 +00:00
}
2017-04-28 20:26:49 +00:00
public void Dispose ( bool disposing )
{
if ( disposing ) {
// dispose managed resources
if ( FS ! = null ) FS . Dispose ( ) ;
}
// free native resources
}
public void Dispose ( )
{
Dispose ( true ) ;
GC . SuppressFinalize ( this ) ;
}
2014-08-02 20:28:13 +00:00
/// <summary>
/// Show the Settings Dialog
/// </summary>
2017-12-26 13:44:41 +00:00
public DialogResult ShowSettings ( string pasteString )
2014-07-06 00:14:57 +00:00
{
2018-01-02 00:45:49 +00:00
if ( FS = = null ) FS = new FormSettings ( ) ;
2015-12-26 22:16:25 +00:00
FS . PasteString = pasteString ; // propagate joyinput
2014-07-06 00:14:57 +00:00
FS . ShowDialog ( ) ;
2014-08-02 22:10:55 +00:00
return ( FS . Canceled ) ? DialogResult . Cancel : DialogResult . OK ;
2014-07-06 00:14:57 +00:00
}
#region Setting Properties
2014-08-02 20:28:13 +00:00
// manages Upgrade
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "True" )]
2017-12-26 13:44:41 +00:00
public bool FirstRun
2014-08-02 20:28:13 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( bool ) this [ "FirstRun" ] ; }
2014-08-02 20:28:13 +00:00
set { this [ "FirstRun" ] = value ; }
}
2014-07-06 00:14:57 +00:00
2014-06-28 20:31:31 +00:00
// Control bound settings
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "1000, 900" )]
2014-06-28 20:31:31 +00:00
public Size FormSize
{
get { return ( Size ) this [ "FormSize" ] ; }
set { this [ "FormSize" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "10, 10" )]
2014-06-28 20:31:31 +00:00
public Point FormLocation
{
get { return ( Point ) this [ "FormLocation" ] ; }
set { this [ "FormLocation" ] = value ; }
}
// User Config Settings
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "layout_joystick_spacesim" )] // from Game Bundle
2017-12-26 13:44:41 +00:00
public string DefMappingName
2014-06-28 20:31:31 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( string ) this [ "DefMappingName" ] ; }
2014-06-28 21:50:07 +00:00
set { this [ "DefMappingName" ] = value ; }
2014-06-28 20:31:31 +00:00
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "layout_my_joystick" )] // just a default
2017-12-26 13:44:41 +00:00
public string MyMappingName
2014-06-29 01:26:39 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( string ) this [ "MyMappingName" ] ; }
2014-06-29 01:26:39 +00:00
set { this [ "MyMappingName" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "True" )]
2017-12-26 13:44:41 +00:00
public bool ShowJoystick
2014-12-22 00:34:09 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( bool ) this [ "ShowJoystick" ] ; }
2014-12-22 00:34:09 +00:00
set { this [ "ShowJoystick" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "True" )]
2017-12-26 13:44:41 +00:00
public bool ShowGamepad
2014-12-22 00:34:09 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( bool ) this [ "ShowGamepad" ] ; }
2014-12-22 00:34:09 +00:00
set { this [ "ShowGamepad" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "True" )]
2017-12-26 13:44:41 +00:00
public bool ShowKeyboard
2014-12-22 00:34:09 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( bool ) this [ "ShowKeyboard" ] ; }
2014-12-22 00:34:09 +00:00
set { this [ "ShowKeyboard" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "True" )]
2017-12-26 13:44:41 +00:00
public bool ShowMouse // 20151220BM: add mouse device (from AC 2.0 defaultProfile usage)
2015-12-22 00:47:23 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( bool ) this [ "ShowMouse" ] ; }
2015-12-22 00:47:23 +00:00
set { this [ "ShowMouse" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "False" )]
2017-12-26 13:44:41 +00:00
public bool ShowMapped
2014-12-22 00:34:09 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( bool ) this [ "ShowMapped" ] ; }
2014-12-22 00:34:09 +00:00
set { this [ "ShowMapped" ] = value ; }
}
2014-06-28 20:31:31 +00:00
2014-07-06 00:14:57 +00:00
// Seetings Window
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "" )]
2017-12-26 13:44:41 +00:00
public string IgnoreJS1
2014-07-06 00:14:57 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( string ) this [ "IgnoreJS1" ] ; }
2014-07-06 00:14:57 +00:00
set { this [ "IgnoreJS1" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "" )]
2017-12-26 13:44:41 +00:00
public string IgnoreJS2
2014-07-06 00:14:57 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( string ) this [ "IgnoreJS2" ] ; }
2014-07-06 00:14:57 +00:00
set { this [ "IgnoreJS2" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "" )]
2017-12-26 13:44:41 +00:00
public string IgnoreJS3
2014-07-06 00:14:57 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( string ) this [ "IgnoreJS3" ] ; }
2014-07-06 00:14:57 +00:00
set { this [ "IgnoreJS3" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "" )]
2017-12-26 13:44:41 +00:00
public string IgnoreJS4
2014-07-06 00:14:57 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( string ) this [ "IgnoreJS4" ] ; }
2014-07-06 00:14:57 +00:00
set { this [ "IgnoreJS4" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "" )]
2017-12-26 13:44:41 +00:00
public string IgnoreJS5
2014-07-06 00:14:57 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( string ) this [ "IgnoreJS5" ] ; }
2014-07-06 00:14:57 +00:00
set { this [ "IgnoreJS5" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "" )]
2017-12-26 13:44:41 +00:00
public string IgnoreJS6
2014-07-06 00:14:57 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( string ) this [ "IgnoreJS6" ] ; }
2014-07-06 00:14:57 +00:00
set { this [ "IgnoreJS6" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "" )]
2017-12-26 13:44:41 +00:00
public string IgnoreJS7
2014-07-06 00:14:57 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( string ) this [ "IgnoreJS7" ] ; }
2014-07-06 00:14:57 +00:00
set { this [ "IgnoreJS7" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "" )]
2017-12-26 13:44:41 +00:00
public string IgnoreJS8
2014-07-06 00:14:57 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( string ) this [ "IgnoreJS8" ] ; }
2014-07-06 00:14:57 +00:00
set { this [ "IgnoreJS8" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "" )]
2017-12-26 13:44:41 +00:00
public string IgnoreJS9
2016-03-06 16:22:16 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( string ) this [ "IgnoreJS9" ] ; }
2016-03-06 16:22:16 +00:00
set { this [ "IgnoreJS9" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "" )]
2017-12-26 13:44:41 +00:00
public string IgnoreJS10
2016-03-06 16:22:16 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( string ) this [ "IgnoreJS10" ] ; }
2016-03-06 16:22:16 +00:00
set { this [ "IgnoreJS10" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "" )]
2017-12-26 13:44:41 +00:00
public string IgnoreJS11
2016-03-06 16:22:16 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( string ) this [ "IgnoreJS11" ] ; }
2016-03-06 16:22:16 +00:00
set { this [ "IgnoreJS11" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "" )]
2017-12-26 13:44:41 +00:00
public string IgnoreJS12
2016-03-06 16:22:16 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( string ) this [ "IgnoreJS12" ] ; }
2016-03-06 16:22:16 +00:00
set { this [ "IgnoreJS12" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "" )]
2017-12-26 13:44:41 +00:00
public string UserSCPath
2014-07-06 00:14:57 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( string ) this [ "UserSCPath" ] ; }
2014-07-06 00:14:57 +00:00
set { this [ "UserSCPath" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "False" )]
2017-12-26 13:44:41 +00:00
public bool UserSCPathUsed
2014-07-06 00:14:57 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( bool ) this [ "UserSCPathUsed" ] ; }
2014-07-06 00:14:57 +00:00
set { this [ "UserSCPathUsed" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( ",default,multiplayer,singleplayer,player,flycam,vehicle_driver," )] // empty Note: comma separated list, must have a comma at the begining and the end (to find 'player' on its own...)
2017-12-26 13:44:41 +00:00
public string IgnoreActionmaps
2014-08-02 20:28:13 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( string ) this [ "IgnoreActionmaps" ] ; }
2014-08-02 20:28:13 +00:00
set { this [ "IgnoreActionmaps" ] = value ; }
}
2014-07-06 00:14:57 +00:00
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "False" )]
2017-12-26 13:44:41 +00:00
public bool DetectGamepad
2014-11-16 23:36:17 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( bool ) this [ "DetectGamepad" ] ; }
2014-11-16 23:36:17 +00:00
set { this [ "DetectGamepad" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "False" )]
2017-12-26 13:44:41 +00:00
public bool UsePTU
2015-12-26 22:16:25 +00:00
{
2018-06-23 15:01:41 +00:00
get { return ( bool ) this [ "UsePTU" ] ; }
2015-12-26 22:16:25 +00:00
set { this [ "UsePTU" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "False" )]
2017-12-26 13:44:41 +00:00
public bool UseCSVListing
2016-07-01 15:57:58 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( bool ) this [ "UseCSVListing" ] ; }
2016-07-01 15:57:58 +00:00
set { this [ "UseCSVListing" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "False" )]
2017-12-26 13:44:41 +00:00
public bool ListModifiers
2016-07-01 15:57:58 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( bool ) this [ "ListModifiers" ] ; }
2016-07-01 15:57:58 +00:00
set { this [ "ListModifiers" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "False" )]
2017-12-26 13:44:41 +00:00
public bool AutoTabXML
2017-05-13 22:18:55 +00:00
{
2017-12-26 13:44:41 +00:00
get { return ( bool ) this [ "AutoTabXML" ] ; }
2017-05-13 22:18:55 +00:00
set { this [ "AutoTabXML" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "profile" )]
public string UseLanguage
{
get { return ( string ) this [ "UseLanguage" ] ; }
set { this [ "UseLanguage" ] = value ; }
}
2018-01-03 23:05:35 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "False" )]
public bool ShowTreeTips
{
get { return ( bool ) this [ "ShowTreeTips" ] ; }
set { this [ "ShowTreeTips" ] = value ; }
}
2018-01-02 00:45:49 +00:00
2014-11-16 23:36:17 +00:00
2016-05-27 15:13:24 +00:00
//**** Form Table
// Control bound settings
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "1000, 900" )]
2016-05-27 15:13:24 +00:00
public Size FormTableSize
{
get { return ( Size ) this [ "FormTableSize" ] ; }
set { this [ "FormTableSize" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "760, 320" )]
2016-05-27 15:13:24 +00:00
public Point FormTableLocation
{
get { return ( Point ) this [ "FormTableLocation" ] ; }
set { this [ "FormTableLocation" ] = value ; }
}
2018-01-02 00:45:49 +00:00
[UserScopedSetting( )]
[DefaultSettingValue( "" )]
2016-05-27 15:13:24 +00:00
public string FormTableColumnWidth
{
get { return ( string ) this [ "FormTableColumnWidth" ] ; }
set { this [ "FormTableColumnWidth" ] = value ; }
}
2018-01-05 00:54:14 +00:00
//**** Form Options
[UserScopedSetting( )]
[DefaultSettingValue( "1000, 765" )]
public Size FormOptionsSize
{
get { return ( Size ) this [ "FormOptionsSize" ] ; }
set { this [ "FormOptionsSize" ] = value ; }
}
[UserScopedSetting( )]
[DefaultSettingValue( "10, 10" )]
public Point FormOptionsLocation
{
get { return ( Point ) this [ "FormOptionsLocation" ] ; }
set { this [ "FormOptionsLocation" ] = value ; }
}
2016-05-27 15:13:24 +00:00
2014-07-06 00:14:57 +00:00
#endregion
2014-06-28 20:31:31 +00:00
}
}