diff --git a/data/gui/grand_prix_lose.stkgui b/data/gui/grand_prix_lose.stkgui index 743196dae..e08bb49f4 100644 --- a/data/gui/grand_prix_lose.stkgui +++ b/data/gui/grand_prix_lose.stkgui @@ -1,7 +1,8 @@ -
- -
diff --git a/data/gui/grand_prix_win.stkgui b/data/gui/grand_prix_win.stkgui index 743196dae..05d24c048 100644 --- a/data/gui/grand_prix_win.stkgui +++ b/data/gui/grand_prix_win.stkgui @@ -1,7 +1,9 @@ -
- -
+ diff --git a/src/guiengine/engine.hpp b/src/guiengine/engine.hpp index 5dcfce20d..9669503c7 100644 --- a/src/guiengine/engine.hpp +++ b/src/guiengine/engine.hpp @@ -170,7 +170,7 @@ namespace GUIEngine inline Skin* getSkin() { return Private::g_skin; } Screen* getScreenNamed(const char* name); - + /** \return the height of the title font in pixels */ int getTitleFontHeight(); diff --git a/src/guiengine/widgets/button_widget.cpp b/src/guiengine/widgets/button_widget.cpp index feb18af83..01016b2be 100644 --- a/src/guiengine/widgets/button_widget.cpp +++ b/src/guiengine/widgets/button_widget.cpp @@ -43,6 +43,8 @@ void ButtonWidget::add() m_id = m_element->getID(); m_element->setTabOrder(m_id); m_element->setTabGroup(false); + if (!m_is_visible) + m_element->setVisible(false); } // ----------------------------------------------------------------------------- diff --git a/src/race/grand_prix_manager.hpp b/src/race/grand_prix_manager.hpp index d4800204a..5eabbb719 100644 --- a/src/race/grand_prix_manager.hpp +++ b/src/race/grand_prix_manager.hpp @@ -45,8 +45,6 @@ private: /** Generates a new unique indentifier for a user defined grand prix */ std::string generateId(); - bool existsName(const irr::core::stringw& name) const; - public: GrandPrixManager(); ~GrandPrixManager(); @@ -54,6 +52,7 @@ public: GrandPrixData* getGrandPrix(const int i) const { return m_gp_data[i]; } GrandPrixData* getGrandPrix(const std::string& s) const; unsigned int getNumberOfGrandPrix() const { return m_gp_data.size(); } + bool existsName(const irr::core::stringw& name) const; void checkConsistency(); // Methods for the gp editor diff --git a/src/race/race_manager.cpp b/src/race/race_manager.cpp index 2626530b4..92e4e29fc 100644 --- a/src/race/race_manager.cpp +++ b/src/race/race_manager.cpp @@ -46,6 +46,7 @@ #include "network/protocol_manager.hpp" #include "network/network_world.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_win.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 (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); GrandPrixWin* scene = GrandPrixWin::getInstance(); StateManager::get()->pushScreen(scene); @@ -695,14 +697,6 @@ void RaceManager::exitRace(bool delete_world) } 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); GrandPrixLose* scene = GrandPrixLose::getInstance(); StateManager::get()->pushScreen(scene); @@ -713,7 +707,8 @@ void RaceManager::exitRace(bool delete_world) } 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 karts; karts.push_back(UserConfigParams::m_default_kart); scene->setKarts(karts); diff --git a/src/states_screens/dialogs/enter_gp_name_dialog.cpp b/src/states_screens/dialogs/enter_gp_name_dialog.cpp index e75c64abc..7d68bf09b 100644 --- a/src/states_screens/dialogs/enter_gp_name_dialog.cpp +++ b/src/states_screens/dialogs/enter_gp_name_dialog.cpp @@ -84,17 +84,13 @@ void EnterGPNameDialog::onEnterPressedInternal() if (name.size() > 0 && name != "Random Grand Prix") { // 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); - if (gp->getName() == name) - { - LabelWidget* label = getWidget("title"); - assert(label != NULL); - label->setText(_("Another grand prix with this name already exists."), false); - sfx_manager->quickSound("anvil"); - return; - } + LabelWidget* label = getWidget("title"); + assert(label != NULL); + 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 diff --git a/src/states_screens/grand_prix_cutscene.cpp b/src/states_screens/grand_prix_cutscene.cpp new file mode 100644 index 000000000..850852aec --- /dev/null +++ b/src/states_screens/grand_prix_cutscene.cpp @@ -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 +#include + +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