~fixed confirmation box

~improved history filelist update
~removed some global variables
This commit is contained in:
ekeeke31 2009-05-26 13:14:33 +00:00
parent b7f3a1bfd5
commit 05014756ca
12 changed files with 100 additions and 68 deletions

View File

@ -107,7 +107,7 @@ void config_default(void)
config.bgm_volume = 100.0;
config.sfx_volume = 100.0;
config.screen_w = 658;
config.askConfirm = 0;
config.ask_confirm = 0;
/* restore saved configuration */
config_load();

View File

@ -60,7 +60,7 @@ typedef struct
int8 sram_auto;
int8 state_auto;
int16 screen_w;
uint8 askConfirm;
uint8 ask_confirm;
} t_config;
/* Global data */

View File

@ -41,14 +41,13 @@
/** Minimal Primary Volume Descriptor **/
#define PVDROOT 0x9c
bool haveDVDdir = 0;
/** Static Variables **/
static u64 rootdir = 0; /* current root directory offset */
static u64 basedir = 0; /* base directory offset */
static int rootdirlength = 0; /* current root directory length */
static u64 rootdir = 0;
static u64 basedir = 0;
static int rootdirlength = 0;
static int IsJoliet = 0;
static int diroffset = 0;
static int haveDVDdir = 0;
static char dvdbuffer[2048];
/****************************************************************************
@ -200,11 +199,21 @@ static int getentry(int entrycount)
}
/***************************************************************************
* DVD_UpdateRootDir
* DVD_ClearDirectory
*
* Clear DVD directory flag
***************************************************************************/
void DVD_ClearDirectory(void)
{
haveDVDdir = 0;
}
/***************************************************************************
* DVD_UpdateDirectory
*
* Update DVD current root directory
***************************************************************************/
int DVD_UpdateDir(bool go_up, u64 offset, u32 length)
int DVD_UpdateDirectory(bool go_up, u64 offset, u32 length)
{
/* root has no parent directory */
if (go_up && (basedir == rootdir)) return 0;
@ -380,10 +389,10 @@ int DVD_Open(void)
{
/* set DVD as default */
haveDVDdir = 1;
haveFATdir = 0;
FAT_ClearDirectory();
/* reset File selector */
FileSelClear(max);
ClearSelector(max);
return 1;
}
else

View File

@ -25,10 +25,10 @@
#ifndef _FILE_DVD_H
#define _FILE_DVD_H
extern int DVD_UpdateDir(bool go_up,u64 offset, u32 length);
extern void DVD_ClearDirectory(void);
extern int DVD_UpdateDirectory(bool go_up,u64 offset, u32 length);
extern int DVD_ParseDirectory(void);
extern int DVD_LoadFile(u8 *buffer,u32 selection);
extern int DVD_Open(void);
extern bool haveDVDdir;
#endif

View File

@ -29,7 +29,8 @@
#include "file_fat.h"
#include "file_dvd.h"
bool haveFATdir = 0;
/* FAT directory has been updated */
static int haveFATdir = 0;
/* current FAT directory */
static char fatdir[MAXPATHLEN];
@ -39,11 +40,21 @@ static int fat_type = 0;
static int useHistory = 0;
/***************************************************************************
* FAT_UpdateDir
* FAT_ClearDirectory
*
* Clear FAT directory flag
***************************************************************************/
void FAT_ClearDirectory(void)
{
haveFATdir = 0;
}
/***************************************************************************
* FAT_UpdateDirectory
*
* Update FAT current root directory
***************************************************************************/
int FAT_UpdateDir(bool go_up, char *filename)
int FAT_UpdateDirectory(bool go_up, char *filename)
{
int size=0;
char *test;
@ -143,6 +154,9 @@ int FAT_LoadFile(u8 *buffer, u32 selection)
{
filelist[selection].length = filestat.st_size;
}
/* update filelist */
haveFATdir = 0;
}
/* file size */
@ -151,7 +165,7 @@ int FAT_LoadFile(u8 *buffer, u32 selection)
if (length > 0)
{
/* Add/move the file to the top of the history. */
if(!useHistory) history_add_file(fatdir, filelist[selection].filename);
history_add_file(fatdir, filelist[selection].filename);
/* full filename */
char fname[MAXPATHLEN];
@ -264,10 +278,10 @@ int FAT_Open(int type)
{
/* FAT is default */
haveFATdir = 1;
haveDVDdir = 0;
DVD_ClearDirectory();
/* reset File selector */
FileSelClear(max);
ClearSelector(max);
return 1;
}
else

View File

@ -31,10 +31,10 @@
#define TYPE_USB 2
#endif
extern int FAT_UpdateDir(bool go_up, char *filename);
extern void FAT_ClearDirectory(void);
extern int FAT_UpdateDirectory(bool go_up, char *filename);
extern int FAT_ParseDirectory(void);
extern int FAT_LoadFile(u8* buffer,u32 selection);
extern int FAT_Open(int type);
extern bool haveFATdir;
#endif

View File

@ -89,7 +89,7 @@ static gui_image bg_filesel[10] =
{NULL,Banner_top_png,IMAGE_VISIBLE,0,0,640,108,255},
{NULL,Banner_bottom_png,IMAGE_VISIBLE,0,380,640,100,255},
{NULL,Main_logo_png,IMAGE_VISIBLE,466,40,152,44,255},
{NULL,Frame_s1_png,IMAGE_VISIBLE,8,70,372,336,200},
{NULL,Frame_s1_png,IMAGE_VISIBLE,8,70,372,336,230},
{NULL,Frame_s2_png,0,384,264,248,140,200},
{NULL,Snap_empty_png,IMAGE_VISIBLE,422,114,164,116,255},
{NULL,NULL,0,424,116,160,112,255},
@ -284,7 +284,6 @@ int FileSelector(unsigned char *buffer, bool useFAT)
}
else
{
filelist[i].filename_offset = 0;
if (filelist[i].flags)
{
/* directory icon */
@ -325,13 +324,13 @@ int FileSelector(unsigned char *buffer, bool useFAT)
m->selected = m->max_buttons + 2;
for (i = offset; i < (offset + PAGESIZE) && (i < maxfiles); i++)
{
if ((x<=380)&&(y>=yoffset)&&(y<(yoffset+(bar_over.h))))
if ((x<=380)&&(y>=yoffset)&&(y<(yoffset+24)))
{
selection = i;
m->selected = -1;
break;
}
yoffset += (bar_over.h);
yoffset += 24;
}
/* find selected button */
@ -461,9 +460,9 @@ int FileSelector(unsigned char *buffer, bool useFAT)
/* get new directory */
if (useFAT)
ret = FAT_UpdateDir(go_up,filelist[selection].filename);
ret = FAT_UpdateDirectory(go_up,filelist[selection].filename);
else
ret = DVD_UpdateDir(go_up,filelist[selection].offset,filelist[selection].length);
ret = DVD_UpdateDirectory(go_up,filelist[selection].offset,filelist[selection].length);
/* get new entry list or quit */
if (ret)
@ -514,7 +513,7 @@ int FileSelector(unsigned char *buffer, bool useFAT)
else
{
/* user confirmation */
if (GUI_ConfirmPrompt("WARNING", "Load File ?"))
if (GUI_ConfirmPrompt("Load this file ?"))
{
/* Load ROM file from device */
if (useFAT)
@ -538,7 +537,7 @@ int FileSelector(unsigned char *buffer, bool useFAT)
return size;
}
/* use canceled */
/* user canceled */
GUI_MsgBoxClose();
}
}
@ -547,8 +546,7 @@ int FileSelector(unsigned char *buffer, bool useFAT)
}
}
void FileSelClear(u32 max)
void ClearSelector(u32 max)
{
maxfiles = max;
offset = 0;

View File

@ -35,13 +35,12 @@ typedef struct
u32 length;
char flags;
char filename[MAXJOLIET];
u16 filename_offset;
}FILEENTRIES;
/* Globals */
extern int FileSelector(unsigned char *buffer, bool useFAT);
extern int FileSortCallback(const void *f1, const void *f2);
extern void FileSelClear(u32 max);
extern void ClearSelector(u32 max);
extern FILEENTRIES filelist[MAXFILES];
#endif

