gui: Visually indicate the current savestate slot in the load/save menu

This commit is contained in:
Tyler Wilding 2021-03-18 00:40:51 -04:00 committed by lightningterror
parent 9a435c1a7e
commit 0dffc13e49
4 changed files with 13 additions and 8 deletions

View File

@ -43,7 +43,8 @@ wxMenu* MainEmuFrame::MakeStatesSubMenu(int baseid, int loadBackupId) const
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
// Will be changed once an iso is loaded. // Will be changed once an iso is loaded.
mnuSubstates->Append(baseid + i + 1, wxsFormat(_("Slot %d"), i)); wxMenuItem* m = mnuSubstates->Append(baseid + i + 1, wxsFormat(_("Slot %d"), i), wxEmptyString, wxITEM_CHECK);
m->Check(i == 0); // 0 is the default selected slot
} }
if (loadBackupId >= 0) if (loadBackupId >= 0)

View File

@ -139,20 +139,23 @@ int States_GetCurrentSlot()
return StatesC; return StatesC;
} }
void States_SetCurrentSlot(int slot) void States_SetCurrentSlot(int slot_num)
{ {
StatesC = std::min(std::max(slot, 0), StateSlotsCount); StatesC = std::min(std::max(slot_num, 0), StateSlotsCount);
for (Saveslot& slot : saveslot_cache)
{
sMainFrame.CheckMenuItem(slot.load_item_id, slot.slot_num == slot_num);
sMainFrame.CheckMenuItem(slot.save_item_id, slot.slot_num == slot_num);
}
OnSlotChanged(); OnSlotChanged();
} }
void States_CycleSlotForward() void States_CycleSlotForward()
{ {
StatesC = (StatesC + 1) % StateSlotsCount; States_SetCurrentSlot((StatesC + 1) % StateSlotsCount);
OnSlotChanged();
} }
void States_CycleSlotBackward() void States_CycleSlotBackward()
{ {
StatesC = (StatesC + StateSlotsCount - 1) % StateSlotsCount; States_SetCurrentSlot((StatesC + StateSlotsCount - 1) % StateSlotsCount);
OnSlotChanged();
} }

View File

@ -132,6 +132,6 @@ extern void States_DefrostCurrentSlot();
extern void States_FreezeCurrentSlot(); extern void States_FreezeCurrentSlot();
extern void States_CycleSlotForward(); extern void States_CycleSlotForward();
extern void States_CycleSlotBackward(); extern void States_CycleSlotBackward();
extern void States_SetCurrentSlot(int slot); extern void States_SetCurrentSlot(int slot_num);
extern int States_GetCurrentSlot(); extern int States_GetCurrentSlot();
extern void States_updateLoadBackupMenuItem(); extern void States_updateLoadBackupMenuItem();

View File

@ -86,6 +86,7 @@ static void _SaveLoadStuff(bool enabled)
slot.crc = ElfCRC; slot.crc = ElfCRC;
sMainFrame.EnableMenuItem(slot.load_item_id, !slot.empty); sMainFrame.EnableMenuItem(slot.load_item_id, !slot.empty);
sMainFrame.CheckMenuItem(slot.load_item_id, slot.slot_num == States_GetCurrentSlot());
sMainFrame.SetMenuItemLabel(slot.load_item_id, slot.SlotName()); sMainFrame.SetMenuItemLabel(slot.load_item_id, slot.SlotName());
sMainFrame.SetMenuItemLabel(slot.save_item_id, slot.SlotName()); sMainFrame.SetMenuItemLabel(slot.save_item_id, slot.SlotName());
} }