Changeset View
Changeset View
Standalone View
Standalone View
source/ps/scripting/JSInterface_Main.cpp
Show All 15 Lines | |||||
*/ | */ | ||||
#include "precompiled.h" | #include "precompiled.h" | ||||
#include "JSInterface_Main.h" | #include "JSInterface_Main.h" | ||||
#include "graphics/FontMetrics.h" | #include "graphics/FontMetrics.h" | ||||
#include "graphics/MapReader.h" | #include "graphics/MapReader.h" | ||||
#include "renderer/Renderer.h" | |||||
#include "lib/sysdep/sysdep.h" | #include "lib/sysdep/sysdep.h" | ||||
#include "lib/utf8.h" | #include "lib/utf8.h" | ||||
#include "maths/Size2D.h" | #include "maths/Size2D.h" | ||||
#include "maths/MD5.h" | #include "maths/MD5.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/Globals.h" | #include "ps/Globals.h" | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | int GetFps() | ||||
return g_frequencyFilter->StableFrequency(); | return g_frequencyFilter->StableFrequency(); | ||||
} | } | ||||
CSize2D GetTextSize(const std::string& fontName, const std::wstring& text) | CSize2D GetTextSize(const std::string& fontName, const std::wstring& text) | ||||
{ | { | ||||
int width = 0; | int width = 0; | ||||
int height = 0; | int height = 0; | ||||
if (CRenderer::IsInitialised()) | |||||
{ | |||||
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 CSize2D(width, height); | return CSize2D(width, height); | ||||
} | } | ||||
int GetTextWidth(const std::string& fontName, const std::wstring& text) | int GetTextWidth(const std::string& fontName, const std::wstring& text) | ||||
{ | { | ||||
return GetTextSize(fontName, text).Width; | return GetTextSize(fontName, text).Width; | ||||
} | } | ||||
Show All 27 Lines |
Wildfire Games · Phabricator