Skip to content

Commit e8e39b3

Browse files
committed
scroll animation in menu, stretched instead of streched, quick_save_file accessible as load file option
Signed-off-by: Vincent-FK <[email protected]>
1 parent 047d73a commit e8e39b3

File tree

2 files changed

+75
-26
lines changed

2 files changed

+75
-26
lines changed

src/drivers/menu.cpp

Lines changed: 74 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@
9292
#define SCREEN_HORIZONTAL_SIZE RES_HW_SCREEN_HORIZONTAL
9393
#define SCREEN_VERTICAL_SIZE RES_HW_SCREEN_VERTICAL
9494

95-
#define SCROLL_SPEED_PX 240 //This means no animations but also no tearing effect
96-
#define FPS_MENU 30
95+
#define SCROLL_SPEED_PX 30
96+
#define FPS_MENU 50
9797
#define ARROWS_PADDING 8
9898

9999
#define MENU_ZONE_WIDTH SCREEN_HORIZONTAL_SIZE
@@ -164,6 +164,7 @@ const char *resume_options_str[] = {RESUME_OPTIONS};
164164

165165
extern int SaveStateStatus[10];
166166
extern int CurrentState;
167+
static int quick_load_slot_chosen = 0;
167168

168169
/// -------------- FUNCTIONS DECLARATION --------------
169170

