mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2025-02-04 22:16:24 +01:00
+added real-time update for optionboxes (function callback)
This commit is contained in:
parent
d1c6a04dc7
commit
8aa21d446d
@ -892,7 +892,7 @@ int GUI_WindowPrompt(gui_menu *parent, char *title, char *items[], u8 nb_items)
|
||||
}
|
||||
|
||||
/* display Option Box */
|
||||
void GUI_OptionBox(gui_menu *parent, char *title, void *option, float step, float min, float max, u8 type)
|
||||
void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *option, float step, float min, float max, u8 type)
|
||||
{
|
||||
gx_texture *l_arrow[2];
|
||||
gx_texture *r_arrow[2];
|
||||
@ -1059,8 +1059,12 @@ void GUI_OptionBox(gui_menu *parent, char *title, void *option, float step, floa
|
||||
if (*(float *)option < min) *(float *)option = max;
|
||||
}
|
||||
|
||||
/* play sound effect */
|
||||
ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size,
|
||||
((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL);
|
||||
|
||||
/* option callback */
|
||||
if (cb) cb();
|
||||
}
|
||||
else if ((p&PAD_BUTTON_RIGHT) || ((p & PAD_BUTTON_A) && (selected == 1)))
|
||||
{
|
||||
@ -1078,8 +1082,12 @@ void GUI_OptionBox(gui_menu *parent, char *title, void *option, float step, floa
|
||||
if (*(float *)option > max) *(float *)option = min;
|
||||
}
|
||||
|
||||
/* play sound effect */
|
||||
ASND_SetVoice(ASND_GetFirstUnusedVoice(),VOICE_MONO_16BIT,22050,0,(u8 *)button_over_pcm,button_over_pcm_size,
|
||||
((int)config.sfx_volume * 255) / 100,((int)config.sfx_volume * 255) / 100,NULL);
|
||||
|
||||
/* option callback */
|
||||
if (cb) cb();
|
||||
}
|
||||
|
||||
if (p & PAD_BUTTON_B) quit = 1;
|
||||
|
@ -132,7 +132,7 @@ typedef struct
|
||||
gx_texture *throbber; /* pointer to throbber texture */
|
||||
} gui_message;
|
||||
|
||||
/* Menu Inputs */
|
||||
/* Menu inputs */
|
||||
struct t_input_menu
|
||||
{
|
||||
u32 connected;
|
||||
@ -142,6 +142,10 @@ struct t_input_menu
|
||||
#endif
|
||||
} m_input;
|
||||
|
||||
/* Optionbox callback */
|
||||
typedef void (*optioncallback)(void);
|
||||
|
||||
|
||||
/* PNG images */
|
||||
|
||||
/* Intro */
|
||||
@ -281,7 +285,7 @@ extern void GUI_DrawMenuFX(gui_menu *menu, u8 speed, u8 out);
|
||||
extern int GUI_UpdateMenu(gui_menu *menu);
|
||||
extern int GUI_RunMenu(gui_menu *menu);
|
||||
extern int GUI_WindowPrompt(gui_menu *parent, char *title, char *items[], u8 nb_items);
|
||||
extern void GUI_OptionBox(gui_menu *parent, char *title, void *option, float step, float min, float max, u8 type);
|
||||
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);
|
||||
|
@ -583,6 +583,19 @@ static int domenu (char items[][25], int maxitems, u8 fastmove)
|
||||
* GUI Settings menu
|
||||
*
|
||||
****************************************************************************/
|
||||
static void update_screen_w(void)
|
||||
{
|
||||
vmode->viWidth = config.screen_w;
|
||||
vmode->viXOrigin = (VI_MAX_WIDTH_NTSC -config.screen_w)/2;
|
||||
VIDEO_Configure(vmode);
|
||||
VIDEO_Flush();
|
||||
}
|
||||
|
||||
static void update_bgm(void)
|
||||
{
|
||||
SetVolumeOgg(((int)config.bgm_volume * 255) / 100);
|
||||
}
|
||||
|
||||
static void prefmenu ()
|
||||
{
|
||||
int ret, quit = 0;
|
||||
@ -631,14 +644,13 @@ static void prefmenu ()
|
||||
break;
|
||||
|
||||
case 2: /*** Sound effects volume ***/
|
||||
GUI_OptionBox(m,"SFX Volume",(void *)&config.sfx_volume,10.0,0.0,100.0,0);
|
||||
GUI_OptionBox(m,0,"SFX Volume",(void *)&config.sfx_volume,10.0,0.0,100.0,0);
|
||||
sprintf (items[2].text, "SFX Volume: %1.1f", config.sfx_volume);
|
||||
break;
|
||||
|
||||
case 3: /*** Background music volume ***/
|
||||
GUI_OptionBox(m,"BGM Volume",(void *)&config.bgm_volume,10.0,0.0,100.0,0);
|
||||
GUI_OptionBox(m,update_bgm,"BGM Volume",(void *)&config.bgm_volume,10.0,0.0,100.0,0);
|
||||
sprintf (items[3].text, "BGM Volume: %1.1f", config.bgm_volume);
|
||||
SetVolumeOgg(((int)config.bgm_volume * 255) / 100);
|
||||
break;
|
||||
|
||||
case 4: /*** Background color ***/
|
||||
@ -652,12 +664,8 @@ static void prefmenu ()
|
||||
break;
|
||||
|
||||
case 5:
|
||||
GUI_OptionBox(m,"Screen Width",(void *)&config.screen_w,2,640,VI_MAX_WIDTH_NTSC,1);
|
||||
GUI_OptionBox(m,update_screen_w,"Screen Width",(void *)&config.screen_w,2,640,VI_MAX_WIDTH_NTSC,1);
|
||||
sprintf (items[5].text, "Screen Width: %d", config.screen_w);
|
||||
vmode->viWidth = config.screen_w;
|
||||
vmode->viXOrigin = (VI_MAX_WIDTH_NTSC -config.screen_w)/2;
|
||||
VIDEO_Configure(vmode);
|
||||
VIDEO_Flush();
|
||||
break;
|
||||
|
||||
case -1:
|
||||
@ -699,13 +707,13 @@ static void soundmenu ()
|
||||
switch (ret)
|
||||
{
|
||||
case 0:
|
||||
GUI_OptionBox(m,"PSG Volume",(void *)&psg_volume,0.01,0.0,5.0,0);
|
||||
GUI_OptionBox(m,0,"PSG Volume",(void *)&psg_volume,0.01,0.0,5.0,0);
|
||||
sprintf (items[0].text, "PSG Volume: %1.2f", psg_volume);
|
||||
config.psg_preamp = (int)(psg_volume * 100.0);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
GUI_OptionBox(m,"FM Volume",(void *)&fm_volume,0.01,0.0,5.0,0);
|
||||
GUI_OptionBox(m,0,"FM Volume",(void *)&fm_volume,0.01,0.0,5.0,0);
|
||||
sprintf (items[1].text, "FM Volume: %1.2f", (double)config.fm_preamp/100.0);
|
||||
config.fm_preamp = (int)(fm_volume * 100.0);
|
||||
break;
|
||||
@ -826,7 +834,7 @@ static void systemmenu ()
|
||||
break;
|
||||
|
||||
case 3: /*** SVP emulation ***/
|
||||
GUI_OptionBox(m,"SVP Cycles",(void *)&SVP_cycles,1,1,1500,1);
|
||||
GUI_OptionBox(m,0,"SVP Cycles",(void *)&SVP_cycles,1,1,1500,1);
|
||||
sprintf (items[3].text, "SVP Cycles: %d", SVP_cycles);
|
||||
break;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user