2007-05-27 12:01:53 -04:00
|
|
|
//
|
|
|
|
// SuperTuxKart - a fun racing game with go-kart
|
2013-11-15 06:43:21 -05:00
|
|
|
// Copyright (C) 2004-2013 Ingo Ruhnke <grumbel@gmx.de>
|
|
|
|
// Copyright (C) 2006-2013 Joerg Henrichs
|
2007-05-27 12:01:53 -04:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
2008-06-12 20:53:52 -04:00
|
|
|
// as published by the Free Software Foundation; either version 3
|
2007-05-27 12:01:53 -04:00
|
|
|
// 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.
|
|
|
|
|
2009-06-02 22:17:43 -04:00
|
|
|
#ifndef HEADER_GRAND_PRIX_DATA_HPP
|
|
|
|
#define HEADER_GRAND_PRIX_DATA_HPP
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2007-09-10 13:03:31 -04:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <cassert>
|
2009-08-30 14:21:59 -04:00
|
|
|
#include <irrString.h>
|
2010-02-15 19:33:41 -05:00
|
|
|
#include <stdexcept>
|
2007-09-10 13:03:31 -04:00
|
|
|
|
2011-06-16 21:46:30 -04:00
|
|
|
#include "utils/translation.hpp"
|
2014-03-20 21:13:05 -04:00
|
|
|
|
|
|
|
class Track;
|
2011-06-16 21:46:30 -04:00
|
|
|
|
2008-07-29 01:38:30 -04:00
|
|
|
/** Simple class that hold the data relevant to a 'grand_prix', aka. a number
|
2010-04-23 16:48:56 -04:00
|
|
|
* of races that has to be completed one after the other
|
|
|
|
* \ingroup race
|
|
|
|
*/
|
2008-07-29 01:38:30 -04:00
|
|
|
class GrandPrixData
|
2007-05-27 12:01:53 -04:00
|
|
|
{
|
2014-03-05 06:11:20 -05:00
|
|
|
private:
|
2012-11-25 17:59:34 -05:00
|
|
|
/** The name of the grand prix. */
|
|
|
|
irr::core::stringw m_name;
|
|
|
|
|
|
|
|
/** Internal name of the grand prix, not translated. */
|
|
|
|
std::string m_id;
|
|
|
|
|
|
|
|
/** Original filename, only for error handling needed. */
|
|
|
|
std::string m_filename;
|
2013-05-30 15:47:39 -04:00
|
|
|
|
2012-11-25 17:59:34 -05:00
|
|
|
/** The ident of the tracks in this grand prix in their right order, ident
|
2013-05-30 15:47:39 -04:00
|
|
|
* means the filename of the .track file without .track extension
|
2012-11-25 17:59:34 -05:00
|
|
|
* (ie. 'volcano'). */
|
2007-05-27 12:01:53 -04:00
|
|
|
std::vector<std::string> m_tracks;
|
2012-11-27 07:09:16 -05:00
|
|
|
|
2014-04-25 11:03:12 -04:00
|
|
|
/** The number of laps that each track will be raced, in the right order */
|
2007-12-06 15:57:42 -05:00
|
|
|
std::vector<int> m_laps;
|
2007-05-27 12:01:53 -04:00
|
|
|
|
2012-03-25 18:15:20 -04:00
|
|
|
/** Whether the track in question should be done in reverse mode */
|
|
|
|
std::vector<bool> m_reversed;
|
|
|
|
|
2014-03-20 21:13:05 -04:00
|
|
|
/** Wether the user can edit this grand prix or not */
|
|
|
|
bool m_editable;
|
|
|
|
|
2014-04-13 15:34:28 -04:00
|
|
|
/** In the last GP Fort Magma can not be used untill the final challenge.
|
|
|
|
* In order to provide still 5 tracks/GP, the last GP is only using 4
|
|
|
|
* tracks in story mode, but once nolok is unlocked Fort Magma becomes
|
|
|
|
* available (i.e. if nolok is unlocked, Fort Magma is available, otherwise
|
|
|
|
* not).
|
|
|
|
*/
|
|
|
|
bool isTrackAvailable(const std::string &id, bool includeLocked) const;
|
2014-03-20 21:13:05 -04:00
|
|
|
|
2007-09-10 13:03:31 -04:00
|
|
|
public:
|
2014-04-29 20:35:06 -04:00
|
|
|
#if (defined(WIN32) || defined(_WIN32)) && !defined(__MINGW32__)
|
|
|
|
# pragma warning(disable:4290)
|
|
|
|
#endif
|
2008-07-29 01:38:30 -04:00
|
|
|
/** Load the GrandPrixData from the given filename */
|
2014-04-25 11:03:12 -04:00
|
|
|
GrandPrixData(const std::string& filename);
|
|
|
|
/** Needed for simple creation of an instance of GrandPrixData */
|
|
|
|
GrandPrixData() {};
|
2014-05-18 09:27:57 -04:00
|
|
|
/** TODO */
|
|
|
|
GrandPrixData(const unsigned int number_of_tracks,
|
|
|
|
const std::string& m_track_group,
|
|
|
|
const bool use_reverse);
|
2014-03-05 06:11:20 -05:00
|
|
|
|
2014-04-25 11:03:12 -04:00
|
|
|
// Methods for the GP editor
|
2014-03-20 21:13:05 -04:00
|
|
|
void setId(const std::string& id);
|
|
|
|
void setName(const irr::core::stringw& name);
|
|
|
|
void setFilename(const std::string& filename);
|
|
|
|
void setEditable(const bool editable);
|
2014-04-25 11:03:12 -04:00
|
|
|
/** Load the grand prix from the file set by the constructor or the grand
|
|
|
|
* prix editor */
|
2014-03-20 21:13:05 -04:00
|
|
|
void reload();
|
|
|
|
bool writeToFile();
|
2013-05-30 15:47:39 -04:00
|
|
|
|
2014-04-25 11:03:12 -04:00
|
|
|
bool checkConsistency(bool log_error=true) const;
|
2014-04-13 15:34:28 -04:00
|
|
|
std::vector<std::string> getTrackNames(const bool includeLocked=false) const;
|
|
|
|
std::vector<int> getLaps(const bool includeLocked=false) const;
|
|
|
|
std::vector<bool> getReverse(const bool includeLocked=false) const;
|
|
|
|
bool isEditable() const;
|
|
|
|
unsigned int getNumberOfTracks(const bool includeLocked=false) const;
|
|
|
|
const std::string& getTrackId(const unsigned int track) const;
|
|
|
|
irr::core::stringw getTrackName(const unsigned int track) const;
|
|
|
|
unsigned int getLaps(const unsigned int track) const;
|
|
|
|
bool getReverse(const unsigned int track) const;
|
|
|
|
void moveUp(const unsigned int track);
|
|
|
|
void moveDown(const unsigned int track);
|
|
|
|
void addTrack(Track* track, unsigned int laps,
|
|
|
|
bool reverse, int position=-1);
|
2014-04-25 11:03:12 -04:00
|
|
|
void editTrack(unsigned int index, Track* track,
|
2014-04-13 15:34:28 -04:00
|
|
|
unsigned int laps, bool reverse);
|
|
|
|
void remove(const unsigned int track);
|
2012-11-27 07:09:16 -05:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
2013-05-30 15:47:39 -04:00
|
|
|
/** @return the (potentially translated) user-visible name of the Grand
|
2012-11-27 07:09:16 -05:00
|
|
|
* Prix (apply fribidi as needed) */
|
2014-04-25 11:03:12 -04:00
|
|
|
irr::core::stringw getName() const { return _LTR(m_name.c_str()); }
|
2010-02-15 19:33:41 -05:00
|
|
|
|
2012-11-27 07:09:16 -05:00
|
|
|
// ------------------------------------------------------------------------
|
2014-04-25 11:03:12 -04:00
|
|
|
/** @return the internal indentifier of the Grand Prix (not translated) */
|
|
|
|
const std::string& getId() const { return m_id; }
|
2013-05-30 15:47:39 -04:00
|
|
|
|
2012-11-27 07:09:16 -05:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
/** Returns the filename of the grand prix xml file. */
|
2014-04-25 11:03:12 -04:00
|
|
|
const std::string& getFilename() const { return m_filename; }
|
2012-11-27 07:09:16 -05:00
|
|
|
}; // GrandPrixData
|
2007-05-27 12:01:53 -04:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* EOF */
|