Files
0ad/binaries/data/mods/mod/gui/common/utilities.js
T
marder a6c1d5bbb9 revert last commit / 39dd5329cc
Misscommunication if this was the right move or not.

Leave the size as it was until someone has time to fix all buttons at
once.

This was SVN commit r26987.
2022-06-24 16:41:53 +00:00

36 lines
856 B
JavaScript

function distributeButtonsHorizontally(button, captions)
{
const y1 = "100%-46";
const y2 = "100%-18";
switch (captions.length)
{
case 1:
button[0].size = "18 " + y1 + " 100%-18 " + y2;
break;
case 2:
button[0].size = "18 " + y1 + " 50%-5 " + y2;
button[1].size = "50%+5 " + y1 + " 100%-18 " + y2;
break;
case 3:
button[0].size = "18 " + y1 + " 33%-5 " + y2;
button[1].size = "33%+5 " + y1 + " 66%-5 " + y2;
button[2].size = "66%+5 " + y1 + " 100%-18 " + y2;
break;
}
}
function setButtonCaptionsAndVisibitily(button, captions, cancelHotkey, name)
{
captions.forEach((caption, i) => {
button[i] = Engine.GetGUIObjectByName(name + (i + 1));
button[i].caption = caption;
button[i].hidden = false;
button[i].onPress = () => {
Engine.PopGuiPage(i);
};
if (i == 0)
cancelHotkey.onPress = button[i].onPress;
});
}