correction to battery level

better handling of multiple wiimote cursors on-screen
code refactor - move trigger class definition to gui.h
better filebrowser scrollbar
allow all controllers to use Home button to exit in-game
This commit is contained in:
dborth 2009-04-13 08:43:50 +00:00
parent dafe532939
commit fe9d114fd0
14 changed files with 466 additions and 333 deletions

View File

@ -36,18 +36,21 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <vector> #include <vector>
#include <exception>
#include <math.h> #include <math.h>
#include <asndlib.h> #include <asndlib.h>
#include <wiiuse/wpad.h>
#include "pngu/pngu.h" #include "pngu/pngu.h"
#include "FreeTypeGX.h" #include "FreeTypeGX.h"
#include "snes9xGX.h" #include "snes9xGX.h"
#include "video.h" #include "video.h"
#include "input.h"
#include "filelist.h" #include "filelist.h"
#include "fileop.h" #include "fileop.h"
#include "menu.h" #include "input.h"
#include "oggplayer.h" #include "oggplayer.h"
extern FreeTypeGX *fontSystem;
#define SCROLL_INITIAL_DELAY 20 #define SCROLL_INITIAL_DELAY 20
#define SCROLL_LOOP_DELAY 3 #define SCROLL_LOOP_DELAY 3
#define PAGESIZE 8 #define PAGESIZE 8
@ -89,6 +92,26 @@ enum
IMAGE_DATA IMAGE_DATA
}; };
enum
{
TRIGGER_SIMPLE,
TRIGGER_HELD,
TRIGGER_BUTTON_ONLY,
TRIGGER_BUTTON_ONLY_IN_FOCUS
};
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;
#define EFFECT_SLIDE_TOP 1 #define EFFECT_SLIDE_TOP 1
#define EFFECT_SLIDE_BOTTOM 2 #define EFFECT_SLIDE_BOTTOM 2
#define EFFECT_SLIDE_RIGHT 4 #define EFFECT_SLIDE_RIGHT 4
@ -136,7 +159,61 @@ class GuiSound
bool loop; //!< Loop sound playback bool loop; //!< Loop sound playback
}; };
//!Primary Gui class //!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);
//!Get X/Y value from Wii Joystick (classic, nunchuk) input
//!\param right Controller stick (left = 0, right = 1)
//!\param axis Controller stick axis (x-axis = 0, y-axis = 1)
//!\return Stick value
s8 WPAD_Stick(u8 right, int axis);
//!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();
u8 type; //!< trigger type (TRIGGER_SIMPLE, TRIGGER_HELD, TRIGGER_BUTTON_ONLY, TRIGGER_BUTTON_ONLY_IN_FOCUS)
s32 chan; //!< Trigger controller channel (0-3, -1 for all)
WPADData wpad; //!< Wii controller trigger data
PADData pad; //!< GameCube controller trigger data
};
extern GuiTrigger userInput[4];
//!Primary GUI class. Most other classes inherit from this class.
class GuiElement class GuiElement
{ {
public: public:
@ -198,21 +275,24 @@ class GuiElement
//!Checks whether or not the element is clickable //!Checks whether or not the element is clickable
//!\return true if clickable, false otherwise //!\return true if clickable, false otherwise
bool IsClickable(); bool IsClickable();
//!Checks whether or not the element is draggable //!Checks whether or not the element is holdable
//!\return true if draggable, false otherwise //!\return true if holdable, false otherwise
bool IsDraggable(); bool IsHoldable();
//!Sets whether or not the element is selectable //!Sets whether or not the element is selectable
//!\param s Selectable //!\param s Selectable
void SetSelectable(bool s); void SetSelectable(bool s);
//!Sets whether or not the element is clickable //!Sets whether or not the element is clickable
//!\param c Clickable //!\param c Clickable
void SetClickable(bool c); void SetClickable(bool c);
//!Sets whether or not the element is draggable //!Sets whether or not the element is holdable
//!\param c Draggable //!\param c Holdable
void SetDraggable(bool d); void SetHoldable(bool d);
//!Gets the element's current state //!Gets the element's current state
//!\return state //!\return state
int GetState(); int GetState();
//!Gets the controller channel that last changed the element's state
//!\return Channel number (0-3, -1 = no channel)
int GetStateChan();
//!Sets the element's alpha value //!Sets the element's alpha value
//!\param a alpha value //!\param a alpha value
void SetAlpha(int a); void SetAlpha(int a);
@ -276,11 +356,12 @@ class GuiElement
//!\param v Visibility (true = visible) //!\param v Visibility (true = visible)
virtual void SetVisible(bool v); virtual void SetVisible(bool v);
//!Sets the element's focus //!Sets the element's focus
//!\param v Focus (true = in focus) //!\param f Focus (true = in focus)
virtual void SetFocus(int f); virtual void SetFocus(int f);
//!Sets the element's state //!Sets the element's state
//!\param v State (STATE_DEFAULT, STATE_SELECTED, STATE_CLICKED, STATE_DISABLED) //!\param s State (STATE_DEFAULT, STATE_SELECTED, STATE_CLICKED, STATE_DISABLED)
virtual void SetState(int s); //!\param c Controller channel (0-3, -1 = none)
virtual void SetState(int s, int c = -1);
//!Resets the element's state to STATE_DEFAULT //!Resets the element's state to STATE_DEFAULT
virtual void ResetState(); virtual void ResetState();
//!Gets whether or not the element is in STATE_SELECTED //!Gets whether or not the element is in STATE_SELECTED
@ -325,7 +406,7 @@ class GuiElement
int stateChan; //!< Which controller channel is responsible for the last change in state int stateChan; //!< Which controller channel is responsible for the last change in state
bool selectable; //!< Whether or not this element selectable (can change to SELECTED state) 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) bool clickable; //!< Whether or not this element is clickable (can change to CLICKED state)
bool draggable; //!< Whether or not this element is draggable (can change to HELD state) bool holdable; //!< Whether or not this element is holdable (can change to HELD state)
GuiTrigger * trigger[2]; //!< GuiTriggers (input actions) that this element responds to GuiTrigger * trigger[2]; //!< GuiTriggers (input actions) that this element responds to
GuiElement * parentElement; //!< Parent element GuiElement * parentElement; //!< Parent element
UpdateCallback updateCB; //!< Callback function to call when this element is updated UpdateCallback updateCB; //!< Callback function to call when this element is updated
@ -402,8 +483,7 @@ class GuiWindow : public GuiElement
std::vector<GuiElement*> _elements; //!< Contains all elements within the GuiWindow std::vector<GuiElement*> _elements; //!< Contains all elements within the GuiWindow
}; };
//!Converts image data into GX-useable RGBA8 //!Converts image data into GX-useable RGBA8. Currently designed for use only with PNG files
//!Currently designed for use only with PNG files
class GuiImageData class GuiImageData
{ {
public: public:
@ -428,11 +508,13 @@ class GuiImageData
int width; //!< Width of image int width; //!< Width of image
}; };
//!Display, manage, and manipulate images in the Gui //!Display, manage, and manipulate images in the GUI
class GuiImage : public GuiElement class GuiImage : public GuiElement
{ {
public: public:
//!Constructor //!Constructor
GuiImage();
//!\overload
//!\param img Pointer to GuiImageData element //!\param img Pointer to GuiImageData element
GuiImage(GuiImageData * img); GuiImage(GuiImageData * img);
//!\overload //!\overload
@ -493,7 +575,7 @@ class GuiImage : public GuiElement
int stripe; //!< Alpha value (0-255) to apply a stripe effect to the texture int stripe; //!< Alpha value (0-255) to apply a stripe effect to the texture
}; };
//!Display, manage, and manipulate text in the Gui //!Display, manage, and manipulate text in the GUI
class GuiText : public GuiElement class GuiText : public GuiElement
{ {
public: public:
@ -547,8 +629,7 @@ class GuiText : public GuiElement
GXColor color; //!< Font color GXColor color; //!< Font color
}; };
//!Display, manage, and manipulate buttons in the Gui //!Display, manage, and manipulate buttons in the GUI. Buttons can have images, icons, text, and sound set (all of which are optional)
//!Buttons can have images, icons, text, and sound set (all of which are optional)
class GuiButton : public GuiElement class GuiButton : public GuiElement
{ {
public: public:
@ -564,29 +645,46 @@ class GuiButton : public GuiElement
//!Sets the button's image on over //!Sets the button's image on over
//!\param i Pointer to GuiImage object //!\param i Pointer to GuiImage object
void SetImageOver(GuiImage* i); void SetImageOver(GuiImage* i);
//!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);
//!Sets the button's icon //!Sets the button's icon
//!\param i Pointer to GuiImage object //!\param i Pointer to GuiImage object
void SetIcon(GuiImage* i); void SetIcon(GuiImage* i);
//!Sets the button's icon on over //!Sets the button's icon on over
//!\param i Pointer to GuiImage object //!\param i Pointer to GuiImage object
void SetIconOver(GuiImage* i); void SetIconOver(GuiImage* i);
//!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);
//!Sets the button's label //!Sets the button's label
//!\param t Pointer to GuiText object //!\param t Pointer to GuiText object
void SetLabel(GuiText* t); //!\param n Index of label to set (optional, default is 0)
//!\overload void SetLabel(GuiText* t, int n = 0);
//!\param t Pointer to GuiText object
//!\param n Index of label to set
void SetLabel(GuiText* t, int n);
//!Sets the button's label on over (eg: different colored text) //!Sets the button's label on over (eg: different colored text)
//!\param t Pointer to GuiText object //!\param t Pointer to GuiText object
void SetLabelOver(GuiText* t); //!\param n Index of label to set (optional, default is 0)
//!\overload void SetLabelOver(GuiText* t, int n = 0);
//!Sets the button's label on hold
//!\param t Pointer to GuiText object //!\param t Pointer to GuiText object
//!\param n Index of label to set //!\param n Index of label to set (optional, default is 0)
void SetLabelOver(GuiText* t, int n); void SetLabelHold(GuiText* t, int n = 0);
//!Sets the button's label on click
//!\param t Pointer to GuiText object
//!\param n Index of label to set (optional, default is 0)
void SetLabelClick(GuiText* t, int n = 0);
//!Sets the sound to play on over //!Sets the sound to play on over
//!\param s Pointer to GuiSound object //!\param s Pointer to GuiSound object
void SetSoundOver(GuiSound * s); void SetSoundOver(GuiSound * s);
//!Sets the sound to play on hold
//!\param s Pointer to GuiSound object
void SetSoundHold(GuiSound * s);
//!Sets the sound to play on click //!Sets the sound to play on click
//!\param s Pointer to GuiSound object //!\param s Pointer to GuiSound object
void SetSoundClick(GuiSound * s); void SetSoundClick(GuiSound * s);
@ -596,64 +694,71 @@ class GuiButton : public GuiElement
//!\param t Pointer to a GuiTrigger, containing the current input data from PAD/WPAD //!\param t Pointer to a GuiTrigger, containing the current input data from PAD/WPAD
void Update(GuiTrigger * t); void Update(GuiTrigger * t);
protected: protected:
GuiImage * image; //!< Button image GuiImage * image; //!< Button image (default)
GuiImage * imageOver; //!< Button image on wiimote cursor over GuiImage * imageOver; //!< Button image for STATE_SELECTED
GuiImage * imageHold; //!< Button image for STATE_HELD
GuiImage * imageClick; //!< Button image for STATE_CLICKED
GuiImage * icon; //!< Button icon (drawn after button image) GuiImage * icon; //!< Button icon (drawn after button image)
GuiImage * iconOver; //!< Button icon on wiimote cursor over GuiImage * iconOver; //!< Button icon for STATE_SELECTED
GuiText * label[3]; //!< Label(s) to display GuiImage * iconHold; //!< Button icon for STATE_HELD
GuiText * labelOver[3]; //!< Label(s) to display on wiimote cursor over GuiImage * iconClick; //!< Button icon for STATE_CLICKED
GuiSound * soundOver; //!< Sound to play on wiimote cursor over GuiText * label[3]; //!< Label(s) to display (default)
GuiSound * soundClick; //!< Sound to play on click 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
}; };
//!Display a list of files typedef struct _keytype {
class GuiFileBrowser : public GuiElement char ch, chShift;
} Key;
//!On-screen keyboard
class GuiKeyboard : public GuiWindow
{ {
public: public:
GuiFileBrowser(int w, int h); GuiKeyboard(char * t, u32 m);
~GuiFileBrowser(); ~GuiKeyboard();
void ResetState();
void SetFocus(int f);
void Draw();
void TriggerUpdate();
void Update(GuiTrigger * t); void Update(GuiTrigger * t);
GuiButton * gameList[PAGESIZE]; char kbtextstr[256];
protected: protected:
int selectedItem; u32 kbtextmaxlen;
bool listChanged; Key keys[4][11];
int shift;
GuiText * gameListText[PAGESIZE]; int caps;
GuiImage * gameListBg[PAGESIZE]; GuiText * kbText;
GuiImage * gameListFolder[PAGESIZE]; GuiImage * keyTextboxImg;
GuiText * keyCapsText;
GuiButton * arrowUpBtn; GuiImage * keyCapsImg;
GuiButton * arrowDownBtn; GuiImage * keyCapsOverImg;
GuiButton * scrollbarBoxBtn; GuiButton * keyCaps;
GuiText * keyShiftText;
GuiImage * bgGameSelectionImg; GuiImage * keyShiftImg;
GuiImage * scrollbarImg; GuiImage * keyShiftOverImg;
GuiImage * arrowDownImg; GuiButton * keyShift;
GuiImage * arrowDownOverImg; GuiText * keyBackText;
GuiImage * arrowUpImg; GuiImage * keyBackImg;
GuiImage * arrowUpOverImg; GuiImage * keyBackOverImg;
GuiImage * scrollbarBoxImg; GuiButton * keyBack;
GuiImage * scrollbarBoxOverImg; GuiImage * keySpaceImg;
GuiImage * keySpaceOverImg;
GuiImageData * bgGameSelection; GuiButton * keySpace;
GuiImageData * bgGameSelectionEntry; GuiButton * keyBtn[4][11];
GuiImageData * gameFolder; GuiImage * keyImg[4][11];
GuiImageData * scrollbar; GuiImage * keyImgOver[4][11];
GuiImageData * arrowDown; GuiText * keyTxt[4][11];
GuiImageData * arrowDownOver; GuiImageData * keyTextbox;
GuiImageData * arrowUp; GuiImageData * key;
GuiImageData * arrowUpOver; GuiImageData * keyOver;
GuiImageData * scrollbarBox; GuiImageData * keyMedium;
GuiImageData * scrollbarBoxOver; GuiImageData * keyMediumOver;
GuiImageData * keyLarge;
GuiSound * btnSoundOver; GuiImageData * keyLargeOver;
GuiSound * btnSoundClick; GuiSound * keySoundOver;
GuiSound * keySoundClick;
GuiTrigger * trigA; GuiTrigger * trigA;
GuiTrigger * trigHeldA;
}; };
typedef struct _optionlist { typedef struct _optionlist {
@ -778,54 +883,54 @@ class GuiSaveBrowser : public GuiElement
GuiTrigger * trigA; GuiTrigger * trigA;
}; };
typedef struct _keytype { //!Display a list of files
char ch, chShift; class GuiFileBrowser : public GuiElement
} Key;
//!On-screen keyboard
class GuiKeyboard : public GuiWindow
{ {
public: public:
GuiKeyboard(char * t, u32 m); GuiFileBrowser(int w, int h);
~GuiKeyboard(); ~GuiFileBrowser();
void ResetState();
void SetFocus(int f);
void Draw();
void TriggerUpdate();
void Update(GuiTrigger * t); void Update(GuiTrigger * t);
char kbtextstr[256]; GuiButton * gameList[PAGESIZE];
protected: protected:
u32 kbtextmaxlen; int selectedItem;
Key keys[4][11]; bool listChanged;
int shift;
int caps; GuiText * gameListText[PAGESIZE];
GuiText * kbText; GuiImage * gameListBg[PAGESIZE];
GuiImage * keyTextboxImg; GuiImage * gameListFolder[PAGESIZE];
GuiText * keyCapsText;
GuiImage * keyCapsImg; GuiButton * arrowUpBtn;
GuiImage * keyCapsOverImg; GuiButton * arrowDownBtn;
GuiButton * keyCaps; GuiButton * scrollbarBoxBtn;
GuiText * keyShiftText;
GuiImage * keyShiftImg; GuiImage * bgGameSelectionImg;
GuiImage * keyShiftOverImg; GuiImage * scrollbarImg;
GuiButton * keyShift; GuiImage * arrowDownImg;
GuiText * keyBackText; GuiImage * arrowDownOverImg;
GuiImage * keyBackImg; GuiImage * arrowUpImg;
GuiImage * keyBackOverImg; GuiImage * arrowUpOverImg;
GuiButton * keyBack; GuiImage * scrollbarBoxImg;
GuiImage * keySpaceImg; GuiImage * scrollbarBoxOverImg;
GuiImage * keySpaceOverImg;
GuiButton * keySpace; GuiImageData * bgGameSelection;
GuiButton * keyBtn[4][11]; GuiImageData * bgGameSelectionEntry;
GuiImage * keyImg[4][11]; GuiImageData * gameFolder;
GuiImage * keyImgOver[4][11]; GuiImageData * scrollbar;
GuiText * keyTxt[4][11]; GuiImageData * arrowDown;
GuiImageData * keyTextbox; GuiImageData * arrowDownOver;
GuiImageData * key; GuiImageData * arrowUp;
GuiImageData * keyOver; GuiImageData * arrowUpOver;
GuiImageData * keyMedium; GuiImageData * scrollbarBox;
GuiImageData * keyMediumOver; GuiImageData * scrollbarBoxOver;
GuiImageData * keyLarge;
GuiImageData * keyLargeOver; GuiSound * btnSoundOver;
GuiSound * keySoundOver; GuiSound * btnSoundClick;
GuiSound * keySoundClick;
GuiTrigger * trigA; GuiTrigger * trigA;
GuiTrigger * trigHeldA;
}; };
#endif #endif

