Pyrogenesis  trunk
Functions
VisualReplay Namespace Reference

Contains functions for visually replaying past games. More...

Functions

OsPath GetDirectoryPath ()
 Returns the absolute path to the sim-log directory (that contains the directories with the replay files. More...
 
OsPath GetCacheFilePath ()
 Returns the absolute path to the replay cache file. More...
 
OsPath GetTempCacheFilePath ()
 Returns the absolute path to the temporary replay cache file used to always have a valid cache file in place even if bad things happen. More...
 
bool StartVisualReplay (const OsPath &directory)
 Replays the commands.txt file in the given subdirectory visually. More...
 
bool ReadCacheFile (const ScriptInterface &scriptInterface, JS::MutableHandleObject cachedReplaysObject)
 Reads the replay Cache file and parses it into a jsObject. More...
 
void StoreCacheFile (const ScriptInterface &scriptInterface, JS::HandleObject replays)
 Stores the replay list in the replay cache file. More...
 
JS::HandleObject ReloadReplayCache (const ScriptInterface &scriptInterface, bool compareFiles)
 Load the replay cache and check if there are new/deleted replays. More...
 
JS::Value GetReplays (const ScriptInterface &scriptInterface, bool compareFiles)
 Get a list of replays to display in the GUI. More...
 
JS::Value LoadReplayData (const ScriptInterface &scriptInterface, const OsPath &directory)
 Parses a commands.txt file and extracts metadata. More...
 
bool DeleteReplay (const OsPath &replayFile)
 Permanently deletes the visual replay (including the parent directory) More...
 
JS::Value GetReplayAttributes (const ScriptInterface &scriptInterface, const OsPath &directoryName)
 Returns the parsed header of the replay file (commands.txt). More...
 
bool HasReplayMetadata (const OsPath &directoryName)
 Returns whether or not the metadata / summary screen data has been saved properly when the game ended. More...
 
JS::Value GetReplayMetadata (const ScriptInterface &scriptInterface, const OsPath &directoryName)
 Returns the metadata of a replay. More...
 
void AddReplayToCache (const ScriptInterface &scriptInterface, const CStrW &directoryName)
 Adds a replay to the replayCache. More...
 

Detailed Description

Contains functions for visually replaying past games.

Function Documentation

◆ AddReplayToCache()

void VisualReplay::AddReplayToCache ( const ScriptInterface scriptInterface,
const CStrW &  directoryName 
)

Adds a replay to the replayCache.

◆ DeleteReplay()

bool VisualReplay::DeleteReplay ( const OsPath replayFile)

Permanently deletes the visual replay (including the parent directory)

Parameters
replayFile- path to commands.txt, whose parent directory will be deleted.
Returns
true if deletion was successful, false on error

◆ GetCacheFilePath()

OsPath VisualReplay::GetCacheFilePath ( )

Returns the absolute path to the replay cache file.

◆ GetDirectoryPath()

OsPath VisualReplay::GetDirectoryPath ( )

Returns the absolute path to the sim-log directory (that contains the directories with the replay files.

◆ GetReplayAttributes()

JS::Value VisualReplay::GetReplayAttributes ( const ScriptInterface scriptInterface,
const OsPath directoryName 
)

Returns the parsed header of the replay file (commands.txt).

◆ GetReplayMetadata()

JS::Value VisualReplay::GetReplayMetadata ( const ScriptInterface scriptInterface,
const OsPath directoryName 
)

Returns the metadata of a replay.

◆ GetReplays()

JS::Value VisualReplay::GetReplays ( const ScriptInterface scriptInterface,
bool  compareFiles 
)

Get a list of replays to display in the GUI.

Parameters
scriptInterface- the ScriptInterface in which to create the return data.
compareFiles- reload the cache, which takes more time, but nearly ensures, that no changed replay is missed.
Returns
array of objects containing replay data

◆ GetTempCacheFilePath()

OsPath VisualReplay::GetTempCacheFilePath ( )

Returns the absolute path to the temporary replay cache file used to always have a valid cache file in place even if bad things happen.

◆ HasReplayMetadata()

bool VisualReplay::HasReplayMetadata ( const OsPath directoryName)

Returns whether or not the metadata / summary screen data has been saved properly when the game ended.

◆ LoadReplayData()

JS::Value VisualReplay::LoadReplayData ( const ScriptInterface scriptInterface,
const OsPath directory 
)

Parses a commands.txt file and extracts metadata.

Works similarly to CGame::LoadReplayData().

◆ ReadCacheFile()

bool VisualReplay::ReadCacheFile ( const ScriptInterface scriptInterface,
JS::MutableHandleObject  cachedReplaysObject 
)

Reads the replay Cache file and parses it into a jsObject.

Parameters
scriptInterface- the ScriptInterface in which to create the return data.
cachedReplaysObject- the cached replays.
Returns
true on succes

◆ ReloadReplayCache()

JS::HandleObject VisualReplay::ReloadReplayCache ( const ScriptInterface scriptInterface,
bool  compareFiles 
)

Load the replay cache and check if there are new/deleted replays.

If so, update the cache.

Parameters
scriptInterface- the ScriptInterface in which to create the return data.
compareFiles- compare the directory name and the FileSize of the replays and the cache.
Returns
cache entries

◆ StartVisualReplay()

bool VisualReplay::StartVisualReplay ( const OsPath directory)

Replays the commands.txt file in the given subdirectory visually.

◆ StoreCacheFile()

void VisualReplay::StoreCacheFile ( const ScriptInterface scriptInterface,
JS::HandleObject  replays 
)

Stores the replay list in the replay cache file.

Parameters
scriptInterface- the ScriptInterface in which to create the return data.
replays- the replay list to store.