elexis
38e06fce7e
Rebuild the counters every 250ms instead of every frame and minimize object creation. Differential Revision: https://code.wildfiregames.com/D2391 Comments By: Stan This was SVN commit r23096.
59 lines
1.5 KiB
JavaScript
59 lines
1.5 KiB
JavaScript
/**
|
|
* Update the overlay with the most recent network warning of each client.
|
|
*/
|
|
function displayGamestateNotifications()
|
|
{
|
|
let messages = [];
|
|
let maxTextWidth = 0;
|
|
|
|
// Add network warnings
|
|
if (Engine.ConfigDB_GetValue("user", "overlay.netwarnings") == "true")
|
|
{
|
|
let netwarnings = getNetworkWarnings();
|
|
messages = messages.concat(netwarnings.messages);
|
|
maxTextWidth = Math.max(maxTextWidth, netwarnings.maxTextWidth);
|
|
}
|
|
|
|
// Resize textbox
|
|
let width = maxTextWidth + 20;
|
|
let height = 14 * messages.length;
|
|
|
|
// Position left of the dataCounter
|
|
let top = "40";
|
|
let right = Engine.GetGUIObjectByName("dataCounter").hidden ? "100%-15" : "100%-110";
|
|
|
|
let bottom = top + "+" + height;
|
|
let left = right + "-" + width;
|
|
|
|
let gameStateNotifications = Engine.GetGUIObjectByName("gameStateNotifications");
|
|
gameStateNotifications.caption = messages.join("\n");
|
|
gameStateNotifications.hidden = !messages.length;
|
|
gameStateNotifications.size = left + " " + top + " " + right + " " + bottom;
|
|
|
|
setTimeout(displayGamestateNotifications, 1000);
|
|
}
|
|
|
|
/**
|
|
* This function is called from the engine whenever starting a game fails.
|
|
*/
|
|
function cancelOnLoadGameError(msg)
|
|
{
|
|
Engine.EndGame();
|
|
|
|
if (Engine.HasXmppClient())
|
|
Engine.StopXmppClient();
|
|
|
|
Engine.SwitchGuiPage("page_pregame.xml");
|
|
|
|
if (msg)
|
|
Engine.PushGuiPage("page_msgbox.xml", {
|
|
"width": 500,
|
|
"height": 200,
|
|
"message": '[font="sans-bold-18"]' + msg + '[/font]',
|
|
"title": translate("Loading Aborted"),
|
|
"mode": 2
|
|
});
|
|
|
|
Engine.ResetCursor();
|
|
}
|