View File

@ -19,18 +19,26 @@ GuiButton::GuiButton(int w, int h)
height = h; height = h;
image = NULL; image = NULL;
imageOver = NULL; imageOver = NULL;
imageHold = NULL;
imageClick = NULL;
icon = NULL; icon = NULL;
iconOver = NULL; iconOver = NULL;
iconHold = NULL;
iconClick = NULL;
for(int i=0; i < 3; i++) for(int i=0; i < 3; i++)
{ {
label[i] = NULL; label[i] = NULL;
labelOver[i] = NULL; labelOver[i] = NULL;
labelHold[i] = NULL;
labelClick[i] = NULL;
} }
soundOver = NULL; soundOver = NULL;
soundHold = NULL;
soundClick = NULL; soundClick = NULL;
selectable = true; selectable = true;
holdable = false;
clickable = true; clickable = true;
} }
@ -44,63 +52,71 @@ GuiButton::~GuiButton()
void GuiButton::SetImage(GuiImage* img) void GuiButton::SetImage(GuiImage* img)
{ {
image = img; image = img;
if(img) img->SetParent(this);
if(img)
img->SetParent(this);
} }
void GuiButton::SetImageOver(GuiImage* img) void GuiButton::SetImageOver(GuiImage* img)
{ {
imageOver = img; imageOver = img;
if(img) img->SetParent(this);
if(img) }
img->SetParent(this); void GuiButton::SetImageHold(GuiImage* img)
{
imageHold = img;
if(img) img->SetParent(this);
}
void GuiButton::SetImageClick(GuiImage* img)
{
imageClick = img;
if(img) img->SetParent(this);
} }
void GuiButton::SetIcon(GuiImage* img) void GuiButton::SetIcon(GuiImage* img)
{ {
icon = img; icon = img;
if(img) img->SetParent(this);
if(img)
img->SetParent(this);
} }
void GuiButton::SetIconOver(GuiImage* img) void GuiButton::SetIconOver(GuiImage* img)
{ {
iconOver = img; iconOver = img;
if(img) img->SetParent(this);
if(img)
img->SetParent(this);
} }
void GuiButton::SetLabel(GuiText* txt) void GuiButton::SetIconHold(GuiImage* img)
{ {
label[0] = txt; iconHold = img;
if(img) img->SetParent(this);
if(txt)
txt->SetParent(this);
} }
void GuiButton::SetLabelOver(GuiText* txt) void GuiButton::SetIconClick(GuiImage* img)
{ {
labelOver[0] = txt; iconClick = img;
if(img) img->SetParent(this);
if(txt)
txt->SetParent(this);
} }
void GuiButton::SetLabel(GuiText* txt, int n) void GuiButton::SetLabel(GuiText* txt, int n)
{ {
label[n] = txt; label[n] = txt;
if(txt) txt->SetParent(this);
if(txt)
txt->SetParent(this);
} }
void GuiButton::SetLabelOver(GuiText* txt, int n) void GuiButton::SetLabelOver(GuiText* txt, int n)
{ {
labelOver[n] = txt; labelOver[n] = txt;
if(txt) txt->SetParent(this);
if(txt) }
txt->SetParent(this); void GuiButton::SetLabelHold(GuiText* txt, int n)
{
labelHold[n] = txt;
if(txt) txt->SetParent(this);
}
void GuiButton::SetLabelClick(GuiText* txt, int n)
{
labelClick[n] = txt;
if(txt) txt->SetParent(this);
} }
void GuiButton::SetSoundOver(GuiSound * snd) void GuiButton::SetSoundOver(GuiSound * snd)
{ {
soundOver = snd; soundOver = snd;
} }
void GuiButton::SetSoundHold(GuiSound * snd)
{
soundHold = snd;
}
void GuiButton::SetSoundClick(GuiSound * snd) void GuiButton::SetSoundClick(GuiSound * snd)
{ {
soundClick = snd; soundClick = snd;
@ -151,7 +167,7 @@ void GuiButton::Update(GuiTrigger * t)
{ {
if(state == STATE_DEFAULT) // we weren't on the button before! if(state == STATE_DEFAULT) // we weren't on the button before!
{ {
state = STATE_SELECTED; this->SetState(STATE_SELECTED, t->chan);
if(this->Rumble()) if(this->Rumble())
rumbleRequest[t->chan] = 1; rumbleRequest[t->chan] = 1;
@ -170,8 +186,8 @@ void GuiButton::Update(GuiTrigger * t)
} }
else else
{ {
if(state == STATE_SELECTED) if(state == STATE_SELECTED && (stateChan == t->chan || stateChan == -1))
state = STATE_DEFAULT; this->ResetState();
if(effectTarget == effectTargetOver && effectAmount == effectAmountOver) if(effectTarget == effectTargetOver && effectAmount == effectAmountOver)
{ {
@ -187,17 +203,18 @@ void GuiButton::Update(GuiTrigger * t)
// button triggers // button triggers
if(this->IsClickable()) if(this->IsClickable())
{ {
s32 wm_btns, wm_btns_trig, cc_btns, cc_btns_trig;
for(int i=0; i<2; i++) for(int i=0; i<2; i++)
{ {
if(trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan)) if(trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan))
{ {
// higher 16 bits only (wiimote) // higher 16 bits only (wiimote)
s32 wm_btns = t->wpad.btns_d << 16; wm_btns = t->wpad.btns_d << 16;
s32 wm_btns_trig = trigger[i]->wpad.btns_d << 16; wm_btns_trig = trigger[i]->wpad.btns_d << 16;
// lower 16 bits only (classic controller) // lower 16 bits only (classic controller)
s32 cc_btns = t->wpad.btns_d >> 16; cc_btns = t->wpad.btns_d >> 16;
s32 cc_btns_trig = trigger[i]->wpad.btns_d >> 16; cc_btns_trig = trigger[i]->wpad.btns_d >> 16;
if( if(
(t->wpad.btns_d > 0 && (t->wpad.btns_d > 0 &&
@ -205,47 +222,64 @@ void GuiButton::Update(GuiTrigger * t)
(cc_btns == cc_btns_trig && t->wpad.exp.type == EXP_CLASSIC)) || (cc_btns == cc_btns_trig && t->wpad.exp.type == EXP_CLASSIC)) ||
(t->pad.btns_d == trigger[i]->pad.btns_d && t->pad.btns_d > 0)) (t->pad.btns_d == trigger[i]->pad.btns_d && t->pad.btns_d > 0))
{ {
if(state == STATE_SELECTED) if(t->chan == stateChan || stateChan == -1)
{ {
state = STATE_CLICKED; if(state == STATE_SELECTED)
{
this->SetState(STATE_CLICKED, t->chan);
if(soundClick) if(soundClick)
soundClick->Play(); soundClick->Play();
} }
else if(trigger[i]->type == TRIGGER_BUTTON_ONLY) else if(trigger[i]->type == TRIGGER_BUTTON_ONLY)
{ {
state = STATE_CLICKED; this->SetState(STATE_CLICKED, t->chan);
} }
else if(trigger[i]->type == TRIGGER_BUTTON_ONLY_IN_FOCUS && else if(trigger[i]->type == TRIGGER_BUTTON_ONLY_IN_FOCUS &&
parentElement->IsFocused()) parentElement->IsFocused())
{ {
state = STATE_CLICKED; this->SetState(STATE_CLICKED, t->chan);
}
} }
} }
} }
} }
} }
if(this->IsDraggable()) if(this->IsHoldable())
{ {
bool held = false; bool held = false;
s32 wm_btns, wm_btns_h, wm_btns_trig, cc_btns, cc_btns_h, cc_btns_trig;
for(int i=0; i<2; i++) for(int i=0; i<2; i++)
{ {
if(trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan)) if(trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan))
{ {
// higher 16 bits only (wiimote) // higher 16 bits only (wiimote)
s32 wm_btns = t->wpad.btns_h << 16; wm_btns = t->wpad.btns_d << 16;
s32 wm_btns_trig = trigger[i]->wpad.btns_h << 16; wm_btns_h = t->wpad.btns_h << 16;
wm_btns_trig = trigger[i]->wpad.btns_h << 16;
// lower 16 bits only (classic controller) // lower 16 bits only (classic controller)
s32 cc_btns = t->wpad.btns_h >> 16; cc_btns = t->wpad.btns_d >> 16;
s32 cc_btns_trig = trigger[i]->wpad.btns_h >> 16; cc_btns_h = t->wpad.btns_h >> 16;
cc_btns_trig = trigger[i]->wpad.btns_h >> 16;
if(
(t->wpad.btns_d > 0 &&
wm_btns == wm_btns_trig ||
(cc_btns == cc_btns_trig && t->wpad.exp.type == EXP_CLASSIC)) ||
(t->pad.btns_d == trigger[i]->pad.btns_h && t->pad.btns_d > 0))
{
if(trigger[i]->type == TRIGGER_HELD && state == STATE_SELECTED &&
(t->chan == stateChan || stateChan == -1))
this->SetState(STATE_CLICKED, t->chan);
}
if( if(
(t->wpad.btns_h > 0 && (t->wpad.btns_h > 0 &&
wm_btns == wm_btns_trig || wm_btns_h == wm_btns_trig ||
(cc_btns == cc_btns_trig && t->wpad.exp.type == EXP_CLASSIC)) || (cc_btns_h == cc_btns_trig && t->wpad.exp.type == EXP_CLASSIC)) ||
(t->pad.btns_h == trigger[i]->pad.btns_h && t->pad.btns_h > 0)) (t->pad.btns_h == trigger[i]->pad.btns_h && t->pad.btns_h > 0))
{ {
if(trigger[i]->type == TRIGGER_HELD) if(trigger[i]->type == TRIGGER_HELD)
@ -254,12 +288,11 @@ void GuiButton::Update(GuiTrigger * t)
if(!held && state == STATE_HELD && stateChan == t->chan) if(!held && state == STATE_HELD && stateChan == t->chan)
{ {
state = STATE_DEFAULT; this->ResetState();
} }
else if(held && state == STATE_SELECTED) else if(held && state == STATE_CLICKED && stateChan == t->chan)
{ {
state = STATE_HELD; this->SetState(STATE_HELD, t->chan);
stateChan = t->chan; // record which controller is holding the button
} }
} }
} }

View File

@ -33,7 +33,7 @@ GuiElement::GuiElement()
rumble = true; rumble = true;
selectable = false; selectable = false;
clickable = false; clickable = false;
draggable = false; holdable = false;
visible = true; visible = true;
focus = -1; // cannot be focused focus = -1; // cannot be focused
updateCB = NULL; updateCB = NULL;
@ -268,15 +268,24 @@ int GuiElement::GetState()
return state; return state;
} }
void GuiElement::SetState(int s) int GuiElement::GetStateChan()
{
return stateChan;
}
void GuiElement::SetState(int s, int c)
{ {
state = s; state = s;
stateChan = c;
} }
void GuiElement::ResetState() void GuiElement::ResetState()
{ {
if(state != STATE_DISABLED) if(state != STATE_DISABLED)
{
state = STATE_DEFAULT; state = STATE_DEFAULT;
stateChan = -1;
}
} }
void GuiElement::SetClickable(bool c) void GuiElement::SetClickable(bool c)
@ -289,9 +298,9 @@ void GuiElement::SetSelectable(bool s)
selectable = s; selectable = s;
} }
void GuiElement::SetDraggable(bool d) void GuiElement::SetHoldable(bool d)
{ {
draggable = d; holdable = d;
} }
bool GuiElement::IsSelectable() bool GuiElement::IsSelectable()
@ -312,12 +321,12 @@ bool GuiElement::IsClickable()
return clickable; return clickable;
} }
bool GuiElement::IsDraggable() bool GuiElement::IsHoldable()
{ {
if(state == STATE_DISABLED) if(state == STATE_DISABLED)
return false; return false;
else else
return draggable; return holdable;
} }
void GuiElement::SetFocus(int f) void GuiElement::SetFocus(int f)

View File

@ -71,7 +71,9 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
arrowUpBtn->SetImageOver(arrowUpOverImg); arrowUpBtn->SetImageOver(arrowUpOverImg);
arrowUpBtn->SetAlignment(ALIGN_RIGHT, ALIGN_TOP); arrowUpBtn->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
arrowUpBtn->SetSelectable(false); arrowUpBtn->SetSelectable(false);
arrowUpBtn->SetTrigger(trigA); arrowUpBtn->SetClickable(false);
arrowUpBtn->SetHoldable(true);
arrowUpBtn->SetTrigger(trigHeldA);
arrowUpBtn->SetSoundOver(btnSoundOver); arrowUpBtn->SetSoundOver(btnSoundOver);
arrowUpBtn->SetSoundClick(btnSoundClick); arrowUpBtn->SetSoundClick(btnSoundClick);
@ -81,7 +83,9 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
arrowDownBtn->SetImageOver(arrowDownOverImg); arrowDownBtn->SetImageOver(arrowDownOverImg);
arrowDownBtn->SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); arrowDownBtn->SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
arrowDownBtn->SetSelectable(false); arrowDownBtn->SetSelectable(false);
arrowDownBtn->SetTrigger(trigA); arrowDownBtn->SetClickable(false);
arrowDownBtn->SetHoldable(true);
arrowDownBtn->SetTrigger(trigHeldA);
arrowDownBtn->SetSoundOver(btnSoundOver); arrowDownBtn->SetSoundOver(btnSoundOver);
arrowDownBtn->SetSoundClick(btnSoundClick); arrowDownBtn->SetSoundClick(btnSoundClick);
@ -94,7 +98,7 @@ GuiFileBrowser::GuiFileBrowser(int w, int h)
scrollbarBoxBtn->SetMaxY(304); scrollbarBoxBtn->SetMaxY(304);
scrollbarBoxBtn->SetSelectable(false); scrollbarBoxBtn->SetSelectable(false);
scrollbarBoxBtn->SetClickable(false); scrollbarBoxBtn->SetClickable(false);
scrollbarBoxBtn->SetDraggable(true); scrollbarBoxBtn->SetHoldable(true);
scrollbarBoxBtn->SetTrigger(trigHeldA); scrollbarBoxBtn->SetTrigger(trigHeldA);
for(int i=0; i<PAGESIZE; i++) for(int i=0; i<PAGESIZE; i++)
@ -172,6 +176,7 @@ void GuiFileBrowser::SetFocus(int f)
void GuiFileBrowser::ResetState() void GuiFileBrowser::ResetState()
{ {
state = STATE_DEFAULT; state = STATE_DEFAULT;
stateChan = -1;
selectedItem = 0; selectedItem = 0;
for(int i=0; i<PAGESIZE; i++) for(int i=0; i<PAGESIZE; i++)
@ -215,41 +220,38 @@ void GuiFileBrowser::Update(GuiTrigger * t)
int position; int position;
// update the location of the scroll box based on the position in the file list
position = 136*(browser.pageIndex + selectedItem) / browser.numEntries;
scrollbarBoxBtn->SetPosition(0,position+36);
arrowUpBtn->Update(t); arrowUpBtn->Update(t);
arrowDownBtn->Update(t); arrowDownBtn->Update(t);
scrollbarBoxBtn->Update(t); scrollbarBoxBtn->Update(t);
if(scrollbarBoxBtn->GetState() == STATE_HELD) // move the file listing to respond to wiimote cursor movement
if(scrollbarBoxBtn->GetState() == STATE_HELD &&
scrollbarBoxBtn->GetStateChan() == t->chan &&
t->wpad.ir.valid &&
browser.numEntries > PAGESIZE
)
{ {
// move the file listing to respond to wiimote cursor movement scrollbarBoxBtn->SetPosition(0,0);
if(t->wpad.ir.valid) position = t->wpad.ir.y - 60 - scrollbarBoxBtn->GetTop();
if(position < scrollbarBoxBtn->GetMinY())
position = scrollbarBoxBtn->GetMinY();
else if(position > scrollbarBoxBtn->GetMaxY())
position = scrollbarBoxBtn->GetMaxY();
browser.pageIndex = (position * browser.numEntries)/136.0 - selectedItem;
if(browser.pageIndex <= 0)
{ {
scrollbarBoxBtn->SetPosition(0,0); browser.pageIndex = 0;
position = t->wpad.ir.y - 60 - scrollbarBoxBtn->GetTop(); selectedItem = 0;
if(position > scrollbarBoxBtn->GetMinY() &&
position < scrollbarBoxBtn->GetMaxY())
{
scrollbarBoxBtn->SetPosition(0, position);
browser.pageIndex = (position * browser.numEntries)/136.0 - selectedItem;
if(browser.pageIndex <= 0)
{
browser.pageIndex = 0;
selectedItem = 0;
}
else if(browser.pageIndex+PAGESIZE >= browser.numEntries)
{
browser.pageIndex = browser.numEntries-PAGESIZE;
selectedItem = PAGESIZE-1;
}
listChanged = true;
}
} }
else if(browser.pageIndex+PAGESIZE >= browser.numEntries)
{
browser.pageIndex = browser.numEntries-PAGESIZE;
selectedItem = PAGESIZE-1;
}
listChanged = true;
} }
// pad/joystick navigation // pad/joystick navigation
@ -259,7 +261,16 @@ void GuiFileBrowser::Update(GuiTrigger * t)
listChanged = false; listChanged = false;
} }
if(t->Right() || arrowDownBtn->GetState() == STATE_CLICKED) if(arrowDownBtn->GetState() == STATE_CLICKED && arrowDownBtn->GetStateChan() == t->chan)
t->wpad.btns_d |= WPAD_BUTTON_DOWN;
else if(arrowUpBtn->GetState() == STATE_CLICKED && arrowUpBtn->GetStateChan() == t->chan)
t->wpad.btns_d |= WPAD_BUTTON_UP;
else if(arrowDownBtn->GetState() == STATE_HELD && arrowDownBtn->GetStateChan() == t->chan)
t->wpad.btns_h |= WPAD_BUTTON_DOWN;
else if(arrowUpBtn->GetState() == STATE_HELD && arrowUpBtn->GetStateChan() == t->chan)
t->wpad.btns_h |= WPAD_BUTTON_UP;
if(t->Right())
{ {
if(browser.pageIndex < browser.numEntries && browser.numEntries > PAGESIZE) if(browser.pageIndex < browser.numEntries && browser.numEntries > PAGESIZE)
{ {
@ -268,9 +279,8 @@ void GuiFileBrowser::Update(GuiTrigger * t)
browser.pageIndex = browser.numEntries-PAGESIZE; browser.pageIndex = browser.numEntries-PAGESIZE;
listChanged = true; listChanged = true;
} }
arrowDownBtn->ResetState();
} }
else if(t->Left() || arrowUpBtn->GetState() == STATE_CLICKED) else if(t->Left())
{ {
if(browser.pageIndex > 0) if(browser.pageIndex > 0)
{ {
@ -279,7 +289,6 @@ void GuiFileBrowser::Update(GuiTrigger * t)
browser.pageIndex = 0; browser.pageIndex = 0;
listChanged = true; listChanged = true;
} }
arrowUpBtn->ResetState();
} }
else if(t->Down()) else if(t->Down())
{ {
@ -294,7 +303,7 @@ void GuiFileBrowser::Update(GuiTrigger * t)
else if(gameList[selectedItem+1]->IsVisible()) else if(gameList[selectedItem+1]->IsVisible())
{ {
gameList[selectedItem]->ResetState(); gameList[selectedItem]->ResetState();
gameList[++selectedItem]->SetState(STATE_SELECTED); gameList[++selectedItem]->SetState(STATE_SELECTED, t->chan);
} }
} }
} }
@ -309,7 +318,7 @@ void GuiFileBrowser::Update(GuiTrigger * t)
else if(selectedItem > 0) else if(selectedItem > 0)
{ {
gameList[selectedItem]->ResetState(); gameList[selectedItem]->ResetState();
gameList[--selectedItem]->SetState(STATE_SELECTED); gameList[--selectedItem]->SetState(STATE_SELECTED, t->chan);
} }
} }
@ -351,7 +360,7 @@ void GuiFileBrowser::Update(GuiTrigger * t)
if(i != selectedItem && gameList[i]->GetState() == STATE_SELECTED) if(i != selectedItem && gameList[i]->GetState() == STATE_SELECTED)
gameList[i]->ResetState(); gameList[i]->ResetState();
else if(i == selectedItem && gameList[i]->GetState() == STATE_DEFAULT) else if(i == selectedItem && gameList[i]->GetState() == STATE_DEFAULT)
gameList[selectedItem]->SetState(STATE_SELECTED); gameList[selectedItem]->SetState(STATE_SELECTED, t->chan);
} }
gameList[i]->Update(t); gameList[i]->Update(t);
@ -363,6 +372,13 @@ void GuiFileBrowser::Update(GuiTrigger * t)
} }
} }
// update the location of the scroll box based on the position in the file list
if(listChanged)
{
position = 136*(browser.pageIndex + selectedItem) / browser.numEntries;
scrollbarBoxBtn->SetPosition(0,position+36);
}
listChanged = false; listChanged = false;
if(updateCB) if(updateCB)

