diff --git a/sources.cmake b/sources.cmake index ddc029d4f..f484b15d5 100644 --- a/sources.cmake +++ b/sources.cmake @@ -1,5 +1,5 @@ # Modify this file to change the last-modified date when you add/remove a file. -# This will then trigger a new cmake run automatically. +# This will then trigger a new cmake run automatically. file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp") file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp") file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*") diff --git a/src/race/grand_prix_data.cpp b/src/race/grand_prix_data.cpp index 7ff76b590..32faafa9b 100644 --- a/src/race/grand_prix_data.cpp +++ b/src/race/grand_prix_data.cpp @@ -24,7 +24,6 @@ #include "config/player_manager.hpp" #include "io/file_manager.hpp" #include "io/utf_writer.hpp" -#include "states_screens/dialogs/random_gp_dialog.hpp" #include "tracks/track_manager.hpp" #include "tracks/track.hpp" #include "utils/string_utils.hpp" diff --git a/src/states_screens/dialogs/random_gp_dialog.cpp b/src/states_screens/dialogs/random_gp_dialog.cpp deleted file mode 100644 index 690afda1d..000000000 --- a/src/states_screens/dialogs/random_gp_dialog.cpp +++ /dev/null @@ -1,196 +0,0 @@ -// 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/engine.hpp" -#include "guiengine/widgets/icon_button_widget.hpp" -#include "guiengine/widgets/spinner_widget.hpp" -#include "race/grand_prix_manager.hpp" -#include "race/race_manager.hpp" -#include "states_screens/dialogs/random_gp_dialog.hpp" -#include "tracks/track_manager.hpp" - -#include -#include - -using irr::core::stringc; -using irr::core::stringw; -using irr::gui::IGUIStaticText; - -typedef GUIEngine::SpinnerWidget Spinner; - -RandomGPInfoDialog::RandomGPInfoDialog() -{ - // Defaults - loading selection from last time frrom a file would be better - m_number_of_tracks = 2; // We can assume that there are at least 2 standard tracks - m_trackgroup = "standard"; - m_use_reverse = GrandPrixData::GP_NO_REVERSE; - - doInit(); - m_curr_time = 0.0f; - - m_under_title = m_area.getHeight()/7; - m_over_body = m_area.getHeight()/7 + SPINNER_HEIGHT + 10; // 10px space - m_lower_bound = m_area.getHeight()*6/7; - - m_gp.createRandomGP(m_number_of_tracks, m_trackgroup, m_use_reverse); - - addTitle(); - addSpinners(); - addTracks(); - addScreenshot(); - addButtons(); - addRestartButton(); -} - -// ---------------------------------------------------------------------------- - -void RandomGPInfoDialog::addSpinners() -{ - const int laps_width = 150; - // "20*4" because there a 4 separators between the spinners with 20px each - int label_spinner_width = m_area.getWidth() - laps_width - 20*4; - // This scaling ensures that the spinners are smaller than the available - // area, look well and are (hopefully) big enough for their labels - if (m_area.getWidth() < 700) - label_spinner_width /= 2; - else if (m_area.getWidth() < 1500) - label_spinner_width /= 3; - else - label_spinner_width /= 4; - const int left = (m_area.getWidth() - label_spinner_width*2 - laps_width)/2; - - // Trackgroup chooser - Spinner* spinner = new Spinner(false); - spinner->m_properties[GUIEngine::PROP_ID] = "Trackgroup"; - spinner->m_properties[GUIEngine::PROP_WRAP_AROUND] = "true"; - spinner->setParent(m_irrlicht_window); - m_widgets.push_back(spinner); - spinner->add(); - spinner->move(left, m_under_title, label_spinner_width, SPINNER_HEIGHT); - // Fill it with all the track group names - spinner->addLabel("all"); - int index_standard; - const std::vector& groups = track_manager->getAllTrackGroups(); - for (unsigned int i = 0; i < groups.size(); i++) - { - spinner->addLabel(stringw(groups[i].c_str())); - if(groups[i] == "standard") - index_standard = i+1; - } - // The value can only be set here because SpinnerWidget resets the value - // every time a label is added - spinner->setValue(index_standard); - - // Number of laps chooser - spinner = new Spinner(false); - spinner->setValue(m_number_of_tracks); - spinner->setMin(1); - spinner->setMax(track_manager->getTracksInGroup("standard").size()); - spinner->setParent(m_irrlicht_window); - spinner->m_properties[GUIEngine::PROP_ID] = "Number of tracks"; - spinner->m_properties[GUIEngine::PROP_WRAP_AROUND] = "true"; - m_widgets.push_back(spinner); - spinner->add(); - spinner->move(left + label_spinner_width + 20/2, m_under_title, laps_width, SPINNER_HEIGHT); - - // reverse choose - spinner = new Spinner(false); - spinner->setParent(m_irrlicht_window); - spinner->m_properties[GUIEngine::PROP_ID] = "reverse"; - spinner->m_properties[GUIEngine::PROP_WRAP_AROUND] = "true"; - m_widgets.push_back(spinner); - spinner->add(); - spinner->move(left + label_spinner_width + laps_width + 20/2, m_under_title, label_spinner_width, SPINNER_HEIGHT); - spinner->addLabel("no reverse"); - spinner->addLabel("all reverse"); - spinner->addLabel("mixed"); -} - -// ---------------------------------------------------------------------------- - -void RandomGPInfoDialog::addRestartButton() -{ - GUIEngine::IconButtonWidget* button = new GUIEngine::IconButtonWidget(); - button->setImage("gui/restart.png"); - button->setParent(m_irrlicht_window); - button->m_properties[GUIEngine::PROP_ID] = "reload"; - m_widgets.push_back(button); - button->add(); - button->move(m_area.getWidth() - 20 - 32, 20, 32, 32); -} - -// ---------------------------------------------------------------------------- - -GUIEngine::EventPropagation RandomGPInfoDialog::processEvent( - const std::string& eventSource) -{ - if (eventSource == "start") - { - // Save GP data, since dismiss will delete this object. - GrandPrixData gp = m_gp; - ModalDialog::dismiss(); - race_manager->startGP(gp, false, false); - return GUIEngine::EVENT_BLOCK; - } - else if (eventSource == "Number of tracks") - { - // The old gp can be reused because there's only track deletion/adding - m_number_of_tracks = getWidget("Number of tracks")->getValue(); - m_gp.changeTrackNumber(m_number_of_tracks, m_trackgroup); - addTracks(); - } - else if (eventSource == "Trackgroup") - { - Spinner* t = getWidget("Trackgroup"); - Spinner* s = getWidget("Number of tracks"); - - m_trackgroup = stringc(t->getStringValue()).c_str(); - - // Update the maximum for the number of tracks since it's depending on - // the current track. The current value in the Number-of-tracks-spinner - // has to be updated, since otherwise the displayed (and used) value - // can be bigger than the maximum. (Might be a TODO to fix this) - unsigned int max = (m_trackgroup == "all") ? - track_manager->getNumberOfTracks() : - track_manager->getTracksInGroup(m_trackgroup).size(); - m_number_of_tracks = std::min(max, m_number_of_tracks); - s->setMax(max); - if (s->getValue() > (signed)max) - s->setValue(max); - - // Create a new (i.e. with new tracks) random gp, since the old - // tracks might not all belong to the newly selected group. - m_gp.createRandomGP(m_number_of_tracks, m_trackgroup, m_use_reverse, - /*new_tracks*/true); - addTracks(); - } - else if (eventSource == "reverse") - { - Spinner* r = getWidget("reverse"); - m_use_reverse = static_cast(r->getValue()); - m_gp.changeReverse(m_use_reverse); - } - else if (eventSource == "reload") - { - m_gp.createRandomGP(m_number_of_tracks, m_trackgroup, m_use_reverse, - /*new_tracks*/true); - addTracks(); - } - - return GUIEngine::EVENT_LET; -} - diff --git a/src/states_screens/dialogs/random_gp_dialog.hpp b/src/states_screens/dialogs/random_gp_dialog.hpp deleted file mode 100644 index 35a058825..000000000 --- a/src/states_screens/dialogs/random_gp_dialog.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// 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_RANDOM_GP_INFO_DIALOG_HPP -#define HEADER_RANDOM_GP_INFO_DIALOG_HPP - -#include "states_screens/dialogs/gp_info_dialog.hpp" - -#include - -class RandomGPInfoDialog : public GPInfoDialog -{ -private: - /** How many tracks to pick. */ - unsigned int m_number_of_tracks; - - /** Name of the track group from which to pick tracks. */ - std::string m_trackgroup; - - /** How reverse settings should be determined. */ - GrandPrixData::GPReverseType m_use_reverse; - -public: - static const int SPINNER_HEIGHT = 40; - - RandomGPInfoDialog(); - - /** Adds a SpinnerWidgets to choose the track groups, one to choose the - * number of tracks and one to choose if the tracks should be raced in - * reverse. The Spinners are centered. */ - void addSpinners(); - void addRestartButton(); - - GUIEngine::EventPropagation processEvent(const std::string& eventSource); -}; - -#endif diff --git a/src/states_screens/tracks_screen.cpp b/src/states_screens/tracks_screen.cpp index 2491176c5..4d018feec 100644 --- a/src/states_screens/tracks_screen.cpp +++ b/src/states_screens/tracks_screen.cpp @@ -30,7 +30,6 @@ #include "states_screens/state_manager.hpp" #include "states_screens/track_info_screen.hpp" #include "states_screens/gp_info_screen.hpp" -#include "states_screens/dialogs/random_gp_dialog.hpp" #include "tracks/track.hpp" #include "tracks/track_manager.hpp" #include "utils/translation.hpp"