2010-12-15 17:59:55 -05:00
|
|
|
//
|
|
|
|
// SuperTuxKart - a fun racing game with go-kart
|
2013-11-15 06:43:21 -05:00
|
|
|
// Copyright (C) 2010-2013 SuperTuxKart-Team
|
2010-12-15 17:59:55 -05:00
|
|
|
//
|
|
|
|
// 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.
|
2010-02-20 21:22:05 -05:00
|
|
|
|
2010-05-30 11:48:24 -04:00
|
|
|
#include "states_screens/grand_prix_win.hpp"
|
2010-02-20 21:22:05 -05:00
|
|
|
|
2010-07-20 20:01:22 -04:00
|
|
|
#include <SColor.h>
|
|
|
|
#include <iostream>
|
|
|
|
|
2010-04-21 13:24:02 -04:00
|
|
|
#include "audio/music_manager.hpp"
|
2010-02-23 18:47:31 -05:00
|
|
|
#include "audio/sfx_manager.hpp"
|
2010-03-08 11:44:09 -05:00
|
|
|
#include "challenges/unlock_manager.hpp"
|
2014-02-09 07:22:45 -05:00
|
|
|
#include "config/player_manager.hpp"
|
2010-02-21 18:10:24 -05:00
|
|
|
#include "graphics/irr_driver.hpp"
|
2010-02-20 21:22:05 -05:00
|
|
|
#include "guiengine/engine.hpp"
|
2010-07-20 20:01:22 -04:00
|
|
|
#include "guiengine/scalable_font.hpp"
|
2010-03-08 11:44:09 -05:00
|
|
|
#include "guiengine/widgets/label_widget.hpp"
|
2010-02-20 21:22:05 -05:00
|
|
|
#include "io/file_manager.hpp"
|
|
|
|
#include "items/item_manager.hpp"
|
2012-03-19 16:21:11 -04:00
|
|
|
#include "karts/kart_properties.hpp"
|
2010-02-21 18:10:24 -05:00
|
|
|
#include "karts/kart_properties_manager.hpp"
|
2014-05-02 18:47:43 -04:00
|
|
|
#include "modes/cutscene_world.hpp"
|
|
|
|
#include "modes/world.hpp"
|
2010-03-08 12:04:05 -05:00
|
|
|
#include "states_screens/feature_unlocked.hpp"
|
2010-02-20 21:22:05 -05:00
|
|
|
#include "states_screens/state_manager.hpp"
|
2014-05-02 18:47:43 -04:00
|
|
|
#include "tracks/track.hpp"
|
|
|
|
#include "tracks/track_object.hpp"
|
|
|
|
#include "tracks/track_object_manager.hpp"
|
2010-02-20 21:22:05 -05:00
|
|
|
#include "utils/translation.hpp"
|
|
|
|
|
2011-05-22 15:29:52 -04:00
|
|
|
#include <IGUIEnvironment.h>
|
|
|
|
#include <ICameraSceneNode.h>
|
|
|
|
#include <ISceneManager.h>
|
|
|
|
#include <ILightSceneNode.h>
|
|
|
|
#include <IGUIImage.h>
|
|
|
|
#include <IMeshSceneNode.h>
|
|
|
|
|
2010-02-20 21:22:05 -05:00
|
|
|
using namespace irr::core;
|
|
|
|
using namespace irr::gui;
|
|
|
|
using namespace irr::video;
|
|
|
|
|
2014-05-03 19:19:00 -04:00
|
|
|
const float KARTS_X = -0.62f;
|
|
|
|
const float KARTS_DELTA_X = 0.815f;
|
|
|
|
const float KARTS_DELTA_Y = -0.55f;
|
2014-05-03 19:42:38 -04:00
|
|
|
const float KARTS_DEST_Z = 1.2f;
|
2014-05-03 19:19:00 -04:00
|
|
|
const float INITIAL_Y = 0.0f;
|
2014-05-03 19:42:38 -04:00
|
|
|
const float INITIAL_PODIUM_Y = -0.89f;
|
2010-02-21 18:10:24 -05:00
|
|
|
const float PODIUM_HEIGHT[3] = { 0.325f, 0.5f, 0.15f };
|
|
|
|
|
2010-05-30 11:48:24 -04:00
|
|
|
DEFINE_SCREEN_SINGLETON( GrandPrixWin );
|
2010-03-18 14:18:19 -04:00
|
|
|
|
2010-02-20 21:22:05 -05:00
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
|
2014-05-02 18:47:43 -04:00
|
|
|
GrandPrixWin::GrandPrixWin() : Screen("grand_prix_win.stkgui", false)
|
2010-02-20 21:22:05 -05:00
|
|
|
{
|
|
|
|
setNeeds3D(true);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-04-25 15:23:57 -04:00
|
|
|
m_throttle_FPS = false;
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2014-05-02 18:47:43 -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("gpwin", 999, false);
|
|
|
|
std::vector<std::string> parts;
|
|
|
|
parts.push_back("gpwin");
|
|
|
|
((CutsceneWorld*)World::getWorld())->setParts(parts);
|
|
|
|
CutsceneWorld::setUseDuration(false);
|
2014-05-03 19:19:00 -04:00
|
|
|
|
2014-05-02 18:47:43 -04:00
|
|
|
World::getWorld()->setPhase(WorldStatus::RACE_PHASE);
|
2014-05-03 19:42:38 -04:00
|
|
|
|
|
|
|
m_kart_node[0] = NULL;
|
|
|
|
m_kart_node[1] = NULL;
|
|
|
|
m_kart_node[2] = NULL;
|
|
|
|
|
|
|
|
m_podium_steps[0] = NULL;
|
|
|
|
m_podium_steps[1] = NULL;
|
|
|
|
m_podium_steps[2] = NULL;
|
|
|
|
|
2010-08-14 21:15:19 -04:00
|
|
|
} // GrandPrixWin
|
2010-05-01 15:16:38 -04:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
|
2010-05-30 11:48:24 -04:00
|
|
|
void GrandPrixWin::loadedFromFile()
|
2010-05-01 15:16:38 -04:00
|
|
|
{
|
2014-05-02 18:47:43 -04:00
|
|
|
//m_podium_x[0] = 1.4f;
|
|
|
|
//m_podium_z[0] = 0.0f;
|
|
|
|
//
|
|
|
|
//m_podium_x[1] = 2.2f;
|
|
|
|
//m_podium_z[1] = 0.5f;
|
|
|
|
//
|
|
|
|
//m_podium_x[2] = 3.0f;
|
|
|
|
//m_podium_z[2] = 0.0f;
|
2010-08-14 21:15:19 -04:00
|
|
|
} // loadedFromFile
|
2010-02-20 21:22:05 -05:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
|
2010-05-30 11:48:24 -04:00
|
|
|
void GrandPrixWin::init()
|
2010-02-20 21:22:05 -05:00
|
|
|
{
|
2010-08-14 21:15:19 -04:00
|
|
|
Screen::init();
|
2014-04-07 18:06:52 -04:00
|
|
|
if (PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges().size() > 0)
|
2010-03-08 11:44:09 -05:00
|
|
|
{
|
|
|
|
const core::dimension2d<u32>& frame_size = GUIEngine::getDriver()->getCurrentRenderTargetSize();
|
|
|
|
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2013-06-19 18:27:50 -04:00
|
|
|
core::stringw message = _("You completed a challenge!");
|
2010-03-08 11:44:09 -05:00
|
|
|
const int message_width = GUIEngine::getFont()->getDimension(message.c_str()).Width + 30;
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-03-08 11:44:09 -05:00
|
|
|
const int label_height = GUIEngine::getFontHeight() + 15;
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-03-08 11:44:09 -05:00
|
|
|
const int y_from = frame_size.Height - label_height*2;
|
|
|
|
const int y_to = frame_size.Height - label_height;
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-03-08 11:44:09 -05:00
|
|
|
const int label_x_from = frame_size.Width/2 - message_width/2;
|
|
|
|
const int label_x_to = frame_size.Width/2 + message_width/2;
|
|
|
|
|
|
|
|
// button_h is used in the x coordinates not by mistake, but because the icon is square and
|
|
|
|
// scaled according to the available height.
|
|
|
|
core::rect< s32 > iconarea(label_x_from - label_height, y_from,
|
|
|
|
label_x_from, y_to);
|
|
|
|
IGUIImage* img = GUIEngine::getGUIEnv()->addImage( iconarea );
|
2013-12-18 17:29:08 -05:00
|
|
|
img->setImage( irr_driver->getTexture( FileManager::GUI, "cup_gold.png") );
|
2010-03-08 11:44:09 -05:00
|
|
|
img->setScaleImage(true);
|
|
|
|
img->setTabStop(false);
|
|
|
|
img->setUseAlphaChannel(true);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-03-08 11:44:09 -05:00
|
|
|
core::rect< s32 > icon2area(label_x_to, y_from,
|
|
|
|
label_x_to + label_height, y_to);
|
|
|
|
img = GUIEngine::getGUIEnv()->addImage( icon2area );
|
2013-12-18 17:29:08 -05:00
|
|
|
img->setImage( irr_driver->getTexture( FileManager::GUI,"cup_gold.png") );
|
2010-03-08 11:44:09 -05:00
|
|
|
img->setScaleImage(true);
|
|
|
|
img->setTabStop(false);
|
|
|
|
img->setUseAlphaChannel(true);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-10-18 17:14:35 -04:00
|
|
|
m_unlocked_label = new GUIEngine::LabelWidget();
|
|
|
|
m_unlocked_label->m_properties[GUIEngine::PROP_ID] = "label";
|
|
|
|
m_unlocked_label->m_properties[GUIEngine::PROP_TEXT_ALIGN] = "center";
|
|
|
|
m_unlocked_label->m_x = label_x_from;
|
|
|
|
m_unlocked_label->m_y = y_from;
|
|
|
|
m_unlocked_label->m_w = message_width;
|
|
|
|
m_unlocked_label->m_h = label_height;
|
|
|
|
m_unlocked_label->setText(message, false);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-10-18 17:14:35 -04:00
|
|
|
m_unlocked_label->add();
|
|
|
|
manualAddWidget(m_unlocked_label);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_unlocked_label = NULL;
|
2010-03-08 11:44:09 -05:00
|
|
|
}
|
2010-02-21 19:46:04 -05:00
|
|
|
|
2010-02-20 21:22:05 -05:00
|
|
|
m_global_time = 0.0f;
|
2014-05-02 18:47:43 -04:00
|
|
|
m_phase = 1;
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2013-11-30 16:33:06 -05:00
|
|
|
sfx_manager->quickSound("gp_end");
|
2010-08-14 21:15:19 -04:00
|
|
|
} // init
|
2010-02-20 21:22:05 -05:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
|
2010-05-30 11:48:24 -04:00
|
|
|
void GrandPrixWin::tearDown()
|
2010-02-20 21:22:05 -05:00
|
|
|
{
|
2010-08-14 21:15:19 -04:00
|
|
|
Screen::tearDown();
|
2014-05-02 18:47:43 -04:00
|
|
|
((CutsceneWorld*)World::getWorld())->abortCutscene();
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2014-05-02 18:47:43 -04:00
|
|
|
for (unsigned int i = 0; i<m_all_kart_models.size(); i++)
|
2010-09-10 09:30:31 -04:00
|
|
|
delete m_all_kart_models[i];
|
|
|
|
m_all_kart_models.clear();
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2011-10-18 17:14:35 -04:00
|
|
|
if (m_unlocked_label != NULL)
|
|
|
|
{
|
|
|
|
manualRemoveWidget(m_unlocked_label);
|
|
|
|
delete m_unlocked_label;
|
|
|
|
m_unlocked_label = NULL;
|
|
|
|
}
|
2010-08-14 21:15:19 -04:00
|
|
|
} // tearDown
|
2010-02-20 21:22:05 -05:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
|
2014-01-21 15:43:17 -05:00
|
|
|
void GrandPrixWin::onUpdate(float dt)
|
2010-02-20 21:22:05 -05:00
|
|
|
{
|
|
|
|
m_global_time += dt;
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-02-21 18:10:24 -05:00
|
|
|
// ---- karts move
|
|
|
|
if (m_phase == 1)
|
|
|
|
{
|
2010-05-30 11:48:24 -04:00
|
|
|
assert(m_kart_node[0] != NULL || m_kart_node[1] != NULL || m_kart_node[2] != NULL);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-02-21 18:45:13 -05:00
|
|
|
int karts_not_yet_done = 0;
|
2010-02-21 18:10:24 -05:00
|
|
|
for (int k=0; k<3; k++)
|
|
|
|
{
|
|
|
|
if (m_kart_node[k] != NULL)
|
|
|
|
{
|
2010-02-21 19:46:04 -05:00
|
|
|
|
2014-05-03 19:42:38 -04:00
|
|
|
if (fabsf(m_kart_z[k] - KARTS_DEST_Z) > dt)
|
2010-02-21 18:10:24 -05:00
|
|
|
{
|
2014-05-03 19:42:38 -04:00
|
|
|
if (m_kart_z[k] < KARTS_DEST_Z - dt)
|
2010-02-21 18:10:24 -05:00
|
|
|
{
|
|
|
|
m_kart_z[k] += dt;
|
|
|
|
}
|
2014-05-03 19:42:38 -04:00
|
|
|
else if (m_kart_z[k] > KARTS_DEST_Z + dt)
|
2010-02-21 18:10:24 -05:00
|
|
|
{
|
|
|
|
m_kart_z[k] -= dt;
|
|
|
|
}
|
2010-03-03 14:00:36 -05:00
|
|
|
else
|
|
|
|
{
|
2014-05-03 19:42:38 -04:00
|
|
|
m_kart_z[k] = KARTS_DEST_Z;
|
2010-03-03 14:00:36 -05:00
|
|
|
}
|
2010-02-21 19:46:04 -05:00
|
|
|
karts_not_yet_done++;
|
2010-02-21 18:10:24 -05:00
|
|
|
}
|
2010-02-21 19:46:04 -05:00
|
|
|
|
2014-05-03 19:42:38 -04:00
|
|
|
core::vector3df kart_pos(m_kart_x[k], m_kart_y[k], m_kart_z[k]);
|
|
|
|
core::vector3df kart_rot(0, m_kart_rotation[k], 0);
|
|
|
|
core::vector3df kart_scale(0.5f, 0.5f, 0.5f);
|
|
|
|
m_kart_node[k]->move(kart_pos, kart_rot, kart_scale, false);
|
2010-02-21 18:10:24 -05:00
|
|
|
}
|
|
|
|
} // end for
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-02-21 18:45:13 -05:00
|
|
|
if (karts_not_yet_done == 0)
|
2010-02-21 18:10:24 -05:00
|
|
|
{
|
|
|
|
m_phase = 2;
|
|
|
|
}
|
|
|
|
}
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-02-21 18:10:24 -05:00
|
|
|
// ---- Karts Rotate
|
|
|
|
else if (m_phase == 2)
|
|
|
|
{
|
2010-02-21 18:45:13 -05:00
|
|
|
int karts_not_yet_done = 0;
|
2010-02-21 18:10:24 -05:00
|
|
|
for (int k=0; k<3; k++)
|
|
|
|
{
|
|
|
|
if (m_kart_node[k] != NULL)
|
|
|
|
{
|
|
|
|
if (m_kart_rotation[k] < 180.f)
|
|
|
|
{
|
|
|
|
m_kart_rotation[k] += 25.0f*dt;
|
2014-05-03 19:42:38 -04:00
|
|
|
|
|
|
|
core::vector3df kart_pos(m_kart_x[k], m_kart_y[k], m_kart_z[k]);
|
|
|
|
core::vector3df kart_rot(0, m_kart_rotation[k], 0);
|
|
|
|
core::vector3df kart_scale(0.5f, 0.5f, 0.5f);
|
|
|
|
m_kart_node[k]->move(kart_pos, kart_rot, kart_scale, false);
|
|
|
|
|
|
|
|
core::vector3df podium_pos = m_podium_steps[k]->getInitXYZ();
|
|
|
|
core::vector3df podium_rot(0, m_kart_rotation[k], 0);
|
|
|
|
m_podium_steps[k]->move(podium_pos, podium_rot, core::vector3df(1.0f, 1.0f, 1.0f), false);
|
|
|
|
|
2010-02-21 18:45:13 -05:00
|
|
|
karts_not_yet_done++;
|
2010-02-21 18:10:24 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} // end for
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-02-21 18:45:13 -05:00
|
|
|
if (karts_not_yet_done == 0) m_phase = 3;
|
2010-02-21 18:10:24 -05:00
|
|
|
}
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-02-21 18:10:24 -05:00
|
|
|
// ---- Podium Rises
|
|
|
|
else if (m_phase == 3)
|
|
|
|
{
|
|
|
|
for (int k=0; k<3; k++)
|
|
|
|
{
|
|
|
|
if (m_kart_node[k] != NULL)
|
|
|
|
{
|
|
|
|
const float y_target = INITIAL_Y + PODIUM_HEIGHT[k];
|
2010-10-10 11:12:40 -04:00
|
|
|
if (m_kart_y[k] < y_target + KARTS_DELTA_Y)
|
2010-02-21 18:10:24 -05:00
|
|
|
{
|
|
|
|
m_kart_y[k] += dt*(PODIUM_HEIGHT[k]);
|
2014-05-03 19:42:38 -04:00
|
|
|
core::vector3df kart_pos(m_kart_x[k], m_kart_y[k], m_kart_z[k]);
|
|
|
|
core::vector3df kart_rot(0, m_kart_rotation[k], 0);
|
|
|
|
core::vector3df kart_scale(0.5f, 0.5f, 0.5f);
|
|
|
|
m_kart_node[k]->move(kart_pos, kart_rot, kart_scale, false);
|
|
|
|
|
2010-02-21 18:10:24 -05:00
|
|
|
|
2014-05-03 19:42:38 -04:00
|
|
|
core::vector3df podium_pos = m_podium_steps[k]->getInitXYZ();
|
|
|
|
core::vector3df podium_rot(0, m_kart_rotation[k], 0);
|
|
|
|
podium_pos.Y = INITIAL_PODIUM_Y - (INITIAL_Y - m_kart_y[k]) - KARTS_DELTA_Y;
|
|
|
|
m_podium_steps[k]->move(podium_pos, podium_rot, core::vector3df(1.0f, 1.0f, 1.0f), false);
|
2010-02-21 18:10:24 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} // end for
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-02-21 18:10:24 -05:00
|
|
|
}
|
2014-05-03 19:42:38 -04:00
|
|
|
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-02-21 18:10:24 -05:00
|
|
|
// ---- title
|
2010-02-20 21:22:05 -05:00
|
|
|
static const int w = irr_driver->getFrameSize().Width;
|
|
|
|
static const int h = irr_driver->getFrameSize().Height;
|
|
|
|
const irr::video::SColor color(255, 255, 255, 255);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-02-20 21:22:05 -05:00
|
|
|
static int test_y = 0;
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-10-01 19:05:28 -04:00
|
|
|
GUIEngine::getTitleFont()->draw(_("You completed the Grand Prix!"),
|
2010-02-20 21:22:05 -05:00
|
|
|
core::rect< s32 >( 0, test_y, w, h/10 ),
|
|
|
|
color,
|
|
|
|
true/* center h */, true /* center v */ );
|
2010-08-14 21:15:19 -04:00
|
|
|
} // onUpdate
|
2010-02-20 21:22:05 -05:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
|
|
|
|
2010-05-30 11:48:24 -04:00
|
|
|
void GrandPrixWin::eventCallback(GUIEngine::Widget* widget,
|
2010-02-20 21:22:05 -05:00
|
|
|
const std::string& name,
|
|
|
|
const int playerID)
|
|
|
|
{
|
|
|
|
if (name == "continue")
|
|
|
|
{
|
2010-03-08 12:04:05 -05:00
|
|
|
// un-set the GP mode so that after unlocking, it doesn't try to continue the GP
|
|
|
|
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2014-04-07 18:06:52 -04:00
|
|
|
if (PlayerManager::getCurrentPlayer()
|
|
|
|
->getRecentlyCompletedChallenges().size() > 0)
|
2010-03-08 12:04:05 -05:00
|
|
|
{
|
2013-05-29 18:04:35 -04:00
|
|
|
std::vector<const ChallengeData*> unlocked =
|
2014-04-07 18:06:52 -04:00
|
|
|
PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges();
|
|
|
|
PlayerManager::getCurrentPlayer()->clearUnlocked();
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2014-05-02 18:47:43 -04:00
|
|
|
FeatureUnlockedCutScene* scene = FeatureUnlockedCutScene::getInstance();
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-03-08 12:04:05 -05:00
|
|
|
assert(unlocked.size() > 0);
|
2012-02-14 20:58:24 -05:00
|
|
|
scene->addTrophy(race_manager->getDifficulty());
|
2012-11-26 19:41:38 -05:00
|
|
|
scene->findWhatWasUnlocked(race_manager->getDifficulty());
|
2013-05-29 18:04:35 -04:00
|
|
|
|
2010-03-08 12:04:05 -05:00
|
|
|
StateManager::get()->replaceTopMostScreen(scene);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// we assume the main menu was pushed before showing this menu
|
|
|
|
StateManager::get()->popMenu();
|
|
|
|
}
|
2010-02-20 21:22:05 -05:00
|
|
|
}
|
2010-08-14 21:15:19 -04:00
|
|
|
} // eventCallback
|
2010-02-20 21:22:05 -05:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|
2010-02-21 18:10:24 -05:00
|
|
|
|
2010-05-30 11:48:24 -04:00
|
|
|
void GrandPrixWin::setKarts(const std::string idents_arg[3])
|
2010-02-21 18:10:24 -05:00
|
|
|
{
|
2014-05-03 19:42:38 -04:00
|
|
|
TrackObjectManager* tobjman = World::getWorld()->getTrack()->getTrackObjectManager();
|
2014-05-03 19:19:00 -04:00
|
|
|
|
|
|
|
// reorder in "podium order" (i.e. second player to the left, first player in the middle, last at the right)
|
|
|
|
std::string idents[3];
|
|
|
|
idents[0] = idents_arg[1];
|
|
|
|
idents[1] = idents_arg[0];
|
|
|
|
idents[2] = idents_arg[2];
|
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
{
|
|
|
|
const KartProperties* kp = kart_properties_manager->getKart(idents[i]);
|
|
|
|
KartModel* kart_model = kp->getKartModelCopy();
|
|
|
|
m_all_kart_models.push_back(kart_model);
|
|
|
|
scene::ISceneNode* kart_main_node = kart_model->attachModel(false);
|
2014-05-03 19:42:38 -04:00
|
|
|
|
|
|
|
m_kart_x[i] = KARTS_X + i*KARTS_DELTA_X;
|
|
|
|
m_kart_y[i] = INITIAL_Y + KARTS_DELTA_Y;
|
|
|
|
m_kart_z[i] = -4; // to 1.2
|
|
|
|
m_kart_rotation[i] = 0.0f;
|
|
|
|
|
|
|
|
core::vector3df kart_pos(m_kart_x[i], m_kart_y[i], m_kart_z[i]);
|
2014-05-03 19:19:00 -04:00
|
|
|
core::vector3df kart_rot(0, 0, 0);
|
|
|
|
core::vector3df kart_scale(0.5, 0.5, 0.5);
|
|
|
|
|
|
|
|
//FIXME: it's not ideal that both the track object and the presentation know the initial coordinates of the object
|
|
|
|
TrackObjectPresentationSceneNode* presentation = new TrackObjectPresentationSceneNode(
|
|
|
|
kart_main_node, kart_pos, kart_rot, kart_scale);
|
2014-05-03 19:42:38 -04:00
|
|
|
TrackObject* tobj = new TrackObject(kart_pos, kart_rot, kart_scale,
|
2014-05-03 19:19:00 -04:00
|
|
|
"ghost", presentation, false /* isDynamic */, NULL /* physics settings */);
|
2014-05-03 19:42:38 -04:00
|
|
|
tobjman->insertObject(tobj);
|
2014-05-03 19:19:00 -04:00
|
|
|
|
2014-05-03 19:42:38 -04:00
|
|
|
m_kart_node[i] = tobj;
|
|
|
|
}
|
2014-05-03 19:19:00 -04:00
|
|
|
|
|
|
|
TrackObject* currObj;
|
2014-05-03 19:42:38 -04:00
|
|
|
PtrVector<TrackObject>& objects = tobjman->getObjects();
|
2014-05-03 19:19:00 -04:00
|
|
|
for_in(currObj, objects)
|
|
|
|
{
|
|
|
|
TrackObjectPresentationMesh* meshPresentation = currObj->getPresentation<TrackObjectPresentationMesh>();
|
|
|
|
if (meshPresentation != NULL)
|
|
|
|
{
|
|
|
|
if (meshPresentation->getModelFile() == "gpwin_podium1.b3d")
|
|
|
|
{
|
|
|
|
m_podium_steps[0] = currObj;
|
|
|
|
}
|
|
|
|
else if (meshPresentation->getModelFile() == "gpwin_podium2.b3d")
|
|
|
|
{
|
|
|
|
m_podium_steps[1] = currObj;
|
|
|
|
}
|
|
|
|
else if (meshPresentation->getModelFile() == "gpwin_podium3.b3d")
|
|
|
|
{
|
|
|
|
m_podium_steps[2] = currObj;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(m_podium_steps[0] != NULL);
|
|
|
|
assert(m_podium_steps[1] != NULL);
|
|
|
|
assert(m_podium_steps[2] != NULL);
|
2010-08-14 21:15:19 -04:00
|
|
|
} // setKarts
|
2010-02-21 18:10:24 -05:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------
|