mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-11-12 13:55:07 +01:00
+ improved controller setting menu
+ improved GUI generic code
This commit is contained in:
parent
a9de2b70d1
commit
67517fa794
@ -68,8 +68,8 @@ static butn_data arrow_down_data =
|
|||||||
/* GUI Arrows button */
|
/* GUI Arrows button */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static gui_butn arrow_up = {&arrow_up_data,BUTTON_VISIBLE|BUTTON_OVER_SFX,{0,0},14,76,360,32};
|
static gui_butn arrow_up = {&arrow_up_data,BUTTON_VISIBLE|BUTTON_OVER_SFX,{0,0,0,0},14,76,360,32};
|
||||||
static gui_butn arrow_down = {&arrow_down_data,BUTTON_VISIBLE|BUTTON_OVER_SFX,{0,0},14,368,360,32};
|
static gui_butn arrow_down = {&arrow_down_data,BUTTON_VISIBLE|BUTTON_OVER_SFX,{0,0,0,0},14,368,360,32};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* GUI helpers */
|
/* GUI helpers */
|
||||||
@ -97,16 +97,16 @@ static gui_item action_select =
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static gui_image bg_filesel[10] =
|
static gui_image bg_filesel[10] =
|
||||||
{
|
{
|
||||||
{NULL,Bg_main_png,IMAGE_VISIBLE,356,144,348,288,255,{0,0},{0,0}},
|
{NULL,Bg_main_png,IMAGE_VISIBLE,356,144,348,288,255},
|
||||||
{NULL,Bg_overlay_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255,{0,0},{0,0}},
|
{NULL,Bg_overlay_png,IMAGE_VISIBLE|IMAGE_REPEAT,0,0,640,480,255},
|
||||||
{NULL,Banner_top_png,IMAGE_VISIBLE,0,0,640,108,255,{0,0},{0,0}},
|
{NULL,Banner_top_png,IMAGE_VISIBLE,0,0,640,108,255},
|
||||||
{NULL,Banner_bottom_png,IMAGE_VISIBLE,0,380,640,100,255,{0,0},{0,0}},
|
{NULL,Banner_bottom_png,IMAGE_VISIBLE,0,380,640,100,255},
|
||||||
{NULL,Main_logo_png,IMAGE_VISIBLE,466,40,152,44,255,{0,0},{0,0}},
|
{NULL,Main_logo_png,IMAGE_VISIBLE,466,40,152,44,255},
|
||||||
{NULL,Frame_s1_png,IMAGE_VISIBLE,8,70,372,336,200,{0,0},{0,0}},
|
{NULL,Frame_s1_png,IMAGE_VISIBLE,8,70,372,336,200},
|
||||||
{NULL,Frame_s2_png,0,384,264,248,140,200,{0,0},{0,0}},
|
{NULL,Frame_s2_png,0,384,264,248,140,200},
|
||||||
{NULL,Snap_empty_png,IMAGE_VISIBLE,422,114,164,116,255,{0,0},{0,0}},
|
{NULL,Snap_empty_png,IMAGE_VISIBLE,422,114,164,116,255},
|
||||||
{NULL,NULL,0,424,116,160,112,255,{0,0},{0,0}},
|
{NULL,NULL,0,424,116,160,112,255},
|
||||||
{NULL,Snap_frame_png,IMAGE_VISIBLE,388,112,236,148,255,{0,0},{0,0}}
|
{NULL,Snap_frame_png,IMAGE_VISIBLE,388,112,236,148,255}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -197,10 +197,6 @@ int FileSelector(unsigned char *buffer)
|
|||||||
bar_over.x = 22;
|
bar_over.x = 22;
|
||||||
bar_over.y = -(bar_over.h - dir_icon.h)/2;
|
bar_over.y = -(bar_over.h - dir_icon.h)/2;
|
||||||
|
|
||||||
/* Initialize star icons */
|
|
||||||
//gx_texture *star_full = gxTextureOpenPNG(Star_full_png);
|
|
||||||
//gx_texture *star_empty = gxTextureOpenPNG(Star_empty_png);
|
|
||||||
|
|
||||||
while (!quit)
|
while (!quit)
|
||||||
{
|
{
|
||||||
/* get ROM filename without extension */
|
/* get ROM filename without extension */
|
||||||
@ -300,6 +296,7 @@ int FileSelector(unsigned char *buffer)
|
|||||||
{
|
{
|
||||||
gxTextureClose(&w_pointer);
|
gxTextureClose(&w_pointer);
|
||||||
GUI_DeleteMenu(m);
|
GUI_DeleteMenu(m);
|
||||||
|
GUI_FadeOut();
|
||||||
shutdown();
|
shutdown();
|
||||||
SYS_ResetSystem(SYS_POWEROFF, 0, 0);
|
SYS_ResetSystem(SYS_POWEROFF, 0, 0);
|
||||||
}
|
}
|
||||||
@ -486,8 +483,6 @@ int FileSelector(unsigned char *buffer)
|
|||||||
GUI_DeleteMenu(m);
|
GUI_DeleteMenu(m);
|
||||||
gxTextureClose(&bar_over.texture);
|
gxTextureClose(&bar_over.texture);
|
||||||
gxTextureClose(&dir_icon.texture);
|
gxTextureClose(&dir_icon.texture);
|
||||||
//gxTextureClose(&star_full);
|
|
||||||
//gxTextureClose(&star_empty);
|
|
||||||
|
|
||||||
if (quit == 2) return 0;
|
if (quit == 2) return 0;
|
||||||
else if (useFAT) return FAT_LoadFile(buffer);
|
else if (useFAT) return FAT_LoadFile(buffer);
|
||||||
|
@ -186,19 +186,35 @@ int FONT_write(char *string, int size, int x, int y, int max_width, GXColor colo
|
|||||||
|
|
||||||
void FONT_writeCenter(char *string, int size, int x1, int x2, int y, GXColor color)
|
void FONT_writeCenter(char *string, int size, int x1, int x2, int y, GXColor color)
|
||||||
{
|
{
|
||||||
int i;
|
int i=0;
|
||||||
u16 width = 0;
|
u16 width = 0;
|
||||||
|
|
||||||
for (i=0; i<strlen(string); i++)
|
while (string[i] && (string[i] != '\n'))
|
||||||
width += (font_size[(u8)string[i]] * size) / fheight;
|
width += (font_size[(u8)string[i++]] * size) / fheight;
|
||||||
|
|
||||||
x1 += (x2 - x1 - width - vmode->fbWidth) / 2;
|
int x = x1 + (x2 - x1 - width - vmode->fbWidth) / 2;
|
||||||
y -= (vmode->efbHeight / 2);
|
y -= (vmode->efbHeight / 2);
|
||||||
|
|
||||||
while (*string)
|
while (*string && (*string != '\n'))
|
||||||
{
|
{
|
||||||
DrawChar(*string, x1, y, size,color);
|
DrawChar(*string, x, y, size,color);
|
||||||
x1 += (font_size[(u8)*string++] * size) / fheight;
|
x += (font_size[(u8)*string++] * size) / fheight;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*string == '\n')
|
||||||
|
{
|
||||||
|
string++;
|
||||||
|
i = 0;
|
||||||
|
width = 0;
|
||||||
|
while (string[i])
|
||||||
|
width += (font_size[(u8)string[i++]] * size) / fheight;
|
||||||
|
x = x1 + (x2 - x1 - width - vmode->fbWidth) / 2;
|
||||||
|
y += size;
|
||||||
|
while (*string)
|
||||||
|
{
|
||||||
|
DrawChar(*string, x, y, size,color);
|
||||||
|
x += (font_size[(u8)*string++] * size) / fheight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1611
source/gx/gui/menu.c
1611
source/gx/gui/menu.c
File diff suppressed because it is too large
Load Diff
@ -32,20 +32,27 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* GUI Buttons state */
|
/* GUI Buttons state */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
#define BUTTON_VISIBLE 0x01
|
#define BUTTON_VISIBLE 0x01
|
||||||
#define BUTTON_SHIFT 0x02
|
#define BUTTON_SHIFT 0x02
|
||||||
#define BUTTON_ACTIVE 0x04
|
#define BUTTON_ACTIVE 0x04
|
||||||
#define BUTTON_OVER_SFX 0x10
|
#define BUTTON_OVER_SFX 0x08
|
||||||
#define BUTTON_SELECT_SFX 0x20
|
#define BUTTON_SELECT_SFX 0x10
|
||||||
|
#define BUTTON_FADE 0x20
|
||||||
|
#define BUTTON_SLIDE_LEFT 0x40
|
||||||
|
#define BUTTON_SLIDE_RIGHT 0x80
|
||||||
|
#define BUTTON_SLIDE_TOP 0x100
|
||||||
|
#define BUTTON_SLIDE_BOTTOM 0x200
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* GUI Image state */
|
/* GUI Image state */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
#define IMAGE_VISIBLE 0x01
|
#define IMAGE_VISIBLE 0x01
|
||||||
#define IMAGE_REPEAT 0x02
|
#define IMAGE_REPEAT 0x02
|
||||||
#define IMAGE_FADE 0x10
|
#define IMAGE_FADE 0x04
|
||||||
#define IMAGE_SLIDE_X 0x20
|
#define IMAGE_SLIDE_LEFT 0x08
|
||||||
#define IMAGE_SLIDE_Y 0x40
|
#define IMAGE_SLIDE_RIGHT 0x10
|
||||||
|
#define IMAGE_SLIDE_TOP 0x20
|
||||||
|
#define IMAGE_SLIDE_BOTTOM 0x40
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* GUI png data */
|
/* GUI png data */
|
||||||
@ -186,7 +193,7 @@ typedef struct
|
|||||||
u16 h; /* item image or text height */
|
u16 h; /* item image or text height */
|
||||||
} gui_item;
|
} gui_item;
|
||||||
|
|
||||||
/* Button descriptor */
|
/* Button Data descriptor */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
gx_texture *texture[2]; /* temporary texture datas */
|
gx_texture *texture[2]; /* temporary texture datas */
|
||||||
@ -197,7 +204,7 @@ typedef struct
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
butn_data *data; /* pointer to button image/texture data */
|
butn_data *data; /* pointer to button image/texture data */
|
||||||
u8 state; /* button state (ACTIVE,VISIBLE,SELECTED...) */
|
u16 state; /* button state (ACTIVE,VISIBLE,SELECTED...) */
|
||||||
u8 shift[4]; /* direction offsets */
|
u8 shift[4]; /* direction offsets */
|
||||||
u16 x; /* button image X position (upper left corner) */
|
u16 x; /* button image X position (upper left corner) */
|
||||||
u16 y; /* button image Y position (upper left corner) */
|
u16 y; /* button image Y position (upper left corner) */
|
||||||
@ -216,8 +223,6 @@ typedef struct
|
|||||||
u16 w; /* image width */
|
u16 w; /* image width */
|
||||||
u16 h; /* image height */
|
u16 h; /* image height */
|
||||||
u8 alpha; /* alpha transparency */
|
u8 alpha; /* alpha transparency */
|
||||||
u16 xrange[2]; /* image X range (slide effect) */
|
|
||||||
u16 yrange[2]; /* image Y range (slide effect) */
|
|
||||||
} gui_image;
|
} gui_image;
|
||||||
|
|
||||||
/* Menu descriptor */
|
/* Menu descriptor */
|
||||||
@ -248,11 +253,12 @@ extern gx_texture *w_pointer;
|
|||||||
|
|
||||||
|
|
||||||
extern void MainMenu(void);
|
extern void MainMenu(void);
|
||||||
|
extern void GUI_FadeOut();
|
||||||
extern void GUI_InitMenu(gui_menu *menu);
|
extern void GUI_InitMenu(gui_menu *menu);
|
||||||
extern void GUI_DeleteMenu(gui_menu *menu);
|
extern void GUI_DeleteMenu(gui_menu *menu);
|
||||||
extern void GUI_DrawMenu(gui_menu *menu);
|
extern void GUI_DrawMenu(gui_menu *menu);
|
||||||
extern void GUI_DrawMenuFX(gui_menu *menu, u8 speed, u8 out);
|
extern void GUI_DrawMenuFX(gui_menu *menu, u8 speed, u8 out);
|
||||||
extern void GUI_FadeMenu(gui_menu *menu, u8 speed, u8 out);
|
extern int GUI_UpdateMenu(gui_menu *menu);
|
||||||
extern int GUI_RunMenu(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 int GUI_WindowPrompt(gui_menu *parent, char *title, char *items[], u8 nb_items);
|
||||||
#endif
|
#endif
|
||||||
|
@ -73,8 +73,8 @@ static int held_cnt = 0;
|
|||||||
/* default directions mapping */
|
/* default directions mapping */
|
||||||
static u32 wpad_dirmap[3][4] =
|
static u32 wpad_dirmap[3][4] =
|
||||||
{
|
{
|
||||||
{WPAD_BUTTON_RIGHT, WPAD_BUTTON_LEFT, WPAD_BUTTON_UP, WPAD_BUTTON_DOWN}, /* WIIMOTE */
|
{WPAD_BUTTON_RIGHT, WPAD_BUTTON_LEFT, WPAD_BUTTON_UP, WPAD_BUTTON_DOWN}, /* WIIMOTE */
|
||||||
{WPAD_BUTTON_UP, WPAD_BUTTON_DOWN, WPAD_BUTTON_LEFT, WPAD_BUTTON_RIGHT}, /* WIIMOTE + NUNCHUK */
|
{WPAD_BUTTON_UP, WPAD_BUTTON_DOWN, WPAD_BUTTON_LEFT, WPAD_BUTTON_RIGHT}, /* WIIMOTE + NUNCHUK */
|
||||||
{WPAD_CLASSIC_BUTTON_UP, WPAD_CLASSIC_BUTTON_DOWN, WPAD_CLASSIC_BUTTON_LEFT, WPAD_CLASSIC_BUTTON_RIGHT} /* CLASSIC */
|
{WPAD_CLASSIC_BUTTON_UP, WPAD_CLASSIC_BUTTON_DOWN, WPAD_CLASSIC_BUTTON_LEFT, WPAD_CLASSIC_BUTTON_RIGHT} /* CLASSIC */
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@ -96,11 +96,7 @@ static void pad_config(int chan, int max_keys)
|
|||||||
WaitPrompt(msg);
|
WaitPrompt(msg);
|
||||||
|
|
||||||
/* remove any pending keys */
|
/* remove any pending keys */
|
||||||
while (PAD_ButtonsHeld(chan))
|
while (m_input.keys) VIDEO_WaitVSync();
|
||||||
{
|
|
||||||
VIDEO_WaitVSync();
|
|
||||||
PAD_ScanPads();
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,12 +333,7 @@ static void wpad_config(u8 chan, u8 exp, u8 max_keys)
|
|||||||
WaitPrompt(msg);
|
WaitPrompt(msg);
|
||||||
|
|
||||||
/* remove any pending buttons */
|
/* remove any pending buttons */
|
||||||
while (WPAD_ButtonsHeld(chan))
|
while (m_input.keys) VIDEO_WaitVSync();
|
||||||
{
|
|
||||||
WPAD_ScanPads();
|
|
||||||
VIDEO_WaitVSync();
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ int main (int argc, char *argv[])
|
|||||||
gx_audio_Init();
|
gx_audio_Init();
|
||||||
|
|
||||||
/* initialize core engine */
|
/* initialize core engine */
|
||||||
legal();
|
// legal();
|
||||||
config_default();
|
config_default();
|
||||||
history_default();
|
history_default();
|
||||||
init_machine();
|
init_machine();
|
||||||
|
Loading…
Reference in New Issue
Block a user