View File

@ -101,8 +101,8 @@ void GUI_InitMenu(gui_menu *menu)
item->texture = gxTextureOpenPNG(item->data,0);
}
/* setup message box */
GUI_MsgBoxUpdate(menu,0,0);
/* update message box */
message_box.parent = menu;
}
/* Release Menu allocated memory */
@ -1226,17 +1226,20 @@ static void *MsgBox_Thread(void *arg)
}
/* draw exit message */
if (message_box.buttonB)
if (message_box.buttonA)
{
FONT_write(": OK",18,206+message_box.buttonA->width+12,640,248,(GXColor)WHITE);
FONT_write(": CANCEL",18,286+message_box.buttonB->width+12,640,248,(GXColor)WHITE);
gxDrawTexture(message_box.buttonA, 206, 248-18+(18-message_box.buttonA->height)/2,message_box.buttonA->width, message_box.buttonA->height,255);
gxDrawTexture(message_box.buttonB, 286, 248-18+(18-message_box.buttonB->height)/2,message_box.buttonA->width, message_box.buttonA->height,255);
}
else if (message_box.buttonA)
{
FONT_writeCenter("Press to continue.",18,166,166+message_box.window->width,248+22,(GXColor)WHITE);
gxDrawTexture(message_box.buttonA, 166+116, 248+4+(18-message_box.buttonA->height)/2,message_box.buttonA->width, message_box.buttonA->height,255);
if (message_box.buttonB)
{
FONT_write("OK",18,220+message_box.buttonA->width+6,288,640,(GXColor)WHITE);
FONT_alignRight("CANCEL",18,166+message_box.window->width-(220-166),288,(GXColor)WHITE);
if (message_box.buttonA) gxDrawTexture(message_box.buttonA, 220, 288-18+(18-message_box.buttonA->height)/2,message_box.buttonA->width, message_box.buttonA->height,255);
if (message_box.buttonB) gxDrawTexture(message_box.buttonB, 328, 288-18+(18-message_box.buttonB->height)/2,message_box.buttonB->width, message_box.buttonB->height,255);
}
else
{
FONT_writeCenter("Press to continue.",18,166,166+message_box.window->width,248+22,(GXColor)WHITE);
if (message_box.buttonA) gxDrawTexture(message_box.buttonA, 166+116, 248+4+(18-message_box.buttonA->height)/2,message_box.buttonA->width, message_box.buttonA->height,255);
}
}
/* update display */
@ -1256,9 +1259,8 @@ static void *MsgBox_Thread(void *arg)
}
/* update current Message Box */
void GUI_MsgBoxUpdate(gui_menu *parent, char *title, char *msg)
void GUI_MsgBoxUpdate(char *title, char *msg)
{
if (parent) message_box.parent = parent;
if (title) strncpy(message_box.title,title,64);
if (msg) strncpy(message_box.msg,msg,64);
}
@ -1268,8 +1270,13 @@ void GUI_MsgBoxOpen(char *title, char *msg, bool throbber)
{
if (SILENT) return;
/* clear unused textures */
gxTextureClose(&message_box.buttonA);
gxTextureClose(&message_box.buttonB);
gxTextureClose(&message_box.throbber);
/* update message box */
GUI_MsgBoxUpdate(0,title,msg);
GUI_MsgBoxUpdate(title,msg);
/* ensure we are not already running */
if (!message_box.refresh)
@ -1367,7 +1374,7 @@ void GUI_MsgBoxClose(void)
GUI_DrawMenu(message_box.parent);
gxSetScreen();
/* close textures */
/* clear all textures */
gxTextureClose(&message_box.window);
gxTextureClose(&message_box.top);
gxTextureClose(&message_box.buttonA);
@ -1381,27 +1388,25 @@ void GUI_WaitPrompt(char *title, char *msg)
if (SILENT) return;
/* update message box */
gxTextureClose(&message_box.throbber);
GUI_MsgBoxOpen(title, msg, 0);
/* allocate texture memory */
/* allocate texture */
message_box.buttonA = gxTextureOpenPNG(Key_A_png,0);
/* wait for button A */
while (m_input.keys & PAD_BUTTON_A) VIDEO_WaitVSync();
while (!(m_input.keys & PAD_BUTTON_A)) VIDEO_WaitVSync();
/* close message box */
/* always close message box */
GUI_MsgBoxClose();
}
int GUI_ConfirmPrompt(char *title, char *msg)
int GUI_ConfirmPrompt(char *msg)
{
if (config.askConfirm)
if (config.ask_confirm)
{
/* update message box */
gxTextureClose(&message_box.throbber);
GUI_MsgBoxOpen(title, msg, 0);
GUI_MsgBoxOpen("User Confirmation", msg, 0);
/* allocate textures */
message_box.buttonA = gxTextureOpenPNG(Key_A_png,0);

View File

@ -288,10 +288,10 @@ extern int GUI_WindowPrompt(gui_menu *parent, char *title, char *items[], u8 nb_
extern void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *option, float step, float min, float max, u8 type);
extern void GUI_SlideMenuTitle(gui_menu *m, int title_offset);
extern void GUI_MsgBoxOpen(char *title, char *msg, bool throbber);
extern void GUI_MsgBoxUpdate(gui_menu *parent, char *title, char *msg);
extern void GUI_MsgBoxUpdate(char *title, char *msg);
extern void GUI_MsgBoxClose(void);
extern void GUI_WaitPrompt(char *title, char *msg);
extern int GUI_ConfirmPrompt(char *title, char *msg);
extern int GUI_ConfirmPrompt(char *msg);
extern void GUI_FadeOut();
extern void GUI_SetBgColor(GXColor color);
extern void GUI_Initialize(void);

View File

@ -249,14 +249,15 @@ static gui_item items_video[8] =
};
/* Preferences menu */
static gui_item items_prefs[6] =
static gui_item items_prefs[7] =
{
{NULL,NULL,"Auto SRAM: OFF", "Enable/disable automatic SRAM", 52,132,276,48},
{NULL,NULL,"Auto STATE: OFF", "Enable/disable automatic Savestate", 52,132,276,48},
{NULL,NULL,"SFX Volume: 100", "Adjust sound effects volume", 52,132,276,48},
{NULL,NULL,"BGM Volume: 100", "Adjust background music volume", 52,132,276,48},
{NULL,NULL,"BG Color: DEFAULT", "Change background color", 52,132,276,48},
{NULL,NULL,"Screen Width: 658", "Adjust Screen Width", 52,132,276,48}
{NULL,NULL,"Auto SRAM: OFF", "Enable/disable automatic SRAM", 52,132,276,48},
{NULL,NULL,"Auto STATE: OFF", "Enable/disable automatic Savestate", 52,132,276,48},
{NULL,NULL,"SFX Volume: 100", "Adjust sound effects volume", 52,132,276,48},
{NULL,NULL,"BGM Volume: 100", "Adjust background music volume", 52,132,276,48},
{NULL,NULL,"BG Color: DEFAULT", "Change background color", 52,132,276,48},
{NULL,NULL,"Screen Width: 658", "Adjust Screen Width", 52,132,276,48},
{NULL,NULL,"Confirmation Box: OFF", "Enable/disable user confirmation", 52,132,276,48}
};
/*****************************************************************************/
@ -447,7 +448,7 @@ static gui_menu menu_prefs =
{
"Menu Settings",
0,0,
6,4,6,
7,4,6,
items_prefs,
buttons_list,
bg_list,
@ -615,6 +616,7 @@ static void prefmenu ()
if (config.bg_color) sprintf (items[4].text, "BG Color: Type %d", config.bg_color);
else sprintf (items[4].text, "BG Color: DEFAULT");
sprintf (items[5].text, "Screen Width: %d", config.screen_w);
sprintf (items[6].text, "Confirmation Box: %s",config.ask_confirm ? "ON":"OFF");
GUI_InitMenu(m);
GUI_SlideMenuTitle(m,strlen("Menu "));
@ -668,6 +670,11 @@ static void prefmenu ()
sprintf (items[5].text, "Screen Width: %d", config.screen_w);
break;
case 6:
config.ask_confirm ^= 1;
sprintf (items[6].text, "Confirmation Box: %s",config.ask_confirm ? "ON":"OFF");
break;
case -1:
quit = 1;
break;

View File

@ -116,7 +116,7 @@ static void pad_config(int chan, int max_keys)
/* wait for user input */
sprintf(msg,"Press key for %s\n(Z to return)",keys_name[i]);
GUI_MsgBoxUpdate(0,0,msg);
GUI_MsgBoxUpdate(0,msg);
key = 0;
while (!key)
@ -345,7 +345,7 @@ static void wpad_config(u8 chan, u8 exp, u8 max_keys)
/* wait for user input */
sprintf(msg,"Press key for %s\n(HOME to return)",keys_name[i]);
GUI_MsgBoxUpdate(0,0,msg);
GUI_MsgBoxUpdate(0,msg);
/* wait for input */
key = 0;