Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/mod/gui/msgbox/msgbox.js
Show All 22 Lines | function init(data) | ||||
Engine.GetGUIObjectByName("mbMain").size = "50%-" + mbLRDiff + " 50%-" + mbUDDiff + " 50%+" + mbLRDiff + " 50%+" + mbUDDiff; | Engine.GetGUIObjectByName("mbMain").size = "50%-" + mbLRDiff + " 50%-" + mbUDDiff + " 50%+" + mbLRDiff + " 50%+" + mbUDDiff; | ||||
let captions = data.buttonCaptions || [translate("OK")]; | let captions = data.buttonCaptions || [translate("OK")]; | ||||
// Set button captions and visibility | // Set button captions and visibility | ||||
let mbButton = []; | let mbButton = []; | ||||
captions.forEach((caption, i) => { | captions.forEach((caption, i) => { | ||||
mbButton[i] = Engine.GetGUIObjectByName("mbButton" + (i + 1)); | mbButton[i] = Engine.GetGUIObjectByName("mbButton" + (i + 1)); | ||||
let action = function() | |||||
{ | |||||
if (data.callback) | |||||
Engine.PopGuiPageCB(i); | |||||
else | |||||
Engine.PopGuiPage(); | |||||
}; | |||||
mbButton[i].caption = caption; | mbButton[i].caption = caption; | ||||
mbButton[i].onPress = action; | |||||
mbButton[i].hidden = false; | mbButton[i].hidden = false; | ||||
mbButton[i].onPress = () => { | |||||
Engine.PopGuiPage(i); | |||||
}; | |||||
// Convention: Cancel is the first button | // Convention: Cancel is the first button | ||||
if (i == 0) | if (i == 0) | ||||
mbCancelHotkey.onPress = action; | mbCancelHotkey.onPress = mbButton[i].onPress; | ||||
}); | }); | ||||
// Distribute buttons horizontally | // Distribute buttons horizontally | ||||
let y1 = "100%-46"; | let y1 = "100%-46"; | ||||
let y2 = "100%-18"; | let y2 = "100%-18"; | ||||
switch (captions.length) | switch (captions.length) | ||||
{ | { | ||||
case 1: | case 1: | ||||
Show All 13 Lines |
Wildfire Games · Phabricator