Merge branch 'save_gp'
This commit is contained in:
commit
83a1acc961
@ -1,7 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<stkgui>
|
<stkgui>
|
||||||
<div x="2%" y="2%" width="96%" height="96%" layout="vertical-row">
|
<div x="2%" y="2%" width="96%" height="96%" layout="horizontal-row">
|
||||||
<spacer width="10" proportion="1"/>
|
<button id="continue" width="250" align="bottom" text="Continue"/>
|
||||||
<button id="continue" x="20" width="250" align="left" text="Continue"/>
|
<spacer width="20"/>
|
||||||
|
<button id="save" width="250" align="bottom" text="Save Grand Prix"/>
|
||||||
</div>
|
</div>
|
||||||
</stkgui>
|
</stkgui>
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<stkgui>
|
<stkgui>
|
||||||
<div x="2%" y="2%" width="96%" height="96%" layout="vertical-row">
|
<div x="2%" y="2%" width="96%" height="96%" layout="horizontal-row">
|
||||||
<spacer width="10" proportion="1"/>
|
<button id="continue" width="250" align="bottom" text="Continue"/>
|
||||||
<button id="continue" x="20" width="250" align="left" text="Continue"/>
|
<spacer width="20"/>
|
||||||
|
<button id="save" width="250" align="bottom" text="Save Grand Prix"/>
|
||||||
</div>
|
</div>
|
||||||
</stkgui>
|
</stkgui>
|
||||||
|
|
||||||
|
@ -43,6 +43,8 @@ void ButtonWidget::add()
|
|||||||
m_id = m_element->getID();
|
m_id = m_element->getID();
|
||||||
m_element->setTabOrder(m_id);
|
m_element->setTabOrder(m_id);
|
||||||
m_element->setTabGroup(false);
|
m_element->setTabGroup(false);
|
||||||
|
if (!m_is_visible)
|
||||||
|
m_element->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -45,8 +45,6 @@ private:
|
|||||||
/** Generates a new unique indentifier for a user defined grand prix */
|
/** Generates a new unique indentifier for a user defined grand prix */
|
||||||
std::string generateId();
|
std::string generateId();
|
||||||
|
|
||||||
bool existsName(const irr::core::stringw& name) const;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GrandPrixManager();
|
GrandPrixManager();
|
||||||
~GrandPrixManager();
|
~GrandPrixManager();
|
||||||
@ -54,6 +52,7 @@ public:
|
|||||||
GrandPrixData* getGrandPrix(const int i) const { return m_gp_data[i]; }
|
GrandPrixData* getGrandPrix(const int i) const { return m_gp_data[i]; }
|
||||||
GrandPrixData* getGrandPrix(const std::string& s) const;
|
GrandPrixData* getGrandPrix(const std::string& s) const;
|
||||||
unsigned int getNumberOfGrandPrix() const { return m_gp_data.size(); }
|
unsigned int getNumberOfGrandPrix() const { return m_gp_data.size(); }
|
||||||
|
bool existsName(const irr::core::stringw& name) const;
|
||||||
void checkConsistency();
|
void checkConsistency();
|
||||||
|
|
||||||
// Methods for the gp editor
|
// Methods for the gp editor
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include "network/protocol_manager.hpp"
|
#include "network/protocol_manager.hpp"
|
||||||
#include "network/network_world.hpp"
|
#include "network/network_world.hpp"
|
||||||
#include "network/protocols/start_game_protocol.hpp"
|
#include "network/protocols/start_game_protocol.hpp"
|
||||||
|
#include "states_screens/grand_prix_cutscene.hpp"
|
||||||
#include "states_screens/grand_prix_lose.hpp"
|
#include "states_screens/grand_prix_lose.hpp"
|
||||||
#include "states_screens/grand_prix_win.hpp"
|
#include "states_screens/grand_prix_win.hpp"
|
||||||
#include "states_screens/kart_selection.hpp"
|
#include "states_screens/kart_selection.hpp"
|
||||||
@ -678,16 +679,17 @@ void RaceManager::exitRace(bool delete_world)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (delete_world) World::deleteWorld();
|
||||||
|
delete_world = false;
|
||||||
|
|
||||||
|
StateManager::get()->enterGameState();
|
||||||
|
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
|
||||||
|
race_manager->setNumKarts(0);
|
||||||
|
race_manager->setNumPlayers(0);
|
||||||
|
race_manager->setNumLocalPlayers(0);
|
||||||
|
|
||||||
if (someHumanPlayerWon)
|
if (someHumanPlayerWon)
|
||||||
{
|
{
|
||||||
if (delete_world) World::deleteWorld();
|
|
||||||
delete_world = false;
|
|
||||||
|
|
||||||
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);
|
race_manager->startSingleRace("gpwin", 999, false);
|
||||||
GrandPrixWin* scene = GrandPrixWin::getInstance();
|
GrandPrixWin* scene = GrandPrixWin::getInstance();
|
||||||
StateManager::get()->pushScreen(scene);
|
StateManager::get()->pushScreen(scene);
|
||||||
@ -695,14 +697,6 @@ void RaceManager::exitRace(bool delete_world)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (delete_world) World::deleteWorld();
|
|
||||||
delete_world = false;
|
|
||||||
|
|
||||||
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("gplose", 999, false);
|
race_manager->startSingleRace("gplose", 999, false);
|
||||||
GrandPrixLose* scene = GrandPrixLose::getInstance();
|
GrandPrixLose* scene = GrandPrixLose::getInstance();
|
||||||
StateManager::get()->pushScreen(scene);
|
StateManager::get()->pushScreen(scene);
|
||||||
@ -713,7 +707,8 @@ void RaceManager::exitRace(bool delete_world)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "RaceManager::exitRace() : what's going on?? no winners and no losers??\n";
|
Log::error("RaceManager", "There are no winners and no losers."
|
||||||
|
"This should have never happend\n");
|
||||||
std::vector<std::string> karts;
|
std::vector<std::string> karts;
|
||||||
karts.push_back(UserConfigParams::m_default_kart);
|
karts.push_back(UserConfigParams::m_default_kart);
|
||||||
scene->setKarts(karts);
|
scene->setKarts(karts);
|
||||||
|
@ -84,17 +84,13 @@ void EnterGPNameDialog::onEnterPressedInternal()
|
|||||||
if (name.size() > 0 && name != "Random Grand Prix")
|
if (name.size() > 0 && name != "Random Grand Prix")
|
||||||
{
|
{
|
||||||
// check for duplicate names
|
// check for duplicate names
|
||||||
for (unsigned int i = 0; i < grand_prix_manager->getNumberOfGrandPrix(); i++)
|
if (grand_prix_manager->existsName(name))
|
||||||
{
|
{
|
||||||
const GrandPrixData* gp = grand_prix_manager->getGrandPrix(i);
|
LabelWidget* label = getWidget<LabelWidget>("title");
|
||||||
if (gp->getName() == name)
|
assert(label != NULL);
|
||||||
{
|
label->setText(_("Another grand prix with this name already exists."), false);
|
||||||
LabelWidget* label = getWidget<LabelWidget>("title");
|
sfx_manager->quickSound("anvil");
|
||||||
assert(label != NULL);
|
return;
|
||||||
label->setText(_("Another grand prix with this name already exists."), false);
|
|
||||||
sfx_manager->quickSound("anvil");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// It's unsafe to delete from inside the event handler so we do it
|
// It's unsafe to delete from inside the event handler so we do it
|
||||||
|
91
src/states_screens/grand_prix_cutscene.cpp
Normal file
91
src/states_screens/grand_prix_cutscene.cpp
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
// SuperTuxKart - a fun racing game with go-kart
|
||||||
|
// Copyright (C) 2014 konstin
|
||||||
|
//
|
||||||
|
// 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 "guiengine/scalable_font.hpp"
|
||||||
|
#include "guiengine/widgets/button_widget.hpp"
|
||||||
|
#include "modes/cutscene_world.hpp"
|
||||||
|
#include "race/grand_prix_data.hpp"
|
||||||
|
#include "race/grand_prix_manager.hpp"
|
||||||
|
#include "race/race_manager.hpp"
|
||||||
|
#include "states_screens/grand_prix_cutscene.hpp"
|
||||||
|
#include "tracks/track_manager.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
typedef GUIEngine::ButtonWidget Button;
|
||||||
|
|
||||||
|
/** A Button to save the GP if it was a random GP */
|
||||||
|
void GrandPrixCutscene::saveGPButton()
|
||||||
|
{
|
||||||
|
if (race_manager->getGrandPrix().getId() != "random")
|
||||||
|
getWidget<Button>("save")->setVisible(false);
|
||||||
|
} // saveGPButton
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/** \brief Creates a new GP with the same content as the current and saves it
|
||||||
|
* The GP that the race_manager provides can't be used because we need some
|
||||||
|
* functions and settings that the GP manager only gives us through
|
||||||
|
* createNewGP(). */
|
||||||
|
void GrandPrixCutscene::onNewGPWithName(const irr::core::stringw& name)
|
||||||
|
{
|
||||||
|
// create a new GP with the correct filename and a unique id
|
||||||
|
GrandPrixData* gp = grand_prix_manager->createNewGP(name);
|
||||||
|
const GrandPrixData current_gp = race_manager->getGrandPrix();
|
||||||
|
std::vector<std::string> tracks = current_gp.getTrackNames();
|
||||||
|
std::vector<int> laps = current_gp.getLaps();
|
||||||
|
std::vector<bool> reverse = current_gp.getReverse();
|
||||||
|
for (unsigned int i = 0; i < laps.size(); i++)
|
||||||
|
gp->addTrack(track_manager->getTrack(tracks[i]), laps[i], reverse[i]);
|
||||||
|
gp->writeToFile();
|
||||||
|
|
||||||
|
// Avoid double-save which can have bad side-effects
|
||||||
|
getWidget<Button>("save")->setVisible(false);
|
||||||
|
} // onNewGPWithName
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void GrandPrixCutscene::eventCallback(GUIEngine::Widget* widget,
|
||||||
|
const std::string& name,
|
||||||
|
const int playerID)
|
||||||
|
{
|
||||||
|
if (name == "continue")
|
||||||
|
{
|
||||||
|
((CutsceneWorld*)World::getWorld())->abortCutscene();
|
||||||
|
}
|
||||||
|
else if (name == "save")
|
||||||
|
{
|
||||||
|
new EnterGPNameDialog(this, 0.5f, 0.4f);
|
||||||
|
}
|
||||||
|
} // eventCallback
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool GrandPrixCutscene::onEscapePressed()
|
||||||
|
{
|
||||||
|
((CutsceneWorld*)World::getWorld())->abortCutscene();
|
||||||
|
return false;
|
||||||
|
} // onEscapePressed
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void GrandPrixCutscene::tearDown()
|
||||||
|
{
|
||||||
|
Screen::tearDown();
|
||||||
|
} // tearDown
|
||||||
|
|
48
src/states_screens/grand_prix_cutscene.hpp
Normal file
48
src/states_screens/grand_prix_cutscene.hpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
// SuperTuxKart - a fun racing game with go-kart
|
||||||
|
// Copyright (C) 2014 konstin
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#ifndef HEADER_GRAND_PRIX_CUTSCENE_HPP
|
||||||
|
#define HEADER_GRAND_PRIX_CUTSCENE_HPP
|
||||||
|
|
||||||
|
#include "guiengine/screen.hpp"
|
||||||
|
#include "guiengine/widgets/button_widget.hpp"
|
||||||
|
#include "race/race_manager.hpp"
|
||||||
|
#include "states_screens/dialogs/enter_gp_name_dialog.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class GrandPrixCutscene: public GUIEngine::CutsceneScreen,
|
||||||
|
public EnterGPNameDialog::INewGPListener
|
||||||
|
{
|
||||||
|
friend class GUIEngine::ScreenSingleton<GrandPrixCutscene>;
|
||||||
|
public:
|
||||||
|
GrandPrixCutscene(const char * filename) : CutsceneScreen(filename) {}
|
||||||
|
protected:
|
||||||
|
void saveGPButton();
|
||||||
|
|
||||||
|
/** implement callback from INewGPListener */
|
||||||
|
void onNewGPWithName(const irr::core::stringw& name);
|
||||||
|
|
||||||
|
// implement callbacks from parent class GUIEngine::Screen
|
||||||
|
void eventCallback(GUIEngine::Widget* widget,
|
||||||
|
const std::string& name,
|
||||||
|
const int playerID) OVERRIDE;
|
||||||
|
bool onEscapePressed() OVERRIDE;
|
||||||
|
void tearDown() OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -18,8 +18,8 @@
|
|||||||
#ifndef HEADER_GRAND_PRIX_EDITOR_SCREEN_HPP
|
#ifndef HEADER_GRAND_PRIX_EDITOR_SCREEN_HPP
|
||||||
#define HEADER_GRAND_PRIX_EDITOR_SCREEN_HPP
|
#define HEADER_GRAND_PRIX_EDITOR_SCREEN_HPP
|
||||||
|
|
||||||
#include "dialogs/enter_gp_name_dialog.hpp"
|
|
||||||
#include "guiengine/screen.hpp"
|
#include "guiengine/screen.hpp"
|
||||||
|
#include "states_screens/dialogs/enter_gp_name_dialog.hpp"
|
||||||
#include "states_screens/dialogs/message_dialog.hpp"
|
#include "states_screens/dialogs/message_dialog.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "graphics/irr_driver.hpp"
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "guiengine/engine.hpp"
|
#include "guiengine/engine.hpp"
|
||||||
#include "guiengine/scalable_font.hpp"
|
#include "guiengine/scalable_font.hpp"
|
||||||
|
#include "guiengine/widgets/button_widget.hpp"
|
||||||
#include "guiengine/widgets/label_widget.hpp"
|
#include "guiengine/widgets/label_widget.hpp"
|
||||||
#include "io/file_manager.hpp"
|
#include "io/file_manager.hpp"
|
||||||
#include "items/item_manager.hpp"
|
#include "items/item_manager.hpp"
|
||||||
@ -34,6 +35,7 @@
|
|||||||
#include "modes/cutscene_world.hpp"
|
#include "modes/cutscene_world.hpp"
|
||||||
#include "modes/overworld.hpp"
|
#include "modes/overworld.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
|
#include "race/race_manager.hpp"
|
||||||
#include "states_screens/feature_unlocked.hpp"
|
#include "states_screens/feature_unlocked.hpp"
|
||||||
#include "states_screens/main_menu_screen.hpp"
|
#include "states_screens/main_menu_screen.hpp"
|
||||||
#include "states_screens/state_manager.hpp"
|
#include "states_screens/state_manager.hpp"
|
||||||
@ -47,7 +49,6 @@
|
|||||||
#include <ICameraSceneNode.h>
|
#include <ICameraSceneNode.h>
|
||||||
#include <ILightSceneNode.h>
|
#include <ILightSceneNode.h>
|
||||||
#include <IMeshSceneNode.h>
|
#include <IMeshSceneNode.h>
|
||||||
//#include <iostream>
|
|
||||||
|
|
||||||
using namespace irr::core;
|
using namespace irr::core;
|
||||||
using namespace irr::gui;
|
using namespace irr::gui;
|
||||||
@ -82,42 +83,20 @@ DEFINE_SCREEN_SINGLETON( GrandPrixLose );
|
|||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
GrandPrixLose::GrandPrixLose() : CutsceneScreen("grand_prix_lose.stkgui")
|
|
||||||
{
|
|
||||||
} // GrandPrixLose
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void GrandPrixLose::onCutsceneEnd()
|
void GrandPrixLose::onCutsceneEnd()
|
||||||
{
|
{
|
||||||
TrackObjectManager* tobjman = World::getWorld()->getTrack()->getTrackObjectManager();
|
for (int i = 0; i < 4; i++)
|
||||||
if (m_kart_node[0] != NULL)
|
{
|
||||||
m_kart_node[0]->getPresentation<TrackObjectPresentationSceneNode>()->getNode()->remove();
|
if (m_kart_node[i] != NULL)
|
||||||
if (m_kart_node[1] != NULL)
|
m_kart_node[i]->getPresentation<TrackObjectPresentationSceneNode>()->getNode()->remove();
|
||||||
m_kart_node[1]->getPresentation<TrackObjectPresentationSceneNode>()->getNode()->remove();
|
m_kart_node[i] = NULL;
|
||||||
if (m_kart_node[2] != NULL)
|
}
|
||||||
m_kart_node[2]->getPresentation<TrackObjectPresentationSceneNode>()->getNode()->remove();
|
|
||||||
if (m_kart_node[3] != NULL)
|
|
||||||
m_kart_node[3]->getPresentation<TrackObjectPresentationSceneNode>()->getNode()->remove();
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i<m_all_kart_models.size(); i++)
|
for (unsigned int i = 0; i<m_all_kart_models.size(); i++)
|
||||||
delete m_all_kart_models[i];
|
delete m_all_kart_models[i];
|
||||||
|
|
||||||
m_all_kart_models.clear();
|
m_all_kart_models.clear();
|
||||||
|
} // onCutsceneEnd
|
||||||
m_kart_node[0] = NULL;
|
|
||||||
m_kart_node[1] = NULL;
|
|
||||||
m_kart_node[2] = NULL;
|
|
||||||
m_kart_node[3] = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
bool GrandPrixLose::onEscapePressed()
|
|
||||||
{
|
|
||||||
((CutsceneWorld*)World::getWorld())->abortCutscene();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -142,19 +121,14 @@ void GrandPrixLose::init()
|
|||||||
|
|
||||||
World::getWorld()->setPhase(WorldStatus::RACE_PHASE);
|
World::getWorld()->setPhase(WorldStatus::RACE_PHASE);
|
||||||
|
|
||||||
|
saveGPButton();
|
||||||
|
|
||||||
m_phase = 1;
|
m_phase = 1;
|
||||||
m_global_time = 0.0f;
|
m_global_time = 0.0f;
|
||||||
} // init
|
} // init
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
void GrandPrixLose::tearDown()
|
|
||||||
{
|
|
||||||
Screen::tearDown();
|
|
||||||
} // tearDown
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void GrandPrixLose::onUpdate(float dt)
|
void GrandPrixLose::onUpdate(float dt)
|
||||||
{
|
{
|
||||||
m_global_time += dt;
|
m_global_time += dt;
|
||||||
@ -194,27 +168,13 @@ void GrandPrixLose::onUpdate(float dt)
|
|||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
void GrandPrixLose::eventCallback(GUIEngine::Widget* widget,
|
|
||||||
const std::string& name,
|
|
||||||
const int playerID)
|
|
||||||
{
|
|
||||||
if (name == "continue")
|
|
||||||
{
|
|
||||||
((CutsceneWorld*)World::getWorld())->abortCutscene();
|
|
||||||
}
|
|
||||||
} // eventCallback
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void GrandPrixLose::setKarts(std::vector<std::string> ident_arg)
|
void GrandPrixLose::setKarts(std::vector<std::string> ident_arg)
|
||||||
{
|
{
|
||||||
TrackObjectManager* tobjman = World::getWorld()->getTrack()->getTrackObjectManager();
|
TrackObjectManager* tobjman = World::getWorld()->getTrack()->getTrackObjectManager();
|
||||||
|
|
||||||
assert(ident_arg.size() > 0);
|
assert(ident_arg.size() > 0);
|
||||||
if ((int)ident_arg.size() > MAX_KART_COUNT)
|
if ((int)ident_arg.size() > MAX_KART_COUNT)
|
||||||
{
|
|
||||||
ident_arg.resize(MAX_KART_COUNT);
|
ident_arg.resize(MAX_KART_COUNT);
|
||||||
}
|
|
||||||
|
|
||||||
// (there is at least one kart so kart node 0 is sure to be set)
|
// (there is at least one kart so kart node 0 is sure to be set)
|
||||||
m_kart_node[1] = NULL;
|
m_kart_node[1] = NULL;
|
||||||
@ -252,7 +212,8 @@ void GrandPrixLose::setKarts(std::vector<std::string> ident_arg)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log::warn("GrandPrixLose", "Could not find a kart named '%s'.", ident_arg[n].c_str());
|
Log::warn("GrandPrixLose", "A kart named '%s' could not be found\n",
|
||||||
|
ident_arg[n].c_str());
|
||||||
m_kart_node[n] = NULL;
|
m_kart_node[n] = NULL;
|
||||||
} // if kart != NULL
|
} // if kart != NULL
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "guiengine/screen.hpp"
|
#include "guiengine/screen.hpp"
|
||||||
#include "karts/kart_model.hpp"
|
#include "karts/kart_model.hpp"
|
||||||
|
#include "states_screens/grand_prix_cutscene.hpp"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -33,11 +34,13 @@ class TrackObject;
|
|||||||
* \brief Screen shown at the end of a Grand Prix
|
* \brief Screen shown at the end of a Grand Prix
|
||||||
* \ingroup states_screens
|
* \ingroup states_screens
|
||||||
*/
|
*/
|
||||||
class GrandPrixLose : public GUIEngine::CutsceneScreen, public GUIEngine::ScreenSingleton<GrandPrixLose>
|
class GrandPrixLose :
|
||||||
|
public GrandPrixCutscene,
|
||||||
|
public GUIEngine::ScreenSingleton<GrandPrixLose>
|
||||||
{
|
{
|
||||||
friend class GUIEngine::ScreenSingleton<GrandPrixLose>;
|
friend class GUIEngine::ScreenSingleton<GrandPrixLose>;
|
||||||
|
|
||||||
GrandPrixLose();
|
GrandPrixLose(): GrandPrixCutscene("grand_prix_lose.stkgui") {};
|
||||||
|
|
||||||
/** Global evolution of time */
|
/** Global evolution of time */
|
||||||
float m_global_time;
|
float m_global_time;
|
||||||
@ -52,27 +55,11 @@ class GrandPrixLose : public GUIEngine::CutsceneScreen, public GUIEngine::Screen
|
|||||||
float m_kart_x, m_kart_y, m_kart_z;
|
float m_kart_x, m_kart_y, m_kart_z;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// implement callbacks from parent class GUIEngine::Screen
|
||||||
virtual void onCutsceneEnd() OVERRIDE;
|
|
||||||
|
|
||||||
virtual bool onEscapePressed() OVERRIDE;
|
|
||||||
|
|
||||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
|
||||||
virtual void loadedFromFile() OVERRIDE;
|
|
||||||
|
|
||||||
/** \brief implement optional callback from parent class GUIEngine::Screen */
|
|
||||||
void onUpdate(float dt) OVERRIDE;
|
|
||||||
|
|
||||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
|
||||||
void init() OVERRIDE;
|
void init() OVERRIDE;
|
||||||
|
void loadedFromFile() OVERRIDE;
|
||||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
void onCutsceneEnd() OVERRIDE;
|
||||||
void tearDown() OVERRIDE;
|
void onUpdate(float dt) OVERRIDE;
|
||||||
|
|
||||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
|
||||||
void eventCallback(GUIEngine::Widget* widget, const std::string& name,
|
|
||||||
const int playerID) OVERRIDE;
|
|
||||||
|
|
||||||
/** \brief set which karts lost this GP */
|
/** \brief set which karts lost this GP */
|
||||||
void setKarts(std::vector<std::string> ident);
|
void setKarts(std::vector<std::string> ident);
|
||||||
};
|
};
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "graphics/irr_driver.hpp"
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "guiengine/engine.hpp"
|
#include "guiengine/engine.hpp"
|
||||||
#include "guiengine/scalable_font.hpp"
|
#include "guiengine/scalable_font.hpp"
|
||||||
|
#include "guiengine/widgets/button_widget.hpp"
|
||||||
#include "guiengine/widgets/label_widget.hpp"
|
#include "guiengine/widgets/label_widget.hpp"
|
||||||
#include "io/file_manager.hpp"
|
#include "io/file_manager.hpp"
|
||||||
#include "items/item_manager.hpp"
|
#include "items/item_manager.hpp"
|
||||||
@ -35,6 +36,7 @@
|
|||||||
#include "karts/kart_properties_manager.hpp"
|
#include "karts/kart_properties_manager.hpp"
|
||||||
#include "modes/cutscene_world.hpp"
|
#include "modes/cutscene_world.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
|
#include "race/race_manager.hpp"
|
||||||
#include "states_screens/feature_unlocked.hpp"
|
#include "states_screens/feature_unlocked.hpp"
|
||||||
#include "states_screens/state_manager.hpp"
|
#include "states_screens/state_manager.hpp"
|
||||||
#include "tracks/track.hpp"
|
#include "tracks/track.hpp"
|
||||||
@ -66,26 +68,17 @@ DEFINE_SCREEN_SINGLETON( GrandPrixWin );
|
|||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
GrandPrixWin::GrandPrixWin() : CutsceneScreen("grand_prix_win.stkgui")
|
GrandPrixWin::GrandPrixWin() : GrandPrixCutscene("grand_prix_win.stkgui")
|
||||||
{
|
{
|
||||||
m_kart_node[0] = NULL;
|
for (int i = 0; i < 3; i++)
|
||||||
m_kart_node[1] = NULL;
|
{
|
||||||
m_kart_node[2] = NULL;
|
m_kart_node[i] = NULL;
|
||||||
|
m_podium_steps[i] = NULL;
|
||||||
m_podium_steps[0] = NULL;
|
}
|
||||||
m_podium_steps[1] = NULL;
|
|
||||||
m_podium_steps[2] = NULL;
|
|
||||||
|
|
||||||
} // GrandPrixWin
|
} // GrandPrixWin
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
GrandPrixWin::~GrandPrixWin()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void GrandPrixWin::onCutsceneEnd()
|
void GrandPrixWin::onCutsceneEnd()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i<m_all_kart_models.size(); i++)
|
for (unsigned int i = 0; i<m_all_kart_models.size(); i++)
|
||||||
@ -99,31 +92,17 @@ void GrandPrixWin::onCutsceneEnd()
|
|||||||
m_unlocked_label = NULL;
|
m_unlocked_label = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackObjectManager* tobjman = World::getWorld()->getTrack()->getTrackObjectManager();
|
for (int i = 0; i < 3; i++)
|
||||||
if (m_kart_node[0] != NULL)
|
{
|
||||||
m_kart_node[0]->getPresentation<TrackObjectPresentationSceneNode>()->getNode()->remove();
|
if (m_kart_node[i] != NULL)
|
||||||
if (m_kart_node[1] != NULL)
|
m_kart_node[i]->getPresentation<TrackObjectPresentationSceneNode>()->getNode()->remove();
|
||||||
m_kart_node[1]->getPresentation<TrackObjectPresentationSceneNode>()->getNode()->remove();
|
m_kart_node[i] = NULL;
|
||||||
if (m_kart_node[2] != NULL)
|
m_podium_steps[i] = NULL;
|
||||||
m_kart_node[2]->getPresentation<TrackObjectPresentationSceneNode>()->getNode()->remove();
|
}
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
void GrandPrixWin::loadedFromFile()
|
|
||||||
{
|
|
||||||
} // loadedFromFile
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void GrandPrixWin::init()
|
void GrandPrixWin::init()
|
||||||
{
|
{
|
||||||
std::vector<std::string> parts;
|
std::vector<std::string> parts;
|
||||||
@ -136,6 +115,7 @@ void GrandPrixWin::init()
|
|||||||
World::getWorld()->setPhase(WorldStatus::RACE_PHASE);
|
World::getWorld()->setPhase(WorldStatus::RACE_PHASE);
|
||||||
|
|
||||||
|
|
||||||
|
saveGPButton();
|
||||||
if (PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges().size() > 0)
|
if (PlayerManager::getCurrentPlayer()->getRecentlyCompletedChallenges().size() > 0)
|
||||||
{
|
{
|
||||||
const core::dimension2d<u32>& frame_size = GUIEngine::getDriver()->getCurrentRenderTargetSize();
|
const core::dimension2d<u32>& frame_size = GUIEngine::getDriver()->getCurrentRenderTargetSize();
|
||||||
@ -195,21 +175,6 @@ void GrandPrixWin::init()
|
|||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
bool GrandPrixWin::onEscapePressed()
|
|
||||||
{
|
|
||||||
((CutsceneWorld*)World::getWorld())->abortCutscene();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void GrandPrixWin::tearDown()
|
|
||||||
{
|
|
||||||
Screen::tearDown();
|
|
||||||
} // tearDown
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void GrandPrixWin::onUpdate(float dt)
|
void GrandPrixWin::onUpdate(float dt)
|
||||||
{
|
{
|
||||||
m_global_time += dt;
|
m_global_time += dt;
|
||||||
@ -228,17 +193,11 @@ void GrandPrixWin::onUpdate(float dt)
|
|||||||
if (fabsf(m_kart_z[k] - KARTS_DEST_Z) > dt)
|
if (fabsf(m_kart_z[k] - KARTS_DEST_Z) > dt)
|
||||||
{
|
{
|
||||||
if (m_kart_z[k] < KARTS_DEST_Z - dt)
|
if (m_kart_z[k] < KARTS_DEST_Z - dt)
|
||||||
{
|
|
||||||
m_kart_z[k] += dt;
|
m_kart_z[k] += dt;
|
||||||
}
|
|
||||||
else if (m_kart_z[k] > KARTS_DEST_Z + dt)
|
else if (m_kart_z[k] > KARTS_DEST_Z + dt)
|
||||||
{
|
|
||||||
m_kart_z[k] -= dt;
|
m_kart_z[k] -= dt;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
m_kart_z[k] = KARTS_DEST_Z;
|
m_kart_z[k] = KARTS_DEST_Z;
|
||||||
}
|
|
||||||
karts_not_yet_done++;
|
karts_not_yet_done++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,9 +209,7 @@ void GrandPrixWin::onUpdate(float dt)
|
|||||||
} // end for
|
} // end for
|
||||||
|
|
||||||
if (karts_not_yet_done == 0)
|
if (karts_not_yet_done == 0)
|
||||||
{
|
|
||||||
m_phase = 2;
|
m_phase = 2;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- Karts Rotate
|
// ---- Karts Rotate
|
||||||
@ -281,7 +238,8 @@ void GrandPrixWin::onUpdate(float dt)
|
|||||||
}
|
}
|
||||||
} // end for
|
} // end for
|
||||||
|
|
||||||
if (karts_not_yet_done == 0) m_phase = 3;
|
if (karts_not_yet_done == 0)
|
||||||
|
m_phase = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- Podium Rises
|
// ---- Podium Rises
|
||||||
@ -308,7 +266,6 @@ void GrandPrixWin::onUpdate(float dt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // end for
|
} // end for
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -325,17 +282,6 @@ void GrandPrixWin::onUpdate(float dt)
|
|||||||
true/* center h */, true /* center v */ );
|
true/* center h */, true /* center v */ );
|
||||||
} // onUpdate
|
} // onUpdate
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void GrandPrixWin::eventCallback(GUIEngine::Widget* widget,
|
|
||||||
const std::string& name,
|
|
||||||
const int playerID)
|
|
||||||
{
|
|
||||||
if (name == "continue")
|
|
||||||
{
|
|
||||||
((CutsceneWorld*)World::getWorld())->abortCutscene();
|
|
||||||
}
|
|
||||||
} // eventCallback
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -385,17 +331,11 @@ void GrandPrixWin::setKarts(const std::string idents_arg[3])
|
|||||||
if (meshPresentation != NULL)
|
if (meshPresentation != NULL)
|
||||||
{
|
{
|
||||||
if (meshPresentation->getModelFile() == "gpwin_podium1.b3d")
|
if (meshPresentation->getModelFile() == "gpwin_podium1.b3d")
|
||||||
{
|
|
||||||
m_podium_steps[0] = currObj;
|
m_podium_steps[0] = currObj;
|
||||||
}
|
|
||||||
else if (meshPresentation->getModelFile() == "gpwin_podium2.b3d")
|
else if (meshPresentation->getModelFile() == "gpwin_podium2.b3d")
|
||||||
{
|
|
||||||
m_podium_steps[1] = currObj;
|
m_podium_steps[1] = currObj;
|
||||||
}
|
|
||||||
else if (meshPresentation->getModelFile() == "gpwin_podium3.b3d")
|
else if (meshPresentation->getModelFile() == "gpwin_podium3.b3d")
|
||||||
{
|
|
||||||
m_podium_steps[2] = currObj;
|
m_podium_steps[2] = currObj;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "audio/sfx_base.hpp"
|
#include "audio/sfx_base.hpp"
|
||||||
#include "guiengine/screen.hpp"
|
#include "guiengine/screen.hpp"
|
||||||
#include "karts/kart_model.hpp"
|
#include "karts/kart_model.hpp"
|
||||||
|
#include "states_screens/grand_prix_cutscene.hpp"
|
||||||
|
|
||||||
namespace irr { namespace scene { class ISceneNode; class ICameraSceneNode; class ILightSceneNode; class IMeshSceneNode; } }
|
namespace irr { namespace scene { class ISceneNode; class ICameraSceneNode; class ILightSceneNode; class IMeshSceneNode; } }
|
||||||
namespace GUIEngine { class LabelWidget; }
|
namespace GUIEngine { class LabelWidget; }
|
||||||
@ -32,13 +33,15 @@ class TrackObject;
|
|||||||
* \brief Screen shown at the end of a Grand Prix
|
* \brief Screen shown at the end of a Grand Prix
|
||||||
* \ingroup states_screens
|
* \ingroup states_screens
|
||||||
*/
|
*/
|
||||||
class GrandPrixWin : public GUIEngine::CutsceneScreen, public GUIEngine::ScreenSingleton<GrandPrixWin>
|
class GrandPrixWin :
|
||||||
|
public GrandPrixCutscene,
|
||||||
|
public GUIEngine::ScreenSingleton<GrandPrixWin>
|
||||||
{
|
{
|
||||||
friend class GUIEngine::ScreenSingleton<GrandPrixWin>;
|
friend class GUIEngine::ScreenSingleton<GrandPrixWin>;
|
||||||
|
|
||||||
GrandPrixWin();
|
GrandPrixWin();
|
||||||
|
|
||||||
virtual ~GrandPrixWin();
|
virtual ~GrandPrixWin() {};
|
||||||
|
|
||||||
/** Global evolution of time */
|
/** Global evolution of time */
|
||||||
double m_global_time;
|
double m_global_time;
|
||||||
@ -47,9 +50,6 @@ class GrandPrixWin : public GUIEngine::CutsceneScreen, public GUIEngine::ScreenS
|
|||||||
|
|
||||||
TrackObject* m_kart_node[3];
|
TrackObject* m_kart_node[3];
|
||||||
|
|
||||||
//irr::scene::IMeshSceneNode* m_podium_step[3];
|
|
||||||
//irr::scene::ISceneNode* m_kart_node[3];
|
|
||||||
|
|
||||||
/** A copy of the kart model for each kart used. */
|
/** A copy of the kart model for each kart used. */
|
||||||
std::vector<KartModel*> m_all_kart_models;
|
std::vector<KartModel*> m_all_kart_models;
|
||||||
|
|
||||||
@ -58,30 +58,14 @@ class GrandPrixWin : public GUIEngine::CutsceneScreen, public GUIEngine::ScreenS
|
|||||||
int m_phase;
|
int m_phase;
|
||||||
|
|
||||||
float m_kart_x[3], m_kart_y[3], m_kart_z[3];
|
float m_kart_x[3], m_kart_y[3], m_kart_z[3];
|
||||||
//float m_podium_x[3], m_podium_z[3];
|
|
||||||
float m_kart_rotation[3];
|
float m_kart_rotation[3];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// implement callbacks from parent class GUIEngine::Screen
|
||||||
virtual void onCutsceneEnd() OVERRIDE;
|
|
||||||
|
|
||||||
virtual bool onEscapePressed() OVERRIDE;
|
|
||||||
|
|
||||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
|
||||||
virtual void loadedFromFile() OVERRIDE;
|
|
||||||
|
|
||||||
/** \brief implement optional callback from parent class GUIEngine::Screen */
|
|
||||||
void onUpdate(float dt) OVERRIDE;
|
|
||||||
|
|
||||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
|
||||||
void init() OVERRIDE;
|
void init() OVERRIDE;
|
||||||
|
void loadedFromFile() OVERRIDE {};
|
||||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
void onCutsceneEnd() OVERRIDE;
|
||||||
void tearDown() OVERRIDE;
|
void onUpdate(float dt) OVERRIDE;
|
||||||
|
|
||||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
|
||||||
void eventCallback(GUIEngine::Widget* widget, const std::string& name,
|
|
||||||
const int playerID) OVERRIDE;
|
|
||||||
|
|
||||||
/** \pre must be called after pushing the screen, but before onUpdate had the chance to be invoked */
|
/** \pre must be called after pushing the screen, but before onUpdate had the chance to be invoked */
|
||||||
void setKarts(const std::string idents[3]);
|
void setKarts(const std::string idents[3]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user