0ad/binaries/data/mods/mod/gui/common/functions_msgbox.js
Angen 7e5e06bae8 Fix timeout confirmation box depending on fps
Introduced in b4fbbed379
Use Date.now() to calculate passed time.
Rewrite to class.
Also actually pass timeout from json.

Differential revision: D4318
Comments by: @vladislavbelov, @Stan
This was SVN commit r26306.
2022-02-06 11:04:42 +00:00

48 lines
1.1 KiB
JavaScript

function messageBox(mbWidth, mbHeight, mbMessage, mbTitle, mbButtonCaptions, mbBtnCode, mbCallbackArgs)
{
Engine.PushGuiPage(
"page_msgbox.xml",
{
"width": mbWidth,
"height": mbHeight,
"message": mbMessage,
"title": mbTitle,
"buttonCaptions": mbButtonCaptions
},
btnCode => {
if (mbBtnCode !== undefined && mbBtnCode[btnCode])
mbBtnCode[btnCode](mbCallbackArgs ? mbCallbackArgs[btnCode] : undefined);
});
}
function timedConfirmation(width, height, message, timeParameter, timeout, title, buttonCaptions, btnCode, callbackArgs)
{
Engine.PushGuiPage(
"page_timedconfirmation.xml",
{
"width": width,
"height": height,
"message": message,
"timeParameter": timeParameter,
"timeout": timeout,
"title": title,
"buttonCaptions": buttonCaptions
},
button => {
if (btnCode !== undefined && btnCode[button])
btnCode[button](callbackArgs ? callbackArgs[button] : undefined);
});
}
function openURL(url)
{
Engine.OpenURL(url);
messageBox(
600, 200,
sprintf(
translate("Opening %(url)s\n in default web browser. Please wait…"),
{ "url": url }
),
translate("Opening page"));
}