From: <au...@us...> - 2008-10-20 15:53:54
|
Revision: 2357 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=2357&view=rev Author: auria Date: 2008-10-20 15:53:47 +0000 (Mon, 20 Oct 2008) Log Message: ----------- updated menus for battle mode. 1) don't add AI karts 2) don't show useless screens like kart amount or AI difficulty Modified Paths: -------------- trunk/supertuxkart/src/gui/race_options.cpp trunk/supertuxkart/src/utils/random_generator.cpp Modified: trunk/supertuxkart/src/gui/race_options.cpp =================================================================== --- trunk/supertuxkart/src/gui/race_options.cpp 2008-10-20 14:38:59 UTC (rev 2356) +++ trunk/supertuxkart/src/gui/race_options.cpp 2008-10-20 15:53:47 UTC (rev 2357) @@ -75,38 +75,44 @@ // Difficulty // ========== - widget_manager->addTextWgt( WTOK_DIFFICULTY_TITLE, DESC_WIDTH, 7, _("Difficulty") ); - widget_manager->hideWgtRect(WTOK_DIFFICULTY_TITLE); - widget_manager->setWgtTextSize(WTOK_DIFFICULTY_TITLE, WGT_FNT_LRG); - widget_manager->addTextButtonWgt( WTOK_DIFFICULTY_DOWN, 3, 7, " < " ); - - widget_manager->addTextWgt( WTOK_DIFFICULTY, ITEM_WIDTH, 7, getDifficultyString(m_difficulty)); - widget_manager->setWgtBorderPercentage( WTOK_DIFFICULTY, 10 ); - widget_manager->showWgtBorder( WTOK_DIFFICULTY ); - widget_manager->hideWgtRect( WTOK_DIFFICULTY ); - - widget_manager->addTextButtonWgt( WTOK_DIFFICULTY_UP, 3, 7, " > " ); - - widget_manager->breakLine(); - - // Number of karts - // =============== - widget_manager->addTextWgt( WTOK_KARTS_TITLE, DESC_WIDTH, 7, _("Number of karts") ); - widget_manager->hideWgtRect(WTOK_KARTS_TITLE); - widget_manager->setWgtTextSize(WTOK_KARTS_TITLE, WGT_FNT_LRG); - widget_manager->addTextButtonWgt( WTOK_KARTS_DOWN, 3, 7, " < " ); - - char string_num_karts[MAX_MESSAGE_LENGTH]; - snprintf(string_num_karts, MAX_MESSAGE_LENGTH, "%d", m_num_karts); - widget_manager->addTextWgt( WTOK_KARTS, ITEM_WIDTH, 7, string_num_karts ); - widget_manager->setWgtBorderPercentage( WTOK_KARTS, 10 ); - widget_manager->showWgtBorder( WTOK_KARTS ); - widget_manager->hideWgtRect( WTOK_KARTS ); - - widget_manager->addTextButtonWgt( WTOK_KARTS_UP, 3, 7, " > " ); - - widget_manager->breakLine(); - + // if there is no AI, no point asking for its difficulty... + // There's also no point asking the player for the amount of karts + // since tt will always be the same as the number of human players + if(!RaceManager::isBattleMode( race_manager->getMinorMode() )) + { + widget_manager->addTextWgt( WTOK_DIFFICULTY_TITLE, DESC_WIDTH, 7, _("Difficulty") ); + widget_manager->hideWgtRect(WTOK_DIFFICULTY_TITLE); + widget_manager->setWgtTextSize(WTOK_DIFFICULTY_TITLE, WGT_FNT_LRG); + widget_manager->addTextButtonWgt( WTOK_DIFFICULTY_DOWN, 3, 7, " < " ); + + widget_manager->addTextWgt( WTOK_DIFFICULTY, ITEM_WIDTH, 7, getDifficultyString(m_difficulty)); + widget_manager->setWgtBorderPercentage( WTOK_DIFFICULTY, 10 ); + widget_manager->showWgtBorder( WTOK_DIFFICULTY ); + widget_manager->hideWgtRect( WTOK_DIFFICULTY ); + + widget_manager->addTextButtonWgt( WTOK_DIFFICULTY_UP, 3, 7, " > " ); + + widget_manager->breakLine(); + + // Number of karts + // =============== + widget_manager->addTextWgt( WTOK_KARTS_TITLE, DESC_WIDTH, 7, _("Number of karts") ); + widget_manager->hideWgtRect(WTOK_KARTS_TITLE); + widget_manager->setWgtTextSize(WTOK_KARTS_TITLE, WGT_FNT_LRG); + widget_manager->addTextButtonWgt( WTOK_KARTS_DOWN, 3, 7, " < " ); + + char string_num_karts[MAX_MESSAGE_LENGTH]; + snprintf(string_num_karts, MAX_MESSAGE_LENGTH, "%d", m_num_karts); + widget_manager->addTextWgt( WTOK_KARTS, ITEM_WIDTH, 7, string_num_karts ); + widget_manager->setWgtBorderPercentage( WTOK_KARTS, 10 ); + widget_manager->showWgtBorder( WTOK_KARTS ); + widget_manager->hideWgtRect( WTOK_KARTS ); + + widget_manager->addTextButtonWgt( WTOK_KARTS_UP, 3, 7, " > " ); + + widget_manager->breakLine(); + } + // Number of laps // ============== if( race_manager->getMajorMode() != RaceManager::MAJOR_MODE_GRAND_PRIX && @@ -146,6 +152,11 @@ // Select 'start' by default. widget_manager->setSelectedWgt( WTOK_START ); + + // hack. in battle mode this screen is totally useless. so I'm calling 'select' + // to select the start button, so the screen is entirely skipped (FIXME - find cleaner way) + if(RaceManager::isBattleMode( race_manager->getMinorMode() )) select(); + } // RaceOptions //----------------------------------------------------------------------------- @@ -268,7 +279,13 @@ race_manager->setDifficulty( RaceManager::RD_EASY ); } - race_manager->setNumKarts(m_num_karts); + // if there is no AI, there's no point asking the player for the amount of karts. + // It will always be the same as the number of human players + if(RaceManager::isBattleMode( race_manager->getMinorMode() )) + race_manager->setNumKarts(race_manager->getNumLocalPlayers()); + else + race_manager->setNumKarts(m_num_karts); + if( race_manager->getMajorMode() != RaceManager::MAJOR_MODE_GRAND_PRIX && RaceManager::modeHasLaps( race_manager->getMinorMode() ) ) Modified: trunk/supertuxkart/src/utils/random_generator.cpp =================================================================== --- trunk/supertuxkart/src/utils/random_generator.cpp 2008-10-20 14:38:59 UTC (rev 2356) +++ trunk/supertuxkart/src/utils/random_generator.cpp 2008-10-20 15:53:47 UTC (rev 2357) @@ -28,6 +28,7 @@ m_a = 1103515245; m_c = 12345; m_all_random_generators.push_back(this); + m_random_value = 3141591; } // RandomGenerator // ---------------------------------------------------------------------------- @@ -62,7 +63,7 @@ int RandomGenerator::get(int n) { m_random_value = m_random_value*m_a+m_c; - return m_random_value % n; + return (m_random_value >> 8) % n; } // get // ---------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |