Pyrogenesis  trunk
VisualReplay.h
Go to the documentation of this file.
1 /* Copyright (C) 2016 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef INCLUDED_REPlAY
19 #define INCLUDED_REPlAY
20 
22 class CSimulation2;
23 class CGUIManager;
24 
25 /**
26  * Contains functions for visually replaying past games.
27  */
28 namespace VisualReplay
29 {
30 
31 /**
32  * Returns the path to the sim-log directory (that contains the directories with the replay files.
33  *
34  * @param scriptInterface the ScriptInterface in which to create the return data.
35  * @return OsPath the absolute file path
36  */
38 
39 /**
40  * Replays the commands.txt file in the given subdirectory visually.
41  */
42 void StartVisualReplay(const CStrW& directory);
43 
44 /**
45  * Get a list of replays to display in the GUI.
46  *
47  * @param scriptInterface the ScriptInterface in which to create the return data.
48  * @return array of objects containing replay data
49  */
50 JS::Value GetReplays(ScriptInterface& scriptInterface);
51 
52 /**
53  * Parses a commands.txt file and extracts metadata.
54  * Works similarly to CGame::LoadReplayData().
55  */
56 JS::Value LoadReplayData(ScriptInterface& scriptInterface, OsPath& directory);
57 
58 /**
59  * Permanently deletes the visual replay (including the parent directory)
60  *
61  * @param replayFile path to commands.txt, whose parent directory will be deleted
62  * @return true if deletion was successful, false on error
63  */
64 bool DeleteReplay(const CStrW& replayFile);
65 
66 /**
67  * Returns the parsed header of the replay file (commands.txt).
68  */
69 JS::Value GetReplayAttributes(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& directoryName);
70 
71 /**
72  * Returns whether or not the metadata / summary screen data has been saved properly when the game ended.
73  */
74 bool HasReplayMetadata(const CStrW& directoryName);
75 
76 /**
77  * Returns the metadata of a replay.
78  */
79 JS::Value GetReplayMetadata(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& directoryName);
80 
81 /**
82  * Saves the metadata from the session to metadata.json
83  */
84 void SaveReplayMetadata(ScriptInterface* scriptInterface);
85 
86 }
87 
88 #endif
JS::Value LoadReplayData(ScriptInterface &scriptInterface, OsPath &directory)
Parses a commands.txt file and extracts metadata.
Definition: VisualReplay.cpp:176
Contains functions for visually replaying past games.
Definition: VisualReplay.h:28
JS::Value GetReplays(ScriptInterface &scriptInterface)
Get a list of replays to display in the GUI.
Definition: VisualReplay.cpp:70
Public API for simulation system.
Definition: Simulation2.h:47
Config::Value_type Value
Definition: json_spirit_value.h:181
void StartVisualReplay(const CStrW &directory)
Replays the commands.txt file in the given subdirectory visually.
Definition: VisualReplay.cpp:49
Definition: path.h:77
JS::Value GetReplayMetadata(ScriptInterface::CxPrivate *pCxPrivate, const CStrW &directoryName)
Returns the metadata of a replay.
Definition: VisualReplay.cpp:330
OsPath GetDirectoryName()
Returns the path to the sim-log directory (that contains the directories with the replay files...
Definition: VisualReplay.cpp:43
JS::Value GetReplayAttributes(ScriptInterface::CxPrivate *pCxPrivate, const CStrW &directoryName)
Returns the parsed header of the replay file (commands.txt).
Definition: VisualReplay.cpp:268
Definition: ScriptInterface.h:99
bool HasReplayMetadata(const CStrW &directoryName)
Returns whether or not the metadata / summary screen data has been saved properly when the game ended...
Definition: VisualReplay.cpp:317
Abstraction around a SpiderMonkey JSContext.
Definition: ScriptInterface.h:71
bool DeleteReplay(const CStrW &replayFile)
Permanently deletes the visual replay (including the parent directory)
Definition: VisualReplay.cpp:258
External interface to the GUI system.
Definition: GUIManager.h:47
void SaveReplayMetadata(ScriptInterface *scriptInterface)
Saves the metadata from the session to metadata.json.
Definition: VisualReplay.cpp:293