Skip to content

Commit 7855c28

Browse files
committed
Add confirmation and removal to bindings menu
This makes the following improvements to the gamepad bindings menu: - The menu now shows a hint that you can press a button while any of the bind options are selected (or that you can navigate away from those options) - Instead of button presses immediately setting a binding, they now ask for confirmation: press the same button a second time to confirm - You can now remove a binding, the same way you add it (this has the same type of confirmation) - This menu used to be inconsistent with pretty much every other menu in the game by showing a permanent title and description for the menu itself ("Game Pad", "Change controller options.") rather than showing a title and description for the currently selected option. This inconsistency is now fixed.
1 parent 0e9c4f9 commit 7855c28

File tree

7 files changed

+182
-44
lines changed

7 files changed

+182
-44
lines changed

desktop_version/lang/en/strings.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@
4646
<string english="unlock secret lab" translation="" explanation="menu option"/>
4747
<string english="game pad" translation="" explanation="menu option"/>
4848
<string english="Game Pad Options" translation="" explanation="title" max="20"/>
49-
<string english="Game Pad" translation="" explanation="title" max="20"/>
5049
<string english="Rebind your controller&apos;s buttons and adjust sensitivity." translation="" explanation="" max="38*5"/>
51-
<string english="Change controller options." translation="" explanation="" max="38*2"/>
5250
<string english="language" translation="" explanation="menu option"/>
5351
<string english="Language" translation="" explanation="title" max="20"/>
5452
<string english="Change the language." translation="" explanation="" max="38*2"/>
@@ -135,19 +133,30 @@
135133
<string english="disable cutscenes" translation="" explanation="menu option"/>
136134
<string english="enable cutscenes" translation="" explanation="menu option"/>
137135
<string english="analog stick sensitivity" translation="" explanation="menu option"/>
136+
<string english="Stick Sensitivity" translation="" explanation="title" max="20"/>
137+
<string english="Change the sensitivity of the analog stick." translation="" explanation="" max="38*3"/>
138138
<string english="Low" translation="" explanation="analog stick sensitivity, game pad menu"/>
139139
<string english="Medium" translation="" explanation="analog stick sensitivity, game pad menu"/>
140140
<string english="High" translation="" explanation="analog stick sensitivity, game pad menu"/>
141141
<string english="bind flip" translation="" explanation="menu option"/>
142+
<string english="Bind Flip" translation="" explanation="title" max="20"/>
142143
<string english="bind enter" translation="" explanation="menu option"/>
144+
<string english="Bind Enter" translation="" explanation="title" max="20"/>
143145
<string english="bind menu" translation="" explanation="menu option"/>
146+
<string english="Bind Menu" translation="" explanation="title" max="20"/>
144147
<string english="bind restart" translation="" explanation="menu option. In-game death key to restart at checkpoint"/>
148+
<string english="Bind Restart" translation="" explanation="title" max="20"/>
145149
<string english="bind interact" translation="" explanation="menu option"/>
150+
<string english="Bind Interact" translation="" explanation="title" max="20"/>
146151
<string english="Flip is bound to: " translation="" explanation="controller binds, bound to A, B, X, Y, etc. These strings end with a space!" max="32"/>
147152
<string english="Enter is bound to: " translation="" explanation="controller binds, bound to A, B, X, Y, etc. These strings end with a space!" max="32"/>
148153
<string english="Menu is bound to: " translation="" explanation="controller binds, bound to A, B, X, Y, etc. These strings end with a space!" max="32"/>
149154
<string english="Restart is bound to: " translation="" explanation="in-game death key to restart at checkpoint. Controller binds, bound to A, B, X, Y, etc. These strings end with a space!" max="32"/>
150155
<string english="Interact is bound to: " translation="" explanation="controller binds, bound to A, B, X, Y, etc. These strings end with a space!" max="32"/>
156+
<string english="Press a button...|(or press ↑↓)" translation="" explanation="the arrows represent up/down buttons, or stick movement... So: press a controller button, or navigate away" max="38*2"/>
157+
<string english="Add {button}?|Press again to confirm" translation="" explanation="Bind the X button to this action? Press X again to really add it" max="38*2"/>
158+
<string english="Remove {button}?|Press again to confirm" translation="" explanation="Remove the binding of the X button for this action? Press X again to really remove it" max="38*2"/>
159+
<string english="Interact is currently Enter!|See speedrunner options." translation="" explanation="the Interact action can't be configured now because it's the same as the Enter action. There's an option in the Speedrunner options to split it off" max="38*2"/>
151160
<string english="ERROR: No language files found." translation="" explanation="" max="38*3"/>
152161
<string english="Language folder:" translation="" explanation="" max="39"/>
153162
<string english="Repository language folder:" translation="" explanation="Language folder from the Git repository" max="39"/>

