2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
// Buttons
|
|
|
|
|
|
|
|
#ifndef __GUI_HPP
|
|
|
|
#define __GUI_HPP
|
|
|
|
|
|
|
|
#include <ogc/pad.h>
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "wiiuse/wpad.h"
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
#include "video.hpp"
|
|
|
|
#include "FreeTypeGX.h"
|
|
|
|
#include "text.hpp"
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "music/gui_sound.h"
|
|
|
|
#include "wstringEx/wstringEx.hpp"
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
struct SButtonTextureSet
|
|
|
|
{
|
2012-12-28 15:19:40 +01:00
|
|
|
TexData left;
|
|
|
|
TexData right;
|
|
|
|
TexData center;
|
|
|
|
TexData leftSel;
|
|
|
|
TexData rightSel;
|
|
|
|
TexData centerSel;
|
2012-01-21 21:57:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class CButtonsMgr
|
|
|
|
{
|
|
|
|
public:
|
2012-11-11 19:28:03 +01:00
|
|
|
bool init();
|
2012-01-21 21:57:41 +01:00
|
|
|
void setRumble(bool enabled) { m_rumbleEnabled = enabled; }
|
|
|
|
void reserve(u32 capacity) { m_elts.reserve(capacity); }
|
2012-09-13 16:54:17 +02:00
|
|
|
s16 addButton(SFont font, const wstringEx &text, int x, int y, u32 width, u32 height, const CColor &color,
|
2012-11-03 20:16:03 +01:00
|
|
|
const SButtonTextureSet &texSet, GuiSound *clickSound = NULL, GuiSound *hoverSound = NULL);
|
2012-12-28 15:19:40 +01:00
|
|
|
s16 addLabel(SFont font, const wstringEx &text, int x, int y, u32 width, u32 height, const CColor &color, s16 style, const TexData &bg = _noTexture);
|
2012-09-13 16:54:17 +02:00
|
|
|
s16 addPicButton(const u8 *pngNormal, const u8 *pngSelected, int x, int y, u32 width, u32 height,
|
2012-11-03 20:16:03 +01:00
|
|
|
GuiSound *clickSound = NULL, GuiSound *hoverSound = NULL);
|
2012-12-28 15:19:40 +01:00
|
|
|
s16 addPicButton(TexData &texNormal, TexData &texSelected, int x, int y, u32 width, u32 height,
|
2012-11-03 20:16:03 +01:00
|
|
|
GuiSound *clickSound = NULL, GuiSound *hoverSound = NULL);
|
2012-09-13 16:54:17 +02:00
|
|
|
s16 addProgressBar(int x, int y, u32 width, u32 height, SButtonTextureSet &texSet);
|
|
|
|
void setText(s16 id, const wstringEx &text, bool unwrap = false);
|
|
|
|
void setText(s16 id, const wstringEx &text, u32 startline, bool unwrap = false);
|
2012-12-28 15:19:40 +01:00
|
|
|
void setBtnTexture(s16 id, TexData &texNormal, TexData &texSelected);
|
2012-11-30 21:54:02 +01:00
|
|
|
void freeBtnTexture(s16 id);
|
2012-12-28 15:19:40 +01:00
|
|
|
void setTexture(s16 id ,TexData &bg);
|
|
|
|
void setTexture(s16 id, TexData &bg, int width, int height);
|
2012-09-13 16:54:17 +02:00
|
|
|
void setProgress(s16 id, float f, bool instant = false);
|
|
|
|
void reset(s16 id, bool instant = false);
|
|
|
|
void moveBy(s16 id, int x, int y, bool instant = false);
|
|
|
|
void getDimensions(s16 id, int &x, int &y, u32 &width, u32 &height);
|
|
|
|
void hide(s16 id, int dx, int dy, float scaleX, float scaleY, bool instant = false);
|
|
|
|
void hide(s16 id, bool instant = false);
|
|
|
|
void show(s16 id, bool instant = false);
|
2012-01-21 21:57:41 +01:00
|
|
|
void mouse(int chan, int x, int y);
|
2012-09-15 21:14:08 +02:00
|
|
|
void setMouse(bool enable);
|
2012-01-21 21:57:41 +01:00
|
|
|
void up(void);
|
|
|
|
void down(void);
|
|
|
|
void draw(void);
|
|
|
|
void tick(void);
|
|
|
|
void noClick(bool noclick = false);
|
2012-04-08 16:48:50 +02:00
|
|
|
void noHover(bool nohover = false);
|
2012-09-13 16:54:17 +02:00
|
|
|
void click(s16 id = -1);
|
|
|
|
bool selected(s16 button = -1);
|
2012-01-21 21:57:41 +01:00
|
|
|
void setRumble(int, bool wii = false, bool gc = false);
|
2012-09-13 16:54:17 +02:00
|
|
|
void deselect(void){ for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--) m_selected[chan] = -1; }
|
2012-01-21 21:57:41 +01:00
|
|
|
void stopSounds(void);
|
|
|
|
void setSoundVolume(int vol);
|
|
|
|
private:
|
|
|
|
struct SHideParam
|
|
|
|
{
|
|
|
|
int dx;
|
|
|
|
int dy;
|
|
|
|
float scaleX;
|
|
|
|
float scaleY;
|
|
|
|
public:
|
|
|
|
SHideParam(void) : dx(0), dy(0), scaleX(1.f), scaleY(1.f) { }
|
|
|
|
};
|
|
|
|
enum EltType {
|
|
|
|
GUIELT_BUTTON,
|
|
|
|
GUIELT_LABEL,
|
|
|
|
GUIELT_PROGRESS
|
|
|
|
};
|
|
|
|
struct SElement
|
|
|
|
{
|
|
|
|
SHideParam hideParam;
|
|
|
|
EltType t;
|
|
|
|
bool visible;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int w;
|
|
|
|
int h;
|
|
|
|
Vector3D pos;
|
|
|
|
Vector3D targetPos;
|
|
|
|
u8 alpha;
|
|
|
|
u8 targetAlpha;
|
|
|
|
float scaleX;
|
|
|
|
float scaleY;
|
|
|
|
float targetScaleX;
|
|
|
|
float targetScaleY;
|
|
|
|
int moveByX;
|
|
|
|
int moveByY;
|
|
|
|
public:
|
|
|
|
virtual ~SElement(void) { }
|
|
|
|
virtual void tick(void);
|
|
|
|
protected:
|
|
|
|
SElement(void) { }
|
|
|
|
};
|
|
|
|
struct SButton : public SElement
|
|
|
|
{
|
|
|
|
SFont font;
|
|
|
|
SButtonTextureSet tex;
|
2012-09-16 14:42:08 +02:00
|
|
|
CText text;
|
2012-01-21 21:57:41 +01:00
|
|
|
CColor textColor;
|
|
|
|
float click;
|
2012-11-03 20:16:03 +01:00
|
|
|
GuiSound *clickSound;
|
|
|
|
GuiSound *hoverSound;
|
2012-01-21 21:57:41 +01:00
|
|
|
public:
|
|
|
|
SButton(void) { t = GUIELT_BUTTON; }
|
|
|
|
virtual void tick(void);
|
|
|
|
};
|
|
|
|
struct SLabel : public SElement
|
|
|
|
{
|
|
|
|
SFont font;
|
|
|
|
CText text;
|
|
|
|
CColor textColor;
|
|
|
|
u16 textStyle;
|
2012-12-28 15:19:40 +01:00
|
|
|
TexData texBg;
|
2012-01-21 21:57:41 +01:00
|
|
|
public:
|
|
|
|
SLabel(void) { t = GUIELT_LABEL; }
|
|
|
|
virtual void tick(void);
|
|
|
|
};
|
|
|
|
struct SProgressBar : public SElement
|
|
|
|
{
|
|
|
|
SButtonTextureSet tex;
|
|
|
|
float val;
|
|
|
|
float targetVal;
|
|
|
|
public:
|
|
|
|
SProgressBar(void) { t = GUIELT_PROGRESS; }
|
|
|
|
virtual void tick(void);
|
|
|
|
};
|
|
|
|
private:
|
2012-11-03 20:16:03 +01:00
|
|
|
vector<SElement*> m_elts;
|
2012-09-13 16:54:17 +02:00
|
|
|
s32 m_selected[WPAD_MAX_WIIMOTES];
|
2012-01-21 21:57:41 +01:00
|
|
|
bool m_rumbleEnabled;
|
|
|
|
u8 m_rumble[WPAD_MAX_WIIMOTES];
|
|
|
|
bool wii_rumble[WPAD_MAX_WIIMOTES];
|
|
|
|
bool gc_rumble[WPAD_MAX_WIIMOTES];
|
2012-11-03 20:16:03 +01:00
|
|
|
GuiSound *m_sndHover;
|
|
|
|
GuiSound *m_sndClick;
|
2012-01-21 21:57:41 +01:00
|
|
|
u8 m_soundVolume;
|
|
|
|
bool m_noclick;
|
2012-04-08 16:48:50 +02:00
|
|
|
bool m_nohover;
|
2012-09-15 21:14:08 +02:00
|
|
|
bool m_mouse;
|
2012-01-21 21:57:41 +01:00
|
|
|
private:
|
2012-09-16 14:42:08 +02:00
|
|
|
void _drawBtn(SButton &b, bool selected, bool click);
|
2012-01-21 21:57:41 +01:00
|
|
|
void _drawLbl(SLabel &b);
|
|
|
|
void _drawPBar(const SProgressBar &b);
|
2012-12-28 15:19:40 +01:00
|
|
|
static TexData _noTexture;
|
2012-01-21 21:57:41 +01:00
|
|
|
};
|
|
|
|
|
2012-12-21 20:51:22 +01:00
|
|
|
extern CButtonsMgr m_btnMgr;
|
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
#endif // !defined(__GUI_HPP)
|