@@ -474,7 +475,7 @@ void init_menu_system_values(){
474475

475476
void menu_screen_refresh(int menuItem, int prevItem, int scroll, uint8_t menu_confirmation, uint8_t menu_action){
476477
/// --------- Vars ---------
477-
int print_arrows = 1;
478+
int print_arrows = (scroll==0)?1:0;
478479

479480
/// --------- Clear HW screen ----------
480481
if(SDL_BlitSurface(backup_hw_screen, NULL, draw_screen, NULL)){
@@ -570,7 +571,12 @@ void menu_screen_refresh(int menuItem, int prevItem, int scroll, uint8_t menu_co
570571

571572
case MENU_TYPE_LOAD:
572573
/// ---- Write slot -----
573-
sprintf(text_tmp, "FROM SLOT < %d >", CurrentState+1);
574+
if(quick_load_slot_chosen){
575+
sprintf(text_tmp, "FROM AUTO SAVE");
576+
}
577+
else{
578+
sprintf(text_tmp, "FROM SLOT < %d >", CurrentState+1);
579+
}
574580
text_surface = TTF_RenderText_Blended(menu_info_font, text_tmp, text_color);
575581
text_pos.x = (draw_screen->w - MENU_ZONE_WIDTH)/2 + (MENU_ZONE_WIDTH - text_surface->w)/2;
576582
text_pos.y = draw_screen->h - MENU_ZONE_HEIGHT/2 - text_surface->h/2;
@@ -586,21 +592,25 @@ void menu_screen_refresh(int menuItem, int prevItem, int scroll, uint8_t menu_co
586592
text_surface = TTF_RenderText_Blended(menu_info_font, text_tmp, text_color);
587593
}
588594
else{
589-
/// ---- Get current Load state ----
590-
if(SaveStateStatus[CurrentState])
591-
{
592-
///home/vincent/.mednafen/mcs/Super Mario Bros 3.b76f978ad3076ea67f2b0aca7399c9e9.mc0
593-
strcpy(fname, MDFN_MakeFName(MDFNMKF_STATE, CurrentState, NULL).c_str());
594-
printf("Found Load slot: %s\n", fname);
595-
char *p = strrchr (fname, '/');
596-
char *basename = p ? p + 1 : (char *) fname;
597-
p = strchr (basename, '.'); *p = p ? 0 : *p;
598-
if(strlen(basename) > limit_filename_size){basename[limit_filename_size]=0;} //limiting size
599-
sprintf(text_tmp, "%s - %d", basename, CurrentState);
600-
text_surface = TTF_RenderText_Blended(menu_small_info_font, text_tmp, text_color);
595+
if(quick_load_slot_chosen){
596+
text_surface = TTF_RenderText_Blended(menu_info_font, " ", text_color);
601597
}
602598
else{
603-
text_surface = TTF_RenderText_Blended(menu_info_font, "Free", text_color);
599+
/// ---- Get current Load state ----
600+
if(SaveStateStatus[CurrentState])
601+
{
602+
strcpy(fname, MDFN_MakeFName(MDFNMKF_STATE, CurrentState, NULL).c_str());
603+
printf("Found Load slot: %s\n", fname);
604+
char *p = strrchr (fname, '/');
605+
char *basename = p ? p + 1 : (char *) fname;
606+
p = strchr (basename, '.'); *p = p ? 0 : *p;
607+
if(strlen(basename) > limit_filename_size){basename[limit_filename_size]=0;} //limiting size
608+
sprintf(text_tmp, "%s - %d", basename, CurrentState);
609+
text_surface = TTF_RenderText_Blended(menu_small_info_font, text_tmp, text_color);
610+
}
611+
else{
612+
text_surface = TTF_RenderText_Blended(menu_info_font, "Free", text_color);
613+
}
604614
}
605615
}
606616
}
@@ -796,9 +806,22 @@ void run_menu_loop()
796806
}
797807
else if(idx_menus[menuItem] == MENU_TYPE_LOAD){
798808
MENU_DEBUG_PRINTF("Load Slot DOWN\n");
799-
//idx_load_slot = (!idx_load_slot)?(MAX_SAVE_SLOTS-1):(idx_load_slot-1);
800-
CurrentState = (!CurrentState)?(MAX_SAVE_SLOTS-1):(CurrentState-1);
801-
MDFNI_SelectState(CurrentState);
809+
810+
/** Choose quick save file or standard saveslot for loading */
811+
if(!quick_load_slot_chosen &&
812+
CurrentState == 0 &&
813+
access(quick_save_file, F_OK ) != -1){
814+
quick_load_slot_chosen = 1;
815+
}
816+
else if(quick_load_slot_chosen){
817+
quick_load_slot_chosen = 0;
818+
CurrentState = MAX_SAVE_SLOTS-1;
819+
MDFNI_SelectState(CurrentState);
820+
}
821+
else{
822+
CurrentState = (!CurrentState)?(MAX_SAVE_SLOTS-1):(CurrentState-1);
823+
MDFNI_SelectState(CurrentState);
824+
}
802825

803826
/// ------ Refresh screen ------
804827
screen_refresh = 1;
@@ -852,8 +875,23 @@ void run_menu_loop()
852875
}
853876
else if(idx_menus[menuItem] == MENU_TYPE_LOAD){
854877
MENU_DEBUG_PRINTF("Load Slot UP\n");
855-
//idx_load_slot = (idx_load_slot+1)%MAX_SAVE_SLOTS;
856-
CurrentState = (CurrentState+1)%MAX_SAVE_SLOTS;
878+
879+
/** Choose quick save file or standard saveslot for loading */
880+
if(!quick_load_slot_chosen &&
881+
CurrentState == MAX_SAVE_SLOTS-1 &&
882+
access(quick_save_file, F_OK ) != -1){
883+
quick_load_slot_chosen = 1;
884+
}
885+
else if(quick_load_slot_chosen){
886+
quick_load_slot_chosen = 0;
887+
CurrentState = 0;
888+
MDFNI_SelectState(CurrentState);
889+
}
890+
else{
891+
CurrentState = (CurrentState+1)%MAX_SAVE_SLOTS;
892+
MDFNI_SelectState(CurrentState);
893+
}
894+
857895
/// ------ Refresh screen ------
858896
screen_refresh = 1;
859897
}
@@ -900,11 +938,22 @@ void run_menu_loop()
900938
menu_screen_refresh(menuItem, prevItem, scroll, menu_confirmation, 1);
901939

902940
/// ------ Load game ------
903-
MDFNI_LoadState(NULL, NULL);
941+
if(quick_load_slot_chosen){
942+
MDFNI_LoadState(quick_save_file, NULL);
943+
}
944+
else{
945+
MDFNI_LoadState(NULL, NULL);
946+
}
904947

905948
/// ----- Hud Msg -----
906-
sprintf(shell_cmd, "%s %d \" LOADED FROM SLOT %d\"",
907-
SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP, CurrentState+1);
949+
if(quick_load_slot_chosen){
950+
sprintf(shell_cmd, "%s %d \" LOADED FROM AUTO SAVE\"",
951+
SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP);
952+
}
953+
else{
954+
sprintf(shell_cmd, "%s %d \" LOADED FROM SLOT %d\"",
955+
SHELL_CMD_NOTIF, NOTIF_SECONDS_DISP, CurrentState+1);
956+
}
908957
fp = popen(shell_cmd, "r");
909958
if (fp == NULL) {
910959
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);

src/drivers/menu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ typedef enum{
2929
///------ Definition of the different aspect ratios
3030
#define ASPECT_RATIOS \
3131
X(ASPECT_RATIOS_TYPE_MANUAL, "MANUAL ZOOM") \
32-
X(ASPECT_RATIOS_TYPE_STRECHED, "STRECHED") \
32+
X(ASPECT_RATIOS_TYPE_STRETCHED, "STRETCHED") \
3333
X(ASPECT_RATIOS_TYPE_CROPPED, "CROPPED") \
3434
X(ASPECT_RATIOS_TYPE_SCALED, "SCALED") \
3535
X(NB_ASPECT_RATIOS_TYPES, "")

0 commit comments

Comments
 (0)