diff --git a/src/gui/state_manager.cpp b/src/gui/state_manager.cpp index d92720112..53da56fb5 100644 --- a/src/gui/state_manager.cpp +++ b/src/gui/state_manager.cpp @@ -10,6 +10,7 @@ #include "main_loop.hpp" #include "karts/kart_properties_manager.hpp" #include "karts/kart.hpp" +#include "user_config.hpp" #include @@ -112,9 +113,30 @@ namespace StateManager */ void menuEventRaceSetup(GUIEngine::Widget* widget, std::string& name) { - // TODO - detect difficulty, allow more game modes - if(name == "gamemode") + if(name == "init") { + GUIEngine::RibbonWidget* w = dynamic_cast + (GUIEngine::getCurrentScreen()->getWidget("difficulty")); + assert( w != NULL ); + w->setSelection(user_config->getDefaultDifficulty()); + race_manager->setDifficulty( (RaceManager::Difficulty)user_config->getDefaultDifficulty() ); + } + else if(name == "difficulty") + { + GUIEngine::RibbonWidget* w = dynamic_cast(widget); + assert(w != NULL); + const std::string& selection = w->getSelectionName(); + + if(selection == "novice") + race_manager->setDifficulty(RaceManager::RD_EASY); + else if(selection == "intermediate") + race_manager->setDifficulty(RaceManager::RD_MEDIUM); + else if(selection == "expert") + race_manager->setDifficulty(RaceManager::RD_HARD); + } + else if(name == "gamemode") + { + // TODO - detect more game modes GUIEngine::RibbonWidget* w = dynamic_cast(widget); if(w->getSelectionName() == "normal") { @@ -202,7 +224,7 @@ namespace StateManager StateManager::enterGameState(); race_manager->setLocalKartInfo(0, "tux"); - race_manager->setDifficulty(RaceManager::RD_HARD); + //race_manager->setDifficulty(RaceManager::RD_HARD); race_manager->setTrack("beach"); race_manager->setNumLaps( 3 ); race_manager->setCoinTarget( 0 ); // Might still be set from a previous challenge diff --git a/src/gui/widget.hpp b/src/gui/widget.hpp index 7593df73a..1d69f1332 100644 --- a/src/gui/widget.hpp +++ b/src/gui/widget.hpp @@ -225,6 +225,8 @@ namespace GUIEngine virtual ~RibbonWidget() {} int getSelection() const { return m_selection; } + void setSelection(const int i) { m_selection = i; updateSelection(); } + RibbonType getRibbonType() const { return m_ribbon_type; } const std::string& getSelectionName() { return m_children[m_selection].m_properties[PROP_ID]; } void select(std::string item);