Changeset View
Changeset View
Standalone View
Standalone View
source/ps/scripting/JSInterface_Main.cpp
/* Copyright (C) 2017 Wildfire Games. | /* Copyright (C) 2017 Wildfire Games. | ||||
elexis: 8 | |||||
Not Done Inline Actionsy, sorry ffffffff: y, sorry | |||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 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 | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
Show All 11 Lines | |||||
#include "graphics/FontMetrics.h" | #include "graphics/FontMetrics.h" | ||||
#include "graphics/MapReader.h" | #include "graphics/MapReader.h" | ||||
#include "lib/sysdep/sysdep.h" | #include "lib/sysdep/sysdep.h" | ||||
#include "lib/utf8.h" | #include "lib/utf8.h" | ||||
#include "ps/CStrIntern.h" | #include "ps/CStrIntern.h" | ||||
#include "ps/GUID.h" | #include "ps/GUID.h" | ||||
#include "ps/GameSetup/Atlas.h" | #include "ps/GameSetup/Atlas.h" | ||||
#include "ps/GameSetup/Config.h" | |||||
#include "ps/Globals.h" | #include "ps/Globals.h" | ||||
#include "ps/Hotkey.h" | #include "ps/Hotkey.h" | ||||
#include "tools/atlas/GameInterface/GameLoop.h" | #include "tools/atlas/GameInterface/GameLoop.h" | ||||
extern void restart_mainloop_in_atlas(); | extern void restart_mainloop_in_atlas(); | ||||
extern void kill_mainloop(); | extern void kill_mainloop(); | ||||
void JSI_Main::ExitProgram(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) | void JSI_Main::ExitProgram(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | int JSI_Main::GetTextWidth(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& fontName, const std::wstring& text) | ||||
int width = 0; | int width = 0; | ||||
int height = 0; | int height = 0; | ||||
CStrIntern _fontName(fontName); | CStrIntern _fontName(fontName); | ||||
CFontMetrics fontMetrics(_fontName); | CFontMetrics fontMetrics(_fontName); | ||||
fontMetrics.CalculateStringSize(text.c_str(), width, height); | fontMetrics.CalculateStringSize(text.c_str(), width, height); | ||||
return width; | return width; | ||||
} | } | ||||
void JSI_Main::UpdatePauseOnFocusLoss(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) | |||||
Not Done Inline Actionsenabled elexis: enabled | |||||
{ | |||||
ConfigSetPauseOnFocusLoss(); | |||||
} | |||||
void JSI_Main::RegisterScriptFunctions(const ScriptInterface& scriptInterface) | void JSI_Main::RegisterScriptFunctions(const ScriptInterface& scriptInterface) | ||||
{ | { | ||||
scriptInterface.RegisterFunction<void, &ExitProgram>("Exit"); | scriptInterface.RegisterFunction<void, &ExitProgram>("Exit"); | ||||
scriptInterface.RegisterFunction<void, &RestartInAtlas>("RestartInAtlas"); | scriptInterface.RegisterFunction<void, &RestartInAtlas>("RestartInAtlas"); | ||||
scriptInterface.RegisterFunction<bool, &AtlasIsAvailable>("AtlasIsAvailable"); | scriptInterface.RegisterFunction<bool, &AtlasIsAvailable>("AtlasIsAvailable"); | ||||
Not Done Inline ActionsGuess it's not a terrible to do it JSI_Main, since it is used only by Main.cpp while none of the other config options are used here. elexis: Guess it's not a terrible to do it JSI_Main, since it is used only by Main.cpp while none of… | |||||
scriptInterface.RegisterFunction<bool, &IsAtlasRunning>("IsAtlasRunning"); | scriptInterface.RegisterFunction<bool, &IsAtlasRunning>("IsAtlasRunning"); | ||||
scriptInterface.RegisterFunction<void, std::string, &OpenURL>("OpenURL"); | scriptInterface.RegisterFunction<void, std::string, &OpenURL>("OpenURL"); | ||||
scriptInterface.RegisterFunction<std::wstring, &GetSystemUsername>("GetSystemUsername"); | scriptInterface.RegisterFunction<std::wstring, &GetSystemUsername>("GetSystemUsername"); | ||||
scriptInterface.RegisterFunction<std::wstring, &GetMatchID>("GetMatchID"); | scriptInterface.RegisterFunction<std::wstring, &GetMatchID>("GetMatchID"); | ||||
scriptInterface.RegisterFunction<JS::Value, VfsPath, &LoadMapSettings>("LoadMapSettings"); | scriptInterface.RegisterFunction<JS::Value, VfsPath, &LoadMapSettings>("LoadMapSettings"); | ||||
scriptInterface.RegisterFunction<bool, std::string, &HotkeyIsPressed_>("HotkeyIsPressed"); | scriptInterface.RegisterFunction<bool, std::string, &HotkeyIsPressed_>("HotkeyIsPressed"); | ||||
scriptInterface.RegisterFunction<int, &GetFps>("GetFPS"); | scriptInterface.RegisterFunction<int, &GetFps>("GetFPS"); | ||||
scriptInterface.RegisterFunction<int, std::string, std::wstring, &GetTextWidth>("GetTextWidth"); | scriptInterface.RegisterFunction<int, std::string, std::wstring, &GetTextWidth>("GetTextWidth"); | ||||
scriptInterface.RegisterFunction<void, &UpdatePauseOnFocusLoss>("UpdatePauseOnFocusLoss"); | |||||
} | } |
Wildfire Games · Phabricator
8