mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-26 03:31:29 +00:00
Save map settings. Patch by @aBothe. Fixes #2963.
This was SVN commit r16089.
This commit is contained in:
@@ -842,6 +842,17 @@ CScriptVal ReadJSONFile(ScriptInterface::CxPrivate* pCxPrivate, std::wstring fil
|
||||
return out.get();
|
||||
}
|
||||
|
||||
void WriteJSONFile(ScriptInterface::CxPrivate* pCxPrivate, std::wstring filePath, CScriptVal scriptVal)
|
||||
{
|
||||
JS::RootedValue val(pCxPrivate->pScriptInterface->GetContext(), scriptVal.get());
|
||||
std::string str(pCxPrivate->pScriptInterface->StringifyJSON(&val, false));
|
||||
|
||||
VfsPath path(filePath);
|
||||
WriteBuffer buf;
|
||||
buf.Append(str.c_str(), str.length());
|
||||
g_VFS->CreateFile(path, buf.Data(), buf.Size());
|
||||
}
|
||||
|
||||
CParamNode GetTemplate(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), std::string templateName)
|
||||
{
|
||||
return g_GUI->GetTemplate(templateName);
|
||||
@@ -1007,6 +1018,7 @@ void GuiScriptingInit(ScriptInterface& scriptInterface)
|
||||
scriptInterface.RegisterFunction<int, &GetFps>("GetFPS");
|
||||
scriptInterface.RegisterFunction<std::wstring, int, &GetBuildTimestamp>("GetBuildTimestamp");
|
||||
scriptInterface.RegisterFunction<CScriptVal, std::wstring, &ReadJSONFile>("ReadJSONFile");
|
||||
scriptInterface.RegisterFunction<void, std::wstring, CScriptVal, &WriteJSONFile>("WriteJSONFile");
|
||||
scriptInterface.RegisterFunction<CParamNode, std::string, &GetTemplate>("GetTemplate");
|
||||
|
||||
// User report functions
|
||||
|
||||
Reference in New Issue
Block a user