Skip to content

Commit 83df8a9

Browse files
authored
Stick buttons (#9)
1 parent 25a6835 commit 83df8a9

33 files changed

Lines changed: 328 additions & 46 deletions

InputDisplay.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MP/@EntryIndexedValue">MP</s:String>
1111
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PP/@EntryIndexedValue">PP</s:String>
1212
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RB/@EntryIndexedValue">RB</s:String>
13+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RS/@EntryIndexedValue">RS</s:String>
1314
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RT/@EntryIndexedValue">RT</s:String>
1415
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SOCD/@EntryIndexedValue">SOCD</s:String>
1516
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=UI/@EntryIndexedValue">UI</s:String>

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "8.0.100",
3+
"version": "9.0.204",
44
"rollForward": "latestMinor"
55
}
66
}

src/InputDisplay/.config/dotnet-tools.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,34 @@
33
"isRoot": true,
44
"tools": {
55
"dotnet-mgcb": {
6-
"version": "3.8.1.303",
6+
"version": "3.8.4",
77
"commands": [
88
"mgcb"
99
]
1010
},
1111
"dotnet-mgcb-editor": {
12-
"version": "3.8.1.303",
12+
"version": "3.8.4",
1313
"commands": [
1414
"mgcb-editor"
1515
]
1616
},
1717
"dotnet-mgcb-editor-linux": {
18-
"version": "3.8.1.303",
18+
"version": "3.8.4",
1919
"commands": [
2020
"mgcb-editor-linux"
2121
]
2222
},
2323
"dotnet-mgcb-editor-windows": {
24-
"version": "3.8.1.303",
24+
"version": "3.8.4",
2525
"commands": [
2626
"mgcb-editor-windows"
2727
]
2828
},
2929
"dotnet-mgcb-editor-mac": {
30-
"version": "3.8.1.303",
30+
"version": "3.8.4",
3131
"commands": [
3232
"mgcb-editor-mac"
3333
]
3434
}
3535
}
36-
}
36+
}

src/InputDisplay/Config/Window/SettingsControls.cs

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public sealed class SettingsControls(Desktop desktop, SettingsManager configMana
2222
Dictionary<ButtonName, Button> Buttons { get; } = [];
2323
Dictionary<ButtonName, Button> Macros { get; } = [];
2424

25+
Theme fallbackTheme;
2526
WindowDialog currentModal;
2627
ComboView controllerTypeCombo = new();
2728
Theme defaultTheme;
@@ -75,6 +76,8 @@ public Widget BuildUI()
7576
ButtonName.MK,
7677
ButtonName.HK,
7778
ButtonName.KK,
79+
ButtonName.LS,
80+
ButtonName.RS,
7881
];
7982

8083
PlayerInputDevice player;
@@ -86,6 +89,7 @@ public void SetPlayer(PlayerInputDevice pad)
8689
var currentType = Config.InputMap.GetPadKind(pad);
8790
controllerTypeCombo.SelectedIndex = ThemeConfig.ControllerTypes.Keys.ToArray().IndexOf(currentType);
8891
player = pad;
92+
RefreshFallbackTheme();
8993