View File

@ -12,6 +12,16 @@
/** /**
* Constructor for the GuiImage class. * Constructor for the GuiImage class.
*/ */
GuiImage::GuiImage()
{
image = NULL;
width = 0;
height = 0;
imageangle = 0;
tile = -1;
stripe = 0;
imgType = IMAGE_DATA;
}
GuiImage::GuiImage(GuiImageData * img) GuiImage::GuiImage(GuiImageData * img)
{ {

View File

@ -248,7 +248,7 @@ void GuiKeyboard::Update(GuiTrigger * t)
for (u8 i = 0; i < _elements.size(); i++) for (u8 i = 0; i < _elements.size(); i++)
{ {
try { _elements.at(i)->Update(t); } try { _elements.at(i)->Update(t); }
catch (exception& e) { } catch (const std::exception& e) { }
} }
if(keySpace->GetState() == STATE_CLICKED) if(keySpace->GetState() == STATE_CLICKED)
@ -258,23 +258,23 @@ void GuiKeyboard::Update(GuiTrigger * t)
kbtextstr[strlen(kbtextstr)] = ' '; kbtextstr[strlen(kbtextstr)] = ' ';
kbText->SetText(kbtextstr); kbText->SetText(kbtextstr);
} }
keySpace->SetState(STATE_SELECTED); keySpace->SetState(STATE_SELECTED, t->chan);
} }
else if(keyBack->GetState() == STATE_CLICKED) else if(keyBack->GetState() == STATE_CLICKED)
{ {
kbtextstr[strlen(kbtextstr)-1] = 0; kbtextstr[strlen(kbtextstr)-1] = 0;
kbText->SetText(kbtextstr); kbText->SetText(kbtextstr);
keyBack->SetState(STATE_SELECTED); keyBack->SetState(STATE_SELECTED, t->chan);
} }
else if(keyShift->GetState() == STATE_CLICKED) else if(keyShift->GetState() == STATE_CLICKED)
{ {
shift ^= 1; shift ^= 1;
keyShift->SetState(STATE_SELECTED); keyShift->SetState(STATE_SELECTED, t->chan);
} }
else if(keyCaps->GetState() == STATE_CLICKED) else if(keyCaps->GetState() == STATE_CLICKED)
{ {
caps ^= 1; caps ^= 1;
keyCaps->SetState(STATE_SELECTED); keyCaps->SetState(STATE_SELECTED, t->chan);
} }
char txt[2] = { 0, 0 }; char txt[2] = { 0, 0 };
@ -307,7 +307,7 @@ void GuiKeyboard::Update(GuiTrigger * t)
} }
} }
kbText->SetText(kbtextstr); kbText->SetText(kbtextstr);
keyBtn[i][j]->SetState(STATE_SELECTED); keyBtn[i][j]->SetState(STATE_SELECTED, t->chan);
} }
} }
} }

