mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-21 07:43:59 -07:00
Allows to return the page-completion-value instead of passing it to an `Engine` function. Closes: #7000
31 lines
930 B
JavaScript
31 lines
930 B
JavaScript
/**
|
|
* Currently limited to at most 3 buttons per message box.
|
|
* The convention is to have "cancel" appear first.
|
|
*/
|
|
function init(data)
|
|
{
|
|
// Set title
|
|
Engine.GetGUIObjectByName("mbTitleBar").caption = data.title;
|
|
|
|
// Set subject
|
|
let mbTextObj = Engine.GetGUIObjectByName("mbText");
|
|
mbTextObj.caption = data.message;
|
|
if (data.font)
|
|
mbTextObj.font = data.font;
|
|
|
|
// Default behaviour
|
|
let mbCancelHotkey = Engine.GetGUIObjectByName("mbCancelHotkey");
|
|
|
|
// Calculate size
|
|
let mbLRDiff = data.width / 2;
|
|
let mbUDDiff = data.height / 2;
|
|
Engine.GetGUIObjectByName("mbMain").size = "50%-" + mbLRDiff + " 50%-" + mbUDDiff + " 50%+" + mbLRDiff + " 50%+" + mbUDDiff;
|
|
|
|
let captions = data.buttonCaptions || [translate("OK")];
|
|
|
|
let mbButton = [];
|
|
const closePromise = setButtonCaptionsAndVisibility(mbButton, captions, mbCancelHotkey, "mbButton");
|
|
distributeButtonsHorizontally(mbButton, captions);
|
|
|
|
return closePromise;
|
|
}
|