--- hatari/src/gui-sdl/dlgFileSelect.c 2019/04/01 07:11:38 1.1 +++ hatari/src/gui-sdl/dlgFileSelect.c 2019/04/01 07:13:16 1.1.1.3 @@ -6,29 +6,33 @@ A file selection dialog for the graphical user interface for Hatari. */ -char DlgFileSelect_rcsid[] = "Hatari $Id: dlgFileSelect.c,v 1.1 2019/04/01 07:11:38 root Exp $"; +const char DlgFileSelect_rcsid[] = "Hatari $Id: dlgFileSelect.c,v 1.1.1.3 2019/04/01 07:13:16 root Exp $"; #include #include #include -#include #include "main.h" -#include "screen.h" +#include "scandir.h" #include "sdlgui.h" #include "file.h" #include "zip.h" +#define SGFS_NUMENTRIES 16 /* How many entries are displayed at once */ + + #define SGFSDLG_FILENAME 5 #define SGFSDLG_UPDIR 6 -#define SGFSDLG_ROOTDIR 7 -#define SGFSDLG_ENTRY1 10 -#define SGFSDLG_ENTRY16 25 -#define SGFSDLG_UP 26 -#define SGFSDLG_DOWN 27 -#define SGFSDLG_OKAY 28 -#define SGFSDLG_CANCEL 29 +#define SGFSDLG_HOMEDIR 7 +#define SGFSDLG_ROOTDIR 8 +#define SGFSDLG_ENTRY1 11 +#define SGFSDLG_ENTRY16 26 +#define SGFSDLG_UP 27 +#define SGFSDLG_DOWN 28 +#define SGFSDLG_SHOWHIDDEN 29 +#define SGFSDLG_OKAY 30 +#define SGFSDLG_CANCEL 31 #define DLGPATH_SIZE 62 @@ -38,7 +42,7 @@ static char dlgpath[DLGPATH_SIZE+1]; static char dlgfname[DLGFNAME_SIZE+1]; /* Name of the selected file in the dialog */ #define DLGFILENAMES_SIZE 59 -static char dlgfilenames[16][DLGFILENAMES_SIZE+1]; /* Visible file names in the dialog */ +static char dlgfilenames[SGFS_NUMENTRIES][DLGFILENAMES_SIZE+1]; /* Visible file names in the dialog */ /* The dialog data: */ static SGOBJ fsdlg[] = @@ -49,7 +53,8 @@ static SGOBJ fsdlg[] = { SGTEXT, 0, 0, 1,3, DLGPATH_SIZE,1, dlgpath }, { SGTEXT, 0, 0, 1,4, 6,1, "File:" }, { SGTEXT, 0, 0, 7,4, DLGFNAME_SIZE,1, dlgfname }, - { SGBUTTON, 0, 0, 55,1, 4,1, ".." }, + { SGBUTTON, 0, 0, 51,1, 4,1, ".." }, + { SGBUTTON, 0, 0, 56,1, 3,1, "~" }, { SGBUTTON, 0, 0, 60,1, 3,1, "/" }, { SGBOX, 0, 0, 1,6, 62,16, NULL }, { SGBOX, 0, 0, 62,7, 1,14, NULL }, @@ -71,20 +76,24 @@ static SGOBJ fsdlg[] = { SGTEXT, SG_EXIT, 0, 2,21, DLGFILENAMES_SIZE,1, dlgfilenames[15] }, { SGBUTTON, SG_TOUCHEXIT, 0, 62,6, 1,1, "\x01" }, /* Arrow up */ { SGBUTTON, SG_TOUCHEXIT, 0, 62,21, 1,1, "\x02" }, /* Arrow down */ - { SGBUTTON, 0, 0, 14,23, 8,1, "Okay" }, - { SGBUTTON, 0, 0, 34,23, 8,1, "Cancel" }, + { SGCHECKBOX, SG_EXIT, SG_SELECTED, 2,23, 18,1, "Show hidden files" }, + { SGBUTTON, 0, 0, 32,23, 8,1, "Okay" }, + { SGBUTTON, 0, 0, 50,23, 8,1, "Cancel" }, { -1, 0, 0, 0,0, 0,0, NULL } }; +static int ypos; /* First entry number to be displayed */ +static BOOL refreshentries; /* Do we have to update the file names in the dialog? */ +static int entries; /* How many files are in the actual directory? */ + /*-----------------------------------------------------------------------*/ /* Update the file name strings in the dialog. Returns FALSE if it failed, TRUE on success. */ -static int DlgFileSelect_RefreshEntries(struct dirent **files, char *path, - BOOL browsingzip, int entries, int ypos) +static int DlgFileSelect_RefreshEntries(struct dirent **files, char *path, BOOL browsingzip) { int i; char *tempstr = malloc(FILENAME_MAX); @@ -96,7 +105,7 @@ static int DlgFileSelect_RefreshEntries( } /* Copy entries to dialog: */ - for(i=0; i<16; i++) + for(i=0; i