Use chanIdx instead of chan for State

This commit is contained in:
GaryOderNichts 2020-04-24 12:29:52 +02:00
parent 40d4391788
commit 3597fdcd22
2 changed files with 21 additions and 21 deletions

View File

@ -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]);
}
}

View File

@ -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++) {