diff --git a/src/states_screens/arenas_screen.cpp b/src/states_screens/arenas_screen.cpp index 2d89429af..dd06b8c07 100644 --- a/src/states_screens/arenas_screen.cpp +++ b/src/states_screens/arenas_screen.cpp @@ -68,6 +68,24 @@ ArenasScreen::ArenasScreen() : Screen("arenas.stkgui") // ------------------------------------------------------------------------------------------------------ +void ArenasScreen::init() +{ + buildTrackList(); + + // select something by default for the game master + DynamicRibbonWidget* w = this->getWidget("tracks"); + assert( w != NULL ); + w->setSelection(w->getItems()[0].m_code_name, PLAYER_ID_GAME_MASTER, true); +} // init + +// ------------------------------------------------------------------------------------------------------ + +void ArenasScreen::tearDown() +{ +} // tearDown + +// ------------------------------------------------------------------------------------------------------ + void ArenasScreen::eventCallback(Widget* widget, const std::string& name, const int playerID) { if (name == "tracks") @@ -79,9 +97,34 @@ void ArenasScreen::eventCallback(Widget* widget, const std::string& name, const if (UserConfigParams::m_verbosity>=5) std::cout << "Clicked on arena " << selection.c_str() << std::endl; + if (selection == "random_track") { - // TODO: random arena selection + RibbonWidget* tabs = this->getWidget("trackgroups"); + assert( tabs != NULL ); + + const std::vector& curr_group = track_manager->getArenasInGroup( + tabs->getSelectionIDString(PLAYER_ID_GAME_MASTER) ); + + RandomGenerator random; + const int randomID = random.get(curr_group.size()); + + Track* clickedTrack = track_manager->getTrack( curr_group[randomID] ); + if (clickedTrack != NULL) + { + ITexture* screenshot = irr_driver->getTexture( clickedTrack->getScreenshotFile().c_str() ); + + new TrackInfoDialog( clickedTrack->getIdent(), clickedTrack->getName().c_str(), + screenshot, 0.8f, 0.7f); + } + + } + else if (selection == "locked") + { + unlock_manager->playLockSound(); + } + else if (selection == DynamicRibbonWidget::NO_ITEM_ID) + { } else { @@ -105,18 +148,6 @@ void ArenasScreen::eventCallback(Widget* widget, const std::string& name, const // ------------------------------------------------------------------------------------------------------ -void ArenasScreen::init() -{ - buildTrackList(); - - // select something by default for the game master - DynamicRibbonWidget* w = this->getWidget("tracks"); - assert( w != NULL ); - w->setSelection(w->getItems()[0].m_code_name, PLAYER_ID_GAME_MASTER, true); -} // init - -// ------------------------------------------------------------------------------------------------------ - void ArenasScreen::buildTrackList() { DynamicRibbonWidget* w = this->getWidget("tracks"); @@ -181,19 +212,12 @@ void ArenasScreen::buildTrackList() // ------------------------------------------------------------------------------------------------------ -void ArenasScreen::tearDown() -{ -} // tearDown - -// ------------------------------------------------------------------------------------------------------ - void ArenasScreen::setFocusOnTrack(const std::string& trackName) { DynamicRibbonWidget* w = this->getWidget("tracks"); assert( w != NULL ); - // FIXME: don't hardcode player 0? - w->setSelection(trackName, 0, true); + w->setSelection(trackName, PLAYER_ID_GAME_MASTER, true); } // setFOxuOnTrack // ------------------------------------------------------------------------------------------------------ diff --git a/src/states_screens/arenas_screen.hpp b/src/states_screens/arenas_screen.hpp index 0b666dfa5..62e17012d 100644 --- a/src/states_screens/arenas_screen.hpp +++ b/src/states_screens/arenas_screen.hpp @@ -35,10 +35,16 @@ class ArenasScreen : public GUIEngine::Screen, public GUIEngine::ScreenSingleton void buildTrackList(); public: - void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID); - void init(); - void tearDown(); + /** \brief implement callback from parent class GUIEngine::Screen */ + virtual void init(); + + /** \brief implement callback from parent class GUIEngine::Screen */ + virtual void tearDown(); + + /** \brief implement callback from parent class GUIEngine::Screen */ + virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID); + void setFocusOnTrack(const std::string& trackName); };