From 3597fdcd222b5c036d9a7a32458eba2468e75492 Mon Sep 17 00:00:00 2001 From: GaryOderNichts Date: Fri, 24 Apr 2020 12:29:52 +0200 Subject: [PATCH] Use chanIdx instead of chan for State --- source/gui/GuiButton.cpp | 38 +++++++++++++++++----------------- source/gui/GuiDragListener.cpp | 4 ++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/source/gui/GuiButton.cpp b/source/gui/GuiButton.cpp index a80a10f..8f4134f 100644 --- a/source/gui/GuiButton.cpp +++ b/source/gui/GuiButton.cpp @@ -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]); } } diff --git a/source/gui/GuiDragListener.cpp b/source/gui/GuiDragListener.cpp index d9c10f8..283eb7d 100644 --- a/source/gui/GuiDragListener.cpp +++ b/source/gui/GuiDragListener.cpp @@ -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++) {