2019-05-14 03:13:02 -07:00
|
|
|
/* Copyright (C) 2019 Wildfire Games.
|
2015-09-21 10:14:26 -07:00
|
|
|
* This file is part of 0 A.D.
|
|
|
|
|
*
|
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
2018-04-27 09:48:44 -07:00
|
|
|
#include "JSInterface_VisualReplay.h"
|
2016-08-02 09:58:30 -07:00
|
|
|
|
|
|
|
|
#include "ps/CStr.h"
|
2015-09-21 10:14:26 -07:00
|
|
|
#include "ps/VisualReplay.h"
|
2018-04-27 09:48:44 -07:00
|
|
|
#include "scriptinterface/ScriptInterface.h"
|
2015-09-21 10:14:26 -07:00
|
|
|
|
2020-11-13 08:44:15 -08:00
|
|
|
bool JSI_VisualReplay::StartVisualReplay(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const CStrW& directory)
|
2015-09-21 10:14:26 -07:00
|
|
|
{
|
2017-07-06 09:20:18 -07:00
|
|
|
return VisualReplay::StartVisualReplay(directory);
|
2015-09-21 10:14:26 -07:00
|
|
|
}
|
|
|
|
|
|
2020-11-13 08:44:15 -08:00
|
|
|
bool JSI_VisualReplay::DeleteReplay(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const CStrW& replayFile)
|
2015-09-21 10:14:26 -07:00
|
|
|
{
|
|
|
|
|
return VisualReplay::DeleteReplay(replayFile);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-13 08:44:15 -08:00
|
|
|
JS::Value JSI_VisualReplay::GetReplays(ScriptInterface::CmptPrivate* pCmptPrivate, bool compareFiles)
|
2015-09-21 10:14:26 -07:00
|
|
|
{
|
2020-11-13 08:44:15 -08:00
|
|
|
return VisualReplay::GetReplays(*(pCmptPrivate->pScriptInterface), compareFiles);
|
2015-09-21 10:14:26 -07:00
|
|
|
}
|
|
|
|
|
|
2020-11-13 08:44:15 -08:00
|
|
|
JS::Value JSI_VisualReplay::GetReplayAttributes(ScriptInterface::CmptPrivate* pCmptPrivate, const CStrW& directoryName)
|
2015-09-21 10:14:26 -07:00
|
|
|
{
|
2020-11-13 08:44:15 -08:00
|
|
|
return VisualReplay::GetReplayAttributes(pCmptPrivate, directoryName);
|
2015-09-21 10:14:26 -07:00
|
|
|
}
|
|
|
|
|
|
2020-11-13 08:44:15 -08:00
|
|
|
bool JSI_VisualReplay::HasReplayMetadata(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const CStrW& directoryName)
|
2015-12-02 05:53:44 -08:00
|
|
|
{
|
|
|
|
|
return VisualReplay::HasReplayMetadata(directoryName);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-13 08:44:15 -08:00
|
|
|
JS::Value JSI_VisualReplay::GetReplayMetadata(ScriptInterface::CmptPrivate* pCmptPrivate, const CStrW& directoryName)
|
2015-09-21 10:14:26 -07:00
|
|
|
{
|
2020-11-13 08:44:15 -08:00
|
|
|
return VisualReplay::GetReplayMetadata(pCmptPrivate, directoryName);
|
2015-09-21 10:14:26 -07:00
|
|
|
}
|
|
|
|
|
|
2020-11-13 08:44:15 -08:00
|
|
|
void JSI_VisualReplay::AddReplayToCache(ScriptInterface::CmptPrivate* pCmptPrivate, const CStrW& directoryName)
|
2017-05-27 13:17:57 -07:00
|
|
|
{
|
2020-11-13 08:44:15 -08:00
|
|
|
VisualReplay::AddReplayToCache(*(pCmptPrivate->pScriptInterface), directoryName);
|
2017-05-27 13:17:57 -07:00
|
|
|
}
|
|
|
|
|
|
2020-11-13 08:44:15 -08:00
|
|
|
CStrW JSI_VisualReplay::GetReplayDirectoryName(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const CStrW& directoryName)
|
2017-05-24 06:53:00 -07:00
|
|
|
{
|
2019-05-14 03:13:02 -07:00
|
|
|
return wstring_from_utf8(OsPath(VisualReplay::GetDirectoryPath() / directoryName).string8());
|
2017-05-24 06:53:00 -07:00
|
|
|
}
|
|
|
|
|
|
2017-08-23 17:32:42 -07:00
|
|
|
void JSI_VisualReplay::RegisterScriptFunctions(const ScriptInterface& scriptInterface)
|
2015-09-21 10:14:26 -07:00
|
|
|
{
|
2017-05-27 13:17:57 -07:00
|
|
|
scriptInterface.RegisterFunction<JS::Value, bool, &GetReplays>("GetReplays");
|
2015-09-21 10:14:26 -07:00
|
|
|
scriptInterface.RegisterFunction<bool, CStrW, &DeleteReplay>("DeleteReplay");
|
2017-07-06 09:20:18 -07:00
|
|
|
scriptInterface.RegisterFunction<bool, CStrW, &StartVisualReplay>("StartVisualReplay");
|
2015-09-21 10:14:26 -07:00
|
|
|
scriptInterface.RegisterFunction<JS::Value, CStrW, &GetReplayAttributes>("GetReplayAttributes");
|
|
|
|
|
scriptInterface.RegisterFunction<JS::Value, CStrW, &GetReplayMetadata>("GetReplayMetadata");
|
2015-12-02 05:53:44 -08:00
|
|
|
scriptInterface.RegisterFunction<bool, CStrW, &HasReplayMetadata>("HasReplayMetadata");
|
2017-05-27 13:17:57 -07:00
|
|
|
scriptInterface.RegisterFunction<void, CStrW, &AddReplayToCache>("AddReplayToCache");
|
2017-05-24 06:53:00 -07:00
|
|
|
scriptInterface.RegisterFunction<CStrW, CStrW, &GetReplayDirectoryName>("GetReplayDirectoryName");
|
2015-09-21 10:14:26 -07:00
|
|
|
}
|