you can now start a game from within the GUI! No matter where you click, it will always start in beach with hard settings, Tux and 1 kart only though

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3268 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-03-16 18:02:45 +00:00
parent 87a726ff74
commit 73d8aa063e
5 changed files with 70 additions and 4 deletions

View File

@ -5,6 +5,8 @@
#include "gui/screen.hpp"
#include "sdldrv.hpp"
#include "graphics/irr_driver.hpp"
#include "race_manager.hpp"
#include "network/network_manager.hpp"
#include <vector>
@ -73,7 +75,23 @@ namespace StateManager
{
GUIEngine::RibbonGridWidget* w2 = dynamic_cast<GUIEngine::RibbonGridWidget*>(widget);
if(w2 != NULL)
{
std::cout << "Clicked on track " << w2->getSelectionName().c_str() << std::endl;
StateManager::enterGameState();
race_manager->setLocalKartInfo(0, "tux");
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
race_manager->setNumKarts( 1 );
race_manager->setNumPlayers( 1 );
race_manager->setNumLocalPlayers( 1 );
network_manager->setupPlayerKartInfo();
//race_manager->getKartType(1) = KT_PLAYER;
race_manager->startNew();
}
}
if(name == "gps")
{
@ -81,6 +99,51 @@ namespace StateManager
if(w != NULL)
std::cout << "Clicked on GrandPrix " << w->getSelectionName().c_str() << std::endl;
}
/*
289 race_manager->setDifficulty((RaceManager::Difficulty)m_difficulty);
290 user_config->setDefaultNumDifficulty(m_difficulty);
// if there is no AI, there's no point asking the player for the amount of karts.
299 // It will always be the same as the number of human players
300 if(RaceManager::isBattleMode( race_manager->getMinorMode() ))
301 {
302 race_manager->setNumKarts(race_manager->getNumLocalPlayers());
303 // Don't change the default number of karts in user_config
304 }
305 else
306 {
307 race_manager->setNumKarts(m_num_karts);
308 user_config->setDefaultNumKarts(race_manager->getNumKarts());
309 }
311 if( race_manager->getMajorMode() != RaceManager::MAJOR_MODE_GRAND_PRIX &&
312 RaceManager::modeHasLaps( race_manager->getMinorMode() ) )
313 {
314 race_manager->setNumLaps( m_num_laps );
315 user_config->setDefaultNumLaps(m_num_laps);
316 }
317 // Might still be set from a previous challenge
318 race_manager->setCoinTarget(0);
inputDriver->setMode(SDLDriver::INGAME);
race_manager->setLocalKartInfo(0, argv[i+1]);
race_manager->setDifficulty(RaceManager::RD_EASY);
race_manager->setDifficulty(RaceManager::RD_HARD);
race_manager->setDifficulty(RaceManager::RD_HARD);
race_manager->setTrack(argv[i+1]);
user_config->setDefaultNumKarts(stk_config->m_max_karts);
race_manager->setNumKarts(user_config->getDefaultNumKarts() );
user_config->getDefaultNumKarts()
StateManager::enterGameState();
race_manager->startNew();
*/
}
void initGUI()
@ -95,6 +158,7 @@ namespace StateManager
void pushMenu(std::string name)
{
inputDriver->setMode(SDLDriver::MENU);
g_menu_stack.push_back(name);
g_game_mode = false;
GUIEngine::switchToScreen(name.c_str());
@ -109,6 +173,7 @@ namespace StateManager
void resetAndGoToMenu(std::string name)
{
inputDriver->setMode(SDLDriver::MENU);
g_menu_stack.clear();
g_menu_stack.push_back(name);
g_game_mode = false;

View File

@ -68,6 +68,7 @@ Kart::Kart (const std::string& kart_name, int position,
#endif
{
m_kart_properties = kart_properties_manager->getKart(kart_name);
assert(m_kart_properties != NULL);
m_initial_position = position;
m_collected_energy = 0;
m_eliminated = false;

View File

@ -144,6 +144,7 @@ const KartProperties* KartPropertiesManager::getKart(const std::string &ident) c
return *i;
}
printf("Could not find a kart named %s\n", ident.c_str());
return NULL;
} // getKart

View File

@ -206,8 +206,7 @@ int handleCmdLine(int argc, char **argv)
race_manager->setDifficulty(RaceManager::RD_EASY);
break;
case 2:
// FIXME: no medium AI atm race_manager->setDifficulty(RaceManager::RD_MEDIUM);
race_manager->setDifficulty(RaceManager::RD_HARD);
race_manager->setDifficulty(RaceManager::RD_MEDIUM);
break;
case 3:
race_manager->setDifficulty(RaceManager::RD_HARD);
@ -544,7 +543,6 @@ int main(int argc, char *argv[] )
}
}
//FIXME: this needs a better organization
inputDriver = new SDLDriver ();
main_loop = new MainLoop();

View File

@ -769,8 +769,9 @@ void SDLDriver::setMode(InputDriverMode new_mode)
break;
default:
;
// Something is broken.
assert (false);
//assert (false);
}
break;