Ticket #3440: t3440_simplify_and_empty_JS_Interface_v1.patch
File t3440_simplify_and_empty_JS_Interface_v1.patch, 3.9 KB (added by , 9 years ago) |
---|
-
source/ps/GameSetup/GameSetup.cpp
bool AutostartVisualReplay(const std::st 1483 1483 g_Game->StartVisualReplay(replayFile); 1484 1484 1485 1485 // TODO: Non progressive load can fail - need a decent way to handle this 1486 1486 LDR_NonprogressiveLoad(); 1487 1487 1488 PSRETURN ret = g_Game->ReallyStartGame(); 1489 ENSURE(ret == PSRETURN_OK); 1488 ENSURE(g_Game->ReallyStartGame() == PSRETURN_OK); 1490 1489 1491 1490 ScriptInterface& scriptInterface = g_Game->GetSimulation2()->GetScriptInterface(); 1492 1491 1493 1492 InitPs(true, L"page_session.xml", &scriptInterface, JS::UndefinedHandleValue); 1494 1493 return true; -
source/ps/VisualReplay.cpp
20 20 #include "VisualReplay.h" 21 21 #include "graphics/GameView.h" 22 22 #include "gui/GUIManager.h" 23 23 #include "lib/allocators/shared_ptr.h" 24 24 #include "lib/utf8.h" 25 #include "network/NetClient.h" 26 #include "network/NetServer.h" 25 27 #include "ps/CLogger.h" 26 28 #include "ps/Filesystem.h" 27 29 #include "ps/Game.h" 28 30 #include "ps/Pyrogenesis.h" 29 31 #include "ps/Replay.h" … … const bool debugParser = false; 42 44 OsPath VisualReplay::GetDirectoryName() 43 45 { 44 46 return OsPath(psLogDir() / L"sim_log"); 45 47 } 46 48 49 void VisualReplay::StartVisualReplay(CStrW directory) 50 { 51 ENSURE(!g_NetServer); 52 ENSURE(!g_NetClient); 53 ENSURE(!g_Game); 54 55 const OsPath replayFile = VisualReplay::GetDirectoryName() / directory / L"commands.txt"; 56 57 if (!FileExists(replayFile)) 58 return; 59 60 g_Game = new CGame(false, false); 61 62 // TODO: support unicode when OsString() is implemented for windows 63 g_Game->StartVisualReplay(utf8_from_wstring(replayFile.string())); 64 } 65 47 66 JS::Value VisualReplay::GetReplays(ScriptInterface& scriptInterface) 48 67 { 49 68 TIMER(L"GetReplays"); 50 69 JSContext* cx = scriptInterface.GetContext(); 51 70 JSAutoRequest rq(cx); -
source/ps/VisualReplay.h
namespace VisualReplay 35 35 * @return OsPath the absolute file path 36 36 */ 37 37 OsPath GetDirectoryName(); 38 38 39 39 /** 40 * Replays the commands.txt file in the given replay visually. 41 */ 42 void StartVisualReplay(CStrW directory); 43 44 /** 40 45 * Get a list of replays to display in the GUI. 41 46 * 42 47 * @param scriptInterface the ScriptInterface in which to create the return data. 43 48 * @return array of objects containing replay data 44 49 */ -
source/ps/scripting/JSInterface_VisualReplay.cpp
15 15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. 16 16 */ 17 17 18 18 #include "precompiled.h" 19 19 20 #include "network/NetClient.h"21 #include "network/NetServer.h"22 #include "ps/Filesystem.h"23 #include "ps/Game.h"24 20 #include "ps/VisualReplay.h" 25 21 #include "ps/scripting/JSInterface_VisualReplay.h" 26 22 27 23 void JSI_VisualReplay::StartVisualReplay(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), CStrW directory) 28 24 { 29 ENSURE(!g_NetServer); 30 ENSURE(!g_NetClient); 31 ENSURE(!g_Game); 32 33 const OsPath replayFile = VisualReplay::GetDirectoryName() / directory / L"commands.txt"; 34 if (FileExists(replayFile)) 35 { 36 g_Game = new CGame(false, false); 37 // TODO: support unicode when OsString() is implemented for windows 38 g_Game->StartVisualReplay(utf8_from_wstring(replayFile.string())); 39 } 25 VisualReplay::StartVisualReplay(directory); 40 26 } 41 27 42 28 bool JSI_VisualReplay::DeleteReplay(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), CStrW replayFile) 43 29 { 44 30 return VisualReplay::DeleteReplay(replayFile);