return NULL;\r
}\r
\r
-int emu_check_save_file(int slot)\r
+int emu_check_save_file(int slot, int *time)\r
{\r
return emu_get_save_fname(1, 0, slot) ? 1 : 0;\r
}\r
if (which & (PEV_STATE_LOAD|PEV_STATE_SAVE))\r
{\r
int do_it = 1;\r
- if ( emu_check_save_file(state_slot) &&\r
+ if ( emu_check_save_file(state_slot, NULL) &&\r
(((which & PEV_STATE_LOAD) && (currentConfig.confirm_save & EOPT_CONFIRM_LOAD)) ||\r
((which & PEV_STATE_SAVE) && (currentConfig.confirm_save & EOPT_CONFIRM_SAVE))) )\r
{\r
}\r
\r
emu_status_msg("SAVE SLOT %i [%s]", state_slot,\r
- emu_check_save_file(state_slot) ? "USED" : "FREE");\r
+ emu_check_save_file(state_slot, NULL) ? "USED" : "FREE");\r
}\r
if (which & PEV_MENU)\r
engineState = PGS_Menu;\r
#include <string.h>\r
#include <stdlib.h>\r
#include <stdarg.h>\r
+#include <time.h>\r
+#include <locale.h> // savestate date\r
\r
#include "menu.h"\r
#include "fonts.h"\r
}\r
fclose(f);\r
}\r
+\r
+ // use user's locale for savestate date display\r
+ setlocale(LC_TIME, "");\r
}\r
\r
static void menu_draw_begin(int need_bg)\r
\r
// ------------ savestate loader ------------\r
\r
+#define STATE_SLOT_COUNT 10\r
+\r
static int state_slot_flags = 0;\r
+static int state_slot_times[STATE_SLOT_COUNT];\r
\r
static void state_check_slots(void)\r
{\r
\r
state_slot_flags = 0;\r
\r
- for (slot = 0; slot < 10; slot++) {\r
- if (emu_check_save_file(slot))\r
+ for (slot = 0; slot < STATE_SLOT_COUNT; slot++) {\r
+ state_slot_times[slot] = 0;\r
+ if (emu_check_save_file(slot, &state_slot_times[slot]))\r
state_slot_flags |= 1 << slot;\r
}\r
}\r
static void draw_savestate_menu(int menu_sel, int is_loading)\r
{\r
int i, x, y, w, h;\r
+ char time_buf[32];\r
\r
if (state_slot_flags & (1 << menu_sel))\r
draw_savestate_bg(menu_sel);\r
\r
w = (13 + 2) * me_mfont_w;\r
- h = (1+2+10+1) * me_mfont_h;\r
+ h = (1+2+STATE_SLOT_COUNT+1) * me_mfont_h;\r
x = g_menuscreen_w / 2 - w / 2;\r
if (x < 0) x = 0;\r
y = g_menuscreen_h / 2 - h / 2;\r
text_out16(x, y, is_loading ? "Load state" : "Save state");\r
y += 3 * me_mfont_h;\r
\r
- menu_draw_selection(x - me_mfont_w * 2, y + menu_sel * me_mfont_h, (13 + 2) * me_mfont_w + 4);\r
+ menu_draw_selection(x - me_mfont_w * 2, y + menu_sel * me_mfont_h, (23 + 2) * me_mfont_w + 4);\r
\r
- /* draw all 10 slots */\r
- for (i = 0; i < 10; i++, y += me_mfont_h)\r
+ /* draw all slots */\r
+ for (i = 0; i < STATE_SLOT_COUNT; i++, y += me_mfont_h)\r
{\r
- text_out16(x, y, "SLOT %i (%s)", i, (state_slot_flags & (1 << i)) ? "USED" : "free");\r
+ if (!(state_slot_flags & (1 << i)))\r
+ strcpy(time_buf, "free");\r
+ else {\r
+ strcpy(time_buf, "USED");\r
+ if (state_slot_times[i] != 0) {\r
+ time_t time = state_slot_times[i];\r
+ struct tm *t = localtime(&time);\r
+ strftime(time_buf, sizeof(time_buf), "%x %R", t);\r
+ }\r
+ }\r
+\r
+ text_out16(x, y, "SLOT %i (%s)", i, time_buf);\r
}\r
text_out16(x, y, "back");\r
\r
\r
static int menu_loop_savestate(int is_loading)\r
{\r
- static int menu_sel = 10;\r
- int menu_sel_max = 10;\r
+ static int menu_sel = STATE_SLOT_COUNT;\r
+ int menu_sel_max = STATE_SLOT_COUNT;\r
unsigned long inp = 0;\r
int ret = 0;\r
\r
} while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading);\r
}\r
if (inp & PBTN_MOK) { // save/load\r
- if (menu_sel < 10) {\r
+ if (menu_sel < STATE_SLOT_COUNT) {\r
state_slot = menu_sel;\r
if (emu_save_load_game(is_loading, 0)) {\r
me_update_msg(is_loading ? "Load failed" : "Save failed");\r