bool CGroup::CoreHandleEvent(CWidget *emitter, int event) { if (event == EVENT_REQFOCUS) { FocusWidget(emitter); PushEvent(EVENT_REQFOCUS); return true; } return CWidget::CoreHandleEvent(emitter, event); }
void CGroup::SetValidWidget(CWidget *ignore) { TChildList::iterator itprev, itnext; itprev = itnext = std::find(m_Childs.begin(), m_Childs.end(), ignore); do { if (itprev != m_Childs.begin()) { itprev--; if ((*itprev)->Enabled() && ((*itprev)->CanFocus() || CanFocusChilds(*itprev))) { FocusWidget(*itprev); return; } } if (*itnext != m_Childs.back()) { itnext++; if (itnext != m_Childs.end()) { if ((*itnext)->Enabled() && ((*itnext)->CanFocus() || CanFocusChilds(*itnext))) { FocusWidget(*itnext); return; } } } } while ((itprev != m_Childs.begin()) || (*itnext != m_Childs.back())); // Haven't found a focusable widget m_pFocusedWidget = NULL; }
void SendScoreMenu::onFocus() { // Get player score and check if new highscore m_score = EntityManager::getInstance().getPlayer()->getScore(); if (m_score > UserSettings::getHighscore()) { UserSettings::setHighscore(m_score); lab_result_->setString(I18n::templatize("sendscore.new_record", "{score}", m_score)); } else { lab_result_->setString(I18n::templatize("sendscore.no_record", "{score}", m_score)); } lab_result_->setCharacterSize(30); but_send_score_->SetVisible(true); FocusWidget(but_send_score_); lab_pseudo_->SetVisible(false); txt_pseudo_->SetVisible(false); but_commit_->SetVisible(false); }
bool CGroup::SetPrevFocWidget(bool cont) { if (m_Childs.empty()) return false; TChildList::reverse_iterator it = m_Childs.rbegin(); if (cont && m_pFocusedWidget && Focused()) { TChildList::reverse_iterator f = std::find(m_Childs.rbegin(), m_Childs.rend(), m_pFocusedWidget); if (f != m_Childs.rend()) { it = f; if (!CanFocusChilds(*it)) it++; } } for (; it!=m_Childs.rend(); it++) { if (!(*it)->Enabled()) continue; if (!(*it)->CanFocus()) { if (CanFocusChilds(*it)) { if (!GetGroupWidget(*it)->SetPrevFocWidget(cont)) continue; } else continue; } FocusWidget(*it); return true; } return false; }
void SendScoreMenu::EventCallback(int id) { switch (id) { case 0: but_commit_->SetVisible(true); txt_pseudo_->SetVisible(true); lab_pseudo_->SetVisible(true); FocusWidget(txt_pseudo_); but_send_score_->SetVisible(false); break; case 1: EntityManager::getInstance().setMode(EntityManager::INFINITY_MODE); ControlPanel::getInstance().setHighscore(UserSettings::getHighscore()); Game::getInstance().setCurrentScreen(Game::SC_PlayScreen); break; case 2: Game::getInstance().setCurrentScreen(Game::SC_MainMenu); break; case 3: if (EntityManager::getInstance().getPlayer()->isCheater()) { lab_result_->setCharacterSize(20); lab_result_->setString(_t("sendscore.error_cheat")); } else if (!Game::getInstance().resourcesChecked()) { lab_result_->setCharacterSize(20); lab_result_->setString(_t("sendscore.error_altered_res")); } else { uploadScore(); } break; } }