@@ -15,9 +15,10 @@ public sealed class SettingsControls(Desktop desktop, SettingsManager configMana
1515{
1616 public ButtonName ? MappingButton { get ; private set ; }
1717 public ButtonName ? MappingMacro { get ; private set ; }
18+ public Direction ? MappingDirection { get ; private set ; }
1819 public Button ResetMapButton { get ; private set ; }
1920 Label SelectedJoystick { get ; set ; }
20- Image [ ] Directions { get ; } = new Image [ 9 ] ;
21+ Button [ ] Directions { get ; } = new Button [ 9 ] ;
2122 Dictionary < ButtonName , Button > Buttons { get ; } = [ ] ;
2223 Dictionary < ButtonName , Button > Macros { get ; } = [ ] ;
2324
@@ -26,6 +27,7 @@ public sealed class SettingsControls(Desktop desktop, SettingsManager configMana
2627 Theme defaultTheme ;
2728
2829 static readonly Color darkGray = new ( 50 , 50 , 50 ) ;
30+ static readonly Color slateGray = Color . SlateGray ;
2931
3032 Settings Config => configManager . CurrentConfig ;
3133
@@ -75,15 +77,29 @@ public Widget BuildUI()
7577 ButtonName . KK ,
7678 ] ;
7779
78- PlayerPad player ;
80+ PlayerInputDevice player ;
7981
80- public void SetPlayer ( PlayerPad pad )
82+ public void SetPlayer ( PlayerInputDevice pad )
8183 {
8284 SelectedJoystick . Text = pad . Name ;
8385
8486 var currentType = Config . InputMap . GetPadKind ( pad ) ;
8587 controllerTypeCombo . SelectedIndex = ThemeConfig . ControllerTypes . Keys . ToArray ( ) . IndexOf ( currentType ) ;
8688 player = pad ;
89+
90+ foreach ( var button in Directions )
91+ if ( ! player . IsKeyboard ||
92+ button . Tag is Direction
93+ and not ( Direction . Up or Direction . Down or Direction . Backward or Direction . Forward ) )
94+ {
95+ button . Enabled = false ;
96+ button . OverBackground = null ;
97+ }
98+ else
99+ {
100+ button . Enabled = true ;
101+ button . OverBackground = new SolidBrush ( Color . DarkSlateGray ) ;
102+ }
87103 }
88104
89105 void RebuildMacroButtons ( )
@@ -486,7 +502,9 @@ Grid BuildSettings()
486502 AddCheck ( 1 , 1 , "Frames after" , Config . FramesAfter , check => Config . FramesAfter = check ) ;
487503 AddCheck ( 1 , 2 , "Hide button release" , Config . HideButtonRelease , check => Config . HideButtonRelease = check ) ;
488504 AddCheck ( 1 , 3 , "Use Shortcuts" , Config . ShortcutsEnabled , check => Config . ShortcutsEnabled = check ) ;
489- CreateDirectionsSourceBox ( 1 , 4 , "Dir.Sources" ) ;
505+ AddCheck ( 1 , 4 , "Auto select when single pad" , Config . AutoSelectSinglePad ,
506+ check => Config . AutoSelectSinglePad = check ) ;
507+ CreateDirectionsSourceBox ( 1 , 5 , "Dir.Sources" ) ;
490508
491509 AddEnumCombo ( 2 , 0 , "SOCD" , Config . SOCD , item => Config . SOCD = item ) ;
492510 AddNumeric ( 2 , 1 , "Input space" , Config . SpaceBetweenInputs , v => Config . SpaceBetweenInputs = v ) ;
@@ -860,7 +878,7 @@ void InitButton(ButtonName buttonName, (int Row, int Collumn) pos, Grid grid)
860878 HorizontalAlignment = HorizontalAlignment . Center ,
861879 TextColor = Color . White ,
862880 Text = buttonName . ToString ( ) ,
863- }
881+ } ,
864882 } ;
865883
866884 button . Click += OnButtonMapClick ;
@@ -875,17 +893,27 @@ void InitButton(ButtonName buttonName, (int Row, int Collumn) pos, Grid grid)
875893 void OnButtonMapClick ( object sender , EventArgs e )
876894 {
877895 var button = ( Button ) sender ;
878- var name = ( ButtonName ) button . Tag ;
879896
880- MappingButton = name ;
881- currentModal = BuildButtonMapModal ( $ "Mapping { name } ") ;
897+ if ( button . Tag is ButtonName name )
898+ MappingButton = name ;
899+
900+ if ( button . Tag is Direction dir )
901+ {
902+ if ( player ? . IsKeyboard is not true )
903+ return ;
904+
905+ MappingDirection = dir ;
906+ }
907+
908+ currentModal = BuildButtonMapModal ( $ "Mapping { button . Tag } ") ;
882909 currentModal . ShowModal ( desktop ) ;
883910 }
884911
885912 public void ButtonMapped ( )
886913 {
887914 currentModal ? . Close ( ) ;
888915 MappingButton = null ;
916+ MappingDirection = null ;
889917 currentModal = null ;
890918 }
891919
@@ -895,16 +923,29 @@ void InitNumpadDirection(int numpad, (int Row, int Collumn) pos, Grid grid)
895923 var texture = defaultTheme . GetTexture ( dir ) ;
896924 var index = numpad - 1 ;
897925
898- Directions [ index ] = new ( )
926+ Image image = new ( )
899927 {
900928 Renderable = new TextureRegion ( texture ) ,
929+ Color = darkGray ,
901930 Width = 30 ,
902931 Height = 30 ,
903932 VerticalAlignment = VerticalAlignment . Center ,
904933 HorizontalAlignment = HorizontalAlignment . Center ,
905- Color = darkGray ,
906934 } ;
907935
936+ Button button = new ( )
937+ {
938+ Tag = dir ,
939+ Background = null ,
940+ FocusedBackground = null ,
941+ DisabledBackground = null ,
942+ Content = image ,
943+ } ;
944+
945+ button . Click += OnButtonMapClick ;
946+
947+ Directions [ index ] = button ;
948+
908949 Grid . SetColumn ( Directions [ index ] , pos . Collumn - 1 ) ;
909950 Grid . SetRow ( Directions [ index ] , pos . Row - 1 ) ;
910951 grid . Widgets . Add ( Directions [ index ] ) ;
@@ -950,7 +991,6 @@ Panel BuildSelectedController()
950991 left . Widgets . Add ( labelJoyStick ) ;
951992 left . Widgets . Add ( SelectedJoystick ) ;
952993
953-
954994 HorizontalStackPanel right = new ( )
955995 {
956996 VerticalAlignment = VerticalAlignment . Center ,
@@ -987,7 +1027,7 @@ Panel BuildSelectedController()
9871027
9881028 void OnChangeControllerType ( object sender , EventArgs e )
9891029 {
990- if ( sender is not ListView { SelectedItem : Label { Tag : PlayerPad . Kind kind } }
1030+ if ( sender is not ListView { SelectedItem : Label { Tag : PlayerInputDevice . Kind kind } }
9911031 || player is null || Config . InputMap . GetMapping ( player ) is not { } mapping )
9921032 return ;
9931033
@@ -998,10 +1038,23 @@ void OnChangeControllerType(object sender, EventArgs e)
9981038 public void HighLightDirection ( Direction dir )
9991039 {
10001040 var index = NumpadNotation . From ( dir ) - 1 ;
1041+
10011042 for ( var i = 0 ; i < Directions . Length ; i ++ )
1002- Directions [ i ] . Color = index == i && Config . EnabledDirections is not Settings . DirectionSources . None
1003- ? Color . White
1043+ {
1044+ ref var btn = ref Directions [ i ] ;
1045+
1046+ var backcolor = player ? . IsKeyboard is true &&
1047+ btn . Tag is Direction . Up or Direction . Down or Direction . Backward or Direction . Forward
1048+ ? slateGray
10041049 : darkGray ;
1050+
1051+ var color = index == i && Config . EnabledDirections is not Settings . DirectionSources . None
1052+ ? Color . White
1053+ : backcolor ;
1054+
1055+ if ( btn is { Content : Image img } )
1056+ img . Color = color ;
1057+ }
10051058 }
10061059
10071060 public void HighLightButtons ( ButtonName buttons )
0 commit comments