2009-04-05 03:51:56 +02:00
/*!\mainpage libwiigui Documentation
2009-03-11 18:28:37 +01:00
*
2009-04-05 03:51:56 +02:00
* \ section Introduction
* libwiigui is a GUI library for the Wii , created to help structure the
* design of a complicated GUI interface , and to enable an author to create
* a sophisticated , feature - rich GUI . It was originally conceived and written
* after I started to design a GUI for Snes9x GX , and found libwiisprite and
* GRRLIB inadequate for the purpose . It uses GX for drawing , and makes use
* of PNGU for displaying images and FreeTypeGX for text . It was designed to
* be flexible and is easy to modify - don ' t be afraid to change the way it
* works or expand it to suit your GUI ' s purposes ! If you do , and you think
* your changes might benefit others , please share them so they might be
* added to the project !
2009-03-11 18:28:37 +01:00
*
2009-04-05 03:51:56 +02:00
* \ section Quickstart
* Start from the supplied template example . For more advanced uses , see the
* source code for Snes9x GX , FCE Ultra GX , and Visual Boy Advance GX .
* \ section Contact
* If you have any suggestions for the library or documentation , or want to
* contribute , please visit the libwiigui website :
* http : //code.google.com/p/libwiigui/
* \ section Credits
* This library was wholly designed and written by Tantric . Thanks to the
* authors of PNGU and FreeTypeGX , of which this library makes use . Thanks
* also to the authors of GRRLIB and libwiisprite for laying the foundations .
2009-03-11 18:28:37 +01:00
*
2009-04-05 03:51:56 +02:00
*/
2009-03-11 18:28:37 +01:00
2009-04-05 03:51:56 +02:00
# ifndef LIBWIIGUI_H
# define LIBWIIGUI_H
2009-03-11 18:28:37 +01:00
# include <gccore.h>
# include <malloc.h>
# include <stdlib.h>
# include <string.h>
# include <vector>
2009-04-13 10:43:50 +02:00
# include <exception>
2009-05-21 06:17:44 +02:00
# include <wchar.h>
2009-03-11 18:28:37 +01:00
# include <math.h>
# include <asndlib.h>
2009-04-13 10:43:50 +02:00
# include <wiiuse/wpad.h>
2010-03-22 00:43:54 +01:00
# include "snes9xgx.h"
2009-03-11 18:28:37 +01:00
# include "video.h"
# include "filelist.h"
# include "fileop.h"
2009-04-13 10:43:50 +02:00
# include "input.h"
2010-03-22 00:43:54 +01:00
# include "../utils/pngu.h"
# include "../utils/FreeTypeGX.h"
# include "../utils/oggplayer.h"
2009-03-11 18:28:37 +01:00
2009-07-08 09:14:18 +02:00
extern FreeTypeGX * fontSystem [ ] ;
2009-04-13 10:43:50 +02:00
2009-11-05 05:39:14 +01:00
# define SCROLL_DELAY_INITIAL 200000
# define SCROLL_DELAY_LOOP 30000
# define SCROLL_DELAY_DECREASE 300
2009-06-18 07:47:02 +02:00
# define FILE_PAGESIZE 10
# define PAGESIZE 8
# define SAVELISTSIZE 6
2009-09-15 08:56:15 +02:00
# define MAX_SAVES 100
2009-07-09 06:12:28 +02:00
# define MAX_OPTIONS 150
2009-07-08 07:56:38 +02:00
# define MAX_KEYBOARD_DISPLAY 32
2009-03-11 18:28:37 +01:00
typedef void ( * UpdateCallback ) ( void * e ) ;
enum
{
ALIGN_LEFT ,
ALIGN_RIGHT ,
ALIGN_CENTRE ,
ALIGN_TOP ,
ALIGN_BOTTOM ,
ALIGN_MIDDLE
} ;
enum
{
STATE_DEFAULT ,
STATE_SELECTED ,
STATE_CLICKED ,
2009-04-10 10:12:37 +02:00
STATE_HELD ,
2009-03-11 18:28:37 +01:00
STATE_DISABLED
} ;
enum
{
SOUND_PCM ,
SOUND_OGG
} ;
enum
{
IMAGE_TEXTURE ,
IMAGE_COLOR ,
IMAGE_DATA
} ;
2009-04-13 10:43:50 +02:00
enum
{
TRIGGER_SIMPLE ,
TRIGGER_HELD ,
TRIGGER_BUTTON_ONLY ,
TRIGGER_BUTTON_ONLY_IN_FOCUS
} ;
2009-06-27 21:38:39 +02:00
enum
{
SCROLL_NONE ,
SCROLL_HORIZONTAL
} ;
2009-04-13 10:43:50 +02:00
typedef struct _paddata {
u16 btns_d ;
u16 btns_u ;
u16 btns_h ;
s8 stickX ;
s8 stickY ;
s8 substickX ;
s8 substickY ;
u8 triggerL ;
u8 triggerR ;
} PADData ;
2009-03-11 18:28:37 +01:00
# define EFFECT_SLIDE_TOP 1
# define EFFECT_SLIDE_BOTTOM 2
# define EFFECT_SLIDE_RIGHT 4
# define EFFECT_SLIDE_LEFT 8
# define EFFECT_SLIDE_IN 16
# define EFFECT_SLIDE_OUT 32
# define EFFECT_FADE 64
# define EFFECT_SCALE 128
# define EFFECT_COLOR_TRANSITION 256
2009-04-05 03:51:56 +02:00
//!Sound conversion and playback. A wrapper for other sound libraries - ASND, libmad, ltremor, etc
2009-03-11 18:28:37 +01:00
class GuiSound
{
public :
2009-04-05 03:51:56 +02:00
//!Constructor
//!\param s Pointer to the sound data
//!\param l Length of sound data
//!\param t Sound format type (SOUND_PCM or SOUND_OGG)
2009-10-17 02:15:58 +02:00
GuiSound ( const u8 * s , s32 l , int t ) ;
2009-04-05 03:51:56 +02:00
//!Destructor
2009-03-11 18:28:37 +01:00
~ GuiSound ( ) ;
2009-04-05 03:51:56 +02:00
//!Start sound playback
2009-03-11 18:28:37 +01:00
void Play ( ) ;
2009-04-05 03:51:56 +02:00
//!Stop sound playback
2009-03-11 18:28:37 +01:00
void Stop ( ) ;
2009-04-05 03:51:56 +02:00
//!Pause sound playback
2009-03-11 18:28:37 +01:00
void Pause ( ) ;
2009-04-05 03:51:56 +02:00
//!Resume sound playback
2009-03-11 18:28:37 +01:00
void Resume ( ) ;
2009-04-05 03:51:56 +02:00
//!Checks if the sound is currently playing
//!\return true if sound is playing, false otherwise
bool IsPlaying ( ) ;
//!Set sound volume
//!\param v Sound volume (0-100)
2009-03-11 18:28:37 +01:00
void SetVolume ( int v ) ;
2009-04-05 03:51:56 +02:00
//!Set the sound to loop playback (only applies to OGG)
//!\param l Loop (true to loop)
void SetLoop ( bool l ) ;
2009-03-11 18:28:37 +01:00
protected :
2009-04-05 03:51:56 +02:00
const u8 * sound ; //!< Pointer to the sound data
int type ; //!< Sound format type (SOUND_PCM or SOUND_OGG)
s32 length ; //!< Length of sound data
s32 voice ; //!< Currently assigned ASND voice channel
s32 volume ; //!< Sound volume (0-100)
bool loop ; //!< Loop sound playback
2009-03-11 18:28:37 +01:00
} ;
2009-04-13 10:43:50 +02:00
//!Menu input trigger management. Determine if action is neccessary based on input data by comparing controller input data to a specific trigger element.
class GuiTrigger
{
public :
//!Constructor
GuiTrigger ( ) ;
//!Destructor
~ GuiTrigger ( ) ;
//!Sets a simple trigger. Requires: element is selected, and trigger button is pressed
//!\param ch Controller channel number
//!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately
//!\param gcbtns GameCube controller trigger button(s)
void SetSimpleTrigger ( s32 ch , u32 wiibtns , u16 gcbtns ) ;
//!Sets a held trigger. Requires: element is selected, and trigger button is pressed
//!\param ch Controller channel number
//!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately
//!\param gcbtns GameCube controller trigger button(s)
void SetHeldTrigger ( s32 ch , u32 wiibtns , u16 gcbtns ) ;
//!Sets a button-only trigger. Requires: Trigger button is pressed
//!\param ch Controller channel number
//!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately
//!\param gcbtns GameCube controller trigger button(s)
void SetButtonOnlyTrigger ( s32 ch , u32 wiibtns , u16 gcbtns ) ;
//!Sets a button-only trigger. Requires: trigger button is pressed and parent window of element is in focus
//!\param ch Controller channel number
//!\param wiibtns Wii controller trigger button(s) - classic controller buttons are considered separately
//!\param gcbtns GameCube controller trigger button(s)
void SetButtonOnlyInFocusTrigger ( s32 ch , u32 wiibtns , u16 gcbtns ) ;
2009-10-15 08:51:38 +02:00
//!Get X or Y value from Wii Joystick (classic, nunchuk) input
//!\param stick Controller stick (left = 0, right = 1)
2009-04-13 10:43:50 +02:00
//!\param axis Controller stick axis (x-axis = 0, y-axis = 1)
//!\return Stick value
2009-10-15 08:51:38 +02:00
s8 WPAD_Stick ( u8 stick , int axis ) ;
//!Get X value from Wii Joystick (classic, nunchuk) input
//!\param stick Controller stick (left = 0, right = 1)
//!\return Stick value
s8 WPAD_StickX ( u8 stick ) ;
//!Get Y value from Wii Joystick (classic, nunchuk) input
//!\param stick Controller stick (left = 0, right = 1)
//!\return Stick value
s8 WPAD_StickY ( u8 stick ) ;
2009-04-13 10:43:50 +02:00
//!Move menu selection left (via pad/joystick). Allows scroll delay and button overriding
//!\return true if selection should be moved left, false otherwise
bool Left ( ) ;
//!Move menu selection right (via pad/joystick). Allows scroll delay and button overriding
//!\return true if selection should be moved right, false otherwise
bool Right ( ) ;
//!Move menu selection up (via pad/joystick). Allows scroll delay and button overriding
//!\return true if selection should be moved up, false otherwise
bool Up ( ) ;
//!Move menu selection down (via pad/joystick). Allows scroll delay and button overriding
//!\return true if selection should be moved down, false otherwise
bool Down ( ) ;
2009-10-13 02:48:00 +02:00
WPADData wpaddata ; //!< Wii controller trigger data
2009-04-13 10:43:50 +02:00
PADData pad ; //!< GameCube controller trigger data
2010-01-25 08:34:45 +01:00
WPADData * wpad ; //!< Wii controller trigger
s32 chan ; //!< Trigger controller channel (0-3, -1 for all)
u8 type ; //!< trigger type (TRIGGER_SIMPLE, TRIGGER_HELD, TRIGGER_BUTTON_ONLY, TRIGGER_BUTTON_ONLY_IN_FOCUS)
2009-04-13 10:43:50 +02:00
} ;
extern GuiTrigger userInput [ 4 ] ;
//!Primary GUI class. Most other classes inherit from this class.
2009-03-11 18:28:37 +01:00
class GuiElement
{
public :
2009-04-05 03:51:56 +02:00
//!Constructor
2009-03-11 18:28:37 +01:00
GuiElement ( ) ;
2009-04-05 03:51:56 +02:00
//!Destructor
2009-03-11 18:28:37 +01:00
~ GuiElement ( ) ;
2009-04-05 03:51:56 +02:00
//!Set the element's parent
//!\param e Pointer to parent element
2009-03-11 18:28:37 +01:00
void SetParent ( GuiElement * e ) ;
2009-04-15 08:31:58 +02:00
//!Gets the element's parent
//!\return Pointer to parent element
GuiElement * GetParent ( ) ;
2009-04-05 03:51:56 +02:00
//!Gets the current leftmost coordinate of the element
//!Considers horizontal alignment, x offset, width, and parent element's GetLeft() / GetWidth() values
//!\return left coordinate
2009-03-11 18:28:37 +01:00
int GetLeft ( ) ;
2009-04-05 03:51:56 +02:00
//!Gets the current topmost coordinate of the element
//!Considers vertical alignment, y offset, height, and parent element's GetTop() / GetHeight() values
//!\return top coordinate
2009-03-11 18:28:37 +01:00
int GetTop ( ) ;
2009-04-10 10:12:37 +02:00
//!Sets the minimum y offset of the element
//!\param y Y offset
void SetMinY ( int y ) ;
//!Gets the minimum y offset of the element
//!\return Minimum Y offset
int GetMinY ( ) ;
//!Sets the maximum y offset of the element
//!\param y Y offset
void SetMaxY ( int y ) ;
//!Gets the maximum y offset of the element
//!\return Maximum Y offset
int GetMaxY ( ) ;
//!Sets the minimum x offset of the element
//!\param x X offset
void SetMinX ( int x ) ;
//!Gets the minimum x offset of the element
//!\return Minimum X offset
int GetMinX ( ) ;
//!Sets the maximum x offset of the element
//!\param x X offset
void SetMaxX ( int x ) ;
//!Gets the maximum x offset of the element
//!\return Maximum X offset
int GetMaxX ( ) ;
2009-04-05 03:51:56 +02:00
//!Gets the current width of the element. Does not currently consider the scale
//!\return width
2009-03-11 18:28:37 +01:00
int GetWidth ( ) ;
2009-04-05 03:51:56 +02:00
//!Gets the height of the element. Does not currently consider the scale
//!\return height
2009-03-11 18:28:37 +01:00
int GetHeight ( ) ;
2009-04-05 03:51:56 +02:00
//!Sets the size (width/height) of the element
//!\param w Width of element
//!\param h Height of element
2009-03-11 18:28:37 +01:00
void SetSize ( int w , int h ) ;
2009-04-05 03:51:56 +02:00
//!Checks whether or not the element is visible
//!\return true if visible, false otherwise
2009-03-11 18:28:37 +01:00
bool IsVisible ( ) ;
2009-04-05 03:51:56 +02:00
//!Checks whether or not the element is selectable
//!\return true if selectable, false otherwise
2009-03-11 18:28:37 +01:00
bool IsSelectable ( ) ;
2009-04-05 03:51:56 +02:00
//!Checks whether or not the element is clickable
//!\return true if clickable, false otherwise
2009-03-11 18:28:37 +01:00
bool IsClickable ( ) ;
2009-04-13 10:43:50 +02:00
//!Checks whether or not the element is holdable
//!\return true if holdable, false otherwise
bool IsHoldable ( ) ;
2009-04-05 03:51:56 +02:00
//!Sets whether or not the element is selectable
//!\param s Selectable
2009-03-11 18:28:37 +01:00
void SetSelectable ( bool s ) ;
2009-04-05 03:51:56 +02:00
//!Sets whether or not the element is clickable
//!\param c Clickable
2009-03-11 18:28:37 +01:00
void SetClickable ( bool c ) ;
2009-04-13 10:43:50 +02:00
//!Sets whether or not the element is holdable
2009-10-17 02:15:58 +02:00
//!\param h Holdable
void SetHoldable ( bool h ) ;
2009-04-05 03:51:56 +02:00
//!Gets the element's current state
//!\return state
2009-03-11 18:28:37 +01:00
int GetState ( ) ;
2009-04-13 10:43:50 +02:00
//!Gets the controller channel that last changed the element's state
//!\return Channel number (0-3, -1 = no channel)
int GetStateChan ( ) ;
2009-04-05 03:51:56 +02:00
//!Sets the element's alpha value
//!\param a alpha value
2009-03-11 18:28:37 +01:00
void SetAlpha ( int a ) ;
2009-04-05 03:51:56 +02:00
//!Gets the element's alpha value
//!Considers alpha, alphaDyn, and the parent element's GetAlpha() value
//!\return alpha
2009-03-11 18:28:37 +01:00
int GetAlpha ( ) ;
2010-04-14 01:34:01 +02:00
//!Sets the element's x and y scale
2009-04-05 03:51:56 +02:00
//!\param s scale (1 is 100%)
2009-03-11 18:28:37 +01:00
void SetScale ( float s ) ;
2010-04-14 01:34:01 +02:00
//!Sets the element's x scale
//!\param s scale (1 is 100%)
void SetScaleX ( float s ) ;
//!Sets the element's y scale
//!\param s scale (1 is 100%)
void SetScaleY ( float s ) ;
//!Sets the element's x and y scale, using the provided max width/height
//!\param w Maximum width
//!\param h Maximum height
void SetScale ( int w , int h ) ;
2009-04-05 03:51:56 +02:00
//!Gets the element's current scale
//!Considers scale, scaleDyn, and the parent element's GetScale() value
2009-03-11 18:28:37 +01:00
float GetScale ( ) ;
2010-04-14 01:34:01 +02:00
//!Gets the element's current x scale
//!Considers scale, scaleDyn, and the parent element's GetScale() value
float GetScaleX ( ) ;
//!Gets the element's current y scale
//!Considers scale, scaleDyn, and the parent element's GetScale() value
float GetScaleY ( ) ;
2009-04-05 03:51:56 +02:00
//!Set a new GuiTrigger for the element
//!\param t Pointer to GuiTrigger
2009-03-11 18:28:37 +01:00
void SetTrigger ( GuiTrigger * t ) ;
2009-04-05 03:51:56 +02:00
//!\overload
//!\param i Index of trigger array to set
//!\param t Pointer to GuiTrigger
2009-03-11 18:28:37 +01:00
void SetTrigger ( u8 i , GuiTrigger * t ) ;
2009-04-05 03:51:56 +02:00
//!Checks whether rumble was requested by the element
//!\return true is rumble was requested, false otherwise
2009-03-16 06:16:20 +01:00
bool Rumble ( ) ;
2009-04-05 03:51:56 +02:00
//!Sets whether or not the element is requesting a rumble event
//!\param r true if requesting rumble, false if not
2009-03-16 06:16:20 +01:00
void SetRumble ( bool r ) ;
2009-04-05 03:51:56 +02:00
//!Set an effect for the element
//!\param e Effect to enable
//!\param a Amount of the effect (usage varies on effect)
//!\param t Target amount of the effect (usage varies on effect)
2009-03-11 18:28:37 +01:00
void SetEffect ( int e , int a , int t = 0 ) ;
2009-04-05 03:51:56 +02:00
//!Sets an effect to be enabled on wiimote cursor over
//!\param e Effect to enable
//!\param a Amount of the effect (usage varies on effect)
//!\param t Target amount of the effect (usage varies on effect)
2009-03-11 18:28:37 +01:00
void SetEffectOnOver ( int e , int a , int t = 0 ) ;
2009-04-05 03:51:56 +02:00
//!Shortcut to SetEffectOnOver(EFFECT_SCALE, 4, 110)
2009-03-11 18:28:37 +01:00
void SetEffectGrow ( ) ;
2009-04-05 03:51:56 +02:00
//!Gets the current element effects
//!\return element effects
2009-03-11 18:28:37 +01:00
int GetEffect ( ) ;
2009-04-05 03:51:56 +02:00
//!Checks whether the specified coordinates are within the element's boundaries
//!\param x X coordinate
//!\param y Y coordinate
//!\return true if contained within, false otherwise
2009-03-11 18:28:37 +01:00
bool IsInside ( int x , int y ) ;
2009-04-05 03:51:56 +02:00
//!Sets the element's position
//!\param x X coordinate
//!\param y Y coordinate
2009-03-11 18:28:37 +01:00
void SetPosition ( int x , int y ) ;
2009-04-05 03:51:56 +02:00
//!Updates the element's effects (dynamic values)
//!Called by Draw(), used for animation purposes
2009-03-11 18:28:37 +01:00
void UpdateEffects ( ) ;
2009-04-05 03:51:56 +02:00
//!Sets a function to called after after Update()
//!Callback function can be used to response to changes in the state of the element, and/or update the element's attributes
2009-03-11 18:28:37 +01:00
void SetUpdateCallback ( UpdateCallback u ) ;
2009-04-05 03:51:56 +02:00
//!Checks whether the element is in focus
//!\return true if element is in focus, false otherwise
2009-03-11 18:28:37 +01:00
int IsFocused ( ) ;
2009-04-05 03:51:56 +02:00
//!Sets the element's visibility
//!\param v Visibility (true = visible)
2009-03-16 06:16:20 +01:00
virtual void SetVisible ( bool v ) ;
2009-04-05 03:51:56 +02:00
//!Sets the element's focus
2009-04-13 10:43:50 +02:00
//!\param f Focus (true = in focus)
2009-03-11 18:28:37 +01:00
virtual void SetFocus ( int f ) ;
2009-04-05 03:51:56 +02:00
//!Sets the element's state
2009-04-13 10:43:50 +02:00
//!\param s State (STATE_DEFAULT, STATE_SELECTED, STATE_CLICKED, STATE_DISABLED)
//!\param c Controller channel (0-3, -1 = none)
virtual void SetState ( int s , int c = - 1 ) ;
2009-04-05 03:51:56 +02:00
//!Resets the element's state to STATE_DEFAULT
2009-03-11 18:28:37 +01:00
virtual void ResetState ( ) ;
2009-04-05 03:51:56 +02:00
//!Gets whether or not the element is in STATE_SELECTED
//!\return true if selected, false otherwise
2009-03-11 18:28:37 +01:00
virtual int GetSelected ( ) ;
2009-04-05 03:51:56 +02:00
//!Sets the element's alignment respective to its parent element
//!\param hor Horizontal alignment (ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTRE)
//!\param vert Vertical alignment (ALIGN_TOP, ALIGN_BOTTOM, ALIGN_MIDDLE)
2009-03-11 18:28:37 +01:00
virtual void SetAlignment ( int hor , int vert ) ;
2010-01-25 09:24:11 +01:00
//!Called when the language has changed, to obtain new text values for all text elements
virtual void ResetText ( ) ;
2009-04-05 03:51:56 +02:00
//!Called constantly to allow the element to respond to the current input data
//!\param t Pointer to a GuiTrigger, containing the current input data from PAD/WPAD
2009-03-11 18:28:37 +01:00
virtual void Update ( GuiTrigger * t ) ;
2009-04-05 03:51:56 +02:00
//!Called constantly to redraw the element
2009-03-11 18:28:37 +01:00
virtual void Draw ( ) ;
2010-01-25 09:24:11 +01:00
//!Called constantly to redraw the element's tooltip
virtual void DrawTooltip ( ) ;
2009-03-11 18:28:37 +01:00
protected :
2010-04-13 08:50:54 +02:00
GuiTrigger * trigger [ 3 ] ; //!< GuiTriggers (input actions) that this element responds to
2010-01-25 08:34:45 +01:00
UpdateCallback updateCB ; //!< Callback function to call when this element is updated
GuiElement * parentElement ; //!< Parent element
2009-04-05 03:51:56 +02:00
int focus ; //!< Element focus (-1 = focus disabled, 0 = not focused, 1 = focused)
int width ; //!< Element width
int height ; //!< Element height
int xoffset ; //!< Element X offset
int yoffset ; //!< Element Y offset
2009-04-10 10:12:37 +02:00
int ymin ; //!< Element's min Y offset allowed
int ymax ; //!< Element's max Y offset allowed
int xmin ; //!< Element's min X offset allowed
int xmax ; //!< Element's max X offset allowed
2009-04-05 03:51:56 +02:00
int xoffsetDyn ; //!< Element X offset, dynamic (added to xoffset value for animation effects)
int yoffsetDyn ; //!< Element Y offset, dynamic (added to yoffset value for animation effects)
int alpha ; //!< Element alpha value (0-255)
int alphaDyn ; //!< Element alpha, dynamic (multiplied by alpha value for blending/fading effects)
2010-04-14 01:34:01 +02:00
f32 xscale ; //!< Element X scale (1 = 100%)
f32 yscale ; //!< Element Y scale (1 = 100%)
2009-04-05 03:51:56 +02:00
f32 scaleDyn ; //!< Element scale, dynamic (multiplied by alpha value for blending/fading effects)
int effects ; //!< Currently enabled effect(s). 0 when no effects are enabled
int effectAmount ; //!< Effect amount. Used by different effects for different purposes
int effectTarget ; //!< Effect target amount. Used by different effects for different purposes
int effectsOver ; //!< Effects to enable when wiimote cursor is over this element. Copied to effects variable on over event
int effectAmountOver ; //!< EffectAmount to set when wiimote cursor is over this element
int effectTargetOver ; //!< EffectTarget to set when wiimote cursor is over this element
int alignmentHor ; //!< Horizontal element alignment, respective to parent element (LEFT, RIGHT, CENTRE)
int alignmentVert ; //!< Horizontal element alignment, respective to parent element (TOP, BOTTOM, MIDDLE)
int state ; //!< Element state (DEFAULT, SELECTED, CLICKED, DISABLED)
2009-04-10 10:12:37 +02:00
int stateChan ; //!< Which controller channel is responsible for the last change in state
2009-04-05 03:51:56 +02:00
bool selectable ; //!< Whether or not this element selectable (can change to SELECTED state)
bool clickable ; //!< Whether or not this element is clickable (can change to CLICKED state)
2009-04-13 10:43:50 +02:00
bool holdable ; //!< Whether or not this element is holdable (can change to HELD state)
2010-01-25 08:34:45 +01:00
bool visible ; //!< Visibility of the element. If false, Draw() is skipped
bool rumble ; //!< Wiimote rumble (on/off) - set to on when this element requests a rumble event
2009-03-11 18:28:37 +01:00
} ;
2009-04-05 03:51:56 +02:00
//!Allows GuiElements to be grouped together into a "window"
2009-03-11 18:28:37 +01:00
class GuiWindow : public GuiElement
{
public :
//!Constructor
GuiWindow ( ) ;
2009-04-05 03:51:56 +02:00
//!\overload
//!\param w Width of window
//!\param h Height of window
2009-03-11 18:28:37 +01:00
GuiWindow ( int w , int h ) ;
2009-04-05 03:51:56 +02:00
//!Destructor
2009-03-11 18:28:37 +01:00
~ GuiWindow ( ) ;
2009-04-05 03:51:56 +02:00
//!Appends a GuiElement to the GuiWindow
//!\param e The GuiElement to append. If it is already in the GuiWindow, it is removed first
2009-03-11 18:28:37 +01:00
void Append ( GuiElement * e ) ;
2009-04-05 03:51:56 +02:00
//!Inserts a GuiElement into the GuiWindow at the specified index
//!\param e The GuiElement to insert. If it is already in the GuiWindow, it is removed first
//!\param i Index in which to insert the element
void Insert ( GuiElement * e , u32 i ) ;
//!Removes the specified GuiElement from the GuiWindow
//!\param e GuiElement to be removed
2009-03-11 18:28:37 +01:00
void Remove ( GuiElement * e ) ;
2009-04-05 03:51:56 +02:00
//!Removes all GuiElements
2009-03-11 18:28:37 +01:00
void RemoveAll ( ) ;
2009-04-05 03:51:56 +02:00
//!Returns the GuiElement at the specified index
//!\param index The index of the element
//!\return A pointer to the element at the index, NULL on error (eg: out of bounds)
2009-03-11 18:28:37 +01:00
GuiElement * GetGuiElementAt ( u32 index ) const ;
2009-04-05 03:51:56 +02:00
//!Returns the size of the list of elements
//!\return The size of the current element list
2009-03-11 18:28:37 +01:00
u32 GetSize ( ) ;
2009-04-05 03:51:56 +02:00
//!Sets the visibility of the window
//!\param v visibility (true = visible)
2009-03-16 06:16:20 +01:00
void SetVisible ( bool v ) ;
2009-04-05 03:51:56 +02:00
//!Resets the window's state to STATE_DEFAULT
2009-03-11 18:28:37 +01:00
void ResetState ( ) ;
2009-04-05 03:51:56 +02:00
//!Sets the window's state
//!\param s State
2009-03-11 18:28:37 +01:00
void SetState ( int s ) ;
2009-04-05 03:51:56 +02:00
//!Gets the index of the GuiElement inside the window that is currently selected
//!\return index of selected GuiElement
2009-03-11 18:28:37 +01:00
int GetSelected ( ) ;
2009-04-05 03:51:56 +02:00
//!Sets the window focus
//!\param f Focus
2009-03-11 18:28:37 +01:00
void SetFocus ( int f ) ;
2009-04-05 03:51:56 +02:00
//!Change the focus to the specified element
//!This is intended for the primary GuiWindow only
//!\param e GuiElement that should have focus
2009-03-11 18:28:37 +01:00
void ChangeFocus ( GuiElement * e ) ;
2009-04-05 03:51:56 +02:00
//!Changes window focus to the next focusable window or element
//!If no element is in focus, changes focus to the first available element
//!If B or 1 button is pressed, changes focus to the next available element
//!This is intended for the primary GuiWindow only
//!\param t Pointer to a GuiTrigger, containing the current input data from PAD/WPAD
2009-03-11 18:28:37 +01:00
void ToggleFocus ( GuiTrigger * t ) ;
2009-04-05 03:51:56 +02:00
//!Moves the selected element to the element to the left or right
//!\param d Direction to move (-1 = left, 1 = right)
2009-03-11 18:28:37 +01:00
void MoveSelectionHor ( int d ) ;
2009-04-05 03:51:56 +02:00
//!Moves the selected element to the element above or below
//!\param d Direction to move (-1 = up, 1 = down)
2009-03-11 18:28:37 +01:00
void MoveSelectionVert ( int d ) ;
2010-01-25 09:24:11 +01:00
//!Resets the text for all contained elements
void ResetText ( ) ;
2009-04-05 03:51:56 +02:00
//!Draws all the elements in this GuiWindow
2009-03-11 18:28:37 +01:00
void Draw ( ) ;
2010-01-25 09:24:11 +01:00
//!Draws all of the tooltips in this GuiWindow
void DrawTooltip ( ) ;
2009-04-05 03:51:56 +02:00
//!Updates the window and all elements contains within
//!Allows the GuiWindow and all elements to respond to the input data specified
//!\param t Pointer to a GuiTrigger, containing the current input data from PAD/WPAD
2009-03-11 18:28:37 +01:00
void Update ( GuiTrigger * t ) ;
protected :
2009-04-05 03:51:56 +02:00
std : : vector < GuiElement * > _elements ; //!< Contains all elements within the GuiWindow
2009-03-11 18:28:37 +01:00
} ;
2009-04-13 10:43:50 +02:00
//!Converts image data into GX-useable RGBA8. Currently designed for use only with PNG files
2009-03-11 18:28:37 +01:00
class GuiImageData
{
public :
2009-04-05 03:51:56 +02:00
//!Constructor
//!Converts the image data to RGBA8 - expects PNG format
//!\param i Image data
2009-03-11 18:28:37 +01:00
GuiImageData ( const u8 * i ) ;
2009-04-05 03:51:56 +02:00
//!Destructor
2009-03-11 18:28:37 +01:00
~ GuiImageData ( ) ;
2009-04-05 03:51:56 +02:00
//!Gets a pointer to the image data
//!\return pointer to image data
2009-03-11 18:28:37 +01:00
u8 * GetImage ( ) ;
2009-04-05 03:51:56 +02:00
//!Gets the image width
//!\return image width
2009-03-11 18:28:37 +01:00
int GetWidth ( ) ;
2009-04-05 03:51:56 +02:00
//!Gets the image height
//!\return image height
2009-03-11 18:28:37 +01:00
int GetHeight ( ) ;
protected :
2009-04-05 03:51:56 +02:00
u8 * data ; //!< Image data
int height ; //!< Height of image
int width ; //!< Width of image
2009-03-11 18:28:37 +01:00
} ;
2009-04-13 10:43:50 +02:00
//!Display, manage, and manipulate images in the GUI
2009-03-11 18:28:37 +01:00
class GuiImage : public GuiElement
{
public :
2009-04-05 03:51:56 +02:00
//!Constructor
2009-04-13 10:43:50 +02:00
GuiImage ( ) ;
//!\overload
2009-04-05 03:51:56 +02:00
//!\param img Pointer to GuiImageData element
2009-03-11 18:28:37 +01:00
GuiImage ( GuiImageData * img ) ;
2009-04-05 03:51:56 +02:00
//!\overload
//!Sets up a new image from the image data specified
//!\param img
//!\param w Image width
//!\param h Image height
2009-03-11 18:28:37 +01:00
GuiImage ( u8 * img , int w , int h ) ;
2009-04-05 03:51:56 +02:00
//!\overload
//!Creates an image filled with the specified color
//!\param w Image width
//!\param h Image height
//!\param c Image color
2009-03-11 18:28:37 +01:00
GuiImage ( int w , int h , GXColor c ) ;
2009-04-05 03:51:56 +02:00
//!Destructor
2009-03-11 18:28:37 +01:00
~ GuiImage ( ) ;
2009-04-05 03:51:56 +02:00
//!Sets the image rotation angle for drawing
//!\param a Angle (in degrees)
2009-03-11 18:28:37 +01:00
void SetAngle ( float a ) ;
2009-04-05 03:51:56 +02:00
//!Sets the number of times to draw the image horizontally
//!\param t Number of times to draw the image
2009-03-11 18:28:37 +01:00
void SetTile ( int t ) ;
2009-04-05 03:51:56 +02:00
//!Constantly called to draw the image
2009-03-11 18:28:37 +01:00
void Draw ( ) ;
2009-04-05 03:51:56 +02:00
//!Gets the image data
//!\return pointer to image data
2009-03-11 18:28:37 +01:00
u8 * GetImage ( ) ;
2009-04-05 03:51:56 +02:00
//!Sets up a new image using the GuiImageData object specified
//!\param img Pointer to GuiImageData object
2009-03-11 18:28:37 +01:00
void SetImage ( GuiImageData * img ) ;
2009-04-05 03:51:56 +02:00
//!\overload
//!\param img Pointer to image data
//!\param w Width
//!\param h Height
2009-03-11 18:28:37 +01:00
void SetImage ( u8 * img , int w , int h ) ;
2009-04-05 03:51:56 +02:00
//!Gets the pixel color at the specified coordinates of the image
//!\param x X coordinate
//!\param y Y coordinate
2009-03-11 18:28:37 +01:00
GXColor GetPixel ( int x , int y ) ;
2009-04-05 03:51:56 +02:00
//!Sets the pixel color at the specified coordinates of the image
//!\param x X coordinate
//!\param y Y coordinate
//!\param color Pixel color
2009-03-11 18:28:37 +01:00
void SetPixel ( int x , int y , GXColor color ) ;
2009-04-05 03:51:56 +02:00
//!Directly modifies the image data to create a color-striped effect
//!Alters the RGB values by the specified amount
//!\param s Amount to increment/decrement the RGB values in the image
2009-03-11 18:28:37 +01:00
void ColorStripe ( int s ) ;
2009-04-05 03:51:56 +02:00
//!Sets a stripe effect on the image, overlaying alpha blended rectangles
//!Does not alter the image data
//!\param s Alpha amount to draw over the image
2009-03-11 18:28:37 +01:00
void SetStripe ( int s ) ;
protected :
2009-04-05 03:51:56 +02:00
int imgType ; //!< Type of image data (IMAGE_TEXTURE, IMAGE_COLOR, IMAGE_DATA)
u8 * image ; //!< Poiner to image data. May be shared with GuiImageData data
f32 imageangle ; //!< Angle to draw the image
int tile ; //!< Number of times to draw (tile) the image horizontally
int stripe ; //!< Alpha value (0-255) to apply a stripe effect to the texture
2009-03-11 18:28:37 +01:00
} ;
2009-04-13 10:43:50 +02:00
//!Display, manage, and manipulate text in the GUI
2009-03-11 18:28:37 +01:00
class GuiText : public GuiElement
{
public :
2009-04-05 03:51:56 +02:00
//!Constructor
//!\param t Text
//!\param s Font size
//!\param c Font color
2009-03-11 18:28:37 +01:00
GuiText ( const char * t , int s , GXColor c ) ;
2009-04-05 03:51:56 +02:00
//!\overload
2009-10-17 02:15:58 +02:00
//!Assumes SetPresets() has been called to setup preferred text attributes
2009-04-05 03:51:56 +02:00
//!\param t Text
2009-03-16 06:16:20 +01:00
GuiText ( const char * t ) ;
2009-04-05 03:51:56 +02:00
//!Destructor
2009-03-11 18:28:37 +01:00
~ GuiText ( ) ;
2009-04-05 03:51:56 +02:00
//!Sets the text of the GuiText element
//!\param t Text
2009-03-11 18:28:37 +01:00
void SetText ( const char * t ) ;
2010-05-19 23:51:33 +02:00
//!Sets the text of the GuiText element
//!\param t UTF-8 Text
void SetWText ( wchar_t * t ) ;
//!Gets the translated text length of the GuiText element
int GetLength ( ) ;
2009-04-05 03:51:56 +02:00
//!Sets up preset values to be used by GuiText(t)
//!Useful when printing multiple text elements, all with the same attributes set
//!\param sz Font size
//!\param c Font color
//!\param w Maximum width of texture image (for text wrapping)
//!\param s Font size
//!\param h Text alignment (horizontal)
//!\param v Text alignment (vertical)
2009-03-16 06:16:20 +01:00
void SetPresets ( int sz , GXColor c , int w , u16 s , int h , int v ) ;
2009-04-05 03:51:56 +02:00
//!Sets the font size
//!\param s Font size
2009-03-16 06:16:20 +01:00
void SetFontSize ( int s ) ;
2009-04-05 03:51:56 +02:00
//!Sets the maximum width of the drawn texture image
//!\param w Maximum width
2009-10-17 02:15:58 +02:00
void SetMaxWidth ( int w ) ;
2010-05-19 23:51:33 +02:00
//!Gets the width of the text when rendered
int GetTextWidth ( ) ;
2009-08-12 07:35:18 +02:00
//!Enables/disables text scrolling
//!\param s Scrolling on/off
2009-06-27 21:38:39 +02:00
void SetScroll ( int s ) ;
2009-08-12 07:35:18 +02:00
//!Enables/disables text wrapping
//!\param w Wrapping on/off
//!\param width Maximum width (0 to disable)
2009-06-27 21:38:39 +02:00
void SetWrap ( bool w , int width = 0 ) ;
2009-04-05 03:51:56 +02:00
//!Sets the font color
//!\param c Font color
2009-03-11 18:28:37 +01:00
void SetColor ( GXColor c ) ;
2009-04-05 03:51:56 +02:00
//!Sets the FreeTypeGX style attributes
//!\param s Style attributes
2009-03-11 18:28:37 +01:00
void SetStyle ( u16 s ) ;
2009-04-05 03:51:56 +02:00
//!Sets the text alignment
//!\param hor Horizontal alignment (ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTRE)
//!\param vert Vertical alignment (ALIGN_TOP, ALIGN_BOTTOM, ALIGN_MIDDLE)
2009-03-11 18:28:37 +01:00
void SetAlignment ( int hor , int vert ) ;
2010-01-25 09:24:11 +01:00
//!Updates the text to the selected language
void ResetText ( ) ;
2009-04-05 03:51:56 +02:00
//!Constantly called to draw the text
2009-03-11 18:28:37 +01:00
void Draw ( ) ;
protected :
2010-01-25 08:34:45 +01:00
GXColor color ; //!< Font color
2010-03-22 08:51:11 +01:00
wchar_t * text ; //!< Translated Unicode text value
wchar_t * textDyn [ 20 ] ; //!< Text value, if max width, scrolling, or wrapping enabled
int textDynNum ; //!< Number of text lines
char * origText ; //!< Original text data (English)
2009-04-05 03:51:56 +02:00
int size ; //!< Font size
int maxWidth ; //!< Maximum width of the generated text object (for text wrapping)
2009-08-12 07:35:18 +02:00
int textScroll ; //!< Scrolling toggle
int textScrollPos ; //!< Current starting index of text string for scrolling
int textScrollInitialDelay ; //!< Delay to wait before starting to scroll
int textScrollDelay ; //!< Scrolling speed
2009-04-05 03:51:56 +02:00
u16 style ; //!< FreeTypeGX style attributes
2010-01-25 08:34:45 +01:00
bool wrap ; //!< Wrapping toggle
2009-03-11 18:28:37 +01:00
} ;
2010-01-25 09:24:11 +01:00
//!Display, manage, and manipulate tooltips in the GUI
class GuiTooltip : public GuiElement
{
public :
//!Constructor
//!\param t Text
GuiTooltip ( const char * t ) ;
//!Destructor
~ GuiTooltip ( ) ;
//!Gets the element's current scale
float GetScale ( ) ;
//!Sets the text of the GuiTooltip element
//!\param t Text
void SetText ( const char * t ) ;
//!Constantly called to draw the GuiTooltip
void DrawTooltip ( ) ;
time_t time1 , time2 ; //!< Tooltip times
protected :
GuiImage leftImage ; //!< Tooltip left image
GuiImage tileImage ; //!< Tooltip tile image
GuiImage rightImage ; //!< Tooltip right image
GuiText * text ; //!< Tooltip text
} ;
2009-04-13 10:43:50 +02:00
//!Display, manage, and manipulate buttons in the GUI. Buttons can have images, icons, text, and sound set (all of which are optional)
2009-03-11 18:28:37 +01:00
class GuiButton : public GuiElement
{
public :
2009-04-05 03:51:56 +02:00
//!Constructor
//!\param w Width
//!\param h Height
2010-01-25 09:24:11 +01:00
GuiButton ( int w = 0 , int h = 0 ) ;
2009-04-05 03:51:56 +02:00
//!Destructor
2009-03-11 18:28:37 +01:00
~ GuiButton ( ) ;
2009-04-05 03:51:56 +02:00
//!Sets the button's image
//!\param i Pointer to GuiImage object
2009-03-11 18:28:37 +01:00
void SetImage ( GuiImage * i ) ;
2009-04-05 03:51:56 +02:00
//!Sets the button's image on over
//!\param i Pointer to GuiImage object
2009-03-11 18:28:37 +01:00
void SetImageOver ( GuiImage * i ) ;
2009-04-13 10:43:50 +02:00
//!Sets the button's image on hold
//!\param i Pointer to GuiImage object
void SetImageHold ( GuiImage * i ) ;
//!Sets the button's image on click
//!\param i Pointer to GuiImage object
void SetImageClick ( GuiImage * i ) ;
2009-04-05 03:51:56 +02:00
//!Sets the button's icon
//!\param i Pointer to GuiImage object
2009-03-11 18:28:37 +01:00
void SetIcon ( GuiImage * i ) ;
2009-04-05 03:51:56 +02:00
//!Sets the button's icon on over
//!\param i Pointer to GuiImage object
2009-03-11 18:28:37 +01:00
void SetIconOver ( GuiImage * i ) ;
2009-04-13 10:43:50 +02:00
//!Sets the button's icon on hold
//!\param i Pointer to GuiImage object
void SetIconHold ( GuiImage * i ) ;
//!Sets the button's icon on click
//!\param i Pointer to GuiImage object
void SetIconClick ( GuiImage * i ) ;
2009-04-05 03:51:56 +02:00
//!Sets the button's label
//!\param t Pointer to GuiText object
2009-04-13 10:43:50 +02:00
//!\param n Index of label to set (optional, default is 0)
void SetLabel ( GuiText * t , int n = 0 ) ;
2009-04-05 03:51:56 +02:00
//!Sets the button's label on over (eg: different colored text)
//!\param t Pointer to GuiText object
2009-04-13 10:43:50 +02:00
//!\param n Index of label to set (optional, default is 0)
void SetLabelOver ( GuiText * t , int n = 0 ) ;
//!Sets the button's label on hold
//!\param t Pointer to GuiText object
//!\param n Index of label to set (optional, default is 0)
void SetLabelHold ( GuiText * t , int n = 0 ) ;
//!Sets the button's label on click
2009-04-05 03:51:56 +02:00
//!\param t Pointer to GuiText object
2009-04-13 10:43:50 +02:00
//!\param n Index of label to set (optional, default is 0)
void SetLabelClick ( GuiText * t , int n = 0 ) ;
2009-04-05 03:51:56 +02:00
//!Sets the sound to play on over
//!\param s Pointer to GuiSound object
2009-03-11 18:28:37 +01:00
void SetSoundOver ( GuiSound * s ) ;
2009-04-13 10:43:50 +02:00
//!Sets the sound to play on hold
//!\param s Pointer to GuiSound object
void SetSoundHold ( GuiSound * s ) ;
2009-04-05 03:51:56 +02:00
//!Sets the sound to play on click
//!\param s Pointer to GuiSound object
2009-03-11 18:28:37 +01:00
void SetSoundClick ( GuiSound * s ) ;
2010-01-25 09:24:11 +01:00
//!Sets the tooltip for the button
//!\param t Tooltip
void SetTooltip ( GuiTooltip * t ) ;
2009-04-05 03:51:56 +02:00
//!Constantly called to draw the GuiButton
2009-03-11 18:28:37 +01:00
void Draw ( ) ;
2010-01-25 09:24:11 +01:00
//!Constantly called to draw the GuiButton's tooltip
void DrawTooltip ( ) ;
//!Resets the text for all contained elements
void ResetText ( ) ;
2009-04-05 03:51:56 +02:00
//!Constantly called to allow the GuiButton to respond to updated input data
//!\param t Pointer to a GuiTrigger, containing the current input data from PAD/WPAD
2009-03-11 18:28:37 +01:00
void Update ( GuiTrigger * t ) ;
protected :
2009-04-13 10:43:50 +02:00
GuiImage * image ; //!< Button image (default)
GuiImage * imageOver ; //!< Button image for STATE_SELECTED
GuiImage * imageHold ; //!< Button image for STATE_HELD
GuiImage * imageClick ; //!< Button image for STATE_CLICKED
2009-04-05 03:51:56 +02:00
GuiImage * icon ; //!< Button icon (drawn after button image)
2009-04-13 10:43:50 +02:00
GuiImage * iconOver ; //!< Button icon for STATE_SELECTED
GuiImage * iconHold ; //!< Button icon for STATE_HELD
GuiImage * iconClick ; //!< Button icon for STATE_CLICKED
GuiText * label [ 3 ] ; //!< Label(s) to display (default)
GuiText * labelOver [ 3 ] ; //!< Label(s) to display for STATE_SELECTED
GuiText * labelHold [ 3 ] ; //!< Label(s) to display for STATE_HELD
GuiText * labelClick [ 3 ] ; //!< Label(s) to display for STATE_CLICKED
GuiSound * soundOver ; //!< Sound to play for STATE_SELECTED
GuiSound * soundHold ; //!< Sound to play for STATE_HELD
GuiSound * soundClick ; //!< Sound to play for STATE_CLICKED
2010-01-25 09:24:11 +01:00
GuiTooltip * tooltip ; //!< Tooltip to display on over
2009-03-11 18:28:37 +01:00
} ;
2009-04-13 10:43:50 +02:00
typedef struct _keytype {
char ch , chShift ;
} Key ;
//!On-screen keyboard
class GuiKeyboard : public GuiWindow
2009-03-11 18:28:37 +01:00
{
public :
2009-04-13 10:43:50 +02:00
GuiKeyboard ( char * t , u32 m ) ;
~ GuiKeyboard ( ) ;
2009-03-11 18:28:37 +01:00
void Update ( GuiTrigger * t ) ;
2009-04-13 10:43:50 +02:00
char kbtextstr [ 256 ] ;
2009-03-11 18:28:37 +01:00
protected :
2009-04-13 10:43:50 +02:00
u32 kbtextmaxlen ;
int shift ;
int caps ;
GuiText * kbText ;
GuiImage * keyTextboxImg ;
GuiText * keyCapsText ;
GuiImage * keyCapsImg ;
GuiImage * keyCapsOverImg ;
GuiButton * keyCaps ;
GuiText * keyShiftText ;
GuiImage * keyShiftImg ;
GuiImage * keyShiftOverImg ;
GuiButton * keyShift ;
GuiText * keyBackText ;
GuiImage * keyBackImg ;
GuiImage * keyBackOverImg ;
GuiButton * keyBack ;
GuiImage * keySpaceImg ;
GuiImage * keySpaceOverImg ;
GuiButton * keySpace ;
GuiButton * keyBtn [ 4 ] [ 11 ] ;
GuiImage * keyImg [ 4 ] [ 11 ] ;
GuiImage * keyImgOver [ 4 ] [ 11 ] ;
GuiText * keyTxt [ 4 ] [ 11 ] ;
GuiImageData * keyTextbox ;
GuiImageData * key ;
GuiImageData * keyOver ;
GuiImageData * keyMedium ;
GuiImageData * keyMediumOver ;
GuiImageData * keyLarge ;
GuiImageData * keyLargeOver ;
GuiSound * keySoundOver ;
GuiSound * keySoundClick ;
2009-03-11 18:28:37 +01:00
GuiTrigger * trigA ;
2010-04-13 08:50:54 +02:00
GuiTrigger * trig2 ;
2010-01-25 08:34:45 +01:00
Key keys [ 4 ] [ 11 ] ; // two chars = less space than one pointer
2009-03-11 18:28:37 +01:00
} ;
typedef struct _optionlist {
int length ;
2009-07-09 06:12:28 +02:00
char name [ MAX_OPTIONS ] [ 50 ] ;
char value [ MAX_OPTIONS ] [ 50 ] ;
2009-03-11 18:28:37 +01:00
} OptionList ;
2009-04-05 03:51:56 +02:00
//!Display a list of menu options
2009-03-11 18:28:37 +01:00
class GuiOptionBrowser : public GuiElement
{
public :
GuiOptionBrowser ( int w , int h , OptionList * l ) ;
~ GuiOptionBrowser ( ) ;
2010-01-25 09:24:11 +01:00
void SetCol1Position ( int x ) ;
2009-03-11 18:28:37 +01:00
void SetCol2Position ( int x ) ;
int FindMenuItem ( int c , int d ) ;
int GetClickedOption ( ) ;
void ResetState ( ) ;
void SetFocus ( int f ) ;
void Draw ( ) ;
2009-07-28 00:28:21 +02:00
void TriggerUpdate ( ) ;
2010-01-25 09:24:11 +01:00
void ResetText ( ) ;
2009-03-11 18:28:37 +01:00
void Update ( GuiTrigger * t ) ;
GuiText * optionVal [ PAGESIZE ] ;
protected :
int optionIndex [ PAGESIZE ] ;
GuiButton * optionBtn [ PAGESIZE ] ;
GuiText * optionTxt [ PAGESIZE ] ;
GuiImage * optionBg [ PAGESIZE ] ;
2010-01-25 08:34:45 +01:00
int selectedItem ;
int listOffset ;
OptionList * options ;
2009-03-11 18:28:37 +01:00
GuiButton * arrowUpBtn ;
GuiButton * arrowDownBtn ;
GuiImage * bgOptionsImg ;
GuiImage * scrollbarImg ;
GuiImage * arrowDownImg ;
GuiImage * arrowDownOverImg ;
GuiImage * arrowUpImg ;
GuiImage * arrowUpOverImg ;
GuiImageData * bgOptions ;
GuiImageData * bgOptionsEntry ;
GuiImageData * scrollbar ;
GuiImageData * arrowDown ;
GuiImageData * arrowDownOver ;
GuiImageData * arrowUp ;
GuiImageData * arrowUpOver ;
2009-04-05 03:51:56 +02:00
GuiSound * btnSoundOver ;
GuiSound * btnSoundClick ;
2009-03-11 18:28:37 +01:00
GuiTrigger * trigA ;
2010-04-13 08:50:54 +02:00
GuiTrigger * trig2 ;
2010-01-25 08:34:45 +01:00
bool listChanged ;
2009-03-11 18:28:37 +01:00
} ;
typedef struct _savelist {
int length ;
2009-09-15 08:56:15 +02:00
char filename [ MAX_SAVES + 1 ] [ 256 ] ;
GuiImageData * previewImg [ MAX_SAVES + 1 ] ;
char date [ MAX_SAVES + 1 ] [ 20 ] ;
char time [ MAX_SAVES + 1 ] [ 10 ] ;
int type [ MAX_SAVES + 1 ] ;
int files [ 2 ] [ MAX_SAVES + 1 ] ;
2009-03-11 18:28:37 +01:00
} SaveList ;
2009-04-05 03:51:56 +02:00
//!Display a list of game save files, with screenshots and file information
2009-03-11 18:28:37 +01:00
class GuiSaveBrowser : public GuiElement
{
public :
GuiSaveBrowser ( int w , int h , SaveList * l , int a ) ;
~ GuiSaveBrowser ( ) ;
int GetClickedSave ( ) ;
void ResetState ( ) ;
void SetFocus ( int f ) ;
void Draw ( ) ;
void Update ( GuiTrigger * t ) ;
protected :
int selectedItem ;
int action ;
2010-01-25 08:34:45 +01:00
int listOffset ;
2009-03-11 18:28:37 +01:00
SaveList * saves ;
GuiButton * saveBtn [ SAVELISTSIZE ] ;
GuiText * saveDate [ SAVELISTSIZE ] ;
GuiText * saveTime [ SAVELISTSIZE ] ;
GuiText * saveType [ SAVELISTSIZE ] ;
GuiImage * saveBgImg [ SAVELISTSIZE ] ;
GuiImage * saveBgOverImg [ SAVELISTSIZE ] ;
GuiImage * savePreviewImg [ SAVELISTSIZE ] ;
GuiButton * arrowUpBtn ;
GuiButton * arrowDownBtn ;
GuiImage * scrollbarImg ;
GuiImage * arrowDownImg ;
GuiImage * arrowDownOverImg ;
GuiImage * arrowUpImg ;
GuiImage * arrowUpOverImg ;
GuiImageData * gameSave ;
GuiImageData * gameSaveOver ;
GuiImageData * gameSaveBlank ;
GuiImageData * scrollbar ;
GuiImageData * arrowDown ;
GuiImageData * arrowDownOver ;
GuiImageData * arrowUp ;
GuiImageData * arrowUpOver ;
2009-04-05 03:51:56 +02:00
GuiSound * btnSoundOver ;
GuiSound * btnSoundClick ;
2009-03-11 18:28:37 +01:00
GuiTrigger * trigA ;
2010-04-13 08:50:54 +02:00
GuiTrigger * trig2 ;
2010-01-25 08:34:45 +01:00
bool saveBtnLastOver [ SAVELISTSIZE ] ;
2009-03-11 18:28:37 +01:00
} ;
2009-04-13 10:43:50 +02:00
//!Display a list of files
class GuiFileBrowser : public GuiElement
2009-03-11 18:28:37 +01:00
{
public :
2009-04-13 10:43:50 +02:00
GuiFileBrowser ( int w , int h ) ;
~ GuiFileBrowser ( ) ;
void ResetState ( ) ;
void SetFocus ( int f ) ;
void Draw ( ) ;
2010-01-25 09:24:11 +01:00
void DrawTooltip ( ) ;
2009-04-13 10:43:50 +02:00
void TriggerUpdate ( ) ;
2009-03-11 18:28:37 +01:00
void Update ( GuiTrigger * t ) ;
2009-06-18 07:47:02 +02:00
GuiButton * fileList [ FILE_PAGESIZE ] ;
2009-03-11 18:28:37 +01:00
protected :
2009-06-18 07:47:02 +02:00
GuiText * fileListText [ FILE_PAGESIZE ] ;
GuiImage * fileListBg [ FILE_PAGESIZE ] ;
2009-10-02 00:35:12 +02:00
GuiImage * fileListIcon [ FILE_PAGESIZE ] ;
2009-04-13 10:43:50 +02:00
GuiButton * arrowUpBtn ;
GuiButton * arrowDownBtn ;
GuiButton * scrollbarBoxBtn ;
2009-08-04 06:24:17 +02:00
GuiImage * bgFileSelectionImg ;
2009-04-13 10:43:50 +02:00
GuiImage * scrollbarImg ;
GuiImage * arrowDownImg ;
GuiImage * arrowDownOverImg ;
GuiImage * arrowUpImg ;
GuiImage * arrowUpOverImg ;
GuiImage * scrollbarBoxImg ;
GuiImage * scrollbarBoxOverImg ;
2009-08-04 06:24:17 +02:00
GuiImageData * bgFileSelection ;
GuiImageData * bgFileSelectionEntry ;
2009-10-02 00:35:12 +02:00
GuiImageData * iconFolder ;
GuiImageData * iconSD ;
GuiImageData * iconUSB ;
GuiImageData * iconDVD ;
GuiImageData * iconSMB ;
2009-04-13 10:43:50 +02:00
GuiImageData * scrollbar ;
GuiImageData * arrowDown ;
GuiImageData * arrowDownOver ;
GuiImageData * arrowUp ;
GuiImageData * arrowUpOver ;
GuiImageData * scrollbarBox ;
GuiImageData * scrollbarBoxOver ;
GuiSound * btnSoundOver ;
GuiSound * btnSoundClick ;
2009-03-11 18:28:37 +01:00
GuiTrigger * trigA ;
2010-04-13 08:50:54 +02:00
GuiTrigger * trig2 ;
2009-04-13 10:43:50 +02:00
GuiTrigger * trigHeldA ;
2010-01-25 08:34:45 +01:00
int selectedItem ;
int numEntries ;
bool listChanged ;
2009-03-11 18:28:37 +01:00
} ;
# endif