View File

@ -170,7 +170,10 @@ void GuiOptionBrowser::SetFocus(int f)
void GuiOptionBrowser::ResetState() void GuiOptionBrowser::ResetState()
{ {
if(state != STATE_DISABLED) if(state != STATE_DISABLED)
{
state = STATE_DEFAULT; state = STATE_DEFAULT;
stateChan = -1;
}
for(int i=0; i<PAGESIZE; i++) for(int i=0; i<PAGESIZE; i++)
{ {
@ -290,7 +293,7 @@ void GuiOptionBrowser::Update(GuiTrigger * t)
if(i != selectedItem && optionBtn[i]->GetState() == STATE_SELECTED) if(i != selectedItem && optionBtn[i]->GetState() == STATE_SELECTED)
optionBtn[i]->ResetState(); optionBtn[i]->ResetState();
else if(i == selectedItem && optionBtn[i]->GetState() == STATE_DEFAULT) else if(i == selectedItem && optionBtn[i]->GetState() == STATE_DEFAULT)
optionBtn[selectedItem]->SetState(STATE_SELECTED); optionBtn[selectedItem]->SetState(STATE_SELECTED, t->chan);
} }
optionBtn[i]->Update(t); optionBtn[i]->Update(t);
@ -319,7 +322,7 @@ void GuiOptionBrowser::Update(GuiTrigger * t)
else if(optionBtn[selectedItem+1]->IsVisible()) else if(optionBtn[selectedItem+1]->IsVisible())
{ {
optionBtn[selectedItem]->ResetState(); optionBtn[selectedItem]->ResetState();
optionBtn[selectedItem+1]->SetState(STATE_SELECTED); optionBtn[selectedItem+1]->SetState(STATE_SELECTED, t->chan);
selectedItem++; selectedItem++;
} }
} }
@ -339,7 +342,7 @@ void GuiOptionBrowser::Update(GuiTrigger * t)
else else
{ {
optionBtn[selectedItem]->ResetState(); optionBtn[selectedItem]->ResetState();
optionBtn[selectedItem-1]->SetState(STATE_SELECTED); optionBtn[selectedItem-1]->SetState(STATE_SELECTED, t->chan);
selectedItem--; selectedItem--;
} }
} }

