Skip to content

Commit

Permalink
Qt: Add save slot status info.
Browse files Browse the repository at this point in the history
  • Loading branch information
bearoso committed May 7, 2024
1 parent c476e4a commit add607c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
21 changes: 10 additions & 11 deletions qt/src/EmuApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,22 +335,21 @@ void EmuApplication::handleBinding(std::string name, bool pressed)
window->pauseContinue();
}

else if (name == "IncreaseSlot")
else if (name == "IncreaseSlot" || name == "DecreaseSlot")
{
save_slot++;
if (name == "IncreaseSlot")
save_slot++;
else
save_slot--;

if (save_slot > 999)
save_slot = 0;
emu_thread->runOnThread([&] {
core->setMessage("Current slot: " + std::to_string(save_slot));
});
}
else if (name == "DecreaseSlot")
{
save_slot--;
if (save_slot < 0)
save_slot = 999;
emu_thread->runOnThread([&] {
core->setMessage("Current slot: " + std::to_string(save_slot));

emu_thread->runOnThread([&, slot = this->save_slot] {
std::string status = core->slotUsed(slot) ? " [used]" : " [empty]";
core->setMessage("Current slot: " + std::to_string(save_slot) + status);
});
}
else if (name == "SaveState")
Expand Down
5 changes: 5 additions & 0 deletions qt/src/Snes9xController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,11 @@ std::string Snes9xController::getStateFolder()
return S9xGetDirectory(SNAPSHOT_DIR);
}

bool Snes9xController::slotUsed(int slot)
{
return fs::exists(save_slot_path(slot));
}

bool Snes9xController::loadState(int slot)
{
return loadState(save_slot_path(slot).u8string());
Expand Down
3 changes: 1 addition & 2 deletions qt/src/Snes9xController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ class Snes9xController
void deinit();
void mainLoop();
bool openFile(std::string filename);
bool slotUsed(int slot);
bool loadState(std::string filename);
bool loadState(int slot);
void loadUndoState();
bool saveState(std::string filename);
bool saveState(int slot);
void increaseSaveSlot();
void decreaseSaveSlot();
void updateSettings(const EmuConfig * const config);
void updateBindings(const EmuConfig * const config);
void reportBinding(EmuBinding b, bool active);
Expand Down

0 comments on commit add607c

Please sign in to comment.