Skip to content

Commit 02ed5fa

Browse files
committed
ui: add notification for next/previous state slot
1 parent b31f92f commit 02ed5fa

File tree

3 files changed

+14
-25
lines changed

3 files changed

+14
-25
lines changed

core/input/gamepad_device.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ bool GamepadDevice::handleButtonInput(int port, DreamcastKey key, bool pressed)
104104
break;
105105
case EMU_BTN_NEXTSLOT:
106106
if (pressed)
107-
gui_cycleSaveStateSlotForward();
107+
gui_cycleSaveStateSlot(1);
108108
break;
109109
case EMU_BTN_PREVSLOT:
110110
if (pressed)
111-
gui_cycleSaveStateSlotBackward();
111+
gui_cycleSaveStateSlot(-1);
112112
break;
113113
case EMU_BTN_SCREENSHOT:
114114
if (pressed)

core/ui/gui.cpp

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,12 @@ static void savestate()
720720
savestatePic.invalidate();
721721
}
722722

723+
void cycleSaveStateSlot(int step)
724+
{
725+
config::SavestateSlot = (config::SavestateSlot + 10 + step) % 10;
726+
SaveSettings();
727+
}
728+
723729
static void gui_display_commands()
724730
{
725731
fullScreenWindow(false);
@@ -859,18 +865,14 @@ static void gui_display_commands()
859865

860866
// Slot #
861867
if (ImGui::ArrowButton("##prev-slot", ImGuiDir_Left))
862-
{
863-
gui_cycleSaveStateSlotBackward();
864-
}
868+
cycleSaveStateSlot(-1);
865869
std::string slot = strprintf(T("Slot %d"), (int)config::SavestateSlot + 1);
866870
float spacingW = (uiScaled(buttonWidth) - ImGui::GetFrameHeight() * 2 - ImGui::CalcTextSize(slot.c_str()).x) / 2;
867871
ImGui::SameLine(0, spacingW);
868872
ImGui::Text("%s", slot.c_str());
869873
ImGui::SameLine(0, spacingW);
870874
if (ImGui::ArrowButton("##next-slot", ImGuiDir_Right))
871-
{
872-
gui_cycleSaveStateSlotForward();
873-
}
875+
cycleSaveStateSlot(1);
874876
{
875877
ImVec4 gray(0.75f, 0.75f, 0.75f, 1.f);
876878
if (savestateDate == 0)
@@ -1769,22 +1771,10 @@ void gui_saveState(bool stopRestart)
17691771
}
17701772
}
17711773

1772-
void gui_cycleSaveStateSlotForward()
1774+
void gui_cycleSaveStateSlot(int step)
17731775
{
1774-
if (config::SavestateSlot == 9)
1775-
config::SavestateSlot = 0;
1776-
else
1777-
config::SavestateSlot++;
1778-
SaveSettings();
1779-
}
1780-
1781-
void gui_cycleSaveStateSlotBackward()
1782-
{
1783-
if (config::SavestateSlot == 0)
1784-
config::SavestateSlot = 9;
1785-
else
1786-
config::SavestateSlot--;
1787-
SaveSettings();
1776+
cycleSaveStateSlot(step);
1777+
os_notify(strprintf(T("Save state slot %d"), config::SavestateSlot + 1).c_str(), 2000);
17881778
}
17891779

17901780
void gui_setState(GuiState newState)

core/ui/gui.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ void gui_error(const std::string& what);
5050
void gui_setOnScreenKeyboardCallback(void (*callback)(bool show));
5151
void gui_loadState();
5252
void gui_saveState(bool stopRestart = true);
53-
void gui_cycleSaveStateSlotForward();
54-
void gui_cycleSaveStateSlotBackward();
53+
void gui_cycleSaveStateSlot(int step);
5554
std::string gui_getCurGameBoxartUrl();
5655
void gui_takeScreenshot();
5756
void gui_runOnUiThread(std::function<void()> function);

0 commit comments

Comments
 (0)