View File

@ -186,7 +186,10 @@ void GuiSaveBrowser::SetFocus(int f)
void GuiSaveBrowser::ResetState() void GuiSaveBrowser::ResetState()
{ {
if(state != STATE_DISABLED) if(state != STATE_DISABLED)
{
state = STATE_DEFAULT; state = STATE_DEFAULT;
stateChan = -1;
}
for(int i=0; i<SAVELISTSIZE; i++) for(int i=0; i<SAVELISTSIZE; i++)
{ {
@ -269,7 +272,7 @@ void GuiSaveBrowser::Update(GuiTrigger * t)
else if(saveBtn[selectedItem+1]->IsVisible()) else if(saveBtn[selectedItem+1]->IsVisible())
{ {
saveBtn[selectedItem]->ResetState(); saveBtn[selectedItem]->ResetState();
saveBtn[selectedItem+1]->SetState(STATE_SELECTED); saveBtn[selectedItem+1]->SetState(STATE_SELECTED, t->chan);
selectedItem += 1; selectedItem += 1;
} }
} }
@ -406,7 +409,7 @@ void GuiSaveBrowser::Update(GuiTrigger * t)
if(i != selectedItem && saveBtn[i]->GetState() == STATE_SELECTED) if(i != selectedItem && saveBtn[i]->GetState() == STATE_SELECTED)
saveBtn[i]->ResetState(); saveBtn[i]->ResetState();
else if(i == selectedItem && saveBtn[i]->GetState() == STATE_DEFAULT) else if(i == selectedItem && saveBtn[i]->GetState() == STATE_DEFAULT)
saveBtn[selectedItem]->SetState(STATE_SELECTED); saveBtn[selectedItem]->SetState(STATE_SELECTED, t->chan);
} }
saveBtn[i]->Update(t); saveBtn[i]->Update(t);

