2010-07-15 18:41:41 -04:00
|
|
|
//
|
|
|
|
// SuperTuxKart - a fun racing game with go-kart
|
|
|
|
// Copyright (C) 2010 Joerg Henrichs
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either version 3
|
|
|
|
// of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
#include "states_screens/race_result_gui.hpp"
|
|
|
|
|
2011-05-20 21:07:06 -04:00
|
|
|
#include "audio/music_manager.hpp"
|
|
|
|
#include "audio/sfx_base.hpp"
|
2010-08-24 19:19:14 -04:00
|
|
|
#include "challenges/unlock_manager.hpp"
|
2011-05-22 15:29:52 -04:00
|
|
|
#include "graphics/material.hpp"
|
2010-07-15 18:41:41 -04:00
|
|
|
#include "guiengine/engine.hpp"
|
2013-02-16 19:20:40 -05:00
|
|
|
#include "guiengine/modaldialog.hpp"
|
2010-07-20 20:01:22 -04:00
|
|
|
#include "guiengine/scalable_font.hpp"
|
2010-08-24 19:19:14 -04:00
|
|
|
#include "guiengine/widget.hpp"
|
2011-10-07 19:25:02 -04:00
|
|
|
#include "guiengine/widgets/icon_button_widget.hpp"
|
2010-09-13 21:28:19 -04:00
|
|
|
#include "io/file_manager.hpp"
|
2012-03-19 16:21:11 -04:00
|
|
|
#include "karts/abstract_kart.hpp"
|
2012-03-08 17:56:33 -05:00
|
|
|
#include "karts/controller/controller.hpp"
|
2012-03-19 16:21:11 -04:00
|
|
|
#include "karts/kart_properties.hpp"
|
2012-10-20 15:01:45 -04:00
|
|
|
#include "karts/kart_properties_manager.hpp"
|
2012-09-13 20:03:38 -04:00
|
|
|
#include "modes/cutscene_world.hpp"
|
2012-05-06 20:10:33 -04:00
|
|
|
#include "modes/demo_world.hpp"
|
2012-04-01 11:42:44 -04:00
|
|
|
#include "modes/overworld.hpp"
|
2013-09-14 15:20:08 -04:00
|
|
|
#include "modes/soccer_world.hpp"
|
2010-09-02 09:14:07 -04:00
|
|
|
#include "modes/world_with_rank.hpp"
|
2012-10-20 15:01:45 -04:00
|
|
|
#include "race/highscores.hpp"
|
2011-01-03 13:23:52 -05:00
|
|
|
#include "states_screens/feature_unlocked.hpp"
|
2010-08-24 19:19:14 -04:00
|
|
|
#include "states_screens/main_menu_screen.hpp"
|
2010-08-24 19:33:30 -04:00
|
|
|
#include "states_screens/race_setup_screen.hpp"
|
2011-10-07 19:25:02 -04:00
|
|
|
#include "tracks/track.hpp"
|
|
|
|
#include "tracks/track_manager.hpp"
|
2010-07-15 18:41:41 -04:00
|
|
|
#include "utils/string_utils.hpp"
|
2013-10-14 09:27:42 -04:00
|
|
|
#include <algorithm>
|
2010-07-15 18:41:41 -04:00
|
|
|
|
2010-08-24 19:19:14 -04:00
|
|
|
DEFINE_SCREEN_SINGLETON( RaceResultGUI );
|
|
|
|
|
2010-07-15 18:41:41 -04:00
|
|
|
/** Constructor, initialises internal data structures.
|
|
|
|
*/
|
2013-05-29 18:04:35 -04:00
|
|
|
RaceResultGUI::RaceResultGUI() : Screen("race_result.stkgui",
|
2011-10-26 01:01:51 -04:00
|
|
|
/*pause race*/ false)
|
2010-07-15 18:41:41 -04:00
|
|
|
{
|
|
|
|
} // RaceResultGUI
|
|
|
|
|
2010-08-24 19:19:14 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
2013-05-29 18:04:35 -04:00
|
|
|
/** Besides calling init in the base class this makes all buttons of this
|
|
|
|
* screen invisible. The buttons will only displayed once the animation is
|
2010-08-24 20:58:45 -04:00
|
|
|
* over.
|
2010-08-24 19:19:14 -04:00
|
|
|
*/
|
|
|
|
void RaceResultGUI::init()
|
|
|
|
{
|
|
|
|
Screen::init();
|
|
|
|
determineTableLayout();
|
|
|
|
m_animation_state = RR_INIT;
|
|
|
|
|
|
|
|
m_timer = 0;
|
|
|
|
|
|
|
|
getWidget("top")->setVisible(false);
|
|
|
|
getWidget("middle")->setVisible(false);
|
|
|
|
getWidget("bottom")->setVisible(false);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-05-20 21:07:06 -04:00
|
|
|
music_manager->stopMusic();
|
|
|
|
m_finish_sound = sfx_manager->quickSound("race_finish");
|
2010-08-24 19:19:14 -04:00
|
|
|
} // init
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void RaceResultGUI::tearDown()
|
|
|
|
{
|
|
|
|
Screen::tearDown();
|
|
|
|
m_font->setMonospaceDigits(m_was_monospace);
|
|
|
|
} // tearDown
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-08-24 19:19:14 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/** Makes the correct buttons visible again, and gives them the right label.
|
|
|
|
* 1) If something was unlocked, only a 'next' button is displayed.
|
|
|
|
*/
|
|
|
|
void RaceResultGUI::enableAllButtons()
|
|
|
|
{
|
2010-08-29 19:17:56 -04:00
|
|
|
GUIEngine::Widget *top = getWidget("top");
|
|
|
|
GUIEngine::Widget *middle = getWidget("middle");
|
|
|
|
GUIEngine::Widget *bottom = getWidget("bottom");
|
|
|
|
|
2011-11-07 20:50:31 -05:00
|
|
|
if (race_manager->getMajorMode()==RaceManager::MAJOR_MODE_GRAND_PRIX)
|
|
|
|
{
|
|
|
|
enableGPProgress();
|
|
|
|
}
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-08-24 19:19:14 -04:00
|
|
|
// If something was unlocked
|
|
|
|
// -------------------------
|
2012-02-14 20:58:24 -05:00
|
|
|
int n = unlock_manager->getCurrentSlot()->getRecentlyCompletedChallenges().size();
|
2010-08-24 19:19:14 -04:00
|
|
|
if(n>0)
|
|
|
|
{
|
2013-05-29 18:04:35 -04:00
|
|
|
top->setText(n==1 ? _("You completed a challenge!")
|
2012-03-31 14:34:59 -04:00
|
|
|
: _("You completed challenges!"));
|
2010-08-24 19:19:14 -04:00
|
|
|
top->setVisible(true);
|
2011-08-21 12:54:50 -04:00
|
|
|
top->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
2010-08-24 19:19:14 -04:00
|
|
|
}
|
2011-10-26 01:01:51 -04:00
|
|
|
else if (race_manager->getMajorMode()==RaceManager::MAJOR_MODE_GRAND_PRIX)
|
2010-08-26 06:16:58 -04:00
|
|
|
{
|
2010-08-29 19:17:56 -04:00
|
|
|
// In case of a GP:
|
|
|
|
// ----------------
|
2010-12-20 12:52:39 -05:00
|
|
|
top->setVisible(false);
|
2010-08-24 19:19:14 -04:00
|
|
|
|
2010-12-20 12:52:39 -05:00
|
|
|
middle->setText( _("Continue") );
|
2010-08-24 19:19:14 -04:00
|
|
|
middle->setVisible(true);
|
|
|
|
|
|
|
|
bottom->setText( _("Abort Grand Prix") );
|
|
|
|
bottom->setVisible(true);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-08-21 12:54:50 -04:00
|
|
|
middle->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
2010-08-24 19:19:14 -04:00
|
|
|
}
|
2010-08-26 06:16:58 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Normal race
|
|
|
|
// -----------
|
2010-08-24 19:19:14 -04:00
|
|
|
|
2010-08-26 06:16:58 -04:00
|
|
|
middle->setText( _("Restart") );
|
|
|
|
middle->setVisible(true);
|
2010-08-24 19:19:14 -04:00
|
|
|
|
2012-04-01 11:42:44 -04:00
|
|
|
if (race_manager->raceWasStartedFromOverworld())
|
|
|
|
{
|
2013-05-16 02:53:01 -04:00
|
|
|
top->setVisible(false);
|
|
|
|
bottom->setText( _("Back to challenge selection") );
|
2012-04-01 11:42:44 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-16 02:53:01 -04:00
|
|
|
top->setText( _("Setup New Race") );
|
|
|
|
top->setVisible(true);
|
2012-04-01 11:42:44 -04:00
|
|
|
bottom->setText( _("Back to the menu") );
|
|
|
|
}
|
2010-08-26 06:16:58 -04:00
|
|
|
bottom->setVisible(true);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-08-21 12:54:50 -04:00
|
|
|
bottom->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
2010-08-26 06:16:58 -04:00
|
|
|
}
|
2010-08-24 19:19:14 -04:00
|
|
|
} // enableAllButtons
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2013-05-29 18:04:35 -04:00
|
|
|
void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
|
2010-08-24 19:19:14 -04:00
|
|
|
const std::string& name, const int playerID)
|
|
|
|
{
|
|
|
|
|
2013-05-29 18:04:35 -04:00
|
|
|
// If something was unlocked, the 'continue' button was
|
2010-08-24 19:19:14 -04:00
|
|
|
// actually used to display "Show unlocked feature(s)" text.
|
|
|
|
// ---------------------------------------------------------
|
2012-02-14 20:58:24 -05:00
|
|
|
int n = unlock_manager->getCurrentSlot()->getRecentlyCompletedChallenges().size();
|
2010-08-24 19:19:14 -04:00
|
|
|
if(n>0)
|
|
|
|
{
|
|
|
|
if(name=="top")
|
|
|
|
{
|
2011-11-07 20:50:31 -05:00
|
|
|
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
|
|
|
|
{
|
|
|
|
cleanupGPProgress();
|
|
|
|
}
|
2013-05-29 18:04:35 -04:00
|
|
|
|
|
|
|
std::vector<const ChallengeData*> unlocked =
|
2012-02-14 20:58:24 -05:00
|
|
|
unlock_manager->getCurrentSlot()->getRecentlyCompletedChallenges();
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2012-09-13 20:03:38 -04:00
|
|
|
bool gameCompleted = false;
|
|
|
|
for (unsigned int n = 0; n < unlocked.size(); n++)
|
|
|
|
{
|
|
|
|
if (unlocked[n]->getId() == "fortmagma")
|
|
|
|
{
|
|
|
|
gameCompleted = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-12-05 17:00:42 -05:00
|
|
|
unlock_manager->getCurrentSlot()->clearUnlocked();
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2012-09-13 20:03:38 -04:00
|
|
|
if (gameCompleted)
|
|
|
|
{
|
|
|
|
// clear the race
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2012-11-10 19:15:03 -05:00
|
|
|
// kart will no longer be available during cutscene, drop reference
|
|
|
|
StateManager::get()->getActivePlayer(playerID)->setKart(NULL);
|
2012-09-13 20:03:38 -04:00
|
|
|
World::deleteWorld();
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2012-09-13 20:03:38 -04:00
|
|
|
StateManager::get()->enterGameState();
|
|
|
|
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
|
|
|
|
race_manager->setNumKarts( 0 );
|
|
|
|
race_manager->setNumPlayers(0);
|
|
|
|
race_manager->setNumLocalPlayers(0);
|
|
|
|
race_manager->startSingleRace("endcutscene", 999, false);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2012-09-13 20:03:38 -04:00
|
|
|
std::vector<std::string> parts;
|
|
|
|
parts.push_back("endcutscene");
|
|
|
|
((CutsceneWorld*)World::getWorld())->setParts(parts);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-29 18:04:35 -04:00
|
|
|
FeatureUnlockedCutScene* scene =
|
2012-09-13 20:03:38 -04:00
|
|
|
FeatureUnlockedCutScene::getInstance();
|
|
|
|
scene->addTrophy(race_manager->getDifficulty());
|
2012-11-26 19:41:38 -05:00
|
|
|
scene->findWhatWasUnlocked(race_manager->getDifficulty());
|
2012-09-13 20:03:38 -04:00
|
|
|
StateManager::get()->popMenu();
|
|
|
|
World::deleteWorld();
|
2012-10-29 19:07:22 -04:00
|
|
|
StateManager::get()->pushScreen(scene);
|
2012-12-06 19:24:20 -05:00
|
|
|
race_manager->setAIKartOverride("");
|
2012-09-13 20:03:38 -04:00
|
|
|
}
|
2010-08-24 19:19:14 -04:00
|
|
|
return;
|
|
|
|
}
|
2013-05-29 18:04:35 -04:00
|
|
|
fprintf(stderr, "Incorrect event '%s' when things are unlocked.\n",
|
2010-08-24 19:19:14 -04:00
|
|
|
name.c_str());
|
|
|
|
assert(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Next check for GP
|
|
|
|
// -----------------
|
|
|
|
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
|
|
|
|
{
|
2010-12-20 12:52:39 -05:00
|
|
|
if (name == "middle") // Next GP
|
2010-08-24 19:19:14 -04:00
|
|
|
{
|
2011-10-07 19:25:02 -04:00
|
|
|
cleanupGPProgress();
|
2010-12-20 12:52:39 -05:00
|
|
|
StateManager::get()->popMenu();
|
2010-08-24 19:19:14 -04:00
|
|
|
race_manager->next();
|
|
|
|
}
|
2010-12-20 12:52:39 -05:00
|
|
|
else if (name == "bottom") // Abort
|
2010-08-24 19:19:14 -04:00
|
|
|
{
|
2013-02-16 19:20:40 -05:00
|
|
|
new MessageDialog(_("Do you really want to abort the Grand Prix?"),
|
|
|
|
MessageDialog::MESSAGE_DIALOG_CONFIRM, this, false);
|
2010-08-24 19:19:14 -04:00
|
|
|
}
|
2011-10-07 19:25:02 -04:00
|
|
|
else if (!getWidget(name.c_str())->isVisible())
|
2010-08-24 19:19:14 -04:00
|
|
|
{
|
|
|
|
fprintf(stderr, "Incorrect event '%s' when things are unlocked.\n",
|
|
|
|
name.c_str());
|
|
|
|
assert(false);
|
|
|
|
}
|
2010-08-29 19:17:56 -04:00
|
|
|
return;
|
2010-08-24 19:19:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// This is a normal race, nothing was unlocked
|
|
|
|
// -------------------------------------------
|
2010-08-29 19:17:56 -04:00
|
|
|
StateManager::get()->popMenu();
|
|
|
|
if(name=="top") // Setup new race
|
2010-08-24 19:19:14 -04:00
|
|
|
{
|
|
|
|
race_manager->exitRace();
|
2012-12-06 19:24:20 -05:00
|
|
|
race_manager->setAIKartOverride("");
|
2013-05-29 18:04:35 -04:00
|
|
|
Screen* newStack[] = {MainMenuScreen::getInstance(),
|
|
|
|
RaceSetupScreen::getInstance(),
|
2010-08-24 19:19:14 -04:00
|
|
|
NULL};
|
|
|
|
StateManager::get()->resetAndSetStack( newStack );
|
|
|
|
}
|
|
|
|
else if (name=="middle") // Restart
|
|
|
|
{
|
|
|
|
race_manager->rerunRace();
|
|
|
|
}
|
2010-08-29 19:17:56 -04:00
|
|
|
else if (name=="bottom") // Back to main
|
2010-08-24 19:19:14 -04:00
|
|
|
{
|
|
|
|
race_manager->exitRace();
|
2012-12-06 19:24:20 -05:00
|
|
|
race_manager->setAIKartOverride("");
|
2010-08-24 19:19:14 -04:00
|
|
|
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2012-04-01 11:42:44 -04:00
|
|
|
if (race_manager->raceWasStartedFromOverworld())
|
|
|
|
{
|
|
|
|
OverWorld::enterOverWorld();
|
|
|
|
}
|
2010-08-24 19:19:14 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-24 19:35:43 -04:00
|
|
|
fprintf(stderr, "Incorrect event '%s' for normal race.\n",
|
2010-08-24 19:19:14 -04:00
|
|
|
name.c_str());
|
|
|
|
}
|
2010-08-29 19:17:56 -04:00
|
|
|
return;
|
2010-08-24 19:19:14 -04:00
|
|
|
} // eventCallback
|
|
|
|
|
2013-02-16 19:20:40 -05:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void RaceResultGUI::onConfirm()
|
|
|
|
{
|
|
|
|
GUIEngine::ModalDialog::dismiss();
|
|
|
|
cleanupGPProgress();
|
|
|
|
StateManager::get()->popMenu();
|
|
|
|
race_manager->exitRace();
|
|
|
|
race_manager->setAIKartOverride("");
|
|
|
|
StateManager::get()->resetAndGoToScreen(
|
|
|
|
MainMenuScreen::getInstance());
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2013-02-16 19:20:40 -05:00
|
|
|
if (race_manager->raceWasStartedFromOverworld())
|
|
|
|
{
|
|
|
|
OverWorld::enterOverWorld();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-15 18:41:41 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/** This determines the layout, i.e. the size of all columns, font size etc.
|
|
|
|
*/
|
2010-07-29 19:03:20 -04:00
|
|
|
void RaceResultGUI::determineTableLayout()
|
2010-07-15 18:41:41 -04:00
|
|
|
{
|
2010-08-24 19:19:14 -04:00
|
|
|
GUIEngine::Widget *table_area = getWidget("result-table");
|
|
|
|
|
2010-07-22 18:51:14 -04:00
|
|
|
m_font = GUIEngine::getFont();
|
2010-07-29 19:03:20 -04:00
|
|
|
assert(m_font);
|
2010-07-22 18:51:14 -04:00
|
|
|
m_was_monospace = m_font->getMonospaceDigits();
|
|
|
|
m_font->setMonospaceDigits(true);
|
2010-09-02 09:14:07 -04:00
|
|
|
WorldWithRank *rank_world = (WorldWithRank*)World::getWorld();
|
2010-07-29 19:03:20 -04:00
|
|
|
|
2010-09-04 21:07:44 -04:00
|
|
|
unsigned int first_position = 1;
|
|
|
|
if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER)
|
|
|
|
first_position = 2;
|
2010-07-20 19:01:47 -04:00
|
|
|
|
2010-09-04 21:07:44 -04:00
|
|
|
// Use only the karts that are supposed to be displayed (and
|
|
|
|
// ignore e.g. the leader in a FTL race).
|
|
|
|
unsigned int num_karts =race_manager->getNumberOfKarts()-first_position+1;
|
|
|
|
|
|
|
|
// In FTL races the leader kart is not displayed
|
|
|
|
m_all_row_infos.resize(num_karts);
|
2010-08-24 19:19:14 -04:00
|
|
|
|
|
|
|
|
2013-05-29 18:04:35 -04:00
|
|
|
// Determine the kart to display in the right order,
|
2010-07-22 18:51:14 -04:00
|
|
|
// and the maximum width for the kart name column
|
|
|
|
// -------------------------------------------------
|
|
|
|
m_width_kart_name = 0;
|
2010-07-20 19:01:47 -04:00
|
|
|
float max_finish_time = 0;
|
2010-08-24 19:19:14 -04:00
|
|
|
|
|
|
|
|
2013-05-29 18:04:35 -04:00
|
|
|
for(unsigned int position=first_position;
|
2010-09-04 21:07:44 -04:00
|
|
|
position<=race_manager->getNumberOfKarts(); position++)
|
2010-07-20 19:01:47 -04:00
|
|
|
{
|
2012-03-19 16:21:11 -04:00
|
|
|
const AbstractKart *kart = rank_world->getKartAtPosition(position);
|
2010-09-04 21:07:44 -04:00
|
|
|
|
2010-08-24 19:19:14 -04:00
|
|
|
// Save a pointer to the current row_info entry
|
2010-09-04 21:07:44 -04:00
|
|
|
RowInfo *ri = &(m_all_row_infos[position-first_position]);
|
2010-08-24 19:19:14 -04:00
|
|
|
ri->m_is_player_kart = kart->getController()->isPlayerController();
|
2011-04-19 19:24:16 -04:00
|
|
|
ri->m_kart_name = translations->fribidize(kart->getName());
|
2013-05-29 18:04:35 -04:00
|
|
|
ri->m_player = ri->m_is_player_kart
|
2011-10-26 01:01:51 -04:00
|
|
|
? kart->getController()->getPlayer() : NULL;
|
2013-05-29 18:04:35 -04:00
|
|
|
|
|
|
|
video::ITexture *icon =
|
2010-07-20 19:01:47 -04:00
|
|
|
kart->getKartProperties()->getIconMaterial()->getTexture();
|
2010-08-24 19:19:14 -04:00
|
|
|
ri->m_kart_icon = icon;
|
2010-07-20 19:01:47 -04:00
|
|
|
|
2012-10-25 19:17:10 -04:00
|
|
|
if (kart->isEliminated())
|
|
|
|
{
|
|
|
|
ri->m_finish_time_string = core::stringw(_("Eliminated"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const float time = kart->getFinishTime();
|
|
|
|
if(time > max_finish_time) max_finish_time = time;
|
|
|
|
std::string time_string = StringUtils::timeToString(time);
|
|
|
|
ri->m_finish_time_string = time_string.c_str();
|
|
|
|
}
|
2010-07-20 19:01:47 -04:00
|
|
|
|
2013-05-29 18:04:35 -04:00
|
|
|
core::dimension2du rect =
|
2011-10-26 01:01:51 -04:00
|
|
|
m_font->getDimension(ri->m_kart_name.c_str());
|
2010-07-22 18:51:14 -04:00
|
|
|
if(rect.Width > m_width_kart_name)
|
|
|
|
m_width_kart_name = rect.Width;
|
2010-09-04 21:07:44 -04:00
|
|
|
} // for position
|
2010-07-20 19:01:47 -04:00
|
|
|
|
2010-07-22 18:51:14 -04:00
|
|
|
std::string max_time = StringUtils::timeToString(max_finish_time);
|
2010-07-20 19:01:47 -04:00
|
|
|
core::stringw string_max_time(max_time.c_str());
|
2010-07-22 18:51:14 -04:00
|
|
|
core::dimension2du r = m_font->getDimension(string_max_time.c_str());
|
|
|
|
m_width_finish_time = r.Width;
|
2010-07-20 19:01:47 -04:00
|
|
|
|
2010-07-15 18:41:41 -04:00
|
|
|
// Top pixel where to display text
|
2010-08-24 19:19:14 -04:00
|
|
|
m_top = table_area->m_y;
|
2010-07-15 18:41:41 -04:00
|
|
|
|
|
|
|
// Height of the result display
|
2010-08-24 19:19:14 -04:00
|
|
|
unsigned int height = table_area->m_h;
|
2010-07-15 18:41:41 -04:00
|
|
|
|
2010-07-20 19:01:47 -04:00
|
|
|
// Setup different timing information for the different phases
|
|
|
|
// -----------------------------------------------------------
|
2010-07-15 18:41:41 -04:00
|
|
|
// How much time between consecutive rows
|
2010-07-22 18:51:14 -04:00
|
|
|
m_time_between_rows = 0.1f;
|
2010-07-15 18:41:41 -04:00
|
|
|
|
2010-07-20 19:01:47 -04:00
|
|
|
// How long it takes for one line to scroll from right to left
|
2010-07-22 18:51:14 -04:00
|
|
|
m_time_single_scroll = 0.2f;
|
2010-07-20 19:01:47 -04:00
|
|
|
|
2010-07-25 18:37:11 -04:00
|
|
|
// Time to rotate the entries to the proper GP position.
|
2010-07-29 19:03:20 -04:00
|
|
|
m_time_rotation = 1.0f;
|
2010-07-25 18:37:11 -04:00
|
|
|
|
2013-05-29 18:04:35 -04:00
|
|
|
// The time the first phase is being displayed: add the start time
|
2010-07-20 19:01:47 -04:00
|
|
|
// of the last kart to the duration of the scroll plus some time
|
|
|
|
// of rest before the next phase starts
|
2013-05-29 18:04:35 -04:00
|
|
|
m_time_overall_scroll = (num_karts-1)*m_time_between_rows
|
2010-07-22 18:51:14 -04:00
|
|
|
+ m_time_single_scroll + 2.0f;
|
|
|
|
|
2013-05-29 18:04:35 -04:00
|
|
|
// The time to increase the number of points.
|
2010-08-25 18:55:58 -04:00
|
|
|
m_time_for_points = 1.0f;
|
2010-07-15 18:41:41 -04:00
|
|
|
|
|
|
|
// Determine text height
|
2010-09-13 21:28:19 -04:00
|
|
|
r = m_font->getDimension(L"Y");
|
|
|
|
m_distance_between_rows = (int)(1.5f*r.Height);
|
2010-07-15 18:41:41 -04:00
|
|
|
|
|
|
|
// If there are too many karts, reduce size between rows
|
|
|
|
if(m_distance_between_rows * num_karts > height)
|
|
|
|
m_distance_between_rows = height / num_karts;
|
|
|
|
|
2013-05-29 18:04:35 -04:00
|
|
|
m_width_icon = table_area->m_h<600
|
|
|
|
? 27
|
2010-08-24 19:19:14 -04:00
|
|
|
: (int)(40*(table_area->m_w/800.0f));
|
2010-07-22 18:51:14 -04:00
|
|
|
|
|
|
|
m_width_column_space = 20;
|
|
|
|
|
|
|
|
// Determine width of new points column
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-05-29 17:00:31 -04:00
|
|
|
m_font->setMonospaceDigits(true);
|
2010-07-22 18:51:14 -04:00
|
|
|
core::dimension2du r_new_p = m_font->getDimension(L"+99");
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-07-29 19:03:20 -04:00
|
|
|
m_width_new_points = r_new_p.Width;
|
2010-07-22 18:51:14 -04:00
|
|
|
|
|
|
|
// Determine width of overall points column
|
2010-08-29 19:17:56 -04:00
|
|
|
core::dimension2du r_all_p = m_font->getDimension(L"999");
|
2011-05-29 17:00:31 -04:00
|
|
|
m_font->setMonospaceDigits(false);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-05-29 17:00:31 -04:00
|
|
|
m_width_all_points = r_all_p.Width;
|
2010-07-22 18:51:14 -04:00
|
|
|
|
2010-09-13 21:28:19 -04:00
|
|
|
m_table_width = m_width_icon + m_width_column_space
|
|
|
|
+ m_width_kart_name;
|
2010-09-07 19:05:31 -04:00
|
|
|
|
|
|
|
if(race_manager->getMinorMode()!=RaceManager::MINOR_MODE_FOLLOW_LEADER)
|
2010-09-13 21:28:19 -04:00
|
|
|
m_table_width += m_width_finish_time + m_width_column_space;
|
2010-07-22 18:51:14 -04:00
|
|
|
|
|
|
|
// Only in GP mode are the points displayed.
|
|
|
|
if (race_manager->getMajorMode()==RaceManager::MAJOR_MODE_GRAND_PRIX)
|
2011-05-29 17:00:31 -04:00
|
|
|
m_table_width += m_width_new_points + m_width_all_points
|
2010-09-13 21:28:19 -04:00
|
|
|
+ 2 * m_width_column_space;
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-10-08 16:50:07 -04:00
|
|
|
m_leftmost_column = table_area->m_x;
|
2013-05-29 18:04:35 -04:00
|
|
|
|
|
|
|
m_gp_progress_x = (int)(UserConfigParams::m_width*0.65);
|
2010-07-29 19:03:20 -04:00
|
|
|
} // determineTableLayout
|
2010-07-15 18:41:41 -04:00
|
|
|
|
2010-08-24 19:19:14 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
2010-08-25 09:54:28 -04:00
|
|
|
/** This function is called when one of the player presses 'fire'. The next
|
2013-05-29 18:04:35 -04:00
|
|
|
* phase of the animation will be displayed. E.g.
|
2010-08-25 09:54:28 -04:00
|
|
|
* in a GP: pressing fire while/after showing the latest race result will
|
|
|
|
* start the animation for the current GP result
|
2013-05-29 18:04:35 -04:00
|
|
|
* in a normal race: when pressing fire while an animation is played,
|
2010-08-25 09:54:28 -04:00
|
|
|
* start the menu showing 'rerun, new race, back to main' etc.
|
|
|
|
*/
|
|
|
|
void RaceResultGUI::nextPhase()
|
|
|
|
{
|
|
|
|
// This will trigger the next phase in the next render call.
|
|
|
|
m_timer = 9999;
|
|
|
|
} // nextPhase
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/** If escape is pressed, don't do the default option (close the screen), but
|
|
|
|
* advance to the next animation phase.
|
|
|
|
*/
|
|
|
|
bool RaceResultGUI::onEscapePressed()
|
|
|
|
{
|
|
|
|
nextPhase();
|
|
|
|
return false; // indicates 'do not close'
|
|
|
|
} // onEscapePressed
|
|
|
|
|
2010-08-26 06:16:58 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/** This is called before an event is sent to a widget. Since in this case
|
|
|
|
* no widget is active, the event would be lost, so we act on fire events
|
|
|
|
* here and trigger the next phase.
|
|
|
|
*/
|
2011-05-13 20:30:30 -04:00
|
|
|
GUIEngine::EventPropagation RaceResultGUI::filterActions(PlayerAction action,
|
2011-10-26 01:01:51 -04:00
|
|
|
int deviceID,
|
|
|
|
const unsigned int value,
|
2013-05-29 18:04:35 -04:00
|
|
|
Input::InputType type,
|
2011-10-26 01:01:51 -04:00
|
|
|
int playerId)
|
2010-08-26 06:16:58 -04:00
|
|
|
{
|
|
|
|
if(action!=PA_FIRE) return GUIEngine::EVENT_LET;
|
|
|
|
|
|
|
|
// If the buttons are already visible, let the event go through since
|
|
|
|
// it will be triggering eventCallback where this is handles.
|
|
|
|
|
|
|
|
if(m_animation_state == RR_WAIT_TILL_END) return GUIEngine::EVENT_LET;
|
|
|
|
|
|
|
|
nextPhase();
|
|
|
|
return GUIEngine::EVENT_BLOCK;
|
|
|
|
} // filterActions
|
|
|
|
|
2010-08-25 09:54:28 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/** Called once a frame, this now triggers the rendering of the actual
|
|
|
|
* race result gui.
|
|
|
|
*/
|
2010-08-24 19:19:14 -04:00
|
|
|
void RaceResultGUI::onUpdate(float dt, irr::video::IVideoDriver*)
|
|
|
|
{
|
|
|
|
renderGlobal(dt);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
|
|
|
if (m_finish_sound != NULL &&
|
2011-10-26 01:01:51 -04:00
|
|
|
m_finish_sound->getStatus() != SFXManager::SFX_PLAYING)
|
2011-05-20 21:07:06 -04:00
|
|
|
{
|
2011-06-03 20:17:22 -04:00
|
|
|
try
|
|
|
|
{
|
2013-05-29 18:04:35 -04:00
|
|
|
music_manager->startMusic(
|
2011-06-30 09:14:21 -04:00
|
|
|
music_manager->getMusicInformation(
|
2013-05-29 18:04:35 -04:00
|
|
|
file_manager->getMusicFile("race_summary.music"))
|
2011-06-30 09:14:21 -04:00
|
|
|
);
|
2011-06-03 20:17:22 -04:00
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
2011-10-26 01:01:51 -04:00
|
|
|
fprintf(stderr, "[RaceResultGUI] WARNING: exception caught when "
|
|
|
|
"trying to load music: %s\n", e.what());
|
2011-06-03 20:17:22 -04:00
|
|
|
}
|
2011-05-20 21:07:06 -04:00
|
|
|
}
|
2010-08-24 19:19:14 -04:00
|
|
|
} // onUpdate
|
|
|
|
|
2010-07-15 18:41:41 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
2013-05-29 18:04:35 -04:00
|
|
|
/** Render all global parts of the race gui, i.e. things that are only
|
2010-07-15 18:41:41 -04:00
|
|
|
* displayed once even in splitscreen.
|
|
|
|
* \param dt Timestep sized.
|
|
|
|
*/
|
|
|
|
void RaceResultGUI::renderGlobal(float dt)
|
|
|
|
{
|
2013-10-14 16:25:30 -04:00
|
|
|
bool isSoccerWorld = race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
|
|
|
|
|
|
|
|
m_timer += dt;
|
2010-11-20 07:15:13 -05:00
|
|
|
assert(World::getWorld()->getPhase()==WorldStatus::RESULT_DISPLAY_PHASE);
|
2010-09-02 18:35:16 -04:00
|
|
|
unsigned int num_karts = m_all_row_infos.size();
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-08-01 19:37:39 -04:00
|
|
|
// First: Update the finite state machine
|
|
|
|
// ======================================
|
2010-07-20 19:01:47 -04:00
|
|
|
switch(m_animation_state)
|
|
|
|
{
|
2013-05-29 18:04:35 -04:00
|
|
|
case RR_INIT:
|
2010-07-29 19:03:20 -04:00
|
|
|
for(unsigned int i=0; i<num_karts; i++)
|
|
|
|
{
|
2010-08-24 19:19:14 -04:00
|
|
|
RowInfo *ri = &(m_all_row_infos[i]);
|
|
|
|
ri->m_start_at = m_time_between_rows * i;
|
|
|
|
ri->m_x_pos = (float)UserConfigParams::m_width;
|
|
|
|
ri->m_y_pos = (float)(m_top+i*m_distance_between_rows);
|
2010-07-29 19:03:20 -04:00
|
|
|
}
|
|
|
|
m_animation_state = RR_RACE_RESULT;
|
|
|
|
break;
|
2013-05-29 18:04:35 -04:00
|
|
|
case RR_RACE_RESULT:
|
2010-07-29 19:03:20 -04:00
|
|
|
if(m_timer > m_time_overall_scroll)
|
|
|
|
{
|
2010-09-06 07:11:38 -04:00
|
|
|
// Make sure that all lines are aligned to the left
|
|
|
|
// (in case that the animation was skipped).
|
|
|
|
for(unsigned int i=0; i<num_karts; i++)
|
|
|
|
{
|
|
|
|
RowInfo *ri = &(m_all_row_infos[i]);
|
|
|
|
ri->m_x_pos = (float)m_leftmost_column;
|
|
|
|
}
|
2011-10-26 01:01:51 -04:00
|
|
|
if(race_manager->getMajorMode() !=
|
|
|
|
RaceManager::MAJOR_MODE_GRAND_PRIX)
|
2010-07-29 19:03:20 -04:00
|
|
|
{
|
|
|
|
m_animation_state = RR_WAIT_TILL_END;
|
2010-08-24 19:19:14 -04:00
|
|
|
enableAllButtons();
|
2010-07-29 19:03:20 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
determineGPLayout();
|
|
|
|
m_animation_state = RR_OLD_GP_RESULTS;
|
|
|
|
m_timer = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RR_OLD_GP_RESULTS:
|
|
|
|
if(m_timer > m_time_overall_scroll)
|
|
|
|
{
|
|
|
|
m_animation_state = RR_INCREASE_POINTS;
|
|
|
|
m_timer = 0;
|
2010-08-26 06:16:58 -04:00
|
|
|
for(unsigned int i=0; i<num_karts; i++)
|
|
|
|
{
|
|
|
|
RowInfo *ri = &(m_all_row_infos[i]);
|
|
|
|
ri->m_x_pos = (float)m_leftmost_column;
|
|
|
|
}
|
2010-07-29 19:03:20 -04:00
|
|
|
}
|
2010-08-25 18:55:58 -04:00
|
|
|
break;
|
2013-05-29 18:04:35 -04:00
|
|
|
case RR_INCREASE_POINTS:
|
2010-08-25 18:55:58 -04:00
|
|
|
// Have one second delay before the resorting starts.
|
|
|
|
if(m_timer > 1+m_time_for_points)
|
2010-07-29 19:03:20 -04:00
|
|
|
{
|
|
|
|
m_animation_state = RR_RESORT_TABLE;
|
2010-08-25 18:55:58 -04:00
|
|
|
if(m_gp_position_was_changed)
|
|
|
|
m_timer = 0;
|
|
|
|
else
|
|
|
|
// This causes the phase to go to RESORT_TABLE once, and then
|
|
|
|
// immediately wait till end. This has the advantage that any
|
|
|
|
// phase change settings will be processed properly.
|
|
|
|
m_timer = m_time_rotation+1;
|
|
|
|
// Make the new row permanent; necessary in case
|
|
|
|
// that the animation is skipped.
|
|
|
|
for(unsigned int i=0; i<num_karts; i++)
|
|
|
|
{
|
|
|
|
RowInfo *ri = &(m_all_row_infos[i]);
|
|
|
|
ri->m_new_points = 0;
|
2013-05-29 18:04:35 -04:00
|
|
|
ri->m_current_displayed_points =
|
2011-10-26 01:01:51 -04:00
|
|
|
(float)ri->m_new_overall_points;
|
2010-08-25 18:55:58 -04:00
|
|
|
}
|
|
|
|
|
2010-07-29 19:03:20 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RR_RESORT_TABLE:
|
|
|
|
if(m_timer > m_time_rotation)
|
|
|
|
{
|
|
|
|
m_animation_state = RR_WAIT_TILL_END;
|
|
|
|
// Make the new row permanent.
|
|
|
|
for(unsigned int i=0; i<num_karts; i++)
|
2010-08-24 19:19:14 -04:00
|
|
|
{
|
|
|
|
RowInfo *ri = &(m_all_row_infos[i]);
|
|
|
|
ri->m_y_pos = ri->m_centre_point - ri->m_radius;
|
|
|
|
}
|
|
|
|
enableAllButtons();
|
2010-07-29 19:03:20 -04:00
|
|
|
}
|
|
|
|
break;
|
2013-05-29 18:04:35 -04:00
|
|
|
case RR_WAIT_TILL_END:
|
2011-10-08 16:50:07 -04:00
|
|
|
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
|
|
|
|
displayGPProgress();
|
2012-05-06 20:10:33 -04:00
|
|
|
if(m_timer - m_time_rotation > 1.0f &&
|
|
|
|
dynamic_cast<DemoWorld*>(World::getWorld()) )
|
|
|
|
{
|
|
|
|
race_manager->exitRace();
|
|
|
|
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
|
|
|
|
}
|
2011-10-08 16:50:07 -04:00
|
|
|
break;
|
2010-07-20 19:01:47 -04:00
|
|
|
} // switch
|
2010-07-15 18:41:41 -04:00
|
|
|
|
2010-08-01 19:37:39 -04:00
|
|
|
// Second phase: update X and Y positions for the various animations
|
|
|
|
// =================================================================
|
2010-07-25 18:37:11 -04:00
|
|
|
float v = 0.9f*UserConfigParams::m_width/m_time_single_scroll;
|
2010-08-24 19:19:14 -04:00
|
|
|
for(unsigned int i=0; i<m_all_row_infos.size(); i++)
|
2010-07-15 18:41:41 -04:00
|
|
|
{
|
2010-08-24 19:19:14 -04:00
|
|
|
RowInfo *ri = &(m_all_row_infos[i]);
|
|
|
|
float x = ri->m_x_pos;
|
|
|
|
float y = ri->m_y_pos;
|
2010-07-25 18:37:11 -04:00
|
|
|
switch(m_animation_state)
|
|
|
|
{
|
2010-07-29 19:03:20 -04:00
|
|
|
// Both states use the same scrolling:
|
2010-08-24 19:35:43 -04:00
|
|
|
case RR_INIT: break; // Remove compiler warning
|
2010-07-29 19:03:20 -04:00
|
|
|
case RR_RACE_RESULT:
|
|
|
|
case RR_OLD_GP_RESULTS:
|
2010-08-24 19:19:14 -04:00
|
|
|
if(m_timer > ri->m_start_at)
|
2010-07-25 18:37:11 -04:00
|
|
|
{ // if active
|
2010-08-24 19:19:14 -04:00
|
|
|
ri->m_x_pos -= dt*v;
|
|
|
|
if(ri->m_x_pos<m_leftmost_column)
|
|
|
|
ri->m_x_pos = (float)m_leftmost_column;
|
|
|
|
x = ri->m_x_pos;
|
2010-07-25 18:37:11 -04:00
|
|
|
}
|
|
|
|
break;
|
2013-05-29 18:04:35 -04:00
|
|
|
case RR_INCREASE_POINTS:
|
|
|
|
ri->m_current_displayed_points +=
|
2010-09-15 22:31:20 -04:00
|
|
|
dt*race_manager->getPositionScore(1)/m_time_for_points;
|
2010-08-24 19:19:14 -04:00
|
|
|
if(ri->m_current_displayed_points>ri->m_new_overall_points)
|
2011-10-26 01:01:51 -04:00
|
|
|
{
|
2013-05-29 18:04:35 -04:00
|
|
|
ri->m_current_displayed_points =
|
2011-10-26 01:01:51 -04:00
|
|
|
(float)ri->m_new_overall_points;
|
|
|
|
}
|
2013-05-29 18:04:35 -04:00
|
|
|
ri->m_new_points -=
|
2011-10-26 01:01:51 -04:00
|
|
|
dt*race_manager->getPositionScore(1)/m_time_for_points;
|
2010-08-24 19:19:14 -04:00
|
|
|
if(ri->m_new_points<0)
|
|
|
|
ri->m_new_points = 0;
|
2010-07-25 18:37:11 -04:00
|
|
|
break;
|
|
|
|
case RR_RESORT_TABLE:
|
2013-05-29 18:04:35 -04:00
|
|
|
x = ri->m_x_pos
|
2011-10-26 01:01:51 -04:00
|
|
|
- ri->m_radius*sin(m_timer/m_time_rotation*M_PI);
|
|
|
|
y = ri->m_centre_point
|
|
|
|
+ ri->m_radius*cos(m_timer/m_time_rotation*M_PI);
|
2010-07-25 18:37:11 -04:00
|
|
|
break;
|
|
|
|
case RR_WAIT_TILL_END:
|
|
|
|
break;
|
|
|
|
} // switch
|
2013-10-13 20:23:20 -04:00
|
|
|
if(isSoccerWorld)
|
2013-10-14 16:25:30 -04:00
|
|
|
displaySoccerResults();
|
|
|
|
else
|
|
|
|
displayOneEntry((unsigned int)x, (unsigned int)y, i, true);
|
2010-09-06 07:11:38 -04:00
|
|
|
} // for i
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2012-10-20 15:01:45 -04:00
|
|
|
// Display highscores
|
|
|
|
if (race_manager->getMajorMode() != RaceManager::MAJOR_MODE_GRAND_PRIX ||
|
|
|
|
m_animation_state == RR_RACE_RESULT)
|
|
|
|
{
|
|
|
|
displayHighScores();
|
|
|
|
}
|
2010-07-15 18:41:41 -04:00
|
|
|
} // renderGlobal
|
|
|
|
|
2010-07-29 19:03:20 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/** Determine the layout and fields for the GP table based on the previous
|
|
|
|
* GP results.
|
|
|
|
*/
|
|
|
|
void RaceResultGUI::determineGPLayout()
|
|
|
|
{
|
2010-12-19 20:16:03 -05:00
|
|
|
unsigned int num_karts = race_manager->getNumberOfKarts();
|
2010-07-29 19:03:20 -04:00
|
|
|
std::vector<int> old_rank(num_karts, 0);
|
|
|
|
for(unsigned int kart_id=0; kart_id<num_karts; kart_id++)
|
|
|
|
{
|
2010-08-24 19:19:14 -04:00
|
|
|
int rank = race_manager->getKartGPRank(kart_id);
|
2010-12-19 20:16:03 -05:00
|
|
|
// In case of FTL mode: ignore the leader
|
|
|
|
if(rank<0) continue;
|
2010-08-24 19:19:14 -04:00
|
|
|
old_rank[kart_id] = rank;
|
2012-03-19 16:21:11 -04:00
|
|
|
const AbstractKart *kart = World::getWorld()->getKart(kart_id);
|
2010-08-24 19:19:14 -04:00
|
|
|
RowInfo *ri = &(m_all_row_infos[rank]);
|
2013-05-29 18:04:35 -04:00
|
|
|
ri->m_kart_icon =
|
2010-07-29 19:03:20 -04:00
|
|
|
kart->getKartProperties()->getIconMaterial()->getTexture();
|
2011-04-19 19:24:16 -04:00
|
|
|
ri->m_kart_name = translations->fribidize(kart->getName());
|
2010-08-24 19:19:14 -04:00
|
|
|
ri->m_is_player_kart = kart->getController()->isPlayerController();
|
2013-05-29 18:04:35 -04:00
|
|
|
ri->m_player = ri->m_is_player_kart
|
2011-10-26 01:01:51 -04:00
|
|
|
? kart->getController()->getPlayer() : NULL;
|
2010-08-24 19:19:14 -04:00
|
|
|
|
2012-10-25 19:17:10 -04:00
|
|
|
if (!kart->isEliminated())
|
|
|
|
{
|
|
|
|
float time = race_manager->getOverallTime(kart_id);
|
|
|
|
ri->m_finish_time_string
|
|
|
|
= StringUtils::timeToString(time).c_str();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ri->m_finish_time_string = core::stringw(_("Eliminated"));
|
|
|
|
}
|
2010-08-24 19:19:14 -04:00
|
|
|
ri->m_start_at = m_time_between_rows * rank;
|
|
|
|
ri->m_x_pos = (float)UserConfigParams::m_width;
|
|
|
|
ri->m_y_pos = (float)(m_top+rank*m_distance_between_rows);
|
|
|
|
int p = race_manager->getKartPrevScore(kart_id);
|
|
|
|
ri->m_current_displayed_points = (float)p;
|
2013-05-29 18:04:35 -04:00
|
|
|
ri->m_new_points =
|
2010-08-24 19:19:14 -04:00
|
|
|
(float)race_manager->getPositionScore(kart->getPosition());
|
2010-07-29 19:03:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Now update the GP ranks, and determine the new position
|
|
|
|
// -------------------------------------------------------
|
|
|
|
race_manager->computeGPRanks();
|
2010-08-25 18:55:58 -04:00
|
|
|
m_gp_position_was_changed = false;
|
2010-07-29 19:03:20 -04:00
|
|
|
for(unsigned int i=0; i<num_karts; i++)
|
|
|
|
{
|
2010-08-24 19:19:14 -04:00
|
|
|
int j = old_rank[i];
|
|
|
|
int gp_position = race_manager->getKartGPRank(i);
|
2010-08-25 18:55:58 -04:00
|
|
|
m_gp_position_was_changed |= j!=gp_position;
|
2010-08-24 19:19:14 -04:00
|
|
|
RowInfo *ri = &(m_all_row_infos[j]);
|
2011-10-26 01:01:51 -04:00
|
|
|
ri->m_radius = (j-gp_position)*(int)m_distance_between_rows*0.5f;
|
|
|
|
ri->m_centre_point= m_top+(gp_position+j)*m_distance_between_rows*0.5f;
|
2010-08-24 19:19:14 -04:00
|
|
|
int p = race_manager->getKartScore(i);
|
|
|
|
ri->m_new_overall_points = p;
|
2010-07-29 19:03:20 -04:00
|
|
|
} // i < num_karts
|
|
|
|
} // determineGPLayout
|
|
|
|
|
2010-07-15 18:41:41 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/** Displays the race results for a single kart.
|
|
|
|
* \param n Index of the kart to be displayed.
|
|
|
|
* \param display_points True if GP points should be displayed, too
|
|
|
|
*/
|
2013-05-29 18:04:35 -04:00
|
|
|
void RaceResultGUI::displayOneEntry(unsigned int x, unsigned int y,
|
2010-07-15 18:41:41 -04:00
|
|
|
unsigned int n, bool display_points)
|
|
|
|
{
|
2010-08-24 19:19:14 -04:00
|
|
|
RowInfo *ri = &(m_all_row_infos[n]);
|
2013-05-29 18:04:35 -04:00
|
|
|
video::SColor color = ri->m_is_player_kart
|
2011-10-26 01:01:51 -04:00
|
|
|
? video::SColor(255,255,0, 0 )
|
|
|
|
: video::SColor(255,255,255,255);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-09-13 21:28:19 -04:00
|
|
|
#ifdef USE_PER_LINE_BACKGROUND
|
|
|
|
// Draw the background image
|
2013-05-29 18:04:35 -04:00
|
|
|
core::rect<s32> dest(x-50, y,
|
|
|
|
x+50+m_table_width,
|
2010-09-13 21:28:19 -04:00
|
|
|
(int)(y+m_distance_between_rows));
|
2011-10-26 01:01:51 -04:00
|
|
|
ri->m_box_params.setTexture(irr_driver->getTexture( (
|
2013-05-29 18:04:35 -04:00
|
|
|
file_manager->getGUIDir() +
|
2011-10-26 01:01:51 -04:00
|
|
|
"skins/glass/glassbutton_focused.png").c_str() ) );
|
|
|
|
GUIEngine::getSkin()->drawBoxFromStretchableTexture(
|
|
|
|
&(ri->m_widget_container),dest, ri->m_box_params);
|
2010-09-13 21:28:19 -04:00
|
|
|
#endif
|
2010-09-07 19:05:31 -04:00
|
|
|
unsigned int current_x = x;
|
|
|
|
|
2010-07-15 18:41:41 -04:00
|
|
|
// First draw the icon
|
|
|
|
// -------------------
|
2013-10-13 20:23:20 -04:00
|
|
|
if(ri->m_kart_icon)
|
2010-07-29 20:11:28 -04:00
|
|
|
{
|
2013-10-13 20:23:20 -04:00
|
|
|
core::recti source_rect(core::vector2di(0,0),
|
|
|
|
ri->m_kart_icon->getSize());
|
|
|
|
core::recti dest_rect(current_x, y,
|
|
|
|
current_x+m_width_icon, y+m_width_icon);
|
|
|
|
irr_driver->getVideoDriver()->draw2DImage(ri->m_kart_icon, dest_rect,
|
|
|
|
source_rect, NULL, NULL,
|
|
|
|
true);
|
2010-07-29 20:11:28 -04:00
|
|
|
}
|
2013-10-13 20:23:20 -04:00
|
|
|
|
|
|
|
current_x += m_width_icon + m_width_column_space;
|
2011-01-03 05:45:31 -05:00
|
|
|
|
2010-07-15 18:41:41 -04:00
|
|
|
// Draw the name
|
|
|
|
// -------------
|
2013-09-14 15:20:08 -04:00
|
|
|
|
2013-10-13 20:23:20 -04:00
|
|
|
core::recti pos_name(current_x, y,
|
|
|
|
UserConfigParams::m_width, y+m_distance_between_rows);
|
|
|
|
m_font->draw(ri->m_kart_name, pos_name, color, false, false, NULL,
|
|
|
|
true /* ignoreRTL */);
|
|
|
|
current_x += m_width_kart_name + m_width_column_space;
|
|
|
|
|
|
|
|
|
2010-09-07 19:05:31 -04:00
|
|
|
// Draw the time except in FTL mode
|
|
|
|
// --------------------------------
|
|
|
|
if(race_manager->getMinorMode()!=RaceManager::MINOR_MODE_FOLLOW_LEADER)
|
|
|
|
{
|
|
|
|
core::recti dest_rect = core::recti(current_x, y, current_x+100, y+10);
|
2013-05-29 18:04:35 -04:00
|
|
|
m_font->draw(ri->m_finish_time_string, dest_rect, color, false, false,
|
2011-10-26 01:01:51 -04:00
|
|
|
NULL, true /* ignoreRTL */);
|
2010-09-07 19:05:31 -04:00
|
|
|
current_x += m_width_finish_time + m_width_column_space;
|
|
|
|
}
|
2011-05-29 17:00:31 -04:00
|
|
|
|
|
|
|
// Only display points in GP mode and when the GP results are displayed.
|
|
|
|
// =====================================================================
|
|
|
|
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX &&
|
|
|
|
m_animation_state != RR_RACE_RESULT)
|
|
|
|
{
|
|
|
|
// Draw the new points
|
|
|
|
// -------------------
|
|
|
|
if(ri->m_new_points > 0)
|
|
|
|
{
|
2013-05-29 18:04:35 -04:00
|
|
|
core::recti dest_rect = core::recti(current_x, y,
|
2011-10-26 01:01:51 -04:00
|
|
|
current_x+100, y+10);
|
2011-05-29 17:00:31 -04:00
|
|
|
core::stringw point_string = core::stringw("+")
|
|
|
|
+ core::stringw((int)ri->m_new_points);
|
2013-05-29 18:04:35 -04:00
|
|
|
// With mono-space digits space has the same width as each digit,
|
|
|
|
// so we can simply fill up the string with spaces to get the
|
2011-10-26 01:01:51 -04:00
|
|
|
// right aligned.
|
2011-05-29 17:00:31 -04:00
|
|
|
while(point_string.size()<3)
|
|
|
|
point_string = core::stringw(" ")+point_string;
|
2013-05-29 18:04:35 -04:00
|
|
|
m_font->draw(point_string, dest_rect, color, false, false, NULL,
|
2011-10-26 01:01:51 -04:00
|
|
|
true /* ignoreRTL */);
|
2011-05-29 17:00:31 -04:00
|
|
|
}
|
|
|
|
current_x += m_width_new_points + m_width_column_space;
|
|
|
|
|
|
|
|
// Draw the old_points plus increase value
|
|
|
|
// ---------------------------------------
|
|
|
|
core::recti dest_rect = core::recti(current_x, y, current_x+100, y+10);
|
2013-05-29 18:04:35 -04:00
|
|
|
core::stringw point_inc_string =
|
2011-05-29 17:00:31 -04:00
|
|
|
core::stringw((int)(ri->m_current_displayed_points));
|
|
|
|
while(point_inc_string.size()<3)
|
|
|
|
point_inc_string = core::stringw(" ")+point_inc_string;
|
2013-05-29 18:04:35 -04:00
|
|
|
m_font->draw(point_inc_string, dest_rect, color, false, false, NULL,
|
2011-10-26 01:01:51 -04:00
|
|
|
true /* ignoreRTL */);
|
2011-05-29 17:00:31 -04:00
|
|
|
}
|
2010-07-18 11:49:52 -04:00
|
|
|
} // displayOneEntry
|
2010-07-20 19:01:47 -04:00
|
|
|
|
2013-10-13 20:23:20 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void RaceResultGUI::displaySoccerResults()
|
|
|
|
{
|
|
|
|
|
2013-10-14 16:25:30 -04:00
|
|
|
//Draw win text
|
|
|
|
core::stringw resultText;
|
|
|
|
static video::SColor color = video::SColor(255, 255, 255, 255);
|
|
|
|
gui::IGUIFont* font = GUIEngine::getTitleFont();
|
|
|
|
int currX = UserConfigParams::m_width/2;
|
|
|
|
RowInfo *ri = &(m_all_row_infos[0]);
|
|
|
|
int currY = (int)ri->m_y_pos;
|
|
|
|
SoccerWorld* soccerWorld = (SoccerWorld*)World::getWorld();
|
|
|
|
int teamScore[2] = {soccerWorld->getScore(0), soccerWorld->getScore(1)};
|
|
|
|
|
|
|
|
if(teamScore[0] > teamScore[1])
|
2013-10-13 20:23:20 -04:00
|
|
|
{
|
2013-10-14 16:25:30 -04:00
|
|
|
resultText = _("Red Team Wins");
|
|
|
|
}
|
|
|
|
else if(teamScore[1] > teamScore[0])
|
2013-10-13 20:23:20 -04:00
|
|
|
{
|
2013-10-14 16:25:30 -04:00
|
|
|
resultText = _("Blue Team Wins");
|
|
|
|
}
|
|
|
|
else
|
2013-10-13 20:23:20 -04:00
|
|
|
{
|
2013-10-14 09:27:42 -04:00
|
|
|
//Cannot really happen now. Only in time limited matches.
|
2013-10-14 16:25:30 -04:00
|
|
|
resultText = _("It's a draw");
|
|
|
|
}
|
|
|
|
core::rect<s32> pos(currX, currY, currX, currY);
|
|
|
|
font->draw(resultText.c_str(), pos, color, true, true);
|
2013-10-17 07:24:50 -04:00
|
|
|
|
|
|
|
core::dimension2du rect = m_font->getDimension(resultText.c_str());
|
2013-10-14 16:25:30 -04:00
|
|
|
|
|
|
|
//Draw team scores:
|
2013-10-17 07:24:50 -04:00
|
|
|
currY += rect.Height;
|
2013-10-14 16:25:30 -04:00
|
|
|
currX /= 2;
|
|
|
|
irr::video::ITexture* redTeamIcon = irr_driver->getTexture(
|
|
|
|
file_manager->getTextureFile("soccer_ball_red.png"));
|
|
|
|
irr::video::ITexture* blueTeamIcon = irr_driver->getTexture(
|
|
|
|
file_manager->getTextureFile("soccer_ball_blue.png"));
|
|
|
|
|
|
|
|
core::recti sourceRect(core::vector2di(0,0), redTeamIcon->getSize());
|
|
|
|
core::recti destRect(currX, currY, currX+redTeamIcon->getSize().Width/2,
|
|
|
|
currY+redTeamIcon->getSize().Height/2);
|
|
|
|
irr_driver->getVideoDriver()->draw2DImage(redTeamIcon, destRect,sourceRect,
|
|
|
|
NULL,NULL, true);
|
|
|
|
currX += UserConfigParams::m_width/2 - redTeamIcon->getSize().Width/2;
|
|
|
|
destRect = core::recti(currX, currY, currX+redTeamIcon->getSize().Width/2,
|
|
|
|
currY+redTeamIcon->getSize().Height/2);
|
|
|
|
irr_driver->getVideoDriver()->draw2DImage(blueTeamIcon,destRect,sourceRect,
|
|
|
|
NULL, NULL, true);
|
|
|
|
|
|
|
|
resultText = StringUtils::toWString(teamScore[1]);
|
2013-10-17 07:24:50 -04:00
|
|
|
rect = m_font->getDimension(resultText.c_str());
|
|
|
|
currX += redTeamIcon->getSize().Width/4;
|
|
|
|
currY += redTeamIcon->getSize().Height/2 + rect.Height/4;
|
2013-10-14 16:25:30 -04:00
|
|
|
pos = core::rect<s32>(currX, currY, currX, currY);
|
|
|
|
color = video::SColor(255,255,255,255);
|
|
|
|
font->draw(resultText.c_str(), pos, color, true, false);
|
|
|
|
|
|
|
|
currX -= UserConfigParams::m_width/2 - redTeamIcon->getSize().Width/2;
|
|
|
|
resultText = StringUtils::toWString(teamScore[0]);
|
|
|
|
pos = core::rect<s32>(currX,currY,currX,currY);
|
|
|
|
font->draw(resultText.c_str(), pos, color, true, false);
|
|
|
|
|
|
|
|
int centerX = UserConfigParams::m_width/2;
|
|
|
|
pos = core::rect<s32>(centerX, currY, centerX, currY);
|
2013-10-17 07:24:50 -04:00
|
|
|
font->draw("-", pos, color, true, false);
|
2013-10-14 16:25:30 -04:00
|
|
|
|
|
|
|
//Draw goal scorers:
|
|
|
|
//The red scorers:
|
2013-10-17 07:24:50 -04:00
|
|
|
currY += rect.Height/2 + rect.Height/4;
|
2013-10-14 16:25:30 -04:00
|
|
|
font = GUIEngine::getSmallFont();
|
|
|
|
std::vector<int> scorers = soccerWorld->getScorers(0);
|
|
|
|
std::vector<float> scoreTimes = soccerWorld->getScoreTimes(0);
|
|
|
|
irr::video::ITexture* scorerIcon;
|
2013-10-13 20:23:20 -04:00
|
|
|
|
2013-10-17 07:24:50 -04:00
|
|
|
int prevY = currY;
|
2013-10-14 16:25:30 -04:00
|
|
|
for(unsigned int i=0; i<scorers.size(); i++)
|
2013-10-13 20:23:20 -04:00
|
|
|
{
|
2013-10-14 16:25:30 -04:00
|
|
|
resultText = soccerWorld->getKart(scorers.at(i))->
|
2013-10-14 16:19:49 -04:00
|
|
|
getKartProperties()->getName();
|
2013-10-14 16:25:30 -04:00
|
|
|
resultText.append(" ");
|
|
|
|
resultText.append(StringUtils::timeToString(scoreTimes.at(i)).c_str());
|
2013-10-17 07:24:50 -04:00
|
|
|
rect = m_font->getDimension(resultText.c_str());
|
|
|
|
currY += rect.Height;
|
2013-10-14 16:25:30 -04:00
|
|
|
pos = core::rect<s32>(currX,currY,currX,currY);
|
|
|
|
font->draw(resultText,pos, color, true, false);
|
2013-10-14 15:40:10 -04:00
|
|
|
scorerIcon = soccerWorld->getKart(scorers.at(i))->
|
|
|
|
getKartProperties()->getIconMaterial()->getTexture();
|
2013-10-14 16:25:30 -04:00
|
|
|
sourceRect = core::recti(core::vector2di(0,0), scorerIcon->getSize());
|
2013-10-14 09:27:42 -04:00
|
|
|
irr::u32 offsetX = GUIEngine::getFont()->getDimension(resultText.c_str()).Width/2;
|
2013-10-14 16:25:30 -04:00
|
|
|
destRect = core::recti(currX-offsetX-30, currY, currX-offsetX, currY+ 30);
|
|
|
|
irr_driver->getVideoDriver()->draw2DImage(scorerIcon, destRect, sourceRect,
|
|
|
|
NULL, NULL, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
//The blue scorers:
|
2013-10-17 07:24:50 -04:00
|
|
|
currY = prevY;
|
2013-10-14 16:25:30 -04:00
|
|
|
currX += UserConfigParams::m_width/2 - redTeamIcon->getSize().Width/2;
|
|
|
|
scorers = soccerWorld->getScorers(1);
|
|
|
|
scoreTimes = soccerWorld->getScoreTimes(1);
|
|
|
|
for(unsigned int i=0; i<scorers.size(); i++)
|
2013-10-13 20:23:20 -04:00
|
|
|
{
|
2013-10-14 16:25:30 -04:00
|
|
|
resultText = soccerWorld->getKart(scorers.at(i))->
|
2013-10-14 16:19:49 -04:00
|
|
|
getKartProperties()->getName();
|
2013-10-14 16:25:30 -04:00
|
|
|
resultText.append(" ");
|
|
|
|
resultText.append(StringUtils::timeToString(scoreTimes.at(i)).c_str());
|
2013-10-17 07:24:50 -04:00
|
|
|
rect = m_font->getDimension(resultText.c_str());
|
|
|
|
currY += rect.Height;
|
2013-10-14 16:25:30 -04:00
|
|
|
pos = core::rect<s32>(currX,currY,currX,currY);
|
|
|
|
font->draw(resultText,pos, color, true, false);
|
2013-10-14 15:40:10 -04:00
|
|
|
scorerIcon = soccerWorld->getKart(scorers.at(i))->
|
|
|
|
getKartProperties()->getIconMaterial()->getTexture();
|
2013-10-14 16:25:30 -04:00
|
|
|
sourceRect = core::recti(core::vector2di(0,0), scorerIcon->getSize());
|
2013-10-14 09:27:42 -04:00
|
|
|
irr::u32 offsetX = GUIEngine::getFont()->getDimension(resultText.c_str()).Width/2;
|
|
|
|
|
2013-10-14 16:25:30 -04:00
|
|
|
destRect = core::recti(currX-offsetX-30, currY, currX-offsetX, currY+ 30);
|
|
|
|
irr_driver->getVideoDriver()->draw2DImage(scorerIcon, destRect, sourceRect,
|
|
|
|
NULL, NULL, true);
|
|
|
|
}
|
2013-10-13 20:23:20 -04:00
|
|
|
}
|
|
|
|
|
2011-05-23 21:34:02 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void RaceResultGUI::clearHighscores()
|
|
|
|
{
|
2011-05-24 21:53:15 -04:00
|
|
|
m_highscore_who = "";
|
|
|
|
m_highscore_player = NULL;
|
|
|
|
m_highscore_rank = 0;
|
|
|
|
m_highscore_time = -1;
|
2011-10-26 01:01:51 -04:00
|
|
|
} // clearHighscores
|
2011-05-23 21:34:02 -04:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2013-05-29 18:04:35 -04:00
|
|
|
void RaceResultGUI::setHighscore(const std::string &who,
|
|
|
|
StateManager::ActivePlayer* player, int rank,
|
2011-10-26 01:01:51 -04:00
|
|
|
int time)
|
2011-05-23 21:34:02 -04:00
|
|
|
{
|
2011-05-24 21:53:15 -04:00
|
|
|
m_highscore_who = who;
|
|
|
|
m_highscore_player = player;
|
|
|
|
m_highscore_rank = rank;
|
|
|
|
m_highscore_time = time;
|
2011-10-26 01:01:51 -04:00
|
|
|
} // setHighscore
|
2011-10-07 19:25:02 -04:00
|
|
|
|
2011-10-26 01:01:51 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
2011-10-08 16:50:07 -04:00
|
|
|
void RaceResultGUI::enableGPProgress()
|
|
|
|
{
|
|
|
|
if (race_manager->getMajorMode() == RaceManager::MAJOR_MODE_GRAND_PRIX)
|
|
|
|
{
|
2013-05-29 18:04:35 -04:00
|
|
|
const std::vector<std::string>& tracks =
|
2012-11-27 07:09:16 -05:00
|
|
|
race_manager->getGrandPrix()->getTrackNames();
|
2011-10-08 16:50:07 -04:00
|
|
|
size_t currentTrack = race_manager->getTrackNumber();
|
2011-11-29 13:24:04 -05:00
|
|
|
|
|
|
|
// Assume 5 is the max amount we can render in any given height
|
|
|
|
size_t startTrack = 0;
|
|
|
|
size_t endTrack = tracks.size();
|
|
|
|
if (tracks.size() > 5)
|
|
|
|
{
|
|
|
|
if (currentTrack == 0)
|
|
|
|
{
|
|
|
|
startTrack = 0;
|
|
|
|
endTrack = 5;
|
|
|
|
}
|
|
|
|
else if (currentTrack + 4 > tracks.size())
|
|
|
|
{
|
|
|
|
startTrack = tracks.size() - 5;
|
|
|
|
endTrack = tracks.size();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
startTrack = currentTrack - 1;
|
|
|
|
endTrack = currentTrack + 4;
|
|
|
|
}
|
|
|
|
}
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-11-29 13:24:04 -05:00
|
|
|
for(size_t i=startTrack; i<endTrack; i++)
|
2011-10-08 16:50:07 -04:00
|
|
|
{
|
|
|
|
Track* track = track_manager->getTrack(tracks[i]);
|
2013-05-29 18:04:35 -04:00
|
|
|
GUIEngine::IconButtonWidget* m_screenshot_widget =
|
2011-10-26 01:01:51 -04:00
|
|
|
new GUIEngine::IconButtonWidget(GUIEngine::IconButtonWidget::
|
|
|
|
SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO,
|
2013-05-29 18:04:35 -04:00
|
|
|
false, false,
|
2011-10-26 01:01:51 -04:00
|
|
|
GUIEngine::IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
|
2011-10-08 16:50:07 -04:00
|
|
|
m_screenshot_widget->setCustomAspectRatio(4.0f / 3.0f);
|
|
|
|
m_screenshot_widget->m_x = (int)(UserConfigParams::m_width*0.67);
|
2013-05-29 18:04:35 -04:00
|
|
|
m_screenshot_widget->m_y =
|
2011-11-29 13:24:04 -05:00
|
|
|
(int)(UserConfigParams::m_height
|
|
|
|
* (0.10+(i-startTrack)*0.135));
|
2011-10-08 16:50:07 -04:00
|
|
|
m_screenshot_widget->m_w = (int)(UserConfigParams::m_width*0.17);
|
2013-05-29 18:04:35 -04:00
|
|
|
m_screenshot_widget->m_h =
|
2011-10-26 01:01:51 -04:00
|
|
|
(int)(UserConfigParams::m_height*0.1275);
|
2011-10-08 16:50:07 -04:00
|
|
|
|
2013-05-29 18:04:35 -04:00
|
|
|
m_screenshot_widget->m_properties[GUIEngine::PROP_ICON] =
|
2011-10-26 01:01:51 -04:00
|
|
|
(track ? track->getScreenshotFile()
|
|
|
|
: file_manager->getDataDir() + "gui/main_help.png");
|
2011-10-08 16:50:07 -04:00
|
|
|
m_screenshot_widget->m_properties[GUIEngine::PROP_ID] = tracks[i];
|
|
|
|
|
|
|
|
if(i <= currentTrack)
|
|
|
|
m_screenshot_widget->setBadge(GUIEngine::OK_BADGE);
|
|
|
|
|
|
|
|
m_screenshot_widget->add();
|
|
|
|
m_widgets.push_back(m_screenshot_widget);
|
2011-10-26 01:01:51 -04:00
|
|
|
} // for
|
|
|
|
} // if MAJOR_MODE_GRAND_PRIX)
|
|
|
|
|
|
|
|
} // enableGPProgress
|
2011-10-08 16:50:07 -04:00
|
|
|
|
2011-10-26 01:01:51 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
2011-10-07 19:25:02 -04:00
|
|
|
void RaceResultGUI::displayGPProgress()
|
|
|
|
{
|
2013-05-29 18:04:35 -04:00
|
|
|
video::SColor color = video::SColor(255,255,0,0);
|
2011-10-07 19:25:02 -04:00
|
|
|
core::recti dest_rect(m_gp_progress_x, m_top, 0, 0);
|
|
|
|
|
2011-11-18 14:53:18 -05:00
|
|
|
m_font->draw(_("Grand Prix progress:"), dest_rect, color, false, false, NULL, true);
|
2011-10-26 01:01:51 -04:00
|
|
|
} // displayGPProgress
|
2011-10-07 19:25:02 -04:00
|
|
|
|
2011-10-26 01:01:51 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
2011-10-07 19:25:02 -04:00
|
|
|
void RaceResultGUI::cleanupGPProgress()
|
|
|
|
{
|
2011-10-26 01:01:51 -04:00
|
|
|
const std::vector<std::string>& tracks =
|
2012-11-27 07:09:16 -05:00
|
|
|
race_manager->getGrandPrix()->getTrackNames();
|
2011-10-07 19:25:02 -04:00
|
|
|
for(size_t i=0; i<tracks.size(); i++)
|
|
|
|
{
|
2011-10-08 16:50:07 -04:00
|
|
|
GUIEngine::Widget *trackWidget = getWidget(tracks[i].c_str());
|
|
|
|
m_widgets.remove(trackWidget);
|
|
|
|
delete trackWidget;
|
2011-10-07 19:25:02 -04:00
|
|
|
}
|
2011-10-26 01:01:51 -04:00
|
|
|
} // cleanupGPProgress
|
2012-10-20 15:01:45 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
void RaceResultGUI::displayHighScores()
|
|
|
|
{
|
2012-11-16 07:51:26 -05:00
|
|
|
// This happens in demo world
|
|
|
|
if(!World::getWorld())
|
|
|
|
return;
|
|
|
|
|
2012-10-20 15:01:45 -04:00
|
|
|
Highscores* scores = World::getWorld()->getHighscores();
|
|
|
|
// In some case for exemple FTL they will be no highscores
|
|
|
|
if (scores != NULL)
|
|
|
|
{
|
|
|
|
video::SColor white_color = video::SColor(255,255,255,255);
|
|
|
|
|
|
|
|
int x = (int)(UserConfigParams::m_width*0.55f);
|
|
|
|
int y = m_top;
|
|
|
|
|
|
|
|
// First draw title
|
2013-05-29 18:04:35 -04:00
|
|
|
GUIEngine::getFont()->draw(_("Highscores"),
|
2012-10-20 15:01:45 -04:00
|
|
|
core::recti(x, y, 0, 0),
|
|
|
|
white_color,
|
|
|
|
false, false, NULL, true /* ignoreRTL */);
|
|
|
|
|
|
|
|
std::string kart_name;
|
|
|
|
irr::core::stringw player_name;
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2012-10-20 15:01:45 -04:00
|
|
|
// prevent excessive long name
|
2012-10-21 18:49:08 -04:00
|
|
|
unsigned int max_characters = 15;
|
2012-10-20 15:01:45 -04:00
|
|
|
float time;
|
|
|
|
for (int i = 0; i < scores->getNumberEntries(); i++)
|
|
|
|
{
|
|
|
|
scores->getEntry(i,kart_name,player_name, &time);
|
|
|
|
if (player_name.size() > max_characters)
|
|
|
|
{
|
|
|
|
int begin = (int(m_timer/0.4f)) % ( player_name.size() - max_characters );
|
|
|
|
player_name = player_name.subString(begin,max_characters,false);
|
|
|
|
}
|
|
|
|
|
|
|
|
video::SColor text_color = white_color;
|
|
|
|
if (m_highscore_rank-1 == i)
|
|
|
|
{
|
|
|
|
text_color = video::SColor(255,255,0, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
int current_x = x;
|
|
|
|
int current_y = y+(i+1)*50;
|
|
|
|
|
|
|
|
const KartProperties* prop = kart_properties_manager->getKart(kart_name);
|
|
|
|
if (prop != NULL)
|
|
|
|
{
|
|
|
|
const std::string &icon_path = prop->getAbsoluteIconFile();
|
|
|
|
video::ITexture* kart_icon_texture = irr_driver->getTexture( icon_path );
|
|
|
|
|
2013-01-20 15:28:47 -05:00
|
|
|
if (kart_icon_texture != NULL)
|
|
|
|
{
|
|
|
|
core::recti source_rect(core::vector2di(0,0),
|
|
|
|
kart_icon_texture->getSize());
|
2012-10-20 15:01:45 -04:00
|
|
|
|
2013-01-20 15:28:47 -05:00
|
|
|
core::recti dest_rect(current_x, current_y,
|
|
|
|
current_x+m_width_icon, current_y+m_width_icon);
|
2012-10-20 15:01:45 -04:00
|
|
|
|
2013-01-20 15:28:47 -05:00
|
|
|
irr_driver->getVideoDriver()->draw2DImage(
|
|
|
|
kart_icon_texture, dest_rect,
|
|
|
|
source_rect, NULL, NULL,
|
|
|
|
true);
|
2012-10-20 15:01:45 -04:00
|
|
|
|
2013-01-20 15:28:47 -05:00
|
|
|
current_x += m_width_icon + m_width_column_space;
|
|
|
|
}
|
2012-10-20 15:01:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// draw the player name
|
2013-05-29 18:04:35 -04:00
|
|
|
GUIEngine::getSmallFont()->draw(player_name.c_str(),
|
2012-10-20 15:01:45 -04:00
|
|
|
core::recti(current_x, current_y, current_x+150, current_y+10),
|
|
|
|
text_color,
|
|
|
|
false, false, NULL, true /* ignoreRTL */);
|
|
|
|
|
|
|
|
current_x += 180;
|
|
|
|
|
|
|
|
// Finally draw the time
|
|
|
|
std::string time_string = StringUtils::timeToString(time);
|
|
|
|
GUIEngine::getSmallFont()->draw(time_string.c_str(),
|
|
|
|
core::recti(current_x, current_y, current_x+100, current_y+10),
|
|
|
|
text_color,
|
|
|
|
false, false, NULL, true /* ignoreRTL */);
|
|
|
|
}
|
|
|
|
}
|
2013-01-15 01:28:41 -05:00
|
|
|
}
|