Allow a few replays coming with the game
This commit is contained in:
parent
790cd807a3
commit
f6ce065cee
2594
data/replay/standard_expert.replay
Normal file
2594
data/replay/standard_expert.replay
Normal file
File diff suppressed because it is too large
Load Diff
@ -123,6 +123,7 @@ FileManager::FileManager()
|
|||||||
m_subdir_name[LIBRARY ] = "library";
|
m_subdir_name[LIBRARY ] = "library";
|
||||||
m_subdir_name[MODEL ] = "models";
|
m_subdir_name[MODEL ] = "models";
|
||||||
m_subdir_name[MUSIC ] = "music";
|
m_subdir_name[MUSIC ] = "music";
|
||||||
|
m_subdir_name[REPLAY ] = "replay";
|
||||||
m_subdir_name[SCRIPT ] = "tracks";
|
m_subdir_name[SCRIPT ] = "tracks";
|
||||||
m_subdir_name[SFX ] = "sfx";
|
m_subdir_name[SFX ] = "sfx";
|
||||||
m_subdir_name[SKIN ] = "skins";
|
m_subdir_name[SKIN ] = "skins";
|
||||||
|
@ -48,7 +48,7 @@ public:
|
|||||||
* The last entry ASSET_COUNT specifies the number of entries. */
|
* The last entry ASSET_COUNT specifies the number of entries. */
|
||||||
enum AssetType {ASSET_MIN,
|
enum AssetType {ASSET_MIN,
|
||||||
CHALLENGE=ASSET_MIN,
|
CHALLENGE=ASSET_MIN,
|
||||||
GFX, GRANDPRIX, GUI, LIBRARY, MODEL, MUSIC,
|
GFX, GRANDPRIX, GUI, LIBRARY, MODEL, MUSIC, REPLAY,
|
||||||
SCRIPT, SFX, SHADER, SKIN, TEXTURE, TTF,
|
SCRIPT, SFX, SHADER, SKIN, TEXTURE, TTF,
|
||||||
TRANSLATION, ASSET_MAX = TRANSLATION,
|
TRANSLATION, ASSET_MAX = TRANSLATION,
|
||||||
ASSET_COUNT};
|
ASSET_COUNT};
|
||||||
@ -138,7 +138,13 @@ public:
|
|||||||
bool abort_on_error=false) const;
|
bool abort_on_error=false) const;
|
||||||
std::string getAsset(AssetType type, const std::string &name) const;
|
std::string getAsset(AssetType type, const std::string &name) const;
|
||||||
std::string getAsset(const std::string &name) const;
|
std::string getAsset(const std::string &name) const;
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
/** Returns the directory of an asset. */
|
||||||
|
std::string getAssetDirectory(AssetType type) const
|
||||||
|
{
|
||||||
|
return m_subdir_name[type];
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
std::string searchMusic(const std::string& file_name) const;
|
std::string searchMusic(const std::string& file_name) const;
|
||||||
std::string searchTexture(const std::string& fname) const;
|
std::string searchTexture(const std::string& fname) const;
|
||||||
std::string getUserConfigFile(const std::string& fname) const;
|
std::string getUserConfigFile(const std::string& fname) const;
|
||||||
|
@ -40,7 +40,6 @@ ReplayPlay *ReplayPlay::m_replay_play = NULL;
|
|||||||
ReplayPlay::ReplayPlay()
|
ReplayPlay::ReplayPlay()
|
||||||
{
|
{
|
||||||
m_current_replay_file = 0;
|
m_current_replay_file = 0;
|
||||||
m_custom_replay_file = false;
|
|
||||||
} // ReplayPlay
|
} // ReplayPlay
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -64,6 +63,22 @@ void ReplayPlay::reset()
|
|||||||
void ReplayPlay::loadAllReplayFile()
|
void ReplayPlay::loadAllReplayFile()
|
||||||
{
|
{
|
||||||
m_replay_file_list.clear();
|
m_replay_file_list.clear();
|
||||||
|
|
||||||
|
// Load stock replay first
|
||||||
|
std::set<std::string> pre_record;
|
||||||
|
file_manager->listFiles(pre_record, file_manager
|
||||||
|
->getAssetDirectory(FileManager::REPLAY), /*is_full_path*/ true);
|
||||||
|
for (std::set<std::string>::iterator i = pre_record.begin();
|
||||||
|
i != pre_record.end(); ++i)
|
||||||
|
{
|
||||||
|
if (!addReplayFile(*i, /*custom_replay*/ true))
|
||||||
|
{
|
||||||
|
// Skip invalid replay file
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now user recorded replay
|
||||||
std::set<std::string> files;
|
std::set<std::string> files;
|
||||||
file_manager->listFiles(files, file_manager->getReplayDir(),
|
file_manager->listFiles(files, file_manager->getReplayDir(),
|
||||||
/*is_full_path*/ false);
|
/*is_full_path*/ false);
|
||||||
@ -77,13 +92,12 @@ void ReplayPlay::loadAllReplayFile()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // loadAllReplayFile
|
} // loadAllReplayFile
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool ReplayPlay::addReplayFile(const std::string& fn, bool custom_replay)
|
bool ReplayPlay::addReplayFile(const std::string& fn, bool custom_replay)
|
||||||
{
|
{
|
||||||
// custom_replay is true when full path of filename is given
|
|
||||||
m_custom_replay_file = custom_replay;
|
|
||||||
|
|
||||||
char s[1024], s1[1024];
|
char s[1024], s1[1024];
|
||||||
if (StringUtils::getExtension(fn) != "replay") return false;
|
if (StringUtils::getExtension(fn) != "replay") return false;
|
||||||
@ -92,6 +106,8 @@ bool ReplayPlay::addReplayFile(const std::string& fn, bool custom_replay)
|
|||||||
if (fd == NULL) return false;
|
if (fd == NULL) return false;
|
||||||
ReplayData rd;
|
ReplayData rd;
|
||||||
|
|
||||||
|
// custom_replay is true when full path of filename is given
|
||||||
|
rd.m_custom_replay_file = custom_replay;
|
||||||
rd.m_filename = fn;
|
rd.m_filename = fn;
|
||||||
|
|
||||||
fgets(s, 1023, fd);
|
fgets(s, 1023, fd);
|
||||||
@ -196,7 +212,8 @@ void ReplayPlay::load()
|
|||||||
m_ghost_karts.clearAndDeleteAll();
|
m_ghost_karts.clearAndDeleteAll();
|
||||||
char s[1024];
|
char s[1024];
|
||||||
|
|
||||||
FILE *fd = openReplayFile(/*writeable*/false, m_custom_replay_file);
|
FILE *fd = openReplayFile(/*writeable*/false,
|
||||||
|
m_replay_file_list.at(m_current_replay_file).m_custom_replay_file);
|
||||||
if(!fd)
|
if(!fd)
|
||||||
{
|
{
|
||||||
Log::error("Replay", "Can't read '%s', ghost replay disabled.",
|
Log::error("Replay", "Can't read '%s', ghost replay disabled.",
|
||||||
|
@ -55,6 +55,7 @@ public:
|
|||||||
std::string m_track_name;
|
std::string m_track_name;
|
||||||
std::vector<std::string> m_kart_list;
|
std::vector<std::string> m_kart_list;
|
||||||
bool m_reverse;
|
bool m_reverse;
|
||||||
|
bool m_custom_replay_file;
|
||||||
unsigned int m_difficulty;
|
unsigned int m_difficulty;
|
||||||
unsigned int m_laps;
|
unsigned int m_laps;
|
||||||
float m_min_time;
|
float m_min_time;
|
||||||
@ -93,8 +94,6 @@ private:
|
|||||||
|
|
||||||
unsigned int m_current_replay_file;
|
unsigned int m_current_replay_file;
|
||||||
|
|
||||||
bool m_custom_replay_file;
|
|
||||||
|
|
||||||
std::vector<ReplayData> m_replay_file_list;
|
std::vector<ReplayData> m_replay_file_list;
|
||||||
|
|
||||||
/** All ghost karts. */
|
/** All ghost karts. */
|
||||||
|
@ -39,10 +39,15 @@ GhostReplayInfoDialog::GhostReplayInfoDialog(unsigned int replay_id)
|
|||||||
|
|
||||||
LabelWidget *name = getWidget<LabelWidget>("name");
|
LabelWidget *name = getWidget<LabelWidget>("name");
|
||||||
assert(name);
|
assert(name);
|
||||||
name->setText(stringw((m_rd.m_filename).c_str()), false);
|
name->setText(stringw((m_rd.m_custom_replay_file ? StringUtils::getBasename
|
||||||
|
(m_rd.m_filename) : m_rd.m_filename).c_str()), false);
|
||||||
|
|
||||||
m_back_widget = getWidget<IconButtonWidget>("back");
|
m_back_widget = getWidget<IconButtonWidget>("back");
|
||||||
m_back_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
m_back_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||||
|
|
||||||
|
// Non-deletable for custom (standard) replay file
|
||||||
|
getWidget<IconButtonWidget>("remove")->setActive(!m_rd.m_custom_replay_file);
|
||||||
|
|
||||||
m_action_widget = getWidget<RibbonWidget>("actions");
|
m_action_widget = getWidget<RibbonWidget>("actions");
|
||||||
m_record_widget = getWidget<CheckBoxWidget>("record-race");
|
m_record_widget = getWidget<CheckBoxWidget>("record-race");
|
||||||
m_watch_widget = getWidget<CheckBoxWidget>("watch-only");
|
m_watch_widget = getWidget<CheckBoxWidget>("watch-only");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user