2017-01-23 18:04:50 -08:00
|
|
|
/* Copyright (C) 2017 Wildfire Games.
|
2010-01-09 11:20:14 -08:00
|
|
|
* This file is part of 0 A.D.
|
|
|
|
|
*
|
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
|
|
|
#include "scriptinterface/ScriptInterface.h"
|
|
|
|
|
|
2016-02-04 09:14:46 -08:00
|
|
|
#include "graphics/FontMetrics.h"
|
2010-01-09 11:20:14 -08:00
|
|
|
#include "graphics/GameView.h"
|
2010-08-04 14:15:41 -07:00
|
|
|
#include "graphics/MapReader.h"
|
2014-11-12 17:26:22 -08:00
|
|
|
#include "graphics/scripting/JSInterface_GameView.h"
|
2014-01-04 02:14:53 -08:00
|
|
|
#include "gui/IGUIObject.h"
|
2017-09-11 17:54:49 -07:00
|
|
|
#include "gui/scripting/JSInterface_GUIManager.h"
|
2014-01-04 02:14:53 -08:00
|
|
|
#include "gui/scripting/JSInterface_GUITypes.h"
|
2014-04-20 13:03:57 -07:00
|
|
|
#include "i18n/L10n.h"
|
|
|
|
|
#include "i18n/scripting/JSInterface_L10n.h"
|
2014-01-04 02:14:53 -08:00
|
|
|
#include "lib/svn_revision.h"
|
2010-06-30 14:41:04 -07:00
|
|
|
#include "lib/sysdep/sysdep.h"
|
2014-04-20 13:03:57 -07:00
|
|
|
#include "lib/utf8.h"
|
2013-11-16 10:38:40 -08:00
|
|
|
#include "lobby/scripting/JSInterface_Lobby.h"
|
2010-06-30 14:41:04 -07:00
|
|
|
#include "network/NetClient.h"
|
|
|
|
|
#include "network/NetServer.h"
|
2017-09-11 17:29:10 -07:00
|
|
|
#include "network/scripting/JSInterface_Network.h"
|
2010-10-21 12:54:59 -07:00
|
|
|
#include "ps/CConsole.h"
|
2014-11-12 17:26:22 -08:00
|
|
|
#include "ps/CLogger.h"
|
2010-10-29 21:02:42 -07:00
|
|
|
#include "ps/Errors.h"
|
2014-11-12 17:26:22 -08:00
|
|
|
#include "ps/GUID.h"
|
2010-01-09 11:20:14 -08:00
|
|
|
#include "ps/Game.h"
|
2014-11-12 17:26:22 -08:00
|
|
|
#include "ps/GameSetup/Atlas.h"
|
2014-01-04 02:14:53 -08:00
|
|
|
#include "ps/Globals.h" // g_frequencyFilter
|
2010-11-07 12:42:52 -08:00
|
|
|
#include "ps/Hotkey.h"
|
2011-02-18 19:14:37 -08:00
|
|
|
#include "ps/ProfileViewer.h"
|
2016-06-21 03:33:11 -07:00
|
|
|
#include "ps/Profile.h"
|
2014-11-12 17:26:22 -08:00
|
|
|
#include "ps/UserReport.h"
|
2013-09-29 11:56:50 -07:00
|
|
|
#include "ps/scripting/JSInterface_ConfigDB.h"
|
2013-09-21 07:48:19 -07:00
|
|
|
#include "ps/scripting/JSInterface_Console.h"
|
2017-09-11 18:38:46 -07:00
|
|
|
#include "ps/scripting/JSInterface_Game.h"
|
2014-08-25 09:02:54 -07:00
|
|
|
#include "ps/scripting/JSInterface_Mod.h"
|
2017-09-11 16:22:28 -07:00
|
|
|
#include "ps/scripting/JSInterface_SavedGame.h"
|
2014-01-04 02:14:53 -08:00
|
|
|
#include "ps/scripting/JSInterface_VFS.h"
|
2015-09-21 10:00:21 -07:00
|
|
|
#include "ps/scripting/JSInterface_VisualReplay.h"
|
2013-09-21 01:24:45 -07:00
|
|
|
#include "renderer/scripting/JSInterface_Renderer.h"
|
2017-09-11 18:53:46 -07:00
|
|
|
#include "simulation2/scripting/JSInterface_Simulation.h"
|
2014-01-04 02:14:53 -08:00
|
|
|
#include "soundmanager/scripting/JSInterface_Sound.h"
|
2014-11-12 17:26:22 -08:00
|
|
|
#include "tools/atlas/GameInterface/GameLoop.h"
|
2010-01-09 11:20:14 -08: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 14:47:31 -07:00
|
|
|
extern void restart_mainloop_in_atlas(); // from main.cpp
|
2014-01-04 02:14:53 -08:00
|
|
|
extern void EndGame();
|
|
|
|
|
extern void kill_mainloop();
|
2010-07-07 14:47:31 -07:00
|
|
|
|
2010-01-09 11:20:14 -08:00
|
|
|
namespace {
|
|
|
|
|
|
2016-01-23 07:17:56 -08:00
|
|
|
void OpenURL(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& url)
|
2010-07-07 14:47:31 -07:00
|
|
|
{
|
|
|
|
|
sys_open_url(url);
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-04 02:14:53 -08:00
|
|
|
std::wstring GetMatchID(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
2013-11-07 12:07:24 -08:00
|
|
|
{
|
|
|
|
|
return ps_generate_guid().FromUTF8();
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-04 02:14:53 -08:00
|
|
|
void RestartInAtlas(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
2010-07-07 14:47:31 -07:00
|
|
|
{
|
|
|
|
|
restart_mainloop_in_atlas();
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-04 02:14:53 -08:00
|
|
|
bool AtlasIsAvailable(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
2010-07-07 14:47:31 -07:00
|
|
|
{
|
|
|
|
|
return ATLAS_IsAvailable();
|
|
|
|
|
}
|
2010-07-02 14:28:48 -07:00
|
|
|
|
2014-01-04 02:14:53 -08:00
|
|
|
bool IsAtlasRunning(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
2012-04-19 18:41:54 -07:00
|
|
|
{
|
2017-09-11 18:38:46 -07:00
|
|
|
return g_AtlasGameLoop && g_AtlasGameLoop->running;
|
2012-04-19 18:41:54 -07:00
|
|
|
}
|
|
|
|
|
|
2016-01-23 07:17:56 -08:00
|
|
|
JS::Value LoadMapSettings(ScriptInterface::CxPrivate* pCxPrivate, const VfsPath& pathname)
|
2010-08-04 14:15:41 -07:00
|
|
|
{
|
2015-01-24 06:46:52 -08:00
|
|
|
JSContext* cx = pCxPrivate->pScriptInterface->GetContext();
|
|
|
|
|
JSAutoRequest rq(cx);
|
|
|
|
|
|
2010-08-04 14:15:41 -07:00
|
|
|
CMapSummaryReader reader;
|
2010-10-29 21:02:42 -07:00
|
|
|
|
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
|
|
|
if (reader.LoadMap(pathname) != PSRETURN_OK)
|
2015-01-24 06:46:52 -08:00
|
|
|
return JS::UndefinedValue();
|
2010-08-04 14:15:41 -07:00
|
|
|
|
2015-01-24 06:46:52 -08:00
|
|
|
JS::RootedValue settings(cx);
|
|
|
|
|
reader.GetMapSettings(*(pCxPrivate->pScriptInterface), &settings);
|
|
|
|
|
return settings;
|
2010-08-04 14:15:41 -07:00
|
|
|
}
|
|
|
|
|
|
2016-01-23 07:17:56 -08:00
|
|
|
bool HotkeyIsPressed_(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& hotkeyName)
|
2010-11-07 12:42:52 -08:00
|
|
|
{
|
|
|
|
|
return HotkeyIsPressed(hotkeyName);
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-23 07:17:56 -08:00
|
|
|
void DisplayErrorDialog(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& msg)
|
2010-11-20 11:46:49 -08:00
|
|
|
{
|
|
|
|
|
debug_DisplayError(msg.c_str(), DE_NO_DEBUG_INFO, NULL, NULL, NULL, 0, NULL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-24 06:46:52 -08:00
|
|
|
JS::Value GetProfilerState(ScriptInterface::CxPrivate* pCxPrivate)
|
2011-02-18 19:14:37 -08:00
|
|
|
{
|
2014-01-04 02:14:53 -08:00
|
|
|
return g_ProfileViewer.SaveToJS(*(pCxPrivate->pScriptInterface));
|
2011-02-18 19:14:37 -08:00
|
|
|
}
|
2010-11-20 11:46:49 -08:00
|
|
|
|
2014-01-04 02:14:53 -08:00
|
|
|
bool IsUserReportEnabled(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
2011-02-16 12:40:15 -08:00
|
|
|
{
|
|
|
|
|
return g_UserReporter.IsReportingEnabled();
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-04 02:14:53 -08:00
|
|
|
void SetUserReportEnabled(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), bool enabled)
|
2011-02-16 12:40:15 -08:00
|
|
|
{
|
|
|
|
|
g_UserReporter.SetReportingEnabled(enabled);
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-04 02:14:53 -08:00
|
|
|
std::string GetUserReportStatus(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
2011-02-16 12:40:15 -08:00
|
|
|
{
|
|
|
|
|
return g_UserReporter.GetStatus();
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-23 07:17:56 -08:00
|
|
|
void SubmitUserReport(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& type, int version, const std::wstring& data)
|
2011-02-16 12:40:15 -08:00
|
|
|
{
|
|
|
|
|
g_UserReporter.SubmitReport(type.c_str(), version, utf8_from_wstring(data));
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-21 12:54:59 -07:00
|
|
|
// Deliberately cause the game to crash.
|
|
|
|
|
// Currently implemented via access violation (read of address 0).
|
|
|
|
|
// Useful for testing the crashlog/stack trace code.
|
2014-01-04 02:14:53 -08:00
|
|
|
int Crash(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
2010-10-21 12:54:59 -07:00
|
|
|
{
|
2015-02-13 17:45:13 -08:00
|
|
|
debug_printf("Crashing at user's request.\n");
|
2012-03-07 12:40:38 -08:00
|
|
|
return *(volatile int*)0;
|
2010-10-21 12:54:59 -07:00
|
|
|
}
|
|
|
|
|
|
2014-01-04 02:14:53 -08:00
|
|
|
void DebugWarn(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
2010-11-20 09:14:45 -08:00
|
|
|
{
|
|
|
|
|
debug_warn(L"Warning at user's request.");
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-21 12:54:59 -07:00
|
|
|
// Force a JS garbage collection cycle to take place immediately.
|
|
|
|
|
// Writes an indication of how long this took to the console.
|
2014-01-04 02:14:53 -08:00
|
|
|
void ForceGC(ScriptInterface::CxPrivate* pCxPrivate)
|
2010-10-21 12:54:59 -07:00
|
|
|
{
|
|
|
|
|
double time = timer_Time();
|
2014-03-28 13:26:32 -07:00
|
|
|
JS_GC(pCxPrivate->pScriptInterface->GetJSRuntime());
|
2010-10-21 12:54:59 -07:00
|
|
|
time = timer_Time() - time;
|
2015-02-13 17:49:34 -08:00
|
|
|
g_Console->InsertMessage(fmt::sprintf("Garbage collection completed in: %f", time));
|
2010-10-21 12:54:59 -07:00
|
|
|
}
|
|
|
|
|
|
2014-01-04 02:14:53 -08:00
|
|
|
void Script_EndGame(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
|
|
|
|
{
|
|
|
|
|
EndGame();
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-15 10:13:35 -07:00
|
|
|
CStrW GetSystemUsername(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
|
|
|
|
{
|
|
|
|
|
return sys_get_user_name();
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-04 02:14:53 -08:00
|
|
|
// Cause the game to exit gracefully.
|
|
|
|
|
// params:
|
|
|
|
|
// returns:
|
|
|
|
|
// notes:
|
|
|
|
|
// - Exit happens after the current main loop iteration ends
|
|
|
|
|
// (since this only sets a flag telling it to end)
|
|
|
|
|
void ExitProgram(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
|
|
|
|
{
|
|
|
|
|
kill_mainloop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// - This value is recalculated once a frame. We take special care to
|
|
|
|
|
// filter it, so it is both accurate and free of jitter.
|
|
|
|
|
int GetFps(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
|
|
|
|
{
|
|
|
|
|
int freq = 0;
|
|
|
|
|
if (g_frequencyFilter)
|
|
|
|
|
freq = g_frequencyFilter->StableFrequency();
|
|
|
|
|
return freq;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Return the date/time at which the current executable was compiled.
|
|
|
|
|
// params: mode OR an integer specifying
|
|
|
|
|
// what to display: -1 for "date time (svn revision)", 0 for date, 1 for time, 2 for svn revision
|
|
|
|
|
// returns: string with the requested timestamp info
|
|
|
|
|
// notes:
|
|
|
|
|
// - 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.
|
|
|
|
|
// - To be exact, the date/time returned is when scriptglue.cpp was
|
|
|
|
|
// last compiled, but the auto-build does full rebuilds.
|
|
|
|
|
// - svn revision is generated by calling svnversion and cached in
|
|
|
|
|
// 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).
|
2014-04-20 13:03:57 -07:00
|
|
|
std::wstring GetBuildTimestamp(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), int mode)
|
2014-01-04 02:14:53 -08:00
|
|
|
{
|
|
|
|
|
char buf[200];
|
2014-04-20 13:03:57 -07:00
|
|
|
if (mode == -1) // Date, time and revision.
|
|
|
|
|
{
|
2014-10-15 09:04:37 -07:00
|
|
|
UDate dateTime = g_L10n.ParseDateTime(__DATE__ " " __TIME__, "MMM d yyyy HH:mm:ss", Locale::getUS());
|
|
|
|
|
std::string dateTimeString = g_L10n.LocalizeDateTime(dateTime, L10n::DateTime, SimpleDateFormat::DATE_TIME);
|
2014-04-20 13:03:57 -07:00
|
|
|
char svnRevision[32];
|
|
|
|
|
sprintf_s(svnRevision, ARRAY_SIZE(svnRevision), "%ls", svn_revision);
|
|
|
|
|
if (strcmp(svnRevision, "custom build") == 0)
|
|
|
|
|
{
|
|
|
|
|
// Translation: First item is a date and time, item between parenthesis is the Subversion revision number of the current build.
|
2014-10-15 09:04:37 -07:00
|
|
|
sprintf_s(buf, ARRAY_SIZE(buf), g_L10n.Translate("%s (custom build)").c_str(), dateTimeString.c_str());
|
2014-04-20 13:03:57 -07:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Translation: First item is a date and time, item between parenthesis is the Subversion revision number of the current build.
|
2017-05-27 05:26:26 -07:00
|
|
|
// dennis-ignore: *
|
2014-10-15 09:04:37 -07:00
|
|
|
sprintf_s(buf, ARRAY_SIZE(buf), g_L10n.Translate("%s (%ls)").c_str(), dateTimeString.c_str(), svn_revision);
|
2014-04-20 13:03:57 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (mode == 0) // Date.
|
|
|
|
|
{
|
2014-10-15 09:04:37 -07:00
|
|
|
UDate dateTime = g_L10n.ParseDateTime(__DATE__, "MMM d yyyy", Locale::getUS());
|
|
|
|
|
std::string dateTimeString = g_L10n.LocalizeDateTime(dateTime, L10n::Date, SimpleDateFormat::MEDIUM);
|
2014-04-20 13:03:57 -07:00
|
|
|
sprintf_s(buf, ARRAY_SIZE(buf), "%s", dateTimeString.c_str());
|
|
|
|
|
}
|
|
|
|
|
else if (mode == 1) // Time.
|
2014-01-04 02:14:53 -08:00
|
|
|
{
|
2014-10-15 09:04:37 -07:00
|
|
|
UDate dateTime = g_L10n.ParseDateTime(__TIME__, "HH:mm:ss", Locale::getUS());
|
|
|
|
|
std::string dateTimeString = g_L10n.LocalizeDateTime(dateTime, L10n::Time, SimpleDateFormat::MEDIUM);
|
2014-04-20 13:03:57 -07:00
|
|
|
sprintf_s(buf, ARRAY_SIZE(buf), "%s", dateTimeString.c_str());
|
|
|
|
|
}
|
|
|
|
|
else if (mode == 2) // Revision.
|
|
|
|
|
{
|
|
|
|
|
char svnRevision[32];
|
|
|
|
|
sprintf_s(svnRevision, ARRAY_SIZE(svnRevision), "%ls", svn_revision);
|
|
|
|
|
if (strcmp(svnRevision, "custom build") == 0)
|
|
|
|
|
{
|
2014-10-15 09:04:37 -07:00
|
|
|
sprintf_s(buf, ARRAY_SIZE(buf), "%s", g_L10n.Translate("custom build").c_str());
|
2014-04-20 13:03:57 -07:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sprintf_s(buf, ARRAY_SIZE(buf), "%ls", svn_revision);
|
|
|
|
|
}
|
2014-01-04 02:14:53 -08:00
|
|
|
}
|
|
|
|
|
|
2014-04-20 13:03:57 -07:00
|
|
|
return wstring_from_utf8(buf);
|
2014-01-04 02:14:53 -08:00
|
|
|
}
|
|
|
|
|
|
2016-02-04 09:14:46 -08:00
|
|
|
int GetTextWidth(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const CStr& fontName, const CStrW& text)
|
|
|
|
|
{
|
|
|
|
|
int width = 0;
|
|
|
|
|
int height = 0;
|
|
|
|
|
CStrIntern _fontName(fontName);
|
|
|
|
|
CFontMetrics fontMetrics(_fontName);
|
|
|
|
|
fontMetrics.CalculateStringSize(text.c_str(), width, height);
|
|
|
|
|
return width;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-17 15:10:09 -07:00
|
|
|
/**
|
|
|
|
|
* Microseconds since the epoch.
|
|
|
|
|
*/
|
|
|
|
|
double GetMicroseconds(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
|
|
|
|
{
|
|
|
|
|
return JS_Now();
|
|
|
|
|
}
|
2014-01-04 02:14:53 -08:00
|
|
|
|
2017-05-17 15:10:09 -07:00
|
|
|
} // namespace
|
2014-01-04 02:14:53 -08:00
|
|
|
|
2010-01-09 11:20:14 -08:00
|
|
|
void GuiScriptingInit(ScriptInterface& scriptInterface)
|
|
|
|
|
{
|
2014-01-04 02:14:53 -08:00
|
|
|
JSI_IGUIObject::init(scriptInterface);
|
|
|
|
|
JSI_GUITypes::init(scriptInterface);
|
2014-04-20 13:03:57 -07:00
|
|
|
|
2013-09-12 05:40:05 -07:00
|
|
|
JSI_GameView::RegisterScriptFunctions(scriptInterface);
|
2013-09-21 01:24:45 -07:00
|
|
|
JSI_Renderer::RegisterScriptFunctions(scriptInterface);
|
2013-09-21 07:48:19 -07:00
|
|
|
JSI_Console::RegisterScriptFunctions(scriptInterface);
|
2013-09-29 11:56:50 -07:00
|
|
|
JSI_ConfigDB::RegisterScriptFunctions(scriptInterface);
|
2017-09-11 18:38:46 -07:00
|
|
|
JSI_Game::RegisterScriptFunctions(scriptInterface);
|
2017-09-11 17:54:49 -07:00
|
|
|
JSI_GUIManager::RegisterScriptFunctions(scriptInterface);
|
2014-08-25 09:02:54 -07:00
|
|
|
JSI_Mod::RegisterScriptFunctions(scriptInterface);
|
2017-09-11 17:29:10 -07:00
|
|
|
JSI_Network::RegisterScriptFunctions(scriptInterface);
|
2017-09-11 16:22:28 -07:00
|
|
|
JSI_SavedGame::RegisterScriptFunctions(scriptInterface);
|
2014-01-04 02:14:53 -08:00
|
|
|
JSI_Sound::RegisterScriptFunctions(scriptInterface);
|
2017-09-11 18:53:46 -07:00
|
|
|
JSI_Simulation::RegisterScriptFunctions(scriptInterface);
|
2014-04-20 13:03:57 -07:00
|
|
|
JSI_L10n::RegisterScriptFunctions(scriptInterface);
|
2014-11-15 18:10:24 -08:00
|
|
|
JSI_Lobby::RegisterScriptFunctions(scriptInterface);
|
2017-09-07 21:01:26 -07:00
|
|
|
JSI_VFS::RegisterScriptFunctions(scriptInterface);
|
2015-09-21 10:00:21 -07:00
|
|
|
JSI_VisualReplay::RegisterScriptFunctions(scriptInterface);
|
2015-08-21 10:08:41 -07:00
|
|
|
|
2014-01-04 02:14:53 -08:00
|
|
|
scriptInterface.RegisterFunction<void, &Script_EndGame>("EndGame");
|
2010-07-07 14:47:31 -07:00
|
|
|
scriptInterface.RegisterFunction<void, std::string, &OpenURL>("OpenURL");
|
2013-11-07 12:07:24 -08:00
|
|
|
scriptInterface.RegisterFunction<std::wstring, &GetMatchID>("GetMatchID");
|
2010-07-07 14:47:31 -07:00
|
|
|
scriptInterface.RegisterFunction<void, &RestartInAtlas>("RestartInAtlas");
|
|
|
|
|
scriptInterface.RegisterFunction<bool, &AtlasIsAvailable>("AtlasIsAvailable");
|
2012-04-19 18:41:54 -07:00
|
|
|
scriptInterface.RegisterFunction<bool, &IsAtlasRunning>("IsAtlasRunning");
|
2015-01-24 06:46:52 -08:00
|
|
|
scriptInterface.RegisterFunction<JS::Value, VfsPath, &LoadMapSettings>("LoadMapSettings");
|
2010-11-07 12:42:52 -08:00
|
|
|
scriptInterface.RegisterFunction<bool, std::string, &HotkeyIsPressed_>("HotkeyIsPressed");
|
2010-11-20 11:46:49 -08:00
|
|
|
scriptInterface.RegisterFunction<void, std::wstring, &DisplayErrorDialog>("DisplayErrorDialog");
|
2015-01-24 06:46:52 -08:00
|
|
|
scriptInterface.RegisterFunction<JS::Value, &GetProfilerState>("GetProfilerState");
|
2014-01-04 02:14:53 -08:00
|
|
|
scriptInterface.RegisterFunction<void, &ExitProgram>("Exit");
|
|
|
|
|
scriptInterface.RegisterFunction<int, &GetFps>("GetFPS");
|
2014-04-20 13:51:48 -07:00
|
|
|
scriptInterface.RegisterFunction<std::wstring, int, &GetBuildTimestamp>("GetBuildTimestamp");
|
2016-02-04 09:14:46 -08:00
|
|
|
scriptInterface.RegisterFunction<int, CStr, CStrW, &GetTextWidth>("GetTextWidth");
|
2010-10-21 12:54:59 -07:00
|
|
|
|
2011-02-16 12:40:15 -08:00
|
|
|
// User report functions
|
|
|
|
|
scriptInterface.RegisterFunction<bool, &IsUserReportEnabled>("IsUserReportEnabled");
|
|
|
|
|
scriptInterface.RegisterFunction<void, bool, &SetUserReportEnabled>("SetUserReportEnabled");
|
|
|
|
|
scriptInterface.RegisterFunction<std::string, &GetUserReportStatus>("GetUserReportStatus");
|
|
|
|
|
scriptInterface.RegisterFunction<void, std::string, int, std::wstring, &SubmitUserReport>("SubmitUserReport");
|
|
|
|
|
|
2010-10-21 12:54:59 -07:00
|
|
|
// Development/debugging functions
|
2017-05-17 15:10:09 -07:00
|
|
|
scriptInterface.RegisterFunction<double, &GetMicroseconds>("GetMicroseconds");
|
2010-10-21 12:54:59 -07:00
|
|
|
scriptInterface.RegisterFunction<int, &Crash>("Crash");
|
2010-11-20 09:14:45 -08:00
|
|
|
scriptInterface.RegisterFunction<void, &DebugWarn>("DebugWarn");
|
2010-10-21 12:54:59 -07:00
|
|
|
scriptInterface.RegisterFunction<void, &ForceGC>("ForceGC");
|
2016-05-15 10:13:35 -07:00
|
|
|
scriptInterface.RegisterFunction<CStrW, &GetSystemUsername>("GetSystemUsername");
|
2010-01-09 11:20:14 -08:00
|
|
|
}
|