@@ -13,23 +13,21 @@ namespace InputDisplay.Config.Window;
1313
1414public sealed class SettingsControls ( Desktop desktop , SettingsManager configManager ) : IDisposable
1515{
16- public Label SelectedJoystick { get ; private set ; }
17-
18- public ComboView ControllerTypeCombo = new ( ) ;
19- public Button ResetMapButton { get ; private set ; }
20- public Image [ ] Directions { get ; private set ; } = new Image [ 9 ] ;
21- public Dictionary < ButtonName , Button > Buttons { get ; private set ; } = new ( ) ;
22- public Dictionary < ButtonName , Button > Macros { get ; private set ; } = new ( ) ;
23-
2416 public ButtonName ? MappingButton { get ; private set ; }
2517 public ButtonName ? MappingMacro { get ; private set ; }
26- public WindowDialog CurrentModal { get ; private set ; }
18+ public Button ResetMapButton { get ; private set ; }
19+ Label SelectedJoystick { get ; set ; }
20+ Image [ ] Directions { get ; } = new Image [ 9 ] ;
21+ Dictionary < ButtonName , Button > Buttons { get ; } = [ ] ;
22+ Dictionary < ButtonName , Button > Macros { get ; } = [ ] ;
2723
24+ WindowDialog currentModal ;
25+ ComboView controllerTypeCombo = new ( ) ;
2826 Theme defaultTheme ;
2927
3028 static readonly Color darkGray = new ( 50 , 50 , 50 ) ;
3129
32- Settings config => configManager . CurrentConfig ;
30+ Settings Config => configManager . CurrentConfig ;
3331
3432 public Widget BuildUI ( )
3533 {
@@ -83,8 +81,8 @@ public void SetPlayer(PlayerPad pad)
8381 {
8482 SelectedJoystick . Text = pad . Name ;
8583
86- var currentType = config . InputMap . GetPadKind ( pad ) ;
87- ControllerTypeCombo . SelectedIndex = ThemeConfig . ControllerTypes . Keys . ToArray ( ) . IndexOf ( currentType ) ;
84+ var currentType = Config . InputMap . GetPadKind ( pad ) ;
85+ controllerTypeCombo . SelectedIndex = ThemeConfig . ControllerTypes . Keys . ToArray ( ) . IndexOf ( currentType ) ;
8886 player = pad ;
8987 }
9088
@@ -106,8 +104,8 @@ void RebuildMacroButtons()
106104 HorizontalAlignment = HorizontalAlignment . Left ,
107105 } ) ;
108106
109- var theme = ThemeManager . Get ( config . CurrentTheme ) ;
110- var macros = theme . GetMacro ( buttonName , config . Macros ) ;
107+ var theme = ThemeManager . Get ( Config . CurrentTheme ) ;
108+ var macros = theme . GetMacro ( buttonName , Config . Macros ) ;
111109 if ( macros . Length is 0 )
112110 content . Widgets . Add ( new Image
113111 {
@@ -160,8 +158,8 @@ Dialog CreateMacroDialog(ButtonName buttonName)
160158 Spacing = 15 ,
161159 } ;
162160 MappingMacro = buttonName ;
163- var theme = ThemeManager . Get ( config . CurrentTheme ) ;
164- var macros = theme . GetMacro ( buttonName , config . Macros ) ;
161+ var theme = ThemeManager . Get ( Config . CurrentTheme ) ;
162+ var macros = theme . GetMacro ( buttonName , Config . Macros ) ;
165163 var selected = macros . ToList ( ) ;
166164
167165 foreach ( var b in allButtonNames )
@@ -203,10 +201,10 @@ Dialog CreateMacroDialog(ButtonName buttonName)
203201 MappingMacro = null ;
204202 if ( ! dialog . Result ) return ;
205203
206- if ( config . Macros . ContainsKey ( buttonName ) )
207- config . Macros [ buttonName ] = [ .. selected ] ;
204+ if ( Config . Macros . ContainsKey ( buttonName ) )
205+ Config . Macros [ buttonName ] = [ .. selected ] ;
208206 else
209- config . Macros . Add ( buttonName , [ .. selected ] ) ;
207+ Config . Macros . Add ( buttonName , [ .. selected ] ) ;
210208
211209 selected . Clear ( ) ;
212210 SaveConfig ( ) ;
@@ -218,7 +216,7 @@ Dialog CreateMacroDialog(ButtonName buttonName)
218216 return dialog ;
219217 }
220218
221- Widget BuildMacroMap ( )
219+ Grid BuildMacroMap ( )
222220 {
223221 var root = new Grid
224222 {
@@ -257,7 +255,7 @@ Widget BuildMacroMap()
257255 } ;
258256 resetMapButton . Click += ( _ , _ ) =>
259257 {
260- config . Macros . Clear ( ) ;
258+ Config . Macros . Clear ( ) ;
261259 SaveConfig ( ) ;
262260 RebuildMacroButtons ( ) ;
263261 } ;
@@ -355,7 +353,7 @@ Grid BuildThemes()
355353
356354 dirCombo . Widgets . Add ( item ) ;
357355
358- if ( dirThemeName == config . CurrentTheme . Direction )
356+ if ( dirThemeName == Config . CurrentTheme . Direction )
359357 dirCombo . SelectedItem = item ;
360358 }
361359
@@ -364,7 +362,7 @@ Grid BuildThemes()
364362 var newTheme = ( string ) dirCombo . SelectedItem . Tag ;
365363
366364
367- config . CurrentTheme = config . CurrentTheme with
365+ Config . CurrentTheme = Config . CurrentTheme with
368366 {
369367 Direction = newTheme ,
370368 } ;
@@ -431,15 +429,15 @@ Grid BuildThemes()
431429
432430 btnCombo . Widgets . Add ( item ) ;
433431
434- if ( btnThemeName == config . CurrentTheme . Buttons )
432+ if ( btnThemeName == Config . CurrentTheme . Buttons )
435433 btnCombo . SelectedItem = item ;
436434 }
437435
438436 btnCombo . SelectedIndexChanged += ( _ , _ ) =>
439437 {
440438 var newTheme = ( string ) btnCombo . SelectedItem . Tag ;
441439
442- config . CurrentTheme = config . CurrentTheme with
440+ Config . CurrentTheme = Config . CurrentTheme with
443441 {
444442 Buttons = newTheme ,
445443 } ;
@@ -461,41 +459,41 @@ Grid BuildSettings()
461459 RowSpacing = 4 ,
462460 } ;
463461
464- grid . ColumnsProportions . Add ( new Proportion
462+ grid . ColumnsProportions . Add ( new ( )
465463 {
466464 Type = ProportionType . Part ,
467465 Value = .7f ,
468466 } ) ;
469- grid . ColumnsProportions . Add ( new Proportion
467+ grid . ColumnsProportions . Add ( new ( )
470468 {
471469 Type = ProportionType . Part ,
472470 Value = 1.3f ,
473471 } ) ;
474- grid . ColumnsProportions . Add ( new Proportion
472+ grid . ColumnsProportions . Add ( new ( )
475473 {
476474 Type = ProportionType . Part ,
477475 Value = 1f ,
478476 } ) ;
479477
480- AddCheck ( 0 , 0 , "Borderless" , config . Borderless , check => config . Borderless = check ) ;
481- AddCheck ( 0 , 1 , "Show frames" , config . ShowFrames , check => config . ShowFrames = check ) ;
482- AddCheck ( 0 , 2 , "Show neutral" , config . ShowNeutralIcon , check => config . ShowNeutralIcon = check ) ;
483- AddCheck ( 0 , 3 , "Shadow holding" , config . ShadowHolding , check => config . ShadowHolding = check ) ;
484- AddCheck ( 0 , 4 , "Hide holding" , config . HideHolding , check => config . HideHolding = check ) ;
485- AddCheck ( 0 , 5 , "Auto correct" , config . AutoCorrectMultiple , check => config . AutoCorrectMultiple = check ) ;
486-
487- AddCheck ( 1 , 0 , "Invert history" , config . InvertHistory , check => config . InvertHistory = check ) ;
488- AddCheck ( 1 , 1 , "Frames after" , config . FramesAfter , check => config . FramesAfter = check ) ;
489- AddCheck ( 1 , 2 , "Hide button release" , config . HideButtonRelease , check => config . HideButtonRelease = check ) ;
490- AddCheck ( 1 , 3 , "Use Shortcuts" , config . ShortcutsEnabled , check => config . ShortcutsEnabled = check ) ;
478+ AddCheck ( 0 , 0 , "Borderless" , Config . Borderless , check => Config . Borderless = check ) ;
479+ AddCheck ( 0 , 1 , "Show frames" , Config . ShowFrames , check => Config . ShowFrames = check ) ;
480+ AddCheck ( 0 , 2 , "Show neutral" , Config . ShowNeutralIcon , check => Config . ShowNeutralIcon = check ) ;
481+ AddCheck ( 0 , 3 , "Shadow holding" , Config . ShadowHolding , check => Config . ShadowHolding = check ) ;
482+ AddCheck ( 0 , 4 , "Hide holding" , Config . HideHolding , check => Config . HideHolding = check ) ;
483+ AddCheck ( 0 , 5 , "Auto correct" , Config . AutoCorrectMultiple , check => Config . AutoCorrectMultiple = check ) ;
484+
485+ AddCheck ( 1 , 0 , "Invert history" , Config . InvertHistory , check => Config . InvertHistory = check ) ;
486+ AddCheck ( 1 , 1 , "Frames after" , Config . FramesAfter , check => Config . FramesAfter = check ) ;
487+ AddCheck ( 1 , 2 , "Hide button release" , Config . HideButtonRelease , check => Config . HideButtonRelease = check ) ;
488+ AddCheck ( 1 , 3 , "Use Shortcuts" , Config . ShortcutsEnabled , check => Config . ShortcutsEnabled = check ) ;
491489 CreateDirectionsSourceBox ( 1 , 4 , "Dir.Sources" ) ;
492490
493- AddEnumCombo ( 2 , 0 , "SOCD" , config . SOCD , item => config . SOCD = item ) ;
494- AddNumeric ( 2 , 1 , "Input space" , config . SpaceBetweenInputs , v => config . SpaceBetweenInputs = v ) ;
495- AddNumeric ( 2 , 2 , "Command space" , config . SpaceBetweenCommands , v => config . SpaceBetweenCommands = v ) ;
496- AddNumeric ( 2 , 3 , "Direction space" , config . DirectionSpace , v => config . DirectionSpace = v ) ;
497- AddNumeric ( 2 , 4 , "Icon size" , config . IconSize , v => config . IconSize = v ) ;
498- AddColorPicker ( 2 , 5 , "Background color" , config . ClearColor , c => config . ClearColor = c ) ;
491+ AddEnumCombo ( 2 , 0 , "SOCD" , Config . SOCD , item => Config . SOCD = item ) ;
492+ AddNumeric ( 2 , 1 , "Input space" , Config . SpaceBetweenInputs , v => Config . SpaceBetweenInputs = v ) ;
493+ AddNumeric ( 2 , 2 , "Command space" , Config . SpaceBetweenCommands , v => Config . SpaceBetweenCommands = v ) ;
494+ AddNumeric ( 2 , 3 , "Direction space" , Config . DirectionSpace , v => Config . DirectionSpace = v ) ;
495+ AddNumeric ( 2 , 4 , "Icon size" , Config . IconSize , v => Config . IconSize = v ) ;
496+ AddColorPicker ( 2 , 5 , "Background color" , Config . ClearColor , c => Config . ClearColor = c ) ;
499497
500498 return grid ;
501499
@@ -514,18 +512,18 @@ void CreateDirectionsSourceBox(int col, int row, string labelText)
514512 } ;
515513 panel . Widgets . Add ( label ) ;
516514
517- var dirSources = config . EnabledDirections ;
515+ var dirSources = Config . EnabledDirections ;
518516 var chkDpad = InputCheck ( "DPad" , dirSources . HasFlag ( Settings . DirectionSources . DPad ) , check =>
519- config . EnabledDirections =
520- config . EnabledDirections . ChangeFlag ( Settings . DirectionSources . DPad , check ) ) ;
517+ Config . EnabledDirections =
518+ Config . EnabledDirections . ChangeFlag ( Settings . DirectionSources . DPad , check ) ) ;
521519
522520 var chkLAnalog = InputCheck ( "L.Analog" , dirSources . HasFlag ( Settings . DirectionSources . LeftAnalog ) , check =>
523- config . EnabledDirections =
524- config . EnabledDirections . ChangeFlag ( Settings . DirectionSources . LeftAnalog , check ) ) ;
521+ Config . EnabledDirections =
522+ Config . EnabledDirections . ChangeFlag ( Settings . DirectionSources . LeftAnalog , check ) ) ;
525523
526524 var chkRAnalog = InputCheck ( "R.Analog" , dirSources . HasFlag ( Settings . DirectionSources . RightAnalog ) , check =>
527- config . EnabledDirections =
528- config . EnabledDirections . ChangeFlag ( Settings . DirectionSources . RightAnalog , check ) ) ;
525+ Config . EnabledDirections =
526+ Config . EnabledDirections . ChangeFlag ( Settings . DirectionSources . RightAnalog , check ) ) ;
529527
530528 HorizontalStackPanel checksPanel = new ( )
531529 {
@@ -880,15 +878,15 @@ void OnButtonMapClick(object sender, EventArgs e)
880878 var name = ( ButtonName ) button . Tag ;
881879
882880 MappingButton = name ;
883- CurrentModal = BuildButtonMapModal ( $ "Mapping { name } ") ;
884- CurrentModal . ShowModal ( desktop ) ;
881+ currentModal = BuildButtonMapModal ( $ "Mapping { name } ") ;
882+ currentModal . ShowModal ( desktop ) ;
885883 }
886884
887885 public void ButtonMapped ( )
888886 {
889- CurrentModal ? . Close ( ) ;
887+ currentModal ? . Close ( ) ;
890888 MappingButton = null ;
891- CurrentModal = null ;
889+ currentModal = null ;
892890 }
893891
894892 void InitNumpadDirection ( int numpad , ( int Row , int Collumn ) pos , Grid grid )
@@ -912,15 +910,15 @@ void InitNumpadDirection(int numpad, (int Row, int Collumn) pos, Grid grid)
912910 grid . Widgets . Add ( Directions [ index ] ) ;
913911 }
914912
915- static Widget Line ( ) =>
916- new Panel
913+ static Panel Line ( ) =>
914+ new ( )
917915 {
918916 BorderThickness = new ( 0 , 1 ) ,
919917 Border = new SolidBrush ( Color . White ) ,
920918 Margin = new ( 0 , 5 ) ,
921919 } ;
922920
923- Widget BuildSelectedController ( )
921+ Panel BuildSelectedController ( )
924922 {
925923 Panel root = new ( ) ;
926924
@@ -969,28 +967,28 @@ Widget BuildSelectedController()
969967 } ;
970968 right . Widgets . Add ( labelType ) ;
971969
972- ControllerTypeCombo = new ( )
970+ controllerTypeCombo = new ( )
973971 {
974972 VerticalAlignment = VerticalAlignment . Center ,
975973 } ;
976- right . Widgets . Add ( ControllerTypeCombo ) ;
974+ right . Widgets . Add ( controllerTypeCombo ) ;
977975 foreach ( var ( typeName , text ) in ThemeConfig . ControllerTypes )
978- ControllerTypeCombo . Widgets . Add ( new Label
976+ controllerTypeCombo . Widgets . Add ( new Label
979977 {
980978 VerticalAlignment = VerticalAlignment . Center ,
981979 Padding = new ( 5 ) ,
982980 Text = text ,
983981 Tag = typeName ,
984982 } ) ;
985983
986- ControllerTypeCombo . SelectedIndexChanged += OnChangeControllerType ;
984+ controllerTypeCombo . SelectedIndexChanged += OnChangeControllerType ;
987985 return root ;
988986 }
989987
990988 void OnChangeControllerType ( object sender , EventArgs e )
991989 {
992990 if ( sender is not ListView { SelectedItem : Label { Tag : PlayerPad . Kind kind } }
993- || player is null || config . InputMap . GetMapping ( player ) is not { } mapping )
991+ || player is null || Config . InputMap . GetMapping ( player ) is not { } mapping )
994992 return ;
995993
996994 mapping . Kind = kind ;
@@ -1001,7 +999,7 @@ public void HighLightDirection(Direction dir)
1001999 {
10021000 var index = NumpadNotation . From ( dir ) - 1 ;
10031001 for ( var i = 0 ; i < Directions . Length ; i ++ )
1004- Directions [ i ] . Color = index == i && config . EnabledDirections is not Settings . DirectionSources . None
1002+ Directions [ i ] . Color = index == i && Config . EnabledDirections is not Settings . DirectionSources . None
10051003 ? Color . White
10061004 : darkGray ;
10071005 }
@@ -1015,7 +1013,7 @@ public void HighLightButtons(ButtonName buttons)
10151013 : ( IBrush ) null ;
10161014 }
10171015
1018- WindowDialog BuildButtonMapModal ( string title )
1016+ static Dialog BuildButtonMapModal ( string title )
10191017 {
10201018 Label label = new ( )
10211019 {
@@ -1030,13 +1028,13 @@ WindowDialog BuildButtonMapModal(string title)
10301028 return buttonMapModal ;
10311029 }
10321030
1033- public void SaveConfig ( ) => configManager . SaveFile ( ) ;
1031+ void SaveConfig ( ) => configManager . SaveFile ( ) ;
10341032
10351033 public void Dispose ( )
10361034 {
10371035 foreach ( var btn in Buttons . Values )
10381036 btn . Click -= OnButtonMapClick ;
10391037
1040- ControllerTypeCombo . SelectedIndexChanged -= OnChangeControllerType ;
1038+ controllerTypeCombo . SelectedIndexChanged -= OnChangeControllerType ;
10411039 }
10421040}
0 commit comments