Mass rename CxPrivate to CmptPrivate.

As part of the SM45->52 migration, a ScriptInterface becomes a wrapper
around a JSCompartment, not a JSContext, thus we ought to store private
data for the compartment and not the context.
This is a mass rename of CxPrivate to CmptPrivate to match that before
the actual changes.

Part of the SM52 migration, stage: SM45 compatible

Patch by: Itms
Tested By: Freagarach
Refs #4893

Differential Revision: https://code.wildfiregames.com/D3089
This was SVN commit r24177.
This commit is contained in:
wraitii 2020-11-13 16:44:15 +00:00
parent ee0d204bf6
commit ab5616b4c4
52 changed files with 674 additions and 674 deletions

View File

@ -209,7 +209,7 @@ int CMapGeneratorWorker::GetProgress()
return m_Progress;
}
double CMapGeneratorWorker::GetMicroseconds(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
double CMapGeneratorWorker::GetMicroseconds(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return JS_Now();
}
@ -220,15 +220,15 @@ shared_ptr<ScriptInterface::StructuredClone> CMapGeneratorWorker::GetResults()
return m_MapData;
}
bool CMapGeneratorWorker::LoadLibrary(ScriptInterface::CxPrivate* pCxPrivate, const VfsPath& name)
bool CMapGeneratorWorker::LoadLibrary(ScriptInterface::CmptPrivate* pCmptPrivate, const VfsPath& name)
{
CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(pCxPrivate->pCBData);
CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(pCmptPrivate->pCBData);
return self->LoadScripts(name);
}
void CMapGeneratorWorker::ExportMap(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue data)
void CMapGeneratorWorker::ExportMap(ScriptInterface::CmptPrivate* pCmptPrivate, JS::HandleValue data)
{
CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(pCxPrivate->pCBData);
CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(pCmptPrivate->pCBData);
// Copy results
std::lock_guard<std::mutex> lock(self->m_WorkerMutex);
@ -236,9 +236,9 @@ void CMapGeneratorWorker::ExportMap(ScriptInterface::CxPrivate* pCxPrivate, JS::
self->m_Progress = 0;
}
void CMapGeneratorWorker::SetProgress(ScriptInterface::CxPrivate* pCxPrivate, int progress)
void CMapGeneratorWorker::SetProgress(ScriptInterface::CmptPrivate* pCmptPrivate, int progress)
{
CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(pCxPrivate->pCBData);
CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(pCmptPrivate->pCBData);
// Copy data
std::lock_guard<std::mutex> lock(self->m_WorkerMutex);
@ -249,9 +249,9 @@ void CMapGeneratorWorker::SetProgress(ScriptInterface::CxPrivate* pCxPrivate, in
LOGWARNING("The random map script tried to reduce the loading progress from %d to %d", self->m_Progress, progress);
}
CParamNode CMapGeneratorWorker::GetTemplate(ScriptInterface::CxPrivate* pCxPrivate, const std::string& templateName)
CParamNode CMapGeneratorWorker::GetTemplate(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& templateName)
{
CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(pCxPrivate->pCBData);
CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(pCmptPrivate->pCBData);
const CParamNode& templateRoot = self->m_TemplateLoader.GetTemplateFileData(templateName).GetChild("Entity");
if (!templateRoot.IsOk())
LOGERROR("Invalid template found for '%s'", templateName.c_str());
@ -259,21 +259,21 @@ CParamNode CMapGeneratorWorker::GetTemplate(ScriptInterface::CxPrivate* pCxPriva
return templateRoot;
}
bool CMapGeneratorWorker::TemplateExists(ScriptInterface::CxPrivate* pCxPrivate, const std::string& templateName)
bool CMapGeneratorWorker::TemplateExists(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& templateName)
{
CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(pCxPrivate->pCBData);
CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(pCmptPrivate->pCBData);
return self->m_TemplateLoader.TemplateExists(templateName);
}
std::vector<std::string> CMapGeneratorWorker::FindTemplates(ScriptInterface::CxPrivate* pCxPrivate, const std::string& path, bool includeSubdirectories)
std::vector<std::string> CMapGeneratorWorker::FindTemplates(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& path, bool includeSubdirectories)
{
CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(pCxPrivate->pCBData);
CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(pCmptPrivate->pCBData);
return self->m_TemplateLoader.FindTemplates(path, includeSubdirectories, SIMULATION_TEMPLATES);
}
std::vector<std::string> CMapGeneratorWorker::FindActorTemplates(ScriptInterface::CxPrivate* pCxPrivate, const std::string& path, bool includeSubdirectories)
std::vector<std::string> CMapGeneratorWorker::FindActorTemplates(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& path, bool includeSubdirectories)
{
CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(pCxPrivate->pCBData);
CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(pCmptPrivate->pCBData);
return self->m_TemplateLoader.FindTemplates(path, includeSubdirectories, ACTOR_TEMPLATES);
}
@ -315,7 +315,7 @@ bool CMapGeneratorWorker::LoadScripts(const VfsPath& libraryName)
return true;
}
JS::Value CMapGeneratorWorker::LoadHeightmap(ScriptInterface::CxPrivate* pCxPrivate, const VfsPath& filename)
JS::Value CMapGeneratorWorker::LoadHeightmap(ScriptInterface::CmptPrivate* pCmptPrivate, const VfsPath& filename)
{
std::vector<u16> heightmap;
if (LoadHeightmapImageVfs(filename, heightmap) != INFO::OK)
@ -324,7 +324,7 @@ JS::Value CMapGeneratorWorker::LoadHeightmap(ScriptInterface::CxPrivate* pCxPriv
return JS::UndefinedValue();
}
CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(pCxPrivate->pCBData);
CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(pCmptPrivate->pCBData);
ScriptInterface::Request rq(self->m_ScriptInterface);
JS::RootedValue returnValue(rq.cx);
ToJSVal_vector(rq, &returnValue, heightmap);
@ -332,9 +332,9 @@ JS::Value CMapGeneratorWorker::LoadHeightmap(ScriptInterface::CxPrivate* pCxPriv
}
// See CMapReader::UnpackTerrain, CMapReader::ParseTerrain for the reordering
JS::Value CMapGeneratorWorker::LoadMapTerrain(ScriptInterface::CxPrivate* pCxPrivate, const VfsPath& filename)
JS::Value CMapGeneratorWorker::LoadMapTerrain(ScriptInterface::CmptPrivate* pCmptPrivate, const VfsPath& filename)
{
CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(pCxPrivate->pCBData);
CMapGeneratorWorker* self = static_cast<CMapGeneratorWorker*>(pCmptPrivate->pCBData);
ScriptInterface::Request rq(self->m_ScriptInterface);
if (!VfsFileExists(filename))

View File

@ -136,52 +136,52 @@ private:
/**
* Recursively load all script files in the given folder.
*/
static bool LoadLibrary(ScriptInterface::CxPrivate* pCxPrivate, const VfsPath& name);
static bool LoadLibrary(ScriptInterface::CmptPrivate* pCmptPrivate, const VfsPath& name);
/**
* Finalize map generation and pass results from the script to the engine.
*/
static void ExportMap(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue data);
static void ExportMap(ScriptInterface::CmptPrivate* pCmptPrivate, JS::HandleValue data);
/**
* Load an image file and return it as a height array.
*/
static JS::Value LoadHeightmap(ScriptInterface::CxPrivate* pCxPrivate, const VfsPath& src);
static JS::Value LoadHeightmap(ScriptInterface::CmptPrivate* pCmptPrivate, const VfsPath& src);
/**
* Load an Atlas terrain file (PMP) returning textures and heightmap.
*/
static JS::Value LoadMapTerrain(ScriptInterface::CxPrivate* pCxPrivate, const VfsPath& filename);
static JS::Value LoadMapTerrain(ScriptInterface::CmptPrivate* pCmptPrivate, const VfsPath& filename);
/**
* Sets the map generation progress, which is one of multiple stages determining the loading screen progress.
*/
static void SetProgress(ScriptInterface::CxPrivate* pCxPrivate, int progress);
static void SetProgress(ScriptInterface::CmptPrivate* pCmptPrivate, int progress);
/**
* Microseconds since the epoch.
*/
static double GetMicroseconds(ScriptInterface::CxPrivate* pCxPrivate);
static double GetMicroseconds(ScriptInterface::CmptPrivate* pCmptPrivate);
/**
* Return the template data of the given template name.
*/
static CParamNode GetTemplate(ScriptInterface::CxPrivate* pCxPrivate, const std::string& templateName);
static CParamNode GetTemplate(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& templateName);
/**
* Check whether the given template exists.
*/
static bool TemplateExists(ScriptInterface::CxPrivate* pCxPrivate, const std::string& templateName);
static bool TemplateExists(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& templateName);
/**
* Returns all template names of simulation entity templates.
*/
static std::vector<std::string> FindTemplates(ScriptInterface::CxPrivate* pCxPrivate, const std::string& path, bool includeSubdirectories);
static std::vector<std::string> FindTemplates(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& path, bool includeSubdirectories);
/**
* Returns all template names of actors.
*/
static std::vector<std::string> FindActorTemplates(ScriptInterface::CxPrivate* pCxPrivate, const std::string& path, bool includeSubdirectories);
static std::vector<std::string> FindActorTemplates(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& path, bool includeSubdirectories);
/**
* Perform map generation in an independent thread.

View File

@ -28,7 +28,7 @@
#include "scriptinterface/ScriptInterface.h"
#define IMPLEMENT_BOOLEAN_SCRIPT_SETTING(NAME) \
bool JSI_GameView::Get##NAME##Enabled(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) \
bool JSI_GameView::Get##NAME##Enabled(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate)) \
{ \
if (!g_Game || !g_Game->GetView()) \
{ \
@ -38,7 +38,7 @@ bool JSI_GameView::Get##NAME##Enabled(ScriptInterface::CxPrivate* UNUSED(pCxPriv
return g_Game->GetView()->Get##NAME##Enabled(); \
} \
\
void JSI_GameView::Set##NAME##Enabled(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), bool Enabled) \
void JSI_GameView::Set##NAME##Enabled(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), bool Enabled) \
{ \
if (!g_Game || !g_Game->GetView()) \
{ \
@ -68,9 +68,9 @@ void JSI_GameView::RegisterScriptFunctions_Settings(const ScriptInterface& scrip
#undef REGISTER_BOOLEAN_SCRIPT_SETTING
JS::Value JSI_GameView::GetCameraPivot(ScriptInterface::CxPrivate* pCxPrivate)
JS::Value JSI_GameView::GetCameraPivot(ScriptInterface::CmptPrivate* pCmptPrivate)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
CVector3D pivot(-1, -1, -1);
if (g_Game && g_Game->GetView())
pivot = g_Game->GetView()->GetCameraPivot();
@ -83,7 +83,7 @@ JS::Value JSI_GameView::GetCameraPivot(ScriptInterface::CxPrivate* pCxPrivate)
/**
* Move camera to a 2D location.
*/
void JSI_GameView::CameraMoveTo(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), entity_pos_t x, entity_pos_t z)
void JSI_GameView::CameraMoveTo(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), entity_pos_t x, entity_pos_t z)
{
if (!g_Game || !g_Game->GetWorld() || !g_Game->GetView() || !g_Game->GetWorld()->GetTerrain())
return;
@ -101,7 +101,7 @@ void JSI_GameView::CameraMoveTo(ScriptInterface::CxPrivate* UNUSED(pCxPrivate),
/**
* Set the camera to look at the given location.
*/
void JSI_GameView::SetCameraTarget(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), float x, float y, float z)
void JSI_GameView::SetCameraTarget(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), float x, float y, float z)
{
g_Game->GetView()->ResetCameraTarget(CVector3D(x, y, z));
}
@ -109,7 +109,7 @@ void JSI_GameView::SetCameraTarget(ScriptInterface::CxPrivate* UNUSED(pCxPrivate
/**
* Set the data (position, orientation and zoom) of the camera.
*/
void JSI_GameView::SetCameraData(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), entity_pos_t x, entity_pos_t y, entity_pos_t z, entity_pos_t rotx, entity_pos_t roty, entity_pos_t zoom)
void JSI_GameView::SetCameraData(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), entity_pos_t x, entity_pos_t y, entity_pos_t z, entity_pos_t rotx, entity_pos_t roty, entity_pos_t zoom)
{
if (!g_Game || !g_Game->GetWorld() || !g_Game->GetView() || !g_Game->GetWorld()->GetTerrain())
return;
@ -126,7 +126,7 @@ void JSI_GameView::SetCameraData(ScriptInterface::CxPrivate* UNUSED(pCxPrivate),
* Start / stop camera following mode.
* @param entityid unit id to follow. If zero, stop following mode
*/
void JSI_GameView::CameraFollow(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), entity_id_t entityid)
void JSI_GameView::CameraFollow(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), entity_id_t entityid)
{
if (!g_Game || !g_Game->GetView())
return;
@ -138,7 +138,7 @@ void JSI_GameView::CameraFollow(ScriptInterface::CxPrivate* UNUSED(pCxPrivate),
* Start / stop first-person camera following mode.
* @param entityid unit id to follow. If zero, stop following mode.
*/
void JSI_GameView::CameraFollowFPS(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), entity_id_t entityid)
void JSI_GameView::CameraFollowFPS(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), entity_id_t entityid)
{
if (!g_Game || !g_Game->GetView())
return;
@ -146,7 +146,7 @@ void JSI_GameView::CameraFollowFPS(ScriptInterface::CxPrivate* UNUSED(pCxPrivate
g_Game->GetView()->FollowEntity(entityid, true);
}
entity_id_t JSI_GameView::GetFollowedEntity(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
entity_id_t JSI_GameView::GetFollowedEntity(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
if (!g_Game || !g_Game->GetView())
return INVALID_ENTITY;
@ -154,7 +154,7 @@ entity_id_t JSI_GameView::GetFollowedEntity(ScriptInterface::CxPrivate* UNUSED(p
return g_Game->GetView()->GetFollowedEntity();
}
CFixedVector3D JSI_GameView::GetTerrainAtScreenPoint(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), int x, int y)
CFixedVector3D JSI_GameView::GetTerrainAtScreenPoint(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), int x, int y)
{
CVector3D pos = g_Game->GetView()->GetCamera()->GetWorldCoordinates(x, y, true);
return CFixedVector3D(fixed::FromFloat(pos.X), fixed::FromFloat(pos.Y), fixed::FromFloat(pos.Z));

View File

@ -24,8 +24,8 @@
#include "simulation2/system/Entity.h"
#define DECLARE_BOOLEAN_SCRIPT_SETTING(NAME) \
bool Get##NAME##Enabled(ScriptInterface::CxPrivate* pCxPrivate); \
void Set##NAME##Enabled(ScriptInterface::CxPrivate* pCxPrivate, bool Enabled);
bool Get##NAME##Enabled(ScriptInterface::CmptPrivate* pCmptPrivate); \
void Set##NAME##Enabled(ScriptInterface::CmptPrivate* pCmptPrivate, bool Enabled);
namespace JSI_GameView
{
@ -36,14 +36,14 @@ namespace JSI_GameView
DECLARE_BOOLEAN_SCRIPT_SETTING(LockCullCamera);
DECLARE_BOOLEAN_SCRIPT_SETTING(ConstrainCamera);
JS::Value GetCameraPivot(ScriptInterface::CxPrivate* pCxPrivate);
void CameraMoveTo(ScriptInterface::CxPrivate* pCxPrivate, entity_pos_t x, entity_pos_t z);
void SetCameraTarget(ScriptInterface::CxPrivate* pCxPrivate, float x, float y, float z);
void SetCameraData(ScriptInterface::CxPrivate* pCxPrivate, entity_pos_t x, entity_pos_t y, entity_pos_t z, entity_pos_t rotx, entity_pos_t roty, entity_pos_t zoom);
void CameraFollow(ScriptInterface::CxPrivate* pCxPrivate, entity_id_t entityid);
void CameraFollowFPS(ScriptInterface::CxPrivate* pCxPrivate, entity_id_t entityid);
entity_id_t GetFollowedEntity(ScriptInterface::CxPrivate* pCxPrivate);
CFixedVector3D GetTerrainAtScreenPoint(ScriptInterface::CxPrivate* pCxPrivate, int x, int y);
JS::Value GetCameraPivot(ScriptInterface::CmptPrivate* pCmptPrivate);
void CameraMoveTo(ScriptInterface::CmptPrivate* pCmptPrivate, entity_pos_t x, entity_pos_t z);
void SetCameraTarget(ScriptInterface::CmptPrivate* pCmptPrivate, float x, float y, float z);
void SetCameraData(ScriptInterface::CmptPrivate* pCmptPrivate, entity_pos_t x, entity_pos_t y, entity_pos_t z, entity_pos_t rotx, entity_pos_t roty, entity_pos_t zoom);
void CameraFollow(ScriptInterface::CmptPrivate* pCmptPrivate, entity_id_t entityid);
void CameraFollowFPS(ScriptInterface::CmptPrivate* pCmptPrivate, entity_id_t entityid);
entity_id_t GetFollowedEntity(ScriptInterface::CmptPrivate* pCmptPrivate);
CFixedVector3D GetTerrainAtScreenPoint(ScriptInterface::CmptPrivate* pCmptPrivate, int x, int y);
}
#undef DECLARE_BOOLEAN_SCRIPT_SETTING

View File

@ -27,31 +27,31 @@
// Note that the initData argument may only contain clonable data.
// Functions aren't supported for example!
void JSI_GUIManager::PushGuiPage(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& name, JS::HandleValue initData, JS::HandleValue callbackFunction)
void JSI_GUIManager::PushGuiPage(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& name, JS::HandleValue initData, JS::HandleValue callbackFunction)
{
g_GUI->PushPage(name, pCxPrivate->pScriptInterface->WriteStructuredClone(initData), callbackFunction);
g_GUI->PushPage(name, pCmptPrivate->pScriptInterface->WriteStructuredClone(initData), callbackFunction);
}
void JSI_GUIManager::SwitchGuiPage(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& name, JS::HandleValue initData)
void JSI_GUIManager::SwitchGuiPage(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& name, JS::HandleValue initData)
{
g_GUI->SwitchPage(name, pCxPrivate->pScriptInterface, initData);
g_GUI->SwitchPage(name, pCmptPrivate->pScriptInterface, initData);
}
void JSI_GUIManager::PopGuiPage(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue args)
void JSI_GUIManager::PopGuiPage(ScriptInterface::CmptPrivate* pCmptPrivate, JS::HandleValue args)
{
if (g_GUI->GetPageCount() < 2)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Can't pop GUI pages when less than two pages are opened!");
return;
}
g_GUI->PopPage(pCxPrivate->pScriptInterface->WriteStructuredClone(args));
g_GUI->PopPage(pCmptPrivate->pScriptInterface->WriteStructuredClone(args));
}
JS::Value JSI_GUIManager::GetGUIObjectByName(ScriptInterface::CxPrivate* pCxPrivate, const std::string& name)
JS::Value JSI_GUIManager::GetGUIObjectByName(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& name)
{
CGUI* guiPage = static_cast<CGUI*>(pCxPrivate->pCBData);
CGUI* guiPage = static_cast<CGUI*>(pCmptPrivate->pCBData);
IGUIObject* guiObj = guiPage->FindObjectByName(name);
if (!guiObj)
@ -60,36 +60,36 @@ JS::Value JSI_GUIManager::GetGUIObjectByName(ScriptInterface::CxPrivate* pCxPriv
return JS::ObjectValue(*guiObj->GetJSObject());
}
void JSI_GUIManager::SetGlobalHotkey(ScriptInterface::CxPrivate* pCxPrivate, const std::string& hotkeyTag, const std::string& eventName, JS::HandleValue function)
void JSI_GUIManager::SetGlobalHotkey(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& hotkeyTag, const std::string& eventName, JS::HandleValue function)
{
CGUI* guiPage = static_cast<CGUI*>(pCxPrivate->pCBData);
CGUI* guiPage = static_cast<CGUI*>(pCmptPrivate->pCBData);
guiPage->SetGlobalHotkey(hotkeyTag, eventName, function);
}
void JSI_GUIManager::UnsetGlobalHotkey(ScriptInterface::CxPrivate* pCxPrivate, const std::string& hotkeyTag, const std::string& eventName)
void JSI_GUIManager::UnsetGlobalHotkey(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& hotkeyTag, const std::string& eventName)
{
CGUI* guiPage = static_cast<CGUI*>(pCxPrivate->pCBData);
CGUI* guiPage = static_cast<CGUI*>(pCmptPrivate->pCBData);
guiPage->UnsetGlobalHotkey(hotkeyTag, eventName);
}
std::wstring JSI_GUIManager::SetCursor(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& name)
std::wstring JSI_GUIManager::SetCursor(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& name)
{
std::wstring old = g_CursorName;
g_CursorName = name;
return old;
}
void JSI_GUIManager::ResetCursor(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_GUIManager::ResetCursor(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
g_CursorName = g_DefaultCursor;
}
bool JSI_GUIManager::TemplateExists(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& templateName)
bool JSI_GUIManager::TemplateExists(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& templateName)
{
return g_GUI->TemplateExists(templateName);
}
CParamNode JSI_GUIManager::GetTemplate(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& templateName)
CParamNode JSI_GUIManager::GetTemplate(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& templateName)
{
return g_GUI->GetTemplate(templateName);
}

View File

@ -23,16 +23,16 @@
namespace JSI_GUIManager
{
void PushGuiPage(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& name, JS::HandleValue initData, JS::HandleValue callbackFunction);
void SwitchGuiPage(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& name, JS::HandleValue initData);
void PopGuiPage(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue args);
JS::Value GetGUIObjectByName(ScriptInterface::CxPrivate* pCxPrivate, const std::string& name);
void SetGlobalHotkey(ScriptInterface::CxPrivate* pCxPrivate, const std::string& hotkeyTag, const std::string& eventName, JS::HandleValue function);
void UnsetGlobalHotkey(ScriptInterface::CxPrivate* pCxPrivate, const std::string& hotkeyTag, const std::string& eventName);
std::wstring SetCursor(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& name);
void ResetCursor(ScriptInterface::CxPrivate* pCxPrivate);
bool TemplateExists(ScriptInterface::CxPrivate* pCxPrivate, const std::string& templateName);
CParamNode GetTemplate(ScriptInterface::CxPrivate* pCxPrivate, const std::string& templateName);
void PushGuiPage(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& name, JS::HandleValue initData, JS::HandleValue callbackFunction);
void SwitchGuiPage(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& name, JS::HandleValue initData);
void PopGuiPage(ScriptInterface::CmptPrivate* pCmptPrivate, JS::HandleValue args);
JS::Value GetGUIObjectByName(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& name);
void SetGlobalHotkey(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& hotkeyTag, const std::string& eventName, JS::HandleValue function);
void UnsetGlobalHotkey(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& hotkeyTag, const std::string& eventName);
std::wstring SetCursor(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& name);
void ResetCursor(ScriptInterface::CmptPrivate* pCmptPrivate);
bool TemplateExists(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& templateName);
CParamNode GetTemplate(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& templateName);
void RegisterScriptFunctions(const ScriptInterface& scriptInterface);
}

View File

@ -24,37 +24,37 @@
#include "scriptinterface/ScriptInterface.h"
// Returns a translation of the specified English string into the current language.
std::wstring JSI_L10n::Translate(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& sourceString)
std::wstring JSI_L10n::Translate(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& sourceString)
{
return wstring_from_utf8(g_L10n.Translate(utf8_from_wstring(sourceString)));
}
// Returns a translation of the specified English string, for the specified context.
std::wstring JSI_L10n::TranslateWithContext(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& context, const std::wstring& sourceString)
std::wstring JSI_L10n::TranslateWithContext(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& context, const std::wstring& sourceString)
{
return wstring_from_utf8(g_L10n.TranslateWithContext(context, utf8_from_wstring(sourceString)));
}
// Return a translated version of the given strings (singular and plural) depending on an integer value.
std::wstring JSI_L10n::TranslatePlural(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& singularSourceString, const std::wstring& pluralSourceString, int number)
std::wstring JSI_L10n::TranslatePlural(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& singularSourceString, const std::wstring& pluralSourceString, int number)
{
return wstring_from_utf8(g_L10n.TranslatePlural(utf8_from_wstring(singularSourceString), utf8_from_wstring(pluralSourceString), number));
}
// Return a translated version of the given strings (singular and plural) depending on an integer value, for the specified context.
std::wstring JSI_L10n::TranslatePluralWithContext(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& context, const std::wstring& singularSourceString, const std::wstring& pluralSourceString, int number)
std::wstring JSI_L10n::TranslatePluralWithContext(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& context, const std::wstring& singularSourceString, const std::wstring& pluralSourceString, int number)
{
return wstring_from_utf8(g_L10n.TranslatePluralWithContext(context, utf8_from_wstring(singularSourceString), utf8_from_wstring(pluralSourceString), number));
}
// Return a translated version of the given string, localizing it line by line.
std::wstring JSI_L10n::TranslateLines(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& sourceString)
std::wstring JSI_L10n::TranslateLines(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& sourceString)
{
return wstring_from_utf8(g_L10n.TranslateLines(utf8_from_wstring(sourceString)));
}
// Return a translated version of the items in the specified array.
std::vector<std::wstring> JSI_L10n::TranslateArray(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::vector<std::wstring>& sourceArray)
std::vector<std::wstring> JSI_L10n::TranslateArray(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::vector<std::wstring>& sourceArray)
{
std::vector<std::wstring> translatedArray;
for (const std::wstring& elem : sourceArray)
@ -63,95 +63,95 @@ std::vector<std::wstring> JSI_L10n::TranslateArray(ScriptInterface::CxPrivate* U
return translatedArray;
}
std::wstring JSI_L10n::GetFallbackToAvailableDictLocale(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale)
std::wstring JSI_L10n::GetFallbackToAvailableDictLocale(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& locale)
{
return g_L10n.GetFallbackToAvailableDictLocale(locale);
}
// Return a localized version of a time given in milliseconds.
std::wstring JSI_L10n::FormatMillisecondsIntoDateStringLocal(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), UDate milliseconds, const std::wstring& formatString)
std::wstring JSI_L10n::FormatMillisecondsIntoDateStringLocal(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), UDate milliseconds, const std::wstring& formatString)
{
return wstring_from_utf8(g_L10n.FormatMillisecondsIntoDateString(milliseconds, utf8_from_wstring(formatString), true));
}
// Return a localized version of a duration or a time in GMT given in milliseconds.
std::wstring JSI_L10n::FormatMillisecondsIntoDateStringGMT(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), UDate milliseconds, const std::wstring& formatString)
std::wstring JSI_L10n::FormatMillisecondsIntoDateStringGMT(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), UDate milliseconds, const std::wstring& formatString)
{
return wstring_from_utf8(g_L10n.FormatMillisecondsIntoDateString(milliseconds, utf8_from_wstring(formatString), false));
}
// Return a localized version of the given decimal number.
std::wstring JSI_L10n::FormatDecimalNumberIntoString(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), double number)
std::wstring JSI_L10n::FormatDecimalNumberIntoString(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), double number)
{
return wstring_from_utf8(g_L10n.FormatDecimalNumberIntoString(number));
}
std::vector<std::string> JSI_L10n::GetSupportedLocaleBaseNames(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
std::vector<std::string> JSI_L10n::GetSupportedLocaleBaseNames(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return g_L10n.GetSupportedLocaleBaseNames();
}
std::vector<std::wstring> JSI_L10n::GetSupportedLocaleDisplayNames(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
std::vector<std::wstring> JSI_L10n::GetSupportedLocaleDisplayNames(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return g_L10n.GetSupportedLocaleDisplayNames();
}
std::string JSI_L10n::GetCurrentLocale(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
std::string JSI_L10n::GetCurrentLocale(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return g_L10n.GetCurrentLocaleString();
}
bool JSI_L10n::UseLongStrings(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
bool JSI_L10n::UseLongStrings(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return g_L10n.UseLongStrings();
}
std::vector<std::string> JSI_L10n::GetAllLocales(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
std::vector<std::string> JSI_L10n::GetAllLocales(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return g_L10n.GetAllLocales();
}
std::string JSI_L10n::GetDictionaryLocale(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& configLocale)
std::string JSI_L10n::GetDictionaryLocale(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& configLocale)
{
return g_L10n.GetDictionaryLocale(configLocale);
}
std::vector<std::wstring> JSI_L10n::GetDictionariesForLocale(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale)
std::vector<std::wstring> JSI_L10n::GetDictionariesForLocale(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& locale)
{
return g_L10n.GetDictionariesForLocale(locale);
}
std::string JSI_L10n::GetLocaleLanguage(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale)
std::string JSI_L10n::GetLocaleLanguage(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& locale)
{
return g_L10n.GetLocaleLanguage(locale);
}
std::string JSI_L10n::GetLocaleBaseName(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale)
std::string JSI_L10n::GetLocaleBaseName(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& locale)
{
return g_L10n.GetLocaleBaseName(locale);
}
std::string JSI_L10n::GetLocaleCountry(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale)
std::string JSI_L10n::GetLocaleCountry(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& locale)
{
return g_L10n.GetLocaleCountry(locale);
}
std::string JSI_L10n::GetLocaleScript(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale)
std::string JSI_L10n::GetLocaleScript(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& locale)
{
return g_L10n.GetLocaleScript(locale);
}
bool JSI_L10n::ValidateLocale(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale)
bool JSI_L10n::ValidateLocale(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& locale)
{
return g_L10n.ValidateLocale(locale);
}
bool JSI_L10n::SaveLocale(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale)
bool JSI_L10n::SaveLocale(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& locale)
{
return g_L10n.SaveLocale(locale);
}
void JSI_L10n::ReevaluateCurrentLocaleAndReload(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_L10n::ReevaluateCurrentLocaleAndReload(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
g_L10n.ReevaluateCurrentLocaleAndReload();
}

View File

@ -50,12 +50,12 @@ namespace JSI_L10n
*
* This is a JavaScript interface to L10n::Translate().
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
* @param sourceString String to translate to the current locale.
* @return Translation of @p sourceString to the current locale, or
* @p sourceString if there is no translation available.
*/
std::wstring Translate(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& sourceString);
std::wstring Translate(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& sourceString);
/**
* Returns the translation of the specified string to the
@ -64,7 +64,7 @@ namespace JSI_L10n
*
* This is a JavaScript interface to L10n::TranslateWithContext().
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
* @param context Context where the string is used. See
* http://www.gnu.org/software/gettext/manual/html_node/Contexts.html
* @param sourceString String to translate to the current locale.
@ -72,7 +72,7 @@ namespace JSI_L10n
* specified @p context, or @p sourceString if there is no
* translation available.
*/
std::wstring TranslateWithContext(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& context, const std::wstring& sourceString);
std::wstring TranslateWithContext(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& context, const std::wstring& sourceString);
/**
* Returns the translation of the specified string to the
@ -81,7 +81,7 @@ namespace JSI_L10n
*
* This is a JavaScript interface to L10n::TranslatePlural().
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
* @param singularSourceString String to translate to the current locale,
* in English singular form.
* @param pluralSourceString String to translate to the current locale, in
@ -93,7 +93,7 @@ namespace JSI_L10n
* @p number is 1) or @p pluralSourceString (if @p number is not 1)
* if there is no translation available.
*/
std::wstring TranslatePlural(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& singularSourceString, const std::wstring& pluralSourceString, int number);
std::wstring TranslatePlural(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& singularSourceString, const std::wstring& pluralSourceString, int number);
/**
* Returns the translation of the specified string to the
@ -102,7 +102,7 @@ namespace JSI_L10n
*
* This is a JavaScript interface to L10n::TranslatePluralWithContext().
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
* @param context Context where the string is used. See
* http://www.gnu.org/software/gettext/manual/html_node/Contexts.html
* @param singularSourceString String to translate to the current locale,
@ -117,7 +117,7 @@ namespace JSI_L10n
* @p pluralSourceString (if @p number is not 1) if there is no
* translation available.
*/
std::wstring TranslatePluralWithContext(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& context, const std::wstring& singularSourceString, const std::wstring& pluralSourceString, int number);
std::wstring TranslatePluralWithContext(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& context, const std::wstring& singularSourceString, const std::wstring& pluralSourceString, int number);
/**
* Translates a text line by line to the
@ -128,13 +128,13 @@ namespace JSI_L10n
*
* This is a JavaScript interface to L10n::TranslateLines().
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
* @param sourceString Text to translate to the current locale.
* @return Line by line translation of @p sourceString to the current
* locale. Some of the lines in the returned text may be in English
* because there was not translation available for them.
*/
std::wstring TranslateLines(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& sourceString);
std::wstring TranslateLines(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& sourceString);
/**
* Translate each of the strings of a JavaScript array to the
@ -143,14 +143,14 @@ namespace JSI_L10n
* This is a helper function that loops through the items of the input array
* and calls L10n::Translate() on each of them.
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
* @param sourceArray JavaScript array of strings to translate to the
* current locale.
* @return Item by item translation of @p sourceArray to the current locale.
* Some of the items in the returned array may be in English because
* there was not translation available for them.
*/
std::vector<std::wstring> TranslateArray(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::vector<std::wstring>& sourceArray);
std::vector<std::wstring> TranslateArray(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::vector<std::wstring>& sourceArray);
/**
* Returns the specified date converted to the local timezone using the specified date format.
@ -158,7 +158,7 @@ namespace JSI_L10n
* This is a JavaScript interface to
* L10n::FormatMillisecondsIntoDateString().
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
* @param milliseconds Date specified as a UNIX timestamp in milliseconds
* (not seconds). If you have a JavaScript @c Date object, you can
* use @c Date.getTime() to obtain the UNIX time in milliseconds.
@ -172,7 +172,7 @@ namespace JSI_L10n
* @sa http://en.wikipedia.org/wiki/Unix_time
* @sa https://sites.google.com/site/icuprojectuserguide/formatparse/datetime?pli=1#TOC-Date-Field-Symbol-Table
*/
std::wstring FormatMillisecondsIntoDateStringLocal(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), UDate milliseconds, const std::wstring& formatString);
std::wstring FormatMillisecondsIntoDateStringLocal(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), UDate milliseconds, const std::wstring& formatString);
/**
* Returns the specified date in GMT using the specified date format.
@ -180,7 +180,7 @@ namespace JSI_L10n
* This is a JavaScript interface to
* L10n::FormatMillisecondsIntoDateString().
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
* @param milliseconds Date specified as a UNIX timestamp in milliseconds
* (not seconds). If you have a JavaScript @c Date object, you can
* use @c Date.getTime() to obtain the UNIX time in milliseconds.
@ -194,7 +194,7 @@ namespace JSI_L10n
* @sa http://en.wikipedia.org/wiki/Unix_time
* @sa https://sites.google.com/site/icuprojectuserguide/formatparse/datetime?pli=1#TOC-Date-Field-Symbol-Table
*/
std::wstring FormatMillisecondsIntoDateStringGMT(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), UDate milliseconds, const std::wstring& formatString);
std::wstring FormatMillisecondsIntoDateStringGMT(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), UDate milliseconds, const std::wstring& formatString);
/**
* Returns the specified floating-point number as a string, with the number
@ -203,11 +203,11 @@ namespace JSI_L10n
*
* This is a JavaScript interface to L10n::FormatDecimalNumberIntoString().
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
* @param number Number to format.
* @return Decimal number formatted using the current locale.
*/
std::wstring FormatDecimalNumberIntoString(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), double number);
std::wstring FormatDecimalNumberIntoString(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), double number);
/**
* Returns an array of supported locale codes sorted alphabetically.
@ -220,7 +220,7 @@ namespace JSI_L10n
*
* This is a JavaScript interface to L10n::GetSupportedLocaleBaseNames().
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
* @return Array of supported locale codes.
*
* @sa GetSupportedLocaleDisplayNames()
@ -229,7 +229,7 @@ namespace JSI_L10n
*
* @sa http://trac.wildfiregames.com/wiki/Implementation_of_Internationalization_and_Localization#LongStringsLocale
*/
std::vector<std::string> GetSupportedLocaleBaseNames(ScriptInterface::CxPrivate* UNUSED(pCxPrivate));
std::vector<std::string> GetSupportedLocaleBaseNames(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate));
/**
* Returns an array of supported locale names sorted alphabetically by
@ -243,14 +243,14 @@ namespace JSI_L10n
*
* This is a JavaScript interface to L10n::GetSupportedLocaleDisplayNames().
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
* @return Array of supported locale codes.
*
* @sa GetSupportedLocaleBaseNames()
*
* @sa http://trac.wildfiregames.com/wiki/Implementation_of_Internationalization_and_Localization#LongStringsLocale
*/
std::vector<std::wstring> GetSupportedLocaleDisplayNames(ScriptInterface::CxPrivate* UNUSED(pCxPrivate));
std::vector<std::wstring> GetSupportedLocaleDisplayNames(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate));
/**
* Returns the code of the current locale.
@ -259,13 +259,13 @@ namespace JSI_L10n
*
* This is a JavaScript interface to L10n::GetCurrentLocaleString().
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
*
* @sa GetSupportedLocaleBaseNames()
* @sa GetAllLocales()
* @sa ReevaluateCurrentLocaleAndReload()
*/
std::string GetCurrentLocale(ScriptInterface::CxPrivate* UNUSED(pCxPrivate));
std::string GetCurrentLocale(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate));
/**
* Returns an array of locale codes supported by ICU.
@ -274,7 +274,7 @@ namespace JSI_L10n
*
* This is a JavaScript interface to L10n::GetAllLocales().
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
* @return Array of supported locale codes.
*
* @sa GetSupportedLocaleBaseNames()
@ -282,7 +282,7 @@ namespace JSI_L10n
*
* @sa http://www.icu-project.org/apiref/icu4c/classicu_1_1Locale.html#a073d70df8c9c8d119c0d42d70de24137
*/
std::vector<std::string> GetAllLocales(ScriptInterface::CxPrivate* UNUSED(pCxPrivate));
std::vector<std::string> GetAllLocales(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate));
/**
* Returns the code of the recommended locale for the current user that the
@ -301,14 +301,14 @@ namespace JSI_L10n
*
* This is a JavaScript interface to L10n::GetDictionaryLocale(std::string).
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
* @param configLocale Locale to check for support first. Pass an empty
* string to check the system locale directly.
* @return Code of a locale that the game supports.
*
* @sa http://trac.wildfiregames.com/wiki/Implementation_of_Internationalization_and_Localization#LongStringsLocale
*/
std::string GetDictionaryLocale(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& configLocale);
std::string GetDictionaryLocale(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& configLocale);
/**
* Returns an array of paths to files in the virtual filesystem that provide
@ -316,12 +316,12 @@ namespace JSI_L10n
*
* This is a JavaScript interface to L10n::GetDictionariesForLocale().
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
* @param locale Locale code.
* @return Array of paths to files in the virtual filesystem that provide
* translations for @p locale.
*/
std::vector<std::wstring> GetDictionariesForLocale(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale);
std::vector<std::wstring> GetDictionariesForLocale(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& locale);
/**
* Returns the ISO-639 language code of the specified locale code.
@ -330,26 +330,26 @@ namespace JSI_L10n
*
* This is a JavaScript interface to L10n::GetLocaleLanguage().
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
* @param locale Locale code.
* @return Language code.
*
* @sa http://www.icu-project.org/apiref/icu4c/classicu_1_1Locale.html#af36d821adced72a870d921ebadd0ca93
*/
std::string GetLocaleLanguage(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale);
std::string GetLocaleLanguage(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& locale);
/**
* Returns the programmatic code of the entire locale without keywords.
*
* This is a JavaScript interface to L10n::GetLocaleBaseName().
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
* @param locale Locale code.
* @return Locale code without keywords.
*
* @sa http://www.icu-project.org/apiref/icu4c/classicu_1_1Locale.html#a4c1acbbdf95dc15599db5f322fa4c4d0
*/
std::string GetLocaleBaseName(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale);
std::string GetLocaleBaseName(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& locale);
/**
* Returns the ISO-3166 country code of the specified locale code.
@ -358,29 +358,29 @@ namespace JSI_L10n
*
* This is a JavaScript interface to L10n::GetLocaleCountry().
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
* @param locale Locale code.
* @return Country code.
*
* @sa http://www.icu-project.org/apiref/icu4c/classicu_1_1Locale.html#ae3f1fc415c00d4f0ab33288ceadccbf9
*/
std::string GetLocaleCountry(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale);
std::string GetLocaleCountry(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& locale);
/**
* Returns the ISO-15924 abbreviation script code of the specified locale code.
*
* This is a JavaScript interface to L10n::GetLocaleScript().
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
* @param locale Locale code.
* @return Script code.
*
* @sa http://www.icu-project.org/apiref/icu4c/classicu_1_1Locale.html#a5e0145a339d30794178a1412dcc55abe
*/
std::string GetLocaleScript(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale);
std::string GetLocaleScript(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& locale);
std::wstring GetFallbackToAvailableDictLocale(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale);
std::wstring GetFallbackToAvailableDictLocale(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& locale);
/**
* Returns @c true if the current locale is the special Long Strings
@ -388,11 +388,11 @@ namespace JSI_L10n
*
* This is a JavaScript interface to L10n::UseLongStrings().
*
* @param pCxPrivate JavaScript context. *
* @param pCmptPrivate JavaScript context. *
* @return Whether the current locale is the special Long Strings
* (@c true) or not (@c false).
*/
bool UseLongStrings(ScriptInterface::CxPrivate* UNUSED(pCxPrivate));
bool UseLongStrings(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate));
/**
* Returns @c true if the locale is supported by both ICU and the game. It
@ -406,12 +406,12 @@ namespace JSI_L10n
*
* This is a JavaScript interface to L10n::ValidateLocale(const std::string&).
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
* @param locale Locale to check.
* @return Whether @p locale is supported by both ICU and the game (@c true)
* or not (@c false).
*/
bool ValidateLocale(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale);
bool ValidateLocale(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& locale);
/**
* Saves the specified locale in the game configuration file.
@ -425,12 +425,12 @@ namespace JSI_L10n
*
* This is a JavaScript interface to L10n::SaveLocale().
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
* @param locale Locale to save to the configuration file.
* @return Whether the specified locale is valid (@c true) or not
* (@c false).
*/
bool SaveLocale(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale);
bool SaveLocale(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& locale);
/**
* Determines the best, supported locale for the current user, makes it the
@ -445,11 +445,11 @@ namespace JSI_L10n
*
* This is a JavaScript interface to L10n::ReevaluateCurrentLocaleAndReload().
*
* @param pCxPrivate JavaScript context.
* @param pCmptPrivate JavaScript context.
*
* @sa GetCurrentLocale()
*/
void ReevaluateCurrentLocaleAndReload(ScriptInterface::CxPrivate* UNUSED(pCxPrivate));
void ReevaluateCurrentLocaleAndReload(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate));
}
#endif // INCLUDED_JSINTERFACE_L10N