desktop_version/src/ButtonGlyphs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ const char* BUTTONGLYPHS_get_wasd_text(void)
272272
return loc::gettext("Press left/right to move");
273273
}
274274

275-
static const char* sdlbutton_to_glyph(const SDL_GameControllerButton button)
275+
const char* BUTTONGLYPHS_sdlbutton_to_glyph(const SDL_GameControllerButton button)
276276
{
277277
if (button > SDL_CONTROLLER_BUTTON_RIGHTSHOULDER)
278278
{
@@ -292,7 +292,7 @@ static const char* glyph_for_vector(
292292
return NULL;
293293
}
294294

295-
return sdlbutton_to_glyph(buttons[index]);
295+
return BUTTONGLYPHS_sdlbutton_to_glyph(buttons[index]);
296296
}
297297

298298
const char* BUTTONGLYPHS_get_button(const ActionSet actionset, const Action action, int binding)

desktop_version/src/ButtonGlyphs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ void BUTTONGLYPHS_keyboard_set_active(bool active);
2020
void BUTTONGLYPHS_update_layout(SDL_GameController *c);
2121

2222
const char* BUTTONGLYPHS_get_wasd_text(void);
23+
const char* BUTTONGLYPHS_sdlbutton_to_glyph(SDL_GameControllerButton button);
2324
const char* BUTTONGLYPHS_get_button(ActionSet actionset, Action action, int binding);
2425

2526
char* BUTTONGLYPHS_get_all_gamepad_buttons(

desktop_version/src/Game.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,10 @@ void Game::init(void)
254254
levelpage=0;
255255
playcustomlevel=0;
256256

257+
gpmenu_lastbutton = SDL_CONTROLLER_BUTTON_INVALID;
258+
gpmenu_confirming = false;
259+
gpmenu_showremove = false;
260+
257261
silence_settings_error = false;
258262

259263
deathcounts = 0;
@@ -7009,7 +7013,7 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ )
70097013
option(loc::gettext("bind restart"));
70107014
option(loc::gettext("bind interact"), separate_interact);
70117015
option(loc::gettext("return"));
7012-
menuyoff = 0;
7016+
menuyoff = 12;
70137017
maxspacing = 10;
70147018
break;
70157019
case Menu::language:

desktop_version/src/Game.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,10 @@ class Game
404404
int creditposx, creditposy, creditposdelay;
405405
int oldcreditposx;
406406

407+
SDL_GameControllerButton gpmenu_lastbutton;
408+
bool gpmenu_confirming;
409+
bool gpmenu_showremove;
410+
407411
bool silence_settings_error;
408412

409413

desktop_version/src/Input.cpp

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,37 @@ static void updatebuttonmappings(int bind)
3535
) {
3636
if (key.isDown(i))
3737
{
38+
if (!game.gpmenu_confirming || i != game.gpmenu_lastbutton)
39+
{
40+
game.gpmenu_confirming = true;
41+
game.gpmenu_lastbutton = i;
42+
43+
// Is this button already in the list for this action?
44+
std::vector<SDL_GameControllerButton>* vec = NULL;
45+
switch (bind)
46+
{
47+
case 1: vec = &game.controllerButton_flip; break;
48+
case 2: vec = &game.controllerButton_map; break;
49+
case 3: vec = &game.controllerButton_esc; break;
50+
case 4: vec = &game.controllerButton_restart; break;
51+
case 5: vec = &game.controllerButton_interact; break;
52+
default: return;
53+
}
54+
55+
game.gpmenu_showremove = false;
56+
for (size_t j = 0; j < vec->size(); j += 1)
57+
{
58+
if (i == (*vec)[j])
59+
{
60+
game.gpmenu_showremove = true;
61+
break;
62+
}
63+
}
64+
65+
return;
66+
}
67+
game.gpmenu_confirming = false;
68+
3869
bool dupe = false;
3970
switch (bind)
4071
{
@@ -46,13 +77,14 @@ static void updatebuttonmappings(int bind)
4677
if (i == game.controllerButton_flip[j])
4778
{
4879
dupe = true;
80+
game.controllerButton_flip.erase(game.controllerButton_flip.begin() + j);
4981
}
5082
}
5183
if (!dupe)
5284
{
5385
game.controllerButton_flip.push_back(i);
54-
music.playef(Sound_VIRIDIAN);
5586
}
87+
music.playef(Sound_VIRIDIAN);
5688
for (j = 0; j < game.controllerButton_map.size(); j += 1)
5789
{
5890
if (i == game.controllerButton_map[j])
@@ -91,13 +123,14 @@ static void updatebuttonmappings(int bind)
91123
if (i == game.controllerButton_map[j])
92124
{
93125
dupe = true;
126+
game.controllerButton_map.erase(game.controllerButton_map.begin() + j);
94127
}
95128
}
96129
if (!dupe)
97130
{
98131
game.controllerButton_map.push_back(i);
99-
music.playef(Sound_VIRIDIAN);
100132
}
133+
music.playef(Sound_VIRIDIAN);
101134
for (j = 0; j < game.controllerButton_flip.size(); j += 1)
102135
{
103136
if (i == game.controllerButton_flip[j])
@@ -136,13 +169,14 @@ static void updatebuttonmappings(int bind)
136169
if (i == game.controllerButton_esc[j])
137170
{
138171
dupe = true;
172+
game.controllerButton_esc.erase(game.controllerButton_esc.begin() + j);
139173
}
140174
}
141175
if (!dupe)
142176
{
143177
game.controllerButton_esc.push_back(i);
144-
music.playef(Sound_VIRIDIAN);
145178
}
179+
music.playef(Sound_VIRIDIAN);
146180
for (j = 0; j < game.controllerButton_flip.size(); j += 1)
147181
{
148182
if (i == game.controllerButton_flip[j])
@@ -181,13 +215,14 @@ static void updatebuttonmappings(int bind)
181215
if (i == game.controllerButton_restart[j])
182216
{
183217
dupe = true;
218+
game.controllerButton_restart.erase(game.controllerButton_restart.begin() + j);
184219
}
185220
}
186221
if (!dupe)
187222
{
188223
game.controllerButton_restart.push_back(i);
189-
music.playef(Sound_VIRIDIAN);
190224
}
225+
music.playef(Sound_VIRIDIAN);
191226
for (j = 0; j < game.controllerButton_flip.size(); j += 1)
192227
{
193228
if (i == game.controllerButton_flip[j])
@@ -226,13 +261,14 @@ static void updatebuttonmappings(int bind)
226261
if (i == game.controllerButton_interact[j])
227262
{
228263
dupe = true;
264+
game.controllerButton_interact.erase(game.controllerButton_interact.begin() + j);
229265
}
230266
}
231267
if (!dupe)
232268
{
233269
game.controllerButton_interact.push_back(i);
234-
music.playef(Sound_VIRIDIAN);
235270
}
271+
music.playef(Sound_VIRIDIAN);
236272
for (j = 0; j < game.controllerButton_flip.size(); j += 1)
237273
{
238274
if (i == game.controllerButton_flip[j])
@@ -2526,6 +2562,11 @@ void titleinput(void)
25262562
{
25272563
game.currentmenuoption++;
25282564
}
2565+
2566+
if (game.currentmenuname == Menu::controller && (game.press_left || game.press_right))
2567+
{
2568+
game.gpmenu_confirming = false;
2569+
}
25292570
}
25302571
else
25312572
{

0 commit comments

Comments
 (0)