mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Refactor GUI object resizing JS code passages
It is possible to modify sizes by setting the properties directly. (Without having to create a copy of it) This allows to shorten those passages quite a bit without any functional change.
This commit is contained in:
parent
b34f4b79aa
commit
fd847c2a23
61 changed files with 324 additions and 508 deletions
|
|
@ -40,10 +40,8 @@ class ColorMixer
|
|||
if (!object)
|
||||
continue;
|
||||
|
||||
const size = object.size;
|
||||
size.top = i * height0;
|
||||
size.bottom = size.top + height0;
|
||||
object.size = size;
|
||||
object.size.top = i * height0;
|
||||
object.size.bottom = (i + 1) * height0;
|
||||
|
||||
this.sliders[i] = Engine.GetGUIObjectByName("colorSlider[" + i + "]");
|
||||
const slider = this.sliders[i];
|
||||
|
|
|
|||
|
|
@ -314,12 +314,9 @@ async function progressDialog(dialogCaption, dialogTitle, showProgressBar, butto
|
|||
{
|
||||
Engine.GetGUIObjectByName("downloadDialog_title").caption = dialogTitle;
|
||||
|
||||
const downloadDialog_caption = Engine.GetGUIObjectByName("downloadDialog_caption");
|
||||
downloadDialog_caption.caption = dialogCaption;
|
||||
|
||||
const size = downloadDialog_caption.size;
|
||||
size.rbottom = showProgressBar ? 40 : 80;
|
||||
downloadDialog_caption.size = size;
|
||||
const downloadDialogCaption = Engine.GetGUIObjectByName("downloadDialog_caption");
|
||||
downloadDialogCaption.caption = dialogCaption;
|
||||
downloadDialogCaption.size.rbottom = showProgressBar ? 40 : 80;
|
||||
|
||||
Engine.GetGUIObjectByName("downloadDialog_progress").hidden = !showProgressBar;
|
||||
Engine.GetGUIObjectByName("downloadDialog_status").hidden = !showProgressBar;
|
||||
|
|
|
|||
|
|
@ -42,10 +42,6 @@ class AlignmentHelper
|
|||
value = Math[this.direction](value, this.objectData[objectName].wantedPosition);
|
||||
|
||||
for (const objectName in this.objectData)
|
||||
{
|
||||
const objectSize = this.objectData[objectName].GUIObject.size;
|
||||
objectSize[this.objectData[objectName].edge] = value;
|
||||
this.objectData[objectName].GUIObject.size = objectSize;
|
||||
}
|
||||
this.objectData[objectName].GUIObject.size[this.objectData[objectName].edge] = value;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -221,11 +221,10 @@ function horizontallySpaceObjects(parentName, margin = 0)
|
|||
const objects = Engine.GetGUIObjectByName(parentName).children;
|
||||
for (let i = 0; i < objects.length; ++i)
|
||||
{
|
||||
const size = objects[i].size;
|
||||
const width = size.right - size.left;
|
||||
size.left = i * (width + margin) + margin;
|
||||
size.right = (i + 1) * (width + margin);
|
||||
objects[i].size = size;
|
||||
const obj = objects[i];
|
||||
const width = obj.size.right - obj.size.left;
|
||||
obj.size.left = i * (width + margin) + margin;
|
||||
obj.size.right = (i + 1) * (width + margin);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -237,7 +236,6 @@ function horizontallySpaceObjects(parentName, margin = 0)
|
|||
*/
|
||||
function resizeGUIObjectToCaption(object, align, margin = {})
|
||||
{
|
||||
const objectSize = object.size;
|
||||
const textSize = Engine.GetTextSize(object.font, object.caption);
|
||||
if (align.horizontal)
|
||||
{
|
||||
|
|
@ -245,17 +243,17 @@ function resizeGUIObjectToCaption(object, align, margin = {})
|
|||
switch (align.horizontal)
|
||||
{
|
||||
case "right":
|
||||
objectSize.right = object.size.left + width;
|
||||
object.size.right = object.size.left + width;
|
||||
break;
|
||||
case "left":
|
||||
objectSize.left = object.size.right - width;
|
||||
object.size.left = object.size.right - width;
|
||||
break;
|
||||
case "center":
|
||||
{
|
||||
const oldWidth = object.size.right - object.size.left;
|
||||
const widthDiff = width - oldWidth;
|
||||
objectSize.right = object.size.right + (widthDiff / 2);
|
||||
objectSize.left = object.size.left - (widthDiff / 2);
|
||||
object.size.right += (widthDiff / 2);
|
||||
object.size.left -= (widthDiff / 2);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
@ -268,17 +266,16 @@ function resizeGUIObjectToCaption(object, align, margin = {})
|
|||
switch (align.vertical)
|
||||
{
|
||||
case "bottom":
|
||||
objectSize.bottom = object.size.top + height;
|
||||
object.size.bottom = object.size.top + height;
|
||||
break;
|
||||
case "top":
|
||||
objectSize.top = object.size.bottom - height;
|
||||
object.size.top = object.size.bottom - height;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
object.size = objectSize;
|
||||
return objectSize;
|
||||
return object.size;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -46,20 +46,19 @@ function placeTabButtons(categoriesData, horizontal, buttonSize, spacing, onPres
|
|||
button.style = "ModernTabButton" + (horizontal ? "Horizontal" : "Vertical");
|
||||
button.hidden = false;
|
||||
|
||||
const size = button.size;
|
||||
if (horizontal)
|
||||
{
|
||||
size.left = category * (buttonSize + spacing) + spacing / 2;
|
||||
size.right = size.left + buttonSize;
|
||||
size.rright = 0;
|
||||
button.size.left = category * (buttonSize + spacing) + spacing / 2;
|
||||
button.size.right = button.size.left + buttonSize;
|
||||
button.size.rright = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
size.top = category * (buttonSize + spacing) + spacing / 2;
|
||||
size.bottom = size.top + buttonSize;
|
||||
size.rbottom = 0;
|
||||
button.size.top = category * (buttonSize + spacing) + spacing / 2;
|
||||
button.size.bottom = button.size.top + buttonSize;
|
||||
button.size.rbottom = 0;
|
||||
}
|
||||
button.size = size;
|
||||
|
||||
button.tooltip = (categoriesData[category].tooltip ? categoriesData[category].tooltip + "\n" : "") +
|
||||
(g_TabHorizontal ?
|
||||
colorizeHotkey(translate("Scroll down or use %(hotkey)s to move a tab right."), "tab.next") + "\n" + colorizeHotkey(translate("Scroll up or use %(hotkey)s to move a tab left."), "tab.prev"):
|
||||
|
|
|
|||
|
|
@ -29,10 +29,8 @@ class AIGameSettingControlDropdown extends GameSettingControlDropdown
|
|||
this.dropdown = this.frame.children[1];
|
||||
this.label = this.frame.children[2];
|
||||
|
||||
const size = this.frame.size;
|
||||
size.top = i * (this.Height + this.Margin);
|
||||
size.bottom = size.top + this.Height;
|
||||
this.frame.size = size;
|
||||
this.frame.size.top = i * (this.Height + this.Margin);
|
||||
this.frame.size.bottom = this.frame.size.top + this.Height;
|
||||
|
||||
this.setHidden(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,8 @@ PlayerSettingControls.PlayerFrame = class PlayerFrame extends GameSettingControl
|
|||
|
||||
this.playerFrame = Engine.GetGUIObjectByName("playerFrame[" + this.playerIndex + "]");
|
||||
|
||||
{
|
||||
const size = this.playerFrame.size;
|
||||
size.top = this.Height * this.playerIndex;
|
||||
size.bottom = this.Height * (this.playerIndex + 1);
|
||||
this.playerFrame.size = size;
|
||||
}
|
||||
this.playerFrame.size.top = this.Height * this.playerIndex;
|
||||
this.playerFrame.size.bottom = this.Height * (this.playerIndex + 1);
|
||||
|
||||
g_GameSettings.playerCount.watch(() => this.render(), ["nbPlayers"]);
|
||||
this.render();
|
||||
|
|
|
|||
|
|
@ -11,16 +11,16 @@ class SavedGameLabel
|
|||
|
||||
if (isSavedGame)
|
||||
{
|
||||
savedGameLabel.parent.size = new GUISize(
|
||||
bottomRightPanel.size.left - labelWidth - marginRight,
|
||||
savedGameLabel.parent.size.top,
|
||||
bottomRightPanel.size.left - marginRight,
|
||||
savedGameLabel.parent.size.bottom,
|
||||
bottomRightPanel.size.rleft,
|
||||
savedGameLabel.parent.size.rtop,
|
||||
bottomRightPanel.size.rleft,
|
||||
savedGameLabel.parent.size.rbottom
|
||||
);
|
||||
savedGameLabel.parent.size = {
|
||||
"left": bottomRightPanel.size.left - labelWidth - marginRight,
|
||||
"top": savedGameLabel.parent.size.top,
|
||||
"right": bottomRightPanel.size.left - marginRight,
|
||||
"bottom": savedGameLabel.parent.size.bottom,
|
||||
"rleft": bottomRightPanel.size.rleft,
|
||||
"rtop": savedGameLabel.parent.size.rtop,
|
||||
"rright": bottomRightPanel.size.rleft,
|
||||
"rbottom": savedGameLabel.parent.size.rbottom
|
||||
};
|
||||
savedGameLabel.hidden = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@ class ChatInputPanel
|
|||
resizeGUIObjectToCaption(this.chatSubmitButton, { "horizontal": "left" }, { "horizontal": 8 });
|
||||
|
||||
this.chatInput = Engine.GetGUIObjectByName("chatInput");
|
||||
const size = this.chatInput.size;
|
||||
size.right = this.chatSubmitButton.size.left;
|
||||
this.chatInput.size = size;
|
||||
this.chatSubmitButton.size.right = this.chatSubmitButton.size.left;
|
||||
|
||||
this.chatInput = Engine.GetGUIObjectByName("chatInput");
|
||||
this.chatInput.tooltip = colorizeAutocompleteHotkey(this.Tooltip);
|
||||
|
|
|
|||
|
|
@ -59,10 +59,7 @@ class ChatMessagesPanel
|
|||
|
||||
onGameSettingsPanelResize(settingsPanel)
|
||||
{
|
||||
const size = this.chatPanel.size;
|
||||
size.right = settingsPanel.size.left + this.gameSettingsPanel.MaxColumnWidth + this.Margin;
|
||||
this.chatPanel.size = size;
|
||||
|
||||
this.chatPanel.size.right = settingsPanel.size.left + this.gameSettingsPanel.MaxColumnWidth + this.Margin;
|
||||
this.updateHidden();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,9 +39,7 @@ class GameDescription
|
|||
|
||||
onTabsResize(settingsTabButtonsFrame)
|
||||
{
|
||||
const size = this.gameDescription.size;
|
||||
size.top = settingsTabButtonsFrame.size.bottom + this.Margin;
|
||||
this.gameDescription.size = size;
|
||||
this.gameDescription.size.top = settingsTabButtonsFrame.size.bottom + this.Margin;
|
||||
}
|
||||
|
||||
updateGameDescription()
|
||||
|
|
|
|||
|
|
@ -31,16 +31,16 @@ class GameSettingWarning
|
|||
const labelWidth = Math.min(Engine.GetTextWidth(this.gameSettingWarning.font, this.gameSettingWarning.caption) + 10, maxWidth);
|
||||
|
||||
const neighborElement = !this.savedGameLabel.hidden ? this.savedGameLabel.parent : this.bottomRightPanel;
|
||||
this.gameSettingWarning.parent.size = new GUISize(
|
||||
neighborElement.size.left - labelWidth - marginRight,
|
||||
this.gameSettingWarning.parent.size.top,
|
||||
neighborElement.size.left - marginRight,
|
||||
this.gameSettingWarning.parent.size.bottom,
|
||||
neighborElement.size.rleft,
|
||||
this.gameSettingWarning.parent.size.rtop,
|
||||
neighborElement.size.rright,
|
||||
this.gameSettingWarning.parent.size.rbottom
|
||||
);
|
||||
this.gameSettingWarning.parent.size = {
|
||||
"left": neighborElement.size.left - labelWidth - marginRight,
|
||||
"top": this.gameSettingWarning.parent.size.top,
|
||||
"right": neighborElement.size.left - marginRight,
|
||||
"bottom": this.gameSettingWarning.parent.size.bottom,
|
||||
"rleft": neighborElement.size.rleft,
|
||||
"rtop": this.gameSettingWarning.parent.size.rtop,
|
||||
"rright": neighborElement.size.rright,
|
||||
"rbottom": this.gameSettingWarning.parent.size.rbottom
|
||||
};
|
||||
this.gameSettingWarning.hidden = !caption;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,10 +92,8 @@ class GameSettingsPanel
|
|||
if (!offset)
|
||||
return;
|
||||
|
||||
const size = this.settingsPanelFrame.size;
|
||||
size.left += offset;
|
||||
size.right += offset;
|
||||
this.settingsPanelFrame.size = size;
|
||||
this.settingsPanelFrame.size.left += offset;
|
||||
this.settingsPanelFrame.size.right += offset;
|
||||
|
||||
this.triggerResizeHandlers();
|
||||
}
|
||||
|
|
@ -141,21 +139,18 @@ class GameSettingsPanel
|
|||
settingsThisColumn = 0;
|
||||
}
|
||||
|
||||
settingFrame.size = new GUISize(
|
||||
columnWidth * column,
|
||||
yPos,
|
||||
columnWidth * (column + 1) - this.SettingMarginRight,
|
||||
yPos + this.SettingHeight - this.SettingMarginBottom);
|
||||
settingFrame.size = {
|
||||
"left": columnWidth * column,
|
||||
"top": yPos,
|
||||
"right": columnWidth * (column + 1) - this.SettingMarginRight,
|
||||
"bottom": yPos + this.SettingHeight - this.SettingMarginBottom
|
||||
};
|
||||
|
||||
yPos += this.SettingHeight;
|
||||
++settingsThisColumn;
|
||||
}
|
||||
|
||||
{
|
||||
const size = this.settingsPanelFrame.size;
|
||||
size.right = size.left + (column + 1) * columnWidth;
|
||||
this.settingsPanelFrame.size = size;
|
||||
}
|
||||
this.settingsPanelFrame.size.right = this.settingsPanelFrame.size.left + (column + 1) * columnWidth;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,15 +44,15 @@ class GameSettingTabs
|
|||
|
||||
resize()
|
||||
{
|
||||
const size = this.settingsTabButtonsFrame.size;
|
||||
size.bottom = size.top + g_GameSettingsLayout.length * (this.TabButtonHeight + this.TabButtonMargin);
|
||||
this.settingsTabButtonsFrame.size.bottom =
|
||||
this.settingsTabButtonsFrame.size.top +
|
||||
g_GameSettingsLayout.length * (this.TabButtonHeight + this.TabButtonMargin);
|
||||
|
||||
if (!this.lobbyButton.lobbyButton.hidden)
|
||||
{
|
||||
const lobbyButtonSize = this.lobbyButton.lobbyButton.parent.size;
|
||||
size.right -= lobbyButtonSize.right - lobbyButtonSize.left + this.LobbyButtonMargin;
|
||||
this.settingsTabButtonsFrame.size.right -= lobbyButtonSize.right - lobbyButtonSize.left + this.LobbyButtonMargin;
|
||||
}
|
||||
this.settingsTabButtonsFrame.size = size;
|
||||
|
||||
for (const handler of this.tabsResizeHandlers)
|
||||
handler(this.settingsTabButtonsFrame);
|
||||
|
|
|
|||
|
|
@ -16,15 +16,10 @@ class Tooltip
|
|||
const marginRight = 8;
|
||||
const neighborElement = !g_IsNetworked ? this.bottomRightPanel : this.gameSettingWarning.parent;
|
||||
|
||||
this.onScreenTooltip.parent.size = new GUISize(
|
||||
this.onScreenTooltip.parent.size.left,
|
||||
this.onScreenTooltip.parent.size.top,
|
||||
neighborElement.size.left - marginRight,
|
||||
this.onScreenTooltip.parent.size.bottom,
|
||||
this.onScreenTooltip.size.rleft,
|
||||
this.onScreenTooltip.parent.size.rtop,
|
||||
neighborElement.size.rleft,
|
||||
this.onScreenTooltip.parent.size.rbottom
|
||||
);
|
||||
Object.assign(this.onScreenTooltip.parent.size, {
|
||||
"right": neighborElement.size.left - marginRight,
|
||||
"rleft": this.onScreenTooltip.size.rleft,
|
||||
"rright": neighborElement.size.rleft,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -374,19 +374,15 @@ function switchSetupPage(newPage)
|
|||
|
||||
if (newPage == "pageJoin" || newPage == "pageHost")
|
||||
{
|
||||
const pageSize = multiplayerPages.size;
|
||||
const halfHeight = newPage == "pageJoin" ? 145 : Engine.HasXmppClient() ? 140 : 125;
|
||||
pageSize.top = -halfHeight;
|
||||
pageSize.bottom = halfHeight;
|
||||
multiplayerPages.size = pageSize;
|
||||
multiplayerPages.size.top = -halfHeight;
|
||||
multiplayerPages.size.bottom = halfHeight;
|
||||
}
|
||||
else if (newPage == "pagePassword")
|
||||
{
|
||||
const pageSize = multiplayerPages.size;
|
||||
const halfHeight = 60;
|
||||
pageSize.top = -halfHeight;
|
||||
pageSize.bottom = halfHeight;
|
||||
multiplayerPages.size = pageSize;
|
||||
multiplayerPages.size.top = -halfHeight;
|
||||
multiplayerPages.size.bottom = halfHeight;
|
||||
}
|
||||
|
||||
Engine.GetGUIObjectByName(newPage).hidden = false;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class HotkeyPicker
|
|||
const s = Engine.GetGUIObjectByName("combination[" + i + "]").size;
|
||||
s.top = +i * 60 + 120;
|
||||
s.bottom = +i * 60 + 150;
|
||||
Engine.GetGUIObjectByName("combination[" + i + "]").size = s;
|
||||
|
||||
Engine.GetGUIObjectByName("combNb[" + i + "]").caption = sprintf(translate("#%i"), i);
|
||||
|
||||
if (i == this.combinations.length)
|
||||
|
|
|
|||
|
|
@ -20,9 +20,7 @@ class SavegamePage
|
|||
{
|
||||
this.savegameWriter = new SavegameWriter(closePageCallback, data.savedGameData);
|
||||
this.savegameList.registerSelectionChangeHandler(this.savegameWriter);
|
||||
const size = this.savegameList.gameSelection.size;
|
||||
size.bottom -= 24;
|
||||
this.savegameList.gameSelection.size = size;
|
||||
this.savegameList.gameSelection.size.bottom -= 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,10 +37,8 @@ class ProgressBar
|
|||
}
|
||||
|
||||
const increment = Math.round(progress * this.progressBarSize / 100);
|
||||
const size = this.progressbar_right.size;
|
||||
size.left = increment;
|
||||
size.right = increment + this.progressbar_right_width;
|
||||
this.progressbar_right.size = size;
|
||||
this.progressbar_right.size.left = increment;
|
||||
this.progressbar_right.size.right = increment + this.progressbar_right_width;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,9 +27,6 @@ class ChatPanel
|
|||
resizeGUIObjectToCaption(this.chatSubmit, { "horizontal": "left" }, { "horizontal": 8 });
|
||||
|
||||
this.chatInput = Engine.GetGUIObjectByName("chatInput");
|
||||
const size = this.chatInput.size;
|
||||
size.right = this.chatSubmit.size.left;
|
||||
this.chatInput.size = size;
|
||||
this.chatInput = Engine.GetGUIObjectByName("chatInput");
|
||||
this.chatInput.size.right = this.chatSubmit.size.left;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@ class GameDetails
|
|||
resize(dialog)
|
||||
{
|
||||
const bottom = Engine.GetGUIObjectByName(dialog ? "leaveButton" : "joinButton").size.top - 5;
|
||||
const size = this.gameDetails.size;
|
||||
size.bottom = bottom;
|
||||
this.gameDetails.size = size;
|
||||
this.gameDetails.size.bottom = bottom;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -87,10 +85,7 @@ class GameDetails
|
|||
this.sgGame.caption = txt;
|
||||
|
||||
const textHeight = this.sgGame.getTextSize().height;
|
||||
|
||||
const sgGameSize = this.sgGame.size;
|
||||
sgGameSize.bottom = textHeight;
|
||||
this.sgGame.size = sgGameSize;
|
||||
this.sgGame.size.bottom = textHeight;
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -128,10 +123,7 @@ class GameDetails
|
|||
this.sgPlayersAndMods.caption = txt;
|
||||
|
||||
// Resize the box
|
||||
const textHeight = this.sgPlayersAndMods.getTextSize().height;
|
||||
const size = this.sgPlayersAndMods.size;
|
||||
size.top = this.sgGame.size.bottom + 5;
|
||||
this.sgPlayersAndMods.size = size;
|
||||
this.sgPlayersAndMods.size.top = this.sgGame.size.bottom + 5;
|
||||
}
|
||||
|
||||
this.lastGame = game;
|
||||
|
|
|
|||
|
|
@ -41,11 +41,8 @@ GameListFilters.Rating = class
|
|||
const mapTypeFilter = Engine.GetGUIObjectByName("mapTypeFilter");
|
||||
mapTypeFilter.hidden = enabled;
|
||||
const playersNumberFilter = Engine.GetGUIObjectByName("playersNumberFilter");
|
||||
const mapTypeFilterSize = mapTypeFilter.size;
|
||||
const size = playersNumberFilter.size;
|
||||
size.rleft = mapTypeFilterSize.rleft;
|
||||
size.rright = this.gameRatingFilter.size.rleft;
|
||||
playersNumberFilter.size = size;
|
||||
playersNumberFilter.size.rleft = mapTypeFilter.size.rleft;
|
||||
playersNumberFilter.size.rright = this.gameRatingFilter.size.rleft;
|
||||
}
|
||||
|
||||
onSelectionChange()
|
||||
|
|
|
|||
|
|
@ -49,32 +49,24 @@ class LobbyPage
|
|||
|
||||
setDialogStyle()
|
||||
{
|
||||
{
|
||||
const lobbyPage = Engine.GetGUIObjectByName("lobbyPage");
|
||||
lobbyPage.sprite = "ModernDialog";
|
||||
const lobbyPage = Engine.GetGUIObjectByName("lobbyPage");
|
||||
lobbyPage.sprite = "ModernDialog";
|
||||
lobbyPage.size = {
|
||||
"left": this.WindowMargin,
|
||||
"top": this.WindowMargin,
|
||||
"right": -this.WindowMargin,
|
||||
"bottom": -this.WindowMargin,
|
||||
"rleft": 0,
|
||||
"rtop": 0,
|
||||
"rright": 100,
|
||||
"rbottom": 100
|
||||
};
|
||||
|
||||
const size = lobbyPage.size;
|
||||
size.left = this.WindowMargin;
|
||||
size.top = this.WindowMargin;
|
||||
size.right = -this.WindowMargin;
|
||||
size.bottom = -this.WindowMargin;
|
||||
lobbyPage.size = size;
|
||||
}
|
||||
const lobbyPageTitle = Engine.GetGUIObjectByName("lobbyPageTitle");
|
||||
lobbyPageTitle.size.top -= this.WindowMargin / 2;
|
||||
lobbyPageTitle.size.bottom -= this.WindowMargin / 2;
|
||||
|
||||
{
|
||||
const lobbyPageTitle = Engine.GetGUIObjectByName("lobbyPageTitle");
|
||||
const size = lobbyPageTitle.size;
|
||||
size.top -= this.WindowMargin / 2;
|
||||
size.bottom -= this.WindowMargin / 2;
|
||||
lobbyPageTitle.size = size;
|
||||
}
|
||||
|
||||
{
|
||||
const lobbyPanels = Engine.GetGUIObjectByName("lobbyPanels");
|
||||
const size = lobbyPanels.size;
|
||||
size.top -= this.WindowMargin / 2;
|
||||
lobbyPanels.size = size;
|
||||
}
|
||||
Engine.GetGUIObjectByName("lobbyPanels").size.top -= this.WindowMargin / 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,10 +18,7 @@ class Subject
|
|||
xmppMessages.registerXmppMessageHandler("chat", "subject", this.onSubject.bind(this));
|
||||
gameList.registerSelectionChangeHandler(this.onGameListSelectionChange.bind(this));
|
||||
|
||||
const bottom = Engine.GetGUIObjectByName(dialog ? "leaveButton" : "hostButton").size.top - 5;
|
||||
const size = this.subjectPanel.size;
|
||||
size.bottom = bottom;
|
||||
this.subjectPanel.size = size;
|
||||
this.subjectPanel.size.bottom = Engine.GetGUIObjectByName(dialog ? "leaveButton" : "hostButton").size.top - 5;
|
||||
}
|
||||
|
||||
onGameListSelectionChange(game)
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@ class ProfilePage
|
|||
this.fetchInput = Engine.GetGUIObjectByName("fetchInput");
|
||||
this.fetchInputLabel = Engine.GetGUIObjectByName("fetchInputLabel");
|
||||
resizeGUIObjectToCaption(this.fetchInputLabel, { "horizontal": "right" });
|
||||
const size = this.fetchInput.size;
|
||||
size.left = this.fetchInputLabel.size.right;
|
||||
this.fetchInput.size = size;
|
||||
this.fetchInput.size.left = this.fetchInputLabel.size.right;
|
||||
|
||||
this.fetchInput.onPress = this.onPressLookup.bind(this);
|
||||
this.fetchInput.onTab = this.autocomplete.bind(this);
|
||||
|
|
|
|||
|
|
@ -16,18 +16,9 @@ MapBrowserPageControls.prototype.MapDescription = class
|
|||
const top = this.mapBrowserSelectedName.size.bottom;
|
||||
const height = Math.floor((computedSize.right - computedSize.left) / this.ImageRatio);
|
||||
|
||||
{
|
||||
const size = this.mapBrowserSelectedPreview.size;
|
||||
size.top = top;
|
||||
size.bottom = top + height;
|
||||
this.mapBrowserSelectedPreview.size = size;
|
||||
}
|
||||
|
||||
{
|
||||
const size = this.mapBrowserSelectedDescription.size;
|
||||
size.top = top + height + 10;
|
||||
this.mapBrowserSelectedDescription.size = size;
|
||||
}
|
||||
this.mapBrowserSelectedPreview.size.top = top;
|
||||
this.mapBrowserSelectedPreview.size.bottom = top + height;
|
||||
this.mapBrowserSelectedDescription.size.top = top + height + 10;
|
||||
|
||||
gridBrowser.registerSelectionChangeHandler(this.onSelectionChange.bind(this));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ class GridBrowserItem
|
|||
const gridBrowser = this.gridBrowser;
|
||||
const x = this.itemIndex % gridBrowser.columnCount;
|
||||
const y = Math.floor(this.itemIndex / gridBrowser.columnCount);
|
||||
const size = this.imageObject.size;
|
||||
size.left = gridBrowser.itemWidth * x;
|
||||
size.right = gridBrowser.itemWidth * (x + 1);
|
||||
size.top = gridBrowser.itemHeight * y;
|
||||
size.bottom = gridBrowser.itemHeight * (y + 1);
|
||||
this.imageObject.size = size;
|
||||
Object.assign(this.imageObject.size, {
|
||||
"left": gridBrowser.itemWidth * x,
|
||||
"top": gridBrowser.itemHeight * y,
|
||||
"right": gridBrowser.itemWidth * (x + 1),
|
||||
"bottom": gridBrowser.itemHeight * (y + 1)
|
||||
});
|
||||
this.updateVisibility();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,17 +21,8 @@ class LabelledControl
|
|||
resizeLabel()
|
||||
{
|
||||
const labelWidth = Engine.GetTextWidth(this.label.font, this.label.caption) + 15;
|
||||
|
||||
{
|
||||
const size = this.label.size;
|
||||
size.right = labelWidth;
|
||||
this.label.size = size;
|
||||
}
|
||||
{
|
||||
const size = this.control.size;
|
||||
size.left = labelWidth;
|
||||
this.control.size = size;
|
||||
}
|
||||
this.label.size.right = labelWidth;
|
||||
this.label.size.left = labelWidth;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -260,10 +260,8 @@ function displayOptions()
|
|||
{
|
||||
// Position vertically
|
||||
const body = Engine.GetGUIObjectByName("option_control[" + i + "]");
|
||||
const bodySize = body.size;
|
||||
bodySize.top = g_OptionControlOffset + i * (g_OptionControlHeight + g_OptionControlDist);
|
||||
bodySize.bottom = bodySize.top + g_OptionControlHeight;
|
||||
body.size = bodySize;
|
||||
body.size.top = g_OptionControlOffset + i * (g_OptionControlHeight + g_OptionControlDist);
|
||||
body.size.bottom = body.size.top + g_OptionControlHeight;
|
||||
body.hidden = false;
|
||||
|
||||
// Load option data
|
||||
|
|
@ -316,10 +314,8 @@ function displayOptions()
|
|||
label.tooltip = option.tooltip;
|
||||
label.hidden = false;
|
||||
|
||||
const labelSize = label.size;
|
||||
labelSize.left = option.dependencies ? g_DependentLabelIndentation : 0;
|
||||
labelSize.rright = control.size.rleft;
|
||||
label.size = labelSize;
|
||||
label.size.left = option.dependencies ? g_DependentLabelIndentation : 0;
|
||||
label.size.rright = control.size.rleft;
|
||||
}
|
||||
|
||||
enableButtons();
|
||||
|
|
|
|||
|
|
@ -22,20 +22,22 @@ class BackgroundLayer
|
|||
let left = offset % iw;
|
||||
if (left >= 0)
|
||||
left -= iw;
|
||||
this.background.size = new GUISize(
|
||||
left,
|
||||
backgroundsSize.top,
|
||||
backgroundsSize.right,
|
||||
backgroundsSize.bottom);
|
||||
this.background.size = {
|
||||
"left": left,
|
||||
"top": backgroundsSize.top,
|
||||
"right": backgroundsSize.right,
|
||||
"bottom": backgroundsSize.bottom
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
const right = backgroundsSize.right / 2 + offset;
|
||||
this.background.size = new GUISize(
|
||||
right - height,
|
||||
backgroundsSize.top,
|
||||
right + height,
|
||||
backgroundsSize.bottom);
|
||||
this.background.size = {
|
||||
"left": right - height,
|
||||
"top": backgroundsSize.top,
|
||||
"right": right + height,
|
||||
"bottom": backgroundsSize.bottom
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -58,7 +60,7 @@ class BackgroundHandler
|
|||
onWindowResized()
|
||||
{
|
||||
const size = this.backgrounds.getComputedSize();
|
||||
this.backgroundsSize = deepfreeze(new GUISize(size.top, size.left, size.right, size.bottom));
|
||||
this.backgroundsSize = { "left": size.top, "top": size.left, "right": size.right, "bottom": size.bottom };
|
||||
}
|
||||
|
||||
onTick()
|
||||
|
|
|
|||
|
|
@ -33,10 +33,11 @@ class MainMenuItemHandler
|
|||
if (button.hidden)
|
||||
return;
|
||||
|
||||
button.size = new GUISize(
|
||||
0, (this.ButtonHeight + this.Margin) * i,
|
||||
0, (this.ButtonHeight + this.Margin) * i + this.ButtonHeight,
|
||||
0, 0, 100, 0);
|
||||
button.size = {
|
||||
"top": (this.ButtonHeight + this.Margin) * i,
|
||||
"bottom": (this.ButtonHeight + this.Margin) * i + this.ButtonHeight,
|
||||
"rright": 100
|
||||
};
|
||||
button.caption = item.caption;
|
||||
button.tooltip = item.tooltip;
|
||||
button.enabled = item.enabled === undefined || item.enabled();
|
||||
|
|
@ -102,24 +103,18 @@ class MainMenuItemHandler
|
|||
|
||||
const top = this.mainMenuButtons.children[i].getComputedSize().top;
|
||||
|
||||
this.submenu.size = new GUISize(
|
||||
this.submenu.size.left, top - this.Margin,
|
||||
this.submenu.size.right, top + (this.ButtonHeight + this.Margin) * this.menuItems[i].submenu.length);
|
||||
this.submenu.size = {
|
||||
"left": this.submenu.size.left,
|
||||
"right": this.mainMenu.size.right,
|
||||
"top": top - this.Margin,
|
||||
"bottom": top + (this.ButtonHeight + this.Margin) * this.menuItems[i].submenu.length
|
||||
};
|
||||
|
||||
this.submenu.hidden = false;
|
||||
|
||||
{
|
||||
const size = this.MainMenuPanelRightBorderTop.size;
|
||||
size.bottom = this.submenu.size.top + this.Margin;
|
||||
size.rbottom = 0;
|
||||
this.MainMenuPanelRightBorderTop.size = size;
|
||||
}
|
||||
|
||||
{
|
||||
const size = this.MainMenuPanelRightBorderBottom.size;
|
||||
size.top = this.submenu.size.bottom;
|
||||
this.MainMenuPanelRightBorderBottom.size = size;
|
||||
}
|
||||
this.MainMenuPanelRightBorderTop.size.bottom = this.submenu.size.top + this.Margin;
|
||||
this.MainMenuPanelRightBorderTop.size.rbottom = 0;
|
||||
this.MainMenuPanelRightBorderBottom.size.top = this.submenu.size.bottom;
|
||||
|
||||
// Start animation
|
||||
this.lastTickTime = Date.now();
|
||||
|
|
@ -131,11 +126,11 @@ class MainMenuItemHandler
|
|||
this.submenu.hidden = true;
|
||||
this.submenu.size = this.mainMenu.size;
|
||||
|
||||
const size = this.MainMenuPanelRightBorderTop.size;
|
||||
size.top = 0;
|
||||
size.bottom = 0;
|
||||
size.rbottom = 100;
|
||||
this.MainMenuPanelRightBorderTop.size = size;
|
||||
Object.assign(this.MainMenuPanelRightBorderTop.size, {
|
||||
"top": 0,
|
||||
"bottom": 0,
|
||||
"rbottom": 100
|
||||
});
|
||||
}
|
||||
|
||||
onTick()
|
||||
|
|
@ -155,10 +150,8 @@ class MainMenuItemHandler
|
|||
return;
|
||||
}
|
||||
|
||||
const size = this.submenu.size;
|
||||
size.left += offset;
|
||||
size.right += offset;
|
||||
this.submenu.size = size;
|
||||
this.submenu.size.left += offset;
|
||||
this.submenu.size.right += offset;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,10 +47,8 @@ function initLobbyTerms()
|
|||
openTerms(page);
|
||||
};
|
||||
|
||||
const size = button.size;
|
||||
size.top = i * g_TermsButtonHeight;
|
||||
size.bottom = i * g_TermsButtonHeight + 28;
|
||||
button.size = size;
|
||||
button.size.top = i * g_TermsButtonHeight;
|
||||
button.size.bottom = i * g_TermsButtonHeight + 28;
|
||||
});
|
||||
|
||||
initTerms(terms);
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@ class Emblem
|
|||
|
||||
setPosition(x, y)
|
||||
{
|
||||
const size = this.Emblem.size;
|
||||
size.left = x - this.cx;
|
||||
size.right = x + this.cx;
|
||||
size.top = y - this.cy;
|
||||
size.bottom = y + this.cy;
|
||||
this.Emblem.size = size;
|
||||
Object.assign(this.Emblem.size, {
|
||||
"left": x - this.cx,
|
||||
"top": y - this.cy,
|
||||
"right": x + this.cx,
|
||||
"bottom": y + this.cy
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,12 +42,10 @@ class ProductionRow
|
|||
const rowOffset = IconSize.rowHeight * (this.phaseOffset - this.rowIndex);
|
||||
const rowWidth = this.productionIconsDrawn * IconSize.rowWidth + IconSize.hMargin;
|
||||
|
||||
const size = this.productionRow.size;
|
||||
size.left = -rowWidth / 2;
|
||||
size.top = -rowOffset;
|
||||
this.productionRow.size = size;
|
||||
|
||||
this.productionRow.size.left = -rowWidth / 2;
|
||||
this.productionRow.size.top = -rowOffset;
|
||||
this.productionRow.hidden = false;
|
||||
|
||||
return rowWidth;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,12 +24,10 @@ class StructureBox extends EntityBox
|
|||
const boxWidth = Math.max(this.MinWidth, this.captionWidth(), this.ProductionRows.width);
|
||||
|
||||
// Set position of the Structure Box
|
||||
const size = this.gui.size;
|
||||
size.left = this.HMargin + runningWidths[this.phaseIdx];
|
||||
size.right = this.HMargin + runningWidths[this.phaseIdx] + boxWidth;
|
||||
size.top = TreeSection.getPositionOffset(this.phaseIdx, this.page.TemplateParser);
|
||||
size.bottom = TreeSection.getPositionOffset(this.phaseIdx + 1, this.page.TemplateParser) - this.VMargin;
|
||||
this.gui.size = size;
|
||||
Object.assign(this.gui.size, {
|
||||
"left": this.HMargin + runningWidths[this.phaseIdx], "top": TreeSection.getPositionOffset(this.phaseIdx, this.page.TemplateParser),
|
||||
"right": this.HMargin + runningWidths[this.phaseIdx] + boxWidth, "bottom": TreeSection.getPositionOffset(this.phaseIdx + 1, this.page.TemplateParser) - this.VMargin
|
||||
});
|
||||
|
||||
// Update new right-side-edge dimension
|
||||
runningWidths[this.phaseIdx] += boxWidth + this.HMargin / 2;
|
||||
|
|
|
|||
|
|
@ -13,21 +13,19 @@ class TrainerBox extends EntityBox
|
|||
this.ProductionRows = new ProductionRowManager(this.page, "trainer[" + trainerIdx + "]_productionRows", false);
|
||||
|
||||
const rowHeight = ProductionIcon.Size().rowHeight;
|
||||
const size = this.gui.size;
|
||||
|
||||
// Adjust height to accommodate production row
|
||||
size.bottom += rowHeight;
|
||||
this.gui.size.bottom += rowHeight;
|
||||
|
||||
// We make the assumuption that all trainer boxes have the same height
|
||||
const boxHeight = (this.VMargin / 2 + (size.bottom - size.top + this.VMargin)) * trainerIdx;
|
||||
size.top += boxHeight;
|
||||
size.bottom += boxHeight;
|
||||
|
||||
// Make the box adjust automatically to column width
|
||||
size.rright = 100;
|
||||
size.right = -size.left;
|
||||
|
||||
this.gui.size = size;
|
||||
const boxHeight = (this.VMargin / 2 + (this.gui.size.bottom - this.gui.size.top + this.VMargin)) * trainerIdx;
|
||||
Object.assign(this.gui.size, {
|
||||
"top": this.gui.size.top + boxHeight,
|
||||
"bottom": this.gui.size.bottom + boxHeight,
|
||||
// Make the box adjust automatically to column width
|
||||
"rright": 100,
|
||||
"right": -this.gui.size.left,
|
||||
});
|
||||
}
|
||||
|
||||
draw(templateName, civCode)
|
||||
|
|
|
|||
|
|
@ -50,10 +50,8 @@ class TrainerSection
|
|||
hideRemaining(this.Trainers.name, count);
|
||||
|
||||
// Update width and visibility of section
|
||||
const size = this.TrainerSection.size;
|
||||
this.width += EntityBox.prototype.HMargin;
|
||||
size.left = -this.width + size.right;
|
||||
this.TrainerSection.size = size;
|
||||
this.TrainerSection.size.left = -this.width + this.TrainerSection.size.right;
|
||||
this.TrainerSection.hidden = count == 0;
|
||||
|
||||
for (const handler of this.widthChangedHandlers)
|
||||
|
|
|
|||
|
|
@ -13,20 +13,19 @@ class PhaseIdent
|
|||
const entityBoxHeight = EntityBox.IconAndCaptionHeight();
|
||||
for (let i = 0; i < this.Bars.children.length; ++i)
|
||||
{
|
||||
const size = this.Bars.children[i].size;
|
||||
size.top = entityBoxHeight + prodIconSize.rowHeight * (i + 1);
|
||||
size.bottom = entityBoxHeight + prodIconSize.rowHeight * (i + 2) - prodIconSize.rowGap;
|
||||
this.Bars.children[i].size = size;
|
||||
const bar = this.Bars.children[i];
|
||||
bar.size = {
|
||||
"top": entityBoxHeight + prodIconSize.rowHeight * (i + 1),
|
||||
"bottom": entityBoxHeight + prodIconSize.rowHeight * (i + 2) - prodIconSize.rowGap
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
draw(phaseList, civCode)
|
||||
{
|
||||
// Position ident
|
||||
const identSize = this.Ident.size;
|
||||
identSize.top = TreeSection.getPositionOffset(this.phaseIdx, this.page.TemplateParser);
|
||||
identSize.bottom = TreeSection.getPositionOffset(this.phaseIdx + 1, this.page.TemplateParser);
|
||||
this.Ident.size = identSize;
|
||||
this.Ident.size.top = TreeSection.getPositionOffset(this.phaseIdx, this.page.TemplateParser);
|
||||
this.Ident.size.bottom = TreeSection.getPositionOffset(this.phaseIdx + 1, this.page.TemplateParser);
|
||||
this.Ident.hidden = false;
|
||||
|
||||
// Draw main icon
|
||||
|
|
|
|||
|
|
@ -50,11 +50,9 @@ class TreeSection
|
|||
|
||||
onTrainerSectionWidthChange(trainerSectionWidth, trainerSectionVisible)
|
||||
{
|
||||
const size = this.TreeSection.size;
|
||||
size.right = this.rightMargin;
|
||||
this.TreeSection.size.right = this.rightMargin;
|
||||
if (trainerSectionVisible)
|
||||
size.right -= trainerSectionWidth + this.page.SectionGap;
|
||||
this.TreeSection.size = size;
|
||||
this.TreeSection.size.right -= trainerSectionWidth + this.page.SectionGap;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -158,20 +158,18 @@ class TipDisplay
|
|||
|
||||
scaleGuiElementsToFit()
|
||||
{
|
||||
const titleSize = this.tipTitle.size;
|
||||
const titleTextSize = this.tipTitle.getTextSize();
|
||||
this.tipTitle.size.bottom = this.tipTitle.size.top + titleTextSize.height;
|
||||
|
||||
titleSize.bottom = titleSize.top + titleTextSize.height;
|
||||
this.tipTitle.size = titleSize;
|
||||
Object.assign(this.tipTitleDecoration.size, {
|
||||
"left": -(titleTextSize.width / 2 + 12),
|
||||
"top": this.tipTitle.size.bottom - 4,
|
||||
"right": titleTextSize.width / 2 + 12,
|
||||
"bottom": this.tipTitle.size.bottom + 12,
|
||||
"rleft": 50, "rtop": 0, "rright": 50, "rbottom": 0
|
||||
});
|
||||
|
||||
this.tipTitleDecoration.size = new GUISize(
|
||||
-(titleTextSize.width / 2 + 12), this.tipTitle.size.bottom - 4, titleTextSize.width / 2 + 12, this.tipTitle.size.bottom + 12,
|
||||
50, 0, 50, 0
|
||||
);
|
||||
|
||||
const textSize = this.tipText.size;
|
||||
textSize.top = this.tipTitleDecoration.size.bottom + 16;
|
||||
this.tipText.size = textSize;
|
||||
this.tipText.size.top = this.tipTitleDecoration.size.bottom + 16;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,10 +126,8 @@ class ViewerPage extends ReferencePage
|
|||
const entityStats = this.guiElements.entityStats;
|
||||
entityStats.caption = this.constructor.buildText(this.currentTemplate, this.StatsFunctions);
|
||||
|
||||
const infoSize = this.guiElements.entityInfo.size;
|
||||
const infoTopMargin = 8;
|
||||
infoSize.top = Math.max(entityIcon.size.bottom + infoTopMargin, entityStats.size.top + entityStats.getTextSize().height + infoTopMargin);
|
||||
this.guiElements.entityInfo.size = infoSize;
|
||||
this.guiElements.entityInfo.size.top = Math.max(entityIcon.size.bottom + infoTopMargin, entityStats.size.top + entityStats.getTextSize().height + infoTopMargin);
|
||||
|
||||
this.guiElements.entityInfo.caption = this.constructor.buildText(this.currentTemplate, this.InfoFunctions, "\n\n");
|
||||
|
||||
|
|
|
|||
|
|
@ -30,10 +30,8 @@ class Menu
|
|||
});
|
||||
|
||||
this.endPosition = this.margin + this.buttonHeight * (1 + handlerNames.length);
|
||||
const size = this.menuButtonPanel.size;
|
||||
size.top = -this.endPosition;
|
||||
size.bottom = 0;
|
||||
this.menuButtonPanel.size = size;
|
||||
this.menuButtonPanel.size.top = -this.endPosition;
|
||||
this.menuButtonPanel.size.bottom = 0;
|
||||
}
|
||||
|
||||
rebuild()
|
||||
|
|
@ -69,12 +67,8 @@ class Menu
|
|||
this.close();
|
||||
handler.onPress();
|
||||
};
|
||||
|
||||
const size = button.size;
|
||||
size.top = this.buttonHeight * (i + 1) + this.margin;
|
||||
size.bottom = this.buttonHeight * (i + 2);
|
||||
button.size = size;
|
||||
|
||||
button.size.top = this.buttonHeight * (i + 1) + this.margin;
|
||||
button.size.bottom = this.buttonHeight * (i + 2);
|
||||
button.hidden = false;
|
||||
}
|
||||
|
||||
|
|
@ -106,10 +100,8 @@ class Menu
|
|||
}
|
||||
|
||||
const offset = Math.min(this.Speed * tickLength, maxOffset) * (this.isOpen ? +1 : -1);
|
||||
const size = this.menuButtonPanel.size;
|
||||
size.top += offset;
|
||||
size.bottom += offset;
|
||||
this.menuButtonPanel.size = size;
|
||||
this.menuButtonPanel.size.top += offset;
|
||||
this.menuButtonPanel.size.bottom += offset;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,11 +75,8 @@ class PanelEntity
|
|||
return;
|
||||
|
||||
if (this.hitpoints != entityState.hitpoints)
|
||||
{
|
||||
const size = this.panelEntityHealthBar.size;
|
||||
size.rright = 100 * entityState.hitpoints / entityState.maxHitpoints;
|
||||
this.panelEntityHealthBar.size = size;
|
||||
}
|
||||
this.panelEntityHealthBar.size.rright = 100 * entityState.hitpoints / entityState.maxHitpoints;
|
||||
|
||||
if (entityState.hitpoints < this.hitpoints)
|
||||
this.onAttacked();
|
||||
this.hitpoints = entityState.hitpoints;
|
||||
|
|
@ -93,13 +90,11 @@ class PanelEntity
|
|||
const playerParts = this.panelEntityCaptureBar.children;
|
||||
const setCaptureBarPart = function(player, startSize) {
|
||||
const captureBar = playerParts[player];
|
||||
const size = captureBar.size;
|
||||
size.rleft = startSize;
|
||||
size.rright = startSize + 100 * Math.max(0, Math.min(1, entityState.capturePoints[player] / entityState.maxCapturePoints));
|
||||
captureBar.size = size;
|
||||
captureBar.size.rleft = startSize;
|
||||
captureBar.size.rright = startSize + 100 * Math.max(0, Math.min(1, entityState.capturePoints[player] / entityState.maxCapturePoints));
|
||||
captureBar.sprite = "color:" + g_DiplomacyColors.getPlayerColor(player, 128);
|
||||
captureBar.hidden = false;
|
||||
return size.rright;
|
||||
return captureBar.size.rright;
|
||||
};
|
||||
|
||||
let size = setCaptureBarPart(entityState.player, 0);
|
||||
|
|
|
|||
|
|
@ -29,18 +29,15 @@ class ResearchProgressButton
|
|||
modifier += "color:0 0 0 127:grayscale:";
|
||||
this.sprite.sprite = modifier + this.PortraitDirectory + template.icon;
|
||||
|
||||
let size = this.button.size;
|
||||
size.top = offset + this.buttonTop;
|
||||
size.bottom = size.top + this.buttonHeight;
|
||||
this.button.size = size;
|
||||
this.button.size.top = offset + this.buttonTop;
|
||||
this.button.size.bottom = this.button.size.top + this.buttonHeight;
|
||||
|
||||
this.button.tooltip = getEntityNames(template);
|
||||
if (researchStatus.paused)
|
||||
this.button.tooltip += "\n" + translate(this.PausedResearchString);
|
||||
this.button.hidden = false;
|
||||
|
||||
size = this.progress.size;
|
||||
size.top = this.progressTop + this.progressHeight * researchStatus.progress;
|
||||
this.progress.size = size;
|
||||
this.progress.size.top = this.progressTop + this.progressHeight * researchStatus.progress;
|
||||
|
||||
this.timeRemaining.caption =
|
||||
Engine.FormatMillisecondsIntoDateStringGMT(
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ class ChatHistory
|
|||
this.chatHistoryFilter.selected = 0;
|
||||
this.chatHistoryFilter.onSelectionChange = this.onSelectionChange.bind(this);
|
||||
|
||||
const chatHistoryFilterSize = this.chatHistoryFilter.size;
|
||||
chatHistoryFilterSize.left = this.chatHistoryFilterCaption.size.right + this.FilterMargin;
|
||||
this.chatHistoryFilter.size = chatHistoryFilterSize;
|
||||
this.chatHistoryFilter.size.left = this.chatHistoryFilterCaption.size.right + this.FilterMargin;
|
||||
|
||||
this.chatHistoryText = Engine.GetGUIObjectByName("chatHistoryText");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,19 +38,18 @@ class ChatOverlay
|
|||
if (chatMessage && chatMessage.text)
|
||||
{
|
||||
// First scale line width to maximum size.
|
||||
const lineSize = this.chatLines[i].size;
|
||||
const height = lineSize.bottom - lineSize.top;
|
||||
lineSize.top = i * height;
|
||||
lineSize.bottom = lineSize.top + height;
|
||||
lineSize.rright = 100;
|
||||
this.chatLines[i].size = lineSize;
|
||||
const height = this.chatLines[i].size.bottom - this.chatLines[i].size.top;
|
||||
Object.assign(this.chatLines[i].size, {
|
||||
"top": i * height,
|
||||
"bottom": (i + 1) * height,
|
||||
"rright": 100
|
||||
});
|
||||
|
||||
this.chatLines[i].caption = chatMessage.text;
|
||||
|
||||
// Now read the actual text width and scale the line width accordingly.
|
||||
lineSize.rright = 0;
|
||||
lineSize.right = lineSize.left + this.chatLines[i].getTextSize().width;
|
||||
this.chatLines[i].size = lineSize;
|
||||
this.chatLines[i].size.rright = 0;
|
||||
this.chatLines[i].size.right = this.chatLines[i].size.left + this.chatLines[i].getTextSize().width;
|
||||
|
||||
if (chatMessage.callback)
|
||||
this.chatLines[i].onPress = chatMessage.callback;
|
||||
|
|
|
|||
|
|
@ -84,10 +84,8 @@ class ChatWindow
|
|||
const chatHistoryTextSize = this.chatHistoryText.getComputedSize();
|
||||
const width = this.aspectRatio * (chatHistoryTextSize.bottom - chatHistoryTextSize.top);
|
||||
|
||||
const size = this.chatDialogPanel.size;
|
||||
size.left = -width / 2 - this.chatHistoryText.size.left;
|
||||
size.right = width / 2 + this.chatHistoryText.size.left;
|
||||
this.chatDialogPanel.size = size;
|
||||
this.chatDialogPanel.size.left = -width / 2 - this.chatHistoryText.size.left;
|
||||
this.chatDialogPanel.size.right = width / 2 + this.chatHistoryText.size.left;
|
||||
}
|
||||
else
|
||||
this.chatDialogPanel.size = this.chatDialogPanelSmallSize;
|
||||
|
|
|
|||
|
|
@ -68,12 +68,10 @@ class DeveloperOverlay
|
|||
|
||||
resize()
|
||||
{
|
||||
const size = this.devCommandsOverlay.size;
|
||||
size.bottom =
|
||||
size.top +
|
||||
this.devCommandsOverlay.size.bottom =
|
||||
this.devCommandsOverlay.size.top +
|
||||
this.checkBoxes.reduce((height, checkbox) => height + checkbox.getHeight(), 0) +
|
||||
this.dropDowns.reduce((height, dropDown) => height + dropDown.getHeight(), 0);
|
||||
this.devCommandsOverlay.size = size;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,11 +24,10 @@ class DeveloperOverlayControl
|
|||
|
||||
resize(i)
|
||||
{
|
||||
const size = this.body.size;
|
||||
const height = size.bottom;
|
||||
size.top = height * i;
|
||||
size.bottom = height * (i + 1);
|
||||
this.body.size = size;
|
||||
const height = this.body.size.bottom;
|
||||
this.body.size.top = height * i;
|
||||
this.body.size.bottom = height * (i + 1);
|
||||
|
||||
this.body.hidden = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,11 +85,9 @@ class DiplomacyDialog
|
|||
const widthOffset = DiplomacyDialogPlayerControl.prototype.TributeButtonManager.getWidthOffset() / 2;
|
||||
const heightOffset = DiplomacyDialogPlayerControl.prototype.DiplomacyPlayerText.getHeightOffset() / 2;
|
||||
|
||||
const size = this.diplomacyDialogPanel.size;
|
||||
size.left -= widthOffset;
|
||||
size.right += widthOffset;
|
||||
size.top -= heightOffset;
|
||||
size.bottom += heightOffset;
|
||||
this.diplomacyDialogPanel.size = size;
|
||||
this.diplomacyDialogPanel.size.left -= widthOffset;
|
||||
this.diplomacyDialogPanel.size.right += widthOffset;
|
||||
this.diplomacyDialogPanel.size.top -= heightOffset;
|
||||
this.diplomacyDialogPanel.size.bottom += heightOffset;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,10 +30,8 @@ DiplomacyDialogPlayerControl.prototype.DiplomacyPlayerText = class
|
|||
|
||||
// Apply offset
|
||||
const rowSize = DiplomacyDialogPlayerControl.prototype.DiplomacyPlayerText.getRowHeight();
|
||||
const size = this.diplomacyPlayer.size;
|
||||
size.top = rowSize * (this.playerID - 1);
|
||||
size.bottom = rowSize * this.playerID;
|
||||
this.diplomacyPlayer.size = size;
|
||||
this.diplomacyPlayer.size.top = rowSize * (this.playerID - 1);
|
||||
this.diplomacyPlayer.size.bottom = rowSize * this.playerID;
|
||||
this.diplomacyPlayer.hidden = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -413,7 +413,12 @@ function updateBandbox(bandbox, ev, hidden)
|
|||
const vMin = Vector2D.min(g_DragStart, ev);
|
||||
const vMax = Vector2D.max(g_DragStart, ev);
|
||||
|
||||
bandbox.size = new GUISize(vMin.x / scale, vMin.y / scale, vMax.x / scale, vMax.y / scale);
|
||||
bandbox.size = {
|
||||
"left": vMin.x / scale,
|
||||
"top": vMin.y / scale,
|
||||
"right": vMax.x / scale,
|
||||
"bottom": vMax.y / scale
|
||||
};
|
||||
bandbox.hidden = hidden;
|
||||
|
||||
return [vMin.x, vMin.y, vMax.x, vMax.y];
|
||||
|
|
|
|||
|
|
@ -52,8 +52,6 @@ class MatchSettingsDialog
|
|||
this.matchSettingsPlayerstate.hidden = isActive;
|
||||
this.matchSettingsPlayerstate.caption = g_PlayerStateMessages[playerState] || "";
|
||||
|
||||
const size = this.gameDescription.size;
|
||||
size.top = (isActive ? this.matchSettingsTitle : this.matchSettingsPlayerstate).size.bottom;
|
||||
this.gameDescription.size = size;
|
||||
this.gameDescription.size.top = (isActive ? this.objectivesTitle : this.objectivesPlayerstate).size.bottom;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,10 +37,7 @@ function updateGarrisonHealthBar(entState, selection)
|
|||
if (totalGarrisonHealth > 0)
|
||||
{
|
||||
const healthBarGarrison = Engine.GetGUIObjectByName("healthBarGarrison");
|
||||
const healthSize = healthBarGarrison.size;
|
||||
healthSize.rtop = 100 - 100 * Math.max(0, Math.min(1, totalGarrisonHealth / maxGarrisonHealth));
|
||||
healthBarGarrison.size = healthSize;
|
||||
|
||||
healthBarGarrison.size.rtop = 100 - 100 * Math.max(0, Math.min(1, totalGarrisonHealth / maxGarrisonHealth));
|
||||
healthGarrison.tooltip = getCurrentHealthTooltip({
|
||||
"hitpoints": totalGarrisonHealth,
|
||||
"maxHitpoints": maxGarrisonHealth
|
||||
|
|
@ -105,10 +102,8 @@ function displaySingle(entState)
|
|||
statusIcons[i].hidden = false;
|
||||
statusIcons[i].sprite = "stretched:session/icons/status_effects/" + g_StatusEffectsMetadata.getIcon(effect.baseCode) + ".png";
|
||||
statusIcons[i].tooltip = getStatusEffectsTooltip(effect.baseCode, effect, false);
|
||||
const size = statusIcons[i].size;
|
||||
size.top = i * 18;
|
||||
size.bottom = i * 18 + 16;
|
||||
statusIcons[i].size = size;
|
||||
statusIcons[i].size.top = i * 18;
|
||||
statusIcons[i].size.bottom = i * 18 + 16;
|
||||
|
||||
if (++i >= statusIcons.length)
|
||||
break;
|
||||
|
|
@ -134,10 +129,7 @@ function displaySingle(entState)
|
|||
healthSection.hidden = !showHealth;
|
||||
if (showHealth)
|
||||
{
|
||||
const unitHealthBar = Engine.GetGUIObjectByName("healthBar");
|
||||
const healthSize = unitHealthBar.size;
|
||||
healthSize.rright = 100 * Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints));
|
||||
unitHealthBar.size = healthSize;
|
||||
Engine.GetGUIObjectByName("healthBar").size.rright = 100 * Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints));
|
||||
Engine.GetGUIObjectByName("healthStats").caption = sprintf(translate("%(hitpoints)s / %(maxHitpoints)s"), {
|
||||
"hitpoints": Math.ceil(entState.hitpoints),
|
||||
"maxHitpoints": Math.ceil(entState.maxHitpoints)
|
||||
|
|
@ -161,15 +153,14 @@ function displaySingle(entState)
|
|||
{
|
||||
const setCaptureBarPart = function(playerID, startSize) {
|
||||
const unitCaptureBar = Engine.GetGUIObjectByName("captureBar[" + playerID + "]");
|
||||
const sizeObj = unitCaptureBar.size;
|
||||
sizeObj.rleft = startSize;
|
||||
|
||||
const size = 100 * Math.max(0, Math.min(1, entState.capturePoints[playerID] / entState.maxCapturePoints));
|
||||
sizeObj.rright = startSize + size;
|
||||
unitCaptureBar.size = sizeObj;
|
||||
const width = 100 * Math.max(0, Math.min(1, entState.capturePoints[playerID] / entState.maxCapturePoints));
|
||||
unitCaptureBar.size.rleft = startSize;
|
||||
unitCaptureBar.size.rright = startSize + width;
|
||||
|
||||
unitCaptureBar.sprite = "color:" + g_DiplomacyColors.getPlayerColor(playerID, 128);
|
||||
unitCaptureBar.hidden = false;
|
||||
return startSize + size;
|
||||
return startSize + width;
|
||||
};
|
||||
|
||||
// first handle the owner's points, to keep those points on the left for clarity
|
||||
|
|
@ -193,10 +184,7 @@ function displaySingle(entState)
|
|||
Engine.GetGUIObjectByName("experience").hidden = !entState.promotion;
|
||||
if (entState.promotion)
|
||||
{
|
||||
const experienceBar = Engine.GetGUIObjectByName("experienceBar");
|
||||
const experienceSize = experienceBar.size;
|
||||
experienceSize.rtop = 100 - (100 * Math.max(0, Math.min(1, 1.0 * +entState.promotion.curr / (+entState.promotion.req || 1))));
|
||||
experienceBar.size = experienceSize;
|
||||
Engine.GetGUIObjectByName("experienceBar").size.rtop = 100 - (100 * Math.max(0, Math.min(1, 1.0 * +entState.promotion.curr / (+entState.promotion.req || 1))));
|
||||
|
||||
if (entState.promotion.curr < entState.promotion.req)
|
||||
Engine.GetGUIObjectByName("experience").tooltip = sprintf(translate("%(experience)s %(current)s / %(required)s"), {
|
||||
|
|
@ -221,12 +209,8 @@ function displaySingle(entState)
|
|||
"max": entState.resourceSupply.max
|
||||
});
|
||||
|
||||
const unitResourceBar = Engine.GetGUIObjectByName("resourceBar");
|
||||
const resourceSize = unitResourceBar.size;
|
||||
|
||||
resourceSize.rright = entState.resourceSupply.isInfinite ? 100 :
|
||||
Engine.GetGUIObjectByName("resourceBar").size.rright = entState.resourceSupply.isInfinite ? 100 :
|
||||
100 * Math.max(0, Math.min(1, +entState.resourceSupply.amount / +entState.resourceSupply.max));
|
||||
unitResourceBar.size = resourceSize;
|
||||
|
||||
Engine.GetGUIObjectByName("resourceLabel").caption = sprintf(translate("%(resource)s:"), {
|
||||
"resource": resourceNameFirstWord(entState.resourceSupply.type.generic)
|
||||
|
|
@ -306,9 +290,7 @@ function displaySingle(entState)
|
|||
|
||||
const primaryObject = Engine.GetGUIObjectByName("primary");
|
||||
primaryObject.caption = primaryName;
|
||||
const primaryObjectSize = primaryObject.size;
|
||||
primaryObjectSize.rbottom = hideSecondary ? 100 : 50;
|
||||
primaryObject.size = primaryObjectSize;
|
||||
primaryObject.size.rbottom = hideSecondary ? 100 : 50;
|
||||
|
||||
const secondaryObject = Engine.GetGUIObjectByName("secondary");
|
||||
secondaryObject.caption = hideSecondary ? "" :
|
||||
|
|
@ -450,10 +432,7 @@ function displayMultiple(entStates)
|
|||
Engine.GetGUIObjectByName("healthMultiple").hidden = averageHealth <= 0;
|
||||
if (averageHealth > 0)
|
||||
{
|
||||
const unitHealthBar = Engine.GetGUIObjectByName("healthBarMultiple");
|
||||
const healthSize = unitHealthBar.size;
|
||||
healthSize.rtop = 100 - 100 * Math.max(0, Math.min(1, averageHealth / maxHealth));
|
||||
unitHealthBar.size = healthSize;
|
||||
Engine.GetGUIObjectByName("healthBarMultiple").size.rtop = 100 - 100 * Math.max(0, Math.min(1, averageHealth / maxHealth));
|
||||
|
||||
Engine.GetGUIObjectByName("healthMultiple").tooltip = getCurrentHealthTooltip({
|
||||
"hitpoints": averageHealth,
|
||||
|
|
@ -467,15 +446,14 @@ function displayMultiple(entStates)
|
|||
const setCaptureBarPart = function(pID, startSize)
|
||||
{
|
||||
const unitCaptureBar = Engine.GetGUIObjectByName("captureBarMultiple[" + pID + "]");
|
||||
const sizeObj = unitCaptureBar.size;
|
||||
sizeObj.rtop = startSize;
|
||||
|
||||
const size = 100 * Math.max(0, Math.min(1, capturePoints[pID] / maxCapturePoints));
|
||||
sizeObj.rbottom = startSize + size;
|
||||
unitCaptureBar.size = sizeObj;
|
||||
const height = 100 * Math.max(0, Math.min(1, capturePoints[pID] / maxCapturePoints));
|
||||
unitCaptureBar.size.rtop = startSize;
|
||||
unitCaptureBar.size.rbottom = startSize + height;
|
||||
|
||||
unitCaptureBar.sprite = "color:" + g_DiplomacyColors.getPlayerColor(pID, 128);
|
||||
unitCaptureBar.hidden = false;
|
||||
return startSize + size;
|
||||
return startSize + height;
|
||||
};
|
||||
|
||||
let size = 0;
|
||||
|
|
|
|||
|
|
@ -154,14 +154,16 @@ g_SelectionPanels.Command = {
|
|||
|
||||
data.icon.sprite = "stretched:session/icons/" + data.item.icon;
|
||||
|
||||
const size = data.button.size;
|
||||
// relative to the center ( = 50%)
|
||||
size.rleft = 50;
|
||||
size.rright = 50;
|
||||
// offset from the center calculation, count on square buttons, so size.bottom is the width too
|
||||
size.left = (data.i - data.numberOfItems / 2) * (size.bottom + 1);
|
||||
size.right = size.left + size.bottom;
|
||||
data.button.size = size;
|
||||
const left = (data.i - data.numberOfItems / 2) * (data.button.size.bottom + 1);
|
||||
Object.assign(data.button.size, {
|
||||
// relative to the center ( = 50%)
|
||||
"rleft": 50,
|
||||
"rright": 50,
|
||||
// offset from the center calculation, count on square buttons, so size.bottom is the width too
|
||||
"left": left,
|
||||
"right": left + data.button.size.bottom
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
@ -548,11 +550,9 @@ g_SelectionPanels.Queue = {
|
|||
{
|
||||
const numRows = Math.ceil(numberOfItems / rowLength);
|
||||
const panel = Engine.GetGUIObjectByName("unitQueuePanel");
|
||||
const size = panel.size;
|
||||
const buttonSize = Engine.GetGUIObjectByName("unitQueueButton[0]").size.bottom;
|
||||
const margin = 4;
|
||||
size.top = size.bottom - numRows * buttonSize - (numRows + 2) * margin;
|
||||
panel.size = size;
|
||||
panel.size.top = panel.size.bottom - numRows * buttonSize - (numRows + 2) * margin;
|
||||
},
|
||||
"setupButton": function(data)
|
||||
{
|
||||
|
|
@ -591,12 +591,10 @@ g_SelectionPanels.Queue = {
|
|||
if (data.item.ghost)
|
||||
{
|
||||
data.button.enabled = false;
|
||||
progressSlider.sprite="color:0 150 250 50";
|
||||
const size = progressSlider.size;
|
||||
progressSlider.sprite = "color:0 150 250 50";
|
||||
|
||||
// Buttons are assumed to be square, so left/right offsets can be used for top/bottom.
|
||||
size.top = size.left;
|
||||
progressSlider.size = size;
|
||||
progressSlider.size.top = progressSlider.size.left;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -606,11 +604,9 @@ g_SelectionPanels.Queue = {
|
|||
Engine.FormatMillisecondsIntoDateStringGMT(queuedItem.timeRemaining, translateWithContext("countdown format", "m:ss"));
|
||||
|
||||
progressSlider.sprite = "queueProgressSlider";
|
||||
const size = progressSlider.size;
|
||||
|
||||
// Buttons are assumed to be square, so left/right offsets can be used for top/bottom.
|
||||
size.top = size.left + Math.round(queuedItem.progress * (size.right - size.left));
|
||||
progressSlider.size = size;
|
||||
progressSlider.size.top = progressSlider.size.left + Math.round(queuedItem.progress * (progressSlider.size.right - progressSlider.size.left));
|
||||
|
||||
data.button.enabled = controlsPlayer(data.player);
|
||||
|
||||
|
|
@ -1220,10 +1216,9 @@ g_SelectionPanels.Upgrade = {
|
|||
let progress = 0;
|
||||
for (const state of upgradingEntStates)
|
||||
progress = Math.max(progress, state.upgrade.progress || 1);
|
||||
const progressOverlaySize = progressOverlay.size;
|
||||
|
||||
// TODO This is bad: we assume the progressOverlay is square
|
||||
progressOverlaySize.top = progressOverlaySize.bottom + Math.round((1 - progress) * (progressOverlaySize.left - progressOverlaySize.right));
|
||||
progressOverlay.size = progressOverlaySize;
|
||||
progressOverlay.size.top = progressOverlay.size.bottom + Math.round((1 - progress) * (progressOverlay.size.left - progressOverlay.size.right));
|
||||
progressOverlay.hidden = false;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -720,15 +720,8 @@ function updateCinemaOverlay()
|
|||
if (barHeight < 0)
|
||||
barHeight = 0;
|
||||
|
||||
const cinemaBarTop = Engine.GetGUIObjectByName("cinemaBarTop");
|
||||
const cinemaBarTopSize = cinemaBarTop.size;
|
||||
cinemaBarTopSize.bottom = barHeight;
|
||||
cinemaBarTop.size = cinemaBarTopSize;
|
||||
|
||||
const cinemaBarBottom = Engine.GetGUIObjectByName("cinemaBarBottom");
|
||||
const cinemaBarBottomSize = cinemaBarBottom.size;
|
||||
cinemaBarBottomSize.top = -barHeight;
|
||||
cinemaBarBottom.size = cinemaBarBottomSize;
|
||||
Engine.GetGUIObjectByName("cinemaBarTop").size.bottom = barHeight;
|
||||
Engine.GetGUIObjectByName("cinemaBarBottom").size.top = -barHeight;
|
||||
}
|
||||
|
||||
// TODO: Use event subscription onSimulationUpdate, onEntitySelectionChange, onPlayerViewChange, ... instead
|
||||
|
|
|
|||
|
|
@ -70,14 +70,11 @@ class TradeDialog
|
|||
|
||||
onPlayersInit()
|
||||
{
|
||||
const size = this.tradeDialogPanel.size;
|
||||
|
||||
const width = 1/2 * Math.max(
|
||||
TradeDialog.prototype.BarterPanel.getWidthOffset(),
|
||||
TradeDialog.prototype.TradePanel.getWidthOffset());
|
||||
|
||||
size.left -= width;
|
||||
size.right += width;
|
||||
this.tradeDialogPanel.size = size;
|
||||
this.tradeDialogPanel.size.left -= width;
|
||||
this.tradeDialogPanel.size.right += width;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,18 +24,19 @@ var g_unitPanelButtons = {
|
|||
*/
|
||||
function setPanelObjectPosition(object, index, rowLength, vMargin = 1, hMargin = 1)
|
||||
{
|
||||
var size = object.size;
|
||||
// horizontal position
|
||||
var oWidth = size.right - size.left;
|
||||
var hIndex = index % rowLength;
|
||||
size.left = hIndex * (oWidth + vMargin);
|
||||
size.right = size.left + oWidth;
|
||||
// vertical position
|
||||
var oHeight = size.bottom - size.top;
|
||||
var vIndex = Math.floor(index / rowLength);
|
||||
size.top = vIndex * (oHeight + hMargin);
|
||||
size.bottom = size.top + oHeight;
|
||||
object.size = size;
|
||||
const oWidth = object.size.right - object.size.left;
|
||||
const oHeight = object.size.bottom - object.size.top;
|
||||
const left = (index % rowLength) * (oWidth + vMargin);
|
||||
const top = (Math.floor(index / rowLength)) * (oHeight + hMargin);
|
||||
|
||||
Object.assign(object.size, {
|
||||
// horizontal position
|
||||
"left": left,
|
||||
"right": left + oWidth,
|
||||
// vertical position
|
||||
"top": top,
|
||||
"bottom": top + oHeight
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -13,14 +13,24 @@ async function init(data)
|
|||
const text = paragraphObject.children.find(object => object.toString().startsWith("text"));
|
||||
const icon = paragraphObject.children.find(object => object.toString().startsWith("icon"));
|
||||
|
||||
text.size = new GUISize(textIndent, verticalOffset, -10, 0, 0, 0, 100, 100);
|
||||
text.size = {
|
||||
"left": textIndent,
|
||||
"top": verticalOffset,
|
||||
"right": -10,
|
||||
"bottom": 0,
|
||||
"rleft": 0,
|
||||
"rtop": 0,
|
||||
"rright": 100,
|
||||
"rbottom": 100
|
||||
};
|
||||
const paragraphHeight = Math.max(text.getTextSize().height, iconSize);
|
||||
const sizeTop = Math.min(verticalOffset + 5, verticalOffset + paragraphHeight / 2 - iconSize / 2);
|
||||
icon.size = new GUISize(
|
||||
iconMargin, sizeTop,
|
||||
iconMargin + iconSize, sizeTop + iconSize,
|
||||
0, 0, 0, 0
|
||||
);
|
||||
icon.size = {
|
||||
"left": iconMargin,
|
||||
"top": sizeTop,
|
||||
"right": iconMargin + iconSize,
|
||||
"bottom": sizeTop + iconSize
|
||||
};
|
||||
verticalOffset += paragraphHeight + paragraphSpacing;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -362,9 +362,7 @@ function updateGeneralPanelTeams()
|
|||
|
||||
const teamBox = Engine.GetGUIObjectByName("teamBoxt["+i+"]");
|
||||
teamBox.hidden = false;
|
||||
const teamBoxSize = teamBox.size;
|
||||
teamBoxSize.top = yStart;
|
||||
teamBox.size = teamBoxSize;
|
||||
teamBox.size.top = yStart;
|
||||
|
||||
yStart += 30 + g_Teams[i].length * (g_PlayerBoxYSize + g_PlayerBoxGap) + 32;
|
||||
|
||||
|
|
@ -386,18 +384,14 @@ function initPlayerBoxPositions()
|
|||
for (let h = 0; h < g_MaxPlayers; ++h)
|
||||
{
|
||||
const playerBox = Engine.GetGUIObjectByName("playerBox[" + h + "]");
|
||||
let boxSize = playerBox.size;
|
||||
boxSize.top += h * (g_PlayerBoxYSize + g_PlayerBoxGap);
|
||||
boxSize.bottom = boxSize.top + g_PlayerBoxYSize;
|
||||
playerBox.size = boxSize;
|
||||
playerBox.size.top += h * (g_PlayerBoxYSize + g_PlayerBoxGap);
|
||||
playerBox.size.bottom = playerBox.size.top + g_PlayerBoxYSize;
|
||||
|
||||
for (let i = 0; i < g_MaxTeams; ++i)
|
||||
{
|
||||
const playerBoxt = Engine.GetGUIObjectByName("playerBoxt[" + i + "][" + h + "]");
|
||||
boxSize = playerBoxt.size;
|
||||
boxSize.top += h * (g_PlayerBoxYSize + g_PlayerBoxGap);
|
||||
boxSize.bottom = boxSize.top + g_PlayerBoxYSize;
|
||||
playerBoxt.size = boxSize;
|
||||
playerBoxt.size.top += h * (g_PlayerBoxYSize + g_PlayerBoxGap);
|
||||
playerBoxt.size.bottom = playerBoxt.size.top + g_PlayerBoxYSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -254,23 +254,20 @@ function initGUICharts()
|
|||
{
|
||||
updateChartColorAndLegend();
|
||||
const chart1Part = Engine.GetGUIObjectByName("chart[1]Part");
|
||||
const chart1PartSize = chart1Part.size;
|
||||
chart1PartSize.rright += 50;
|
||||
chart1PartSize.rleft += 50;
|
||||
chart1PartSize.right -= 5;
|
||||
chart1PartSize.left -= 5;
|
||||
chart1Part.size = chart1PartSize;
|
||||
chart1Part.size.rright += 50;
|
||||
chart1Part.size.rleft += 50;
|
||||
chart1Part.size.right -= 5;
|
||||
chart1Part.size.left -= 5;
|
||||
|
||||
Engine.GetGUIObjectByName("toggleTeam").hidden = !g_Teams;
|
||||
}
|
||||
|
||||
function resizeDropdown(dropdown)
|
||||
{
|
||||
const size = dropdown.size;
|
||||
size.bottom = dropdown.size.top +
|
||||
dropdown.size.bottom = dropdown.size.top +
|
||||
(Engine.GetTextWidth(dropdown.font, dropdown.list[dropdown.selected]) >
|
||||
dropdown.size.right - dropdown.size.left - 28 &&
|
||||
dropdown.list[dropdown.selected].indexOf(" ") !== -1 ? 42 : 28);
|
||||
dropdown.size = size;
|
||||
}
|
||||
|
||||
function updateCategoryDropdown(number)
|
||||
|
|
@ -389,15 +386,9 @@ function adjustTabDividers(tabSize)
|
|||
{
|
||||
const tabButtonsLeft = Engine.GetGUIObjectByName("tabButtonsFrame").size.left;
|
||||
|
||||
const leftSpacer = Engine.GetGUIObjectByName("tabDividerLeft");
|
||||
const leftSpacerSize = leftSpacer.size;
|
||||
leftSpacerSize.right = tabSize.left + tabButtonsLeft + 2;
|
||||
leftSpacer.size = leftSpacerSize;
|
||||
Engine.GetGUIObjectByName("tabDividerLeft").size.right = tabSize.left + tabButtonsLeft + 2;
|
||||
|
||||
const rightSpacer = Engine.GetGUIObjectByName("tabDividerRight");
|
||||
const rightSpacerSize = rightSpacer.size;
|
||||
rightSpacerSize.left = tabSize.right + tabButtonsLeft - 2;
|
||||
rightSpacer.size = rightSpacerSize;
|
||||
Engine.GetGUIObjectByName("tabDividerRight").size.left = tabSize.right + tabButtonsLeft - 2;
|
||||
}
|
||||
|
||||
function updatePanelData(panelInfo)
|
||||
|
|
@ -444,9 +435,7 @@ function updatePanelData(panelInfo)
|
|||
rowPlayerObject.hidden = false;
|
||||
rowPlayerObject.sprite = colorString + " " + g_PlayerBoxAlpha;
|
||||
|
||||
const boxSize = rowPlayerObject.size;
|
||||
boxSize.right = rowPlayerObjectWidth;
|
||||
rowPlayerObject.size = boxSize;
|
||||
rowPlayerObject.size.right = rowPlayerObjectWidth;
|
||||
|
||||
setOutcomeIcon(playerState.state, Engine.GetGUIObjectByName(playerOutcome));
|
||||
|
||||
|
|
@ -560,11 +549,10 @@ function initGUIButtons()
|
|||
lobbyButton.hidden = g_GameData.gui.isInGame || !Engine.HasXmppClient();
|
||||
|
||||
// Right-align lobby button
|
||||
const lobbyButtonSize = lobbyButton.size;
|
||||
const lobbyButtonWidth = lobbyButtonSize.right - lobbyButtonSize.left;
|
||||
lobbyButtonSize.right = (replayButton.hidden ? Engine.GetGUIObjectByName("continueButton").size.left : replayButton.size.left) - 10;
|
||||
lobbyButtonSize.left = lobbyButtonSize.right - lobbyButtonWidth;
|
||||
lobbyButton.size = lobbyButtonSize;
|
||||
const lobbyButtonWidth = lobbyButton.size.right - lobbyButton.size.left;
|
||||
const right = (replayButton.hidden ? Engine.GetGUIObjectByName("continueButton").size.left : replayButton.size.left) - 10;
|
||||
lobbyButton.size.right = right;
|
||||
lobbyButton.size.left = right - lobbyButtonWidth;
|
||||
|
||||
const allPanelsData = g_ScorePanelsData.concat(g_ChartPanelsData);
|
||||
for (const tab in allPanelsData)
|
||||
|
|
|
|||
Loading…
Reference in a new issue