View File

@ -160,7 +160,8 @@ bool GuiTrigger::Left()
} }
else else
{ {
scrollDelay--; if(scrollDelay > 0)
scrollDelay--;
} }
} }
return false; return false;
@ -188,7 +189,8 @@ bool GuiTrigger::Right()
} }
else else
{ {
scrollDelay--; if(scrollDelay > 0)
scrollDelay--;
} }
} }
return false; return false;
@ -216,7 +218,8 @@ bool GuiTrigger::Up()
} }
else else
{ {
scrollDelay--; if(scrollDelay > 0)
scrollDelay--;
} }
} }
return false; return false;
@ -244,7 +247,8 @@ bool GuiTrigger::Down()
} }
else else
{ {
scrollDelay--; if(scrollDelay > 0)
scrollDelay--;
} }
} }
return false; return false;

View File

@ -88,7 +88,7 @@ void GuiWindow::Draw()
for (u8 i = 0; i < _elements.size(); i++) for (u8 i = 0; i < _elements.size(); i++)
{ {
try { _elements.at(i)->Draw(); } try { _elements.at(i)->Draw(); }
catch (exception& e) { } catch (const std::exception& e) { }
} }
this->UpdateEffects(); this->UpdateEffects();
@ -105,7 +105,7 @@ void GuiWindow::ResetState()
for (u8 i = 0; i < _elements.size(); i++) for (u8 i = 0; i < _elements.size(); i++)
{ {
try { _elements.at(i)->ResetState(); } try { _elements.at(i)->ResetState(); }
catch (exception& e) { } catch (const std::exception& e) { }
} }
} }
@ -116,7 +116,7 @@ void GuiWindow::SetState(int s)
for (u8 i = 0; i < _elements.size(); i++) for (u8 i = 0; i < _elements.size(); i++)
{ {
try { _elements.at(i)->SetState(s); } try { _elements.at(i)->SetState(s); }
catch (exception& e) { } catch (const std::exception& e) { }
} }
} }
@ -127,7 +127,7 @@ void GuiWindow::SetVisible(bool v)
for (u8 i = 0; i < _elements.size(); i++) for (u8 i = 0; i < _elements.size(); i++)
{ {
try { _elements.at(i)->SetVisible(v); } try { _elements.at(i)->SetVisible(v); }
catch (exception& e) { } catch (const std::exception& e) { }
} }
} }
@ -175,7 +175,7 @@ void GuiWindow::ToggleFocus(GuiTrigger * t)
break; break;
} }
} }
catch (exception& e) { } catch (const std::exception& e) { }
} }
// element with focus not found, try to give focus // element with focus not found, try to give focus
@ -191,7 +191,7 @@ void GuiWindow::ToggleFocus(GuiTrigger * t)
break; break;
} }
} }
catch (exception& e) { } catch (const std::exception& e) { }
} }
} }
// change focus // change focus
@ -210,7 +210,7 @@ void GuiWindow::ToggleFocus(GuiTrigger * t)
break; break;
} }
} }
catch (exception& e) { } catch (const std::exception& e) { }
} }
if(newfocus == -1) if(newfocus == -1)
@ -226,7 +226,7 @@ void GuiWindow::ToggleFocus(GuiTrigger * t)
break; break;
} }
} }
catch (exception& e) { } catch (const std::exception& e) { }
} }
} }
} }
@ -246,7 +246,7 @@ int GuiWindow::GetSelected()
break; break;
} }
} }
catch (exception& e) { } catch (const std::exception& e) { }
} }
return found; return found;
} }
@ -284,7 +284,7 @@ void GuiWindow::MoveSelectionHor(int dir)
} }
} }
} }
catch (exception& e) { } catch (const std::exception& e) { }
} }
if(found >= 0) if(found >= 0)
goto matchfound; goto matchfound;
@ -309,7 +309,7 @@ void GuiWindow::MoveSelectionHor(int dir)
} }
} }
} }
catch (exception& e) { } catch (const std::exception& e) { }
} }
// match found // match found
@ -358,7 +358,7 @@ void GuiWindow::MoveSelectionVert(int dir)
} }
} }
} }
catch (exception& e) { } catch (const std::exception& e) { }
} }
if(found >= 0) if(found >= 0)
goto matchfound; goto matchfound;
@ -381,7 +381,7 @@ void GuiWindow::Update(GuiTrigger * t)
for (u8 i = 0; i < _elements.size(); i++) for (u8 i = 0; i < _elements.size(); i++)
{ {
try { _elements.at(i)->Update(t); } try { _elements.at(i)->Update(t); }
catch (exception& e) { } catch (const std::exception& e) { }
} }
this->ToggleFocus(t); this->ToggleFocus(t);

