19 #ifndef HEADER_REPLAY__PLAY_HPP
20 #define HEADER_REPLAY__PLAY_HPP
22 #include "replay/replay_base.hpp"
23 #include "tracks/track.hpp"
25 #include "irrString.h"
46 SO_TRACK = SO_DEFAULT,
59 std::string m_filename;
60 std::string m_track_name;
62 std::string m_minor_mode;
63 core::stringw m_stk_version;
64 core::stringw m_user_name;
66 std::vector<std::string> m_kart_list;
67 std::vector<core::stringw> m_name_list;
68 std::vector<float> m_kart_color;
70 bool m_custom_replay_file;
71 unsigned int m_difficulty;
73 unsigned int m_replay_version;
74 uint64_t m_replay_uid;
85 return m_kart_list.size() < r.m_kart_list.size();
88 return m_reverse < r.m_reverse;
91 return m_difficulty < r.m_difficulty;
94 return m_laps < r.m_laps;
97 return m_min_time < r.m_min_time;
100 return m_user_name < r.m_user_name;
103 return m_stk_version < r.m_stk_version;
115 unsigned int m_current_replay_file;
117 unsigned int m_second_replay_file;
119 bool m_second_replay_enabled;
121 std::vector<ReplayData> m_replay_file_list;
128 void readKartData(FILE *fd,
char *next_line,
bool second_replay);
132 void loadFile(
bool second_replay);
133 void loadAllReplayFile();
135 static void setSortOrder(
SortOrder so) { m_sort_order = so; }
137 void sortReplay(
bool reverse)
139 (reverse ? std::stable_sort(m_replay_file_list.rbegin(),
140 m_replay_file_list.rend()) : std::stable_sort(m_replay_file_list.begin(),
141 m_replay_file_list.end()));
144 void setReplayFile(
unsigned int n)
145 { m_current_replay_file = n; }
148 void setSecondReplayFile(
unsigned int n,
bool second_replay_enabled)
149 { m_second_replay_file = n;
150 m_second_replay_enabled = second_replay_enabled;}
153 void setReplayFileByUID(uint64_t uid);
155 unsigned int getReplayIdByUID(uint64_t uid);
158 bool addReplayFile(
const std::string& fn,
159 bool custom_replay =
false,
162 const ReplayData& getReplayData(
unsigned int n)
const
163 {
return m_replay_file_list.at(n); }
165 const ReplayData& getCurrentReplayData()
const
166 {
return m_replay_file_list.at(m_current_replay_file); }
168 const unsigned int getNumReplayFile()
const
169 {
return (
unsigned int)m_replay_file_list.size(); }
171 std::shared_ptr<GhostKart> getGhostKart(
int n) {
return m_ghost_karts[n]; }
173 const unsigned int getNumGhostKart()
const
175 assert(m_replay_file_list.size() > 0);
177 (
unsigned int)m_replay_file_list.at(m_current_replay_file)
179 unsigned int second_file_num =
180 (
unsigned int)m_replay_file_list.at(m_second_replay_file)
183 num = (m_second_replay_enabled) ? num + second_file_num : num;
188 const std::string& getGhostKartName(
unsigned int n)
const
190 assert(m_replay_file_list.size() > 0);
193 (
unsigned int)m_replay_file_list.at(m_current_replay_file)
196 return m_replay_file_list.at(m_current_replay_file).m_kart_list.at(n);
198 return m_replay_file_list.at(m_second_replay_file).m_kart_list.at(n-fkn);
209 {
delete m_replay_play; m_replay_play = NULL; }
214 assert(m_replay_file_list.size() > 0);
215 if (replay_file_number == 2)
216 return m_replay_file_list.at(m_second_replay_file).m_filename;
218 return m_replay_file_list.at(m_current_replay_file).m_filename;
221 unsigned int getCurrentReplayFileIndex()
const
222 {
return m_current_replay_file; }
224 unsigned int getSecondReplayFileIndex()
const
225 {
return m_second_replay_file; }
227 bool isSecondReplayEnabled()
const {
return m_second_replay_enabled; }
A ghost kart.
Definition: ghost_kart.hpp:38
Definition: replay_base.hpp:33
Definition: replay_play.hpp:57
Definition: replay_play.hpp:39
static void create()
Creates a new instance of the replay object.
Definition: replay_play.hpp:202
static void destroy()
Delete the instance of the replay object.
Definition: replay_play.hpp:208
virtual const std::string & getReplayFilename(int replay_file_number=1) const
Returns the filename that was opened.
Definition: replay_play.hpp:212
SortOrder
Order of sort for ReplayData.
Definition: replay_play.hpp:44
std::vector< std::shared_ptr< GhostKart > > m_ghost_karts
All ghost karts.
Definition: replay_play.hpp:124
static ReplayPlay * get()
Returns the instance of the replay object.
Definition: replay_play.hpp:205
Definition: track.hpp:115
core::stringw getSortName() const
Returns the name of the track used to sort the tracks alphabetically.
Definition: track.cpp:249