mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-18 22:33:56 -07:00
Now It's not hardcoded what is done if a button is pressed. The caller can decide that. Previously one had to call this function and then overwrite the on Press attribute of each button. Rename "Visibitily" to "Visibility" in setButtonCaptionsAndVisibility.
31 lines
954 B
JavaScript
31 lines
954 B
JavaScript
/**
|
|
* Currently limited to at most 3 buttons per message box.
|
|
* The convention is to have "cancel" appear first.
|
|
*/
|
|
async 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);
|
|
|
|
Engine.PopGuiPage(await closePromise);
|
|
}
|