View File

@ -560,46 +560,36 @@ void decodepad (int pad)
***************************************************************************/ ***************************************************************************/
void NGCReportButtons () void NGCReportButtons ()
{ {
s8 gc_px = PAD_SubStickX (0); int i, j;
u16 gc_pb = PAD_ButtonsHeld (0); Settings.TurboMode = (
(userInput[0].pad.substickX > 70) ||
(userInput[0].WPAD_Stick(1,0) > 70)
); // RIGHT on c-stick and on classic controller right joystick
#ifdef HW_RVL /* Check for menu:
s8 wm_sx = WPAD_Stick (0,1,0); * CStick left
u32 wm_pb = WPAD_ButtonsDown (0); // wiimote / expansion button info * OR "L+R+X+Y" (eg. Hombrew/Adapted SNES controllers)
#endif * OR "Home" on the wiimote or classic controller
* OR LEFT on classic right analog stick
*/
for(i=0; i<4; i++)
{
if (
(userInput[i].pad.substickX < -70) ||
(userInput[i].pad.btns_h & (PAD_TRIGGER_L | PAD_TRIGGER_R | PAD_BUTTON_X | PAD_BUTTON_Y)) ||
(userInput[i].wpad.btns_d & WPAD_BUTTON_HOME) ||
(userInput[i].wpad.btns_d & WPAD_CLASSIC_BUTTON_HOME)
)
{
ConfigRequested = 1; // go to the menu
}
}
Settings.TurboMode = ( (gc_px > 70) j = (Settings.MultiPlayer5Master == true ? 4 : 2);
#ifdef HW_RVL
|| (wm_sx > 70)
#endif
); // RIGHT on c-stick and on classic ctrlr right joystick
/*** Check for menu: for (i = 0; i < j; i++)
CStick left decodepad (i);
OR "L+R+X+Y" (eg. Hombrew/Adapted SNES controllers)
OR "Home" on the wiimote or classic controller
OR LEFT on classic right analog stick***/
if ((gc_px < -70) ||
((gc_pb & PAD_TRIGGER_L) &&
(gc_pb & PAD_TRIGGER_R ) &&
(gc_pb & PAD_BUTTON_X) &&
(gc_pb & PAD_BUTTON_Y ))
#ifdef HW_RVL
|| (wm_pb & WPAD_BUTTON_HOME)
|| (wm_pb & WPAD_CLASSIC_BUTTON_HOME)
#endif
)
{
ConfigRequested = 1; // go to the menu
}
else
{
int j = (Settings.MultiPlayer5Master == true ? 4 : 2);
for (int i = 0; i < j; i++)
decodepad (i);
}
} }
void SetControllers() void SetControllers()