View File

@ -71,23 +71,23 @@ void JSI_Lobby::RegisterScriptFunctions(const ScriptInterface& scriptInterface)
#endif // CONFIG2_LOBBY
}
bool JSI_Lobby::HasXmppClient(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
bool JSI_Lobby::HasXmppClient(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return g_XmppClient;
}
void JSI_Lobby::SetRankedGame(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), bool isRanked)
void JSI_Lobby::SetRankedGame(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), bool isRanked)
{
g_rankedGame = isRanked;
}
#if CONFIG2_LOBBY
void JSI_Lobby::StartXmppClient(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& username, const std::wstring& password, const std::wstring& room, const std::wstring& nick, int historyRequestSize)
void JSI_Lobby::StartXmppClient(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& username, const std::wstring& password, const std::wstring& room, const std::wstring& nick, int historyRequestSize)
{
if (g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call StartXmppClient with an already initialized XmppClient!");
return;
}
@ -104,11 +104,11 @@ void JSI_Lobby::StartXmppClient(ScriptInterface::CxPrivate* pCxPrivate, const st
g_rankedGame = true;
}
void JSI_Lobby::StartRegisterXmppClient(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& username, const std::wstring& password)
void JSI_Lobby::StartRegisterXmppClient(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& username, const std::wstring& password)
{
if (g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call StartRegisterXmppClient with an already initialized XmppClient!");
return;
}
@ -124,11 +124,11 @@ void JSI_Lobby::StartRegisterXmppClient(ScriptInterface::CxPrivate* pCxPrivate,
true);
}
void JSI_Lobby::StopXmppClient(ScriptInterface::CxPrivate* pCxPrivate)
void JSI_Lobby::StopXmppClient(ScriptInterface::CmptPrivate* pCmptPrivate)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call StopXmppClient without an initialized XmppClient!");
return;
}
@ -137,11 +137,11 @@ void JSI_Lobby::StopXmppClient(ScriptInterface::CxPrivate* pCxPrivate)
g_rankedGame = false;
}
void JSI_Lobby::ConnectXmppClient(ScriptInterface::CxPrivate* pCxPrivate)
void JSI_Lobby::ConnectXmppClient(ScriptInterface::CmptPrivate* pCmptPrivate)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call ConnectXmppClient without an initialized XmppClient!");
return;
}
@ -149,11 +149,11 @@ void JSI_Lobby::ConnectXmppClient(ScriptInterface::CxPrivate* pCxPrivate)
g_XmppClient->connect();
}
void JSI_Lobby::DisconnectXmppClient(ScriptInterface::CxPrivate* pCxPrivate)
void JSI_Lobby::DisconnectXmppClient(ScriptInterface::CmptPrivate* pCmptPrivate)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call DisconnectXmppClient without an initialized XmppClient!");
return;
}
@ -161,11 +161,11 @@ void JSI_Lobby::DisconnectXmppClient(ScriptInterface::CxPrivate* pCxPrivate)
g_XmppClient->disconnect();
}
bool JSI_Lobby::IsXmppClientConnected(ScriptInterface::CxPrivate* pCxPrivate)
bool JSI_Lobby::IsXmppClientConnected(ScriptInterface::CmptPrivate* pCmptPrivate)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call IsXmppClientConnected without an initialized XmppClient!");
return false;
}
@ -173,11 +173,11 @@ bool JSI_Lobby::IsXmppClientConnected(ScriptInterface::CxPrivate* pCxPrivate)
return g_XmppClient->isConnected();
}
void JSI_Lobby::SendGetBoardList(ScriptInterface::CxPrivate* pCxPrivate)
void JSI_Lobby::SendGetBoardList(ScriptInterface::CmptPrivate* pCmptPrivate)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call SendGetBoardList without an initialized XmppClient!");
return;
}
@ -185,11 +185,11 @@ void JSI_Lobby::SendGetBoardList(ScriptInterface::CxPrivate* pCxPrivate)
g_XmppClient->SendIqGetBoardList();
}
void JSI_Lobby::SendGetProfile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& player)
void JSI_Lobby::SendGetProfile(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& player)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call SendGetProfile without an initialized XmppClient!");
return;
}
@ -197,23 +197,23 @@ void JSI_Lobby::SendGetProfile(ScriptInterface::CxPrivate* pCxPrivate, const std
g_XmppClient->SendIqGetProfile(utf8_from_wstring(player));
}
void JSI_Lobby::SendGameReport(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue data)
void JSI_Lobby::SendGameReport(ScriptInterface::CmptPrivate* pCmptPrivate, JS::HandleValue data)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call SendGameReport without an initialized XmppClient!");
return;
}
g_XmppClient->SendIqGameReport(*(pCxPrivate->pScriptInterface), data);
g_XmppClient->SendIqGameReport(*(pCmptPrivate->pScriptInterface), data);
}
void JSI_Lobby::SendRegisterGame(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue data)
void JSI_Lobby::SendRegisterGame(ScriptInterface::CmptPrivate* pCmptPrivate, JS::HandleValue data)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call SendRegisterGame without an initialized XmppClient!");
return;
}
@ -225,14 +225,14 @@ void JSI_Lobby::SendRegisterGame(ScriptInterface::CxPrivate* pCxPrivate, JS::Han
return;
}
g_XmppClient->SendIqRegisterGame(*(pCxPrivate->pScriptInterface), data);
g_XmppClient->SendIqRegisterGame(*(pCmptPrivate->pScriptInterface), data);
}
void JSI_Lobby::SendUnregisterGame(ScriptInterface::CxPrivate* pCxPrivate)
void JSI_Lobby::SendUnregisterGame(ScriptInterface::CmptPrivate* pCmptPrivate)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call SendUnregisterGame without an initialized XmppClient!");
return;
}
@ -240,11 +240,11 @@ void JSI_Lobby::SendUnregisterGame(ScriptInterface::CxPrivate* pCxPrivate)
g_XmppClient->SendIqUnregisterGame();
}
void JSI_Lobby::SendChangeStateGame(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nbp, const std::wstring& players)
void JSI_Lobby::SendChangeStateGame(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& nbp, const std::wstring& players)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call SendChangeStateGame without an initialized XmppClient!");
return;
}
@ -252,9 +252,9 @@ void JSI_Lobby::SendChangeStateGame(ScriptInterface::CxPrivate* pCxPrivate, cons
g_XmppClient->SendIqChangeStateGame(utf8_from_wstring(nbp), utf8_from_wstring(players));
}
JS::Value JSI_Lobby::GetPlayerList(ScriptInterface::CxPrivate* pCxPrivate)
JS::Value JSI_Lobby::GetPlayerList(ScriptInterface::CmptPrivate* pCmptPrivate)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
if (!g_XmppClient)
{
@ -263,14 +263,14 @@ JS::Value JSI_Lobby::GetPlayerList(ScriptInterface::CxPrivate* pCxPrivate)
}
JS::RootedValue playerList(rq.cx);
g_XmppClient->GUIGetPlayerList(*(pCxPrivate->pScriptInterface), &playerList);
g_XmppClient->GUIGetPlayerList(*(pCmptPrivate->pScriptInterface), &playerList);
return playerList;
}
JS::Value JSI_Lobby::GetGameList(ScriptInterface::CxPrivate* pCxPrivate)
JS::Value JSI_Lobby::GetGameList(ScriptInterface::CmptPrivate* pCmptPrivate)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
if (!g_XmppClient)
{
@ -279,14 +279,14 @@ JS::Value JSI_Lobby::GetGameList(ScriptInterface::CxPrivate* pCxPrivate)
}
JS::RootedValue gameList(rq.cx);
g_XmppClient->GUIGetGameList(*(pCxPrivate->pScriptInterface), &gameList);
g_XmppClient->GUIGetGameList(*(pCmptPrivate->pScriptInterface), &gameList);
return gameList;
}
JS::Value JSI_Lobby::GetBoardList(ScriptInterface::CxPrivate* pCxPrivate)
JS::Value JSI_Lobby::GetBoardList(ScriptInterface::CmptPrivate* pCmptPrivate)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
if (!g_XmppClient)
{
@ -295,14 +295,14 @@ JS::Value JSI_Lobby::GetBoardList(ScriptInterface::CxPrivate* pCxPrivate)
}
JS::RootedValue boardList(rq.cx);
g_XmppClient->GUIGetBoardList(*(pCxPrivate->pScriptInterface), &boardList);
g_XmppClient->GUIGetBoardList(*(pCmptPrivate->pScriptInterface), &boardList);
return boardList;
}
JS::Value JSI_Lobby::GetProfile(ScriptInterface::CxPrivate* pCxPrivate)
JS::Value JSI_Lobby::GetProfile(ScriptInterface::CmptPrivate* pCmptPrivate)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
if (!g_XmppClient)
{
@ -311,16 +311,16 @@ JS::Value JSI_Lobby::GetProfile(ScriptInterface::CxPrivate* pCxPrivate)
}
JS::RootedValue profileFetch(rq.cx);
g_XmppClient->GUIGetProfile(*(pCxPrivate->pScriptInterface), &profileFetch);
g_XmppClient->GUIGetProfile(*(pCmptPrivate->pScriptInterface), &profileFetch);
return profileFetch;
}
bool JSI_Lobby::LobbyGuiPollHasPlayerListUpdate(ScriptInterface::CxPrivate* pCxPrivate)
bool JSI_Lobby::LobbyGuiPollHasPlayerListUpdate(ScriptInterface::CmptPrivate* pCmptPrivate)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call LobbyGuiPollHasPlayerListUpdate without an initialized XmppClient!");
return false;
}
@ -328,31 +328,31 @@ bool JSI_Lobby::LobbyGuiPollHasPlayerListUpdate(ScriptInterface::CxPrivate* pCxP
return g_XmppClient->GuiPollHasPlayerListUpdate();
}
JS::Value JSI_Lobby::LobbyGuiPollNewMessages(ScriptInterface::CxPrivate* pCxPrivate)
JS::Value JSI_Lobby::LobbyGuiPollNewMessages(ScriptInterface::CmptPrivate* pCmptPrivate)
{
if (!g_XmppClient)
return JS::UndefinedValue();
return g_XmppClient->GuiPollNewMessages(*(pCxPrivate->pScriptInterface));
return g_XmppClient->GuiPollNewMessages(*(pCmptPrivate->pScriptInterface));
}
JS::Value JSI_Lobby::LobbyGuiPollHistoricMessages(ScriptInterface::CxPrivate* pCxPrivate)
JS::Value JSI_Lobby::LobbyGuiPollHistoricMessages(ScriptInterface::CmptPrivate* pCmptPrivate)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call LobbyGuiPollHistoricMessages without an initialized XmppClient!");
return JS::UndefinedValue();
}
return g_XmppClient->GuiPollHistoricMessages(*(pCxPrivate->pScriptInterface));
return g_XmppClient->GuiPollHistoricMessages(*(pCmptPrivate->pScriptInterface));
}
void JSI_Lobby::LobbySendMessage(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& message)
void JSI_Lobby::LobbySendMessage(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& message)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call LobbySendMessage without an initialized XmppClient!");
return;
}
@ -360,11 +360,11 @@ void JSI_Lobby::LobbySendMessage(ScriptInterface::CxPrivate* pCxPrivate, const s
g_XmppClient->SendMUCMessage(utf8_from_wstring(message));
}
void JSI_Lobby::LobbySetPlayerPresence(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& presence)
void JSI_Lobby::LobbySetPlayerPresence(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& presence)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call LobbySetPlayerPresence without an initialized XmppClient!");
return;
}
@ -372,11 +372,11 @@ void JSI_Lobby::LobbySetPlayerPresence(ScriptInterface::CxPrivate* pCxPrivate, c
g_XmppClient->SetPresence(utf8_from_wstring(presence));
}
void JSI_Lobby::LobbySetNick(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nick)
void JSI_Lobby::LobbySetNick(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& nick)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call LobbySetNick without an initialized XmppClient!");
return;
}
@ -384,11 +384,11 @@ void JSI_Lobby::LobbySetNick(ScriptInterface::CxPrivate* pCxPrivate, const std::
g_XmppClient->SetNick(utf8_from_wstring(nick));
}
std::wstring JSI_Lobby::LobbyGetNick(ScriptInterface::CxPrivate* pCxPrivate)
std::wstring JSI_Lobby::LobbyGetNick(ScriptInterface::CmptPrivate* pCmptPrivate)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call LobbyGetNick without an initialized XmppClient!");
return std::wstring();
}
@ -398,11 +398,11 @@ std::wstring JSI_Lobby::LobbyGetNick(ScriptInterface::CxPrivate* pCxPrivate)
return wstring_from_utf8(nick);
}
void JSI_Lobby::LobbyKick(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nick, const std::wstring& reason)
void JSI_Lobby::LobbyKick(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& nick, const std::wstring& reason)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call LobbyKick without an initialized XmppClient!");
return;
}
@ -410,11 +410,11 @@ void JSI_Lobby::LobbyKick(ScriptInterface::CxPrivate* pCxPrivate, const std::wst
g_XmppClient->kick(utf8_from_wstring(nick), utf8_from_wstring(reason));
}
void JSI_Lobby::LobbyBan(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nick, const std::wstring& reason)
void JSI_Lobby::LobbyBan(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& nick, const std::wstring& reason)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call LobbyBan without an initialized XmppClient!");
return;
}
@ -422,11 +422,11 @@ void JSI_Lobby::LobbyBan(ScriptInterface::CxPrivate* pCxPrivate, const std::wstr
g_XmppClient->ban(utf8_from_wstring(nick), utf8_from_wstring(reason));
}
const char* JSI_Lobby::LobbyGetPlayerPresence(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nickname)
const char* JSI_Lobby::LobbyGetPlayerPresence(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& nickname)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call LobbyGetPlayerPresence without an initialized XmppClient!");
return "";
}
@ -434,11 +434,11 @@ const char* JSI_Lobby::LobbyGetPlayerPresence(ScriptInterface::CxPrivate* pCxPri
return g_XmppClient->GetPresence(utf8_from_wstring(nickname));
}
const char* JSI_Lobby::LobbyGetPlayerRole(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nickname)
const char* JSI_Lobby::LobbyGetPlayerRole(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& nickname)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call LobbyGetPlayerRole without an initialized XmppClient!");
return "";
}
@ -446,11 +446,11 @@ const char* JSI_Lobby::LobbyGetPlayerRole(ScriptInterface::CxPrivate* pCxPrivate
return g_XmppClient->GetRole(utf8_from_wstring(nickname));
}
std::wstring JSI_Lobby::LobbyGetPlayerRating(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nickname)
std::wstring JSI_Lobby::LobbyGetPlayerRating(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& nickname)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call LobbyGetPlayerRating without an initialized XmppClient!");
return std::wstring();
}
@ -500,16 +500,16 @@ std::string JSI_Lobby::EncryptPassword(const std::string& password, const std::s
return CStr(Hexify(encrypted, DIGESTSIZE)).UpperCase();
}
std::wstring JSI_Lobby::EncryptPassword(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& pass, const std::wstring& user)
std::wstring JSI_Lobby::EncryptPassword(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& pass, const std::wstring& user)
{
return wstring_from_utf8(JSI_Lobby::EncryptPassword(utf8_from_wstring(pass), utf8_from_wstring(user)));
}
std::wstring JSI_Lobby::LobbyGetRoomSubject(ScriptInterface::CxPrivate* pCxPrivate)
std::wstring JSI_Lobby::LobbyGetRoomSubject(ScriptInterface::CmptPrivate* pCmptPrivate)
{
if (!g_XmppClient)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Cannot call LobbyGetRoomSubject without an initialized XmppClient!");
return std::wstring();
}

