2009-10-01 01:10:58 +02:00
|
|
|
|
/****************************************************************************
|
|
|
|
|
* libwiigui
|
|
|
|
|
*
|
|
|
|
|
* Tantric 2009
|
|
|
|
|
*
|
|
|
|
|
* gui_button.cpp
|
|
|
|
|
*
|
|
|
|
|
* GUI class definitions
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "gui.h"
|
|
|
|
|
|
|
|
|
|
static int scrollison;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor for the GuiButton class.
|
|
|
|
|
*/
|
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
GuiButton::GuiButton(int w, int h)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
width = w;
|
|
|
|
|
height = h;
|
|
|
|
|
image = NULL;
|
|
|
|
|
imageOver = NULL;
|
|
|
|
|
imageHold = NULL;
|
|
|
|
|
imageClick = NULL;
|
|
|
|
|
icon = NULL;
|
|
|
|
|
iconOver = NULL;
|
|
|
|
|
iconHold = NULL;
|
|
|
|
|
iconClick = NULL;
|
|
|
|
|
toolTip = NULL;
|
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
for (int i = 0; i < 3; i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
|
|
|
|
label[i] = NULL;
|
|
|
|
|
labelOver[i] = NULL;
|
|
|
|
|
labelHold[i] = NULL;
|
|
|
|
|
labelClick[i] = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
soundOver = NULL;
|
|
|
|
|
soundHold = NULL;
|
|
|
|
|
soundClick = NULL;
|
|
|
|
|
selectable = true;
|
|
|
|
|
holdable = false;
|
|
|
|
|
clickable = true;
|
|
|
|
|
|
|
|
|
|
time1 = time2 = 0;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
GuiButton::GuiButton(GuiImage* img, GuiImage* imgOver, int hor, int vert, int x, int y, GuiTrigger* trig,
|
|
|
|
|
GuiSound* sndOver, GuiSound* sndClick, u8 grow)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
width = img->GetWidth();
|
|
|
|
|
height = img->GetHeight();
|
|
|
|
|
image = img;
|
2010-09-24 02:48:03 +02:00
|
|
|
|
image->SetParent(this);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
imageOver = imgOver;
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (imageOver) imageOver->SetParent(this);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
imageHold = NULL;
|
|
|
|
|
imageClick = NULL;
|
|
|
|
|
icon = NULL;
|
|
|
|
|
iconOver = NULL;
|
|
|
|
|
iconHold = NULL;
|
|
|
|
|
iconClick = NULL;
|
|
|
|
|
toolTip = NULL;
|
|
|
|
|
alignmentHor = hor;
|
|
|
|
|
alignmentVert = vert;
|
|
|
|
|
xoffset = x;
|
|
|
|
|
yoffset = y;
|
|
|
|
|
trigger[0] = trig;
|
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
for (int i = 0; i < 3; i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
|
|
|
|
label[i] = NULL;
|
|
|
|
|
labelOver[i] = NULL;
|
|
|
|
|
labelHold[i] = NULL;
|
|
|
|
|
labelClick[i] = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
soundOver = sndOver;
|
|
|
|
|
soundHold = NULL;
|
|
|
|
|
soundClick = sndClick;
|
|
|
|
|
selectable = true;
|
|
|
|
|
holdable = false;
|
|
|
|
|
clickable = true;
|
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (grow == 1)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
|
|
|
|
effectsOver |= EFFECT_SCALE;
|
|
|
|
|
effectAmountOver = 4;
|
|
|
|
|
effectTargetOver = 110;
|
|
|
|
|
}
|
|
|
|
|
time1 = time2 = 0;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
GuiButton::GuiButton(GuiImage* img, GuiImage* imgOver, int hor, int vert, int x, int y, GuiTrigger* trig,
|
|
|
|
|
GuiSound* sndOver, GuiSound* sndClick, u8 grow, GuiTooltip* tt, int ttx, int tty, int h_align, int v_align)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
width = img->GetWidth();
|
|
|
|
|
height = img->GetHeight();
|
|
|
|
|
image = img;
|
2010-09-24 02:48:03 +02:00
|
|
|
|
image->SetParent(this);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
imageOver = imgOver;
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (imageOver) imageOver->SetParent(this);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
imageHold = NULL;
|
|
|
|
|
imageClick = NULL;
|
|
|
|
|
icon = NULL;
|
|
|
|
|
iconOver = NULL;
|
|
|
|
|
iconHold = NULL;
|
|
|
|
|
iconClick = NULL;
|
|
|
|
|
toolTip = NULL;
|
|
|
|
|
alignmentHor = hor;
|
|
|
|
|
alignmentVert = vert;
|
|
|
|
|
xoffset = x;
|
|
|
|
|
yoffset = y;
|
|
|
|
|
trigger[0] = trig;
|
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
for (int i = 0; i < 3; i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
|
|
|
|
label[i] = NULL;
|
|
|
|
|
labelOver[i] = NULL;
|
|
|
|
|
labelHold[i] = NULL;
|
|
|
|
|
labelClick[i] = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
soundOver = sndOver;
|
|
|
|
|
soundHold = NULL;
|
|
|
|
|
soundClick = sndClick;
|
|
|
|
|
selectable = true;
|
|
|
|
|
holdable = false;
|
|
|
|
|
clickable = true;
|
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (grow == 1)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
|
|
|
|
effectsOver |= EFFECT_SCALE;
|
|
|
|
|
effectAmountOver = 4;
|
|
|
|
|
effectTargetOver = 110;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toolTip = tt;
|
2010-09-24 02:48:03 +02:00
|
|
|
|
toolTip->SetParent(this);
|
|
|
|
|
toolTip->SetAlignment(h_align, v_align);
|
|
|
|
|
toolTip->SetPosition(ttx, tty);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
|
|
time1 = time2 = 0;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Destructor for the GuiButton class.
|
|
|
|
|
*/
|
2010-02-09 11:59:55 +01:00
|
|
|
|
GuiButton::~GuiButton()
|
|
|
|
|
{
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
void GuiButton::SetImage(GuiImage* img)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
|
|
|
|
image = img;
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (img) img->SetParent(this);
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
void GuiButton::SetImageOver(GuiImage* img)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
|
|
|
|
imageOver = img;
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (img) img->SetParent(this);
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
void GuiButton::SetImageHold(GuiImage* img)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
|
|
|
|
imageHold = img;
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (img) img->SetParent(this);
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
void GuiButton::SetImageClick(GuiImage* img)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
|
|
|
|
imageClick = img;
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (img) img->SetParent(this);
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
void GuiButton::SetIcon(GuiImage* img)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
|
|
|
|
icon = img;
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (img) img->SetParent(this);
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
void GuiButton::SetIconOver(GuiImage* img)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
|
|
|
|
iconOver = img;
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (img) img->SetParent(this);
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
void GuiButton::SetIconHold(GuiImage* img)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
|
|
|
|
iconHold = img;
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (img) img->SetParent(this);
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
void GuiButton::SetIconClick(GuiImage* img)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
|
|
|
|
iconClick = img;
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (img) img->SetParent(this);
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
void GuiButton::SetLabel(GuiText* txt, int n)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
|
|
|
|
label[n] = txt;
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (txt) txt->SetParent(this);
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
void GuiButton::SetLabelOver(GuiText* txt, int n)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
|
|
|
|
labelOver[n] = txt;
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (txt) txt->SetParent(this);
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
void GuiButton::SetLabelHold(GuiText* txt, int n)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
|
|
|
|
labelHold[n] = txt;
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (txt) txt->SetParent(this);
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
void GuiButton::SetLabelClick(GuiText* txt, int n)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
|
|
|
|
labelClick[n] = txt;
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (txt) txt->SetParent(this);
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
void GuiButton::SetSoundOver(GuiSound * snd)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
|
|
|
|
soundOver = snd;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
void GuiButton::SetSoundHold(GuiSound * snd)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
|
|
|
|
soundHold = snd;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
void GuiButton::SetSoundClick(GuiSound * snd)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
|
|
|
|
soundClick = snd;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
void GuiButton::SetToolTip(GuiTooltip* tt, int x, int y, int h_align, int v_align)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (tt)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
|
|
|
|
toolTip = tt;
|
2010-09-24 02:48:03 +02:00
|
|
|
|
toolTip->SetParent(this);
|
|
|
|
|
toolTip->SetAlignment(h_align, v_align);
|
|
|
|
|
toolTip->SetPosition(x, y);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
|
|
}
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
|
void GuiButton::RemoveToolTip()
|
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
|
|
|
|
toolTip = NULL;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-02-09 11:59:55 +01:00
|
|
|
|
void GuiButton::RemoveSoundOver()
|
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
|
|
|
|
soundOver = NULL;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
2010-02-09 11:59:55 +01:00
|
|
|
|
void GuiButton::RemoveSoundClick()
|
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
|
|
|
|
soundClick = NULL;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
void GuiButton::SetSkew(int XX1, int YY1, int XX2, int YY2, int XX3, int YY3, int XX4, int YY4)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (image)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
|
|
|
|
image->xx1 = XX1;
|
|
|
|
|
image->yy1 = YY1;
|
|
|
|
|
image->xx2 = XX2;
|
|
|
|
|
image->yy2 = YY2;
|
|
|
|
|
image->xx3 = XX3;
|
|
|
|
|
image->yy3 = YY3;
|
|
|
|
|
image->xx4 = XX4;
|
|
|
|
|
image->yy4 = YY4;
|
|
|
|
|
}
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
void GuiButton::SetSkew(int *skew)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (image) image->SetSkew(skew);
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Draw the button on screen
|
|
|
|
|
*/
|
2010-02-09 11:59:55 +01:00
|
|
|
|
void GuiButton::Draw()
|
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (!this->IsVisible()) return;
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
|
|
// draw image
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if ((state == STATE_SELECTED || state == STATE_HELD) && imageOver)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
imageOver->Draw();
|
2010-09-24 02:48:03 +02:00
|
|
|
|
else if (image) image->Draw();
|
2010-09-19 01:16:05 +02:00
|
|
|
|
// draw icon
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if ((state == STATE_SELECTED || state == STATE_HELD) && iconOver)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
iconOver->Draw();
|
2010-09-24 02:48:03 +02:00
|
|
|
|
else if (icon) icon->Draw();
|
2010-09-19 01:16:05 +02:00
|
|
|
|
// draw text
|
2010-09-24 02:48:03 +02:00
|
|
|
|
for (int i = 0; i < 3; i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if ((state == STATE_SELECTED || state == STATE_HELD) && labelOver[i])
|
2010-09-19 01:16:05 +02:00
|
|
|
|
labelOver[i]->Draw();
|
2010-09-24 02:48:03 +02:00
|
|
|
|
else if (label[i]) label[i]->Draw();
|
2010-09-19 01:16:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this->UpdateEffects();
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
2010-02-09 11:59:55 +01:00
|
|
|
|
void GuiButton::DrawTooltip()
|
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (this->IsVisible() && state == STATE_SELECTED && toolTip)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (time2 == 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
|
time(&time1);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
time2 = time1;
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (time1 != 0) // timer l<>uft
|
|
|
|
|
time(&time1);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (time1 == 0 || difftime(time1, time2) >= 2)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (time1 != 0) // timer gerade abgelaufen
|
|
|
|
|
toolTip->SetEffect(EFFECT_FADE, 20);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
time1 = 0;
|
|
|
|
|
toolTip->Draw();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (time2 != 0 && time1 == 0) // timer abgelaufen, gerade DESELECT
|
|
|
|
|
if (toolTip) toolTip->SetEffect(EFFECT_FADE, -20);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
time2 = 0;
|
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (toolTip && toolTip->GetEffect()) toolTip->Draw();
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
void GuiButton::ScrollIsOn(int f)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
2009-10-01 01:10:58 +02:00
|
|
|
|
scrollison = f;
|
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
void GuiButton::Update(GuiTrigger * t)
|
2010-02-09 11:59:55 +01:00
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
|
LOCK( this );
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (!this->IsVisible() || state == STATE_CLICKED || state == STATE_DISABLED || !t)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
return;
|
2010-09-24 02:48:03 +02:00
|
|
|
|
else if (parentElement && parentElement->GetState() == STATE_DISABLED) return;
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
|
|
#ifdef HW_RVL
|
|
|
|
|
// cursor
|
|
|
|
|
if ( t->wpad.ir.valid )
|
|
|
|
|
{
|
|
|
|
|
if ( this->IsInside( t->wpad.ir.x, t->wpad.ir.y ) )
|
|
|
|
|
{
|
|
|
|
|
if ( state == STATE_DEFAULT ) // we weren't on the button before!
|
2010-09-24 02:48:03 +02:00
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
|
|
|
|
if ( scrollison == 0 )
|
|
|
|
|
{
|
|
|
|
|
this->SetState( STATE_SELECTED, t->chan );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( this->Rumble() && scrollison == 0 )
|
2010-09-24 02:48:03 +02:00
|
|
|
|
rumbleRequest[t->chan] = 1;
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
|
|
if ( soundOver && scrollison == 0 )
|
2010-09-24 02:48:03 +02:00
|
|
|
|
soundOver->Play();
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
|
|
if ( effectsOver && !effects && scrollison == 0 )
|
|
|
|
|
{
|
|
|
|
|
// initiate effects
|
|
|
|
|
effects = effectsOver;
|
|
|
|
|
effectAmount = effectAmountOver;
|
|
|
|
|
effectTarget = effectTargetOver;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ( state == STATE_SELECTED && ( stateChan == t->chan || stateChan == -1 ) )
|
2010-09-24 02:48:03 +02:00
|
|
|
|
this->ResetState();
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
|
|
if ( effectTarget == effectTargetOver && effectAmount == effectAmountOver )
|
|
|
|
|
{
|
|
|
|
|
// initiate effects (in reverse)
|
|
|
|
|
effects = effectsOver;
|
|
|
|
|
effectAmount = -effectAmountOver;
|
|
|
|
|
effectTarget = 100;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (state == STATE_SELECTED && (stateChan == t->chan || stateChan == -1)) this->ResetState();
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (effectTarget == effectTargetOver && effectAmount == effectAmountOver)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
|
|
|
|
// initiate effects (in reverse)
|
|
|
|
|
effects = effectsOver;
|
|
|
|
|
effectAmount = -effectAmountOver;
|
|
|
|
|
effectTarget = 100;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// button triggers
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (this->IsClickable() && scrollison == 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
|
|
|
|
s32 wm_btns, wm_btns_trig, cc_btns, cc_btns_trig;
|
2010-09-24 02:48:03 +02:00
|
|
|
|
for (int i = 0; i < 6; i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan))
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
|
|
|
|
// higher 16 bits only (wiimote)
|
|
|
|
|
wm_btns = t->wpad.btns_d << 16;
|
|
|
|
|
wm_btns_trig = trigger[i]->wpad.btns_d << 16;
|
|
|
|
|
|
|
|
|
|
// lower 16 bits only (classic controller)
|
|
|
|
|
cc_btns = t->wpad.btns_d >> 16;
|
|
|
|
|
cc_btns_trig = trigger[i]->wpad.btns_d >> 16;
|
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
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_d && t->pad.btns_d > 0))
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (t->chan == stateChan || stateChan == -1)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (state == STATE_SELECTED)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
|
this->SetState(STATE_CLICKED, t->chan);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (soundClick) soundClick->Play();
|
2010-09-19 01:16:05 +02:00
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
else if (trigger[i]->type == TRIGGER_BUTTON_ONLY)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
|
this->SetState(STATE_CLICKED, t->chan);
|
|
|
|
|
if (soundClick) soundClick->Play();
|
2010-09-19 01:16:05 +02:00
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
else if (trigger[i]->type == TRIGGER_BUTTON_ONLY_IN_FOCUS && parentElement->IsFocused())
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
|
this->SetState(STATE_CLICKED, t->chan);
|
|
|
|
|
if (soundClick) soundClick->Play();
|
2010-09-19 01:16:05 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (this->IsHoldable())
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
|
|
|
|
bool held = false;
|
|
|
|
|
s32 wm_btns, wm_btns_h, wm_btns_trig, cc_btns, cc_btns_h, cc_btns_trig;
|
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
for (int i = 0; i < 6; i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan))
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
|
|
|
|
// higher 16 bits only (wiimote)
|
|
|
|
|
wm_btns = t->wpad.btns_d << 16;
|
|
|
|
|
wm_btns_h = t->wpad.btns_h << 16;
|
|
|
|
|
wm_btns_trig = trigger[i]->wpad.btns_h << 16;
|
|
|
|
|
|
|
|
|
|
// lower 16 bits only (classic controller)
|
|
|
|
|
cc_btns = t->wpad.btns_d >> 16;
|
|
|
|
|
cc_btns_h = t->wpad.btns_h >> 16;
|
|
|
|
|
cc_btns_trig = trigger[i]->wpad.btns_h >> 16;
|
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
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))
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (trigger[i]->type == TRIGGER_HELD && state == STATE_SELECTED && (t->chan == stateChan
|
|
|
|
|
|| stateChan == -1)) this->SetState(STATE_CLICKED, t->chan);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (((t->wpad.btns_h > 0 && wm_btns_h == wm_btns_trig) || (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))
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (trigger[i]->type == TRIGGER_HELD) held = true;
|
2010-09-19 01:16:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (!held && state == STATE_HELD && stateChan == t->chan)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
|
|
|
|
this->ResetState();
|
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
|
else if (held && state == STATE_CLICKED && stateChan == t->chan)
|
2010-09-19 01:16:05 +02:00
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
|
this->SetState(STATE_HELD, t->chan);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
|
if (updateCB) updateCB(this);
|
2009-10-01 01:10:58 +02:00
|
|
|
|
}
|
|
|
|
|
|