View File

@ -21,50 +21,8 @@
#define PADCAL 50 #define PADCAL 50
#define MAXJP 12 // # of mappable controller buttons #define MAXJP 12 // # of mappable controller buttons
enum
{
TRIGGER_SIMPLE,
TRIGGER_HELD,
TRIGGER_BUTTON_ONLY,
TRIGGER_BUTTON_ONLY_IN_FOCUS
};
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;
class GuiTrigger
{
public:
GuiTrigger();
~GuiTrigger();
void SetSimpleTrigger(s32 ch, u32 wiibtns, u16 gcbtns);
void SetHeldTrigger(s32 ch, u32 wiibtns, u16 gcbtns);
void SetButtonOnlyTrigger(s32 ch, u32 wiibtns, u16 gcbtns);
void SetButtonOnlyInFocusTrigger(s32 ch, u32 wiibtns, u16 gcbtns);
s8 WPAD_Stick(u8 right, int axis);
bool Left();
bool Right();
bool Up();
bool Down();
u8 type;
s32 chan;
WPADData wpad;
PADData pad;
};
extern GuiTrigger userInput[4];
extern int rumbleRequest[4];
extern u32 btnmap[4][4][12]; extern u32 btnmap[4][4][12];
extern int rumbleRequest[4];
void ResetControls(); void ResetControls();
void ShutoffRumble(); void ShutoffRumble();

View File

@ -294,7 +294,7 @@ UpdateGUI (void *arg)
Menu_Render(); Menu_Render();
for(int i=0; i < 4; i++) for(int i=3; i >= 0; i--)
mainWindow->Update(&userInput[i]); mainWindow->Update(&userInput[i]);
#ifdef HW_RVL #ifdef HW_RVL
@ -1369,7 +1369,8 @@ static int MenuGame()
if(WPAD_Probe(i, NULL) == WPAD_ERR_NONE) // controller connected if(WPAD_Probe(i, NULL) == WPAD_ERR_NONE) // controller connected
{ {
level = (userInput[i].wpad.battery_level / 100.0) * 4; level = (userInput[i].wpad.battery_level / 100.0) * 4;
batteryBarImg[i]->SetTile(level); if(level > 4) level = 4;
batteryBarImg[i]->SetTile(level);
if(level == 0) if(level == 0)
batteryImg[i]->SetImage(&batteryRed); batteryImg[i]->SetImage(&batteryRed);

View File

@ -29,6 +29,7 @@
#include "filter.h" #include "filter.h"
#include "filelist.h" #include "filelist.h"
#include "audio.h" #include "audio.h"
#include "gui/gui.h"
#include "input.h" #include "input.h"
/*** Snes9x GFX Buffer ***/ /*** Snes9x GFX Buffer ***/