9094
foreach (var button in Directions)
9195
if (!player.IsKeyboard ||
@@ -123,18 +127,27 @@ void RebuildMacroButtons()
123127
var theme = ThemeManager.Get(Config.CurrentTheme);
124128
var macros = theme.GetMacro(buttonName, Config.Macros);
125129
if (macros.Length is 0)
130+
{
131+
var texture = theme.GetTexture(buttonName)
132+
?? fallbackTheme?.GetTexture(buttonName)
133+
?? ThemeManager.UnknownButton;
134+
126135
content.Widgets.Add(new Image
127136
{
128137
VerticalAlignment = VerticalAlignment.Center,
129138
HorizontalAlignment = HorizontalAlignment.Right,
130-
Renderable = new TextureRegion(ThemeManager.UnknownButton),
139+
Renderable = new TextureRegion(texture),
131140
Width = 30,
132141
Height = 30,
133142
});
143+
}
134144
else
135145
foreach (var part in macros)
136146
{
137-
var texture = theme.GetTexture(part) ?? ThemeManager.UnknownButton;
147+
var texture = theme.GetTexture(part)
148+
?? fallbackTheme?.GetTexture(part)
149+
?? ThemeManager.UnknownButton;
150+
138151
content.Widgets.Add(new Image
139152
{
140153
VerticalAlignment = VerticalAlignment.Center,
@@ -180,7 +193,7 @@ Dialog CreateMacroDialog(ButtonName buttonName)
180193

181194
foreach (var b in allButtonNames)
182195
{
183-
var texture = theme.GetTexture(b);
196+
var texture = theme.GetTexture(b) ?? fallbackTheme?.GetTexture(b);
184197
if (texture is null) continue;
185198

186199
Image icon = new()
@@ -245,6 +258,7 @@ Grid BuildMacroMap()
245258
root.ColumnsProportions.Add(new(ProportionType.Auto));
246259
root.ColumnsProportions.Add(new(ProportionType.Auto));
247260
root.ColumnsProportions.Add(new(ProportionType.Auto));
261+
root.ColumnsProportions.Add(new(ProportionType.Auto));
248262
root.RowsProportions.Add(new(ProportionType.Auto));
249263
root.RowsProportions.Add(new(ProportionType.Auto));
250264

@@ -276,7 +290,7 @@ Grid BuildMacroMap()
276290
RebuildMacroButtons();
277291
};
278292

279-
Grid.SetColumn(resetMapButton, 3);
293+
Grid.SetColumn(resetMapButton, 4);
280294
Grid.SetRow(resetMapButton, 0);
281295
root.Widgets.Add(resetMapButton);
282296

@@ -290,6 +304,8 @@ Grid BuildMacroMap()
290304
SetMacroButton(ButtonName.MK, (2, 1));
291305
SetMacroButton(ButtonName.HK, (2, 2));
292306
SetMacroButton(ButtonName.KK, (2, 3));
307+
SetMacroButton(ButtonName.LS, (1, 4));
308+
SetMacroButton(ButtonName.RS, (2, 4));
293309

294310
return root;
295311

@@ -852,11 +868,13 @@ VerticalStackPanel BuildInputMap()
852868
InitButton(ButtonName.MP, (1, 2), buttonsGrid);
853869
InitButton(ButtonName.HP, (1, 3), buttonsGrid);
854870
InitButton(ButtonName.PP, (1, 4), buttonsGrid);
871+
InitButton(ButtonName.LS, (1, 5), buttonsGrid);
855872

856873
InitButton(ButtonName.LK, (2, 1), buttonsGrid);
857874
InitButton(ButtonName.MK, (2, 2), buttonsGrid);
858875
InitButton(ButtonName.HK, (2, 3), buttonsGrid);
859876
InitButton(ButtonName.KK, (2, 4), buttonsGrid);
877+
InitButton(ButtonName.RS, (2, 5), buttonsGrid);
860878

861879
return root;
862880
}
@@ -1028,13 +1046,29 @@ Panel BuildSelectedController()
10281046
void OnChangeControllerType(object sender, EventArgs e)
10291047
{
10301048
if (sender is not ListView { SelectedItem: Label { Tag: PlayerInputDevice.Kind kind } }
1031-
|| player is null || Config.InputMap.GetMapping(player) is not { } mapping)
1049+
|| player is null
1050+
|| Config.InputMap.GetMapping(player) is not { } mapping
1051+
)
10321052
return;
10331053

10341054
mapping.Kind = kind;
1055+
RefreshFallbackTheme();
10351056
SaveConfig();
10361057
}
10371058

1059+
void RefreshFallbackTheme()
1060+
{
1061+
if (player is null) return;
1062+
1063+
var kind = Config.InputMap.GetPadKind(player);
1064+
var theme = ThemeManager.GetFallback(kind);
1065+
1066+
if (fallbackTheme == theme) return;
1067+
1068+
fallbackTheme = theme;
1069+
RebuildMacroButtons();
1070+
}
1071+
10381072
public void HighLightDirection(Direction dir)
10391073
{
10401074
var index = NumpadNotation.From(dir) - 1;

0 commit comments

Comments
 (0)