19#ifndef HEADER_REPLAY__PLAY_HPP
20#define HEADER_REPLAY__PLAY_HPP
22#include "replay/replay_base.hpp"
23#include "tracks/track.hpp"
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;
65 std::vector<std::string> m_kart_list;
66 std::vector<core::stringw> m_name_list;
67 std::vector<float> m_kart_color;
69 bool m_custom_replay_file;
70 unsigned int m_difficulty;
72 unsigned int m_replay_version;
73 uint64_t m_replay_uid;
84 return m_kart_list.size() < r.m_kart_list.size();
87 return m_reverse < r.m_reverse;
90 return m_difficulty < r.m_difficulty;
93 return m_laps < r.m_laps;
96 return m_min_time < r.m_min_time;
99 return m_user_name < r.m_user_name;
102 return m_stk_version < r.m_stk_version;
114 unsigned int m_current_replay_file;
116 unsigned int m_second_replay_file;
118 bool m_second_replay_enabled;
120 std::vector<ReplayData> m_replay_file_list;
127 void readKartData(FILE *fd,
char *next_line,
bool second_replay);
131 void loadFile(
bool second_replay);
132 void loadAllReplayFile();
134 static void setSortOrder(
SortOrder so) { m_sort_order = so; }
136 void sortReplay(
bool reverse)
138 (reverse ? std::stable_sort(m_replay_file_list.rbegin(),
139 m_replay_file_list.rend()) : std::stable_sort(m_replay_file_list.begin(),
140 m_replay_file_list.end()));
143 void setReplayFile(
unsigned int n)
144 { m_current_replay_file = n; }
147 void setSecondReplayFile(
unsigned int n,
bool second_replay_enabled)
148 { m_second_replay_file = n;
149 m_second_replay_enabled = second_replay_enabled;}
157 bool addReplayFile(
const std::string& fn,
158 bool custom_replay =
false,
161 const ReplayData& getReplayData(
unsigned int n)
const
162 {
return m_replay_file_list.at(n); }
164 const ReplayData& getCurrentReplayData()
const
165 {
return m_replay_file_list.at(m_current_replay_file); }
167 const unsigned int getNumReplayFile()
const
168 {
return (
unsigned int)m_replay_file_list.size(); }
170 std::shared_ptr<GhostKart> getGhostKart(
int n) {
return m_ghost_karts[n]; }
172 const unsigned int getNumGhostKart()
const
174 assert(m_replay_file_list.size() > 0);
176 (
unsigned int)m_replay_file_list.at(m_current_replay_file)
178 unsigned int second_file_num =
179 (
unsigned int)m_replay_file_list.at(m_second_replay_file)
182 num = (m_second_replay_enabled) ? num + second_file_num : num;
187 const std::string& getGhostKartName(
unsigned int n)
const
189 assert(m_replay_file_list.size() > 0);
192 (
unsigned int)m_replay_file_list.at(m_current_replay_file)
195 return m_replay_file_list.at(m_current_replay_file).m_kart_list.at(n);
197 return m_replay_file_list.at(m_second_replay_file).m_kart_list.at(n-fkn);
208 {
delete m_replay_play; m_replay_play = NULL; }
213 assert(m_replay_file_list.size() > 0);
214 if (replay_file_number == 2)
215 return m_replay_file_list.at(m_second_replay_file).m_filename;
217 return m_replay_file_list.at(m_current_replay_file).m_filename;
220 unsigned int getCurrentReplayFileIndex()
const
221 {
return m_current_replay_file; }
223 unsigned int getSecondReplayFileIndex()
const
224 {
return m_second_replay_file; }
226 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:201
static void destroy()
Delete the instance of the replay object.
Definition: replay_play.hpp:207
void reset()
Resets all ghost karts back to start position.
Definition: replay_play.cpp:59
unsigned int getReplayIdByUID(uint64_t uid)
Search among replay file and return the first index with a matching UID.
Definition: replay_play.cpp:509
~ReplayPlay()
Frees all stored data.
Definition: replay_play.cpp:52
SortOrder
Order of sort for ReplayData.
Definition: replay_play.hpp:44
void readKartData(FILE *fd, char *next_line, bool second_replay)
Reads all data from a replay file for a specific kart.
Definition: replay_play.cpp:357
void setReplayFileByUID(uint64_t uid)
call getReplayIdByUID and set the current replay file to the first one with a matching UID.
Definition: replay_play.cpp:500
ReplayPlay()
Initialises the Replay engine.
Definition: replay_play.cpp:43
std::vector< std::shared_ptr< GhostKart > > m_ghost_karts
All ghost karts.
Definition: replay_play.hpp:123
static ReplayPlay * get()
Returns the instance of the replay object.
Definition: replay_play.hpp:204
virtual const std::string & getReplayFilename(int replay_file_number=1) const
Returns the filename that was opened.
Definition: replay_play.hpp:211
Definition: track.hpp:114
core::stringw getSortName() const
Returns the name of the track used to sort the tracks alphabetically.
Definition: track.cpp:243