From ed0b8c39112fce9cbe52763bf665abdc38f402ce Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Wed, 9 Sep 2026 21:38:28 -0500 Subject: [PATCH] Exit delete mode on save select after delete or back button Previously deleting a save left the panel in delete mode, and pressing back while in delete mode closed the whole save-select screen instead of just returning to the normal load view. Co-Authored-By: Claude Sonnet 5 --- src/dusk/ui/dialog/save/uiselectsave.c | 53 +++++++++++++++----------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/src/dusk/ui/dialog/save/uiselectsave.c b/src/dusk/ui/dialog/save/uiselectsave.c index fc8bbc9b..af37389f 100644 --- a/src/dusk/ui/dialog/save/uiselectsave.c +++ b/src/dusk/ui/dialog/save/uiselectsave.c @@ -60,6 +60,31 @@ void uiSelectSaveRefreshSlot(const uint8_t index) { uiSaveSlotSetDisplayType(&UI_SELECT_SAVE.slots[index], displayType); } +void uiSelectSaveSetActionLabel(const uiselectsavetype_t type) { + const char_t *labelKey = type == UI_SELECT_SAVE_TYPE_LOAD ? + "ui.select_save.delete_mode" : "ui.confirm.cancel"; + + errorret_t result = localeManagerGetString( + labelKey, UI_SELECT_SAVE.actionText, UI_SELECT_SAVE_ACTION_LABEL_MAX, 0 + ); + if(errorIsNotOk(result)) errorCatch(result); + + UI_SELECT_SAVE.slotItems[UI_SELECT_SAVE_ACTION_INDEX].button.label.dirty = + true; +} + +void uiSelectSaveSwitchType(const uiselectsavetype_t type) { + UI_SELECT_SAVE.type = type; + + uisaveslotdisplaytype_t displayType = type == UI_SELECT_SAVE_TYPE_DELETE ? + UI_SAVE_SLOT_DISPLAY_TYPE_DELETE : UI_SAVE_SLOT_DISPLAY_TYPE_NORMAL; + for(uint8_t i = 0; i < SAVE_SLOT_COUNT; i++) { + uiSaveSlotSetDisplayType(&UI_SELECT_SAVE.slots[i], displayType); + } + + uiSelectSaveSetActionLabel(type); +} + void uiSelectSaveDeleteConfirmed(const bool_t result, void *user) { if(!result) return; @@ -79,6 +104,7 @@ void uiSelectSaveDeleteConfirmed(const bool_t result, void *user) { SAVE.caches[index] = slot.cachedData; + uiSelectSaveSwitchType(UI_SELECT_SAVE_TYPE_LOAD); uiSelectSaveRefreshSlot(index); uiSaveSlotSetHighlighted(&UI_SELECT_SAVE.slots[index], true); } @@ -144,29 +170,11 @@ void uiSelectSaveNameEmptySlot(const uint8_t index) { uiKeyboardOpen(&open); } -void uiSelectSaveSetActionLabel(const uiselectsavetype_t type) { - const char_t *labelKey = type == UI_SELECT_SAVE_TYPE_LOAD ? - "ui.select_save.delete_mode" : "ui.confirm.cancel"; +bool_t uiSelectSaveMenuCancelled(const uimenu_t *menu) { + if(UI_SELECT_SAVE.type != UI_SELECT_SAVE_TYPE_DELETE) return false; - errorret_t result = localeManagerGetString( - labelKey, UI_SELECT_SAVE.actionText, UI_SELECT_SAVE_ACTION_LABEL_MAX, 0 - ); - if(errorIsNotOk(result)) errorCatch(result); - - UI_SELECT_SAVE.slotItems[UI_SELECT_SAVE_ACTION_INDEX].button.label.dirty = - true; -} - -void uiSelectSaveSwitchType(const uiselectsavetype_t type) { - UI_SELECT_SAVE.type = type; - - uisaveslotdisplaytype_t displayType = type == UI_SELECT_SAVE_TYPE_DELETE ? - UI_SAVE_SLOT_DISPLAY_TYPE_DELETE : UI_SAVE_SLOT_DISPLAY_TYPE_NORMAL; - for(uint8_t i = 0; i < SAVE_SLOT_COUNT; i++) { - uiSaveSlotSetDisplayType(&UI_SELECT_SAVE.slots[i], displayType); - } - - uiSelectSaveSetActionLabel(type); + uiSelectSaveSwitchType(UI_SELECT_SAVE_TYPE_LOAD); + return true; } void uiSelectSaveSlotSelected( @@ -244,6 +252,7 @@ errorret_t uiSelectSaveInit(void) { &UI_SELECT_SAVE.slotMenu, uiSelectSaveSlotSelected, uiSelectSaveSlotClosed, uiSelectSaveSlotChanged ); + uiMenuSetCancelCallback(&UI_SELECT_SAVE.slotMenu, uiSelectSaveMenuCancelled); uiMenuSetItems( &UI_SELECT_SAVE.slotMenu, UI_SELECT_SAVE.slotItems, SAVE_SLOT_COUNT, 1 );