void MenuHandler::moveUp() { if (selectedMode == MAIN_MENU) { if (selectedOption == QUIT) setSelectedOption(START_GAME); } else if (selectedMode == PAUSE_MENU) { if (selectedOption == QUIT) setSelectedOption(CONTINUE); } }
void MenuHandler::moveDown() { if (selectedMode == MAIN_MENU) { if (selectedOption == START_GAME) setSelectedOption(QUIT); } else if (selectedMode == PAUSE_MENU) { if (selectedOption == CONTINUE) setSelectedOption(QUIT); } }
CG::InteractionResult Dropdown::mouseButtonEvent(const MouseButtonEvent &ev) { CG::InteractionResult result; if (ev.eventType != MouseButtonEvent::PRESSED || ev.button != 0) { return result; } if (isActive()) { setActiveState(false); result.contolStateChanged = true; int currentSelection = _getSelectionLineAtLocation(ev.x, ev.y); if (currentSelection != NOTHING_SELECTED) { result.newDataAvailable = true; result.newControlState = _selectionOptions.at(currentSelection).id; result.newStateLabel = _selectionOptions.at(currentSelection).label; setSelectedOption(currentSelection); notifyCallback(); } } else { if (boundingBox.inside(ev.x, ev.y)) { setActiveState(true); result.contolStateChanged = true; } } return result; }
void Dropdown::setSelectedOption(std::string selectionLabel) { for (int i = 0; i < _selectionOptions.size(); i++) { if (_selectionOptions.at(i).label == selectionLabel) { setSelectedOption(i); break; } } this->notifyControlNeedsRedraw(); }
void Dropdown::setSelectedOptionById(int id) { for (int i = 0; i < _selectionOptions.size(); i++) { if (_selectionOptions.at(i).id == id) { setSelectedOption(i); break; } } this->notifyControlNeedsRedraw(); }
void Dropdown::setNothingSelectedText(string text) { _noSelectionText = text; setSelectedOption(_currentSelectionIndex); notifyControlNeedsRedraw(); }
void Dropdown::setToNothingSelected(void) { setSelectedOption(NOTHING_SELECTED); }