mirror of
https://github.com/wiiu-env/libgui.git
synced 2024-12-24 15:21:50 +01:00
Merge pull request #1 from GaryOderNichts/wiiu-env-master
fix state to support all channels
This commit is contained in:
commit
45bad52a0c
@ -241,30 +241,30 @@ public:
|
||||
//!\param s State (STATE_DEFAULT, STATE_SELECTED, STATE_CLICKED, STATE_DISABLED)
|
||||
//!\param c Controller channel (0-3, -1 = none)
|
||||
virtual void setState(int32_t s, int32_t c = -1) {
|
||||
if(c >= 0 && c < 4) {
|
||||
if(c >= 0 && c < 5) {
|
||||
state[c] |= s;
|
||||
} else {
|
||||
for(int32_t i = 0; i < 4; i++)
|
||||
for(int32_t i = 0; i < 5; i++)
|
||||
state[i] |= s;
|
||||
}
|
||||
stateChan = c;
|
||||
stateChanged(this, s, c);
|
||||
}
|
||||
virtual void clearState(int32_t s, int32_t c = -1) {
|
||||
if(c >= 0 && c < 4) {
|
||||
if(c >= 0 && c < 5) {
|
||||
state[c] &= ~s;
|
||||
} else {
|
||||
for(int32_t i = 0; i < 4; i++)
|
||||
for(int32_t i = 0; i < 5; i++)
|
||||
state[i] &= ~s;
|
||||
}
|
||||
stateChan = c;
|
||||
stateChanged(this, s, c);
|
||||
}
|
||||
virtual bool isStateSet(int32_t s, int32_t c = -1) const {
|
||||
if(c >= 0 && c < 4) {
|
||||
if(c >= 0 && c < 5) {
|
||||
return (state[c] & s) != 0;
|
||||
} else {
|
||||
for(int32_t i = 0; i < 4; i++)
|
||||
for(int32_t i = 0; i < 5; i++)
|
||||
if((state[i] & s) != 0)
|
||||
return true;
|
||||
|
||||
@ -283,7 +283,7 @@ public:
|
||||
};
|
||||
//!Resets the element's state to STATE_DEFAULT
|
||||
virtual void resetState() {
|
||||
for(int32_t i = 0; i < 4; i++)
|
||||
for(int32_t i = 0; i < 5; i++)
|
||||
state[i] = STATE_DEFAULT;
|
||||
stateChan = -1;
|
||||
}
|
||||
@ -519,7 +519,7 @@ protected:
|
||||
float scaleY; //!< Element scale (1 = 100%)
|
||||
float scaleZ; //!< Element scale (1 = 100%)
|
||||
int32_t alignment; //!< Horizontal element alignment, respective to parent element
|
||||
int32_t state[4]; //!< Element state (DEFAULT, SELECTED, CLICKED, DISABLED)
|
||||
int32_t state[5]; //!< Element state (DEFAULT, SELECTED, CLICKED, DISABLED)
|
||||
int32_t stateChan; //!< Which controller channel is responsible for the last change in state
|
||||
GuiElement * parentElement; //!< Parent element
|
||||
|
||||
|
@ -159,15 +159,15 @@ void GuiButton::draw(CVideo *v) {
|
||||
}
|
||||
|
||||
void GuiButton::update(GuiController * c) {
|
||||
if(!c || isStateSet(STATE_DISABLED|STATE_HIDDEN|STATE_DISABLE_INPUT, c->chan))
|
||||
if(!c || isStateSet(STATE_DISABLED|STATE_HIDDEN|STATE_DISABLE_INPUT, c->chanIdx))
|
||||
return;
|
||||
else if(parentElement && (parentElement->isStateSet(STATE_DISABLED|STATE_HIDDEN|STATE_DISABLE_INPUT, c->chan)))
|
||||
else if(parentElement && (parentElement->isStateSet(STATE_DISABLED|STATE_HIDDEN|STATE_DISABLE_INPUT, c->chanIdx)))
|
||||
return;
|
||||
|
||||
if(selectable) {
|
||||
if(c->data.validPointer && this->isInside(c->data.x, c->data.y)) {
|
||||
if(!isStateSet(STATE_OVER, c->chan)) {
|
||||
setState(STATE_OVER, c->chan);
|
||||
if(!isStateSet(STATE_OVER, c->chanIdx)) {
|
||||
setState(STATE_OVER, c->chanIdx);
|
||||
|
||||
//if(this->isRumbleActive())
|
||||
// this->rumble(t->chan);
|
||||
@ -184,8 +184,8 @@ void GuiButton::update(GuiController * c) {
|
||||
|
||||
pointedOn(this, c);
|
||||
}
|
||||
} else if(isStateSet(STATE_OVER, c->chan)) {
|
||||
this->clearState(STATE_OVER, c->chan);
|
||||
} else if(isStateSet(STATE_OVER, c->chanIdx)) {
|
||||
this->clearState(STATE_OVER, c->chanIdx);
|
||||
pointedOff(this, c);
|
||||
|
||||
if(effectTarget == effectTargetOver && effectAmount == effectAmountOver) {
|
||||
@ -207,25 +207,25 @@ void GuiButton::update(GuiController * c) {
|
||||
int32_t isClicked = trigger[i]->clicked(c);
|
||||
|
||||
if( !clickedTrigger && (isClicked != GuiTrigger::CLICKED_NONE)
|
||||
&& (trigger[i]->isClickEverywhere() || (isStateSet(STATE_SELECTED | STATE_OVER, c->chan) && trigger[i]->isSelectionClickEverywhere()) || this->isInside(c->data.x, c->data.y))) {
|
||||
&& (trigger[i]->isClickEverywhere() || (isStateSet(STATE_SELECTED | STATE_OVER, c->chanIdx) && trigger[i]->isSelectionClickEverywhere()) || this->isInside(c->data.x, c->data.y))) {
|
||||
if(soundClick)
|
||||
soundClick->Play();
|
||||
|
||||
clickedTrigger = trigger[i];
|
||||
|
||||
if(!isStateSet(STATE_CLICKED, c->chan)) {
|
||||
if(!isStateSet(STATE_CLICKED, c->chanIdx)) {
|
||||
if(isClicked == GuiTrigger::CLICKED_TOUCH) {
|
||||
setState(STATE_CLICKED_TOUCH, c->chan);
|
||||
setState(STATE_CLICKED_TOUCH, c->chanIdx);
|
||||
} else {
|
||||
setState(STATE_CLICKED, c->chan);
|
||||
setState(STATE_CLICKED, c->chanIdx);
|
||||
}
|
||||
}
|
||||
|
||||
clicked(this, c, trigger[i]);
|
||||
} else if((isStateSet(STATE_CLICKED, c->chan) || isStateSet(STATE_CLICKED_TOUCH, c->chan)) && (clickedTrigger == trigger[i]) && !isStateSet(STATE_HELD, c->chan) && !trigger[i]->held(c) && ((isClicked == GuiTrigger::CLICKED_NONE) || trigger[i]->released(c))) {
|
||||
if((isStateSet(STATE_CLICKED_TOUCH, c->chan) && this->isInside(c->data.x, c->data.y)) || (isStateSet(STATE_CLICKED, c->chan))) {
|
||||
} else if((isStateSet(STATE_CLICKED, c->chanIdx) || isStateSet(STATE_CLICKED_TOUCH, c->chanIdx)) && (clickedTrigger == trigger[i]) && !isStateSet(STATE_HELD, c->chanIdx) && !trigger[i]->held(c) && ((isClicked == GuiTrigger::CLICKED_NONE) || trigger[i]->released(c))) {
|
||||
if((isStateSet(STATE_CLICKED_TOUCH, c->chanIdx) && this->isInside(c->data.x, c->data.y)) || (isStateSet(STATE_CLICKED, c->chanIdx))) {
|
||||
clickedTrigger = NULL;
|
||||
clearState(STATE_CLICKED, c->chan);
|
||||
clearState(STATE_CLICKED, c->chanIdx);
|
||||
released(this, c, trigger[i]);
|
||||
}
|
||||
}
|
||||
@ -235,21 +235,21 @@ void GuiButton::update(GuiController * c) {
|
||||
bool isHeld = trigger[i]->held(c);
|
||||
|
||||
if( (!heldTrigger || heldTrigger == trigger[i]) && isHeld
|
||||
&& (trigger[i]->isHoldEverywhere() || (isStateSet(STATE_SELECTED | STATE_OVER, c->chan) && trigger[i]->isSelectionClickEverywhere()) || this->isInside(c->data.x, c->data.y))) {
|
||||
&& (trigger[i]->isHoldEverywhere() || (isStateSet(STATE_SELECTED | STATE_OVER, c->chanIdx) && trigger[i]->isSelectionClickEverywhere()) || this->isInside(c->data.x, c->data.y))) {
|
||||
heldTrigger = trigger[i];
|
||||
|
||||
if(!isStateSet(STATE_HELD, c->chan))
|
||||
setState(STATE_HELD, c->chan);
|
||||
if(!isStateSet(STATE_HELD, c->chanIdx))
|
||||
setState(STATE_HELD, c->chanIdx);
|
||||
|
||||
held(this, c, trigger[i]);
|
||||
} else if(isStateSet(STATE_HELD, c->chan) && (heldTrigger == trigger[i]) && (!isHeld || trigger[i]->released(c))) {
|
||||
} else if(isStateSet(STATE_HELD, c->chanIdx) && (heldTrigger == trigger[i]) && (!isHeld || trigger[i]->released(c))) {
|
||||
//! click is removed at this point and converted to held
|
||||
if(clickedTrigger == trigger[i]) {
|
||||
clickedTrigger = NULL;
|
||||
clearState(STATE_CLICKED, c->chan);
|
||||
clearState(STATE_CLICKED, c->chanIdx);
|
||||
}
|
||||
heldTrigger = NULL;
|
||||
clearState(STATE_HELD, c->chan);
|
||||
clearState(STATE_HELD, c->chanIdx);
|
||||
released(this, c, trigger[i]);
|
||||
}
|
||||
}
|
||||
|
@ -54,9 +54,9 @@ void GuiDragListener::setTrigger(GuiTrigger * t, int32_t idx) {
|
||||
}
|
||||
|
||||
void GuiDragListener::update(GuiController * c) {
|
||||
if(!c || isStateSet(STATE_DISABLED|STATE_HIDDEN|STATE_DISABLE_INPUT, c->chan))
|
||||
if(!c || isStateSet(STATE_DISABLED|STATE_HIDDEN|STATE_DISABLE_INPUT, c->chanIdx))
|
||||
return;
|
||||
else if(parentElement && (parentElement->isStateSet(STATE_DISABLED|STATE_HIDDEN|STATE_DISABLE_INPUT, c->chan)))
|
||||
else if(parentElement && (parentElement->isStateSet(STATE_DISABLED|STATE_HIDDEN|STATE_DISABLE_INPUT, c->chanIdx)))
|
||||
return;
|
||||
|
||||
for(int32_t i = 0; i < iMaxGuiTriggers; i++) {
|
||||
|
@ -33,7 +33,7 @@ GuiElement::GuiElement() {
|
||||
scaleX = 1.0f;
|
||||
scaleY = 1.0f;
|
||||
scaleZ = 1.0f;
|
||||
for(int32_t i = 0; i < 4; i++)
|
||||
for(int32_t i = 0; i < 5; i++)
|
||||
state[i] = STATE_DEFAULT;
|
||||
stateChan = -1;
|
||||
parentElement = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user