mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Fix eslint rule 'prefer-const' in gui/gamesetup
eslint --no-config-lookup --fix --rule '"prefer-const": 1' \
binaries/data/mods/public/gui/gamesetup
Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
parent
7e73841d50
commit
7df1bd1a42
50 changed files with 152 additions and 152 deletions
|
|
@ -182,7 +182,7 @@ class GameSettingsController
|
|||
// This assumes that messages aren't sent spuriously without changes
|
||||
// (which is generally fair), but technically it would be good
|
||||
// to check if the new data is different from the previous data.
|
||||
for (let handler of this.settingsChangeHandlers)
|
||||
for (const handler of this.settingsChangeHandlers)
|
||||
handler();
|
||||
}
|
||||
|
||||
|
|
@ -191,7 +191,7 @@ class GameSettingsController
|
|||
*/
|
||||
getSettings()
|
||||
{
|
||||
let ret = g_GameSettings.toInitAttributes();
|
||||
const ret = g_GameSettings.toInitAttributes();
|
||||
ret.guiData = this.guiData.Serialize();
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -211,7 +211,7 @@ class GameSettingsController
|
|||
if (this.loading === loading)
|
||||
return;
|
||||
this.loading = loading;
|
||||
for (let handler of this.loadingChangeHandlers)
|
||||
for (const handler of this.loadingChangeHandlers)
|
||||
handler(loading);
|
||||
}
|
||||
|
||||
|
|
@ -224,7 +224,7 @@ class GameSettingsController
|
|||
if (this.layoutTimer)
|
||||
return;
|
||||
this.layoutTimer = setTimeout(() => {
|
||||
for (let handler of this.updateLayoutHandlers)
|
||||
for (const handler of this.updateLayoutHandlers)
|
||||
handler();
|
||||
delete this.layoutTimer;
|
||||
}, 0);
|
||||
|
|
@ -241,7 +241,7 @@ class GameSettingsController
|
|||
*/
|
||||
setNetworkInitAttributes()
|
||||
{
|
||||
for (let handler of this.settingsChangeHandlers)
|
||||
for (const handler of this.settingsChangeHandlers)
|
||||
handler();
|
||||
|
||||
if (g_IsNetworked && this.timer === undefined)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class LobbyGameRegistrationController
|
|||
onGameStart()
|
||||
{
|
||||
this.sendImmediately();
|
||||
let clients = this.formatClientsForStanza();
|
||||
const clients = this.formatClientsForStanza();
|
||||
Engine.SendChangeStateGame(clients.connectedPlayers, clients.list);
|
||||
}
|
||||
|
||||
|
|
@ -78,9 +78,9 @@ class LobbyGameRegistrationController
|
|||
this.timer = undefined;
|
||||
}
|
||||
|
||||
let clients = this.formatClientsForStanza();
|
||||
const clients = this.formatClientsForStanza();
|
||||
|
||||
let stanza = {
|
||||
const stanza = {
|
||||
"name": this.serverName,
|
||||
"hostUsername": Engine.LobbyGetNick(),
|
||||
"hostJID": "", // Overwritten by C++, placeholder.
|
||||
|
|
@ -113,11 +113,11 @@ class LobbyGameRegistrationController
|
|||
formatClientsForStanza()
|
||||
{
|
||||
let connectedPlayers = 0;
|
||||
let playerData = [];
|
||||
const playerData = [];
|
||||
|
||||
for (let guid in g_PlayerAssignments)
|
||||
for (const guid in g_PlayerAssignments)
|
||||
{
|
||||
let pData = { "Name": g_PlayerAssignments[guid].name };
|
||||
const pData = { "Name": g_PlayerAssignments[guid].name };
|
||||
|
||||
if (g_PlayerAssignments[guid].player != -1)
|
||||
++connectedPlayers;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class PlayerAssignmentsController
|
|||
|
||||
if (!g_IsNetworked)
|
||||
{
|
||||
let name = singleplayerName();
|
||||
const name = singleplayerName();
|
||||
|
||||
// Replace empty player name when entering a single-player match for the first time.
|
||||
Engine.ConfigDB_CreateAndSaveValue("user", this.ConfigNameSingleplayer, name);
|
||||
|
|
@ -162,15 +162,15 @@ class PlayerAssignmentsController
|
|||
*/
|
||||
onPlayerAssignmentMessage(message)
|
||||
{
|
||||
let newAssignments = message.newAssignments;
|
||||
for (let guid in newAssignments)
|
||||
const newAssignments = message.newAssignments;
|
||||
for (const guid in newAssignments)
|
||||
if (!g_PlayerAssignments[guid])
|
||||
for (let handler of this.clientJoinHandlers)
|
||||
for (const handler of this.clientJoinHandlers)
|
||||
handler(guid, message.newAssignments);
|
||||
|
||||
for (let guid in g_PlayerAssignments)
|
||||
for (const guid in g_PlayerAssignments)
|
||||
if (!newAssignments[guid])
|
||||
for (let handler of this.clientLeaveHandlers)
|
||||
for (const handler of this.clientLeaveHandlers)
|
||||
handler(guid);
|
||||
|
||||
g_PlayerAssignments = newAssignments;
|
||||
|
|
@ -195,7 +195,7 @@ class PlayerAssignmentsController
|
|||
{
|
||||
if (g_PlayerAssignments[guidToAssign].player != -1)
|
||||
{
|
||||
for (let guid in g_PlayerAssignments)
|
||||
for (const guid in g_PlayerAssignments)
|
||||
if (g_PlayerAssignments[guid].player == playerIndex + 1)
|
||||
{
|
||||
this.assignClient(guid, g_PlayerAssignments[guidToAssign].player);
|
||||
|
|
@ -220,7 +220,7 @@ class PlayerAssignmentsController
|
|||
{
|
||||
if (g_IsNetworked)
|
||||
{
|
||||
for (let guid in g_PlayerAssignments)
|
||||
for (const guid in g_PlayerAssignments)
|
||||
if (g_PlayerAssignments[guid].player > g_GameSettings.playerCount.nbPlayers)
|
||||
Engine.AssignNetworkPlayer(g_PlayerAssignments[guid].player, "");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class ReadyController
|
|||
|
||||
onReadyMessage(message)
|
||||
{
|
||||
let playerAssignment = g_PlayerAssignments[message.guid];
|
||||
const playerAssignment = g_PlayerAssignments[message.guid];
|
||||
if (playerAssignment)
|
||||
{
|
||||
playerAssignment.status = message.status;
|
||||
|
|
@ -60,11 +60,11 @@ class ReadyController
|
|||
onPlayerAssignmentsChange()
|
||||
{
|
||||
// Don't let the host tell you that you're ready when you're not.
|
||||
let playerAssignment = g_PlayerAssignments[Engine.GetPlayerGUID()];
|
||||
const playerAssignment = g_PlayerAssignments[Engine.GetPlayerGUID()];
|
||||
if (playerAssignment && playerAssignment.status > this.readyState)
|
||||
playerAssignment.status = this.readyState;
|
||||
|
||||
for (let guid in g_PlayerAssignments)
|
||||
for (const guid in g_PlayerAssignments)
|
||||
if (this.previousAssignments[guid] &&
|
||||
this.previousAssignments[guid].player != g_PlayerAssignments[guid].player)
|
||||
{
|
||||
|
|
@ -86,7 +86,7 @@ class ReadyController
|
|||
Engine.SendNetworkReady(ready);
|
||||
|
||||
// Update GUI objects instantly if relevant settingchange was detected
|
||||
let playerAssignment = g_PlayerAssignments[Engine.GetPlayerGUID()];
|
||||
const playerAssignment = g_PlayerAssignments[Engine.GetPlayerGUID()];
|
||||
if (playerAssignment)
|
||||
{
|
||||
playerAssignment.status = ready;
|
||||
|
|
@ -101,7 +101,7 @@ class ReadyController
|
|||
if (!g_IsNetworked || this.gameSettingsController.gameStarted)
|
||||
return;
|
||||
|
||||
for (let handler of this.resetReadyHandlers)
|
||||
for (const handler of this.resetReadyHandlers)
|
||||
handler();
|
||||
|
||||
if (g_IsController)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class NetMessages
|
|||
{
|
||||
this.netMessageHandlers = {};
|
||||
|
||||
for (let messageType of this.MessageTypes)
|
||||
for (const messageType of this.MessageTypes)
|
||||
this.netMessageHandlers[messageType] = new Set();
|
||||
}
|
||||
|
||||
|
|
@ -31,14 +31,14 @@ class NetMessages
|
|||
{
|
||||
while (true)
|
||||
{
|
||||
let message = Engine.PollNetworkClient();
|
||||
const message = Engine.PollNetworkClient();
|
||||
if (!message)
|
||||
break;
|
||||
|
||||
log("Net message: " + uneval(message));
|
||||
|
||||
if (this.netMessageHandlers[message.type])
|
||||
for (let handler of this.netMessageHandlers[message.type])
|
||||
for (const handler of this.netMessageHandlers[message.type])
|
||||
handler(message);
|
||||
else
|
||||
error("Unrecognized net message type " + message.type);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ SetupWindowPages.AIConfigPage = class
|
|||
this.openPageHandlers = new Set();
|
||||
this.AIGameSettingControls = {};
|
||||
|
||||
for (let name of this.AIGameSettingControlOrder)
|
||||
for (const name of this.AIGameSettingControlOrder)
|
||||
this.AIGameSettingControls[name] =
|
||||
new AIGameSettingControls[name](this, undefined, undefined, setupWindow,
|
||||
isSavedGame);
|
||||
|
|
@ -43,7 +43,7 @@ SetupWindowPages.AIConfigPage = class
|
|||
{
|
||||
this.playerIndex = playerIndex;
|
||||
|
||||
for (let handler of this.openPageHandlers)
|
||||
for (const handler of this.openPageHandlers)
|
||||
handler(playerIndex, enabled);
|
||||
|
||||
this.aiConfigPage.hidden = false;
|
||||
|
|
|
|||
|
|
@ -22,14 +22,14 @@ class AIGameSettingControlDropdown extends GameSettingControlDropdown
|
|||
{
|
||||
aiConfigPage.registerOpenPageHandler(this.onOpenPage.bind(this));
|
||||
|
||||
let i = aiConfigPage.getRow();
|
||||
const i = aiConfigPage.getRow();
|
||||
|
||||
this.frame = Engine.GetGUIObjectByName("aiSettingFrame[" + i + "]");
|
||||
this.title = this.frame.children[0];
|
||||
this.dropdown = this.frame.children[1];
|
||||
this.label = this.frame.children[2];
|
||||
|
||||
let size = this.frame.size;
|
||||
const size = this.frame.size;
|
||||
size.top = i * (this.Height + this.Margin);
|
||||
size.bottom = size.top + this.Height;
|
||||
this.frame.size = size;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ AIGameSettingControls.AIBehavior = class extends AIGameSettingControlDropdown
|
|||
this.dropdown.list = g_Settings.AIBehaviors.map(AIBehavior => AIBehavior.Title);
|
||||
this.dropdown.list_data = g_Settings.AIBehaviors.map(AIBehavior => AIBehavior.Name);
|
||||
|
||||
let ai = g_GameSettings.playerAI.get(this.playerIndex);
|
||||
const ai = g_GameSettings.playerAI.get(this.playerIndex);
|
||||
this.setHidden(!ai);
|
||||
if (!!ai)
|
||||
this.setSelectedValue(ai.behavior);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ AIGameSettingControls.AIDifficulty = class extends AIGameSettingControlDropdown
|
|||
this.dropdown.list = g_Settings.AIDifficulties.map(AI => AI.Title);
|
||||
this.dropdown.list_data = g_Settings.AIDifficulties.map((AI, i) => i);
|
||||
|
||||
let ai = g_GameSettings.playerAI.get(this.playerIndex);
|
||||
const ai = g_GameSettings.playerAI.get(this.playerIndex);
|
||||
this.setHidden(!ai);
|
||||
if (!!ai)
|
||||
this.setSelectedValue(ai.difficulty);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ AIGameSettingControls.AISelection = class extends AIGameSettingControlDropdown
|
|||
|
||||
render()
|
||||
{
|
||||
let ai = g_GameSettings.playerAI.get(this.playerIndex);
|
||||
const ai = g_GameSettings.playerAI.get(this.playerIndex);
|
||||
this.setHidden(!ai);
|
||||
if (!!ai)
|
||||
this.setSelectedValue(ai.bot);
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ class GameSettingControl /* extends Profilable /* Uncomment to profile controls
|
|||
|
||||
updateVisibility()
|
||||
{
|
||||
let hidden =
|
||||
const hidden =
|
||||
this.hidden ||
|
||||
this.playerIndex === undefined &&
|
||||
this.category != g_TabCategorySelected ||
|
||||
|
|
@ -109,7 +109,7 @@ class GameSettingControl /* extends Profilable /* Uncomment to profile controls
|
|||
if (hidden)
|
||||
return;
|
||||
|
||||
let enabled = g_IsController && this.enabled;
|
||||
const enabled = g_IsController && this.enabled;
|
||||
|
||||
if (this.setControlHidden)
|
||||
this.setControlHidden(!enabled);
|
||||
|
|
@ -135,7 +135,7 @@ class GameSettingControl /* extends Profilable /* Uncomment to profile controls
|
|||
return;
|
||||
}
|
||||
|
||||
let newEntries = this.getAutocompleteEntries();
|
||||
const newEntries = this.getAutocompleteEntries();
|
||||
if (newEntries)
|
||||
autocomplete[this.AutocompleteOrder] =
|
||||
(autocomplete[this.AutocompleteOrder] || []).concat(newEntries);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ class GameSettingControlButton extends GameSettingControl
|
|||
{
|
||||
setControl(gameSettingControlManager)
|
||||
{
|
||||
let row = gameSettingControlManager.getNextRow("buttonSettingFrame");
|
||||
const row = gameSettingControlManager.getNextRow("buttonSettingFrame");
|
||||
this.frame = Engine.GetGUIObjectByName("buttonSettingFrame[" + row + "]");
|
||||
this.button = Engine.GetGUIObjectByName("buttonSettingControl[" + row + "]");
|
||||
this.button.onPress = this.onPress.bind(this);
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ class GameSettingControlCheckbox extends GameSettingControl
|
|||
|
||||
setControl(gameSettingControlManager)
|
||||
{
|
||||
let row = gameSettingControlManager.getNextRow("checkboxSettingFrame");
|
||||
const row = gameSettingControlManager.getNextRow("checkboxSettingFrame");
|
||||
this.frame = Engine.GetGUIObjectByName("checkboxSettingFrame[" + row + "]");
|
||||
this.checkbox = Engine.GetGUIObjectByName("checkboxSettingControl[" + row + "]");
|
||||
this.checkbox.onPress = this.onPressSuper.bind(this);
|
||||
|
||||
let labels = this.frame.children[0].children;
|
||||
const labels = this.frame.children[0].children;
|
||||
this.title = labels[0];
|
||||
this.label = labels[1];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@ class GameSettingControlDropdown extends GameSettingControl
|
|||
|
||||
setControl(gameSettingControlManager)
|
||||
{
|
||||
let row = gameSettingControlManager.getNextRow("dropdownSettingFrame");
|
||||
const row = gameSettingControlManager.getNextRow("dropdownSettingFrame");
|
||||
this.frame = Engine.GetGUIObjectByName("dropdownSettingFrame[" + row + "]");
|
||||
this.dropdown = Engine.GetGUIObjectByName("dropdownSettingControl[" + row + "]");
|
||||
|
||||
let labels = this.frame.children[0].children;
|
||||
const labels = this.frame.children[0].children;
|
||||
this.title = labels[0];
|
||||
this.label = labels[1];
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ class GameSettingControlDropdown extends GameSettingControl
|
|||
|
||||
setSelectedValue(value)
|
||||
{
|
||||
let index = this.dropdown.list_data.indexOf(String(value));
|
||||
const index = this.dropdown.list_data.indexOf(String(value));
|
||||
|
||||
this.isInGuiUpdate = true;
|
||||
this.dropdown.selected = index;
|
||||
|
|
|
|||
|
|
@ -18,15 +18,15 @@ class GameSettingControlManager
|
|||
this.rows = {};
|
||||
this.gameSettingControls = {};
|
||||
|
||||
let getCategory = name =>
|
||||
const getCategory = name =>
|
||||
g_GameSettingsLayout.findIndex(category => category.settings.indexOf(name) != -1);
|
||||
|
||||
for (let name in GameSettingControls)
|
||||
for (const name in GameSettingControls)
|
||||
this.gameSettingControls[name] =
|
||||
new GameSettingControls[name](
|
||||
this, getCategory(name), undefined, setupWindow, isSavedGame);
|
||||
|
||||
for (let victoryCondition of g_VictoryConditions)
|
||||
for (const victoryCondition of g_VictoryConditions)
|
||||
this.gameSettingControls[victoryCondition.Name] =
|
||||
new VictoryConditionCheckbox(
|
||||
victoryCondition, this, getCategory(victoryCondition.Name), undefined,
|
||||
|
|
@ -50,16 +50,16 @@ class GameSettingControlManager
|
|||
|
||||
updateSettingVisibility()
|
||||
{
|
||||
for (let name in this.gameSettingControls)
|
||||
for (const name in this.gameSettingControls)
|
||||
this.gameSettingControls[name].updateVisibility();
|
||||
}
|
||||
|
||||
addAutocompleteEntries(entries)
|
||||
{
|
||||
for (let name in this.gameSettingControls)
|
||||
for (const name in this.gameSettingControls)
|
||||
this.gameSettingControls[name].addAutocompleteEntries(name, entries);
|
||||
|
||||
for (let playerSettingControlManager of this.playerSettingControlManagers)
|
||||
for (const playerSettingControlManager of this.playerSettingControlManagers)
|
||||
playerSettingControlManager.addAutocompleteEntries(entries);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@ class GameSettingControlSlider extends GameSettingControl
|
|||
|
||||
setControl(gameSettingControlManager)
|
||||
{
|
||||
let row = gameSettingControlManager.getNextRow("sliderSettingFrame");
|
||||
const row = gameSettingControlManager.getNextRow("sliderSettingFrame");
|
||||
this.frame = Engine.GetGUIObjectByName("sliderSettingFrame[" + row + "]");
|
||||
this.slider = Engine.GetGUIObjectByName("sliderSettingControl[" + row + "]");
|
||||
this.valueLabel = Engine.GetGUIObjectByName("sliderSettingLabel[" + row + "]");
|
||||
|
||||
let labels = this.frame.children[0].children;
|
||||
const labels = this.frame.children[0].children;
|
||||
this.title = labels[0];
|
||||
this.label = labels[1];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ PlayerSettingControls.PlayerAssignment = class PlayerAssignment extends GameSett
|
|||
|
||||
OnPlayerNbChange(oldNb)
|
||||
{
|
||||
let isPlayerSlot = Object.values(g_PlayerAssignments).some(x => x.player === this.playerIndex + 1);
|
||||
const isPlayerSlot = Object.values(g_PlayerAssignments).some(x => x.player === this.playerIndex + 1);
|
||||
if (!isPlayerSlot && !g_GameSettings.playerAI.get(this.playerIndex) &&
|
||||
this.playerIndex >= oldNb && this.playerIndex < g_GameSettings.playerCount.nbPlayers)
|
||||
{
|
||||
|
|
@ -71,7 +71,7 @@ PlayerSettingControls.PlayerAssignment = class PlayerAssignment extends GameSett
|
|||
// Rebuild the list to account for new/removed players.
|
||||
this.rebuildList();
|
||||
let newGUID;
|
||||
for (let guid in g_PlayerAssignments)
|
||||
for (const guid in g_PlayerAssignments)
|
||||
if (g_PlayerAssignments[guid].player == this.playerIndex + 1)
|
||||
{
|
||||
newGUID = guid;
|
||||
|
|
@ -97,7 +97,7 @@ PlayerSettingControls.PlayerAssignment = class PlayerAssignment extends GameSett
|
|||
this.setSelectedValue(this.assignedGUID);
|
||||
return;
|
||||
}
|
||||
let ai = g_GameSettings.playerAI.get(this.playerIndex);
|
||||
const ai = g_GameSettings.playerAI.get(this.playerIndex);
|
||||
if (ai)
|
||||
{
|
||||
this.rebuildList();
|
||||
|
|
@ -124,7 +124,7 @@ PlayerSettingControls.PlayerAssignment = class PlayerAssignment extends GameSett
|
|||
this.unassignedItem
|
||||
]);
|
||||
|
||||
let selected = this.dropdown.list_data?.[this.dropdown.selected];
|
||||
const selected = this.dropdown.list_data?.[this.dropdown.selected];
|
||||
this.dropdown.list = this.values.Caption;
|
||||
this.dropdown.list_data = this.values.Value.map(x => x || "undefined");
|
||||
this.setSelectedValue(selected);
|
||||
|
|
@ -172,10 +172,10 @@ PlayerSettingControls.PlayerAssignment.prototype.AutocompleteOrder = 100;
|
|||
onSelectionChange(gameSettingsController, playerAssignmentsController, playerIndex,
|
||||
guidToAssign, isSavedGame)
|
||||
{
|
||||
let sourcePlayer = g_PlayerAssignments[guidToAssign].player - 1;
|
||||
const sourcePlayer = g_PlayerAssignments[guidToAssign].player - 1;
|
||||
if (sourcePlayer >= 0)
|
||||
{
|
||||
let ai = g_GameSettings.playerAI.get(playerIndex);
|
||||
const ai = g_GameSettings.playerAI.get(playerIndex);
|
||||
// If the target was an AI, swap so AI settings are kept.
|
||||
if (ai)
|
||||
g_GameSettings.playerAI.swap(sourcePlayer, playerIndex);
|
||||
|
|
@ -209,7 +209,7 @@ PlayerSettingControls.PlayerAssignment.prototype.AutocompleteOrder = 100;
|
|||
{
|
||||
createItem(ai)
|
||||
{
|
||||
let aiName = translate(ai.data.name);
|
||||
const aiName = translate(ai.data.name);
|
||||
return {
|
||||
"Handler": this,
|
||||
"Value": ai.id,
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@ PlayerSettingControls.PlayerCiv = class PlayerCiv extends GameSettingControlDrop
|
|||
|
||||
getItems(allItems)
|
||||
{
|
||||
let values = [];
|
||||
const values = [];
|
||||
|
||||
for (let civ in g_CivData)
|
||||
for (const civ in g_CivData)
|
||||
if (allItems || g_CivData[civ].SelectableInGameSetup)
|
||||
values.push({
|
||||
"name": g_CivData[civ].Name,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ PlayerSettingControls.PlayerFrame = class PlayerFrame extends GameSettingControl
|
|||
this.playerFrame = Engine.GetGUIObjectByName("playerFrame[" + this.playerIndex + "]");
|
||||
|
||||
{
|
||||
let size = this.playerFrame.size;
|
||||
const size = this.playerFrame.size;
|
||||
size.top = this.Height * this.playerIndex;
|
||||
size.bottom = this.Height * (this.playerIndex + 1);
|
||||
this.playerFrame.size = size;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ PlayerSettingControls.PlayerName = class PlayerName extends GameSettingControl
|
|||
{
|
||||
this.guid = undefined;
|
||||
|
||||
for (let guid in g_PlayerAssignments)
|
||||
for (const guid in g_PlayerAssignments)
|
||||
if (g_PlayerAssignments[guid].player == this.playerIndex + 1)
|
||||
{
|
||||
this.guid = guid;
|
||||
|
|
@ -34,7 +34,7 @@ PlayerSettingControls.PlayerName = class PlayerName extends GameSettingControl
|
|||
|
||||
if (g_IsNetworked)
|
||||
{
|
||||
let status = this.guid ? g_PlayerAssignments[this.guid].status : this.ReadyTags.length - 1;
|
||||
const status = this.guid ? g_PlayerAssignments[this.guid].status : this.ReadyTags.length - 1;
|
||||
name = setStringTags(name, this.ReadyTags[status]);
|
||||
}
|
||||
else if (name)
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ class PlayerSettingControlManager
|
|||
{
|
||||
this.playerSettingControls = {};
|
||||
|
||||
for (let name in PlayerSettingControls)
|
||||
for (const name in PlayerSettingControls)
|
||||
this.playerSettingControls[name] = new PlayerSettingControls[name](undefined, undefined, ...args);
|
||||
}
|
||||
|
||||
addAutocompleteEntries(autocomplete)
|
||||
{
|
||||
for (let name in this.playerSettingControls)
|
||||
for (const name in this.playerSettingControls)
|
||||
this.playerSettingControls[name].addAutocompleteEntries(name, autocomplete);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ GameSettingControls.Biome = class Biome extends GameSettingControlDropdown
|
|||
{
|
||||
this.setHidden(!g_GameSettings.biome.available.size);
|
||||
|
||||
let values = prepareForDropdown([
|
||||
const values = prepareForDropdown([
|
||||
{
|
||||
"Title": setStringTags(this.RandomBiome, this.RandomItemTags),
|
||||
"Id": "random"
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ GameSettingControls.GameSpeed = class GameSpeed extends GameSettingControlDropdo
|
|||
render()
|
||||
{
|
||||
let allowFastForward = true;
|
||||
for (let guid in g_PlayerAssignments)
|
||||
for (const guid in g_PlayerAssignments)
|
||||
if (g_PlayerAssignments[guid].player != -1)
|
||||
{
|
||||
allowFastForward = false;
|
||||
|
|
@ -38,10 +38,10 @@ GameSettingControls.GameSpeed = class GameSpeed extends GameSettingControlDropdo
|
|||
return;
|
||||
}
|
||||
this.previousAllowFastForward = allowFastForward;
|
||||
let values = prepareForDropdown(
|
||||
const values = prepareForDropdown(
|
||||
g_Settings.GameSpeeds.filter(speed => !speed.FastForward || allowFastForward));
|
||||
let currentSpeed = +this.dropdown.list_data?.[this.dropdown.selected];
|
||||
let resetToDefault = values.Speed.indexOf(currentSpeed) === -1;
|
||||
const currentSpeed = +this.dropdown.list_data?.[this.dropdown.selected];
|
||||
const resetToDefault = values.Speed.indexOf(currentSpeed) === -1;
|
||||
|
||||
this.dropdown.list = values.Title;
|
||||
this.dropdown.list_data = values.Speed;
|
||||
|
|
|
|||
|
|
@ -20,19 +20,19 @@ GameSettingControls.Landscape = class Landscape extends GameSettingControlDropdo
|
|||
if (!g_GameSettings.landscape.data)
|
||||
return;
|
||||
|
||||
let randomItems = [{
|
||||
const randomItems = [{
|
||||
"Id": "random",
|
||||
"Name": setStringTags(translateWithContext("landscape selection", "Random"), this.RandomItemTags),
|
||||
"Description": translateWithContext("landscape selection", "Select a random landscape.")
|
||||
}];
|
||||
let data = g_GameSettings.landscape.data;
|
||||
const data = g_GameSettings.landscape.data;
|
||||
let items = [];
|
||||
for (let group of data)
|
||||
for (const group of data)
|
||||
{
|
||||
let itemTag = this.translateItem(group);
|
||||
const itemTag = this.translateItem(group);
|
||||
itemTag.Name = setStringTags(itemTag.Name, this.RandomItemTags);
|
||||
randomItems.push(itemTag);
|
||||
let sort = (item1, item2) => item1.Name > item2.Name;
|
||||
const sort = (item1, item2) => item1.Name > item2.Name;
|
||||
items = items.concat(group.Items.map(this.translateItem).sort(sort));
|
||||
}
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ GameSettingControls.Landscape = class Landscape extends GameSettingControlDropdo
|
|||
if (!this.values)
|
||||
return undefined;
|
||||
|
||||
let entries = [];
|
||||
const entries = [];
|
||||
for (let i = 0; i < this.values.Id.length; ++i)
|
||||
if (!this.values.Id[i].startsWith("random"))
|
||||
entries.push(this.values.Name[i]);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ GameSettingControls.MapFilter = class MapFilter extends GameSettingControlDropdo
|
|||
if (!g_GameSettings.map.type)
|
||||
return;
|
||||
|
||||
let values = prepareForDropdown(
|
||||
const values = prepareForDropdown(
|
||||
this.mapFilters.getAvailableMapFilters(
|
||||
g_GameSettings.map.type));
|
||||
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ GameSettingControls.MapSelection = class MapSelection extends GameSettingControl
|
|||
// which takes a few ms, but this could only be done once per frame anyways.
|
||||
// NB: this technically makes it possible to start the game without the change going through
|
||||
// but it's essentially impossible to trigger accidentally.
|
||||
let call = () => {
|
||||
const call = () => {
|
||||
g_GameSettings.map.selectMap(this.values.file[itemIdx]);
|
||||
this.gameSettingsController.setNetworkInitAttributes();
|
||||
delete this.reRenderTimeout;
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@ GameSettingControls.PlayerPlacement = class PlayerPlacement extends GameSettingC
|
|||
if (!g_GameSettings.playerPlacement.value)
|
||||
return;
|
||||
|
||||
let randomItem = clone(this.RandomItem);
|
||||
const randomItem = clone(this.RandomItem);
|
||||
randomItem.Name = setStringTags(randomItem.Name, this.RandomItemTags);
|
||||
|
||||
let patterns = [randomItem];
|
||||
const patterns = [randomItem];
|
||||
|
||||
for (let pattern of g_GameSettings.playerPlacement.available)
|
||||
for (const pattern of g_GameSettings.playerPlacement.available)
|
||||
patterns.push(g_Settings.PlayerPlacements
|
||||
.find(pObj => pObj.Id == pattern));
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ GameSettingControls.Ceasefire = class Ceasefire extends GameSettingControlSlider
|
|||
{
|
||||
this.setEnabled(g_GameSettings.map.type != "scenario");
|
||||
|
||||
let value = Math.round(g_GameSettings.ceasefire.value);
|
||||
const value = Math.round(g_GameSettings.ceasefire.value);
|
||||
this.sprintfValue.minutes = value;
|
||||
|
||||
this.setSelectedValue(g_GameSettings.ceasefire.value,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ GameSettingControls.RelicCount = class RelicCount extends GameSettingControlSlid
|
|||
|
||||
if (g_GameSettings.relic.available)
|
||||
{
|
||||
let value = g_GameSettings.relic.count;
|
||||
const value = g_GameSettings.relic.count;
|
||||
this.sprintfValue.number = value;
|
||||
this.setSelectedValue(
|
||||
g_GameSettings.relic.count,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ GameSettingControls.RelicDuration = class RelicDuration extends GameSettingContr
|
|||
|
||||
if (g_GameSettings.relic.available)
|
||||
{
|
||||
let value = g_GameSettings.relic.duration;
|
||||
const value = g_GameSettings.relic.duration;
|
||||
this.sprintfValue.min = value;
|
||||
this.setSelectedValue(
|
||||
g_GameSettings.relic.duration,
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@ GameSettingControls.SeaLevelRiseTime = class SeaLevelRiseTime extends GameSettin
|
|||
|
||||
render()
|
||||
{
|
||||
let hidden = g_GameSettings.seaLevelRise.value === undefined;
|
||||
const hidden = g_GameSettings.seaLevelRise.value === undefined;
|
||||
this.setHidden(hidden);
|
||||
this.setEnabled(g_GameSettings.map.type != "scenario");
|
||||
if (hidden)
|
||||
return;
|
||||
|
||||
let value = g_GameSettings.seaLevelRise.value;
|
||||
const value = g_GameSettings.seaLevelRise.value;
|
||||
this.sprintfValue.minutes = value;
|
||||
|
||||
this.setSelectedValue(
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ GameSettingControls.WonderDuration = class WonderDuration extends GameSettingCon
|
|||
|
||||
if (g_GameSettings.wonder.available)
|
||||
{
|
||||
let value = g_GameSettings.wonder.duration;
|
||||
const value = g_GameSettings.wonder.duration;
|
||||
this.sprintfValue.min = value;
|
||||
this.setSelectedValue(
|
||||
g_GameSettings.wonder.duration,
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ SetupWindowPages.GameSetupPage = class
|
|||
|
||||
// These classes manage GUI buttons.
|
||||
{
|
||||
let startGameButton = new StartGameButton(setupWindow);
|
||||
let readyButton = new ReadyButton(setupWindow);
|
||||
const startGameButton = new StartGameButton(setupWindow);
|
||||
const readyButton = new ReadyButton(setupWindow);
|
||||
this.panelButtons = {
|
||||
"civInfoButton": new CivInfoButton(),
|
||||
"lobbyButton": new LobbyButton(),
|
||||
|
|
@ -26,8 +26,8 @@ SetupWindowPages.GameSetupPage = class
|
|||
|
||||
// These classes manage GUI Objects.
|
||||
{
|
||||
let gameSettingTabs = new GameSettingTabs(setupWindow, this.panelButtons.lobbyButton);
|
||||
let gameSettingsPanel = new GameSettingsPanel(
|
||||
const gameSettingTabs = new GameSettingTabs(setupWindow, this.panelButtons.lobbyButton);
|
||||
const gameSettingsPanel = new GameSettingsPanel(
|
||||
setupWindow, gameSettingTabs, this.gameSettingControlManager);
|
||||
|
||||
this.panels = {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class CivInfoButton
|
|||
"page": "page_civinfo.xml"
|
||||
};
|
||||
|
||||
let civInfoButton = Engine.GetGUIObjectByName("civInfoButton");
|
||||
const civInfoButton = Engine.GetGUIObjectByName("civInfoButton");
|
||||
civInfoButton.onPress = this.onPress.bind(this);
|
||||
civInfoButton.tooltip =
|
||||
sprintf(translate(this.Tooltip), {
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ class ReadyButton
|
|||
|
||||
onPlayerAssignmentsChange()
|
||||
{
|
||||
let playerAssignment = g_PlayerAssignments[Engine.GetPlayerGUID()];
|
||||
let hidden = g_IsController || !playerAssignment || playerAssignment.player == -1;
|
||||
const playerAssignment = g_PlayerAssignments[Engine.GetPlayerGUID()];
|
||||
const hidden = g_IsController || !playerAssignment || playerAssignment.player == -1;
|
||||
|
||||
if (!hidden)
|
||||
{
|
||||
|
|
@ -50,10 +50,10 @@ class ReadyButton
|
|||
|
||||
onPress()
|
||||
{
|
||||
let newState =
|
||||
const newState =
|
||||
(g_PlayerAssignments[Engine.GetPlayerGUID()].status + 1) % (this.readyController.StayReady + 1);
|
||||
|
||||
for (let handler of this.readyButtonPressHandlers)
|
||||
for (const handler of this.readyButtonPressHandlers)
|
||||
handler(newState);
|
||||
|
||||
this.readyController.setReady(newState, true);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class SavedGameLabel
|
|||
|
||||
const bottomRightPanel = Engine.GetGUIObjectByName("bottomRightPanel");
|
||||
const savedGameLabel = Engine.GetGUIObjectByName("savedGameLabel");
|
||||
let labelWidth = Math.min(Engine.GetTextWidth(savedGameLabel.font, savedGameLabel.caption) + 10, maxWidth);
|
||||
const labelWidth = Math.min(Engine.GetTextWidth(savedGameLabel.font, savedGameLabel.caption) + 10, maxWidth);
|
||||
|
||||
if (isSavedGame)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class StartGameButton
|
|||
|
||||
update()
|
||||
{
|
||||
let isEveryoneReady = this.isEveryoneReady();
|
||||
const isEveryoneReady = this.isEveryoneReady();
|
||||
this.startGameButton.enabled = !this.gameStarted && isEveryoneReady;
|
||||
this.startGameButton.tooltip =
|
||||
!g_IsNetworked || isEveryoneReady ?
|
||||
|
|
@ -33,7 +33,7 @@ class StartGameButton
|
|||
if (!g_IsNetworked)
|
||||
return true;
|
||||
|
||||
for (let guid in g_PlayerAssignments)
|
||||
for (const guid in g_PlayerAssignments)
|
||||
if (g_PlayerAssignments[guid].player != -1 &&
|
||||
g_PlayerAssignments[guid].status == this.setupWindow.controls.readyController.NotReady)
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@ class ChatInputAutocomplete
|
|||
return this.entries;
|
||||
|
||||
// Maps from priority to autocompletable strings
|
||||
let entries = { "0": [] };
|
||||
const entries = { "0": [] };
|
||||
|
||||
this.gameSettingControlManager.addAutocompleteEntries(entries);
|
||||
|
||||
let allEntries = Object.keys(entries).sort((a, b) => +b - +a).reduce(
|
||||
const allEntries = Object.keys(entries).sort((a, b) => +b - +a).reduce(
|
||||
(all, priority) => all.concat(entries[priority]),
|
||||
[]);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class ChatInputPanel
|
|||
resizeGUIObjectToCaption(this.chatSubmitButton, { "horizontal": "left" }, { "horizontal": 8 });
|
||||
|
||||
this.chatInput = Engine.GetGUIObjectByName("chatInput");
|
||||
let size = this.chatInput.size;
|
||||
const size = this.chatInput.size;
|
||||
size.right = this.chatSubmitButton.size.left;
|
||||
this.chatInput.size = size;
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ class ChatInputPanel
|
|||
if (!g_IsNetworked)
|
||||
return;
|
||||
|
||||
let text = this.chatInput.caption;
|
||||
const text = this.chatInput.caption;
|
||||
if (!text.length)
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ ChatMessageEvents.ClientChat = class
|
|||
colorizePlayernameByGUID(guid)
|
||||
{
|
||||
// TODO: Controllers should have the moderator-prefix
|
||||
let username = g_PlayerAssignments[guid] ? escapeText(g_PlayerAssignments[guid].name) : translate("Unknown Player");
|
||||
let playerID = g_PlayerAssignments[guid] ? g_PlayerAssignments[guid].player : -1;
|
||||
const username = g_PlayerAssignments[guid] ? escapeText(g_PlayerAssignments[guid].name) : translate("Unknown Player");
|
||||
const playerID = g_PlayerAssignments[guid] ? g_PlayerAssignments[guid].player : -1;
|
||||
|
||||
let color = "white";
|
||||
if (playerID > 0)
|
||||
|
|
@ -33,8 +33,8 @@ ChatMessageEvents.ClientChat = class
|
|||
color = g_GameSettings.playerColor.values[playerID - 1];
|
||||
|
||||
// Enlighten playercolor to improve readability
|
||||
let [h, s, l] = rgbToHsl(color.r, color.g, color.b);
|
||||
let [r, g, b] = hslToRgb(h, s, Math.max(0.6, l));
|
||||
const [h, s, l] = rgbToHsl(color.r, color.g, color.b);
|
||||
const [r, g, b] = hslToRgb(h, s, Math.max(0.6, l));
|
||||
|
||||
color = rgbToGuiColor({ "r": r, "g": g, "b": b });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ ChatMessageEvents.ClientReady = class
|
|||
|
||||
onReadyMessage(message)
|
||||
{
|
||||
let playerAssignment = g_PlayerAssignments[message.guid];
|
||||
const playerAssignment = g_PlayerAssignments[message.guid];
|
||||
if (!playerAssignment || playerAssignment.player == -1)
|
||||
return;
|
||||
|
||||
let text = this.ReadyMessage[message.status] || undefined;
|
||||
const text = this.ReadyMessage[message.status] || undefined;
|
||||
if (!text)
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class ChatMessagesPanel
|
|||
|
||||
updateHidden()
|
||||
{
|
||||
let size = this.chatPanel.getComputedSize();
|
||||
const size = this.chatPanel.getComputedSize();
|
||||
this.chatPanel.hidden = !g_IsNetworked || size.right - size.left < this.MinimumWidth;
|
||||
}
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ class ChatMessagesPanel
|
|||
|
||||
onGameSettingsPanelResize(settingsPanel)
|
||||
{
|
||||
let size = this.chatPanel.size;
|
||||
const size = this.chatPanel.size;
|
||||
size.right = settingsPanel.size.left + this.gameSettingsPanel.MaxColumnWidth + this.Margin;
|
||||
this.chatPanel.size = size;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class ChatPanel
|
|||
setupWindow.controls.netMessages, this.chatInputAutocomplete);
|
||||
|
||||
this.chatMessageEvents = [];
|
||||
for (let name in ChatMessageEvents)
|
||||
for (const name in ChatMessageEvents)
|
||||
this.chatMessageEvents.push(new ChatMessageEvents[name](setupWindow, this.chatMessagesPanel));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class GameDescription
|
|||
|
||||
registerWatchers()
|
||||
{
|
||||
let update = () => this.updateGameDescription();
|
||||
const update = () => this.updateGameDescription();
|
||||
g_GameSettings.biome.watch(update, ["biome"]);
|
||||
g_GameSettings.ceasefire.watch(update, ["value"]);
|
||||
g_GameSettings.cheats.watch(update, ["enabled"]);
|
||||
|
|
@ -39,7 +39,7 @@ class GameDescription
|
|||
|
||||
onTabsResize(settingsTabButtonsFrame)
|
||||
{
|
||||
let size = this.gameDescription.size;
|
||||
const size = this.gameDescription.size;
|
||||
size.top = settingsTabButtonsFrame.size.bottom + this.Margin;
|
||||
this.gameDescription.size = size;
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ class GameDescription
|
|||
clearTimeout(this.timer);
|
||||
// Update the description on the next GUI tick.
|
||||
// (multiple settings can change at once)
|
||||
let updateCaption = () => { this.gameDescription.caption = getGameDescription(g_GameSettings.toInitAttributes(), this.mapCache); };
|
||||
const updateCaption = () => { this.gameDescription.caption = getGameDescription(g_GameSettings.toInitAttributes(), this.mapCache); };
|
||||
this.timer = setTimeout(updateCaption, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class GameSettingWarning
|
|||
const maxWidth = this.savedGameLabel.hidden ? 260 : 180;
|
||||
const marginRight = 8;
|
||||
|
||||
let caption =
|
||||
const caption =
|
||||
g_GameSettings.cheats.enabled ?
|
||||
this.CheatsEnabled :
|
||||
g_GameSettings.rating.enabled ?
|
||||
|
|
@ -28,7 +28,7 @@ class GameSettingWarning
|
|||
|
||||
this.gameSettingWarning.caption = caption;
|
||||
|
||||
let labelWidth = Math.min(Engine.GetTextWidth(this.gameSettingWarning.font, this.gameSettingWarning.caption) + 10, maxWidth);
|
||||
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(
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class GameSettingsPanel
|
|||
|
||||
triggerResizeHandlers()
|
||||
{
|
||||
for (let handler of this.gameSettingsPanelResizeHandlers)
|
||||
for (const handler of this.gameSettingsPanelResizeHandlers)
|
||||
handler(this.settingsPanelFrame);
|
||||
}
|
||||
|
||||
|
|
@ -51,19 +51,19 @@ class GameSettingsPanel
|
|||
|
||||
onTick()
|
||||
{
|
||||
let now = Date.now();
|
||||
let tickLength = now - this.lastTickTime;
|
||||
let previousTime = this.lastTickTime;
|
||||
const now = Date.now();
|
||||
const tickLength = now - this.lastTickTime;
|
||||
const previousTime = this.lastTickTime;
|
||||
this.lastTickTime = now;
|
||||
if (previousTime === undefined)
|
||||
return;
|
||||
|
||||
const distance = this.slideSpeed * (tickLength || 1);
|
||||
let rightBorder = this.settingTabButtonsFrame.size.left;
|
||||
const rightBorder = this.settingTabButtonsFrame.size.left;
|
||||
let offset = 0;
|
||||
if (g_TabCategorySelected === undefined)
|
||||
{
|
||||
let maxOffset = rightBorder - this.settingsPanelFrame.size.left;
|
||||
const maxOffset = rightBorder - this.settingsPanelFrame.size.left;
|
||||
if (maxOffset > 0)
|
||||
offset = Math.min(distance, maxOffset);
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ class GameSettingsPanel
|
|||
}
|
||||
else
|
||||
{
|
||||
let maxOffset = this.settingsPanelFrame.size.left - rightBorder + (this.settingsPanelFrame.size.right - this.settingsPanelFrame.size.left);
|
||||
const maxOffset = this.settingsPanelFrame.size.left - rightBorder + (this.settingsPanelFrame.size.right - this.settingsPanelFrame.size.left);
|
||||
if (maxOffset > 0)
|
||||
offset = -Math.min(distance, maxOffset);
|
||||
}
|
||||
|
|
@ -92,7 +92,7 @@ class GameSettingsPanel
|
|||
if (!offset)
|
||||
return;
|
||||
|
||||
let size = this.settingsPanelFrame.size;
|
||||
const size = this.settingsPanelFrame.size;
|
||||
size.left += offset;
|
||||
size.right += offset;
|
||||
this.settingsPanelFrame.size = size;
|
||||
|
|
@ -106,17 +106,17 @@ class GameSettingsPanel
|
|||
*/
|
||||
positionSettings()
|
||||
{
|
||||
let gameSetupPageSize = this.gameSetupPage.getComputedSize();
|
||||
const gameSetupPageSize = this.gameSetupPage.getComputedSize();
|
||||
|
||||
let columnWidth = Math.min(
|
||||
const columnWidth = Math.min(
|
||||
this.MaxColumnWidth,
|
||||
(gameSetupPageSize.right - gameSetupPageSize.left + this.centerRightPanel.size.left) / 2);
|
||||
|
||||
let settingsPerColumn;
|
||||
{
|
||||
let settingPanelSize = this.settingsPanel.getComputedSize();
|
||||
let maxSettingsPerColumn = Math.floor((settingPanelSize.bottom - settingPanelSize.top) / this.SettingHeight);
|
||||
let settingCount = this.settingsPanel.children.filter(child => !child.children[0].hidden).length;
|
||||
const settingPanelSize = this.settingsPanel.getComputedSize();
|
||||
const maxSettingsPerColumn = Math.floor((settingPanelSize.bottom - settingPanelSize.top) / this.SettingHeight);
|
||||
const settingCount = this.settingsPanel.children.filter(child => !child.children[0].hidden).length;
|
||||
settingsPerColumn = settingCount / Math.ceil(settingCount / maxSettingsPerColumn);
|
||||
}
|
||||
|
||||
|
|
@ -124,13 +124,13 @@ class GameSettingsPanel
|
|||
let column = 0;
|
||||
let settingsThisColumn = 0;
|
||||
|
||||
let selectedTab = g_GameSettingsLayout[g_TabCategorySelected];
|
||||
const selectedTab = g_GameSettingsLayout[g_TabCategorySelected];
|
||||
if (!selectedTab)
|
||||
return;
|
||||
|
||||
for (let name of selectedTab.settings)
|
||||
for (const name of selectedTab.settings)
|
||||
{
|
||||
let settingFrame = this.gameSettingControlManager.gameSettingControls[name].frame;
|
||||
const settingFrame = this.gameSettingControlManager.gameSettingControls[name].frame;
|
||||
if (settingFrame.hidden)
|
||||
continue;
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ class GameSettingsPanel
|
|||
}
|
||||
|
||||
{
|
||||
let size = this.settingsPanelFrame.size;
|
||||
const size = this.settingsPanelFrame.size;
|
||||
size.right = size.left + (column + 1) * columnWidth;
|
||||
this.settingsPanelFrame.size = size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class GameSettingTabs
|
|||
|
||||
this.settingsTabButtonsFrame = Engine.GetGUIObjectByName("settingTabButtonsFrame");
|
||||
|
||||
for (let tab in g_GameSettingsLayout)
|
||||
for (const tab in g_GameSettingsLayout)
|
||||
g_GameSettingsLayout[tab].tooltip = sprintf(this.ToggleTooltip, { "name": g_GameSettingsLayout[tab].label });
|
||||
|
||||
setupWindow.registerLoadHandler(this.onLoad.bind(this));
|
||||
|
|
@ -44,17 +44,17 @@ class GameSettingTabs
|
|||
|
||||
resize()
|
||||
{
|
||||
let size = this.settingsTabButtonsFrame.size;
|
||||
const size = this.settingsTabButtonsFrame.size;
|
||||
size.bottom = size.top + g_GameSettingsLayout.length * (this.TabButtonHeight + this.TabButtonMargin);
|
||||
|
||||
if (!this.lobbyButton.lobbyButton.hidden)
|
||||
{
|
||||
let lobbyButtonSize = this.lobbyButton.lobbyButton.parent.size;
|
||||
const lobbyButtonSize = this.lobbyButton.lobbyButton.parent.size;
|
||||
size.right -= lobbyButtonSize.right - lobbyButtonSize.left + this.LobbyButtonMargin;
|
||||
}
|
||||
this.settingsTabButtonsFrame.size = size;
|
||||
|
||||
for (let handler of this.tabsResizeHandlers)
|
||||
for (const handler of this.tabsResizeHandlers)
|
||||
handler(this.settingsTabButtonsFrame);
|
||||
}
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ class GameSettingTabs
|
|||
|
||||
onTabSelect()
|
||||
{
|
||||
for (let handler of this.tabSelectHandlers)
|
||||
for (const handler of this.tabSelectHandlers)
|
||||
handler();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class TipsPanel
|
|||
{
|
||||
constructor(gameSettingsPanel)
|
||||
{
|
||||
let available = !g_IsNetworked && Engine.ConfigDB_GetValue("user", this.Config) == "true";
|
||||
const available = !g_IsNetworked && Engine.ConfigDB_GetValue("user", this.Config) == "true";
|
||||
|
||||
this.spTips = Engine.GetGUIObjectByName("spTips");
|
||||
this.spTips.hidden = !available;
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ class PersistentMatchSettings
|
|||
|
||||
Engine.ProfileStart("loadPersistMatchSettingsFile");
|
||||
|
||||
let data =
|
||||
const data =
|
||||
Engine.FileExists(this.filename) &&
|
||||
Engine.ReadJSONFile(this.filename);
|
||||
|
||||
let persistedSettings = data?.engine_info?.engine_version == this.engineInfo.engine_version &&
|
||||
const persistedSettings = data?.engine_info?.engine_version == this.engineInfo.engine_version &&
|
||||
hasSameMods(data?.engine_info?.mods, this.engineInfo.mods) &&
|
||||
data.attributes || {};
|
||||
|
||||
|
|
|
|||
|
|
@ -33,13 +33,13 @@ class SetupWindow
|
|||
g_GameSettings.init(mapCache, g_IsController ? savedGame : undefined);
|
||||
|
||||
|
||||
let netMessages = new NetMessages();
|
||||
let mapFilters = new MapFilters(mapCache);
|
||||
let playerAssignmentsController =
|
||||
const netMessages = new NetMessages();
|
||||
const mapFilters = new MapFilters(mapCache);
|
||||
const playerAssignmentsController =
|
||||
new PlayerAssignmentsController(this, netMessages, isSavedGame);
|
||||
let gameSettingsController = new GameSettingsController(this, netMessages,
|
||||
const gameSettingsController = new GameSettingsController(this, netMessages,
|
||||
playerAssignmentsController, mapCache, isSavedGame);
|
||||
let readyController = new ReadyController(netMessages, gameSettingsController, playerAssignmentsController);
|
||||
const readyController = new ReadyController(netMessages, gameSettingsController, playerAssignmentsController);
|
||||
const lobbyGameRegistrationController = g_IsController && Engine.HasXmppClient() &&
|
||||
new LobbyGameRegistrationController(initData, this, netMessages, mapCache, playerAssignmentsController);
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ class SetupWindow
|
|||
|
||||
// These are the pages within the setup window that may use the controls defined above
|
||||
this.pages = {};
|
||||
for (let name in SetupWindowPages)
|
||||
for (const name in SetupWindowPages)
|
||||
this.pages[name] = new SetupWindowPages[name](this, isSavedGame);
|
||||
|
||||
netMessages.registerNetMessageHandler("netwarn", addNetworkWarning);
|
||||
|
|
@ -64,7 +64,7 @@ class SetupWindow
|
|||
Engine.GetGUIObjectByName("setupWindow").onTick = () => this.onTick();
|
||||
|
||||
// This event is triggered after all classes have been instantiated and subscribed to each others events
|
||||
for (let handler of this.loadHandlers)
|
||||
for (const handler of this.loadHandlers)
|
||||
handler(initData, hotloadData);
|
||||
|
||||
Engine.ProfileStop();
|
||||
|
|
@ -102,8 +102,8 @@ class SetupWindow
|
|||
|
||||
getHotloadData()
|
||||
{
|
||||
let object = {};
|
||||
for (let handler of this.getHotloadDataHandlers)
|
||||
const object = {};
|
||||
for (const handler of this.getHotloadDataHandlers)
|
||||
handler(object);
|
||||
return object;
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ class SetupWindow
|
|||
|
||||
closePage()
|
||||
{
|
||||
for (let handler of this.closePageHandlers)
|
||||
for (const handler of this.closePageHandlers)
|
||||
handler();
|
||||
|
||||
Engine.DisconnectNetworkGame();
|
||||
|
|
|
|||
Loading…
Reference in a new issue