Skip to content

Commit

Permalink
Gtk: Show existence of save state on slot select.
Browse files Browse the repository at this point in the history
  • Loading branch information
bearoso committed May 7, 2024
1 parent bac6798 commit c476e4a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion gtk/src/gtk_control.cpp
Expand Up @@ -5,8 +5,10 @@
\*****************************************************************************/

#include <fcntl.h>
#include <filesystem>

#include "SDL_joystick.h"
#include "fscompat.h"
#include "gtk_s9x.h"
#include "gtk_config.h"
#include "gtk_control.h"
Expand Down Expand Up @@ -195,7 +197,15 @@ static void change_slot(int difference)
if (!gui_config->rom_loaded)
return;

auto info_string = "State Slot: " + std::to_string(gui_config->current_save_slot);
char extension_string[5];
snprintf(extension_string, 5, ".%03d", gui_config->current_save_slot);
auto filename = S9xGetFilename(extension_string, SNAPSHOT_DIR);
struct stat info;
std::string exists = "empty";
if (stat(filename.c_str(), &info) == 0)
exists = "used";

auto info_string = "State Slot: " + std::to_string(gui_config->current_save_slot) + " [" + exists + "]";
S9xSetInfoString(info_string.c_str());
GFX.InfoStringTimeout = 60;
}
Expand Down

0 comments on commit c476e4a

Please sign in to comment.