Qt: Add save slot status info.

This commit is contained in:
BearOso 2024-05-07 14:27:28 -05:00
parent c476e4acdc
commit add607c38f
3 changed files with 16 additions and 13 deletions

View File

@ -335,22 +335,21 @@ void EmuApplication::handleBinding(std::string name, bool pressed)
window->pauseContinue(); 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) if (save_slot > 999)
save_slot = 0; 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) if (save_slot < 0)
save_slot = 999; 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") else if (name == "SaveState")

View File

@ -718,6 +718,11 @@ std::string Snes9xController::getStateFolder()
return S9xGetDirectory(SNAPSHOT_DIR); return S9xGetDirectory(SNAPSHOT_DIR);
} }
bool Snes9xController::slotUsed(int slot)
{
return fs::exists(save_slot_path(slot));
}
bool Snes9xController::loadState(int slot) bool Snes9xController::loadState(int slot)
{ {
return loadState(save_slot_path(slot).u8string()); return loadState(save_slot_path(slot).u8string());

View File

@ -16,13 +16,12 @@ class Snes9xController
void deinit(); void deinit();
void mainLoop(); void mainLoop();
bool openFile(std::string filename); bool openFile(std::string filename);
bool slotUsed(int slot);
bool loadState(std::string filename); bool loadState(std::string filename);
bool loadState(int slot); bool loadState(int slot);
void loadUndoState(); void loadUndoState();
bool saveState(std::string filename); bool saveState(std::string filename);
bool saveState(int slot); bool saveState(int slot);
void increaseSaveSlot();
void decreaseSaveSlot();
void updateSettings(const EmuConfig * const config); void updateSettings(const EmuConfig * const config);
void updateBindings(const EmuConfig * const config); void updateBindings(const EmuConfig * const config);
void reportBinding(EmuBinding b, bool active); void reportBinding(EmuBinding b, bool active);