Implement network-warnings, fixes #3264.

Shows a notification if the local client or other players connections
timeout or have bad latency.

This was SVN commit r17730.
This commit is contained in:
elexis
2016-02-04 17:14:46 +00:00
parent 4d41bd9622
commit 22f5b00fce
21 changed files with 468 additions and 19 deletions
+12
View File
@@ -20,6 +20,7 @@
#include "scriptinterface/ScriptInterface.h"
#include "graphics/Camera.h"
#include "graphics/FontMetrics.h"
#include "graphics/GameView.h"
#include "graphics/MapReader.h"
#include "graphics/scripting/JSInterface_GameView.h"
@@ -875,6 +876,16 @@ CParamNode GetTemplate(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std
return g_GUI->GetTemplate(templateName);
}
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;
}
//-----------------------------------------------------------------------------
// Timer
//-----------------------------------------------------------------------------
@@ -1049,6 +1060,7 @@ void GuiScriptingInit(ScriptInterface& scriptInterface)
scriptInterface.RegisterFunction<void, std::wstring, JS::HandleValue, &WriteJSONFile>("WriteJSONFile");
scriptInterface.RegisterFunction<bool, std::string, &TemplateExists>("TemplateExists");
scriptInterface.RegisterFunction<CParamNode, std::string, &GetTemplate>("GetTemplate");
scriptInterface.RegisterFunction<int, CStr, CStrW, &GetTextWidth>("GetTextWidth");
// User report functions
scriptInterface.RegisterFunction<bool, &IsUserReportEnabled>("IsUserReportEnabled");