the difficulty setting in the race setup menu is now taken into consideration

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3345 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-04-02 00:30:09 +00:00
parent 199baee176
commit 054b656701
2 changed files with 27 additions and 3 deletions

View File

@ -10,6 +10,7 @@
#include "main_loop.hpp"
#include "karts/kart_properties_manager.hpp"
#include "karts/kart.hpp"
#include "user_config.hpp"
#include <vector>
@ -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::RibbonWidget*>
(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<GUIEngine::RibbonWidget*>(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<GUIEngine::RibbonWidget*>(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

View File

@ -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);