X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=frontend%2Fcommon%2Fmenu.c;h=97e365d75379979101794f048e5642a944b2c8fd;hb=0b49a8f782ef178d5aa22f189e275cfbc43967f3;hp=1513d395eebb4c27055ef0980abe877fe5ebb56a;hpb=2924e5711a8279228df4c03bc0a970c349e55938;p=pcsx_rearmed.git diff --git a/frontend/common/menu.c b/frontend/common/menu.c index 1513d395..97e365d7 100644 --- a/frontend/common/menu.c +++ b/frontend/common/menu.c @@ -12,6 +12,8 @@ #include #include #include +#include +#include // savestate date #include "menu.h" #include "fonts.h" @@ -309,6 +311,9 @@ void menu_init(void) } fclose(f); } + + // use user's locale for savestate date display + setlocale(LC_TIME, ""); } static void menu_draw_begin(int need_bg) @@ -482,7 +487,7 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) for (ent = entries; ent->name; ent++) { const char **names; - int len; + int len, leftname_end = 0; if (!ent->enabled) continue; @@ -492,8 +497,10 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) if (ent->generate_name) name = ent->generate_name(ent->id, &offs); } - if (name != NULL) + if (name != NULL) { text_out16(x, y, name); + leftname_end = x + (strlen(name) + 1) * me_mfont_w; + } switch (ent->beh) { case MB_NONE: @@ -516,13 +523,15 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) break; case MB_OPT_ENUM: names = (const char **)ent->data; - offs = 0; for (i = 0; names[i] != NULL; i++) { + offs = x + col2_offs; len = strlen(names[i]); if (len > 10) - offs = 10 - len - 2; + offs += (10 - len - 2) * me_mfont_w; + if (offs < leftname_end) + offs = leftname_end; if (i == *(unsigned char *)ent->var) { - text_out16(x + col2_offs + offs * me_mfont_w, y, "%s", names[i]); + text_out16(offs, y, "%s", names[i]); break; } } @@ -961,7 +970,10 @@ rescan: // ------------ savestate loader ------------ +#define STATE_SLOT_COUNT 10 + static int state_slot_flags = 0; +static int state_slot_times[STATE_SLOT_COUNT]; static void state_check_slots(void) { @@ -969,8 +981,9 @@ static void state_check_slots(void) state_slot_flags = 0; - for (slot = 0; slot < 10; slot++) { - if (emu_check_save_file(slot)) + for (slot = 0; slot < STATE_SLOT_COUNT; slot++) { + state_slot_times[slot] = 0; + if (emu_check_save_file(slot, &state_slot_times[slot])) state_slot_flags |= 1 << slot; } } @@ -980,12 +993,13 @@ static void draw_savestate_bg(int slot); static void draw_savestate_menu(int menu_sel, int is_loading) { int i, x, y, w, h; + char time_buf[32]; if (state_slot_flags & (1 << menu_sel)) draw_savestate_bg(menu_sel); w = (13 + 2) * me_mfont_w; - h = (1+2+10+1) * me_mfont_h; + h = (1+2+STATE_SLOT_COUNT+1) * me_mfont_h; x = g_menuscreen_w / 2 - w / 2; if (x < 0) x = 0; y = g_menuscreen_h / 2 - h / 2; @@ -1000,12 +1014,23 @@ static void draw_savestate_menu(int menu_sel, int is_loading) text_out16(x, y, is_loading ? "Load state" : "Save state"); y += 3 * me_mfont_h; - menu_draw_selection(x - me_mfont_w * 2, y + menu_sel * me_mfont_h, (13 + 2) * me_mfont_w + 4); + menu_draw_selection(x - me_mfont_w * 2, y + menu_sel * me_mfont_h, (23 + 2) * me_mfont_w + 4); - /* draw all 10 slots */ - for (i = 0; i < 10; i++, y += me_mfont_h) + /* draw all slots */ + for (i = 0; i < STATE_SLOT_COUNT; i++, y += me_mfont_h) { - text_out16(x, y, "SLOT %i (%s)", i, (state_slot_flags & (1 << i)) ? "USED" : "free"); + if (!(state_slot_flags & (1 << i))) + strcpy(time_buf, "free"); + else { + strcpy(time_buf, "USED"); + if (state_slot_times[i] != 0) { + time_t time = state_slot_times[i]; + struct tm *t = localtime(&time); + strftime(time_buf, sizeof(time_buf), "%x %R", t); + } + } + + text_out16(x, y, "SLOT %i (%s)", i, time_buf); } text_out16(x, y, "back"); @@ -1014,8 +1039,8 @@ static void draw_savestate_menu(int menu_sel, int is_loading) static int menu_loop_savestate(int is_loading) { - static int menu_sel = 10; - int menu_sel_max = 10; + static int menu_sel = STATE_SLOT_COUNT; + int menu_sel_max = STATE_SLOT_COUNT; unsigned long inp = 0; int ret = 0; @@ -1043,7 +1068,7 @@ static int menu_loop_savestate(int is_loading) } while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading); } if (inp & PBTN_MOK) { // save/load - if (menu_sel < 10) { + if (menu_sel < STATE_SLOT_COUNT) { state_slot = menu_sel; if (emu_save_load_game(is_loading, 0)) { me_update_msg(is_loading ? "Load failed" : "Save failed");