[Gamecube/Wii] improved Cheats Menu

This commit is contained in:
EkeEke 2014-06-17 22:07:35 +02:00
parent da32b05777
commit 731b0afcc3
4 changed files with 108 additions and 53 deletions

View File

@ -3,7 +3,7 @@
* *
* Cheats menu * Cheats menu
* *
* Copyright Eke-Eke (2010-2012) * Copyright Eke-Eke (2010-2014)
* *
* Redistribution and use of this code or any derivative works are permitted * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:
@ -46,7 +46,7 @@
#define BG_COLOR_1 {0x49,0x49,0x49,0xff} #define BG_COLOR_1 {0x49,0x49,0x49,0xff}
#define BG_COLOR_2 {0x66,0x66,0x66,0xff} #define BG_COLOR_2 {0x66,0x66,0x66,0xff}
#define MAX_CHEATS (150) #define MAX_CHEATS (350)
#define MAX_DESC_LENGTH (63) #define MAX_DESC_LENGTH (63)
#ifdef HW_RVL #ifdef HW_RVL
@ -853,25 +853,34 @@ void CheatMenu(void)
while (update != -1) while (update != -1)
{ {
/* update arrows buttons */ /* update arrows buttons */
if (offset > 0) m->arrows[0]->state |= BUTTON_VISIBLE; if (offset > 0)
else m->arrows[0]->state &= ~BUTTON_VISIBLE; m->arrows[0]->state |= BUTTON_VISIBLE;
if ((offset + 10) < (maxcheats + 1)) m->arrows[1]->state |= BUTTON_VISIBLE; else
else m->arrows[1]->state &= ~BUTTON_VISIBLE; m->arrows[0]->state &= ~BUTTON_VISIBLE;
if (((offset + 10) < (maxcheats + 1)) && ((offset + 10) < MAX_CHEATS))
m->arrows[1]->state |= BUTTON_VISIBLE;
else
m->arrows[1]->state &= ~BUTTON_VISIBLE;
/* draw menu */ /* draw menu */
GUI_DrawMenu(m); GUI_DrawMenu(m);
/* restore cheats offset */ /* check if browsing cheats list */
if (!(menu_cheats.bg_images[6].state & IMAGE_VISIBLE)) if (!(m->bg_images[6].state & IMAGE_VISIBLE))
{ {
/* restore cheats list offset */
m->offset = offset; m->offset = offset;
m->max_items = maxcheats + 1; m->max_items = (maxcheats < MAX_CHEATS) ? (maxcheats + 1) : MAX_CHEATS;
m->max_buttons = 10; m->max_buttons = 10;
m->helpers[1] = NULL;
} }
/* update menu */ /* update menu */
update = GUI_UpdateMenu(m); update = GUI_UpdateMenu(m);
/* check if browsing cheats list */
if (!(m->bg_images[6].state & IMAGE_VISIBLE))
{
/* update selected cheat */ /* update selected cheat */
if ((m->selected < 10) && (selection != m->selected)) if ((m->selected < 10) && (selection != m->selected))
{ {
@ -879,12 +888,17 @@ void CheatMenu(void)
string_offset = 0; string_offset = 0;
} }
/* save offset then restore default */ /* save cheats list offset */
if (!(m->bg_images[6].state & IMAGE_VISIBLE)) if (offset != m->offset)
{ {
offset = m->offset; offset = m->offset;
string_offset = 0;
}
/* restore default GUI settings */
m->offset = 0; m->offset = 0;
m->max_items = m->max_buttons = 30; m->max_items = m->max_buttons = 30;
m->helpers[1] = &action_select;
} }
@ -1193,6 +1207,8 @@ void CheatMenu(void)
{ {
/* Special inputs */ /* Special inputs */
if (m_input.keys & PAD_TRIGGER_R) if (m_input.keys & PAD_TRIGGER_R)
{
if (GUI_WaitConfirm("Warning","Delete Cheat Entry ?"))
{ {
/* sort cheat list */ /* sort cheat list */
for (i = offset + selection + 1; i < maxcheats; i++) for (i = offset + selection + 1; i < maxcheats; i++)
@ -1224,6 +1240,7 @@ void CheatMenu(void)
/* reset scrolling */ /* reset scrolling */
string_offset = 0; string_offset = 0;
} }
}
else if (m_input.keys & PAD_TRIGGER_L) else if (m_input.keys & PAD_TRIGGER_L)
{ {
/* cheat ON/OFF */ /* cheat ON/OFF */

View File

@ -3,7 +3,7 @@
* *
* Cheats menu * Cheats menu
* *
* Copyright Eke-Eke (2010-2012) * Copyright Eke-Eke (2010-2014)
* *
* Redistribution and use of this code or any derivative works are permitted * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:

View File

@ -1770,9 +1770,18 @@ static void *MsgBox_Thread(gui_message *message_box)
/* draw exit message */ /* draw exit message */
if (message_box->buttonA) if (message_box->buttonA)
{ {
FONT_writeCenter("Press to continue.",18,166,166+message_box->window->width,248+22,(GXColor)WHITE); if (message_box->buttonB)
{
FONT_writeCenter(" Confirm Cancel ",18,166,166+message_box->window->width,248+18+8,(GXColor)WHITE);
gxDrawTexture(message_box->buttonA, 166+56, 248+8+(18-message_box->buttonA->height)/2,message_box->buttonA->width, message_box->buttonA->height,255);
gxDrawTexture(message_box->buttonB, 166+166, 248+8+(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+18+4,(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); 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 */ /* update display */
gxSetScreen(); gxSetScreen();
@ -1936,6 +1945,7 @@ void GUI_MsgBoxClose(void)
gxTextureClose(&message_box.window); gxTextureClose(&message_box.window);
gxTextureClose(&message_box.top); gxTextureClose(&message_box.top);
gxTextureClose(&message_box.buttonA); gxTextureClose(&message_box.buttonA);
gxTextureClose(&message_box.buttonB);
gxTextureClose(&message_box.throbber); gxTextureClose(&message_box.throbber);
} }
} }
@ -1964,6 +1974,32 @@ void GUI_WaitPrompt(char *title, char *msg)
GUI_MsgBoxClose(); GUI_MsgBoxClose();
} }
int GUI_WaitConfirm(char *title, char *msg)
{
/* clear unused texture */
gxTextureClose(&message_box.throbber);
/* open or update message box */
GUI_MsgBoxOpen(title, msg, 0);
/* allocate texture */
message_box.buttonA = gxTextureOpenPNG(Key_A_png,0);
message_box.buttonB = gxTextureOpenPNG(Key_B_png,0);
/* wait for button A or Button B*/
while (m_input.keys & (PAD_BUTTON_A | PAD_BUTTON_B))
VIDEO_WaitVSync();
while (!(m_input.keys & (PAD_BUTTON_A | PAD_BUTTON_B)))
VIDEO_WaitVSync();
int ret = m_input.keys & PAD_BUTTON_A;
/* always close message box */
GUI_MsgBoxClose();
return ret;
}
/* Basic Fading */ /* Basic Fading */
void GUI_FadeOut() void GUI_FadeOut()
{ {

View File

@ -120,11 +120,11 @@ typedef struct
typedef struct typedef struct
{ {
char title[64]; /* menu title */ char title[64]; /* menu title */
s8 selected; /* index of selected item */ int selected; /* index of selected item */
s8 offset; /* items list offset */ int offset; /* items list offset */
u8 max_items; /* total number of items */ int max_items; /* total number of items */
u8 max_buttons; /* total number of buttons */ int max_buttons; /* total number of buttons */
u8 max_images; /* total number of background images */ int max_images; /* total number of background images */
u8 screenshot; /* game screen background */ u8 screenshot; /* game screen background */
gui_item *items; /* menu items */ gui_item *items; /* menu items */
gui_butn *buttons; /* menu buttons */ gui_butn *buttons; /* menu buttons */
@ -144,6 +144,7 @@ typedef struct
gx_texture *window; /* pointer to box texture */ gx_texture *window; /* pointer to box texture */
gx_texture *top; /* pointer to box title texture */ gx_texture *top; /* pointer to box title texture */
gx_texture *buttonA; /* pointer to button A texture */ gx_texture *buttonA; /* pointer to button A texture */
gx_texture *buttonB; /* pointer to button A texture */
gx_texture *throbber; /* pointer to throbber texture */ gx_texture *throbber; /* pointer to throbber texture */
} gui_message; } gui_message;
@ -238,6 +239,7 @@ extern void GUI_MsgBoxOpen(char *title, char *msg, bool throbber);
extern void GUI_MsgBoxUpdate(char *title, char *msg); extern void GUI_MsgBoxUpdate(char *title, char *msg);
extern void GUI_MsgBoxClose(void); extern void GUI_MsgBoxClose(void);
extern void GUI_WaitPrompt(char *title, char *msg); extern void GUI_WaitPrompt(char *title, char *msg);
extern int GUI_WaitConfirm(char *title, char *msg);
extern void GUI_FadeOut(); extern void GUI_FadeOut();
extern GXColor *GUI_GetBgColor(void); extern GXColor *GUI_GetBgColor(void);
extern void GUI_SetBgColor(u8 color); extern void GUI_SetBgColor(u8 color);