View File

@ -27,46 +27,46 @@ namespace JSI_Lobby
{
void RegisterScriptFunctions(const ScriptInterface& scriptInterface);
bool HasXmppClient(ScriptInterface::CxPrivate* pCxPrivate);
bool IsRankedGame(ScriptInterface::CxPrivate* pCxPrivate);
void SetRankedGame(ScriptInterface::CxPrivate* pCxPrivate, bool isRanked);
bool HasXmppClient(ScriptInterface::CmptPrivate* pCmptPrivate);
bool IsRankedGame(ScriptInterface::CmptPrivate* pCmptPrivate);
void SetRankedGame(ScriptInterface::CmptPrivate* pCmptPrivate, bool isRanked);
#if CONFIG2_LOBBY
void StartXmppClient(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& username, const std::wstring& password, const std::wstring& room, const std::wstring& nick, int historyRequestSize);
void StartRegisterXmppClient(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& username, const std::wstring& password);
void StopXmppClient(ScriptInterface::CxPrivate* pCxPrivate);
void ConnectXmppClient(ScriptInterface::CxPrivate* pCxPrivate);
void DisconnectXmppClient(ScriptInterface::CxPrivate* pCxPrivate);
bool IsXmppClientConnected(ScriptInterface::CxPrivate* pCxPrivate);
void SendGetBoardList(ScriptInterface::CxPrivate* pCxPrivate);
void SendGetProfile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& player);
void SendGameReport(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue data);
void SendRegisterGame(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue data);
void SendUnregisterGame(ScriptInterface::CxPrivate* pCxPrivate);
void SendChangeStateGame(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nbp, const std::wstring& players);
JS::Value GetPlayerList(ScriptInterface::CxPrivate* pCxPrivate);
JS::Value GetGameList(ScriptInterface::CxPrivate* pCxPrivate);
JS::Value GetBoardList(ScriptInterface::CxPrivate* pCxPrivate);
JS::Value GetProfile(ScriptInterface::CxPrivate* pCxPrivate);
JS::Value LobbyGuiPollNewMessages(ScriptInterface::CxPrivate* pCxPrivate);
JS::Value LobbyGuiPollHistoricMessages(ScriptInterface::CxPrivate* pCxPrivate);
bool LobbyGuiPollHasPlayerListUpdate(ScriptInterface::CxPrivate* pCxPrivate);
void LobbySendMessage(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& message);
void LobbySetPlayerPresence(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& presence);
void LobbySetNick(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nick);
std::wstring LobbyGetNick(ScriptInterface::CxPrivate* pCxPrivate);
void LobbyKick(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nick, const std::wstring& reason);
void LobbyBan(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nick, const std::wstring& reason);
const char* LobbyGetPlayerPresence(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nickname);
const char* LobbyGetPlayerRole(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nickname);
std::wstring LobbyGetPlayerRating(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& nickname);
std::wstring LobbyGetRoomSubject(ScriptInterface::CxPrivate* pCxPrivate);
void StartXmppClient(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& username, const std::wstring& password, const std::wstring& room, const std::wstring& nick, int historyRequestSize);
void StartRegisterXmppClient(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& username, const std::wstring& password);
void StopXmppClient(ScriptInterface::CmptPrivate* pCmptPrivate);
void ConnectXmppClient(ScriptInterface::CmptPrivate* pCmptPrivate);
void DisconnectXmppClient(ScriptInterface::CmptPrivate* pCmptPrivate);
bool IsXmppClientConnected(ScriptInterface::CmptPrivate* pCmptPrivate);
void SendGetBoardList(ScriptInterface::CmptPrivate* pCmptPrivate);
void SendGetProfile(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& player);
void SendGameReport(ScriptInterface::CmptPrivate* pCmptPrivate, JS::HandleValue data);
void SendRegisterGame(ScriptInterface::CmptPrivate* pCmptPrivate, JS::HandleValue data);
void SendUnregisterGame(ScriptInterface::CmptPrivate* pCmptPrivate);
void SendChangeStateGame(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& nbp, const std::wstring& players);
JS::Value GetPlayerList(ScriptInterface::CmptPrivate* pCmptPrivate);
JS::Value GetGameList(ScriptInterface::CmptPrivate* pCmptPrivate);
JS::Value GetBoardList(ScriptInterface::CmptPrivate* pCmptPrivate);
JS::Value GetProfile(ScriptInterface::CmptPrivate* pCmptPrivate);
JS::Value LobbyGuiPollNewMessages(ScriptInterface::CmptPrivate* pCmptPrivate);
JS::Value LobbyGuiPollHistoricMessages(ScriptInterface::CmptPrivate* pCmptPrivate);
bool LobbyGuiPollHasPlayerListUpdate(ScriptInterface::CmptPrivate* pCmptPrivate);
void LobbySendMessage(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& message);
void LobbySetPlayerPresence(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& presence);
void LobbySetNick(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& nick);
std::wstring LobbyGetNick(ScriptInterface::CmptPrivate* pCmptPrivate);
void LobbyKick(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& nick, const std::wstring& reason);
void LobbyBan(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& nick, const std::wstring& reason);
const char* LobbyGetPlayerPresence(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& nickname);
const char* LobbyGetPlayerRole(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& nickname);
std::wstring LobbyGetPlayerRating(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& nickname);
std::wstring LobbyGetRoomSubject(ScriptInterface::CmptPrivate* pCmptPrivate);
// Non-public secure PBKDF2 hash function with salting and 1,337 iterations
std::string EncryptPassword(const std::string& password, const std::string& username);
// Public hash interface.
std::wstring EncryptPassword(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& pass, const std::wstring& user);
std::wstring EncryptPassword(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& pass, const std::wstring& user);
#endif // CONFIG2_LOBBY
}

View File

