Menus/Controls: RESET TO DEFAULT and CLEAR ALL buttons

This commit is contained in:
James R 2024-02-18 00:38:16 -08:00
parent 788f49f6e2
commit d2f48eda29
2 changed files with 53 additions and 0 deletions

View file

@ -1068,6 +1068,8 @@ boolean M_ProfileEditInputs(INT32 ch);
void M_HandleProfileControls(void);
boolean M_ProfileControlsInputs(INT32 ch);
void M_ProfileSetControl(INT32 ch);
void M_ProfileDefaultControls(INT32 ch);
void M_ProfileClearControls(INT32 ch);
void M_MapProfileControl(event_t *ev);
void M_ProfileTryController(INT32 choice);

View file

@ -1,6 +1,7 @@
/// \file menus/options-profiles-edit-controls.c
/// \brief Profile Controls Editor
#include "../g_input.h"
#include "../k_menu.h"
#include "../s_sound.h"
#include "../i_joy.h" // for joystick menu controls
@ -88,6 +89,12 @@ menuitem_t OPTIONS_ProfileControls[] = {
{IT_STRING | IT_CALL, "TRY MAPPINGS", "Test your controls.",
NULL, {.routine = M_ProfileTryController}, 0, 0},
{IT_STRING | IT_CALL, "RESET TO DEFAULT", "Reset all controls back to default.",
NULL, {.routine = M_ProfileDefaultControls}, 0, 0},
{IT_STRING | IT_CALL, "CLEAR ALL", "Unbind all controls.",
NULL, {.routine = M_ProfileClearControls}, 0, 0},
{IT_STRING | IT_CALL, "CONFIRM", "Go back to profile setup.",
NULL, {.routine = M_ProfileControlsConfirm}, 0, 0},
};
@ -290,6 +297,50 @@ void M_ProfileSetControl(INT32 ch)
optionsmenu.bindtimer = TICRATE*5;
}
static void M_ProfileDefaultControlsResponse(INT32 ch)
{
if (ch == MA_YES)
{
memcpy(&optionsmenu.tempcontrols, gamecontroldefault, sizeof optionsmenu.tempcontrols);
S_StartSound(NULL, sfx_s24f);
}
}
void M_ProfileDefaultControls(INT32 ch)
{
(void)ch;
M_StartMessage(
"Profiles",
"Reset all controls to the default mappings?",
&M_ProfileDefaultControlsResponse,
MM_YESNO,
NULL,
NULL
);
}
static void M_ProfileClearControlsResponse(INT32 ch)
{
if (ch == MA_YES)
{
memset(&optionsmenu.tempcontrols, 0, sizeof optionsmenu.tempcontrols);
S_StartSound(NULL, sfx_s3k66);
}
}
void M_ProfileClearControls(INT32 ch)
{
(void)ch;
M_StartMessage(
"Profiles",
"Clear all control bindings?",
&M_ProfileClearControlsResponse,
MM_YESNO,
NULL,
NULL
);
}
// Map the event to the profile.
#define KEYHOLDFOR 1