forked from mirrors/0ad
34 lines
1.0 KiB
JavaScript
34 lines
1.0 KiB
JavaScript
/**
|
|
* Update the overlay with the most recent network warning of each client.
|
|
*/
|
|
function displayGamestateNotifications()
|
|
{
|
|
let messages = [];
|
|
// Add network warnings
|
|
if (Engine.ConfigDB_GetValue("user", "overlay.netwarnings") == "true")
|
|
{
|
|
const netwarnings = getNetworkWarnings();
|
|
messages = messages.concat(netwarnings);
|
|
}
|
|
|
|
const gameStateNotifications = Engine.GetGUIObjectByName("gameStateNotifications");
|
|
gameStateNotifications.caption = messages.join("\n");
|
|
|
|
const maxTextWidth = gameStateNotifications.getPreferredTextSize().width;
|
|
// Resize textbox
|
|
const width = maxTextWidth + 20;
|
|
const height = 14 * messages.length;
|
|
|
|
// Position left of the dataCounter
|
|
const top = "40";
|
|
const right = Engine.GetGUIObjectByName("dataCounter").hidden ? "100%-15" : "100%-110";
|
|
|
|
const bottom = top + "+" + height;
|
|
const left = right + "-" + width;
|
|
|
|
gameStateNotifications.hidden = !messages.length;
|
|
gameStateNotifications.size = left + " " + top + " " + right + " " + bottom;
|
|
|
|
setTimeout(displayGamestateNotifications, 1000);
|
|
}
|