From 726415981f4889a18e02e8a4a2ab53a54a74103b Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 21 Feb 2024 20:21:15 -0800 Subject: [PATCH] Menus/Controls: confirm changes on go back (bypassing confirm button) --- src/menus/options-profiles-edit-controls.c | 32 +++++++++++++++++----- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/menus/options-profiles-edit-controls.c b/src/menus/options-profiles-edit-controls.c index 1968c5d96..5075852ab 100644 --- a/src/menus/options-profiles-edit-controls.c +++ b/src/menus/options-profiles-edit-controls.c @@ -193,19 +193,37 @@ static void M_ProfileControlSaveResponse(INT32 choice) { memcpy(&gamecontrol[belongsto], optionsmenu.tempcontrols, sizeof(gamecontroldefault)); } - - M_GoBack(0); } + else + { + // Revert changes + memcpy(optionsmenu.tempcontrols, optionsmenu.profile->controls, sizeof(gamecontroldefault)); + } + + M_GoBack(0); } void M_ProfileControlsConfirm(INT32 choice) { - (void)choice; + if (!memcmp(optionsmenu.profile->controls, optionsmenu.tempcontrols, sizeof(gamecontroldefault))) + { + M_GoBack(0); // no change + } + else if (choice == 0) + { + M_StartMessage( + "Profiles", + "You have unsaved changes to your controls.\n" + "Please confirm if you wish to save them.\n", + &M_ProfileControlSaveResponse, + MM_YESNO, + NULL, + NULL + ); + } + else + M_ProfileControlSaveResponse(MA_YES); - //M_StartMessage("Profiles", M_GetText("Exiting will save the control changes\nfor this Profile.\nIs this okay?\n"), &M_ProfileControlSaveResponse, MM_YESNO, NULL, NULL); - // TODO: Add a graphic for controls saving, instead of obnoxious prompt. - - M_ProfileControlSaveResponse(MA_YES); // Reapply player 1's real profile. if (cv_currprofile.value > -1)