@@ -5077,12 +5077,14 @@ static struct {
50775077 int slot ;
50785078 int save_exists ;
50795079 int preview_exists ;
5080+ time_t save_mtime ;
50805081} menu = {
50815082 .bitmap = NULL ,
50825083 .disc = -1 ,
50835084 .total_discs = 0 ,
50845085 .save_exists = 0 ,
50855086 .preview_exists = 0 ,
5087+ .save_mtime = 0 ,
50865088
50875089 .items = {
50885090 [ITEM_CONT ] = "Continue" ,
@@ -6558,6 +6560,7 @@ static void Menu_initState(void) {
65586560
65596561 menu .save_exists = 0 ;
65606562 menu .preview_exists = 0 ;
6563+ menu .save_mtime = 0 ;
65616564}
65626565static void Menu_updateState (void ) {
65636566 // LOG_info("Menu_updateState\n");
@@ -6576,11 +6579,26 @@ static void Menu_updateState(void) {
65766579
65776580 menu .save_exists = exists (save_path );
65786581 menu .preview_exists = menu .save_exists && exists (menu .bmp_path );
6582+ menu .save_mtime = 0 ;
6583+ if (menu .save_exists ) {
6584+ time_t mtime = 0 ;
6585+ if (getFileMTime (save_path , & mtime )) {
6586+ menu .save_mtime = mtime ;
6587+ }
6588+ }
65796589
65806590 // LOG_info("save_path: %s (%i)\n", save_path, menu.save_exists);
65816591 // LOG_info("bmp_path: %s txt_path: %s (%i)\n", menu.bmp_path, menu.txt_path, menu.preview_exists);
65826592}
65836593
6594+ static int Menu_formatSaveTime (char * out , size_t out_size , time_t when ) {
6595+ if (!out || out_size == 0 || when == 0 ) return 0 ;
6596+ struct tm tm = * localtime (& when );
6597+ if (CFG_getClock24H ())
6598+ return strftime (out , out_size , "%Y-%m-%d %H:%M" , & tm ) > 0 ;
6599+ return strftime (out , out_size , "%Y-%m-%d %-I:%M %p" , & tm ) > 0 ;
6600+ }
6601+
65846602typedef struct {
65856603 char * pixels ;
65866604 char * path ;
@@ -6999,6 +7017,31 @@ static void Menu_loop(void) {
69997017 else GFX_blitMessage (font .large , "Empty Slot" , screen , & preview_rect );
70007018 }
70017019
7020+ // save time overlay
7021+ if (menu .save_exists && menu .save_mtime ) {
7022+ char save_time [32 ];
7023+ if (Menu_formatSaveTime (save_time , sizeof (save_time ), menu .save_mtime )) {
7024+ int tw = 0 ;
7025+ int th = 0 ;
7026+ TTF_SizeUTF8 (font .tiny , save_time , & tw , & th );
7027+ int pad_x = SCALE1 (6 );
7028+ int pad_y = SCALE1 (4 );
7029+ int pill_h = SCALE1 (PILL_SIZE );
7030+ int pill_w = tw + pad_x * 2 ;
7031+ if (pill_w < pill_h ) pill_w = pill_h ;
7032+ int tx = ox + SCALE1 (6 );
7033+ int ty = oy + hh - pill_h - SCALE1 (6 );
7034+ GFX_blitPillLight (ASSET_WHITE_PILL , screen , & (SDL_Rect ){tx , ty , pill_w , pill_h });
7035+ SDL_Surface * time_text = TTF_RenderUTF8_Blended (font .tiny , save_time , uintToColour (THEME_COLOR1_255 ));
7036+ if (time_text ) {
7037+ SDL_BlitSurface (time_text , NULL , screen , & (SDL_Rect ){
7038+ tx + (pill_w - time_text -> w ) / 2 ,
7039+ ty + (pill_h - time_text -> h ) / 2
7040+ });
7041+ SDL_FreeSurface (time_text );
7042+ }
7043+ }
7044+ }
70027045 // pagination
70037046 ox += (pw - SCALE1 (15 * MENU_SLOT_COUNT ))/2 ;
70047047 oy += hh + SCALE1 (WINDOW_RADIUS );
0 commit comments