diff --git a/include/gui/GuiElement.h b/include/gui/GuiElement.h index bb983b2..5a09375 100644 --- a/include/gui/GuiElement.h +++ b/include/gui/GuiElement.h @@ -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 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++) { diff --git a/source/gui/GuiElement.cpp b/source/gui/GuiElement.cpp index e6c301a..6d0a7c9 100644 --- a/source/gui/GuiElement.cpp +++ b/source/gui/GuiElement.cpp @@ -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;