2009-04-15 17:33:51 +02:00
|
|
|
/****************************************************************************
|
2009-05-13 16:26:55 +02:00
|
|
|
* gui.c
|
2009-04-15 17:33:51 +02:00
|
|
|
*
|
2010-11-01 19:13:17 +01:00
|
|
|
* generic GUI Engine (using GX rendering)
|
2009-04-15 17:33:51 +02:00
|
|
|
*
|
2010-11-01 19:13:17 +01:00
|
|
|
* Eke-Eke (2009,2010)
|
2009-04-15 17:33:51 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
2009-05-13 16:26:55 +02:00
|
|
|
#ifndef _GUI_H
|
|
|
|
#define _GUI_H
|
2009-04-15 17:33:51 +02:00
|
|
|
|
|
|
|
#ifdef HW_RVL
|
|
|
|
#include <wiiuse/wpad.h>
|
|
|
|
#endif
|
|
|
|
|
2010-11-01 19:13:17 +01:00
|
|
|
#define BG_COLOR_MAX 15
|
|
|
|
|
2009-04-20 00:31:08 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* GUI Buttons state */
|
|
|
|
/*****************************************************************************/
|
2009-05-04 23:43:16 +02:00
|
|
|
#define BUTTON_VISIBLE 0x01
|
2009-05-25 09:46:19 +02:00
|
|
|
#define BUTTON_ACTIVE 0x02
|
2010-05-06 14:59:43 +02:00
|
|
|
#define BUTTON_SELECTED 0x04
|
|
|
|
#define BUTTON_OVER_SFX 0x08
|
2009-05-04 23:43:16 +02:00
|
|
|
#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
|
2009-04-20 00:31:08 +02:00
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* GUI Image state */
|
|
|
|
/*****************************************************************************/
|
2009-05-04 23:43:16 +02:00
|
|
|
#define IMAGE_VISIBLE 0x01
|
|
|
|
#define IMAGE_REPEAT 0x02
|
|
|
|
#define IMAGE_FADE 0x04
|
|
|
|
#define IMAGE_SLIDE_LEFT 0x08
|
|
|
|
#define IMAGE_SLIDE_RIGHT 0x10
|
|
|
|
#define IMAGE_SLIDE_TOP 0x20
|
|
|
|
#define IMAGE_SLIDE_BOTTOM 0x40
|
2009-04-20 00:31:08 +02:00
|
|
|
|
2009-04-15 18:55:11 +02:00
|
|
|
/*****************************************************************************/
|
2009-05-13 16:26:55 +02:00
|
|
|
/* Generic GUI structures */
|
2009-04-15 18:55:11 +02:00
|
|
|
/*****************************************************************************/
|
2009-04-15 17:33:51 +02:00
|
|
|
|
2009-05-13 16:26:55 +02:00
|
|
|
/* Item descriptor*/
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gx_texture *texture; /* temporary texture data */
|
|
|
|
const u8 *data; /* pointer to png image data (items icon only) */
|
|
|
|
char text[64]; /* item string (items list only) */
|
|
|
|
char comment[64]; /* item comment */
|
|
|
|
u16 x; /* item image or text X position (upper left corner) */
|
|
|
|
u16 y; /* item image or text Y position (upper left corner) */
|
|
|
|
u16 w; /* item image or text width */
|
|
|
|
u16 h; /* item image or text height */
|
|
|
|
} gui_item;
|
|
|
|
|
|
|
|
/* Button Data descriptor */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gx_texture *texture[2]; /* temporary texture datas */
|
|
|
|
const u8 *image[2]; /* pointer to png image datas (default) */
|
|
|
|
} butn_data;
|
|
|
|
|
|
|
|
/* Button descriptor */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
butn_data *data; /* pointer to button image/texture data */
|
|
|
|
u16 state; /* button state (ACTIVE,VISIBLE,SELECTED...) */
|
|
|
|
u8 shift[4]; /* direction offsets */
|
|
|
|
u16 x; /* button image X position (upper left corner) */
|
|
|
|
u16 y; /* button image Y position (upper left corner) */
|
|
|
|
u16 w; /* button image pixels width */
|
|
|
|
u16 h; /* button image pixels height */
|
|
|
|
} gui_butn;
|
|
|
|
|
|
|
|
/* Image descriptor */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gx_texture *texture; /* temporary texture data */
|
|
|
|
const u8 *data; /* pointer to png image data */
|
|
|
|
u8 state; /* image state (VISIBLE) */
|
|
|
|
u16 x; /* image X position (upper left corner) */
|
|
|
|
u16 y; /* image Y position (upper left corner) */
|
|
|
|
u16 w; /* image width */
|
|
|
|
u16 h; /* image height */
|
|
|
|
u8 alpha; /* alpha transparency */
|
|
|
|
} gui_image;
|
|
|
|
|
|
|
|
/* Menu descriptor */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char title[64]; /* menu title */
|
|
|
|
s8 selected; /* index of selected item */
|
|
|
|
s8 offset; /* items list offset */
|
|
|
|
u8 max_items; /* total number of items */
|
|
|
|
u8 max_buttons; /* total number of buttons */
|
|
|
|
u8 max_images; /* total number of background images */
|
2009-12-30 16:31:50 +01:00
|
|
|
u8 screenshot; /* game screen background */
|
2009-05-13 16:26:55 +02:00
|
|
|
gui_item *items; /* menu items */
|
|
|
|
gui_butn *buttons; /* menu buttons */
|
|
|
|
gui_image *bg_images; /* background images */
|
|
|
|
gui_item *helpers[2]; /* left & right key comments */
|
|
|
|
gui_butn *arrows[2]; /* arrows buttons */
|
2010-05-06 14:59:43 +02:00
|
|
|
void (*cb)(void); /* specific draw callback */
|
2009-05-13 16:26:55 +02:00
|
|
|
} gui_menu;
|
|
|
|
|
2009-05-19 18:14:43 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2009-05-23 19:29:53 +02:00
|
|
|
u32 progress; /* progress counter */
|
|
|
|
bool refresh; /* messagebox current state */
|
|
|
|
gui_menu *parent; /* parent menu */
|
|
|
|
char title[64]; /* box title */
|
|
|
|
char msg[64]; /* box message */
|
|
|
|
gx_texture *window; /* pointer to box texture */
|
|
|
|
gx_texture *top; /* pointer to box title texture */
|
|
|
|
gx_texture *buttonA; /* pointer to button A texture */
|
|
|
|
gx_texture *throbber; /* pointer to throbber texture */
|
2009-05-19 18:14:43 +02:00
|
|
|
} gui_message;
|
|
|
|
|
2009-05-25 12:41:16 +02:00
|
|
|
/* Menu inputs */
|
2009-05-13 16:26:55 +02:00
|
|
|
struct t_input_menu
|
|
|
|
{
|
|
|
|
u16 keys;
|
|
|
|
#ifdef HW_RVL
|
|
|
|
struct ir_t ir;
|
|
|
|
#endif
|
|
|
|
} m_input;
|
|
|
|
|
2009-05-25 12:41:16 +02:00
|
|
|
/* Optionbox callback */
|
|
|
|
typedef void (*optioncallback)(void);
|
|
|
|
|
2010-05-06 14:59:43 +02:00
|
|
|
/* Generic textures*/
|
|
|
|
#ifdef HW_RVL
|
|
|
|
extern gx_texture *w_pointer;
|
|
|
|
#endif
|
2009-05-13 16:26:55 +02:00
|
|
|
|
2009-05-02 17:00:13 +02:00
|
|
|
/* Generic backgrounds */
|
2010-07-06 16:03:50 +02:00
|
|
|
extern const u8 Bg_layer_png[];
|
2009-04-15 18:55:11 +02:00
|
|
|
extern const u8 Bg_main_png[];
|
2010-03-22 15:07:25 +01:00
|
|
|
extern const u8 Bg_main_2_png[];
|
2009-04-15 18:55:11 +02:00
|
|
|
extern const u8 Bg_overlay_png[];
|
|
|
|
extern const u8 Banner_main_png[];
|
|
|
|
extern const u8 Banner_bottom_png[];
|
|
|
|
extern const u8 Banner_top_png[];
|
2010-05-06 14:59:43 +02:00
|
|
|
extern const u8 Banner_main_2_png[];
|
|
|
|
extern const u8 Banner_bottom_2_png[];
|
|
|
|
extern const u8 Banner_top_2_png[];
|
2009-05-02 17:00:13 +02:00
|
|
|
extern const u8 Main_logo_png[];
|
2009-04-15 17:33:51 +02:00
|
|
|
|
2009-05-02 17:00:13 +02:00
|
|
|
/* Generic frames */
|
2009-04-15 18:55:11 +02:00
|
|
|
extern const u8 Frame_s1_png[];
|
|
|
|
extern const u8 Frame_s2_png[];
|
2009-05-01 14:56:48 +02:00
|
|
|
extern const u8 Frame_s3_png[];
|
|
|
|
extern const u8 Frame_s1_title_png[];
|
2010-11-01 19:13:17 +01:00
|
|
|
extern const u8 Frame_s2_title_png[];
|
2009-05-23 19:29:53 +02:00
|
|
|
extern const u8 Frame_throbber_png[];
|
2009-04-15 17:33:51 +02:00
|
|
|
|
2009-05-02 17:00:13 +02:00
|
|
|
/* Generic Buttons */
|
2009-04-15 18:55:11 +02:00
|
|
|
extern const u8 Button_text_png[];
|
|
|
|
extern const u8 Button_text_over_png[];
|
|
|
|
extern const u8 Button_icon_png[];
|
|
|
|
extern const u8 Button_icon_over_png[];
|
2009-05-02 17:00:13 +02:00
|
|
|
extern const u8 Button_icon_sm_png[];
|
|
|
|
extern const u8 Button_icon_sm_over_png[];
|
2009-04-15 18:55:11 +02:00
|
|
|
extern const u8 Button_up_png[];
|
|
|
|
extern const u8 Button_up_over_png[];
|
2009-12-30 16:31:50 +01:00
|
|
|
extern const u8 Button_down_png[];
|
2009-04-15 18:55:11 +02:00
|
|
|
extern const u8 Button_down_over_png[];
|
2009-12-30 16:31:50 +01:00
|
|
|
extern const u8 Button_arrow_png[];
|
|
|
|
extern const u8 Button_arrow_over_png[];
|
2010-11-01 19:13:17 +01:00
|
|
|
extern const u8 Button_digit_png[];
|
|
|
|
extern const u8 Button_digit_over_png[];
|
2009-04-15 17:33:51 +02:00
|
|
|
|
2009-05-02 17:00:13 +02:00
|
|
|
/* Generic images*/
|
|
|
|
#ifdef HW_RVL
|
2009-05-19 18:14:43 +02:00
|
|
|
#define Key_A_png Key_A_wii_png
|
|
|
|
#define Key_B_png Key_B_wii_png
|
2009-05-02 17:00:13 +02:00
|
|
|
extern const u8 generic_point_png[];
|
2009-04-15 18:55:11 +02:00
|
|
|
extern const u8 Key_A_wii_png[];
|
|
|
|
extern const u8 Key_B_wii_png[];
|
2009-04-15 17:33:51 +02:00
|
|
|
#else
|
2009-05-19 18:14:43 +02:00
|
|
|
#define Key_A_png Key_A_gcn_png
|
|
|
|
#define Key_B_png Key_B_gcn_png
|
2009-04-15 18:55:11 +02:00
|
|
|
extern const u8 Key_A_gcn_png[];
|
|
|
|
extern const u8 Key_B_gcn_png[];
|
2009-04-15 17:33:51 +02:00
|
|
|
#endif
|
2010-11-01 19:13:17 +01:00
|
|
|
extern const u8 Star_full_png[];
|
|
|
|
extern const u8 Star_empty_png[];
|
|
|
|
extern const u8 Overlay_bar_png[];
|
2009-04-15 17:33:51 +02:00
|
|
|
|
2009-05-13 16:26:55 +02:00
|
|
|
/* Generic Sounds */
|
|
|
|
extern const u8 button_over_pcm[];
|
2009-04-15 18:55:11 +02:00
|
|
|
extern const u8 button_select_pcm[];
|
2009-05-13 16:26:55 +02:00
|
|
|
extern const u8 intro_pcm[];
|
2009-04-15 18:55:11 +02:00
|
|
|
extern const u32 button_select_pcm_size;
|
|
|
|
extern const u32 button_over_pcm_size;
|
2009-05-13 16:26:55 +02:00
|
|
|
extern const u32 intro_pcm_size;
|
2009-04-15 18:55:11 +02:00
|
|
|
|
2009-05-19 18:14:43 +02:00
|
|
|
extern u8 SILENT;
|
|
|
|
|
2009-04-20 00:31:08 +02:00
|
|
|
extern void GUI_InitMenu(gui_menu *menu);
|
|
|
|
extern void GUI_DeleteMenu(gui_menu *menu);
|
|
|
|
extern void GUI_DrawMenu(gui_menu *menu);
|
2009-04-21 03:05:56 +02:00
|
|
|
extern void GUI_DrawMenuFX(gui_menu *menu, u8 speed, u8 out);
|
2009-09-27 20:08:33 +02:00
|
|
|
extern void GUI_SlideMenuTitle(gui_menu *m, int title_offset);
|
2009-05-04 23:43:16 +02:00
|
|
|
extern int GUI_UpdateMenu(gui_menu *menu);
|
2009-04-20 00:31:08 +02:00
|
|
|
extern int GUI_RunMenu(gui_menu *menu);
|
2010-05-09 02:53:19 +02:00
|
|
|
extern void GUI_TextWindow(gui_menu *parent, char *title, char items[][64], u8 nb_items, u8 fontsize);
|
2009-09-27 20:08:33 +02:00
|
|
|
extern int GUI_OptionWindow(gui_menu *parent, char *title, char *items[], u8 nb_items);
|
2009-05-25 12:41:16 +02:00
|
|
|
extern void GUI_OptionBox(gui_menu *parent, optioncallback cb, char *title, void *option, float step, float min, float max, u8 type);
|
2009-12-30 16:31:50 +01:00
|
|
|
extern void GUI_OptionBox2(gui_menu *parent, char *text_1, char *text_2, s16 *option_1, s16 *option_2, s16 step, s16 min, s16 max);
|
2009-05-23 19:29:53 +02:00
|
|
|
extern void GUI_MsgBoxOpen(char *title, char *msg, bool throbber);
|
2009-05-26 15:14:33 +02:00
|
|
|
extern void GUI_MsgBoxUpdate(char *title, char *msg);
|
2009-05-19 18:14:43 +02:00
|
|
|
extern void GUI_MsgBoxClose(void);
|
|
|
|
extern void GUI_WaitPrompt(char *title, char *msg);
|
|
|
|
extern void GUI_FadeOut();
|
2010-03-22 15:07:25 +01:00
|
|
|
extern GXColor *GUI_GetBgColor(void);
|
|
|
|
extern void GUI_SetBgColor(u8 color);
|
2009-05-19 18:14:43 +02:00
|
|
|
extern void GUI_Initialize(void);
|
2009-05-13 16:26:55 +02:00
|
|
|
|
2009-04-15 17:33:51 +02:00
|
|
|
#endif
|