@ -31,27 +31,27 @@
#include "ps/Game.h"
#include "scriptinterface/ScriptInterface.h"
u16 JSI_Network::GetDefaultPort(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
u16 JSI_Network::GetDefaultPort(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return PS_DEFAULT_PORT;
}
bool JSI_Network::HasNetServer(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
bool JSI_Network::HasNetServer(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return g_NetServer;
}
bool JSI_Network::HasNetClient(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
bool JSI_Network::HasNetClient(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return g_NetClient;
}
JS::Value JSI_Network::FindStunEndpoint(ScriptInterface::CxPrivate* pCxPrivate, int port)
JS::Value JSI_Network::FindStunEndpoint(ScriptInterface::CmptPrivate* pCmptPrivate, int port)
{
return StunClient::FindStunEndpointHost(*(pCxPrivate->pScriptInterface), port);
return StunClient::FindStunEndpointHost(*(pCmptPrivate->pScriptInterface), port);
}
void JSI_Network::StartNetworkHost(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& playerName, const u16 serverPort, const CStr& hostLobbyName)
void JSI_Network::StartNetworkHost(ScriptInterface::CmptPrivate* pCmptPrivate, const CStrW& playerName, const u16 serverPort, const CStr& hostLobbyName)
{
ENSURE(!g_NetClient);
ENSURE(!g_NetServer);
@ -61,7 +61,7 @@ void JSI_Network::StartNetworkHost(ScriptInterface::CxPrivate* pCxPrivate, const
g_NetServer = new CNetServer(static_cast<bool>(g_XmppClient));
if (!g_NetServer->SetupConnection(serverPort))
{
pCxPrivate->pScriptInterface->ReportError("Failed to start server");
pCmptPrivate->pScriptInterface->ReportError("Failed to start server");
SAFE_DELETE(g_NetServer);
return;
}
@ -73,13 +73,13 @@ void JSI_Network::StartNetworkHost(ScriptInterface::CxPrivate* pCxPrivate, const
if (!g_NetClient->SetupConnection("127.0.0.1", serverPort, nullptr))
{
pCxPrivate->pScriptInterface->ReportError("Failed to connect to server");
pCmptPrivate->pScriptInterface->ReportError("Failed to connect to server");
SAFE_DELETE(g_NetClient);
SAFE_DELETE(g_Game);
}
}
void JSI_Network::StartNetworkJoin(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& playerName, const CStr& serverAddress, u16 serverPort, bool useSTUN, const CStr& hostJID)
void JSI_Network::StartNetworkJoin(ScriptInterface::CmptPrivate* pCmptPrivate, const CStrW& playerName, const CStr& serverAddress, u16 serverPort, bool useSTUN, const CStr& hostJID)
{
ENSURE(!g_NetClient);
ENSURE(!g_NetServer);
@ -100,14 +100,14 @@ void JSI_Network::StartNetworkJoin(ScriptInterface::CxPrivate* pCxPrivate, const
if (!enetClient)
{
pCxPrivate->pScriptInterface->ReportError("Could not find an unused port for the enet STUN client");
pCmptPrivate->pScriptInterface->ReportError("Could not find an unused port for the enet STUN client");
return;
}
StunClient::StunEndpoint stunEndpoint;
if (!StunClient::FindStunEndpointJoin(*enetClient, stunEndpoint))
{
pCxPrivate->pScriptInterface->ReportError("Could not find the STUN endpoint");
pCmptPrivate->pScriptInterface->ReportError("Could not find the STUN endpoint");
return;
}
@ -126,13 +126,13 @@ void JSI_Network::StartNetworkJoin(ScriptInterface::CxPrivate* pCxPrivate, const
if (!g_NetClient->SetupConnection(serverAddress, serverPort, enetClient))
{
pCxPrivate->pScriptInterface->ReportError("Failed to connect to server");
pCmptPrivate->pScriptInterface->ReportError("Failed to connect to server");
SAFE_DELETE(g_NetClient);
SAFE_DELETE(g_Game);
}
}
void JSI_Network::DisconnectNetworkGame(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_Network::DisconnectNetworkGame(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
// TODO: we ought to do async reliable disconnections
@ -141,7 +141,7 @@ void JSI_Network::DisconnectNetworkGame(ScriptInterface::CxPrivate* UNUSED(pCxPr
SAFE_DELETE(g_Game);
}
CStr JSI_Network::GetPlayerGUID(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
CStr JSI_Network::GetPlayerGUID(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
if (!g_NetClient)
return "local";
@ -149,7 +149,7 @@ CStr JSI_Network::GetPlayerGUID(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
return g_NetClient->GetGUID();
}
JS::Value JSI_Network::PollNetworkClient(ScriptInterface::CxPrivate* pCxPrivate)
JS::Value JSI_Network::PollNetworkClient(ScriptInterface::CmptPrivate* pCmptPrivate)
{
if (!g_NetClient)
return JS::UndefinedValue();
@ -158,62 +158,62 @@ JS::Value JSI_Network::PollNetworkClient(ScriptInterface::CxPrivate* pCxPrivate)
ScriptInterface::Request rqNet(g_NetClient->GetScriptInterface());
JS::RootedValue pollNet(rqNet.cx);
g_NetClient->GuiPoll(&pollNet);
return pCxPrivate->pScriptInterface->CloneValueFromOtherContext(g_NetClient->GetScriptInterface(), pollNet);
return pCmptPrivate->pScriptInterface->CloneValueFromOtherContext(g_NetClient->GetScriptInterface(), pollNet);
}
void JSI_Network::SetNetworkGameAttributes(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue attribs1)
void JSI_Network::SetNetworkGameAttributes(ScriptInterface::CmptPrivate* pCmptPrivate, JS::HandleValue attribs1)
{
ENSURE(g_NetClient);
// TODO: This is a workaround because we need to pass a MutableHandle to a JSAPI functions somewhere (with no obvious reason).
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS::RootedValue attribs(rq.cx, attribs1);
g_NetClient->SendGameSetupMessage(&attribs, *(pCxPrivate->pScriptInterface));
g_NetClient->SendGameSetupMessage(&attribs, *(pCmptPrivate->pScriptInterface));
}
void JSI_Network::AssignNetworkPlayer(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), int playerID, const CStr& guid)
void JSI_Network::AssignNetworkPlayer(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), int playerID, const CStr& guid)
{
ENSURE(g_NetClient);
g_NetClient->SendAssignPlayerMessage(playerID, guid);
}
void JSI_Network::KickPlayer(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const CStrW& playerName, bool ban)
void JSI_Network::KickPlayer(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const CStrW& playerName, bool ban)
{
ENSURE(g_NetClient);
g_NetClient->SendKickPlayerMessage(playerName, ban);
}
void JSI_Network::SendNetworkChat(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const CStrW& message)
void JSI_Network::SendNetworkChat(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const CStrW& message)
{
ENSURE(g_NetClient);
g_NetClient->SendChatMessage(message);
}
void JSI_Network::SendNetworkReady(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), int message)
void JSI_Network::SendNetworkReady(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), int message)
{
ENSURE(g_NetClient);
g_NetClient->SendReadyMessage(message);
}
void JSI_Network::ClearAllPlayerReady (ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_Network::ClearAllPlayerReady (ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
ENSURE(g_NetClient);
g_NetClient->SendClearAllReadyMessage();
}
void JSI_Network::StartNetworkGame(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_Network::StartNetworkGame(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
ENSURE(g_NetClient);
g_NetClient->SendStartGameMessage();
}
void JSI_Network::SetTurnLength(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), int length)
void JSI_Network::SetTurnLength(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), int length)
{
if (g_NetServer)
g_NetServer->SetTurnLength(length);

View File

@ -24,23 +24,23 @@
namespace JSI_Network
{
u16 GetDefaultPort(ScriptInterface::CxPrivate* pCxPrivate);
bool HasNetServer(ScriptInterface::CxPrivate* pCxPrivate);
bool HasNetClient(ScriptInterface::CxPrivate* pCxPrivate);
void StartNetworkGame(ScriptInterface::CxPrivate* pCxPrivate);
void SetNetworkGameAttributes(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue attribs1);
void StartNetworkHost(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& playerName, const u16 serverPort, const CStr& hostLobbyName);
void StartNetworkJoin(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& playerName, const CStr& serverAddress, u16 serverPort, bool useSTUN, const CStr& hostJID);
JS::Value FindStunEndpoint(ScriptInterface::CxPrivate* pCxPrivate, int port);
void DisconnectNetworkGame(ScriptInterface::CxPrivate* pCxPrivate);
JS::Value PollNetworkClient(ScriptInterface::CxPrivate* pCxPrivate);
CStr GetPlayerGUID(ScriptInterface::CxPrivate* pCxPrivate);
void KickPlayer(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& playerName, bool ban);
void AssignNetworkPlayer(ScriptInterface::CxPrivate* pCxPrivate, int playerID, const CStr& guid);
void ClearAllPlayerReady (ScriptInterface::CxPrivate* pCxPrivate);
void SendNetworkChat(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& message);
void SendNetworkReady(ScriptInterface::CxPrivate* pCxPrivate, int message);
void SetTurnLength(ScriptInterface::CxPrivate* pCxPrivate, int length);
u16 GetDefaultPort(ScriptInterface::CmptPrivate* pCmptPrivate);
bool HasNetServer(ScriptInterface::CmptPrivate* pCmptPrivate);
bool HasNetClient(ScriptInterface::CmptPrivate* pCmptPrivate);
void StartNetworkGame(ScriptInterface::CmptPrivate* pCmptPrivate);
void SetNetworkGameAttributes(ScriptInterface::CmptPrivate* pCmptPrivate, JS::HandleValue attribs1);
void StartNetworkHost(ScriptInterface::CmptPrivate* pCmptPrivate, const CStrW& playerName, const u16 serverPort, const CStr& hostLobbyName);
void StartNetworkJoin(ScriptInterface::CmptPrivate* pCmptPrivate, const CStrW& playerName, const CStr& serverAddress, u16 serverPort, bool useSTUN, const CStr& hostJID);
JS::Value FindStunEndpoint(ScriptInterface::CmptPrivate* pCmptPrivate, int port);
void DisconnectNetworkGame(ScriptInterface::CmptPrivate* pCmptPrivate);
JS::Value PollNetworkClient(ScriptInterface::CmptPrivate* pCmptPrivate);
CStr GetPlayerGUID(ScriptInterface::CmptPrivate* pCmptPrivate);
void KickPlayer(ScriptInterface::CmptPrivate* pCmptPrivate, const CStrW& playerName, bool ban);
void AssignNetworkPlayer(ScriptInterface::CmptPrivate* pCmptPrivate, int playerID, const CStr& guid);
void ClearAllPlayerReady (ScriptInterface::CmptPrivate* pCmptPrivate);
void SendNetworkChat(ScriptInterface::CmptPrivate* pCmptPrivate, const CStrW& message);
void SendNetworkReady(ScriptInterface::CmptPrivate* pCmptPrivate, int message);
void SetTurnLength(ScriptInterface::CmptPrivate* pCmptPrivate, int length);
void RegisterScriptFunctions(const ScriptInterface& scriptInterface);
}

View File

@ -132,7 +132,7 @@ void ConvertTLBs(const ScriptInterface& scriptInterface, JS::MutableHandleValue
}
#endif
void SetDisableAudio(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), bool disabled)
void SetDisableAudio(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), bool disabled)
{
g_DisableAudio = disabled;
}

View File

@ -423,10 +423,10 @@ bool VisualReplay::DeleteReplay(const OsPath& replayDirectory)
return DirectoryExists(directory) && DeleteDirectory(directory) == INFO::OK;
}
JS::Value VisualReplay::GetReplayAttributes(ScriptInterface::CxPrivate* pCxPrivate, const OsPath& directoryName)
JS::Value VisualReplay::GetReplayAttributes(ScriptInterface::CmptPrivate* pCmptPrivate, const OsPath& directoryName)
{
// Create empty JS object
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS::RootedValue attribs(rq.cx);
ScriptInterface::CreateObject(rq, &attribs);
@ -442,7 +442,7 @@ JS::Value VisualReplay::GetReplayAttributes(ScriptInterface::CxPrivate* pCxPriva
// Read and return first line
std::getline(*replayStream, line);
pCxPrivate->pScriptInterface->ParseJSON(line, &attribs);
pCmptPrivate->pScriptInterface->ParseJSON(line, &attribs);
SAFE_DELETE(replayStream);;
return attribs;
}
@ -480,12 +480,12 @@ bool VisualReplay::HasReplayMetadata(const OsPath& directoryName)
return fileInfo.Size() > 0;
}
JS::Value VisualReplay::GetReplayMetadata(ScriptInterface::CxPrivate* pCxPrivate, const OsPath& directoryName)
JS::Value VisualReplay::GetReplayMetadata(ScriptInterface::CmptPrivate* pCmptPrivate, const OsPath& directoryName)
{
if (!HasReplayMetadata(directoryName))
return JS::NullValue();
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS::RootedValue metadata(rq.cx);
std::ifstream* stream = new std::ifstream(OsString(GetDirectoryPath() / directoryName / L"metadata.json").c_str());
@ -494,7 +494,7 @@ JS::Value VisualReplay::GetReplayMetadata(ScriptInterface::CxPrivate* pCxPrivate
std::getline(*stream, line);
stream->close();
SAFE_DELETE(stream);
pCxPrivate->pScriptInterface->ParseJSON(line, &metadata);
pCmptPrivate->pScriptInterface->ParseJSON(line, &metadata);
return metadata;
}

View File

@ -104,7 +104,7 @@ bool DeleteReplay(const OsPath& replayFile);
/**
* Returns the parsed header of the replay file (commands.txt).
*/
JS::Value GetReplayAttributes(ScriptInterface::CxPrivate* pCxPrivate, const OsPath& directoryName);
JS::Value GetReplayAttributes(ScriptInterface::CmptPrivate* pCmptPrivate, const OsPath& directoryName);
/**
* Returns whether or not the metadata / summary screen data has been saved properly when the game ended.
@ -114,7 +114,7 @@ bool HasReplayMetadata(const OsPath& directoryName);
/**
* Returns the metadata of a replay.
*/
JS::Value GetReplayMetadata(ScriptInterface::CxPrivate* pCxPrivate, const OsPath& directoryName);
JS::Value GetReplayMetadata(ScriptInterface::CmptPrivate* pCmptPrivate, const OsPath& directoryName);
/**
* Adds a replay to the replayCache.

View File

@ -66,7 +66,7 @@ bool JSI_ConfigDB::GetConfigNamespace(const std::wstring& cfgNsString, EConfigNa
return true;
}
bool JSI_ConfigDB::HasChanges(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString)
bool JSI_ConfigDB::HasChanges(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& cfgNsString)
{
EConfigNamespace cfgNs;
if (!GetConfigNamespace(cfgNsString, cfgNs))
@ -75,7 +75,7 @@ bool JSI_ConfigDB::HasChanges(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), co
return g_ConfigDB.HasChanges(cfgNs);
}
bool JSI_ConfigDB::SetChanges(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString, bool value)
bool JSI_ConfigDB::SetChanges(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& cfgNsString, bool value)
{
EConfigNamespace cfgNs;
if (!GetConfigNamespace(cfgNsString, cfgNs))
@ -85,7 +85,7 @@ bool JSI_ConfigDB::SetChanges(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), co
return true;
}
std::string JSI_ConfigDB::GetValue(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString, const std::string& name)
std::string JSI_ConfigDB::GetValue(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& cfgNsString, const std::string& name)
{
if (IsProtectedConfigName(name))
return "";
@ -99,7 +99,7 @@ std::string JSI_ConfigDB::GetValue(ScriptInterface::CxPrivate* UNUSED(pCxPrivate
return value;
}
bool JSI_ConfigDB::CreateValue(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString, const std::string& name, const std::string& value)
bool JSI_ConfigDB::CreateValue(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& cfgNsString, const std::string& name, const std::string& value)
{
if (IsProtectedConfigName(name))
return false;
@ -112,7 +112,7 @@ bool JSI_ConfigDB::CreateValue(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), c
return true;
}
bool JSI_ConfigDB::RemoveValue(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString, const std::string& name)
bool JSI_ConfigDB::RemoveValue(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& cfgNsString, const std::string& name)
{
if (IsProtectedConfigName(name))
return false;
@ -125,7 +125,7 @@ bool JSI_ConfigDB::RemoveValue(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), c
return true;
}
bool JSI_ConfigDB::WriteFile(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString, const Path& path)
bool JSI_ConfigDB::WriteFile(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& cfgNsString, const Path& path)
{
EConfigNamespace cfgNs;
if (!GetConfigNamespace(cfgNsString, cfgNs))
@ -134,7 +134,7 @@ bool JSI_ConfigDB::WriteFile(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), con
return g_ConfigDB.WriteFile(cfgNs, path);
}
bool JSI_ConfigDB::WriteValueToFile(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString, const std::string& name, const std::string& value, const Path& path)
bool JSI_ConfigDB::WriteValueToFile(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& cfgNsString, const std::string& name, const std::string& value, const Path& path)
{
if (IsProtectedConfigName(name))
return false;
@ -146,13 +146,13 @@ bool JSI_ConfigDB::WriteValueToFile(ScriptInterface::CxPrivate* UNUSED(pCxPrivat
return g_ConfigDB.WriteValueToFile(cfgNs, name, value, path);
}
void JSI_ConfigDB::CreateAndWriteValueToFile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const std::string& name, const std::string& value, const Path& path)
void JSI_ConfigDB::CreateAndWriteValueToFile(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& cfgNsString, const std::string& name, const std::string& value, const Path& path)
{
CreateValue(pCxPrivate, cfgNsString, name, value);
WriteValueToFile(pCxPrivate, cfgNsString, name, value, path);
CreateValue(pCmptPrivate, cfgNsString, name, value);
WriteValueToFile(pCmptPrivate, cfgNsString, name, value, path);
}
bool JSI_ConfigDB::Reload(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString)
bool JSI_ConfigDB::Reload(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& cfgNsString)
{
EConfigNamespace cfgNs;
if (!GetConfigNamespace(cfgNsString, cfgNs))
@ -161,7 +161,7 @@ bool JSI_ConfigDB::Reload(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const
return g_ConfigDB.Reload(cfgNs);
}
bool JSI_ConfigDB::SetFile(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString, const Path& path)
bool JSI_ConfigDB::SetFile(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& cfgNsString, const Path& path)
{
EConfigNamespace cfgNs;
if (!GetConfigNamespace(cfgNsString, cfgNs))

View File

@ -27,16 +27,16 @@ namespace JSI_ConfigDB
{
bool IsProtectedConfigName(const std::string& name);
bool GetConfigNamespace(const std::wstring& cfgNsString, EConfigNamespace& cfgNs);
bool HasChanges(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString);
bool SetChanges(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, bool value);
std::string GetValue(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const std::string& name);
bool CreateValue(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const std::string& name, const std::string& value);
bool RemoveValue(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const std::string& name);
bool WriteFile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const Path& path);
bool WriteValueToFile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const std::string& name, const std::string& value, const Path& path);
void CreateAndWriteValueToFile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const std::string& name, const std::string& value, const Path& path);
bool Reload(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString);
bool SetFile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, const Path& path);
bool HasChanges(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& cfgNsString);
bool SetChanges(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& cfgNsString, bool value);
std::string GetValue(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& cfgNsString, const std::string& name);
bool CreateValue(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& cfgNsString, const std::string& name, const std::string& value);
bool RemoveValue(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& cfgNsString, const std::string& name);
bool WriteFile(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& cfgNsString, const Path& path);
bool WriteValueToFile(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& cfgNsString, const std::string& name, const std::string& value, const Path& path);
void CreateAndWriteValueToFile(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& cfgNsString, const std::string& name, const std::string& value, const Path& path);
bool Reload(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& cfgNsString);
bool SetFile(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& cfgNsString, const Path& path);
void RegisterScriptFunctions(const ScriptInterface& scriptInterface);
}

View File

@ -33,14 +33,14 @@ bool JSI_Console::CheckGlobalInitialized()
return true;
}
bool JSI_Console::GetVisibleEnabled(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
bool JSI_Console::GetVisibleEnabled(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
if (!CheckGlobalInitialized())
return false;
return g_Console->IsActive();
}
void JSI_Console::SetVisibleEnabled(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), bool Enabled)
void JSI_Console::SetVisibleEnabled(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), bool Enabled)
{
if (!CheckGlobalInitialized())
return;

View File

@ -23,8 +23,8 @@
namespace JSI_Console
{
bool CheckGlobalInitialized();
bool GetVisibleEnabled(ScriptInterface::CxPrivate* pCxPrivate);
void SetVisibleEnabled(ScriptInterface::CxPrivate* pCxPrivate, bool Enabled);
bool GetVisibleEnabled(ScriptInterface::CmptPrivate* pCmptPrivate);
void SetVisibleEnabled(ScriptInterface::CmptPrivate* pCmptPrivate, bool Enabled);
void RegisterScriptFunctions(const ScriptInterface& scriptInterface);
}

View File

@ -29,7 +29,7 @@
/**
* Microseconds since the epoch.
*/
double JSI_Debug::GetMicroseconds(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
double JSI_Debug::GetMicroseconds(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return JS_Now();
}
@ -37,18 +37,18 @@ double JSI_Debug::GetMicroseconds(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)
// Deliberately cause the game to crash.
// Currently implemented via access violation (read of address 0).
// Useful for testing the crashlog/stack trace code.
int JSI_Debug::Crash(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
int JSI_Debug::Crash(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
debug_printf("Crashing at user's request.\n");
return *(volatile int*)0;
}
void JSI_Debug::DebugWarn(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_Debug::DebugWarn(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
debug_warn(L"Warning at user's request.");
}
void JSI_Debug::DisplayErrorDialog(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& msg)
void JSI_Debug::DisplayErrorDialog(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& msg)
{
debug_DisplayError(msg.c_str(), DE_NO_DEBUG_INFO, NULL, NULL, NULL, 0, NULL, NULL);
}
@ -57,13 +57,13 @@ void JSI_Debug::DisplayErrorDialog(ScriptInterface::CxPrivate* UNUSED(pCxPrivate
// - Displayed on main menu screen; tells non-programmers which auto-build
// they are running. Could also be determined via .EXE file properties,
// but that's a bit more trouble.
std::wstring JSI_Debug::GetBuildDate(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
std::wstring JSI_Debug::GetBuildDate(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
UDate buildDate = g_L10n.ParseDateTime(__DATE__, "MMM d yyyy", icu::Locale::getUS());
return wstring_from_utf8(g_L10n.LocalizeDateTime(buildDate, L10n::Date, icu::SimpleDateFormat::MEDIUM));
}
double JSI_Debug::GetBuildTimestamp(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
double JSI_Debug::GetBuildTimestamp(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
UDate buildDate = g_L10n.ParseDateTime(__DATE__ " " __TIME__, "MMM d yyyy HH:mm:ss", icu::Locale::getUS());
if (buildDate)
@ -76,7 +76,7 @@ double JSI_Debug::GetBuildTimestamp(ScriptInterface::CxPrivate* UNUSED(pCxPrivat
// lib/svn_revision.cpp. it is useful to know when attempting to
// reproduce bugs (the main EXE and PDB should be temporarily reverted to
// that revision so that they match user-submitted crashdumps).
std::wstring JSI_Debug::GetBuildRevision(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
std::wstring JSI_Debug::GetBuildRevision(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
std::wstring svnRevision(svn_revision);
if (svnRevision == L"custom build")

View File

@ -24,13 +24,13 @@
namespace JSI_Debug
{
int Crash(ScriptInterface::CxPrivate* UNUSED(pCxPrivate));
void DebugWarn(ScriptInterface::CxPrivate* UNUSED(pCxPrivate));
void DisplayErrorDialog(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& msg);
std::wstring GetBuildDate(ScriptInterface::CxPrivate* UNUSED(pCxPrivate));
double GetBuildTimestamp(ScriptInterface::CxPrivate* UNUSED(pCxPrivate));
std::wstring GetBuildRevision(ScriptInterface::CxPrivate* UNUSED(pCxPrivate));
double GetMicroseconds(ScriptInterface::CxPrivate* UNUSED(pCxPrivate));
int Crash(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate));
void DebugWarn(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate));
void DisplayErrorDialog(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& msg);
std::wstring GetBuildDate(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate));
double GetBuildTimestamp(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate));
std::wstring GetBuildRevision(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate));
double GetMicroseconds(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate));
void RegisterScriptFunctions(const ScriptInterface& ScriptInterface);
}

View File

@ -33,12 +33,12 @@
extern void EndGame();
bool JSI_Game::IsGameStarted(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
bool JSI_Game::IsGameStarted(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return g_Game;
}
void JSI_Game::StartGame(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue attribs, int playerID)
void JSI_Game::StartGame(ScriptInterface::CmptPrivate* pCmptPrivate, JS::HandleValue attribs, int playerID)
{
ENSURE(!g_NetServer);
ENSURE(!g_NetClient);
@ -51,18 +51,18 @@ void JSI_Game::StartGame(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue
ScriptInterface::Request rqSim(sim->GetScriptInterface());
JS::RootedValue gameAttribs(rqSim.cx,
sim->GetScriptInterface().CloneValueFromOtherContext(*(pCxPrivate->pScriptInterface), attribs));
sim->GetScriptInterface().CloneValueFromOtherContext(*(pCmptPrivate->pScriptInterface), attribs));
g_Game->SetPlayerID(playerID);
g_Game->StartGame(&gameAttribs, "");
}
void JSI_Game::Script_EndGame(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_Game::Script_EndGame(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
EndGame();
}
int JSI_Game::GetPlayerID(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
int JSI_Game::GetPlayerID(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
if (!g_Game)
return -1;
@ -70,7 +70,7 @@ int JSI_Game::GetPlayerID(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
return g_Game->GetPlayerID();
}
void JSI_Game::SetPlayerID(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), int id)
void JSI_Game::SetPlayerID(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), int id)
{
if (!g_Game)
return;
@ -78,7 +78,7 @@ void JSI_Game::SetPlayerID(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), int i
g_Game->SetPlayerID(id);
}
void JSI_Game::SetViewedPlayer(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), int id)
void JSI_Game::SetViewedPlayer(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), int id)
{
if (!g_Game)
return;
@ -86,21 +86,21 @@ void JSI_Game::SetViewedPlayer(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), i
g_Game->SetViewedPlayerID(id);
}
float JSI_Game::GetSimRate(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
float JSI_Game::GetSimRate(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return g_Game->GetSimRate();
}
void JSI_Game::SetSimRate(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), float rate)
void JSI_Game::SetSimRate(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), float rate)
{
g_Game->SetSimRate(rate);
}
bool JSI_Game::IsPaused(ScriptInterface::CxPrivate* pCxPrivate)
bool JSI_Game::IsPaused(ScriptInterface::CmptPrivate* pCmptPrivate)
{
if (!g_Game)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Game is not started");
return false;
}
@ -108,11 +108,11 @@ bool JSI_Game::IsPaused(ScriptInterface::CxPrivate* pCxPrivate)
return g_Game->m_Paused;
}
void JSI_Game::SetPaused(ScriptInterface::CxPrivate* pCxPrivate, bool pause, bool sendMessage)
void JSI_Game::SetPaused(ScriptInterface::CmptPrivate* pCmptPrivate, bool pause, bool sendMessage)
{
if (!g_Game)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "Game is not started");
return;
}
@ -128,7 +128,7 @@ void JSI_Game::SetPaused(ScriptInterface::CxPrivate* pCxPrivate, bool pause, boo
g_NetClient->SendPausedMessage(pause);
}
bool JSI_Game::IsVisualReplay(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
bool JSI_Game::IsVisualReplay(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
if (!g_Game)
return false;
@ -136,7 +136,7 @@ bool JSI_Game::IsVisualReplay(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
return g_Game->IsVisualReplay();
}
std::wstring JSI_Game::GetCurrentReplayDirectory(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
std::wstring JSI_Game::GetCurrentReplayDirectory(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
if (!g_Game)
return std::wstring();
@ -147,17 +147,17 @@ std::wstring JSI_Game::GetCurrentReplayDirectory(ScriptInterface::CxPrivate* UNU
return g_Game->GetReplayLogger().GetDirectory().Filename().string();
}
void JSI_Game::EnableTimeWarpRecording(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), unsigned int numTurns)
void JSI_Game::EnableTimeWarpRecording(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), unsigned int numTurns)
{
g_Game->GetTurnManager()->EnableTimeWarpRecording(numTurns);
}
void JSI_Game::RewindTimeWarp(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_Game::RewindTimeWarp(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
g_Game->GetTurnManager()->RewindTimeWarp();
}
void JSI_Game::DumpTerrainMipmap(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_Game::DumpTerrainMipmap(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
VfsPath filename(L"screenshots/terrainmipmap.png");
g_Game->GetWorld()->GetTerrain()->GetHeightMipmap().DumpToDisk(filename);

View File

@ -22,21 +22,21 @@
namespace JSI_Game
{
bool IsGameStarted(ScriptInterface::CxPrivate* pCxPrivate);
void StartGame(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue attribs, int playerID);
void Script_EndGame(ScriptInterface::CxPrivate* pCxPrivate);
int GetPlayerID(ScriptInterface::CxPrivate* pCxPrivate);
void SetPlayerID(ScriptInterface::CxPrivate* pCxPrivate, int id);
void SetViewedPlayer(ScriptInterface::CxPrivate* pCxPrivate, int id);
float GetSimRate(ScriptInterface::CxPrivate* pCxPrivate);
void SetSimRate(ScriptInterface::CxPrivate* pCxPrivate, float rate);
bool IsPaused(ScriptInterface::CxPrivate* pCxPrivate);
void SetPaused(ScriptInterface::CxPrivate* pCxPrivate, bool pause, bool sendMessage);
bool IsVisualReplay(ScriptInterface::CxPrivate* pCxPrivate);
std::wstring GetCurrentReplayDirectory(ScriptInterface::CxPrivate* pCxPrivate);
void RewindTimeWarp(ScriptInterface::CxPrivate* pCxPrivate);
void EnableTimeWarpRecording(ScriptInterface::CxPrivate* pCxPrivate, unsigned int numTurns);
void DumpTerrainMipmap(ScriptInterface::CxPrivate* pCxPrivate);
bool IsGameStarted(ScriptInterface::CmptPrivate* pCmptPrivate);
void StartGame(ScriptInterface::CmptPrivate* pCmptPrivate, JS::HandleValue attribs, int playerID);
void Script_EndGame(ScriptInterface::CmptPrivate* pCmptPrivate);
int GetPlayerID(ScriptInterface::CmptPrivate* pCmptPrivate);
void SetPlayerID(ScriptInterface::CmptPrivate* pCmptPrivate, int id);
void SetViewedPlayer(ScriptInterface::CmptPrivate* pCmptPrivate, int id);
float GetSimRate(ScriptInterface::CmptPrivate* pCmptPrivate);
void SetSimRate(ScriptInterface::CmptPrivate* pCmptPrivate, float rate);
bool IsPaused(ScriptInterface::CmptPrivate* pCmptPrivate);
void SetPaused(ScriptInterface::CmptPrivate* pCmptPrivate, bool pause, bool sendMessage);
bool IsVisualReplay(ScriptInterface::CmptPrivate* pCmptPrivate);
std::wstring GetCurrentReplayDirectory(ScriptInterface::CmptPrivate* pCmptPrivate);
void RewindTimeWarp(ScriptInterface::CmptPrivate* pCmptPrivate);
void EnableTimeWarpRecording(ScriptInterface::CmptPrivate* pCmptPrivate, unsigned int numTurns);
void DumpTerrainMipmap(ScriptInterface::CmptPrivate* pCmptPrivate);
void RegisterScriptFunctions(const ScriptInterface& ScriptInterface);
}

View File

@ -36,44 +36,44 @@
extern void QuitEngine();
extern void StartAtlas();
void JSI_Main::QuitEngine(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_Main::QuitEngine(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
::QuitEngine();
}
void JSI_Main::StartAtlas(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_Main::StartAtlas(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
::StartAtlas();
}
bool JSI_Main::AtlasIsAvailable(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
bool JSI_Main::AtlasIsAvailable(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return ATLAS_IsAvailable();
}
bool JSI_Main::IsAtlasRunning(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
bool JSI_Main::IsAtlasRunning(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return g_AtlasGameLoop && g_AtlasGameLoop->running;
}
void JSI_Main::OpenURL(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& url)
void JSI_Main::OpenURL(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& url)
{
sys_open_url(url);
}
std::wstring JSI_Main::GetSystemUsername(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
std::wstring JSI_Main::GetSystemUsername(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return sys_get_user_name();
}
std::wstring JSI_Main::GetMatchID(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
std::wstring JSI_Main::GetMatchID(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return ps_generate_guid().FromUTF8();
}
JS::Value JSI_Main::LoadMapSettings(ScriptInterface::CxPrivate* pCxPrivate, const VfsPath& pathname)
JS::Value JSI_Main::LoadMapSettings(ScriptInterface::CmptPrivate* pCmptPrivate, const VfsPath& pathname)
{
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
CMapSummaryReader reader;
@ -81,18 +81,18 @@ JS::Value JSI_Main::LoadMapSettings(ScriptInterface::CxPrivate* pCxPrivate, cons
return JS::UndefinedValue();
JS::RootedValue settings(rq.cx);
reader.GetMapSettings(*(pCxPrivate->pScriptInterface), &settings);
reader.GetMapSettings(*(pCmptPrivate->pScriptInterface), &settings);
return settings;
}
bool JSI_Main::HotkeyIsPressed_(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& hotkeyName)
bool JSI_Main::HotkeyIsPressed_(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& hotkeyName)
{
return HotkeyIsPressed(hotkeyName);
}
// This value is recalculated once a frame. We take special care to
// filter it, so it is both accurate and free of jitter.
int JSI_Main::GetFps(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
int JSI_Main::GetFps(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
if (!g_frequencyFilter)
return 0;
@ -100,7 +100,7 @@ int JSI_Main::GetFps(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
return g_frequencyFilter->StableFrequency();
}
int JSI_Main::GetTextWidth(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& fontName, const std::wstring& text)
int JSI_Main::GetTextWidth(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& fontName, const std::wstring& text)
{
int width = 0;
int height = 0;
@ -110,7 +110,7 @@ int JSI_Main::GetTextWidth(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const
return width;
}
std::string JSI_Main::CalculateMD5(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& input)
std::string JSI_Main::CalculateMD5(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& input)
{
u8 digest[MD5::DIGESTSIZE];

View File

@ -22,18 +22,18 @@
namespace JSI_Main
{
void QuitEngine(ScriptInterface::CxPrivate* pCxPrivate);
void StartAtlas(ScriptInterface::CxPrivate* pCxPrivate);
bool AtlasIsAvailable(ScriptInterface::CxPrivate* pCxPrivate);
bool IsAtlasRunning(ScriptInterface::CxPrivate* pCxPrivate);
void OpenURL(ScriptInterface::CxPrivate* pCxPrivate, const std::string& url);
std::wstring GetSystemUsername(ScriptInterface::CxPrivate* pCxPrivate);
std::wstring GetMatchID(ScriptInterface::CxPrivate* pCxPrivate);
JS::Value LoadMapSettings(ScriptInterface::CxPrivate* pCxPrivate, const VfsPath& pathname);
bool HotkeyIsPressed_(ScriptInterface::CxPrivate* pCxPrivate, const std::string& hotkeyName);
int GetFps(ScriptInterface::CxPrivate* pCxPrivate);
int GetTextWidth(ScriptInterface::CxPrivate* pCxPrivate, const std::string& fontName, const std::wstring& text);
std::string CalculateMD5(ScriptInterface::CxPrivate* pCxPrivate, const std::string& input);
void QuitEngine(ScriptInterface::CmptPrivate* pCmptPrivate);
void StartAtlas(ScriptInterface::CmptPrivate* pCmptPrivate);
bool AtlasIsAvailable(ScriptInterface::CmptPrivate* pCmptPrivate);
bool IsAtlasRunning(ScriptInterface::CmptPrivate* pCmptPrivate);
void OpenURL(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& url);
std::wstring GetSystemUsername(ScriptInterface::CmptPrivate* pCmptPrivate);
std::wstring GetMatchID(ScriptInterface::CmptPrivate* pCmptPrivate);
JS::Value LoadMapSettings(ScriptInterface::CmptPrivate* pCmptPrivate, const VfsPath& pathname);
bool HotkeyIsPressed_(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& hotkeyName);
int GetFps(ScriptInterface::CmptPrivate* pCmptPrivate);
int GetTextWidth(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& fontName, const std::wstring& text);
std::string CalculateMD5(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& input);
void RegisterScriptFunctions(const ScriptInterface& scriptInterface);
}

View File

@ -24,9 +24,9 @@
extern void RestartEngine();
JS::Value JSI_Mod::GetEngineInfo(ScriptInterface::CxPrivate* pCxPrivate)
JS::Value JSI_Mod::GetEngineInfo(ScriptInterface::CmptPrivate* pCmptPrivate)
{
return Mod::GetEngineInfo(*(pCxPrivate->pScriptInterface));
return Mod::GetEngineInfo(*(pCmptPrivate->pScriptInterface));
}
/**
@ -39,17 +39,17 @@ JS::Value JSI_Mod::GetEngineInfo(ScriptInterface::CxPrivate* pCxPrivate)
* @return JS object with available mods as the keys of the modname.json
* properties.
*/
JS::Value JSI_Mod::GetAvailableMods(ScriptInterface::CxPrivate* pCxPrivate)
JS::Value JSI_Mod::GetAvailableMods(ScriptInterface::CmptPrivate* pCmptPrivate)
{
return Mod::GetAvailableMods(*(pCxPrivate->pScriptInterface));
return Mod::GetAvailableMods(*(pCmptPrivate->pScriptInterface));
}
void JSI_Mod::RestartEngine(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_Mod::RestartEngine(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
::RestartEngine();
}
void JSI_Mod::SetMods(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::vector<CStr>& mods)
void JSI_Mod::SetMods(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::vector<CStr>& mods)
{
g_modsLoaded = mods;
}

View File

@ -25,10 +25,10 @@ namespace JSI_Mod
{
void RegisterScriptFunctions(const ScriptInterface& scriptInterface);
JS::Value GetEngineInfo(ScriptInterface::CxPrivate* pCxPrivate);
JS::Value GetAvailableMods(ScriptInterface::CxPrivate* pCxPrivate);
void RestartEngine(ScriptInterface::CxPrivate* pCxPrivate);
void SetMods(ScriptInterface::CxPrivate* pCxPrivate, const std::vector<CStr>& mods);
JS::Value GetEngineInfo(ScriptInterface::CmptPrivate* pCmptPrivate);
JS::Value GetAvailableMods(ScriptInterface::CmptPrivate* pCmptPrivate);
void RestartEngine(ScriptInterface::CmptPrivate* pCmptPrivate);
void SetMods(ScriptInterface::CmptPrivate* pCmptPrivate, const std::vector<CStr>& mods);
}
#endif // INCLUDED_JSI_MOD

View File

@ -22,7 +22,7 @@
#include "ps/CLogger.h"
#include "ps/ModIo.h"
void JSI_ModIo::StartGetGameId(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_ModIo::StartGetGameId(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
if (!g_ModIo)
g_ModIo = new ModIo();
@ -32,7 +32,7 @@ void JSI_ModIo::StartGetGameId(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
g_ModIo->StartGetGameId();
}
void JSI_ModIo::StartListMods(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_ModIo::StartListMods(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
if (!g_ModIo)
{
@ -43,7 +43,7 @@ void JSI_ModIo::StartListMods(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
g_ModIo->StartListMods();
}
void JSI_ModIo::StartDownloadMod(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), uint32_t idx)
void JSI_ModIo::StartDownloadMod(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), uint32_t idx)
{
if (!g_ModIo)
{
@ -54,7 +54,7 @@ void JSI_ModIo::StartDownloadMod(ScriptInterface::CxPrivate* UNUSED(pCxPrivate),
g_ModIo->StartDownloadMod(idx);
}
bool JSI_ModIo::AdvanceRequest(ScriptInterface::CxPrivate* pCxPrivate)
bool JSI_ModIo::AdvanceRequest(ScriptInterface::CmptPrivate* pCmptPrivate)
{
if (!g_ModIo)
{
@ -62,11 +62,11 @@ bool JSI_ModIo::AdvanceRequest(ScriptInterface::CxPrivate* pCxPrivate)
return false;
}
ScriptInterface* scriptInterface = pCxPrivate->pScriptInterface;
ScriptInterface* scriptInterface = pCmptPrivate->pScriptInterface;
return g_ModIo->AdvanceRequest(*scriptInterface);
}
void JSI_ModIo::CancelRequest(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_ModIo::CancelRequest(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
if (!g_ModIo)
{
@ -77,7 +77,7 @@ void JSI_ModIo::CancelRequest(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
g_ModIo->CancelRequest();
}
JS::Value JSI_ModIo::GetMods(ScriptInterface::CxPrivate* pCxPrivate)
JS::Value JSI_ModIo::GetMods(ScriptInterface::CmptPrivate* pCmptPrivate)
{
if (!g_ModIo)
{
@ -85,7 +85,7 @@ JS::Value JSI_ModIo::GetMods(ScriptInterface::CxPrivate* pCxPrivate)
return JS::NullValue();
}
ScriptInterface* scriptInterface = pCxPrivate->pScriptInterface;
ScriptInterface* scriptInterface = pCmptPrivate->pScriptInterface;
ScriptInterface::Request rq(scriptInterface);
const std::vector<ModIoModData>& availableMods = g_ModIo->GetMods();
@ -123,7 +123,7 @@ const std::map<DownloadProgressStatus, std::string> statusStrings = {
{ DownloadProgressStatus::FAILED_FILECHECK, "failed_filecheck" }
};
JS::Value JSI_ModIo::GetDownloadProgress(ScriptInterface::CxPrivate* pCxPrivate)
JS::Value JSI_ModIo::GetDownloadProgress(ScriptInterface::CmptPrivate* pCmptPrivate)
{
if (!g_ModIo)
{
@ -131,7 +131,7 @@ JS::Value JSI_ModIo::GetDownloadProgress(ScriptInterface::CxPrivate* pCxPrivate)
return JS::NullValue();
}
ScriptInterface* scriptInterface = pCxPrivate->pScriptInterface;
ScriptInterface* scriptInterface = pCmptPrivate->pScriptInterface;
ScriptInterface::Request rq(scriptInterface);
const DownloadProgressData& progress = g_ModIo->GetDownloadProgress();

View File

@ -24,13 +24,13 @@ namespace JSI_ModIo
{
void RegisterScriptFunctions(const ScriptInterface& scriptInterface);
void StartGetGameId(ScriptInterface::CxPrivate* pCxPrivate);
void StartListMods(ScriptInterface::CxPrivate* pCxPrivate);
void StartDownloadMod(ScriptInterface::CxPrivate* pCxPrivate, uint32_t idx);
bool AdvanceRequest(ScriptInterface::CxPrivate* pCxPrivate);
void CancelRequest(ScriptInterface::CxPrivate* pCxPrivate);
JS::Value GetMods(ScriptInterface::CxPrivate* pCxPrivate);
JS::Value GetDownloadProgress(ScriptInterface::CxPrivate* pCxPrivate);
void StartGetGameId(ScriptInterface::CmptPrivate* pCmptPrivate);
void StartListMods(ScriptInterface::CmptPrivate* pCmptPrivate);
void StartDownloadMod(ScriptInterface::CmptPrivate* pCmptPrivate, uint32_t idx);
bool AdvanceRequest(ScriptInterface::CmptPrivate* pCmptPrivate);
void CancelRequest(ScriptInterface::CmptPrivate* pCmptPrivate);
JS::Value GetMods(ScriptInterface::CmptPrivate* pCmptPrivate);
JS::Value GetDownloadProgress(ScriptInterface::CmptPrivate* pCmptPrivate);
}
#endif // INCLUDED_JSI_MODIO

View File

@ -28,31 +28,31 @@
#include "simulation2/Simulation2.h"
#include "simulation2/system/TurnManager.h"
JS::Value JSI_SavedGame::GetSavedGames(ScriptInterface::CxPrivate* pCxPrivate)
JS::Value JSI_SavedGame::GetSavedGames(ScriptInterface::CmptPrivate* pCmptPrivate)
{
return SavedGames::GetSavedGames(*(pCxPrivate->pScriptInterface));
return SavedGames::GetSavedGames(*(pCmptPrivate->pScriptInterface));
}
bool JSI_SavedGame::DeleteSavedGame(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& name)
bool JSI_SavedGame::DeleteSavedGame(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& name)
{
return SavedGames::DeleteSavedGame(name);
}
void JSI_SavedGame::SaveGame(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& filename, const std::wstring& description, JS::HandleValue GUIMetadata)
void JSI_SavedGame::SaveGame(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& filename, const std::wstring& description, JS::HandleValue GUIMetadata)
{
shared_ptr<ScriptInterface::StructuredClone> GUIMetadataClone = pCxPrivate->pScriptInterface->WriteStructuredClone(GUIMetadata);
shared_ptr<ScriptInterface::StructuredClone> GUIMetadataClone = pCmptPrivate->pScriptInterface->WriteStructuredClone(GUIMetadata);
if (SavedGames::Save(filename, description, *g_Game->GetSimulation2(), GUIMetadataClone) < 0)
LOGERROR("Failed to save game");
}
void JSI_SavedGame::SaveGamePrefix(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& prefix, const std::wstring& description, JS::HandleValue GUIMetadata)
void JSI_SavedGame::SaveGamePrefix(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& prefix, const std::wstring& description, JS::HandleValue GUIMetadata)
{
shared_ptr<ScriptInterface::StructuredClone> GUIMetadataClone = pCxPrivate->pScriptInterface->WriteStructuredClone(GUIMetadata);
shared_ptr<ScriptInterface::StructuredClone> GUIMetadataClone = pCmptPrivate->pScriptInterface->WriteStructuredClone(GUIMetadata);
if (SavedGames::SavePrefix(prefix, description, *g_Game->GetSimulation2(), GUIMetadataClone) < 0)
LOGERROR("Failed to save game");
}
void JSI_SavedGame::QuickSave(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), JS::HandleValue GUIMetadata)
void JSI_SavedGame::QuickSave(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), JS::HandleValue GUIMetadata)
{
if (g_NetServer || g_NetClient)
LOGERROR("Can't store quicksave during multiplayer!");
@ -62,7 +62,7 @@ void JSI_SavedGame::QuickSave(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), JS
LOGERROR("Can't store quicksave if game is not running!");
}
void JSI_SavedGame::QuickLoad(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_SavedGame::QuickLoad(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
if (g_NetServer || g_NetClient)
LOGERROR("Can't load quicksave during multiplayer!");
@ -72,13 +72,13 @@ void JSI_SavedGame::QuickLoad(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
LOGERROR("Can't load quicksave if game is not running!");
}
JS::Value JSI_SavedGame::StartSavedGame(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& name)
JS::Value JSI_SavedGame::StartSavedGame(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& name)
{
// We need to be careful with different compartments and contexts.
// The GUI calls this function from the GUI context and expects the return value in the same context.
// The game we start from here creates another context and expects data in this context.
ScriptInterface::Request rqGui(pCxPrivate);
ScriptInterface::Request rqGui(pCmptPrivate);
ENSURE(!g_NetServer);
ENSURE(!g_NetClient);
@ -88,7 +88,7 @@ JS::Value JSI_SavedGame::StartSavedGame(ScriptInterface::CxPrivate* pCxPrivate,
// Load the saved game data from disk
JS::RootedValue guiContextMetadata(rqGui.cx);
std::string savedState;
Status err = SavedGames::Load(name, *(pCxPrivate->pScriptInterface), &guiContextMetadata, savedState);
Status err = SavedGames::Load(name, *(pCmptPrivate->pScriptInterface), &guiContextMetadata, savedState);
if (err < 0)
return JS::UndefinedValue();
@ -99,7 +99,7 @@ JS::Value JSI_SavedGame::StartSavedGame(ScriptInterface::CxPrivate* pCxPrivate,
ScriptInterface::Request rqGame(sim->GetScriptInterface());
JS::RootedValue gameContextMetadata(rqGame.cx,
sim->GetScriptInterface().CloneValueFromOtherContext(*(pCxPrivate->pScriptInterface), guiContextMetadata));
sim->GetScriptInterface().CloneValueFromOtherContext(*(pCmptPrivate->pScriptInterface), guiContextMetadata));
JS::RootedValue gameInitAttributes(rqGame.cx);
sim->GetScriptInterface().GetProperty(gameContextMetadata, "initAttributes", &gameInitAttributes);

View File

@ -22,13 +22,13 @@
namespace JSI_SavedGame
{
JS::Value GetSavedGames(ScriptInterface::CxPrivate* pCxPrivate);
bool DeleteSavedGame(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& name);
void SaveGame(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& filename, const std::wstring& description, JS::HandleValue GUIMetadata);
void SaveGamePrefix(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& prefix, const std::wstring& description, JS::HandleValue GUIMetadata);
void QuickSave(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue GUIMetadata);
void QuickLoad(ScriptInterface::CxPrivate* pCxPrivate);
JS::Value StartSavedGame(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& name);
JS::Value GetSavedGames(ScriptInterface::CmptPrivate* pCmptPrivate);
bool DeleteSavedGame(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& name);
void SaveGame(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& filename, const std::wstring& description, JS::HandleValue GUIMetadata);
void SaveGamePrefix(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& prefix, const std::wstring& description, JS::HandleValue GUIMetadata);
void QuickSave(ScriptInterface::CmptPrivate* pCmptPrivate, JS::HandleValue GUIMetadata);
void QuickLoad(ScriptInterface::CmptPrivate* pCmptPrivate);
JS::Value StartSavedGame(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& name);
void RegisterScriptFunctions(const ScriptInterface& scriptInterface);
}

View File

@ -26,27 +26,27 @@
#include <string>
bool JSI_UserReport::IsUserReportEnabled(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
bool JSI_UserReport::IsUserReportEnabled(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return g_UserReporter.IsReportingEnabled();
}
void JSI_UserReport::SetUserReportEnabled(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), bool enabled)
void JSI_UserReport::SetUserReportEnabled(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), bool enabled)
{
g_UserReporter.SetReportingEnabled(enabled);
}
std::string JSI_UserReport::GetUserReportStatus(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
std::string JSI_UserReport::GetUserReportStatus(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return g_UserReporter.GetStatus();
}
std::string JSI_UserReport::GetUserReportLogPath(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
std::string JSI_UserReport::GetUserReportLogPath(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return psLogDir().string8();
}
std::string JSI_UserReport::GetUserReportConfigPath(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
std::string JSI_UserReport::GetUserReportConfigPath(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
OsPath configPath;
WARN_IF_ERR(g_VFS->GetDirectoryRealPath("config/", configPath));

View File

@ -24,11 +24,11 @@
namespace JSI_UserReport
{
bool IsUserReportEnabled(ScriptInterface::CxPrivate* pCxPrivate);
void SetUserReportEnabled(ScriptInterface::CxPrivate* pCxPrivate, bool enabled);
std::string GetUserReportStatus(ScriptInterface::CxPrivate* pCxPrivate);
std::string GetUserReportLogPath(ScriptInterface::CxPrivate* pCxPrivate);
std::string GetUserReportConfigPath(ScriptInterface::CxPrivate* pCxPrivate);
bool IsUserReportEnabled(ScriptInterface::CmptPrivate* pCmptPrivate);
void SetUserReportEnabled(ScriptInterface::CmptPrivate* pCmptPrivate, bool enabled);
std::string GetUserReportStatus(ScriptInterface::CmptPrivate* pCmptPrivate);
std::string GetUserReportLogPath(ScriptInterface::CmptPrivate* pCmptPrivate);
std::string GetUserReportConfigPath(ScriptInterface::CmptPrivate* pCmptPrivate);
void RegisterScriptFunctions(const ScriptInterface& ScriptInterface);
}

View File

@ -80,9 +80,9 @@ static Status BuildDirEntListCB(const VfsPath& pathname, const CFileInfo& UNUSED
// specified directory.
// filter_string: default "" matches everything; otherwise, see vfs_next_dirent.
// recurse: should subdirectories be included in the search? default false.
JS::Value JSI_VFS::BuildDirEntList(ScriptInterface::CxPrivate* pCxPrivate, const std::vector<CStrW>& validPaths, const std::wstring& path, const std::wstring& filterStr, bool recurse)
JS::Value JSI_VFS::BuildDirEntList(ScriptInterface::CmptPrivate* pCmptPrivate, const std::vector<CStrW>& validPaths, const std::wstring& path, const std::wstring& filterStr, bool recurse)
{
if (!PathRestrictionMet(pCxPrivate, validPaths, path))
if (!PathRestrictionMet(pCmptPrivate, validPaths, path))
return JS::NullValue();
// convert to const wchar_t*; if there's no filter, pass 0 for speed
@ -94,20 +94,20 @@ JS::Value JSI_VFS::BuildDirEntList(ScriptInterface::CxPrivate* pCxPrivate, const
int flags = recurse ? vfs::DIR_RECURSIVE : 0;
// build array in the callback function
BuildDirEntListState state(pCxPrivate->pScriptInterface);
BuildDirEntListState state(pCmptPrivate->pScriptInterface);
vfs::ForEachFile(g_VFS, path, BuildDirEntListCB, (uintptr_t)&state, filter, flags);
return JS::ObjectValue(*state.filename_array);
}
// Return true iff the file exits
bool JSI_VFS::FileExists(ScriptInterface::CxPrivate* pCxPrivate, const std::vector<CStrW>& validPaths, const CStrW& filename)
bool JSI_VFS::FileExists(ScriptInterface::CmptPrivate* pCmptPrivate, const std::vector<CStrW>& validPaths, const CStrW& filename)
{
return PathRestrictionMet(pCxPrivate, validPaths, filename) && g_VFS->GetFileInfo(filename, 0) == INFO::OK;
return PathRestrictionMet(pCmptPrivate, validPaths, filename) && g_VFS->GetFileInfo(filename, 0) == INFO::OK;
}
// Return time [seconds since 1970] of the last modification to the specified file.
double JSI_VFS::GetFileMTime(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& filename)
double JSI_VFS::GetFileMTime(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& filename)
{
CFileInfo fileInfo;
Status err = g_VFS->GetFileInfo(filename, &fileInfo);
@ -117,7 +117,7 @@ double JSI_VFS::GetFileMTime(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), con
}
// Return current size of file.
unsigned int JSI_VFS::GetFileSize(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& filename)
unsigned int JSI_VFS::GetFileSize(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& filename)
{
CFileInfo fileInfo;
Status err = g_VFS->GetFileInfo(filename, &fileInfo);
@ -127,7 +127,7 @@ unsigned int JSI_VFS::GetFileSize(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)
}
// Return file contents in a string. Assume file is UTF-8 encoded text.
JS::Value JSI_VFS::ReadFile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& filename)
JS::Value JSI_VFS::ReadFile(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& filename)
{
CVFSFile file;
if (file.Load(g_VFS, filename) != PSRETURN_OK)
@ -139,14 +139,14 @@ JS::Value JSI_VFS::ReadFile(ScriptInterface::CxPrivate* pCxPrivate, const std::w
contents.Replace("\r\n", "\n");
// Decode as UTF-8
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS::RootedValue ret(rq.cx);
ScriptInterface::ToJSVal(rq, &ret, contents.FromUTF8());
return ret;
}
// Return file contents as an array of lines. Assume file is UTF-8 encoded text.
JS::Value JSI_VFS::ReadFileLines(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& filename)
JS::Value JSI_VFS::ReadFileLines(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& filename)
{
CVFSFile file;
if (file.Load(g_VFS, filename) != PSRETURN_OK)
@ -160,7 +160,7 @@ JS::Value JSI_VFS::ReadFileLines(ScriptInterface::CxPrivate* pCxPrivate, const s
// split into array of strings (one per line)
std::stringstream ss(contents);
const ScriptInterface& scriptInterface = *pCxPrivate->pScriptInterface;
const ScriptInterface& scriptInterface = *pCmptPrivate->pScriptInterface;
ScriptInterface::Request rq(scriptInterface);
JS::RootedValue line_array(rq.cx);
@ -180,21 +180,21 @@ JS::Value JSI_VFS::ReadFileLines(ScriptInterface::CxPrivate* pCxPrivate, const s
return line_array;
}
JS::Value JSI_VFS::ReadJSONFile(ScriptInterface::CxPrivate* pCxPrivate, const std::vector<CStrW>& validPaths, const CStrW& filePath)
JS::Value JSI_VFS::ReadJSONFile(ScriptInterface::CmptPrivate* pCmptPrivate, const std::vector<CStrW>& validPaths, const CStrW& filePath)
{
if (!PathRestrictionMet(pCxPrivate, validPaths, filePath))
if (!PathRestrictionMet(pCmptPrivate, validPaths, filePath))
return JS::NullValue();
const ScriptInterface& scriptInterface = *pCxPrivate->pScriptInterface;
const ScriptInterface& scriptInterface = *pCmptPrivate->pScriptInterface;
ScriptInterface::Request rq(scriptInterface);
JS::RootedValue out(rq.cx);
scriptInterface.ReadJSONFile(filePath, &out);
return out;
}
void JSI_VFS::WriteJSONFile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& filePath, JS::HandleValue val1)
void JSI_VFS::WriteJSONFile(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& filePath, JS::HandleValue val1)
{
const ScriptInterface& scriptInterface = *pCxPrivate->pScriptInterface;
const ScriptInterface& scriptInterface = *pCmptPrivate->pScriptInterface;
ScriptInterface::Request rq(scriptInterface);
// TODO: This is a workaround because we need to pass a MutableHandle to StringifyJSON.
@ -208,7 +208,7 @@ void JSI_VFS::WriteJSONFile(ScriptInterface::CxPrivate* pCxPrivate, const std::w
g_VFS->CreateFile(path, buf.Data(), buf.Size());
}
bool JSI_VFS::PathRestrictionMet(ScriptInterface::CxPrivate* pCxPrivate, const std::vector<CStrW>& validPaths, const CStrW& filePath)
bool JSI_VFS::PathRestrictionMet(ScriptInterface::CmptPrivate* pCmptPrivate, const std::vector<CStrW>& validPaths, const CStrW& filePath)
{
for (const CStrW& validPath : validPaths)
if (filePath.find(validPath) == 0)
@ -223,24 +223,24 @@ bool JSI_VFS::PathRestrictionMet(ScriptInterface::CxPrivate* pCxPrivate, const s
allowedPaths += L"\"" + validPaths[i] + L"\"";
}
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS_ReportError(rq.cx, "This part of the engine may only read from %s!", utf8_from_wstring(allowedPaths).c_str());
return false;
}
#define VFS_ScriptFunctions(context)\
JS::Value Script_ReadJSONFile_##context(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& filePath)\
JS::Value Script_ReadJSONFile_##context(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& filePath)\
{\
return JSI_VFS::ReadJSONFile(pCxPrivate, PathRestriction_##context, filePath);\
return JSI_VFS::ReadJSONFile(pCmptPrivate, PathRestriction_##context, filePath);\
}\
JS::Value Script_ListDirectoryFiles_##context(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& path, const std::wstring& filterStr, bool recurse)\
JS::Value Script_ListDirectoryFiles_##context(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& path, const std::wstring& filterStr, bool recurse)\
{\
return JSI_VFS::BuildDirEntList(pCxPrivate, PathRestriction_##context, path, filterStr, recurse);\
return JSI_VFS::BuildDirEntList(pCmptPrivate, PathRestriction_##context, path, filterStr, recurse);\
}\
bool Script_FileExists_##context(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& filePath)\
bool Script_FileExists_##context(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& filePath)\
{\
return JSI_VFS::FileExists(pCxPrivate, PathRestriction_##context, filePath);\
return JSI_VFS::FileExists(pCmptPrivate, PathRestriction_##context, filePath);\
}\
VFS_ScriptFunctions(GUI);

View File

@ -24,31 +24,31 @@ namespace JSI_VFS
{
// Return an array of pathname strings, one for each matching entry in the
// specified directory.
JS::Value BuildDirEntList(ScriptInterface::CxPrivate* pCxPrivate, const std::vector<CStrW>& validPaths, const std::wstring& path, const std::wstring& filterStr, bool recurse);
JS::Value BuildDirEntList(ScriptInterface::CmptPrivate* pCmptPrivate, const std::vector<CStrW>& validPaths, const std::wstring& path, const std::wstring& filterStr, bool recurse);
// Return true iff the file exists
bool FileExists(ScriptInterface::CxPrivate* pCxPrivate, const std::vector<CStrW>& validPaths, const CStrW& filename);
bool FileExists(ScriptInterface::CmptPrivate* pCmptPrivate, const std::vector<CStrW>& validPaths, const CStrW& filename);
// Return time [seconds since 1970] of the last modification to the specified file.
double GetFileMTime(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& filename);
double GetFileMTime(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& filename);
// Return current size of file.
unsigned int GetFileSize(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& filename);
unsigned int GetFileSize(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& filename);
// Return file contents in a string.
JS::Value ReadFile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& filename);
JS::Value ReadFile(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& filename);
// Return file contents as an array of lines.
JS::Value ReadFileLines(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& filename);
JS::Value ReadFileLines(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& filename);
// Return file contents parsed as a JS Object
JS::Value ReadJSONFile(ScriptInterface::CxPrivate* pCxPrivate, const std::vector<CStrW>& validPaths, const CStrW& filePath);
JS::Value ReadJSONFile(ScriptInterface::CmptPrivate* pCmptPrivate, const std::vector<CStrW>& validPaths, const CStrW& filePath);
// Save given JS Object to a JSON file
void WriteJSONFile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& filePath, JS::HandleValue val1);
void WriteJSONFile(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& filePath, JS::HandleValue val1);
// Tests whether the current script context is allowed to read from the given directory
bool PathRestrictionMet(ScriptInterface::CxPrivate* pCxPrivate, const std::vector<CStrW>& validPaths, const CStrW& filePath);
bool PathRestrictionMet(ScriptInterface::CmptPrivate* pCmptPrivate, const std::vector<CStrW>& validPaths, const CStrW& filePath);
void RegisterScriptFunctions_GUI(const ScriptInterface& scriptInterface);
void RegisterScriptFunctions_Simulation(const ScriptInterface& scriptInterface);

View File

@ -23,42 +23,42 @@
#include "ps/VisualReplay.h"
#include "scriptinterface/ScriptInterface.h"
bool JSI_VisualReplay::StartVisualReplay(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const CStrW& directory)
bool JSI_VisualReplay::StartVisualReplay(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const CStrW& directory)
{
return VisualReplay::StartVisualReplay(directory);
}
bool JSI_VisualReplay::DeleteReplay(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const CStrW& replayFile)
bool JSI_VisualReplay::DeleteReplay(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const CStrW& replayFile)
{
return VisualReplay::DeleteReplay(replayFile);
}
JS::Value JSI_VisualReplay::GetReplays(ScriptInterface::CxPrivate* pCxPrivate, bool compareFiles)
JS::Value JSI_VisualReplay::GetReplays(ScriptInterface::CmptPrivate* pCmptPrivate, bool compareFiles)
{
return VisualReplay::GetReplays(*(pCxPrivate->pScriptInterface), compareFiles);
return VisualReplay::GetReplays(*(pCmptPrivate->pScriptInterface), compareFiles);
}
JS::Value JSI_VisualReplay::GetReplayAttributes(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& directoryName)
JS::Value JSI_VisualReplay::GetReplayAttributes(ScriptInterface::CmptPrivate* pCmptPrivate, const CStrW& directoryName)
{
return VisualReplay::GetReplayAttributes(pCxPrivate, directoryName);
return VisualReplay::GetReplayAttributes(pCmptPrivate, directoryName);
}
bool JSI_VisualReplay::HasReplayMetadata(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const CStrW& directoryName)
bool JSI_VisualReplay::HasReplayMetadata(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const CStrW& directoryName)
{
return VisualReplay::HasReplayMetadata(directoryName);
}
JS::Value JSI_VisualReplay::GetReplayMetadata(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& directoryName)
JS::Value JSI_VisualReplay::GetReplayMetadata(ScriptInterface::CmptPrivate* pCmptPrivate, const CStrW& directoryName)
{
return VisualReplay::GetReplayMetadata(pCxPrivate, directoryName);
return VisualReplay::GetReplayMetadata(pCmptPrivate, directoryName);
}
void JSI_VisualReplay::AddReplayToCache(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& directoryName)
void JSI_VisualReplay::AddReplayToCache(ScriptInterface::CmptPrivate* pCmptPrivate, const CStrW& directoryName)
{
VisualReplay::AddReplayToCache(*(pCxPrivate->pScriptInterface), directoryName);
VisualReplay::AddReplayToCache(*(pCmptPrivate->pScriptInterface), directoryName);
}
CStrW JSI_VisualReplay::GetReplayDirectoryName(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const CStrW& directoryName)
CStrW JSI_VisualReplay::GetReplayDirectoryName(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const CStrW& directoryName)
{
return wstring_from_utf8(OsPath(VisualReplay::GetDirectoryPath() / directoryName).string8());
}

View File

@ -22,15 +22,15 @@
namespace JSI_VisualReplay
{
bool StartVisualReplay(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& directory);
bool DeleteReplay(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& replayFile);
JS::Value GetReplays(ScriptInterface::CxPrivate* pCxPrivate, bool compareFiles);
JS::Value GetReplayAttributes(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& directoryName);
bool HasReplayMetadata(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& directoryName);
JS::Value GetReplayMetadata(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& directoryName);
void AddReplayToCache(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& directoryName);
bool StartVisualReplay(ScriptInterface::CmptPrivate* pCmptPrivate, const CStrW& directory);
bool DeleteReplay(ScriptInterface::CmptPrivate* pCmptPrivate, const CStrW& replayFile);
JS::Value GetReplays(ScriptInterface::CmptPrivate* pCmptPrivate, bool compareFiles);
JS::Value GetReplayAttributes(ScriptInterface::CmptPrivate* pCmptPrivate, const CStrW& directoryName);
bool HasReplayMetadata(ScriptInterface::CmptPrivate* pCmptPrivate, const CStrW& directoryName);
JS::Value GetReplayMetadata(ScriptInterface::CmptPrivate* pCmptPrivate, const CStrW& directoryName);
void AddReplayToCache(ScriptInterface::CmptPrivate* pCmptPrivate, const CStrW& directoryName);
void RegisterScriptFunctions(const ScriptInterface& scriptInterface);
CStrW GetReplayDirectoryName(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& directoryName);
CStrW GetReplayDirectoryName(ScriptInterface::CmptPrivate* pCmptPrivate, const CStrW& directoryName);
}
#endif // INCLUDED_JSI_VISUALREPLAY

View File

@ -27,12 +27,12 @@
#include "scriptinterface/ScriptInterface.h"
#define IMPLEMENT_BOOLEAN_SCRIPT_SETTING(NAME) \
bool JSI_Renderer::Get##NAME##Enabled(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) \
bool JSI_Renderer::Get##NAME##Enabled(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate)) \
{ \
return g_RenderingOptions.Get##NAME(); \
} \
\
void JSI_Renderer::Set##NAME##Enabled(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), bool enabled) \
void JSI_Renderer::Set##NAME##Enabled(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), bool enabled) \
{ \
g_RenderingOptions.Set##NAME(enabled); \
}
@ -57,37 +57,37 @@ IMPLEMENT_BOOLEAN_SCRIPT_SETTING(DisplayShadowsFrustum);
#undef IMPLEMENT_BOOLEAN_SCRIPT_SETTING
std::string JSI_Renderer::GetRenderPath(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
std::string JSI_Renderer::GetRenderPath(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return RenderPathEnum::ToString(g_RenderingOptions.GetRenderPath());
}
void JSI_Renderer::SetRenderPath(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& name)
void JSI_Renderer::SetRenderPath(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& name)
{
g_RenderingOptions.SetRenderPath(RenderPathEnum::FromString(name));
}
void JSI_Renderer::UpdateAntiAliasingTechnique(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_Renderer::UpdateAntiAliasingTechnique(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
g_Renderer.GetPostprocManager().UpdateAntiAliasingTechnique();
}
void JSI_Renderer::UpdateSharpeningTechnique(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_Renderer::UpdateSharpeningTechnique(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
g_Renderer.GetPostprocManager().UpdateSharpeningTechnique();
}
void JSI_Renderer::UpdateSharpnessFactor(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_Renderer::UpdateSharpnessFactor(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
g_Renderer.GetPostprocManager().UpdateSharpnessFactor();
}
void JSI_Renderer::RecreateShadowMap(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_Renderer::RecreateShadowMap(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
g_Renderer.GetShadowMap().RecreateTexture();
}
bool JSI_Renderer::TextureExists(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& filename)
bool JSI_Renderer::TextureExists(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& filename)
{
return g_Renderer.GetTextureManager().TextureExists(filename);
}

View File

@ -21,18 +21,18 @@
#include "scriptinterface/ScriptInterface.h"
#define DECLARE_BOOLEAN_SCRIPT_SETTING(NAME) \
bool Get##NAME##Enabled(ScriptInterface::CxPrivate* pCxPrivate); \
void Set##NAME##Enabled(ScriptInterface::CxPrivate* pCxPrivate, bool Enabled);
bool Get##NAME##Enabled(ScriptInterface::CmptPrivate* pCmptPrivate); \
void Set##NAME##Enabled(ScriptInterface::CmptPrivate* pCmptPrivate, bool Enabled);
namespace JSI_Renderer
{
std::string GetRenderPath(ScriptInterface::CxPrivate* pCxPrivate);
void SetRenderPath(ScriptInterface::CxPrivate* pCxPrivate, const std::string& name);
void UpdateAntiAliasingTechnique(ScriptInterface::CxPrivate* pCxPrivate);
void UpdateSharpeningTechnique(ScriptInterface::CxPrivate* pCxPrivate);
void UpdateSharpnessFactor(ScriptInterface::CxPrivate* pCxPrivate);
void RecreateShadowMap(ScriptInterface::CxPrivate* pCxPrivate);
bool TextureExists(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& filename);
std::string GetRenderPath(ScriptInterface::CmptPrivate* pCmptPrivate);
void SetRenderPath(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& name);
void UpdateAntiAliasingTechnique(ScriptInterface::CmptPrivate* pCmptPrivate);
void UpdateSharpeningTechnique(ScriptInterface::CmptPrivate* pCmptPrivate);
void UpdateSharpnessFactor(ScriptInterface::CmptPrivate* pCmptPrivate);
void RecreateShadowMap(ScriptInterface::CmptPrivate* pCmptPrivate);
bool TextureExists(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& filename);
DECLARE_BOOLEAN_SCRIPT_SETTING(Shadows);
DECLARE_BOOLEAN_SCRIPT_SETTING(ShadowPCF);

View File

@ -58,7 +58,7 @@ template <typename T> struct MaybeRef;
// Define RegisterFunction<TR, T0..., f>
#define OVERLOADS(z, i, data) \
template <typename R, TYPENAME_T0_HEAD(z,i) R (*fptr) ( ScriptInterface::CxPrivate* T0_TAIL_MAYBE_REF(z,i) )> \
template <typename R, TYPENAME_T0_HEAD(z,i) R (*fptr) ( ScriptInterface::CmptPrivate* T0_TAIL_MAYBE_REF(z,i) )> \
void RegisterFunction(const char* name) const \
{ \
Register(name, call<R T0_TAIL(z,i), fptr>, nargs<T0(z,i)>()); \
@ -69,7 +69,7 @@ BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
// JSFastNative-compatible function that wraps the function identified in the template argument list
// (Definition comes later, since it depends on some things we haven't defined yet)
#define OVERLOADS(z, i, data) \
template <typename R, TYPENAME_T0_HEAD(z,i) R (*fptr) ( ScriptInterface::CxPrivate* T0_TAIL_MAYBE_REF(z,i) )> \
template <typename R, TYPENAME_T0_HEAD(z,i) R (*fptr) ( ScriptInterface::CmptPrivate* T0_TAIL_MAYBE_REF(z,i) )> \
static bool call(JSContext* cx, uint argc, JS::Value* vp);
BOOST_PP_REPEAT(SCRIPT_INTERFACE_MAX_ARGS, OVERLOADS, ~)
#undef OVERLOADS

View File

@ -110,14 +110,14 @@ struct ScriptInterface_NativeMethodWrapper<void, TC>
// JSFastNative-compatible function that wraps the function identified in the template argument list
#define OVERLOADS(z, i, data) \
template <typename R, TYPENAME_T0_HEAD(z,i) R (*fptr) ( ScriptInterface::CxPrivate* T0_TAIL_MAYBE_REF(z,i) )> \
template <typename R, TYPENAME_T0_HEAD(z,i) R (*fptr) ( ScriptInterface::CmptPrivate* T0_TAIL_MAYBE_REF(z,i) )> \
bool ScriptInterface::call(JSContext* cx, uint argc, JS::Value* vp) \
{ \
JS::CallArgs args = JS::CallArgsFromVp(argc, vp); \
ScriptInterface::Request rq(*ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface); \
BOOST_PP_REPEAT_##z (i, CONVERT_ARG, ~) \
JS::RootedValue rval(rq.cx); \
ScriptInterface_NativeWrapper<R>::template call<R( ScriptInterface::CxPrivate* T0_TAIL_MAYBE_REF(z,i)) T0_TAIL(z,i)>(rq, &rval, fptr A0_TAIL(z,i)); \
ScriptInterface_NativeWrapper<R>::template call<R( ScriptInterface::CmptPrivate* T0_TAIL_MAYBE_REF(z,i)) T0_TAIL(z,i)>(rq, &rval, fptr A0_TAIL(z,i)); \
args.rval().set(rval); \
return !ScriptInterface::IsExceptionPending(rq); \
}

View File

@ -430,8 +430,8 @@ ScriptInterface::ScriptInterface(const char* nativeScopeName, const char* debugN
}
Request rq(this);
m_CxPrivate.pScriptInterface = this;
JS_SetContextPrivate(rq.cx, (void*)&m_CxPrivate);
m_CmptPrivate.pScriptInterface = this;
JS_SetContextPrivate(rq.cx, (void*)&m_CmptPrivate);
}
ScriptInterface::~ScriptInterface()
@ -445,13 +445,13 @@ ScriptInterface::~ScriptInterface()
void ScriptInterface::SetCallbackData(void* pCBData)
{
m_CxPrivate.pCBData = pCBData;
m_CmptPrivate.pCBData = pCBData;
}
ScriptInterface::CxPrivate* ScriptInterface::GetScriptInterfaceAndCBData(JSContext* cx)
ScriptInterface::CmptPrivate* ScriptInterface::GetScriptInterfaceAndCBData(JSContext* cx)
{
CxPrivate* pCxPrivate = (CxPrivate*)JS_GetContextPrivate(cx);
return pCxPrivate;
CmptPrivate* pCmptPrivate = (CmptPrivate*)JS_GetContextPrivate(cx);
return pCmptPrivate;
}

View File

@ -82,14 +82,14 @@ public:
~ScriptInterface();
struct CxPrivate
struct CmptPrivate
{
ScriptInterface* pScriptInterface; // the ScriptInterface object the current context belongs to
void* pCBData; // meant to be used as the "this" object for callback functions
} m_CxPrivate;
} m_CmptPrivate;
void SetCallbackData(void* pCBData);
static CxPrivate* GetScriptInterfaceAndCBData(JSContext* cx);
static CmptPrivate* GetScriptInterfaceAndCBData(JSContext* cx);
JSRuntime* GetJSRuntime() const;
shared_ptr<ScriptRuntime> GetRuntime() const;
@ -107,7 +107,7 @@ public:
Request(const ScriptInterface& scriptInterface);
Request(const ScriptInterface* scriptInterface) : Request(*scriptInterface) {}
Request(shared_ptr<ScriptInterface> scriptInterface) : Request(*scriptInterface) {}
Request(const CxPrivate* cxPrivate) : Request(cxPrivate->pScriptInterface) {}
Request(const CmptPrivate* CmptPrivate) : Request(CmptPrivate->pScriptInterface) {}
~Request();
JSContext* cx;

View File

@ -279,17 +279,17 @@ public:
return true;
}
static void IncludeModule(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& name)
static void IncludeModule(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& name)
{
ENSURE(pCxPrivate->pCBData);
CAIWorker* self = static_cast<CAIWorker*> (pCxPrivate->pCBData);
ENSURE(pCmptPrivate->pCBData);
CAIWorker* self = static_cast<CAIWorker*> (pCmptPrivate->pCBData);
self->LoadScripts(name);
}
static void PostCommand(ScriptInterface::CxPrivate* pCxPrivate, int playerid, JS::HandleValue cmd)
static void PostCommand(ScriptInterface::CmptPrivate* pCmptPrivate, int playerid, JS::HandleValue cmd)
{
ENSURE(pCxPrivate->pCBData);
CAIWorker* self = static_cast<CAIWorker*> (pCxPrivate->pCBData);
ENSURE(pCmptPrivate->pCBData);
CAIWorker* self = static_cast<CAIWorker*> (pCmptPrivate->pCBData);
self->PostCommand(playerid, cmd);
}
@ -307,11 +307,11 @@ public:
LOGERROR("Invalid playerid in PostCommand!");
}
static JS::Value ComputePath(ScriptInterface::CxPrivate* pCxPrivate,
static JS::Value ComputePath(ScriptInterface::CmptPrivate* pCmptPrivate,
JS::HandleValue position, JS::HandleValue goal, pass_class_t passClass)
{
ENSURE(pCxPrivate->pCBData);
CAIWorker* self = static_cast<CAIWorker*> (pCxPrivate->pCBData);
ENSURE(pCmptPrivate->pCBData);
CAIWorker* self = static_cast<CAIWorker*> (pCmptPrivate->pCBData);
ScriptInterface::Request rq(self->m_ScriptInterface);
CFixedVector2D pos, goalPos;
@ -337,10 +337,10 @@ public:
waypoints.emplace_back(wp.x, wp.z);
}
static CParamNode GetTemplate(ScriptInterface::CxPrivate* pCxPrivate, const std::string& name)
static CParamNode GetTemplate(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& name)
{
ENSURE(pCxPrivate->pCBData);
CAIWorker* self = static_cast<CAIWorker*> (pCxPrivate->pCBData);
ENSURE(pCmptPrivate->pCBData);
CAIWorker* self = static_cast<CAIWorker*> (pCmptPrivate->pCBData);
return self->GetTemplate(name);
}
@ -352,7 +352,7 @@ public:
return m_TemplateLoader.GetTemplateFileData(name).GetChild("Entity");
}
static void ExitProgram(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
static void ExitProgram(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
QuitEngine();
}
@ -360,7 +360,7 @@ public:
/**
* Debug function for AI scripts to dump 2D array data (e.g. terrain tile weights).
*/
static void DumpImage(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& name, const std::vector<u32>& data, u32 w, u32 h, u32 max)
static void DumpImage(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& name, const std::vector<u32>& data, u32 w, u32 h, u32 max)
{
// TODO: this is totally not threadsafe.
VfsPath filename = L"screenshots/aidump/" + name;

View File

@ -44,15 +44,15 @@ public:
TSM_ASSERT(L"Running script "+pathname.string(), scriptInterface.LoadScript(pathname, content));
}
static void Script_LoadComponentScript(ScriptInterface::CxPrivate* pCxPrivate, const VfsPath& pathname)
static void Script_LoadComponentScript(ScriptInterface::CmptPrivate* pCmptPrivate, const VfsPath& pathname)
{
CComponentManager* componentManager = static_cast<CComponentManager*> (pCxPrivate->pCBData);
CComponentManager* componentManager = static_cast<CComponentManager*> (pCmptPrivate->pCBData);
TS_ASSERT(componentManager->LoadScript(VfsPath(L"simulation/components") / pathname));
}
static void Script_LoadHelperScript(ScriptInterface::CxPrivate* pCxPrivate, const VfsPath& pathname)
static void Script_LoadHelperScript(ScriptInterface::CmptPrivate* pCmptPrivate, const VfsPath& pathname)
{
CComponentManager* componentManager = static_cast<CComponentManager*> (pCxPrivate->pCBData);
CComponentManager* componentManager = static_cast<CComponentManager*> (pCmptPrivate->pCBData);
TS_ASSERT(componentManager->LoadScript(VfsPath(L"simulation/helpers") / pathname));
}

View File

@ -158,8 +158,8 @@ template<> bool ScriptInterface::FromJSVal<CFixedVector3D>(const Request& rq, J
template<> void ScriptInterface::ToJSVal<CFixedVector3D>(const Request& rq, JS::MutableHandleValue ret, const CFixedVector3D& val)
{
ScriptInterface::CxPrivate* pCxPrivate = ScriptInterface::GetScriptInterfaceAndCBData(rq.cx);
JS::RootedObject global(rq.cx, &pCxPrivate->pScriptInterface->GetGlobalObject().toObject());
ScriptInterface::CmptPrivate* pCmptPrivate = ScriptInterface::GetScriptInterfaceAndCBData(rq.cx);
JS::RootedObject global(rq.cx, &pCmptPrivate->pScriptInterface->GetGlobalObject().toObject());
JS::RootedValue valueVector3D(rq.cx);
if (!JS_GetProperty(rq.cx, global, "Vector3D", &valueVector3D))
FAIL_VOID("Failed to get Vector3D constructor");
@ -192,8 +192,8 @@ template<> bool ScriptInterface::FromJSVal<CFixedVector2D>(const Request& rq, J
template<> void ScriptInterface::ToJSVal<CFixedVector2D>(const Request& rq, JS::MutableHandleValue ret, const CFixedVector2D& val)
{
ScriptInterface::CxPrivate* pCxPrivate = ScriptInterface::GetScriptInterfaceAndCBData(rq.cx);
JS::RootedObject global(rq.cx, &pCxPrivate->pScriptInterface->GetGlobalObject().toObject());
ScriptInterface::CmptPrivate* pCmptPrivate = ScriptInterface::GetScriptInterfaceAndCBData(rq.cx);
JS::RootedObject global(rq.cx, &pCmptPrivate->pScriptInterface->GetGlobalObject().toObject());
JS::RootedValue valueVector2D(rq.cx);
if (!JS_GetProperty(rq.cx, global, "Vector2D", &valueVector2D))
FAIL_VOID("Failed to get Vector2D constructor");

View File

@ -38,7 +38,7 @@
#include <array>
#include <fstream>
JS::Value JSI_Simulation::GuiInterfaceCall(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& name, JS::HandleValue data)
JS::Value JSI_Simulation::GuiInterfaceCall(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& name, JS::HandleValue data)
{
if (!g_Game)
return JS::UndefinedValue();
@ -51,14 +51,14 @@ JS::Value JSI_Simulation::GuiInterfaceCall(ScriptInterface::CxPrivate* pCxPrivat
return JS::UndefinedValue();
ScriptInterface::Request rqSim(sim->GetScriptInterface());
JS::RootedValue arg(rqSim.cx, sim->GetScriptInterface().CloneValueFromOtherContext(*(pCxPrivate->pScriptInterface), data));
JS::RootedValue arg(rqSim.cx, sim->GetScriptInterface().CloneValueFromOtherContext(*(pCmptPrivate->pScriptInterface), data));
JS::RootedValue ret(rqSim.cx);
cmpGuiInterface->ScriptCall(g_Game->GetViewedPlayerID(), name, arg, &ret);
return pCxPrivate->pScriptInterface->CloneValueFromOtherContext(sim->GetScriptInterface(), ret);
return pCmptPrivate->pScriptInterface->CloneValueFromOtherContext(sim->GetScriptInterface(), ret);
}
void JSI_Simulation::PostNetworkCommand(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue cmd)
void JSI_Simulation::PostNetworkCommand(ScriptInterface::CmptPrivate* pCmptPrivate, JS::HandleValue cmd)
{
if (!g_Game)
return;
@ -71,39 +71,39 @@ void JSI_Simulation::PostNetworkCommand(ScriptInterface::CxPrivate* pCxPrivate,
return;
ScriptInterface::Request rqSim(sim->GetScriptInterface());
JS::RootedValue cmd2(rqSim.cx, sim->GetScriptInterface().CloneValueFromOtherContext(*(pCxPrivate->pScriptInterface), cmd));
JS::RootedValue cmd2(rqSim.cx, sim->GetScriptInterface().CloneValueFromOtherContext(*(pCmptPrivate->pScriptInterface), cmd));
cmpCommandQueue->PostNetworkCommand(cmd2);
}
void JSI_Simulation::DumpSimState(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void JSI_Simulation::DumpSimState(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
OsPath path = psLogDir()/"sim_dump.txt";
std::ofstream file (OsString(path).c_str(), std::ofstream::out | std::ofstream::trunc);
g_Game->GetSimulation2()->DumpDebugState(file);
}
entity_id_t JSI_Simulation::PickEntityAtPoint(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), int x, int y)
entity_id_t JSI_Simulation::PickEntityAtPoint(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), int x, int y)
{
return EntitySelection::PickEntityAtPoint(*g_Game->GetSimulation2(), *g_Game->GetView()->GetCamera(), x, y, g_Game->GetViewedPlayerID(), false);
}
std::vector<entity_id_t> JSI_Simulation::PickPlayerEntitiesInRect(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), int x0, int y0, int x1, int y1, int player)
std::vector<entity_id_t> JSI_Simulation::PickPlayerEntitiesInRect(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), int x0, int y0, int x1, int y1, int player)
{
return EntitySelection::PickEntitiesInRect(*g_Game->GetSimulation2(), *g_Game->GetView()->GetCamera(), x0, y0, x1, y1, player, false);
}
std::vector<entity_id_t> JSI_Simulation::PickPlayerEntitiesOnScreen(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), int player)
std::vector<entity_id_t> JSI_Simulation::PickPlayerEntitiesOnScreen(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), int player)
{
return EntitySelection::PickEntitiesInRect(*g_Game->GetSimulation2(), *g_Game->GetView()->GetCamera(), 0, 0, g_xres, g_yres, player, false);
}
std::vector<entity_id_t> JSI_Simulation::PickNonGaiaEntitiesOnScreen(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
std::vector<entity_id_t> JSI_Simulation::PickNonGaiaEntitiesOnScreen(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return EntitySelection::PickNonGaiaEntitiesInRect(*g_Game->GetSimulation2(), *g_Game->GetView()->GetCamera(), 0, 0, g_xres, g_yres, false);
}
std::vector<entity_id_t> JSI_Simulation::GetEntitiesWithStaticObstructionOnScreen(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
std::vector<entity_id_t> JSI_Simulation::GetEntitiesWithStaticObstructionOnScreen(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
struct StaticObstructionFilter
{
@ -116,7 +116,7 @@ std::vector<entity_id_t> JSI_Simulation::GetEntitiesWithStaticObstructionOnScree
return EntitySelection::GetEntitiesWithComponentInRect<StaticObstructionFilter>(*g_Game->GetSimulation2(), IID_Obstruction, *g_Game->GetView()->GetCamera(), 0, 0, g_xres, g_yres);
}
JS::Value JSI_Simulation::GetEdgesOfStaticObstructionsOnScreenNearTo(ScriptInterface::CxPrivate* pCxPrivate, entity_pos_t x, entity_pos_t z)
JS::Value JSI_Simulation::GetEdgesOfStaticObstructionsOnScreenNearTo(ScriptInterface::CmptPrivate* pCmptPrivate, entity_pos_t x, entity_pos_t z)
{
if (!g_Game)
return JS::UndefinedValue();
@ -124,7 +124,7 @@ JS::Value JSI_Simulation::GetEdgesOfStaticObstructionsOnScreenNearTo(ScriptInter
CSimulation2* sim = g_Game->GetSimulation2();
ENSURE(sim);
ScriptInterface::Request rq(pCxPrivate);
ScriptInterface::Request rq(pCmptPrivate);
JS::RootedValue edgeList(rq.cx);
ScriptInterface::CreateArray(rq, &edgeList);
int edgeListIndex = 0;
@ -133,7 +133,7 @@ JS::Value JSI_Simulation::GetEdgesOfStaticObstructionsOnScreenNearTo(ScriptInter
CFG_GET_VAL("gui.session.snaptoedgesdistancethreshold", distanceThreshold);
CFixedVector2D entityPos(x, z);
std::vector<entity_id_t> entities = GetEntitiesWithStaticObstructionOnScreen(pCxPrivate);
std::vector<entity_id_t> entities = GetEntitiesWithStaticObstructionOnScreen(pCmptPrivate);
for (entity_id_t entity : entities)
{
CmpPtr<ICmpObstruction> cmpObstruction(sim->GetSimContext(), entity);
@ -180,23 +180,23 @@ JS::Value JSI_Simulation::GetEdgesOfStaticObstructionsOnScreenNearTo(ScriptInter
"normal", normal,
"order", "cw");
pCxPrivate->pScriptInterface->SetPropertyInt(edgeList, edgeListIndex++, edge);
pCmptPrivate->pScriptInterface->SetPropertyInt(edgeList, edgeListIndex++, edge);
}
}
return edgeList;
}
std::vector<entity_id_t> JSI_Simulation::PickSimilarPlayerEntities(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& templateName, bool includeOffScreen, bool matchRank, bool allowFoundations)
std::vector<entity_id_t> JSI_Simulation::PickSimilarPlayerEntities(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::string& templateName, bool includeOffScreen, bool matchRank, bool allowFoundations)
{
return EntitySelection::PickSimilarEntities(*g_Game->GetSimulation2(), *g_Game->GetView()->GetCamera(), templateName, g_Game->GetViewedPlayerID(), includeOffScreen, matchRank, false, allowFoundations);
}
JS::Value JSI_Simulation::GetAIs(ScriptInterface::CxPrivate* pCxPrivate)
JS::Value JSI_Simulation::GetAIs(ScriptInterface::CmptPrivate* pCmptPrivate)
{
return ICmpAIManager::GetAIs(*(pCxPrivate->pScriptInterface));
return ICmpAIManager::GetAIs(*(pCmptPrivate->pScriptInterface));
}
void JSI_Simulation::SetBoundingBoxDebugOverlay(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), bool enabled)
void JSI_Simulation::SetBoundingBoxDebugOverlay(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), bool enabled)
{
ICmpSelectable::ms_EnableDebugOverlays = enabled;
}

View File

@ -24,18 +24,18 @@
namespace JSI_Simulation
{
JS::Value GuiInterfaceCall(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& name, JS::HandleValue data);
void PostNetworkCommand(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue cmd);
entity_id_t PickEntityAtPoint(ScriptInterface::CxPrivate* pCxPrivate, int x, int y);
void DumpSimState(ScriptInterface::CxPrivate* pCxPrivate);
std::vector<entity_id_t> PickPlayerEntitiesInRect(ScriptInterface::CxPrivate* pCxPrivate, int x0, int y0, int x1, int y1, int player);
std::vector<entity_id_t> PickPlayerEntitiesOnScreen(ScriptInterface::CxPrivate* pCxPrivate, int player);
std::vector<entity_id_t> PickNonGaiaEntitiesOnScreen(ScriptInterface::CxPrivate* pCxPrivate);
std::vector<entity_id_t> GetEntitiesWithStaticObstructionOnScreen(ScriptInterface::CxPrivate* pCxPrivate);
JS::Value GetEdgesOfStaticObstructionsOnScreenNearTo(ScriptInterface::CxPrivate* pCxPrivate, entity_pos_t x, entity_pos_t z);
std::vector<entity_id_t> PickSimilarPlayerEntities(ScriptInterface::CxPrivate* pCxPrivate, const std::string& templateName, bool includeOffScreen, bool matchRank, bool allowFoundations);
JS::Value GetAIs(ScriptInterface::CxPrivate* pCxPrivate);
void SetBoundingBoxDebugOverlay(ScriptInterface::CxPrivate* pCxPrivate, bool enabled);
JS::Value GuiInterfaceCall(ScriptInterface::CmptPrivate* pCmptPrivate, const std::wstring& name, JS::HandleValue data);
void PostNetworkCommand(ScriptInterface::CmptPrivate* pCmptPrivate, JS::HandleValue cmd);
entity_id_t PickEntityAtPoint(ScriptInterface::CmptPrivate* pCmptPrivate, int x, int y);
void DumpSimState(ScriptInterface::CmptPrivate* pCmptPrivate);
std::vector<entity_id_t> PickPlayerEntitiesInRect(ScriptInterface::CmptPrivate* pCmptPrivate, int x0, int y0, int x1, int y1, int player);
std::vector<entity_id_t> PickPlayerEntitiesOnScreen(ScriptInterface::CmptPrivate* pCmptPrivate, int player);
std::vector<entity_id_t> PickNonGaiaEntitiesOnScreen(ScriptInterface::CmptPrivate* pCmptPrivate);
std::vector<entity_id_t> GetEntitiesWithStaticObstructionOnScreen(ScriptInterface::CmptPrivate* pCmptPrivate);
JS::Value GetEdgesOfStaticObstructionsOnScreenNearTo(ScriptInterface::CmptPrivate* pCmptPrivate, entity_pos_t x, entity_pos_t z);
std::vector<entity_id_t> PickSimilarPlayerEntities(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& templateName, bool includeOffScreen, bool matchRank, bool allowFoundations);
JS::Value GetAIs(ScriptInterface::CmptPrivate* pCmptPrivate);
void SetBoundingBoxDebugOverlay(ScriptInterface::CmptPrivate* pCmptPrivate, bool enabled);
void RegisterScriptFunctions(const ScriptInterface& ScriptInterface);
}

View File

@ -149,9 +149,9 @@ bool CComponentManager::LoadScript(const VfsPath& filename, bool hotload)
return ok;
}
void CComponentManager::Script_RegisterComponentType_Common(ScriptInterface::CxPrivate* pCxPrivate, int iid, const std::string& cname, JS::HandleValue ctor, bool reRegister, bool systemComponent)
void CComponentManager::Script_RegisterComponentType_Common(ScriptInterface::CmptPrivate* pCmptPrivate, int iid, const std::string& cname, JS::HandleValue ctor, bool reRegister, bool systemComponent)
{
CComponentManager* componentManager = static_cast<CComponentManager*> (pCxPrivate->pCBData);
CComponentManager* componentManager = static_cast<CComponentManager*> (pCmptPrivate->pCBData);
ScriptInterface::Request rq(componentManager->m_ScriptInterface);
// Find the C++ component that wraps the interface
@ -315,28 +315,28 @@ void CComponentManager::Script_RegisterComponentType_Common(ScriptInterface::CxP
}
}
void CComponentManager::Script_RegisterComponentType(ScriptInterface::CxPrivate* pCxPrivate, int iid, const std::string& cname, JS::HandleValue ctor)
void CComponentManager::Script_RegisterComponentType(ScriptInterface::CmptPrivate* pCmptPrivate, int iid, const std::string& cname, JS::HandleValue ctor)
{
CComponentManager* componentManager = static_cast<CComponentManager*> (pCxPrivate->pCBData);
componentManager->Script_RegisterComponentType_Common(pCxPrivate, iid, cname, ctor, false, false);
CComponentManager* componentManager = static_cast<CComponentManager*> (pCmptPrivate->pCBData);
componentManager->Script_RegisterComponentType_Common(pCmptPrivate, iid, cname, ctor, false, false);
componentManager->m_ScriptInterface.SetGlobal(cname.c_str(), ctor, componentManager->m_CurrentlyHotloading);
}
void CComponentManager::Script_RegisterSystemComponentType(ScriptInterface::CxPrivate* pCxPrivate, int iid, const std::string& cname, JS::HandleValue ctor)
void CComponentManager::Script_RegisterSystemComponentType(ScriptInterface::CmptPrivate* pCmptPrivate, int iid, const std::string& cname, JS::HandleValue ctor)
{
CComponentManager* componentManager = static_cast<CComponentManager*> (pCxPrivate->pCBData);
componentManager->Script_RegisterComponentType_Common(pCxPrivate, iid, cname, ctor, false, true);
CComponentManager* componentManager = static_cast<CComponentManager*> (pCmptPrivate->pCBData);
componentManager->Script_RegisterComponentType_Common(pCmptPrivate, iid, cname, ctor, false, true);
componentManager->m_ScriptInterface.SetGlobal(cname.c_str(), ctor, componentManager->m_CurrentlyHotloading);
}
void CComponentManager::Script_ReRegisterComponentType(ScriptInterface::CxPrivate* pCxPrivate, int iid, const std::string& cname, JS::HandleValue ctor)
void CComponentManager::Script_ReRegisterComponentType(ScriptInterface::CmptPrivate* pCmptPrivate, int iid, const std::string& cname, JS::HandleValue ctor)
{
Script_RegisterComponentType_Common(pCxPrivate, iid, cname, ctor, true, false);
Script_RegisterComponentType_Common(pCmptPrivate, iid, cname, ctor, true, false);
}
void CComponentManager::Script_RegisterInterface(ScriptInterface::CxPrivate* pCxPrivate, const std::string& name)
void CComponentManager::Script_RegisterInterface(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& name)
{
CComponentManager* componentManager = static_cast<CComponentManager*> (pCxPrivate->pCBData);
CComponentManager* componentManager = static_cast<CComponentManager*> (pCmptPrivate->pCBData);
std::map<std::string, InterfaceId>::iterator it = componentManager->m_InterfaceIdsByName.find(name);
if (it != componentManager->m_InterfaceIdsByName.end())
@ -355,9 +355,9 @@ void CComponentManager::Script_RegisterInterface(ScriptInterface::CxPrivate* pCx
componentManager->m_ScriptInterface.SetGlobal(("IID_" + name).c_str(), (int)id);
}
void CComponentManager::Script_RegisterMessageType(ScriptInterface::CxPrivate* pCxPrivate, const std::string& name)
void CComponentManager::Script_RegisterMessageType(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& name)
{
CComponentManager* componentManager = static_cast<CComponentManager*> (pCxPrivate->pCBData);
CComponentManager* componentManager = static_cast<CComponentManager*> (pCmptPrivate->pCBData);
std::map<std::string, MessageTypeId>::iterator it = componentManager->m_MessageTypeIdsByName.find(name);
if (it != componentManager->m_MessageTypeIdsByName.end())
@ -375,22 +375,22 @@ void CComponentManager::Script_RegisterMessageType(ScriptInterface::CxPrivate* p
componentManager->m_ScriptInterface.SetGlobal(("MT_" + name).c_str(), (int)id);
}
void CComponentManager::Script_RegisterGlobal(ScriptInterface::CxPrivate* pCxPrivate, const std::string& name, JS::HandleValue value)
void CComponentManager::Script_RegisterGlobal(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& name, JS::HandleValue value)
{
CComponentManager* componentManager = static_cast<CComponentManager*> (pCxPrivate->pCBData);
CComponentManager* componentManager = static_cast<CComponentManager*> (pCmptPrivate->pCBData);
componentManager->m_ScriptInterface.SetGlobal(name.c_str(), value, componentManager->m_CurrentlyHotloading);
}
IComponent* CComponentManager::Script_QueryInterface(ScriptInterface::CxPrivate* pCxPrivate, int ent, int iid)
IComponent* CComponentManager::Script_QueryInterface(ScriptInterface::CmptPrivate* pCmptPrivate, int ent, int iid)
{
CComponentManager* componentManager = static_cast<CComponentManager*> (pCxPrivate->pCBData);
CComponentManager* componentManager = static_cast<CComponentManager*> (pCmptPrivate->pCBData);
IComponent* component = componentManager->QueryInterface((entity_id_t)ent, iid);
return component;
}
std::vector<int> CComponentManager::Script_GetEntitiesWithInterface(ScriptInterface::CxPrivate* pCxPrivate, int iid)
std::vector<int> CComponentManager::Script_GetEntitiesWithInterface(ScriptInterface::CmptPrivate* pCmptPrivate, int iid)
{
CComponentManager* componentManager = static_cast<CComponentManager*> (pCxPrivate->pCBData);
CComponentManager* componentManager = static_cast<CComponentManager*> (pCmptPrivate->pCBData);
std::vector<int> ret;
const InterfaceListUnordered& ents = componentManager->GetEntitiesWithInterfaceUnordered(iid);
@ -401,9 +401,9 @@ std::vector<int> CComponentManager::Script_GetEntitiesWithInterface(ScriptInterf
return ret;
}
std::vector<IComponent*> CComponentManager::Script_GetComponentsWithInterface(ScriptInterface::CxPrivate* pCxPrivate, int iid)
std::vector<IComponent*> CComponentManager::Script_GetComponentsWithInterface(ScriptInterface::CmptPrivate* pCmptPrivate, int iid)
{
CComponentManager* componentManager = static_cast<CComponentManager*> (pCxPrivate->pCBData);
CComponentManager* componentManager = static_cast<CComponentManager*> (pCmptPrivate->pCBData);
std::vector<IComponent*> ret;
InterfaceList ents = componentManager->GetEntitiesWithInterface(iid);
@ -427,9 +427,9 @@ CMessage* CComponentManager::ConstructMessage(int mtid, JS::HandleValue data)
}
}
void CComponentManager::Script_PostMessage(ScriptInterface::CxPrivate* pCxPrivate, int ent, int mtid, JS::HandleValue data)
void CComponentManager::Script_PostMessage(ScriptInterface::CmptPrivate* pCmptPrivate, int ent, int mtid, JS::HandleValue data)
{
CComponentManager* componentManager = static_cast<CComponentManager*> (pCxPrivate->pCBData);
CComponentManager* componentManager = static_cast<CComponentManager*> (pCmptPrivate->pCBData);
CMessage* msg = componentManager->ConstructMessage(mtid, data);
if (!msg)
@ -440,9 +440,9 @@ void CComponentManager::Script_PostMessage(ScriptInterface::CxPrivate* pCxPrivat
delete msg;
}
void CComponentManager::Script_BroadcastMessage(ScriptInterface::CxPrivate* pCxPrivate, int mtid, JS::HandleValue data)
void CComponentManager::Script_BroadcastMessage(ScriptInterface::CmptPrivate* pCmptPrivate, int mtid, JS::HandleValue data)
{
CComponentManager* componentManager = static_cast<CComponentManager*> (pCxPrivate->pCBData);
CComponentManager* componentManager = static_cast<CComponentManager*> (pCmptPrivate->pCBData);
CMessage* msg = componentManager->ConstructMessage(mtid, data);
if (!msg)
@ -453,9 +453,9 @@ void CComponentManager::Script_BroadcastMessage(ScriptInterface::CxPrivate* pCxP
delete msg;
}
int CComponentManager::Script_AddEntity(ScriptInterface::CxPrivate* pCxPrivate, const std::string& templateName)
int CComponentManager::Script_AddEntity(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& templateName)
{
CComponentManager* componentManager = static_cast<CComponentManager*> (pCxPrivate->pCBData);
CComponentManager* componentManager = static_cast<CComponentManager*> (pCmptPrivate->pCBData);
std::wstring name(templateName.begin(), templateName.end());
// TODO: should validate the string to make sure it doesn't contain scary characters
@ -465,9 +465,9 @@ int CComponentManager::Script_AddEntity(ScriptInterface::CxPrivate* pCxPrivate,
return (int)ent;
}
int CComponentManager::Script_AddLocalEntity(ScriptInterface::CxPrivate* pCxPrivate, const std::string& templateName)
int CComponentManager::Script_AddLocalEntity(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& templateName)
{
CComponentManager* componentManager = static_cast<CComponentManager*> (pCxPrivate->pCBData);
CComponentManager* componentManager = static_cast<CComponentManager*> (pCmptPrivate->pCBData);
std::wstring name(templateName.begin(), templateName.end());
// TODO: should validate the string to make sure it doesn't contain scary characters
@ -477,16 +477,16 @@ int CComponentManager::Script_AddLocalEntity(ScriptInterface::CxPrivate* pCxPriv
return (int)ent;
}
void CComponentManager::Script_DestroyEntity(ScriptInterface::CxPrivate* pCxPrivate, int ent)
void CComponentManager::Script_DestroyEntity(ScriptInterface::CmptPrivate* pCmptPrivate, int ent)
{
CComponentManager* componentManager = static_cast<CComponentManager*> (pCxPrivate->pCBData);
CComponentManager* componentManager = static_cast<CComponentManager*> (pCmptPrivate->pCBData);
componentManager->DestroyComponentsSoon(ent);
}
void CComponentManager::Script_FlushDestroyedEntities(ScriptInterface::CxPrivate *pCxPrivate)
void CComponentManager::Script_FlushDestroyedEntities(ScriptInterface::CmptPrivate *pCmptPrivate)
{
CComponentManager* componentManager = static_cast<CComponentManager*> (pCxPrivate->pCBData);
CComponentManager* componentManager = static_cast<CComponentManager*> (pCmptPrivate->pCBData);
componentManager->FlushDestroyedComponents();
}

View File

@ -273,22 +273,22 @@ public:
private:
// Implementations of functions exposed to scripts
static void Script_RegisterComponentType_Common(ScriptInterface::CxPrivate* pCxPrivate, int iid, const std::string& cname, JS::HandleValue ctor, bool reRegister, bool systemComponent);
static void Script_RegisterComponentType(ScriptInterface::CxPrivate* pCxPrivate, int iid, const std::string& cname, JS::HandleValue ctor);
static void Script_RegisterSystemComponentType(ScriptInterface::CxPrivate* pCxPrivate, int iid, const std::string& cname, JS::HandleValue ctor);
static void Script_ReRegisterComponentType(ScriptInterface::CxPrivate* pCxPrivate, int iid, const std::string& cname, JS::HandleValue ctor);
static void Script_RegisterInterface(ScriptInterface::CxPrivate* pCxPrivate, const std::string& name);
static void Script_RegisterMessageType(ScriptInterface::CxPrivate* pCxPrivate, const std::string& name);
static void Script_RegisterGlobal(ScriptInterface::CxPrivate* pCxPrivate, const std::string& name, JS::HandleValue value);
static IComponent* Script_QueryInterface(ScriptInterface::CxPrivate* pCxPrivate, int ent, int iid);
static std::vector<int> Script_GetEntitiesWithInterface(ScriptInterface::CxPrivate* pCxPrivate, int iid);
static std::vector<IComponent*> Script_GetComponentsWithInterface(ScriptInterface::CxPrivate* pCxPrivate, int iid);
static void Script_PostMessage(ScriptInterface::CxPrivate* pCxPrivate, int ent, int mtid, JS::HandleValue data);
static void Script_BroadcastMessage(ScriptInterface::CxPrivate* pCxPrivate, int mtid, JS::HandleValue data);
static int Script_AddEntity(ScriptInterface::CxPrivate* pCxPrivate, const std::string& templateName);
static int Script_AddLocalEntity(ScriptInterface::CxPrivate* pCxPrivate, const std::string& templateName);
static void Script_DestroyEntity(ScriptInterface::CxPrivate* pCxPrivate, int ent);
static void Script_FlushDestroyedEntities(ScriptInterface::CxPrivate* pCxPrivate);
static void Script_RegisterComponentType_Common(ScriptInterface::CmptPrivate* pCmptPrivate, int iid, const std::string& cname, JS::HandleValue ctor, bool reRegister, bool systemComponent);
static void Script_RegisterComponentType(ScriptInterface::CmptPrivate* pCmptPrivate, int iid, const std::string& cname, JS::HandleValue ctor);
static void Script_RegisterSystemComponentType(ScriptInterface::CmptPrivate* pCmptPrivate, int iid, const std::string& cname, JS::HandleValue ctor);
static void Script_ReRegisterComponentType(ScriptInterface::CmptPrivate* pCmptPrivate, int iid, const std::string& cname, JS::HandleValue ctor);
static void Script_RegisterInterface(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& name);
static void Script_RegisterMessageType(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& name);
static void Script_RegisterGlobal(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& name, JS::HandleValue value);
static IComponent* Script_QueryInterface(ScriptInterface::CmptPrivate* pCmptPrivate, int ent, int iid);
static std::vector<int> Script_GetEntitiesWithInterface(ScriptInterface::CmptPrivate* pCmptPrivate, int iid);
static std::vector<IComponent*> Script_GetComponentsWithInterface(ScriptInterface::CmptPrivate* pCmptPrivate, int iid);
static void Script_PostMessage(ScriptInterface::CmptPrivate* pCmptPrivate, int ent, int mtid, JS::HandleValue data);
static void Script_BroadcastMessage(ScriptInterface::CmptPrivate* pCmptPrivate, int mtid, JS::HandleValue data);
static int Script_AddEntity(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& templateName);
static int Script_AddLocalEntity(ScriptInterface::CmptPrivate* pCmptPrivate, const std::string& templateName);
static void Script_DestroyEntity(ScriptInterface::CmptPrivate* pCmptPrivate, int ent);
static void Script_FlushDestroyedEntities(ScriptInterface::CmptPrivate* pCmptPrivate);
CMessage* ConstructMessage(int mtid, JS::HandleValue data);
void SendGlobalMessage(entity_id_t ent, const CMessage& msg);

View File

@ -31,84 +31,84 @@ namespace JSI_Sound
{
#if CONFIG2_AUDIO
void StartMusic(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void StartMusic(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
if (CSoundManager* sndManager = (CSoundManager*)g_SoundManager)
sndManager->SetMusicEnabled(true);
}
void StopMusic(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void StopMusic(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
if (CSoundManager* sndManager = (CSoundManager*)g_SoundManager)
sndManager->SetMusicEnabled(false);
}
void ClearPlaylist(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
void ClearPlaylist(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
if (CSoundManager* sndManager = (CSoundManager*)g_SoundManager)
sndManager->ClearPlayListItems();
}
void AddPlaylistItem(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& filename)
void AddPlaylistItem(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& filename)
{
if (CSoundManager* sndManager = (CSoundManager*)g_SoundManager)
sndManager->AddPlayListItem(VfsPath(filename));
}
void StartPlaylist(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), bool looping)
void StartPlaylist(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), bool looping)
{
if (CSoundManager* sndManager = (CSoundManager*)g_SoundManager)
sndManager->StartPlayList(looping );
}
void PlayMusic(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& filename, bool looping)
void PlayMusic(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& filename, bool looping)
{
if (CSoundManager* sndManager = (CSoundManager*)g_SoundManager)
sndManager->PlayAsMusic(filename, looping);
}
void PlayUISound(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& filename, bool looping)
void PlayUISound(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& filename, bool looping)
{
if (CSoundManager* sndManager = (CSoundManager*)g_SoundManager)
sndManager->PlayAsUI(filename, looping);
}
void PlayAmbientSound(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& filename, bool looping)
void PlayAmbientSound(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& filename, bool looping)
{
if (CSoundManager* sndManager = (CSoundManager*)g_SoundManager)
sndManager->PlayAsAmbient(filename, looping);
}
bool MusicPlaying(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
bool MusicPlaying(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate))
{
return true;
}
void SetMasterGain(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), float gain)
void SetMasterGain(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), float gain)
{
if (CSoundManager* sndManager = (CSoundManager*)g_SoundManager)
sndManager->SetMasterGain(gain);
}
void SetMusicGain(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), float gain)
void SetMusicGain(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), float gain)
{
if (CSoundManager* sndManager = (CSoundManager*)g_SoundManager)
sndManager->SetMusicGain(gain);
}
void SetAmbientGain(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), float gain)
void SetAmbientGain(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), float gain)
{
if (CSoundManager* sndManager = (CSoundManager*)g_SoundManager)
sndManager->SetAmbientGain(gain);
}
void SetActionGain(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), float gain)
void SetActionGain(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), float gain)
{
if (CSoundManager* sndManager = (CSoundManager*)g_SoundManager)
sndManager->SetActionGain(gain);
}
void SetUIGain(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), float gain)
void SetUIGain(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), float gain)
{
if (CSoundManager* sndManager = (CSoundManager*)g_SoundManager)
sndManager->SetUIGain(gain);
@ -116,20 +116,20 @@ namespace JSI_Sound
#else
bool MusicPlaying(ScriptInterface::CxPrivate* UNUSED(pCxPrivate) ){ return false; }
void PlayAmbientSound(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& UNUSED(filename), bool UNUSED(looping) ){}
void PlayUISound(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& UNUSED(filename), bool UNUSED(looping) ) {}
void PlayMusic(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& UNUSED(filename), bool UNUSED(looping) ) {}
void StartPlaylist(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), bool UNUSED(looping) ){}
void AddPlaylistItem(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& UNUSED(filename) ){}
void ClearPlaylist(ScriptInterface::CxPrivate* UNUSED(pCxPrivate) ){}
void StopMusic(ScriptInterface::CxPrivate* UNUSED(pCxPrivate) ){}
void StartMusic(ScriptInterface::CxPrivate* UNUSED(pCxPrivate) ){}
void SetMasterGain(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), float UNUSED(gain)){}
void SetMusicGain(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), float UNUSED(gain)){}
void SetAmbientGain(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), float UNUSED(gain)){}
void SetActionGain(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), float UNUSED(gain)){}
void SetUIGain(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), float UNUSED(gain)){}
bool MusicPlaying(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate) ){ return false; }
void PlayAmbientSound(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& UNUSED(filename), bool UNUSED(looping) ){}
void PlayUISound(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& UNUSED(filename), bool UNUSED(looping) ) {}
void PlayMusic(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& UNUSED(filename), bool UNUSED(looping) ) {}
void StartPlaylist(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), bool UNUSED(looping) ){}
void AddPlaylistItem(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& UNUSED(filename) ){}
void ClearPlaylist(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate) ){}
void StopMusic(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate) ){}
void StartMusic(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate) ){}
void SetMasterGain(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), float UNUSED(gain)){}
void SetMusicGain(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), float UNUSED(gain)){}
void SetAmbientGain(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), float UNUSED(gain)){}
void SetActionGain(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), float UNUSED(gain)){}
void SetUIGain(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), float UNUSED(gain)){}
#endif

View File

@ -129,7 +129,7 @@ OsPath DataDir()
namespace
{
void script_TS_FAIL(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& msg)
void script_TS_FAIL(ScriptInterface::CmptPrivate* UNUSED(pCmptPrivate), const std::wstring& msg)
{
TS_FAIL(utf8_from_wstring(msg).c_str());
}