Last selected file remebered

This commit is contained in:
fabio.olimpieri 2015-03-28 07:49:44 +00:00
parent f496d9f1b7
commit 447444479e
4 changed files with 61 additions and 31 deletions

View File

@ -207,7 +207,7 @@ struct computer {
unsigned char tape_write; // 0 can't write; 1 can write unsigned char tape_write; // 0 can't write; 1 can write
//Recording Variable //RZX variables
unsigned char recording_rzx; unsigned char recording_rzx;
unsigned char playing_rzx; unsigned char playing_rzx;
unsigned short int maxicount; unsigned short int maxicount;

View File

@ -56,6 +56,16 @@ extern FILE *fdebug;
#define MAX_POKE 20 #define MAX_POKE 20
#define MAX_TRAINER 50 #define MAX_TRAINER 50
int last_sel_tap=0;
int last_sel_snap=0;
int last_sel_rzx=0;
int last_sel_paste=0;
int last_sel_del=0;
int last_sel_poke=0;
int last_sel_mdr=0;
int last_sel_conf=0;
int last_sel_scr=0;
extern int last_sel_menu;
extern int countdown_buffer; extern int countdown_buffer;
extern unsigned int beeper; extern unsigned int beeper;
@ -338,10 +348,12 @@ static void insert_tape()
unsigned char char_id[11]; unsigned char char_id[11];
int retorno, retval; int retorno, retval;
const char *filename = menu_select_file(load_path_taps, ordenador.current_tap, 1); const char *filename = menu_select_file(load_path_taps, ordenador.current_tap, 1, last_sel_tap);
last_sel_tap=last_sel_menu;
if (filename==NULL) // Aborted if (filename==NULL) // Aborted
return; return;
if (strstr(filename, "None") != NULL) if (strstr(filename, "None") != NULL)
{ {
@ -405,7 +417,7 @@ static void insert_tape()
static void delete_tape() static void delete_tape()
{ {
const char *filename = menu_select_file(load_path_taps, NULL, 1); const char *filename = menu_select_file(load_path_taps, NULL, 1, 0);
if (filename==NULL) // Aborted if (filename==NULL) // Aborted
return; return;
@ -944,8 +956,10 @@ static int select_mdr()
retorno2=0; //stay in menu as default retorno2=0; //stay in menu as default
const char *filename = menu_select_file(path_mdrs, ordenador.mdr_current_mdr, 0); const char *filename = menu_select_file(path_mdrs, ordenador.mdr_current_mdr, 0, last_sel_mdr);
last_sel_mdr=last_sel_menu;
if (filename==NULL) // Aborted if (filename==NULL) // Aborted
return 0; return 0;
@ -988,7 +1002,7 @@ static int select_mdr()
static void delete_mdr() static void delete_mdr()
{ {
const char *filename = menu_select_file(path_mdrs, NULL, 0); const char *filename = menu_select_file(path_mdrs, NULL, 0, 0);
if (filename==NULL) // Aborted if (filename==NULL) // Aborted
return; return;
@ -1234,7 +1248,7 @@ static int microdrive()
static void delete_scr() static void delete_scr()
{ {
const char *filename = menu_select_file(load_path_scr1, NULL, 0); //Delete in the load dir const char *filename = menu_select_file(load_path_scr1, NULL, 0, 0); //Delete in the load dir
if (filename==NULL) // Aborted if (filename==NULL) // Aborted
return; return;
@ -1254,8 +1268,10 @@ static int load_scr()
retorno2=0; //stay in the menu as default retorno2=0; //stay in the menu as default
const char *filename = menu_select_file(load_path_scr1, NULL, 1); // Load from SCR1 const char *filename = menu_select_file(load_path_scr1, NULL, 1, last_sel_scr); // Load from SCR1
last_sel_scr=last_sel_menu;
if (filename==NULL) // Aborted if (filename==NULL) // Aborted
return 0; return 0;
@ -1710,8 +1726,10 @@ static int load_poke_file()
ritorno=0; ritorno=0;
retorno2=0; //Stay in menu as default retorno2=0; //Stay in menu as default
const char *filename = menu_select_file(dir, NULL,0); const char *filename = menu_select_file(dir, NULL,0, last_sel_poke);
last_sel_poke=last_sel_menu;
if (!filename) return 0; if (!filename) return 0;
if (ext_matches(filename, ".pok")|ext_matches(filename, ".POK")) if (ext_matches(filename, ".pok")|ext_matches(filename, ".POK"))
@ -1777,8 +1795,10 @@ switch (which)
static void delete_file() static void delete_file()
{ {
const char *filename = menu_select_file(path_delete, NULL, 0); const char *filename = menu_select_file(path_delete, NULL, 0, last_sel_del);
last_sel_del=last_sel_menu;
if (filename==NULL) // Aborted if (filename==NULL) // Aborted
return; return;
@ -1789,7 +1809,9 @@ static void delete_file()
static void paste_file() static void paste_file()
{ {
const char *filename = menu_select_file(path_paste, NULL, 0); const char *filename = menu_select_file(path_paste, NULL, 0, last_sel_paste);
last_sel_paste=last_sel_menu;
if (filename==NULL) // Aborted if (filename==NULL) // Aborted
return; return;
@ -1814,8 +1836,8 @@ static void copy_file()
msgInfo("Select \"None\" in the dir", 2000,NULL) ; msgInfo("Select \"None\" in the dir", 2000,NULL) ;
const char *filename = menu_select_file(path_copy, pasted_file, 0); const char *filename = menu_select_file(path_copy, pasted_file, 0, 0);
if (filename==NULL) // Aborted if (filename==NULL) // Aborted
return; return;
@ -1882,7 +1904,9 @@ static int load_rzx(int edit)
{ {
int retorno; int retorno;
const char *filename = menu_select_file(load_path_rzx, NULL, 1); // Load from rzx dir const char *filename = menu_select_file(load_path_rzx, NULL, 1, last_sel_rzx); // Load from rzx dir
last_sel_rzx=last_sel_menu;
if (filename==NULL) // Aborted if (filename==NULL) // Aborted
return -1; return -1;
@ -2174,11 +2198,13 @@ static int save_load_snapshot(int which)
case 2: case 2:
case 0: // Load or delete file case 0: // Load or delete file
{ {
const char *filename = menu_select_file(dir_load, NULL,1); const char *filename = menu_select_file(dir_load, NULL,1, last_sel_snap);
last_sel_snap=last_sel_menu;
if (!filename) if (!filename)
return 0; return 0;
//Load ROM Cartridge //Load ROM Cartridge
if ((ext_matches(filename, ".rom")|ext_matches(filename, ".ROM"))&(which == 0)) if ((ext_matches(filename, ".rom")|ext_matches(filename, ".ROM"))&(which == 0))
{ {
@ -2262,8 +2288,10 @@ static int save_load_game_configurations(int which)
case 2: case 2:
case 0: // Load or delete file case 0: // Load or delete file
{ {
const char *filename = menu_select_file(dir, NULL,0); const char *filename = menu_select_file(dir, NULL,0, last_sel_conf);
last_sel_conf=last_sel_menu;
if (!filename) if (!filename)
return 0; return 0;

View File

@ -102,7 +102,7 @@ static SDL_Surface *real_screen;
static int is_inited = 0; static int is_inited = 0;
static TTF_Font *menu_font_alt_large, *menu_font_large, *menu_font_alt_small, *menu_font_small; static TTF_Font *menu_font_alt_large, *menu_font_large, *menu_font_alt_small, *menu_font_small;
int fh, fw; int fh, fw, last_sel_menu;
static int *click_buffer_pointer[3]; static int *click_buffer_pointer[3];
static int len_click_buffer[3]; static int len_click_buffer[3];
@ -987,6 +987,8 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_typ
} }
} }
last_sel_menu = p_menu->cur_sel;
if ((draw_scr)&&(RATIO==1)&&ordenador.show_preview) //Only in 640 mode if ((draw_scr)&&(RATIO==1)&&ordenador.show_preview) //Only in 640 mode
{ {
r.x = 367; r.x = 367;
@ -1601,7 +1603,7 @@ const char **get_file_list_select_block()
} }
static const char *menu_select_file_internal(char *dir_path, static const char *menu_select_file_internal(char *dir_path,
int x, int y, int x2, int y2, const char *selected_file, int draw_scr, unsigned int tape_pos) int x, int y, int x2, int y2, const char *selected_file, int draw_scr, unsigned int tape_pos, int sel_pos)
{ {
const char **file_list; const char **file_list;
char *sel; char *sel;
@ -1633,9 +1635,9 @@ static const char *menu_select_file_internal(char *dir_path,
if (ptr_selected_file) ptr_selected_file++; if (ptr_selected_file) ptr_selected_file++;
else ptr_selected_file = selected_file; else ptr_selected_file = selected_file;
snprintf(buf,80,"Selected file:%s",ptr_selected_file); snprintf(buf,80,"Selected file:%s",ptr_selected_file);
opt = menu_select_sized(buf, file_list, NULL, 0, x, y, x2, y2, NULL, NULL, FONT_ALT, draw_scr); opt = menu_select_sized(buf, file_list, NULL, sel_pos, x, y, x2, y2, NULL, NULL, FONT_ALT, draw_scr);
} }
else opt = menu_select_sized("Select file", file_list, NULL, 0, x, y, x2, y2, NULL, NULL ,FONT_ALT, draw_scr); else opt = menu_select_sized("Select file", file_list, NULL, sel_pos, x, y, x2, y2, NULL, NULL ,FONT_ALT, draw_scr);
sel = NULL; sel = NULL;
@ -1664,7 +1666,7 @@ static const char *menu_select_file_internal(char *dir_path,
if (strrchr(dir_path,'/')==NULL) {*updir='/'; *(updir+1)=0;} //check if it was root if (strrchr(dir_path,'/')==NULL) {*updir='/'; *(updir+1)=0;} //check if it was root
} }
return menu_select_file(dir_path, selected_file, draw_scr); return menu_select_file(dir_path, selected_file, draw_scr, 0);
} }
/* If this is a folder, enter it recursively */ /* If this is a folder, enter it recursively */
if (sel[0] == '[') if (sel[0] == '[')
@ -1687,7 +1689,7 @@ static const char *menu_select_file_internal(char *dir_path,
/* We don't need this anymore */ /* We don't need this anymore */
free((void*)sel); free((void*)sel);
return menu_select_file(dir_path, selected_file, draw_scr); return menu_select_file(dir_path, selected_file, draw_scr, 0);
} }
@ -1704,38 +1706,38 @@ static const char *menu_select_file_internal(char *dir_path,
if(!strcmp(out_zip,"[..]")) if(!strcmp(out_zip,"[..]"))
{ {
free(out_zip); free(out_zip);
return menu_select_file_internal (dir_path, x, y, x2, y2, selected_file, draw_scr, 0); return menu_select_file_internal (dir_path, x, y, x2, y2, selected_file, draw_scr, 0, 0);
} }
else return out_zip; else return out_zip;
} }
else return out; else return out;
} }
const char *menu_select_file(char *dir_path,const char *selected_file, int draw_scr) const char *menu_select_file(char *dir_path,const char *selected_file, int draw_scr, int sel_pos)
{ {
if (dir_path == NULL) if (dir_path == NULL)
dir_path = ""; dir_path = "";
return menu_select_file_internal(dir_path, return menu_select_file_internal(dir_path,
0, 18/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 18/RATIO, selected_file, draw_scr, 0); 0, 18/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 18/RATIO, selected_file, draw_scr, 0, sel_pos);
} }
const char *menu_select_browser(unsigned int tape_pos) const char *menu_select_browser(unsigned int tape_pos)
{ {
return menu_select_file_internal("browser", return menu_select_file_internal("browser",
0, 18/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 18/RATIO, NULL, 0, tape_pos); 0, 18/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 18/RATIO, NULL, 0, tape_pos, 0);
} }
const char *menu_select_browser_rzx() const char *menu_select_browser_rzx()
{ {
return menu_select_file_internal("browser_rzx", return menu_select_file_internal("browser_rzx",
0, 18/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 18/RATIO, NULL, 1, 0); 0, 18/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 18/RATIO, NULL, 1, 0, 0);
} }
const char *menu_select_tape_block() const char *menu_select_tape_block()
{ {
SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0)); SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
return menu_select_file_internal("select_block", return menu_select_file_internal("select_block",
0, 18/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 18/RATIO, NULL, 0, 0); 0, 18/RATIO, FULL_DISPLAY_X, FULL_DISPLAY_Y - 18/RATIO, NULL, 0, 0, 0);
} }
/* /*

View File

@ -54,7 +54,7 @@ void print_font(SDL_Surface *screen, int r, int g, int b, int x, int y, const ch
/* Various option selects */ /* Various option selects */
int menu_select_title(const char *title, const char **pp_msgs, int *p_submenus); int menu_select_title(const char *title, const char **pp_msgs, int *p_submenus);
int menu_select(const char **pp_msgs, int *p_submenus); int menu_select(const char **pp_msgs, int *p_submenus);
const char *menu_select_file(char *dir_path,const char *selected_file, int draw_scr); const char *menu_select_file(char *dir_path,const char *selected_file, int draw_scr, int sel_pos);
const char *menu_select_browser(unsigned int tape_pos); const char *menu_select_browser(unsigned int tape_pos);
const char *menu_select_browser_rzx(); const char *menu_select_browser_rzx();