2010-01-09 20:20:14 +01:00
|
|
|
/* Copyright (C) 2010 Wildfire Games.
|
|
|
|
* This file is part of 0 A.D.
|
|
|
|
*
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
|
#include "scriptinterface/ScriptInterface.h"
|
|
|
|
|
|
|
|
#include "graphics/Camera.h"
|
|
|
|
#include "graphics/GameView.h"
|
2010-08-04 23:15:41 +02:00
|
|
|
#include "graphics/MapReader.h"
|
2010-01-09 20:20:14 +01:00
|
|
|
#include "gui/GUIManager.h"
|
2010-10-21 21:54:59 +02:00
|
|
|
#include "lib/timer.h"
|
2010-06-30 23:41:04 +02:00
|
|
|
#include "lib/sysdep/sysdep.h"
|
2010-03-20 20:18:01 +01:00
|
|
|
#include "maths/FixedVector3D.h"
|
2010-06-30 23:41:04 +02:00
|
|
|
#include "network/NetClient.h"
|
|
|
|
#include "network/NetServer.h"
|
|
|
|
#include "network/NetTurnManager.h"
|
2010-01-09 20:20:14 +01:00
|
|
|
#include "ps/CLogger.h"
|
2010-10-21 21:54:59 +02:00
|
|
|
#include "ps/CConsole.h"
|
2010-10-30 06:02:42 +02:00
|
|
|
#include "ps/Errors.h"
|
2010-01-09 20:20:14 +01:00
|
|
|
#include "ps/Game.h"
|
2010-11-07 21:42:52 +01:00
|
|
|
#include "ps/Hotkey.h"
|
2010-01-09 20:20:14 +01:00
|
|
|
#include "ps/Overlay.h"
|
2010-10-21 21:54:59 +02:00
|
|
|
#include "ps/Pyrogenesis.h"
|
2010-07-07 23:47:31 +02:00
|
|
|
#include "ps/GameSetup/Atlas.h"
|
2010-02-05 23:00:39 +01:00
|
|
|
#include "ps/GameSetup/Config.h"
|
2010-10-30 06:02:42 +02:00
|
|
|
|
2010-01-09 20:20:14 +01:00
|
|
|
#include "simulation2/Simulation2.h"
|
|
|
|
#include "simulation2/components/ICmpCommandQueue.h"
|
2010-01-26 00:43:58 +01:00
|
|
|
#include "simulation2/components/ICmpGuiInterface.h"
|
2010-09-23 14:13:13 +02:00
|
|
|
#include "simulation2/components/ICmpRangeManager.h"
|
2010-01-26 00:43:58 +01:00
|
|
|
#include "simulation2/components/ICmpTemplateManager.h"
|
2010-01-09 20:20:14 +01:00
|
|
|
#include "simulation2/helpers/Selection.h"
|
|
|
|
|
2010-06-30 23:41:04 +02:00
|
|
|
#include "js/jsapi.h"
|
|
|
|
|
2010-01-09 20:20:14 +01:00
|
|
|
/*
|
|
|
|
* This file defines a set of functions that are available to GUI scripts, to allow
|
|
|
|
* interaction with the rest of the engine.
|
|
|
|
* Functions are exposed to scripts within the global object 'Engine', so
|
|
|
|
* scripts should call "Engine.FunctionName(...)" etc.
|
|
|
|
*/
|
|
|
|
|
2010-07-07 23:47:31 +02:00
|
|
|
extern void restart_mainloop_in_atlas(); // from main.cpp
|
|
|
|
|
2010-01-09 20:20:14 +01:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
CScriptVal GetActiveGui(void* UNUSED(cbdata))
|
|
|
|
{
|
|
|
|
return OBJECT_TO_JSVAL(g_GUI->GetScriptObject());
|
|
|
|
}
|
|
|
|
|
|
|
|
void PushGuiPage(void* UNUSED(cbdata), std::wstring name, CScriptVal initData)
|
|
|
|
{
|
|
|
|
g_GUI->PushPage(name, initData);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwitchGuiPage(void* UNUSED(cbdata), std::wstring name, CScriptVal initData)
|
|
|
|
{
|
|
|
|
g_GUI->SwitchPage(name, initData);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PopGuiPage(void* UNUSED(cbdata))
|
|
|
|
{
|
|
|
|
g_GUI->PopPage();
|
|
|
|
}
|
|
|
|
|
2010-01-26 00:43:58 +01:00
|
|
|
CScriptVal GuiInterfaceCall(void* cbdata, std::wstring name, CScriptVal data)
|
2010-01-09 20:20:14 +01:00
|
|
|
{
|
|
|
|
CGUIManager* guiManager = static_cast<CGUIManager*> (cbdata);
|
|
|
|
|
2010-05-20 20:09:23 +02:00
|
|
|
if (!g_Game)
|
2010-01-09 20:20:14 +01:00
|
|
|
return JSVAL_VOID;
|
|
|
|
CSimulation2* sim = g_Game->GetSimulation2();
|
|
|
|
debug_assert(sim);
|
2010-01-26 00:43:58 +01:00
|
|
|
|
2010-01-09 20:20:14 +01:00
|
|
|
CmpPtr<ICmpGuiInterface> gui(*sim, SYSTEM_ENTITY);
|
|
|
|
if (gui.null())
|
|
|
|
return JSVAL_VOID;
|
|
|
|
|
|
|
|
int player = -1;
|
2010-06-30 23:41:04 +02:00
|
|
|
if (g_Game)
|
|
|
|
player = g_Game->GetPlayerID();
|
2010-01-09 20:20:14 +01:00
|
|
|
|
2010-05-15 13:21:40 +02:00
|
|
|
CScriptValRooted arg (sim->GetScriptInterface().GetContext(), sim->GetScriptInterface().CloneValueFromOtherContext(guiManager->GetScriptInterface(), data.get()));
|
|
|
|
CScriptVal ret (gui->ScriptCall(player, name, arg.get()));
|
2010-05-06 00:36:35 +02:00
|
|
|
return guiManager->GetScriptInterface().CloneValueFromOtherContext(sim->GetScriptInterface(), ret.get());
|
2010-01-24 18:24:35 +01:00
|
|
|
}
|
|
|
|
|
2010-01-09 20:20:14 +01:00
|
|
|
void PostNetworkCommand(void* cbdata, CScriptVal cmd)
|
|
|
|
{
|
|
|
|
CGUIManager* guiManager = static_cast<CGUIManager*> (cbdata);
|
|
|
|
|
2010-05-20 20:09:23 +02:00
|
|
|
if (!g_Game)
|
2010-01-09 20:20:14 +01:00
|
|
|
return;
|
|
|
|
CSimulation2* sim = g_Game->GetSimulation2();
|
|
|
|
debug_assert(sim);
|
2010-01-26 00:43:58 +01:00
|
|
|
|
2010-01-09 20:20:14 +01:00
|
|
|
CmpPtr<ICmpCommandQueue> queue(*sim, SYSTEM_ENTITY);
|
|
|
|
if (queue.null())
|
|
|
|
return;
|
|
|
|
|
2010-05-06 00:36:35 +02:00
|
|
|
jsval cmd2 = sim->GetScriptInterface().CloneValueFromOtherContext(guiManager->GetScriptInterface(), cmd.get());
|
2010-01-09 20:20:14 +01:00
|
|
|
|
2010-05-20 02:59:01 +02:00
|
|
|
queue->PostNetworkCommand(cmd2);
|
2010-01-09 20:20:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<entity_id_t> PickEntitiesAtPoint(void* UNUSED(cbdata), int x, int y)
|
|
|
|
{
|
2010-09-23 14:13:13 +02:00
|
|
|
return EntitySelection::PickEntitiesAtPoint(*g_Game->GetSimulation2(), *g_Game->GetView()->GetCamera(), x, y, g_Game->GetPlayerID());
|
2010-01-09 20:20:14 +01:00
|
|
|
}
|
|
|
|
|
2010-03-11 21:01:16 +01:00
|
|
|
std::vector<entity_id_t> PickFriendlyEntitiesInRect(void* UNUSED(cbdata), 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);
|
|
|
|
}
|
|
|
|
|
2010-11-07 01:12:55 +01:00
|
|
|
std::vector<entity_id_t> PickSimilarFriendlyEntities(void* UNUSED(cbdata), std::string templateName, bool onScreenOnly)
|
|
|
|
{
|
|
|
|
return EntitySelection::PickSimilarEntities(*g_Game->GetSimulation2(), *g_Game->GetView()->GetCamera(), templateName, g_Game->GetPlayerID(), onScreenOnly);
|
|
|
|
}
|
|
|
|
|
2010-01-09 20:20:14 +01:00
|
|
|
CFixedVector3D GetTerrainAtPoint(void* UNUSED(cbdata), int x, int y)
|
|
|
|
{
|
2010-05-28 01:23:53 +02:00
|
|
|
CVector3D pos = g_Game->GetView()->GetCamera()->GetWorldCoordinates(x, y, true);
|
2010-05-02 22:32:37 +02:00
|
|
|
return CFixedVector3D(fixed::FromFloat(pos.X), fixed::FromFloat(pos.Y), fixed::FromFloat(pos.Z));
|
2010-01-09 20:20:14 +01:00
|
|
|
}
|
|
|
|
|
2010-02-05 23:00:39 +01:00
|
|
|
std::wstring SetCursor(void* UNUSED(cbdata), std::wstring name)
|
|
|
|
{
|
|
|
|
std::wstring old = g_CursorName;
|
|
|
|
g_CursorName = name;
|
|
|
|
return old;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetPlayerID(void* UNUSED(cbdata))
|
|
|
|
{
|
2010-06-30 23:41:04 +02:00
|
|
|
if (g_Game)
|
|
|
|
return g_Game->GetPlayerID();
|
2010-02-05 23:00:39 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-06-30 23:41:04 +02:00
|
|
|
std::wstring GetDefaultPlayerName(void* UNUSED(cbdata))
|
|
|
|
{
|
|
|
|
// TODO: this should come from a config file or something
|
|
|
|
std::wstring name = sys_get_user_name();
|
|
|
|
if (name.empty())
|
|
|
|
name = L"anonymous";
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
void StartNetworkGame(void* UNUSED(cbdata))
|
|
|
|
{
|
|
|
|
debug_assert(g_NetServer);
|
|
|
|
g_NetServer->StartGame();
|
|
|
|
}
|
|
|
|
|
|
|
|
void StartGame(void* cbdata, CScriptVal attribs, int playerID)
|
|
|
|
{
|
|
|
|
CGUIManager* guiManager = static_cast<CGUIManager*> (cbdata);
|
|
|
|
|
|
|
|
debug_assert(!g_NetServer);
|
|
|
|
debug_assert(!g_NetClient);
|
|
|
|
|
|
|
|
debug_assert(!g_Game);
|
|
|
|
g_Game = new CGame();
|
|
|
|
|
|
|
|
// Convert from GUI script context to sim script context
|
|
|
|
CSimulation2* sim = g_Game->GetSimulation2();
|
|
|
|
CScriptValRooted gameAttribs (sim->GetScriptInterface().GetContext(),
|
|
|
|
sim->GetScriptInterface().CloneValueFromOtherContext(guiManager->GetScriptInterface(), attribs.get()));
|
|
|
|
|
|
|
|
g_Game->SetPlayerID(playerID);
|
|
|
|
g_Game->StartGame(gameAttribs);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetNetworkGameAttributes(void* cbdata, CScriptVal attribs)
|
|
|
|
{
|
|
|
|
CGUIManager* guiManager = static_cast<CGUIManager*> (cbdata);
|
|
|
|
|
|
|
|
debug_assert(g_NetServer);
|
|
|
|
|
2010-10-31 23:00:28 +01:00
|
|
|
g_NetServer->UpdateGameAttributes(attribs, guiManager->GetScriptInterface());
|
2010-06-30 23:41:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-06 22:51:45 +02:00
|
|
|
void StartNetworkHost(void* cbdata, std::wstring playerName)
|
2010-06-30 23:41:04 +02:00
|
|
|
{
|
2010-07-06 22:51:45 +02:00
|
|
|
CGUIManager* guiManager = static_cast<CGUIManager*> (cbdata);
|
|
|
|
|
2010-06-30 23:41:04 +02:00
|
|
|
debug_assert(!g_NetClient);
|
|
|
|
debug_assert(!g_NetServer);
|
|
|
|
debug_assert(!g_Game);
|
|
|
|
|
|
|
|
g_NetServer = new CNetServer();
|
2010-07-06 22:51:45 +02:00
|
|
|
if (!g_NetServer->SetupConnection())
|
|
|
|
{
|
|
|
|
guiManager->GetScriptInterface().ReportError("Failed to start server");
|
|
|
|
SAFE_DELETE(g_NetServer);
|
|
|
|
return;
|
|
|
|
}
|
2010-06-30 23:41:04 +02:00
|
|
|
|
|
|
|
g_Game = new CGame();
|
|
|
|
g_NetClient = new CNetClient(g_Game);
|
|
|
|
g_NetClient->SetUserName(playerName);
|
2010-07-06 22:51:45 +02:00
|
|
|
|
|
|
|
if (!g_NetClient->SetupConnection("127.0.0.1"))
|
|
|
|
{
|
|
|
|
guiManager->GetScriptInterface().ReportError("Failed to connect to server");
|
|
|
|
SAFE_DELETE(g_NetClient);
|
|
|
|
SAFE_DELETE(g_Game);
|
|
|
|
}
|
2010-06-30 23:41:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-06 22:51:45 +02:00
|
|
|
void StartNetworkJoin(void* cbdata, std::wstring playerName, std::string serverAddress)
|
2010-06-30 23:41:04 +02:00
|
|
|
{
|
2010-07-06 22:51:45 +02:00
|
|
|
CGUIManager* guiManager = static_cast<CGUIManager*> (cbdata);
|
|
|
|
|
2010-06-30 23:41:04 +02:00
|
|
|
debug_assert(!g_NetClient);
|
|
|
|
debug_assert(!g_NetServer);
|
|
|
|
debug_assert(!g_Game);
|
|
|
|
|
|
|
|
g_Game = new CGame();
|
|
|
|
g_NetClient = new CNetClient(g_Game);
|
|
|
|
g_NetClient->SetUserName(playerName);
|
2010-07-06 22:51:45 +02:00
|
|
|
if (!g_NetClient->SetupConnection(serverAddress))
|
|
|
|
{
|
|
|
|
guiManager->GetScriptInterface().ReportError("Failed to connect to server");
|
|
|
|
SAFE_DELETE(g_NetClient);
|
|
|
|
SAFE_DELETE(g_Game);
|
|
|
|
}
|
2010-06-30 23:41:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-02 23:28:48 +02:00
|
|
|
void DisconnectNetworkGame(void* UNUSED(cbdata))
|
|
|
|
{
|
|
|
|
// TODO: we ought to do async reliable disconnections
|
|
|
|
|
|
|
|
SAFE_DELETE(g_NetServer);
|
|
|
|
SAFE_DELETE(g_NetClient);
|
|
|
|
SAFE_DELETE(g_Game);
|
|
|
|
}
|
2010-06-30 23:41:04 +02:00
|
|
|
|
|
|
|
CScriptVal PollNetworkClient(void* cbdata)
|
|
|
|
{
|
|
|
|
CGUIManager* guiManager = static_cast<CGUIManager*> (cbdata);
|
|
|
|
|
2010-07-02 23:28:48 +02:00
|
|
|
if (!g_NetClient)
|
|
|
|
return CScriptVal();
|
2010-06-30 23:41:04 +02:00
|
|
|
|
|
|
|
CScriptValRooted poll = g_NetClient->GuiPoll();
|
|
|
|
|
|
|
|
// Convert from net client context to GUI script context
|
|
|
|
return guiManager->GetScriptInterface().CloneValueFromOtherContext(g_NetClient->GetScriptInterface(), poll.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
void AssignNetworkPlayer(void* UNUSED(cbdata), int playerID, std::string guid)
|
|
|
|
{
|
|
|
|
debug_assert(g_NetServer);
|
|
|
|
|
|
|
|
g_NetServer->AssignPlayer(playerID, guid);
|
|
|
|
}
|
|
|
|
|
2010-07-02 23:28:48 +02:00
|
|
|
void SendNetworkChat(void* UNUSED(cbdata), std::wstring message)
|
|
|
|
{
|
|
|
|
debug_assert(g_NetClient);
|
|
|
|
|
|
|
|
g_NetClient->SendChatMessage(message);
|
|
|
|
}
|
|
|
|
|
2010-07-07 23:47:31 +02:00
|
|
|
void OpenURL(void* UNUSED(cbdata), std::string url)
|
|
|
|
{
|
|
|
|
sys_open_url(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RestartInAtlas(void* UNUSED(cbdata))
|
|
|
|
{
|
|
|
|
restart_mainloop_in_atlas();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AtlasIsAvailable(void* UNUSED(cbdata))
|
|
|
|
{
|
|
|
|
return ATLAS_IsAvailable();
|
|
|
|
}
|
2010-07-02 23:28:48 +02:00
|
|
|
|
2010-10-30 06:02:42 +02:00
|
|
|
CScriptVal LoadMapSettings(void* cbdata, std::wstring pathname)
|
2010-08-04 23:15:41 +02:00
|
|
|
{
|
|
|
|
CGUIManager* guiManager = static_cast<CGUIManager*> (cbdata);
|
|
|
|
|
|
|
|
CMapSummaryReader reader;
|
2010-10-30 06:02:42 +02:00
|
|
|
|
|
|
|
if (reader.LoadMap(VfsPath(pathname + L".xml")) != PSRETURN_OK)
|
2010-08-04 23:15:41 +02:00
|
|
|
return CScriptVal();
|
|
|
|
|
2010-10-30 06:02:42 +02:00
|
|
|
return reader.GetMapSettings(guiManager->GetScriptInterface()).get();
|
2010-08-04 23:15:41 +02:00
|
|
|
}
|
|
|
|
|
2010-09-27 01:05:25 +02:00
|
|
|
/**
|
|
|
|
* Start / stop camera following mode
|
|
|
|
* @param entityid unit id to follow. If zero, stop following mode
|
|
|
|
*/
|
|
|
|
void CameraFollow(void* UNUSED(cbdata), entity_id_t entityid)
|
|
|
|
{
|
|
|
|
if (g_Game && g_Game->GetView())
|
2010-11-01 22:40:29 +01:00
|
|
|
g_Game->GetView()->CameraFollow(entityid, false);
|
2010-09-27 01:05:25 +02:00
|
|
|
}
|
|
|
|
|
2010-11-01 22:40:29 +01:00
|
|
|
void CameraFollowFPS(void* UNUSED(cbdata), entity_id_t entityid)
|
|
|
|
{
|
|
|
|
if (g_Game && g_Game->GetView())
|
|
|
|
g_Game->GetView()->CameraFollow(entityid, true);
|
|
|
|
}
|
2010-10-21 21:54:59 +02:00
|
|
|
|
2010-11-07 21:42:52 +01:00
|
|
|
bool HotkeyIsPressed_(void* UNUSED(cbdata), std::string hotkeyName)
|
|
|
|
{
|
|
|
|
return HotkeyIsPressed(hotkeyName);
|
|
|
|
}
|
|
|
|
|
2010-11-20 20:46:49 +01:00
|
|
|
void DisplayErrorDialog(void* UNUSED(cbdata), std::wstring msg)
|
|
|
|
{
|
|
|
|
debug_DisplayError(msg.c_str(), DE_NO_DEBUG_INFO, NULL, NULL, NULL, 0, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-21 21:54:59 +02:00
|
|
|
void SetSimRate(void* UNUSED(cbdata), float rate)
|
|
|
|
{
|
|
|
|
g_Game->SetSimRate(rate);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetTurnLength(void* UNUSED(cbdata), int length)
|
|
|
|
{
|
|
|
|
if (g_NetServer)
|
|
|
|
g_NetServer->SetTurnLength(length);
|
|
|
|
else
|
|
|
|
LOGERROR(L"Only network host can change turn length");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Focus the game camera on a given position.
|
|
|
|
void SetCameraTarget(void* UNUSED(cbdata), float x, float y, float z)
|
|
|
|
{
|
|
|
|
g_Game->GetView()->ResetCameraTarget(CVector3D(x, y, z));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Deliberately cause the game to crash.
|
|
|
|
// Currently implemented via access violation (read of address 0).
|
|
|
|
// Useful for testing the crashlog/stack trace code.
|
|
|
|
int Crash(void* UNUSED(cbdata))
|
|
|
|
{
|
2010-11-06 20:11:40 +01:00
|
|
|
debug_printf(L"Crashing at user's request.\n");
|
2010-10-21 21:54:59 +02:00
|
|
|
return *(int*)0;
|
|
|
|
}
|
|
|
|
|
2010-11-20 18:14:45 +01:00
|
|
|
void DebugWarn(void* UNUSED(cbdata))
|
|
|
|
{
|
|
|
|
debug_warn(L"Warning at user's request.");
|
|
|
|
}
|
|
|
|
|
2010-10-21 21:54:59 +02:00
|
|
|
// Force a JS garbage collection cycle to take place immediately.
|
|
|
|
// Writes an indication of how long this took to the console.
|
|
|
|
void ForceGC(void* cbdata)
|
|
|
|
{
|
|
|
|
CGUIManager* guiManager = static_cast<CGUIManager*> (cbdata);
|
|
|
|
|
|
|
|
double time = timer_Time();
|
|
|
|
JS_GC(guiManager->GetScriptInterface().GetContext());
|
|
|
|
time = timer_Time() - time;
|
|
|
|
g_Console->InsertMessage(L"Garbage collection completed in: %f", time);
|
|
|
|
}
|
|
|
|
|
2010-01-09 20:20:14 +01:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
void GuiScriptingInit(ScriptInterface& scriptInterface)
|
|
|
|
{
|
|
|
|
// GUI manager functions:
|
|
|
|
scriptInterface.RegisterFunction<CScriptVal, &GetActiveGui>("GetActiveGui");
|
|
|
|
scriptInterface.RegisterFunction<void, std::wstring, CScriptVal, &PushGuiPage>("PushGuiPage");
|
|
|
|
scriptInterface.RegisterFunction<void, std::wstring, CScriptVal, &SwitchGuiPage>("SwitchGuiPage");
|
|
|
|
scriptInterface.RegisterFunction<void, &PopGuiPage>("PopGuiPage");
|
|
|
|
|
|
|
|
// Simulation<->GUI interface functions:
|
2010-01-26 00:43:58 +01:00
|
|
|
scriptInterface.RegisterFunction<CScriptVal, std::wstring, CScriptVal, &GuiInterfaceCall>("GuiInterfaceCall");
|
2010-01-09 20:20:14 +01:00
|
|
|
scriptInterface.RegisterFunction<void, CScriptVal, &PostNetworkCommand>("PostNetworkCommand");
|
|
|
|
|
|
|
|
// Entity picking
|
|
|
|
scriptInterface.RegisterFunction<std::vector<entity_id_t>, int, int, &PickEntitiesAtPoint>("PickEntitiesAtPoint");
|
2010-03-11 21:01:16 +01:00
|
|
|
scriptInterface.RegisterFunction<std::vector<entity_id_t>, int, int, int, int, int, &PickFriendlyEntitiesInRect>("PickFriendlyEntitiesInRect");
|
2010-11-07 01:12:55 +01:00
|
|
|
scriptInterface.RegisterFunction<std::vector<entity_id_t>, std::string, bool, &PickSimilarFriendlyEntities>("PickSimilarFriendlyEntities");
|
2010-01-09 20:20:14 +01:00
|
|
|
scriptInterface.RegisterFunction<CFixedVector3D, int, int, &GetTerrainAtPoint>("GetTerrainAtPoint");
|
|
|
|
|
2010-06-30 23:41:04 +02:00
|
|
|
// Network / game setup functions
|
|
|
|
scriptInterface.RegisterFunction<void, &StartNetworkGame>("StartNetworkGame");
|
|
|
|
scriptInterface.RegisterFunction<void, CScriptVal, int, &StartGame>("StartGame");
|
|
|
|
scriptInterface.RegisterFunction<void, std::wstring, &StartNetworkHost>("StartNetworkHost");
|
|
|
|
scriptInterface.RegisterFunction<void, std::wstring, std::string, &StartNetworkJoin>("StartNetworkJoin");
|
2010-07-02 23:28:48 +02:00
|
|
|
scriptInterface.RegisterFunction<void, &DisconnectNetworkGame>("DisconnectNetworkGame");
|
2010-06-30 23:41:04 +02:00
|
|
|
scriptInterface.RegisterFunction<CScriptVal, &PollNetworkClient>("PollNetworkClient");
|
|
|
|
scriptInterface.RegisterFunction<void, CScriptVal, &SetNetworkGameAttributes>("SetNetworkGameAttributes");
|
|
|
|
scriptInterface.RegisterFunction<void, int, std::string, &AssignNetworkPlayer>("AssignNetworkPlayer");
|
2010-07-02 23:28:48 +02:00
|
|
|
scriptInterface.RegisterFunction<void, std::wstring, &SendNetworkChat>("SendNetworkChat");
|
2010-06-30 23:41:04 +02:00
|
|
|
|
2010-02-05 23:00:39 +01:00
|
|
|
// Misc functions
|
|
|
|
scriptInterface.RegisterFunction<std::wstring, std::wstring, &SetCursor>("SetCursor");
|
|
|
|
scriptInterface.RegisterFunction<int, &GetPlayerID>("GetPlayerID");
|
2010-06-30 23:41:04 +02:00
|
|
|
scriptInterface.RegisterFunction<std::wstring, &GetDefaultPlayerName>("GetDefaultPlayerName");
|
2010-07-07 23:47:31 +02:00
|
|
|
scriptInterface.RegisterFunction<void, std::string, &OpenURL>("OpenURL");
|
|
|
|
scriptInterface.RegisterFunction<void, &RestartInAtlas>("RestartInAtlas");
|
|
|
|
scriptInterface.RegisterFunction<bool, &AtlasIsAvailable>("AtlasIsAvailable");
|
2010-10-30 06:02:42 +02:00
|
|
|
scriptInterface.RegisterFunction<CScriptVal, std::wstring, &LoadMapSettings>("LoadMapSettings");
|
2010-09-27 01:05:25 +02:00
|
|
|
scriptInterface.RegisterFunction<void, entity_id_t, &CameraFollow>("CameraFollow");
|
2010-11-01 22:40:29 +01:00
|
|
|
scriptInterface.RegisterFunction<void, entity_id_t, &CameraFollowFPS>("CameraFollowFPS");
|
2010-11-07 21:42:52 +01:00
|
|
|
scriptInterface.RegisterFunction<bool, std::string, &HotkeyIsPressed_>("HotkeyIsPressed");
|
2010-11-20 20:46:49 +01:00
|
|
|
scriptInterface.RegisterFunction<void, std::wstring, &DisplayErrorDialog>("DisplayErrorDialog");
|
2010-10-21 21:54:59 +02:00
|
|
|
|
|
|
|
// Development/debugging functions
|
|
|
|
scriptInterface.RegisterFunction<void, float, &SetSimRate>("SetSimRate");
|
|
|
|
scriptInterface.RegisterFunction<void, int, &SetTurnLength>("SetTurnLength");
|
|
|
|
scriptInterface.RegisterFunction<void, float, float, float, &SetCameraTarget>("SetCameraTarget");
|
|
|
|
scriptInterface.RegisterFunction<int, &Crash>("Crash");
|
2010-11-20 18:14:45 +01:00
|
|
|
scriptInterface.RegisterFunction<void, &DebugWarn>("DebugWarn");
|
2010-10-21 21:54:59 +02:00
|
|
|
scriptInterface.RegisterFunction<void, &ForceGC>("ForceGC");
|
2010-01-09 20:20:14 +01:00
|
|
|
}
|