Esempio n. 1
0
void Options::handle(View* view, OptionSet set, int lastIndex) {
  vector<ListElem> options;
  options.emplace_back("Change settings:", ListElem::TITLE);
  for (OptionId option : optionSets.at(set))
    options.push_back(ListElem(names.at(option),
          getValueString(option, getValue(option))).setTip(hints.at(option)));
  options.emplace_back("Done");
  auto index = view->chooseFromList("", options, lastIndex, getMenuType(set));
  if (!index || (*index) == optionSets.at(set).size())
    return;
  OptionId option = optionSets.at(set)[*index];
  changeValue(option, getValue(option), view);
  handle(view, set, *index);
}
Esempio n. 2
0
bool Options::handleOrExit(View* view, OptionSet set, int lastIndex) {
  if (!optionSets.count(set))
    return true;
  vector<ListElem> options;
  options.emplace_back("Change settings:", ListElem::TITLE);
  for (OptionId option : optionSets.at(set))
    options.push_back(ListElem(names.at(option),
          getValueString(option, getValue(option))).setTip(hints.at(option)));
  options.emplace_back("Done");
  if (lastIndex == -1)
    lastIndex = optionSets.at(set).size();
  auto index = view->chooseFromList("", options, lastIndex, getMenuType(set));
  if (!index)
    return false;
  else if (index && (*index) == optionSets.at(set).size())
    return true;
  OptionId option = optionSets.at(set)[*index];
  changeValue(option, getValue(option), view);
  return handleOrExit(view, set, *index);
}
Esempio n. 3
0
void EditorScene::showMenu(MenuState state, EditorMenu* menu)
{
    menu->setEditorListener(this);
    
    switch (state)
    {
        case MenuState::FIRST:
        {
            this->_hideMenu(m_secondMenuContainer);
            this->_hideMenu(m_thirdMenuContainer);
            
            if (m_state == MenuState::FIRST)
            {
                auto _menu = m_firstMenuContainer->getMenu();
                
                
                if (_menu->getMenuType() != menu->getMenuType())
                {
                    this->_hideMenu(m_firstMenuContainer);
                }
                else
                {
                    return;
                }
            }
            m_firstMenuContainer->setMenu(menu);
            this->_showMenu(m_firstMenuContainer);
            
            m_state = MenuState::FIRST;
        }
            break;
        case MenuState::SECOND:
        {
            if (m_state == MenuState::NONE)
            {
                CCASSERT(0, "MENU ERROR!");
            }
            this->_hideMenu(m_thirdMenuContainer);
            if (m_state == MenuState::SECOND)
            {
                auto _menu = m_secondMenuContainer->getMenu();
                if (_menu->getMenuType() != menu->getMenuType())
                {
                    this->_hideMenu(m_secondMenuContainer);
                }
                else
                {
                    return;
                }
            }
            
            m_secondMenuContainer->setMenu(menu);
            this->_showMenu(m_secondMenuContainer);
            
            m_state = MenuState::SECOND;
        } break;
            
        case MenuState::THIRD:
        {
            if (m_state == MenuState::NONE || m_state == MenuState::FIRST)
            {
                CCASSERT(0, "MENU ERROR!");
            }
            if (m_state == MenuState::THIRD)
            {
                auto _menu = m_thirdMenuContainer->getMenu();
                if (_menu->getMenuType() != menu->getMenuType())
                {
                    this->_hideMenu(m_thirdMenuContainer);
                }
                else
                {
                    return;
                }
            }
            
            m_thirdMenuContainer->setMenu(menu);
            this->_showMenu(m_thirdMenuContainer);
            
            m_state = MenuState::THIRD;
        } break;
            
        default:
            break;
    }
    
    this->layoutScene();
}