Index: ps/trunk/binaries/data/mods/public/gui/civinfo/civinfo.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/civinfo/civinfo.js +++ ps/trunk/binaries/data/mods/public/gui/civinfo/civinfo.js @@ -21,7 +21,7 @@ */ function bigFirstLetter(str, size) { - return '[font="sans-bold-'+(size+6)+'"]' + str[0] + '[/font]' + '[font="sans-bold-'+size+'"]' + str.substring(1) + '[/font]'; + return '[font="sans-bold-' + (size + 6) + '"]' + str[0] + '[/font]' + '[font="sans-bold-' + size + '"]' + str.substring(1) + '[/font]'; } /** @@ -45,7 +45,7 @@ if (word.length && word[0].toLowerCase() != word[0]) textArray[i] = bigFirstLetter(wordCaps, size); else - textArray[i] = '[font="sans-bold-'+size+'"]' + wordCaps + '[/font]'; // TODO: Would not be necessary if we could do nested tags + textArray[i] = '[font="sans-bold-' + size + '"]' + wordCaps + '[/font]'; // TODO: Would not be necessary if we could do nested tags } return textArray.join(" "); Index: ps/trunk/binaries/data/mods/public/gui/common/color.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/common/color.js +++ ps/trunk/binaries/data/mods/public/gui/common/color.js @@ -32,7 +32,7 @@ */ function sameColor(color1, color2) { - return color1.r === color2.r && color1.g === color2.g && color1.b === color2.b; + return color1.r === color2.r && color1.g === color2.g && color1.b === color2.b; } /** @@ -84,9 +84,15 @@ s = l > 0.5 ? d / (2 - max - min) : d / (max + min); switch (max) { - case r: h = (g - b) / d + (g < b ? 6 : 0); break; - case g: h = (b - r) / d + 2; break; - case b: h = (r - g) / d + 4; break; + case r: + h = (g - b) / d + (g < b ? 6 : 0); + break; + case g: + h = (b - r) / d + 2; + break; + case b: + h = (r - g) / d + 4; + break; } h /= 6; } @@ -107,11 +113,16 @@ { function hue2rgb(p, q, t) { - if (t < 0) t += 1; - if (t > 1) t -= 1; - if (t < 1/6) return p + (q - p) * 6 * t; - if (t < 1/2) return q; - if (t < 2/3) return p + (q - p) * (2/3 - t) * 6; + if (t < 0) + t += 1; + if (t > 1) + t -= 1; + if (t < 1/6) + return p + (q - p) * 6 * t; + if (t < 1/2) + return q; + if (t < 2/3) + return p + (q - p) * (2/3 - t) * 6; return p; } Index: ps/trunk/binaries/data/mods/public/gui/common/colorFades.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/common/colorFades.js +++ ps/trunk/binaries/data/mods/public/gui/common/colorFades.js @@ -217,7 +217,7 @@ // check, if in blinking phase if (data.tickCounter < g_FadeAttackUnit.blinkingTicks) { - data.tickCounter = data.tickCounter % (g_FadeAttackUnit.blinkingChangeInterval * 2); + data.tickCounter %= g_FadeAttackUnit.blinkingChangeInterval * 2; return true; } return false; Index: ps/trunk/binaries/data/mods/public/gui/common/functions_civinfo.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/common/functions_civinfo.js +++ ps/trunk/binaries/data/mods/public/gui/common/functions_civinfo.js @@ -22,7 +22,7 @@ // Sanity check for (let prop of ["Code", "Culture", "Name", "Emblem", "History", "Music", "Factions", "CivBonuses", - "TeamBonuses", "Structures", "StartEntities", "Formations", "AINames","SelectableInGameSetup"]) + "TeamBonuses", "Structures", "StartEntities", "Formations", "AINames", "SelectableInGameSetup"]) if (data[prop] == undefined) error(filename + " doesn't contain " + prop); } Index: ps/trunk/binaries/data/mods/public/gui/common/functions_global_object.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/common/functions_global_object.js +++ ps/trunk/binaries/data/mods/public/gui/common/functions_global_object.js @@ -151,7 +151,7 @@ { let extendedSimState = Engine.GuiInterfaceCall("GetExtendedSimulationState"); return { - "timeElapsed" : extendedSimState.timeElapsed, + "timeElapsed": extendedSimState.timeElapsed, "playerStates": extendedSimState.players, "mapSettings": Engine.GetInitAttributes().settings }; Index: ps/trunk/binaries/data/mods/public/gui/common/functions_utility.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/common/functions_utility.js +++ ps/trunk/binaries/data/mods/public/gui/common/functions_utility.js @@ -18,12 +18,12 @@ for (var i = 0; i < files.length; ++i) { var file = files[i]; - file = file.substring(pathname.length, file.length-4); + file = file.substring(pathname.length, file.length - 4); // Split path into directories so we can check for beginning _ character var tokens = file.split("/"); - if (tokens[tokens.length-1][0] != "_") + if (tokens[tokens.length - 1][0] != "_") result.push(file); } @@ -34,21 +34,20 @@ { // Remove the path and extension from each name, since we just want the filename return Engine.BuildDirEntList(pathname, "*.json", false).map( - filename => filename.substring(pathname.length, filename.length-5)); + filename => filename.substring(pathname.length, filename.length - 5)); } // A sorting function for arrays of objects with 'name' properties, ignoring case function sortNameIgnoreCase(x, y) { - var lowerX = x.name.toLowerCase(); - var lowerY = y.name.toLowerCase(); + let lowerX = x.name.toLowerCase(); + let lowerY = y.name.toLowerCase(); if (lowerX < lowerY) return -1; - else if (lowerX > lowerY) + if (lowerX > lowerY) return 1; - else - return 0; + return 0; } /** @@ -126,12 +125,10 @@ function removeDupes(array) { // loop backwards to make splice operations cheaper - var i = array.length; + let i = array.length; while (i--) - { if (array.indexOf(array[i]) != i) array.splice(i, 1); - } } function singleplayerName() @@ -223,7 +220,7 @@ * * @param margin The gap, in px, between the objects */ -function horizontallySpaceObjects(parentName, margin=0) +function horizontallySpaceObjects(parentName, margin = 0) { let objects = Engine.GetGUIObjectByName(parentName).children; for (let i = 0; i < objects.length; ++i) Index: ps/trunk/binaries/data/mods/public/gui/common/functions_utility_loadsave.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/common/functions_utility_loadsave.js +++ ps/trunk/binaries/data/mods/public/gui/common/functions_utility_loadsave.js @@ -102,14 +102,14 @@ function deleteTooltip() { - let deleteTooltip = colorizeHotkey( + let tooltip = colorizeHotkey( translate("Delete the selected entry using %(hotkey)s."), "session.savedgames.delete"); - if (deleteTooltip) - deleteTooltip += colorizeHotkey( - "\n" + translate("Hold %(hotkey)s to delete without confirmation."), + if (tooltip) + tooltip += colorizeHotkey( + "\n" + translate("Hold %(hotkey)s to delete without confirmation."), "session.savedgames.noconfirmation"); - return deleteTooltip; + return tooltip; } Index: ps/trunk/binaries/data/mods/public/gui/common/gamedescription.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/common/gamedescription.js +++ ps/trunk/binaries/data/mods/public/gui/common/gamedescription.js @@ -67,7 +67,7 @@ function setMapPreviewImage(guiObject, filename) { Engine.GetGUIObjectByName(guiObject).sprite = - "cropped:" + 400/512 + "," + 300/512 + ":" + + "cropped:" + 400 / 512 + "," + 300 / 512 + ":" + "session/icons/mappreview/" + filename; } @@ -343,14 +343,14 @@ "value": g_GameAttributes.map == "random" ? translate("Randomly selects a map from the list") : - g_GameAttributes.settings.Description ? - translate(g_GameAttributes.settings.Description) : - translate("Sorry, no description available."), + g_GameAttributes.settings.Description ? + translate(g_GameAttributes.settings.Description) : + translate("Sorry, no description available.") }); if (g_GameAttributes.settings.Biome) { - let biome = g_Settings.Biomes.find(biome => biome.Id == g_GameAttributes.settings.Biome); + let biome = g_Settings.Biomes.find(b => b.Id == g_GameAttributes.settings.Biome); titles.push({ "label": translate("Biome"), "value": biome ? biome.Title : translateWithContext("biome", "Random") @@ -405,8 +405,7 @@ "label": "[color=\"" + g_DescriptionHighlight + "\"]" + title.label + ":" + "[/color]", "details": title.value === true ? translateWithContext("gamesetup option", "enabled") : - !title.value ? translateWithContext("gamesetup option", "disabled") : - title.value + title.value || translateWithContext("gamesetup option", "disabled") })).join("\n"); } Index: ps/trunk/binaries/data/mods/public/gui/common/music.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/common/music.js +++ ps/trunk/binaries/data/mods/public/gui/common/music.js @@ -21,21 +21,21 @@ this.RELATIVE_MUSIC_PATH = "audio/music/"; this.MUSIC = { - PEACE: "peace", - BATTLE: "battle", - VICTORY: "victory", - DEFEAT: "defeat" + "PEACE": "peace", + "BATTLE": "battle", + "VICTORY": "victory", + "DEFEAT": "defeat" }; this.resetTracks(); this.states = { - OFF : 0, - MENU : 1, - PEACE : 2, - BATTLE : 3, - VICTORY : 4, - DEFEAT : 5 + "OFF": 0, + "MENU": 1, + "PEACE": 2, + "BATTLE": 3, + "VICTORY": 4, + "DEFEAT": 5 }; this.musicGain = 0.3; @@ -61,9 +61,9 @@ "Tavern_in_the_Mist.ogg", "The_Road_Ahead.ogg" ], - BATTLE: ["Taiko_1.ogg", "Taiko_2.ogg"], - VICTORY : ["You_are_Victorious!.ogg"], - DEFEAT : ["Dried_Tears.ogg"] + "BATTLE": ["Taiko_1.ogg", "Taiko_2.ogg"], + "VICTORY": ["You_are_Victorious!.ogg"], + "DEFEAT": ["Dried_Tears.ogg"] }; }; @@ -107,7 +107,7 @@ break; default: - warn(sprintf("%(functionName)s: Unknown music state: %(state)s", { functionName: "Music.updateState()", state: this.currentState })); + warn(sprintf("%(functionName)s: Unknown music state: %(state)s", { "functionName": "Music.updateState()", "state": this.currentState })); break; } } @@ -116,21 +116,19 @@ Music.prototype.storeTracks = function(civMusic) { this.resetTracks(); - for (var music of civMusic) + for (let music of civMusic) { - var type = undefined; - for (var i in this.MUSIC) - { + let type; + for (let i in this.MUSIC) if (music.Type == this.MUSIC[i]) { type = i; break; } - } if (type === undefined) { - warn(sprintf("%(functionName)s: Unrecognized music type: %(musicType)s", { functionName: "Music.storeTracks()", musicType: music.Type })); + warn(sprintf("%(functionName)s: Unrecognized music type: %(musicType)s", { "functionName": "Music.storeTracks()", "musicType": music.Type })); continue; } @@ -141,10 +139,8 @@ Music.prototype.startPlayList = function(tracks, fadeInPeriod, isLooping) { Engine.ClearPlaylist(); - for (var i in tracks) - { - Engine.AddPlaylistItem( this.RELATIVE_MUSIC_PATH + tracks[i] ); - } + for (let i in tracks) + Engine.AddPlaylistItem(this.RELATIVE_MUSIC_PATH + tracks[i]); Engine.StartPlaylist(isLooping); }; Index: ps/trunk/binaries/data/mods/public/gui/common/settings.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/common/settings.js +++ ps/trunk/binaries/data/mods/public/gui/common/settings.js @@ -371,7 +371,7 @@ */ function translateMapSize(tiles) { - let mapSize = g_Settings.MapSizes.find(mapSize => mapSize.Tiles == +tiles); + let mapSize = g_Settings.MapSizes.find(size => size.Tiles == +tiles); return mapSize ? mapSize.Name : translateWithContext("map size", "Default"); } @@ -395,6 +395,6 @@ */ function translateVictoryCondition(gameType) { - let vc = g_Settings.VictoryConditions.find(vc => vc.Name == gameType); - return vc ? vc.Title : translateWithContext("victory condition", "Unknown"); + let victoryCondition = g_Settings.VictoryConditions.find(vc => vc.Name == gameType); + return victoryCondition ? victoryCondition.Title : translateWithContext("victory condition", "Unknown"); } Index: ps/trunk/binaries/data/mods/public/gui/common/timer.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/common/timer.js +++ ps/trunk/binaries/data/mods/public/gui/common/timer.js @@ -47,14 +47,13 @@ // (We do this in two stages to avoid deleting from the timer list while // we're in the middle of iterating through it) var run = []; - for (var id in g_Timers) - { + for (let id in g_Timers) if (g_Timers[id][0] <= g_Time) run.push(id); - } - for (var id of run) + + for (let id of run) { - var t = g_Timers[id]; + let t = g_Timers[id]; if (!t) continue; // an earlier timer might have cancelled this one, so skip it @@ -62,7 +61,7 @@ t[1](); } catch (e) { var stack = e.stack.trimRight().replace(/^/mg, ' '); // indent the stack trace - error(sprintf("Error in timer: %(error)s", { error: e })+"\n"+stack+"\n"); + error(sprintf("Error in timer: %(error)s", { "error": e }) + "\n" + stack + "\n"); } delete g_Timers[id]; } Index: ps/trunk/binaries/data/mods/public/gui/common/tooltips.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/common/tooltips.js +++ ps/trunk/binaries/data/mods/public/gui/common/tooltips.js @@ -433,9 +433,9 @@ types.push(resource.code + "." + subtype); let [rate, count] = types.reduce((sum, t) => { - let r = template.resourceGatherRates[t]; - return [sum[0] + (r > 0 ? r : 0), sum[1] + (r > 0 ? 1 : 0)]; - }, [0, 0]); + let r = template.resourceGatherRates[t]; + return [sum[0] + (r > 0 ? r : 0), sum[1] + (r > 0 ? 1 : 0)]; + }, [0, 0]); if (rate > 0) rates[resource.code] = +(rate / count).toFixed(1); Index: ps/trunk/binaries/data/mods/public/gui/credits/credits.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/credits/credits.js +++ ps/trunk/binaries/data/mods/public/gui/credits/credits.js @@ -71,6 +71,7 @@ else if (element.name) result += "[font=\"sans-14\"]" + element.name + "\n"; } + result += "\n"; } Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/gamesetup.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/gamesetup/gamesetup.js +++ ps/trunk/binaries/data/mods/public/gui/gamesetup/gamesetup.js @@ -896,7 +896,7 @@ !g_IsController ? g_ReadyData[g_IsReady].tooltip : !g_IsNetworked || Object.keys(g_PlayerAssignments).every(guid => - g_PlayerAssignments[guid].status || g_PlayerAssignments[guid].player == -1) ? + g_PlayerAssignments[guid].status || g_PlayerAssignments[guid].player == -1) ? translate("Start a new game with the current settings.") : translate("Start a new game with the current settings (disabled until all players are ready)"), "enabled": () => !g_IsController || @@ -1118,7 +1118,7 @@ function initDropdown(name, playerIdx) { let [guiName, guiType, guiIdx] = getGUIObjectNameFromSetting(name); - let idxName = playerIdx === undefined ? "": "[" + playerIdx + "]"; + let idxName = playerIdx === undefined ? "" : "[" + playerIdx + "]"; let data = (playerIdx === undefined ? g_Dropdowns : g_PlayerDropdowns)[name]; let dropdown = Engine.GetGUIObjectByName(guiName + guiType + guiIdx + idxName); @@ -1284,7 +1284,7 @@ Engine.SwitchGuiPage("page_loading.xml", { "attribs": g_GameAttributes, - "isNetworked" : g_IsNetworked, + "isNetworked": g_IsNetworked, "playerAssignments": g_PlayerAssignments, "isController": g_IsController }); @@ -1369,8 +1369,8 @@ return; } - let freeSlot = g_GameAttributes.settings.PlayerData.findIndex((v,i) => - Object.keys(g_PlayerAssignments).every(guid => g_PlayerAssignments[guid].player != i+1) + let freeSlot = g_GameAttributes.settings.PlayerData.findIndex((v, i) => + Object.keys(g_PlayerAssignments).every(guid => g_PlayerAssignments[guid].player != i + 1) ); // Client is not and cannot become assigned as player @@ -1702,11 +1702,10 @@ function unassignInvalidPlayers(maxPlayers) { if (g_IsNetworked) - { // Remove invalid playerIDs from the servers playerassignments copy for (let playerID = +maxPlayers + 1; playerID <= g_MaxPlayers; ++playerID) Engine.AssignNetworkPlayer(playerID, ""); - } + else if (g_PlayerAssignments.local.player > maxPlayers) g_PlayerAssignments.local.player = -1; } @@ -1770,7 +1769,7 @@ function updateGUIDropdown(name, playerIdx = undefined) { let [guiName, guiType, guiIdx] = getGUIObjectNameFromSetting(name); - let idxName = playerIdx === undefined ? "": "[" + playerIdx + "]"; + let idxName = playerIdx === undefined ? "" : "[" + playerIdx + "]"; let dropdown = Engine.GetGUIObjectByName(guiName + guiType + guiIdx + idxName); let label = Engine.GetGUIObjectByName(guiName + "Text" + guiIdx + idxName); @@ -1778,7 +1777,7 @@ let title = Engine.GetGUIObjectByName(guiName + "Title" + guiIdx + idxName); if (guiType == "Dropdown") - Engine.GetGUIObjectByName(guiName + "Checkbox" + guiIdx).hidden = true; + Engine.GetGUIObjectByName(guiName + "Checkbox" + guiIdx).hidden = true; let indexHidden = isControlArrayElementHidden(playerIdx); let obj = (playerIdx === undefined ? g_Dropdowns : g_PlayerDropdowns)[name]; @@ -1823,7 +1822,7 @@ let title = Engine.GetGUIObjectByName(guiName + "Title" + guiIdx); if (guiType == "Checkbox") - Engine.GetGUIObjectByName(guiName + "Dropdown" + guiIdx).hidden = true; + Engine.GetGUIObjectByName(guiName + "Dropdown" + guiIdx).hidden = true; checkbox.checked = checked; checkbox.enabled = enabled; @@ -1842,7 +1841,7 @@ function updateGUIMiscControl(name, playerIdx) { - let idxName = playerIdx === undefined ? "": "[" + playerIdx + "]"; + let idxName = playerIdx === undefined ? "" : "[" + playerIdx + "]"; let obj = (playerIdx === undefined ? g_MiscControls : g_PlayerMiscElements)[name]; let control = Engine.GetGUIObjectByName(name + idxName); @@ -1923,7 +1922,11 @@ // Count how many players use the chosenName let usedName = g_GameAttributes.settings.PlayerData.filter(pData => pData.Name && pData.Name.indexOf(chosenName) !== -1).length; - g_GameAttributes.settings.PlayerData[i].Name = !usedName ? chosenName : sprintf(translate("%(playerName)s %(romanNumber)s"), { "playerName": chosenName, "romanNumber": g_RomanNumbers[usedName+1] }); + g_GameAttributes.settings.PlayerData[i].Name = !usedName ? chosenName : + sprintf(translate("%(playerName)s %(romanNumber)s"), { + "playerName": chosenName, + "romanNumber": g_RomanNumbers[usedName+1] + }); } // Copy playernames for the purpose of replays @@ -1952,9 +1955,9 @@ let playerID = -1; for (let i in g_GameAttributes.settings.PlayerData) { - let assignBox = Engine.GetGUIObjectByName("playerAssignment["+i+"]"); + let assignBox = Engine.GetGUIObjectByName("playerAssignment[" + i + "]"); if (assignBox.list_data[assignBox.selected] == "guid:local") - playerID = +i+1; + playerID = +i + 1; } Engine.StartGame(g_GameAttributes, playerID); @@ -2123,7 +2126,7 @@ "ai": translate(ai.data.name) }), "Color": g_PlayerAssignmentColors.AI - })); + })); let unassignedSlot = [{ "Choice": "unassigned", @@ -2224,7 +2227,7 @@ color = rgbToGuiColor({ "r": r, "g": g, "b": b }); } - return '[color="'+ color +'"]' + username + '[/color]'; + return '[color="' + color + '"]' + username + '[/color]'; } function addChatMessage(msg) Index: ps/trunk/binaries/data/mods/public/gui/gamesetup_mp/gamesetup_mp.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/gamesetup_mp/gamesetup_mp.js +++ ps/trunk/binaries/data/mods/public/gui/gamesetup_mp/gamesetup_mp.js @@ -160,7 +160,6 @@ // the game setup screen, so perform similar processing to gamesetup.js // in this screen if (g_IsRejoining) - { switch (message.type) { case "netstatus": @@ -186,7 +185,6 @@ break; case "start": - // Copy playernames from initial player assignment to the settings for (let guid in g_PlayerAssignments) { @@ -197,8 +195,8 @@ Engine.SwitchGuiPage("page_loading.xml", { "attribs": g_GameAttributes, - "isNetworked" : true, - "isRejoining" : g_IsRejoining, + "isNetworked": true, + "isRejoining": g_IsRejoining, "playerAssignments": g_PlayerAssignments }); break; @@ -212,9 +210,7 @@ default: error("Unrecognised net message type: " + message.type); } - } else - { // Not rejoining - just trying to connect to server switch (message.type) @@ -233,16 +229,13 @@ g_IsRejoining = true; return; // we'll process the game setup messages in the next tick } - else - { - Engine.SwitchGuiPage("page_gamesetup.xml", { - "type": g_GameType, - "serverName": g_ServerName, - "serverPort": g_ServerPort, - "stunEndpoint": g_StunEndpoint - }); - return; // don't process any more messages - leave them for the game GUI loop - } + Engine.SwitchGuiPage("page_gamesetup.xml", { + "type": g_GameType, + "serverName": g_ServerName, + "serverPort": g_ServerPort, + "stunEndpoint": g_StunEndpoint + }); + return; // don't process any more messages - leave them for the game GUI loop case "disconnected": cancelSetup(); @@ -262,14 +255,13 @@ error("Unrecognised net message type: " + message.type); break; } - } } } function switchSetupPage(newPage) { for (let page of Engine.GetGUIObjectByName("multiplayerPages").children) - if (page.name.substr(0,4) == "page") + if (page.name.substr(0, 4) == "page") page.hidden = true; Engine.GetGUIObjectByName(newPage).hidden = false; Index: ps/trunk/binaries/data/mods/public/gui/loading/loading.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/loading/loading.js +++ ps/trunk/binaries/data/mods/public/gui/loading/loading.js @@ -21,15 +21,15 @@ let index = tipText.indexOf("\n"); let tipTextTitle = tipText.substring(0, index); let tipTextMessage = tipText.substring(index); - Engine.GetGUIObjectByName("tipTitle").caption = tipTextTitle? tipTextTitle : ""; - Engine.GetGUIObjectByName("tipText").caption = tipTextMessage? tipTextMessage : ""; + Engine.GetGUIObjectByName("tipTitle").caption = tipTextTitle ? tipTextTitle : ""; + Engine.GetGUIObjectByName("tipText").caption = tipTextMessage ? tipTextMessage : ""; } // Set tip image - let fileName = tipTextFilePath.substring(tipTextFilePath.lastIndexOf("/")+1).replace(".txt", ".png"); + let fileName = tipTextFilePath.substring(tipTextFilePath.lastIndexOf("/") + 1).replace(".txt", ".png"); let tipImageFilePath = "loading/tips/" + fileName; let sprite = "stretched:" + tipImageFilePath; - Engine.GetGUIObjectByName("tipImage").sprite = sprite? sprite : ""; + Engine.GetGUIObjectByName("tipImage").sprite = sprite ? sprite : ""; } else error("Failed to find any matching tips for the loading screen."); Index: ps/trunk/binaries/data/mods/public/gui/lobby/lobby.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/lobby/lobby.js +++ ps/trunk/binaries/data/mods/public/gui/lobby/lobby.js @@ -48,7 +48,7 @@ "unknown": { "color": "178 178 178", "status": translateWithContext("lobby presence", "Unknown") } }; - var g_RoleNames = { +var g_RoleNames = { "moderator": translate("Moderator"), "participant": translate("Player"), "visitor": translate("Muted Player") @@ -421,8 +421,8 @@ // Keep filters right above the according column let playersNumberFilter = Engine.GetGUIObjectByName("playersNumberFilter"); let size = playersNumberFilter.size; - size.rleft = gameRating ? 74: 90; - size.rright = gameRating ? 84: 100; + size.rleft = gameRating ? 74 : 90; + size.rright = gameRating ? 84 : 100; playersNumberFilter.size = size; } @@ -447,7 +447,7 @@ mapTypeFilter.list = [translateWithContext("map", "Any")].concat(g_MapTypes.Title); mapTypeFilter.list_data = [""].concat(g_MapTypes.Name); - let gameRatingOptions = ["<1000", "<1100","<1200",">1200",">1300",">1400",">1500"].reverse(); + let gameRatingOptions = [">1500", ">1400", ">1300", ">1200", "<1200", "<1100", "<1000"]; gameRatingOptions = prepareForDropdown(gameRatingOptions.map(r => ({ "value": r, "label": sprintf( @@ -880,7 +880,7 @@ { list_name.push(boardList[i].name); list_rating.push(boardList[i].rating); - list_rank.push(+i+1); + list_rank.push(+i + 1); list.push(boardList[i].name); } @@ -1042,7 +1042,7 @@ sgGameStartTime.caption = sprintf( // Translation: %(time)s is the hour and minute here. translate("Game started at %(time)s"), { - "time": Engine.FormatMillisecondsIntoDateStringLocal(+game.startTime*1000, translate("HH:mm")) + "time": Engine.FormatMillisecondsIntoDateStringLocal(+game.startTime * 1000, translate("HH:mm")) }); sgNbPlayers.caption = sprintf( @@ -1299,7 +1299,7 @@ let idx = string.indexOf(' '); if (idx != -1) - return [string.substr(1,idx-1), string.substr(idx+1)]; + return [string.substr(1, idx - 1), string.substr(idx + 1)]; return [string.substr(1), ""]; } @@ -1415,7 +1415,7 @@ "time": senderFont(timePrefixString), "message": formattedMessage }); - } +} /** * Generate a (mostly) unique color for this player based on their name. @@ -1453,8 +1453,8 @@ translate("%(nick)s (%(rating)s)"), { "nick": playername, "rating": rating - }) : - playername) + '[/color]'; + }) : playername + ) + '[/color]'; } function senderFont(text) Index: ps/trunk/binaries/data/mods/public/gui/locale/locale.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/locale/locale.js +++ ps/trunk/binaries/data/mods/public/gui/locale/locale.js @@ -54,8 +54,8 @@ function openAdvancedMenu() { - var localeText = Engine.GetGUIObjectByName("localeText"); - Engine.PushGuiPage("page_locale_advanced.xml", { "callback": "applyFromAdvancedMenu", "locale": localeText.caption } ); + let localeText = Engine.GetGUIObjectByName("localeText"); + Engine.PushGuiPage("page_locale_advanced.xml", { "callback": "applyFromAdvancedMenu", "locale": localeText.caption }); } function applyFromAdvancedMenu(locale) Index: ps/trunk/binaries/data/mods/public/gui/locale/locale_advanced.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/locale/locale_advanced.js +++ ps/trunk/binaries/data/mods/public/gui/locale/locale_advanced.js @@ -1,17 +1,17 @@ function init(initData) { - var languageList = Engine.GetGUIObjectByName("languageList"); - var countryList = Engine.GetGUIObjectByName("countryList"); - var resultingLocaleText = Engine.GetGUIObjectByName("resultingLocale"); - var scriptInput = Engine.GetGUIObjectByName("scriptInput"); + let languageList = Engine.GetGUIObjectByName("languageList"); + let countryList = Engine.GetGUIObjectByName("countryList"); + let resultingLocaleText = Engine.GetGUIObjectByName("resultingLocale"); + let scriptInput = Engine.GetGUIObjectByName("scriptInput"); // get languageList data. Only list languages for which we have a dictionary. - var languageListData = []; - var languageListTmp = Engine.GetSupportedLocaleBaseNames(); - var currentLocaleLanguage = Engine.GetLocaleLanguage(initData.locale); - for (var i=0; i { dictionaryFileString = dictionaryFileString + entry + "\n"; }); dictionaryFile.caption = dictionaryFileString; - var acceptButton = Engine.GetGUIObjectByName("acceptButton"); acceptButton.enabled = true; } else { resultingLocaleText.caption = translate("invalid locale"); dictionaryFile.caption = ""; - var acceptButton = Engine.GetGUIObjectByName("acceptButton"); acceptButton.enabled = false; } } @@ -109,7 +107,7 @@ var locale = Engine.GetDictionaryLocale(""); languageList.selected = languageList.list_data.indexOf(Engine.GetLocaleLanguage(locale)); - countryList.selected = countryList.selected = countryList.list_data.indexOf(Engine.GetLocaleCountry(locale)); + countryList.selected = countryList.list_data.indexOf(Engine.GetLocaleCountry(locale)); scriptInput.caption = Engine.GetLocaleScript(locale); } Index: ps/trunk/binaries/data/mods/public/gui/manual/manual.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/manual/manual.js +++ ps/trunk/binaries/data/mods/public/gui/manual/manual.js @@ -14,7 +14,7 @@ { return function() openURL(url); - }(data.url) + }(data.url); urlButton.onPress = callback; urlButton.hidden = false; } Index: ps/trunk/binaries/data/mods/public/gui/msgbox/msgbox.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/msgbox/msgbox.js +++ ps/trunk/binaries/data/mods/public/gui/msgbox/msgbox.js @@ -27,9 +27,9 @@ // Set button captions and visibility let mbButton = []; captions.forEach((caption, i) => { - mbButton[i] = Engine.GetGUIObjectByName("mbButton" + (i+1)); + mbButton[i] = Engine.GetGUIObjectByName("mbButton" + (i + 1)); - let action = function () + let action = function() { if (data.callback) Engine.PopGuiPageCB(i); Index: ps/trunk/binaries/data/mods/public/gui/options/options.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/options/options.js +++ ps/trunk/binaries/data/mods/public/gui/options/options.js @@ -84,8 +84,8 @@ "sanitizeValue": (value, control, option) => { let sanitized = Math.min(option.max !== undefined ? option.max : +Infinity, - Math.max(option.min !== undefined ? option.min : -Infinity, - isNaN(+value) ? 0 : value)); + Math.max(option.min !== undefined ? option.min : -Infinity, + isNaN(+value) ? 0 : value)); control.sprite = sanitized == value ? "ModernDarkBoxWhite" : "ModernDarkBoxWhiteInvalid"; @@ -353,7 +353,7 @@ return; } - reallySaveChanges() + reallySaveChanges(); } function reallySaveChanges() @@ -369,15 +369,12 @@ function closePage() { if (Engine.ConfigDB_HasChanges("user")) - { messageBox( 500, 200, translate("You have unsaved changes, do you want to close this window?"), translate("Warning"), [translate("No"), translate("Yes")], - [null, closePageWithoutConfirmation] - ); - } + [null, closePageWithoutConfirmation]); else closePageWithoutConfirmation(); } Index: ps/trunk/binaries/data/mods/public/gui/pregame/backgrounds/hellenes.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/pregame/backgrounds/hellenes.js +++ ps/trunk/binaries/data/mods/public/gui/pregame/backgrounds/hellenes.js @@ -6,12 +6,12 @@ "tiling": true, }, { - "offset": (time, width) => 0.12 * width * Math.cos(0.05 * time) - width/10, + "offset": (time, width) => 0.12 * width * Math.cos(0.05 * time) - width / 10, "sprite": "background-hellenes1-2", "tiling": false, }, { - "offset": (time, width) => 0.16 * width * Math.cos(0.05 * time) + width/4, + "offset": (time, width) => 0.16 * width * Math.cos(0.05 * time) + width / 4, "sprite": "background-hellenes1-3", "tiling": false, }, Index: ps/trunk/binaries/data/mods/public/gui/pregame/backgrounds/seleucid.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/pregame/backgrounds/seleucid.js +++ ps/trunk/binaries/data/mods/public/gui/pregame/backgrounds/seleucid.js @@ -11,7 +11,7 @@ "tiling": true, }, { - "offset": (time, width) => 0.17 * width * Math.cos(0.05 * time) + width/8, + "offset": (time, width) => 0.17 * width * Math.cos(0.05 * time) + width / 8, "sprite": "background-seleucid1_3", "tiling": false, }, Index: ps/trunk/binaries/data/mods/public/gui/pregame/mainmenu.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/pregame/mainmenu.js +++ ps/trunk/binaries/data/mods/public/gui/pregame/mainmenu.js @@ -33,7 +33,7 @@ g_BackgroundLayerset = pickRandom(g_BackgroundLayerData); for (let i = 0; i < g_BackgroundLayerset.length; ++i) { - let guiObj = Engine.GetGUIObjectByName("background["+i+"]"); + let guiObj = Engine.GetGUIObjectByName("background[" + i + "]"); guiObj.hidden = false; guiObj.sprite = g_BackgroundLayerset[i].sprite; guiObj.z = i; @@ -49,7 +49,7 @@ { for (let i = 0; i < g_BackgroundLayerset.length; ++i) { - let guiObj = Engine.GetGUIObjectByName("background["+i+"]"); + let guiObj = Engine.GetGUIObjectByName("background[" + i + "]"); let screen = guiObj.parent.getComputedSize(); let h = screen.bottom - screen.top; @@ -96,8 +96,7 @@ let httpCode = d[1]; if (httpCode == 200) return translate("upload succeeded"); - else - return sprintf(translate("upload failed (%(errorCode)s)"), { "errorCode": httpCode }); + return sprintf(translate("upload failed (%(errorCode)s)"), { "errorCode": httpCode }); } if (d[0] == "failed") @@ -131,7 +130,7 @@ if (Engine.ConfigDB_GetValue("user", "gui.splashscreen.enable") === "true" || Engine.ConfigDB_GetValue("user", "gui.splashscreen.version") < Engine.GetFileMTime("gui/splashscreen/splashscreen.txt")) - Engine.PushGuiPage("page_splashscreen.xml", { "page": "splashscreen", callback : "SplashScreenClosedCallback" } ); + Engine.PushGuiPage("page_splashscreen.xml", { "page": "splashscreen", "callback": "SplashScreenClosedCallback" }); else ShowRenderPathMessage(); } Index: ps/trunk/binaries/data/mods/public/gui/prelobby/prelobby.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/prelobby/prelobby.js +++ ps/trunk/binaries/data/mods/public/gui/prelobby/prelobby.js @@ -210,9 +210,7 @@ { // First hide everything. if (!Engine.GetGUIObjectByName("pageWelcome").hidden) - { Engine.GetGUIObjectByName("pageWelcome").hidden = true; - } else if (!Engine.GetGUIObjectByName("pageRegister").hidden) { Engine.GetGUIObjectByName("pageRegister").hidden = true; Index: ps/trunk/binaries/data/mods/public/gui/reference/common/core.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/reference/common/core.js +++ ps/trunk/binaries/data/mods/public/gui/reference/common/core.js @@ -162,7 +162,6 @@ } if (template.WallSet) - { for (let wSegm in template.WallSet.Templates) { let wEntities = getTemplateListsFromStructure(template.WallSet.Templates[wSegm]); @@ -170,7 +169,6 @@ if (templateLists.techs.indexOf(entity) === -1) templateLists.techs.push(entity); } - } return templateLists; } Index: ps/trunk/binaries/data/mods/public/gui/replaymenu/replay_actions.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/replaymenu/replay_actions.js +++ ps/trunk/binaries/data/mods/public/gui/replaymenu/replay_actions.js @@ -67,7 +67,7 @@ "attribs": Engine.GetReplayAttributes(replayDirectory), "isNetworked": false, "playerAssignments": { - "local":{ + "local": { "name": singleplayerName(), "player": -1 } Index: ps/trunk/binaries/data/mods/public/gui/replaymenu/replay_filters.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/replaymenu/replay_filters.js +++ ps/trunk/binaries/data/mods/public/gui/replaymenu/replay_filters.js @@ -2,14 +2,14 @@ * Allow to filter replays by duration in 15min / 30min intervals. */ var g_DurationFilterIntervals = [ - { "min": -1, "max": -1 }, - { "min": -1, "max": 15 }, - { "min": 15, "max": 30 }, - { "min": 30, "max": 45 }, - { "min": 45, "max": 60 }, - { "min": 60, "max": 90 }, - { "min": 90, "max": 120 }, - { "min": 120, "max": -1 } + { "min": -1, "max": -1 }, + { "min": -1, "max": 15 }, + { "min": 15, "max": 30 }, + { "min": 30, "max": 45 }, + { "min": 45, "max": 60 }, + { "min": 60, "max": 90 }, + { "min": 90, "max": 120 }, + { "min": 120, "max": -1 } ]; /** @@ -79,7 +79,7 @@ function initMapNameFilter(mapName) { var mapNameFilter = Engine.GetGUIObjectByName("mapNameFilter"); - mapNameFilter.list = [translateWithContext("map name", "Any")].concat(g_MapNames.map(mapName => translate(mapName))); + mapNameFilter.list = [translateWithContext("map name", "Any")].concat(g_MapNames.map(name => translate(name))); mapNameFilter.list_data = [""].concat(g_MapNames); if (mapName) @@ -152,7 +152,7 @@ function initVictoryConditionFilter(victoryCondition) { let victoryConditionFilter = Engine.GetGUIObjectByName("victoryConditionFilter"); - victoryConditionFilter.list = [translateWithContext("victory condition", "Any gametype")].concat(g_VictoryConditions.map(victoryCondition => translateVictoryCondition(victoryCondition))); + victoryConditionFilter.list = [translateWithContext("victory condition", "Any gametype")].concat(g_VictoryConditions.map(vc => translateVictoryCondition(vc))); victoryConditionFilter.list_data = [""].concat(g_VictoryConditions); if (victoryCondition) @@ -183,8 +183,7 @@ let sortKey = Engine.GetGUIObjectByName("replaySelection").selected_column; let sortOrder = Engine.GetGUIObjectByName("replaySelection").selected_column_order; - g_ReplaysFiltered = g_Replays.filter(replay => filterReplay(replay)).sort((a, b) => - { + g_ReplaysFiltered = g_Replays.filter(replay => filterReplay(replay)).sort((a, b) => { let cmpA, cmpB; switch (sortKey) { Index: ps/trunk/binaries/data/mods/public/gui/savedgames/load.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/savedgames/load.js +++ ps/trunk/binaries/data/mods/public/gui/savedgames/load.js @@ -22,16 +22,14 @@ let selectedGameId = gameSelection.list_data[gameSelection.selected]; // Save metadata for the detailed view - g_SavedGamesMetadata = savedGames.map(game => - { + g_SavedGamesMetadata = savedGames.map(game => { game.metadata.id = game.id; return game.metadata; }); let sortKey = gameSelection.selected_column; let sortOrder = gameSelection.selected_column_order; - g_SavedGamesMetadata = g_SavedGamesMetadata.sort((a, b) => - { + g_SavedGamesMetadata = g_SavedGamesMetadata.sort((a, b) => { let cmpA, cmpB; switch (sortKey) { @@ -149,7 +147,6 @@ let message = translate("This saved game may not be compatible:"); if (!sameEngineVersion) - { if (metadata.engine_version) message += "\n" + sprintf(translate("It needs 0 A.D. version %(requiredVersion)s, while you are running version %(currentVersion)s."), { "requiredVersion": metadata.engine_version, @@ -157,7 +154,6 @@ }); else message += "\n" + translate("It needs an older version of 0 A.D."); - } if (!sameSavegameVersion) message += "\n" + sprintf(translate("It needs 0 A.D. savegame version %(requiredVersion)s, while you have savegame version %(currentVersion)s."), { @@ -206,7 +202,7 @@ Engine.SwitchGuiPage("page_loading.xml", { "attribs": metadata.initAttributes, - "isNetworked" : false, + "isNetworked": false, "playerAssignments": { "local": { "name": pData ? pData.Name : singleplayerName(), Index: ps/trunk/binaries/data/mods/public/gui/session/menu.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/menu.js +++ ps/trunk/binaries/data/mods/public/gui/session/menu.js @@ -195,7 +195,7 @@ { closeOpenDialogs(); - let deleteSelectedEntities = function (selectionArg) + let deleteSelectedEntities = function(selectionArg) { Engine.PostNetworkCommand({ "type": "delete-entities", @@ -306,8 +306,8 @@ let height = chatHistory.getComputedSize().bottom - chatHistory.getComputedSize().top; let width = (1 + Math.sqrt(5)) / 2 * height; let size = chatDialogPanel.size; - size.left = -width/2 - chatHistory.size.left; - size.right = width/2 + chatHistory.size.left; + size.left = -width / 2 - chatHistory.size.left; + size.right = width / 2 + chatHistory.size.left; chatDialogPanel.size = size; } else @@ -415,34 +415,35 @@ function diplomacySetupTexts(i, rowsize) { // Apply offset - let row = Engine.GetGUIObjectByName("diplomacyPlayer["+(i-1)+"]"); + let row = Engine.GetGUIObjectByName("diplomacyPlayer[" + (i - 1) + "]"); let size = row.size; - size.top = rowsize * (i-1); + size.top = rowsize * (i - 1); size.bottom = rowsize * i; row.size = size; row.hidden = false; row.sprite = "color: " + rgbToGuiColor(g_Players[i].color) + " 32"; - setOutcomeIcon(g_Players[i].state, "diplomacyPlayerOutcome["+(i-1)+"]"); + setOutcomeIcon(g_Players[i].state, "diplomacyPlayerOutcome[" + (i - 1) + "]"); - Engine.GetGUIObjectByName("diplomacyPlayerName["+(i-1)+"]").caption = colorizePlayernameByID(i); - Engine.GetGUIObjectByName("diplomacyPlayerCiv["+(i-1)+"]").caption = g_CivData[g_Players[i].civ].Name; + Engine.GetGUIObjectByName("diplomacyPlayerName[" + (i - 1) + "]").caption = colorizePlayernameByID(i); + Engine.GetGUIObjectByName("diplomacyPlayerCiv[" + (i - 1) + "]").caption = g_CivData[g_Players[i].civ].Name; - Engine.GetGUIObjectByName("diplomacyPlayerTeam["+(i-1)+"]").caption = - g_Players[i].team < 0 ? translateWithContext("team", "None") : g_Players[i].team+1; + Engine.GetGUIObjectByName("diplomacyPlayerTeam[" + (i - 1) + "]").caption = + g_Players[i].team < 0 ? translateWithContext("team", "None") : g_Players[i].team + 1; - Engine.GetGUIObjectByName("diplomacyPlayerTheirs["+(i-1)+"]").caption = + Engine.GetGUIObjectByName("diplomacyPlayerTheirs[" + (i - 1) + "]").caption = i == g_ViewedPlayer ? "" : - g_Players[i].isAlly[g_ViewedPlayer] ? translate("Ally") : - g_Players[i].isNeutral[g_ViewedPlayer] ? translate("Neutral") : translate("Enemy"); + g_Players[i].isAlly[g_ViewedPlayer] ? + translate("Ally") : + g_Players[i].isNeutral[g_ViewedPlayer] ? translate("Neutral") : translate("Enemy"); } function diplomacyFormatStanceButtons(i, hidden) { for (let stance of ["Ally", "Neutral", "Enemy"]) { - let button = Engine.GetGUIObjectByName("diplomacyPlayer"+stance+"["+(i-1)+"]"); + let button = Engine.GetGUIObjectByName("diplomacyPlayer" + stance + "[" + (i - 1) + "]"); button.hidden = hidden; if (hidden) continue; @@ -467,16 +468,16 @@ let r = 0; for (let resCode of resCodes) { - let button = Engine.GetGUIObjectByName("diplomacyPlayer["+(i-1)+"]_tribute["+r+"]"); + let button = Engine.GetGUIObjectByName("diplomacyPlayer[" + (i - 1) + "]_tribute[" + r + "]"); if (!button) { warn("Current GUI limits prevent displaying more than " + r + " tribute buttons!"); break; } - Engine.GetGUIObjectByName("diplomacyPlayer["+(i-1)+"]_tribute["+r+"]_image").sprite = "stretched:session/icons/resources/"+resCode+".png"; + Engine.GetGUIObjectByName("diplomacyPlayer[" + (i - 1) + "]_tribute[" + r + "]_image").sprite = "stretched:session/icons/resources/" + resCode + ".png"; button.hidden = hidden; - setPanelObjectPosition(button, r, r+1, 0); + setPanelObjectPosition(button, r, r + 1, 0); ++r; if (hidden) continue; @@ -505,7 +506,7 @@ // This is in a closure so that we have access to `player`, `amounts`, and `multiplier` without some // evil global variable hackery. g_FlushTributing = function() { - Engine.PostNetworkCommand({ "type": "tribute", "player": i, "amounts": amounts }); + Engine.PostNetworkCommand({ "type": "tribute", "player": i, "amounts": amounts }); multiplier = 1; button.tooltip = formatTributeTooltip(i, resCode, 100); }; @@ -519,7 +520,7 @@ function diplomacyFormatAttackRequestButton(i, hidden) { - let button = Engine.GetGUIObjectByName("diplomacyAttackRequest["+(i-1)+"]"); + let button = Engine.GetGUIObjectByName("diplomacyAttackRequest[" + (i - 1) + "]"); button.hidden = hidden; if (hidden) return; @@ -533,7 +534,7 @@ function diplomacyFormatSpyRequestButton(i, hidden) { - let button = Engine.GetGUIObjectByName("diplomacySpyRequest["+(i-1)+"]"); + let button = Engine.GetGUIObjectByName("diplomacySpyRequest[" + (i - 1) + "]"); let template = GetTemplateData("special/spy"); button.hidden = hidden || !template || GetSimState().players[g_ViewedPlayer].disabledTemplates["special/spy"]; if (button.hidden) @@ -583,13 +584,13 @@ if (neededResources) { if (button.enabled) - modifier = resourcesToAlphaMask(neededResources) +":"; + modifier = resourcesToAlphaMask(neededResources) + ":"; button.enabled = false; tooltips.push(getNeededResourcesTooltip(neededResources)); } } } - let icon = Engine.GetGUIObjectByName("diplomacySpyRequestImage["+(i-1)+"]"); + let icon = Engine.GetGUIObjectByName("diplomacySpyRequestImage[" + (i - 1) + "]"); icon.sprite = modifier + "stretched:session/icons/bribes.png"; button.tooltip = tooltips.filter(tip => tip).join("\n"); button.onPress = (function(i, button) { return function() { @@ -659,34 +660,34 @@ // Barter: barterOpenCommon(resCode, i, "barter"); - setPanelObjectPosition(barterResource, i, i+1); + setPanelObjectPosition(barterResource, i, i + 1); // Trade: - let tradeResource = Engine.GetGUIObjectByName("tradeResource["+i+"]"); + let tradeResource = Engine.GetGUIObjectByName("tradeResource[" + i + "]"); if (!tradeResource) { warn("Current GUI limits prevent displaying more than " + i + " resources in the trading goods selection dialog!"); break; } - setPanelObjectPosition(tradeResource, i, i+1); + setPanelObjectPosition(tradeResource, i, i + 1); - let icon = Engine.GetGUIObjectByName("tradeResourceIcon["+i+"]"); + let icon = Engine.GetGUIObjectByName("tradeResourceIcon[" + i + "]"); icon.sprite = "stretched:session/icons/resources/" + resCode + ".png"; - let buttonUp = Engine.GetGUIObjectByName("tradeArrowUp["+i+"]"); - let buttonDn = Engine.GetGUIObjectByName("tradeArrowDn["+i+"]"); + let buttonUp = Engine.GetGUIObjectByName("tradeArrowUp[" + i + "]"); + let buttonDn = Engine.GetGUIObjectByName("tradeArrowDn[" + i + "]"); button[resCode] = { "up": buttonUp, "dn": buttonDn, - "label": Engine.GetGUIObjectByName("tradeResourceText["+i+"]"), - "sel": Engine.GetGUIObjectByName("tradeResourceSelection["+i+"]") + "label": Engine.GetGUIObjectByName("tradeResourceText[" + i + "]"), + "sel": Engine.GetGUIObjectByName("tradeResourceSelection[" + i + "]") }; proba[resCode] = proba[resCode] || 0; - let buttonResource = Engine.GetGUIObjectByName("tradeResourceButton["+i+"]"); + let buttonResource = Engine.GetGUIObjectByName("tradeResourceButton[" + i + "]"); buttonResource.enabled = controlsPlayer(g_ViewedPlayer); buttonResource.onPress = (resource => { return () => { @@ -695,7 +696,7 @@ for (let res of resCodes) proba[res] = 0; proba[resource] = 100; - Engine.PostNetworkCommand({"type": "set-trading-goods", "tradingGoods": proba}); + Engine.PostNetworkCommand({ "type": "set-trading-goods", "tradingGoods": proba }); } currTradeSelection = resource; updateTradeButtons(); @@ -707,7 +708,7 @@ return () => { proba[resource] += Math.min(STEP, proba[currTradeSelection]); proba[currTradeSelection] -= Math.min(STEP, proba[currTradeSelection]); - Engine.PostNetworkCommand({"type": "set-trading-goods", "tradingGoods": proba}); + Engine.PostNetworkCommand({ "type": "set-trading-goods", "tradingGoods": proba }); updateTradeButtons(); }; })(resCode); @@ -717,7 +718,7 @@ return () => { proba[currTradeSelection] += Math.min(STEP, proba[resource]); proba[resource] -= Math.min(STEP, proba[resource]); - Engine.PostNetworkCommand({"type": "set-trading-goods", "tradingGoods": proba}); + Engine.PostNetworkCommand({ "type": "set-trading-goods", "tradingGoods": proba }); updateTradeButtons(); }; })(resCode); @@ -857,11 +858,11 @@ "active": { "garrisoned": { "no-inactive": translate("%(openingTradingString)s, and %(garrisonedString)s."), - "inactive": translate("%(openingTradingString)s, %(garrisonedString)s, and %(inactiveString)s.") + "inactive": translate("%(openingTradingString)s, %(garrisonedString)s, and %(inactiveString)s.") }, "no-garrisoned": { "no-inactive": translate("%(openingTradingString)s."), - "inactive": translate("%(openingTradingString)s, and %(inactiveString)s.") + "inactive": translate("%(openingTradingString)s, and %(inactiveString)s.") } }, "no-active": { @@ -887,31 +888,33 @@ { "numberTrading": active } ); - let inactiveString = sprintf(active || garrisoned ? - translatePlural( - "%(numberOfLandTraders)s inactive", - "%(numberOfLandTraders)s inactive", - inactive - ) : - translatePlural( - "%(numberOfLandTraders)s land trader inactive", - "%(numberOfLandTraders)s land traders inactive", - inactive - ), + let inactiveString = sprintf( + active || garrisoned ? + translatePlural( + "%(numberOfLandTraders)s inactive", + "%(numberOfLandTraders)s inactive", + inactive + ) : + translatePlural( + "%(numberOfLandTraders)s land trader inactive", + "%(numberOfLandTraders)s land traders inactive", + inactive + ), { "numberOfLandTraders": inactive } ); - let garrisonedString = sprintf(active || inactive ? - translatePlural( - "%(numberGarrisoned)s garrisoned on a trading merchant ship", - "%(numberGarrisoned)s garrisoned on a trading merchant ship", - garrisoned - ) : - translatePlural( - "There is %(numberGarrisoned)s land trader garrisoned on a trading merchant ship", - "There are %(numberGarrisoned)s land traders garrisoned on a trading merchant ship", - garrisoned - ), + let garrisonedString = sprintf( + active || inactive ? + translatePlural( + "%(numberGarrisoned)s garrisoned on a trading merchant ship", + "%(numberGarrisoned)s garrisoned on a trading merchant ship", + garrisoned + ) : + translatePlural( + "There is %(numberGarrisoned)s land trader garrisoned on a trading merchant ship", + "There are %(numberGarrisoned)s land traders garrisoned on a trading merchant ship", + garrisoned + ), { "numberGarrisoned": garrisoned } ); @@ -950,17 +953,18 @@ { "numberTrading": active } ); - let inactiveString = sprintf(active ? - translatePlural( - "%(numberOfShipTraders)s inactive", - "%(numberOfShipTraders)s inactive", - inactive - ) : - translatePlural( - "%(numberOfShipTraders)s merchant ship inactive", - "%(numberOfShipTraders)s merchant ships inactive", - inactive - ), + let inactiveString = sprintf( + active ? + translatePlural( + "%(numberOfShipTraders)s inactive", + "%(numberOfShipTraders)s inactive", + inactive + ) : + translatePlural( + "%(numberOfShipTraders)s merchant ship inactive", + "%(numberOfShipTraders)s merchant ships inactive", + inactive + ), { "numberOfShipTraders": inactive } ); @@ -1001,7 +1005,7 @@ gameSpeed.onSelectionChange = function() { changeGameSpeed(+this.list_data[this.selected]); }; -}; +} function toggleGameSpeed() { @@ -1060,10 +1064,10 @@ Engine.PushGuiPage("page_summary.xml", { "sim": { "mapSettings": g_GameAttributes.settings, - "playerStates":extendedSimState.players.filter((state,player) => + "playerStates": extendedSimState.players.filter((state, player) => g_IsObserver || player == 0 || player == g_ViewedPlayer || extendedSimState.players[g_ViewedPlayer].hasSharedLos && g_Players[player].isMutualAlly[g_ViewedPlayer]), - "timeElapsed" : extendedSimState.timeElapsed + "timeElapsed": extendedSimState.timeElapsed }, "gui": { "isInGame": true @@ -1079,7 +1083,7 @@ // TODO add info about researched techs and unlocked entities Engine.PushGuiPage("page_structree.xml", { - "civ" : g_Players[g_ViewedPlayer].civ, + "civ": g_Players[g_ViewedPlayer].civ, "callback": "resumeGame", }); } Index: ps/trunk/binaries/data/mods/public/gui/session/messages.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/messages.js +++ ps/trunk/binaries/data/mods/public/gui/session/messages.js @@ -435,9 +435,7 @@ Engine.CameraMoveTo(targetState.position.x, targetState.position.z); } else if (cmd.type == "delete-entities" && notification.position) - { Engine.CameraMoveTo(notification.position.x, notification.position.y); - } // Focus commanded entities, but don't lose previous focus when training units else if (cmd.type != "train" && cmd.type != "research" && entState) setCameraFollow(cmd.entities[0]); @@ -466,7 +464,7 @@ let cheats = {}; for (let fileName of getJSONFileList("simulation/data/cheats/")) { - let currentCheat = Engine.ReadJSONFile("simulation/data/cheats/"+fileName+".json"); + let currentCheat = Engine.ReadJSONFile("simulation/data/cheats/" + fileName + ".json"); if (!currentCheat) continue; if (Object.keys(cheats).indexOf(currentCheat.Name) !== -1) @@ -489,7 +487,7 @@ return false; // Find the cheat code that is a prefix of the user input - let cheatCode = Object.keys(g_Cheats).find(cheatCode => text.indexOf(cheatCode) == 0); + let cheatCode = Object.keys(g_Cheats).find(code => text.indexOf(code) == 0); if (!cheatCode) return false; @@ -555,7 +553,7 @@ let tutorialText = Engine.GetGUIObjectByName("tutorialText"); tutorialText.caption = tutorialText.caption.replace('[color="yellow"]', '').replace('[/color]', '') + - (tutorialText.caption ? "\n" : "" ) + + (tutorialText.caption ? "\n" : "") + '[color="yellow"]' + notification.instructions.reduce((instructions, item) => instructions + translate(item), "") + '[/color]'; @@ -584,7 +582,7 @@ */ function updateTimeNotifications() { - let notifications = Engine.GuiInterfaceCall("GetTimeNotifications", g_ViewedPlayer); + let notifications = Engine.GuiInterfaceCall("GetTimeNotifications", g_ViewedPlayer); let notificationText = ""; for (let n of notifications) { @@ -689,7 +687,6 @@ if (msg.turn > 1 && g_GameAttributes.settings.PlayerData.some(pData => pData && pData.AI)) txt.push(translateWithContext("Out-Of-Sync", "Rejoining Multiplayer games with AIs is not supported yet!")); else - { txt.push( translateWithContext("Out-Of-Sync", "Ensure all players use the same mods."), translateWithContext("Out-Of-Sync", 'Click on "Report a Bug" in the main menu to help fix this.'), @@ -700,7 +697,6 @@ "filepath": escapeText(msg.path_oos_dump) }) ); - } messageBox( 600, 280, @@ -1016,7 +1012,7 @@ (g_IsObserver || g_GameAttributes.settings.LockTeams && g_Players[msg.sourcePlayer].isMutualAlly[Engine.GetPlayerID()] && g_Players[msg.targetPlayer].isMutualAlly[Engine.GetPlayerID()])) - message = translate("%(player)s has sent %(player2)s %(amounts)s."); + message = translate("%(player)s has sent %(player2)s %(amounts)s."); return sprintf(message, { "player": colorizePlayernameByID(msg.sourcePlayer), @@ -1049,8 +1045,8 @@ return ""; let message = msg.targetIsDomesticAnimal ? - translate("Your livestock has been attacked by %(attacker)s!") : - translate("You have been attacked by %(attacker)s!"); + translate("Your livestock has been attacked by %(attacker)s!") : + translate("You have been attacked by %(attacker)s!"); return sprintf(message, { "attacker": colorizePlayernameByID(msg.attacker) @@ -1221,7 +1217,7 @@ */ function sendDialogAnswer(guiObject, dialogName) { - Engine.GetGUIObjectByName(dialogName+"-dialog").hidden = true; + Engine.GetGUIObjectByName(dialogName + "-dialog").hidden = true; Engine.PostNetworkCommand({ "type": "dialog-answer", Index: ps/trunk/binaries/data/mods/public/gui/session/placement.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/placement.js +++ ps/trunk/binaries/data/mods/public/gui/session/placement.js @@ -3,7 +3,7 @@ this.Reset(); } -PlacementSupport.DEFAULT_ANGLE = Math.PI*3/4; +PlacementSupport.DEFAULT_ANGLE = Math.PI * 3 / 4; /** * Resets the building placement support state. Use this to cancel construction of an entity. @@ -25,8 +25,8 @@ this.attack = null; - Engine.GuiInterfaceCall("SetBuildingPlacementPreview", {"template": ""}); - Engine.GuiInterfaceCall("SetWallPlacementPreview", {"wallSet": null}); + Engine.GuiInterfaceCall("SetBuildingPlacementPreview", { "template": "" }); + Engine.GuiInterfaceCall("SetWallPlacementPreview", { "wallSet": null }); }; PlacementSupport.prototype.SetDefaultAngle = function() Index: ps/trunk/binaries/data/mods/public/gui/session/selection.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/selection.js +++ ps/trunk/binaries/data/mods/public/gui/session/selection.js @@ -9,24 +9,24 @@ function _setHighlight(ents, alpha, selected) { if (ents.length) - Engine.GuiInterfaceCall("SetSelectionHighlight", { "entities":ents, "alpha":alpha, "selected":selected }); + Engine.GuiInterfaceCall("SetSelectionHighlight", { "entities": ents, "alpha": alpha, "selected": selected }); } function _setStatusBars(ents, enabled) { if (ents.length) - Engine.GuiInterfaceCall("SetStatusBars", { "entities":ents, "enabled":enabled }); + Engine.GuiInterfaceCall("SetStatusBars", { "entities": ents, "enabled": enabled }); } function _setMotionOverlay(ents, enabled) { if (ents.length) - Engine.GuiInterfaceCall("SetMotionDebugOverlay", { "entities":ents, "enabled":enabled }); + Engine.GuiInterfaceCall("SetMotionDebugOverlay", { "entities": ents, "enabled": enabled }); } function _playSound(ent) { - Engine.GuiInterfaceCall("PlaySound", { "name":"select", "entity":ent }); + Engine.GuiInterfaceCall("PlaySound", { "name": "select", "entity": ent }); } /** @@ -114,8 +114,8 @@ EntityGroups.prototype.getKeys = function() { - //Preserve order even when shuffling units around - //Can be optimized by moving the sorting elsewhere + // Preserve order even when shuffling units around + // Can be optimized by moving the sorting elsewhere return Object.keys(this.groups).sort(); }; @@ -261,13 +261,11 @@ // Reconstruct the selection if at least one entity has been renamed. for (let renamedEntity of renamedEntities) - { if (this.selected[renamedEntity.entity]) { this.rebuildSelection(renamedLookup); - break; + return; } - } } }; @@ -330,14 +328,12 @@ var removed = []; for (let ent of ents) - { if (this.selected[ent]) { this.groups.removeEnt(ent); removed.push(ent); delete this.selected[ent]; } - } _setHighlight(removed, 0, false); _setStatusBars(removed, false); @@ -434,8 +430,8 @@ g_Selection.isSelection = true; var g_canMoveIntoFormation = {}; -var g_allBuildableEntities = undefined; -var g_allTrainableEntities = undefined; +var g_allBuildableEntities; +var g_allTrainableEntities; // Reset cached quantities function onSelectionChange() @@ -445,7 +441,6 @@ g_allTrainableEntities = undefined; } - /** * EntityGroupsContainer class for managing grouped entities */ @@ -494,14 +489,12 @@ for (let group of this.groups) for (let renamedEntity of renamedEntities) - { // Reconstruct the group if at least one entity has been renamed. if (renamedEntity.entity in group.ents) { group.rebuildGroup(renamedLookup); break; } - } } }; Index: ps/trunk/binaries/data/mods/public/gui/session/selection_details.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/selection_details.js +++ ps/trunk/binaries/data/mods/public/gui/session/selection_details.js @@ -46,7 +46,7 @@ { let healthBarGarrison = Engine.GetGUIObjectByName("healthBarGarrison"); let healthSize = healthBarGarrison.size; - healthSize.rtop = 100-100*Math.max(0, Math.min(1, totalGarrisonHealth / maxGarrisonHealth)); + healthSize.rtop = 100 - 100 * Math.max(0, Math.min(1, totalGarrisonHealth / maxGarrisonHealth)); healthBarGarrison.size = healthSize; healthGarrison.tooltip = getCurrentHealthTooltip({ @@ -109,7 +109,7 @@ { let unitHealthBar = Engine.GetGUIObjectByName("healthBar"); let healthSize = unitHealthBar.size; - healthSize.rright = 100*Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints)); + healthSize.rright = 100 * Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints)); unitHealthBar.size = healthSize; if (entState.foundation && entState.visibility == "visible" && entState.foundation.numBuilders !== 0 && entState.buildTime) @@ -144,15 +144,15 @@ if (entState.capturePoints) { let setCaptureBarPart = function(playerID, startSize) { - let unitCaptureBar = Engine.GetGUIObjectByName("captureBar["+playerID+"]"); + let unitCaptureBar = Engine.GetGUIObjectByName("captureBar[" + playerID + "]"); let sizeObj = unitCaptureBar.size; sizeObj.rleft = startSize; - let size = 100*Math.max(0, Math.min(1, entState.capturePoints[playerID] / entState.maxCapturePoints)); + let size = 100 * Math.max(0, Math.min(1, entState.capturePoints[playerID] / entState.maxCapturePoints)); sizeObj.rright = startSize + size; unitCaptureBar.size = sizeObj; unitCaptureBar.sprite = "color: " + rgbToGuiColor(g_Players[playerID].color, 128); - unitCaptureBar.hidden=false; + unitCaptureBar.hidden = false; return startSize + size; }; @@ -169,7 +169,7 @@ }); let showSmallCapture = showResource && showHealth; - Engine.GetGUIObjectByName("captureStats").caption = showSmallCapture ? "": captureText; + Engine.GetGUIObjectByName("captureStats").caption = showSmallCapture ? "" : captureText; Engine.GetGUIObjectByName("capture").tooltip = showSmallCapture ? captureText : ""; } @@ -209,7 +209,7 @@ let resourceSize = unitResourceBar.size; resourceSize.rright = entState.resourceSupply.isInfinite ? 100 : - 100 * Math.max(0, Math.min(1, +entState.resourceSupply.amount / +entState.resourceSupply.max)); + 100 * Math.max(0, Math.min(1, +entState.resourceSupply.amount / +entState.resourceSupply.max)); unitResourceBar.size = resourceSize; Engine.GetGUIObjectByName("resourceLabel").caption = sprintf(translate("%(resource)s:"), { @@ -227,7 +227,7 @@ Engine.GetGUIObjectByName("resourceCarryingIcon").hidden = false; Engine.GetGUIObjectByName("resourceCarryingText").hidden = false; - Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/resources/"+carried.type+".png"; + Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/resources/" + carried.type + ".png"; Engine.GetGUIObjectByName("resourceCarryingText").caption = sprintf(translate("%(amount)s / %(max)s"), { "amount": carried.amount, "max": carried.max }); Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = ""; } @@ -236,7 +236,7 @@ { Engine.GetGUIObjectByName("resourceCarryingIcon").hidden = false; Engine.GetGUIObjectByName("resourceCarryingText").hidden = false; - Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/resources/"+entState.trader.goods.type+".png"; + Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/resources/" + entState.trader.goods.type + ".png"; let totalGain = entState.trader.goods.amount.traderGain; if (entState.trader.goods.amount.market1Gain) totalGain += entState.trader.goods.amount.market1Gain; @@ -299,7 +299,7 @@ "genericName": genericName }); - let isGaia = "gaia" == playerState.civ; + let isGaia = playerState.civ == "gaia"; Engine.GetGUIObjectByName("playerCivIcon").sprite = isGaia ? "" : "stretched:grayscale:" + civEmblem; Engine.GetGUIObjectByName("player").tooltip = isGaia ? "" : civName; @@ -383,7 +383,7 @@ { let unitHealthBar = Engine.GetGUIObjectByName("healthBarMultiple"); let healthSize = unitHealthBar.size; - healthSize.rtop = 100-100*Math.max(0, Math.min(1, averageHealth / maxHealth)); + healthSize.rtop = 100 - 100 * Math.max(0, Math.min(1, averageHealth / maxHealth)); unitHealthBar.size = healthSize; Engine.GetGUIObjectByName("healthMultiple").tooltip = getCurrentHealthTooltip({ @@ -395,16 +395,16 @@ Engine.GetGUIObjectByName("captureMultiple").hidden = maxCapturePoints <= 0; if (maxCapturePoints > 0) { - let setCaptureBarPart = function(playerID, startSize) + let setCaptureBarPart = function(pID, startSize) { - let unitCaptureBar = Engine.GetGUIObjectByName("captureBarMultiple["+playerID+"]"); + let unitCaptureBar = Engine.GetGUIObjectByName("captureBarMultiple[" + pID + "]"); let sizeObj = unitCaptureBar.size; sizeObj.rtop = startSize; - let size = 100*Math.max(0, Math.min(1, capturePoints[playerID] / maxCapturePoints)); + let size = 100 * Math.max(0, Math.min(1, capturePoints[pID] / maxCapturePoints)); sizeObj.rbottom = startSize + size; unitCaptureBar.size = sizeObj; - unitCaptureBar.sprite = "color: " + rgbToGuiColor(g_Players[playerID].color, 128); + unitCaptureBar.sprite = "color: " + rgbToGuiColor(g_Players[pID].color, 128); unitCaptureBar.hidden = false; return startSize + size; }; @@ -417,7 +417,8 @@ // last handle the owner's points, to keep those points on the bottom for clarity setCaptureBarPart(playerID, size); - Engine.GetGUIObjectByName("captureMultiple").tooltip = getCurrentHealthTooltip({ + Engine.GetGUIObjectByName("captureMultiple").tooltip = getCurrentHealthTooltip( + { "hitpoints": capturePoints[playerID], "maxHitpoints": maxCapturePoints }, Index: ps/trunk/binaries/data/mods/public/gui/session/selection_panels.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/selection_panels.js +++ ps/trunk/binaries/data/mods/public/gui/session/selection_panels.js @@ -166,9 +166,10 @@ // count on square buttons, so size.bottom is the width too let spacer = size.bottom + 1; // relative to the center ( = 50%) - size.rleft = size.rright = 50; + size.rleft = 50; + size.rright = 50; // offset from the center calculation - size.left = (data.i - data.numberOfItems/2) * spacer; + size.left = (data.i - data.numberOfItems / 2) * spacer; size.right = size.left + size.bottom; data.button.size = size; return true; @@ -185,7 +186,6 @@ { let commands = []; for (let command in g_AllyEntityCommands) - { for (let state of unitEntStates) { let info = g_AllyEntityCommands[command].getInfo(state); @@ -196,7 +196,6 @@ break; } } - } return commands; }, "setupButton": function(data) @@ -221,9 +220,10 @@ // count on square buttons, so size.bottom is the width too let spacer = size.bottom + 1; // relative to the center ( = 50%) - size.rleft = size.rright = 50; + size.rleft = 50; + size.rright = 50; // offset from the center calculation - size.left = (data.i - data.numberOfItems/2) * spacer; + size.left = (data.i - data.numberOfItems / 2) * spacer; size.right = size.left + size.bottom; data.button.size = size; @@ -258,7 +258,7 @@ "player": data.player }); - data.button.onPress = function () { startBuildingPlacement(data.item, data.playerState); }; + data.button.onPress = function() { startBuildingPlacement(data.item, data.playerState); }; let tooltips = [ getEntityNamesFormatted, @@ -287,7 +287,7 @@ else if (neededResources) { data.button.enabled = false; - modifier += resourcesToAlphaMask(neededResources) +":"; + modifier += resourcesToAlphaMask(neededResources) + ":"; } else data.button.enabled = controlsPlayer(data.player); @@ -398,8 +398,7 @@ data.button.enabled = canUngarrison && controlsPlayer(g_ViewedPlayer); let tooltip = canUngarrison || g_IsObserver ? - sprintf(translate("Unload %(name)s"), - { "name": getEntityNames(template) }) + "\n" + + sprintf(translate("Unload %(name)s"), { "name": getEntityNames(template) }) + "\n" + translate("Single-click to unload 1. Shift-click to unload all of this type.") : getEntityNames(template); @@ -433,27 +432,23 @@ { let gates = []; for (let state of unitEntStates) - { if (state.gate && !gates.length) - { gates.push({ "gate": state.gate, "tooltip": translate("Lock Gate"), "locked": true, - "callback": function (item) { lockGate(item.locked); } + "callback": function(item) { lockGate(item.locked); } }, { "gate": state.gate, "tooltip": translate("Unlock Gate"), "locked": false, - "callback": function (item) { lockGate(item.locked); } + "callback": function(item) { lockGate(item.locked); } }); - } // Show both 'locked' and 'unlocked' as active if the selected gates have both lock states. else if (state.gate && state.gate.locked != gates[0].gate.locked) for (let j = 0; j < gates.length; ++j) delete gates[j].gate.locked; - } return gates; }, @@ -503,13 +498,10 @@ else checks.packButton = true; } + else if (state.pack.packed) + checks.unpackCancelButton = true; else - { - if (state.pack.packed) - checks.unpackCancelButton = true; - else - checks.packCancelButton = true; - } + checks.packCancelButton = true; } let items = []; @@ -605,7 +597,7 @@ let size = panel.size; let buttonSize = Engine.GetGUIObjectByName("unitQueueButton[0]").size.bottom; let margin = 4; - size.top = size.bottom - numRows*buttonSize - (numRows+2)*margin; + size.top = size.bottom - numRows * buttonSize - (numRows + 2) * margin; panel.size = size; }, "setupButton": function(data) @@ -644,7 +636,7 @@ Engine.GetGUIObjectByName("queueTimeRemaining").caption = Engine.FormatMillisecondsIntoDateStringGMT(queuedItem.timeRemaining, translateWithContext("countdown format", "m:ss")); - let guiObject = Engine.GetGUIObjectByName("unitQueueProgressSlider["+data.i+"]"); + let guiObject = Engine.GetGUIObjectByName("unitQueueProgressSlider[" + data.i + "]"); let size = guiObject.size; // Buttons are assumed to be square, so left/right offsets can be used for top/bottom. @@ -692,7 +684,7 @@ item.tech.top == tech.top) && Object.keys(item.techCostMultiplier).every( k => item.techCostMultiplier[k] == state.production.techCostMultiplier[k]) - )); + )); if (filteredTechs.length + ret.length <= this.getMaxNumberOfItems() && getNumberOfRightPanelButtons() <= this.getMaxNumberOfItems() * (filteredTechs.some(tech => !!tech.pair) ? 1 : 2)) @@ -810,7 +802,7 @@ tooltips.push(getNeededResourcesTooltip(neededResources)); button.tooltip = tooltips.filter(tip => tip).join("\n"); - button.onPress = function () { + button.onPress = function() { addResearchToQueue(data.item.researchFacilityId, tech); }; @@ -820,10 +812,10 @@ let otherPosition = (position + data.rowLength) % (2 * data.rowLength); let unchosenIcon = Engine.GetGUIObjectByName("unitResearchUnchosenIcon[" + otherPosition + "]"); button.onMouseEnter = function() { - unchosenIcon.hidden = false; + unchosenIcon.hidden = false; }; button.onMouseLeave = function() { - unchosenIcon.hidden = true; + unchosenIcon.hidden = true; }; } @@ -1047,13 +1039,13 @@ else if (neededResources) { data.button.enabled = false; - modifier = resourcesToAlphaMask(neededResources) +":"; + modifier = resourcesToAlphaMask(neededResources) + ":"; } else data.button.enabled = controlsPlayer(data.player); if (template.icon) - data.icon.sprite = modifier + "stretched:session/portraits/" + template.icon; + data.icon.sprite = modifier + "stretched:session/portraits/" + template.icon; let index = data.i + getNumberOfRightPanelButtons(); setPanelObjectPosition(data.button, index, data.rowLength); @@ -1075,7 +1067,7 @@ return unitEntStates[0].upgrade && unitEntStates[0].upgrade.upgrades; }, - "setupButton" : function(data) + "setupButton": function(data) { let template = GetTemplateData(data.item.entity); if (!template) @@ -1137,7 +1129,6 @@ let modifier = ""; if (!isUpgrading) - { if (progress || !technologyEnabled || limits.canBeAddedCount == 0 && !hasSameRestrictionCategory(data.item.entity, data.unitEntStates[0].template)) { @@ -1149,7 +1140,6 @@ data.button.enabled = false; modifier = resourcesToAlphaMask(neededResources) + ":"; } - } data.icon.sprite = modifier + "stretched:session/" + (data.item.icon || "portraits/" + template.icon); Index: ps/trunk/binaries/data/mods/public/gui/session/selection_panels_helpers.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/selection_panels_helpers.js +++ ps/trunk/binaries/data/mods/public/gui/session/selection_panels_helpers.js @@ -136,17 +136,14 @@ if (totalBatchTrainingCount < 2) return ""; - var fullBatchesString = ""; - if (buildingsCountToTrainFullBatch > 0) - { - if (buildingsCountToTrainFullBatch > 1) - fullBatchesString = sprintf(translate("%(buildings)s*%(batchSize)s"), { - "buildings": buildingsCountToTrainFullBatch, - "batchSize": fullBatchSize - }); - else - fullBatchesString = fullBatchSize; - } + let fullBatchesString = ""; + if (buildingsCountToTrainFullBatch > 1) + fullBatchesString = sprintf(translate("%(buildings)s*%(batchSize)s"), { + "buildings": buildingsCountToTrainFullBatch, + "batchSize": fullBatchSize + }); + else if (buildingsCountToTrainFullBatch == 1) + fullBatchesString = fullBatchSize; // We need to display the batch details part if there is either more than // one building with full batch or one building with the full batch and @@ -154,12 +151,10 @@ let batchString; if (buildingsCountToTrainFullBatch > 1 || buildingsCountToTrainFullBatch == 1 && remainderBatch > 0) - { if (remainderBatch > 0) batchString = translate("%(action)s to train %(number)s (%(fullBatch)s + %(remainderBatch)s)."); else batchString = translate("%(action)s to train %(number)s (%(fullBatch)s)."); - } else batchString = translate("%(action)s to train %(number)s."); Index: ps/trunk/binaries/data/mods/public/gui/session/session.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/session.js +++ ps/trunk/binaries/data/mods/public/gui/session/session.js @@ -206,7 +206,7 @@ if (g_EntityStates[entId]) for (let name of Object.getOwnPropertyNames(g_EntityStates[entId])) if (typeof prop == 'object' && prop !== null) - deepfreeze(g_EntityStates[entId][name]) + deepfreeze(g_EntityStates[entId][name]); } return g_EntityStates[entId]; @@ -276,11 +276,8 @@ Engine.GetGUIObjectByName("gameSpeedButton").hidden = g_IsNetworked; } - else // Needed for autostart loading option - { - if (g_IsReplay) - g_PlayerAssignments.local.player = -1; - } + else if (g_IsReplay)// Needed for autostart loading option + g_PlayerAssignments.local.player = -1; updatePlayerData(); @@ -329,8 +326,8 @@ // // DISABLED: this information isn't currently useful for anything much, // and it generates a massive amount of data to transmit and store - //setTimeout(function() { reportPerformance(5); }, 5000); - //setTimeout(function() { reportPerformance(60); }, 60000); + // setTimeout(function() { reportPerformance(5); }, 5000); + // setTimeout(function() { reportPerformance(60); }, 60000); } function updatePlayerData() @@ -418,7 +415,7 @@ let button = Engine.GetGUIObjectByName("panelEntityButton[" + slot + "]"); button.onPress = function() { - let panelEnt = g_PanelEntities.find(panelEnt => panelEnt.slot !== undefined && panelEnt.slot == slot); + let panelEnt = g_PanelEntities.find(ent => ent.slot !== undefined && ent.slot == slot); if (!panelEnt) return; @@ -429,7 +426,7 @@ }; button.onDoublePress = function() { - let panelEnt = g_PanelEntities.find(panelEnt => panelEnt.slot !== undefined && panelEnt.slot == slot); + let panelEnt = g_PanelEntities.find(ent => ent.slot !== undefined && ent.slot == slot); if (panelEnt) selectAndMoveTo(getEntityOrHolder(panelEnt.ent)); }; @@ -600,13 +597,13 @@ let r = 0; for (let res of resCodes) { - if (!Engine.GetGUIObjectByName("resource["+r+"]")) + if (!Engine.GetGUIObjectByName("resource[" + r + "]")) { warn("Current GUI limits prevent displaying more than " + r + " resources in the top panel!"); break; } - Engine.GetGUIObjectByName("resource["+r+"]_icon").sprite = "stretched:session/icons/resources/" + res + ".png"; - Engine.GetGUIObjectByName("resource["+r+"]").hidden = !isPlayer; + Engine.GetGUIObjectByName("resource[" + r + "]_icon").sprite = "stretched:session/icons/resources/" + res + ".png"; + Engine.GetGUIObjectByName("resource[" + r + "]").hidden = !isPlayer; ++r; } horizontallySpaceObjects("resourceCounts", 5); @@ -614,7 +611,7 @@ let resPop = Engine.GetGUIObjectByName("population"); let resPopSize = resPop.size; - resPopSize.left = Engine.GetGUIObjectByName("resource["+ (r-1) +"]").size.right; + resPopSize.left = Engine.GetGUIObjectByName("resource[" + (r - 1) + "]").size.right; resPop.size = resPopSize; Engine.GetGUIObjectByName("population").hidden = !isPlayer; @@ -782,9 +779,9 @@ function hasIdleWorker() { return Engine.GuiInterfaceCall("HasIdleUnits", { - "viewedPlayer": g_ViewedPlayer, - "idleClasses": g_WorkerTypes, - "excludeUnits": [] + "viewedPlayer": g_ViewedPlayer, + "idleClasses": g_WorkerTypes, + "excludeUnits": [] }); } @@ -944,7 +941,7 @@ return; let healthSize = statusBar.size; - let value = 100*Math.max(0, Math.min(1, points / maxPoints)); + let value = 100 * Math.max(0, Math.min(1, points / maxPoints)); // inverse bar if (direction == 2 || direction == 3) @@ -976,7 +973,7 @@ let panelEntState = GetExtendedEntityState(ent); let template = GetTemplateData(panelEntState.template); - let panelEnt = g_PanelEntities.find(panelEnt => ent == panelEnt.ent); + let panelEnt = g_PanelEntities.find(pEnt => ent == pEnt.ent); if (!panelEnt) { @@ -1023,7 +1020,7 @@ buttons.forEach((button, slot) => { - if (button.hidden || g_PanelEntities.some(panelEnt => panelEnt.slot !== undefined && panelEnt.slot == slot)) + if (button.hidden || g_PanelEntities.some(ent => ent.slot !== undefined && ent.slot == slot)) return; button.hidden = true; @@ -1069,8 +1066,7 @@ g_Groups.update(); // Determine the sum of the costs of a given template - let getCostSum = (ent) => - { + let getCostSum = (ent) => { let cost = GetTemplateData(GetEntityState(ent).template).cost; return cost ? Object.keys(cost).map(key => cost[key]).reduce((sum, cur) => sum + cur) : 0; }; @@ -1079,7 +1075,7 @@ { Engine.GetGUIObjectByName("unitGroupLabel[" + i + "]").caption = i; - let button = Engine.GetGUIObjectByName("unitGroupButton["+i+"]"); + let button = Engine.GetGUIObjectByName("unitGroupButton[" + i + "]"); button.hidden = g_Groups.groups[i].getTotalCount() == 0; button.onpress = (function(i) { return function() { performGroup((Engine.HotkeyIsPressed("selection.add") ? "add" : "select"), i); }; })(i); button.ondoublepress = (function(i) { return function() { performGroup("snap", i); }; })(i); @@ -1127,7 +1123,7 @@ let template = GetTemplateData(entState.template); text += "\n\nentity: {\n"; for (let k in entState) - text += " "+k+":"+uneval(entState[k])+"\n"; + text += " " + k + ":" + uneval(entState[k]) + "\n"; text += "}\n\ntemplate: " + uneval(template); } } @@ -1141,22 +1137,18 @@ let ret = ""; for (let player in playersState) - { if (player != 0 && player != g_ViewedPlayer && g_Players[player].state != "defeated" && (g_IsObserver || playersState[g_ViewedPlayer].hasSharedLos && g_Players[player].isMutualAlly[g_ViewedPlayer])) - { - ret += "\n" + sprintf(translate("%(playername)s: %(statValue)s"),{ + ret += "\n" + sprintf(translate("%(playername)s: %(statValue)s"), { "playername": colorizePlayernameHelper("■", player) + " " + g_Players[player].name, "statValue": resource == "pop" ? sprintf(translate("%(popCount)s/%(popLimit)s/%(popMax)s"), playersState[player]) : Math.round(playersState[player].resourceCounts[resource]) }); - } - } return ret; } @@ -1187,7 +1179,7 @@ resourceObj.tooltip = tooltip; - Engine.GetGUIObjectByName("resource["+r+"]_count").caption = Math.floor(playerState.resourceCounts[res]); + Engine.GetGUIObjectByName("resource[" + r + "]_count").caption = Math.floor(playerState.resourceCounts[res]); } Engine.GetGUIObjectByName("resourcePop").caption = sprintf(translate("%(popCount)s/%(popLimit)s"), playerState); @@ -1334,7 +1326,6 @@ highlighted.push(g_Selection.highlighted[ent]); if (g_ShowGuarding) - { // flag the guarding entities to add in this additional highlight for (let sel in g_Selection.selected) { @@ -1346,10 +1337,8 @@ if (highlighted.indexOf(ent) == -1 && entsAdd.indexOf(ent) == -1) entsAdd.push(ent); } - } if (g_ShowGuarded) - { // flag the guarded entities to add in this additional highlight for (let sel in g_Selection.selected) { @@ -1360,7 +1349,6 @@ if (highlighted.indexOf(ent) == -1 && entsAdd.indexOf(ent) == -1) entsAdd.push(ent); } - } // flag the entities to remove (from the previously added) from this additional highlight for (let ent of g_AdditionalHighlight) @@ -1627,7 +1615,7 @@ playerStatistics.economyScore += total + ","; playerStatistics.militaryScore += Math.round((player.sequences.enemyUnitsKilledValue[maxIndex] + - player.sequences.enemyBuildingsDestroyedValue[maxIndex]) / 10) + ","; + player.sequences.enemyBuildingsDestroyedValue[maxIndex]) / 10) + ","; playerStatistics.totalScore += (total + Math.round((player.sequences.enemyUnitsKilledValue[maxIndex] + player.sequences.enemyBuildingsDestroyedValue[maxIndex]) / 10)) + ","; @@ -1651,24 +1639,23 @@ reportObject.militaryScore = playerStatistics.militaryScore; reportObject.totalScore = playerStatistics.totalScore; for (let rct of resourcesCounterTypes) - { for (let rt of resourcesTypes) - reportObject[rt+rct.substr(9)] = playerStatistics[rct][rt]; + reportObject[rt + rct.substr(9)] = playerStatistics[rct][rt]; // eg. rt = food rct.substr = Gathered rct = resourcesGathered - } + reportObject.vegetarianFoodGathered = playerStatistics.resourcesGathered.vegetarianFood; for (let type of unitsClasses) { // eg. type = Infantry (type.substr(0,1)).toLowerCase()+type.substr(1) = infantry - reportObject[(type.substr(0,1)).toLowerCase()+type.substr(1)+"UnitsTrained"] = playerStatistics.unitsTrained[type]; - reportObject[(type.substr(0,1)).toLowerCase()+type.substr(1)+"UnitsLost"] = playerStatistics.unitsLost[type]; - reportObject["enemy"+type+"UnitsKilled"] = playerStatistics.enemyUnitsKilled[type]; + reportObject[(type.substr(0, 1)).toLowerCase() + type.substr(1) + "UnitsTrained"] = playerStatistics.unitsTrained[type]; + reportObject[(type.substr(0, 1)).toLowerCase() + type.substr(1) + "UnitsLost"] = playerStatistics.unitsLost[type]; + reportObject["enemy" + type + "UnitsKilled"] = playerStatistics.enemyUnitsKilled[type]; } for (let type of buildingsClasses) { - reportObject[(type.substr(0,1)).toLowerCase()+type.substr(1)+"BuildingsConstructed"] = playerStatistics.buildingsConstructed[type]; - reportObject[(type.substr(0,1)).toLowerCase()+type.substr(1)+"BuildingsLost"] = playerStatistics.buildingsLost[type]; - reportObject["enemy"+type+"BuildingsDestroyed"] = playerStatistics.enemyBuildingsDestroyed[type]; + reportObject[(type.substr(0, 1)).toLowerCase() + type.substr(1) + "BuildingsConstructed"] = playerStatistics.buildingsConstructed[type]; + reportObject[(type.substr(0, 1)).toLowerCase() + type.substr(1) + "BuildingsLost"] = playerStatistics.buildingsLost[type]; + reportObject["enemy" + type + "BuildingsDestroyed"] = playerStatistics.enemyBuildingsDestroyed[type]; } for (let type of misc) reportObject[type] = playerStatistics[type]; Index: ps/trunk/binaries/data/mods/public/gui/session/unit_actions.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/unit_actions.js +++ ps/trunk/binaries/data/mods/public/gui/session/unit_actions.js @@ -266,7 +266,7 @@ "target": target }; }, - "preSelectedActionCheck" : function(target) + "preSelectedActionCheck": function(target) { if (preSelectedAction != ACTION_PATROL || !getActionInfo("patrol", target).possible) return false; @@ -357,7 +357,7 @@ return { "possible": true }; }, - "preSelectedActionCheck" : function(target) + "preSelectedActionCheck": function(target) { if (preSelectedAction != ACTION_REPAIR) return false; @@ -569,7 +569,7 @@ break; case "set second": - if (tradingDetails.gain.traderGain == 0) // markets too close + if (tradingDetails.gain.traderGain == 0) // markets too close return false; tooltip = translate("Right-click to set as destination trade market.") + "\n" + @@ -650,7 +650,7 @@ if (preSelectedAction != ACTION_GARRISON) return false; - let actionInfo = getActionInfo("garrison", target); + let actionInfo = getActionInfo("garrison", target); if (!actionInfo.possible) return { "type": "none", @@ -710,7 +710,7 @@ return { "possible": true }; }, - "preSelectedActionCheck" : function(target) + "preSelectedActionCheck": function(target) { if (preSelectedAction != ACTION_GUARD) return false; @@ -890,9 +890,9 @@ tooltip = translate("Right-click to establish a default route for new traders.") + "\n" + sprintf( trader ? - translate("Gain: %(gain)s") : - translate("Expected gain: %(gain)s"), - { "gain": getTradingTooltip(gain) }); + translate("Gain: %(gain)s") : + translate("Expected gain: %(gain)s"), + { "gain": getTradingTooltip(gain) }); } } else if ((targetState.needsRepair || targetState.foundation) && playerCheck(entState, targetState, ["Ally"])) @@ -913,11 +913,9 @@ if (!Engine.HotkeyIsPressed("session.autorallypoint") || !targetState.production || !targetState.production.entities.length) - { for (let ent in g_Selection.selected) if (targetState.id == +ent) return false; - } return { "possible": true, @@ -1374,12 +1372,11 @@ { let playerState = GetSimState().players[entState.player]; for (let player of validPlayers) - { if (player == "Gaia" && targetState.player == 0 || player == "Player" && targetState.player == entState.player || - playerState["is"+player] && playerState["is"+player][targetState.player]) + playerState["is" + player] && playerState["is" + player][targetState.player]) return true; - } + return false; } Index: ps/trunk/binaries/data/mods/public/gui/session/unit_commands.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/unit_commands.js +++ ps/trunk/binaries/data/mods/public/gui/session/unit_commands.js @@ -12,7 +12,7 @@ "Command": 0, "AllyCommand": 0, "Stance": 0, - "Gate":0, + "Gate": 0, "Pack": 0, "Upgrade": 0 }; @@ -106,7 +106,7 @@ if (g_SelectionPanels[guiName].hideItem) g_SelectionPanels[guiName].hideItem(i, rowLength); else - Engine.GetGUIObjectByName("unit"+guiName+"Button["+i+"]").hidden = true; + Engine.GetGUIObjectByName("unit" + guiName + "Button[" + i + "]").hidden = true; g_unitPanelButtons[guiName] = numberOfItems; g_SelectionPanels[guiName].used = true; @@ -182,12 +182,12 @@ // Get all of the available entities which can be trained by the selected entities function getAllTrainableEntities(selection) { - var trainableEnts = []; - var state; + let trainableEnts = []; // Get all buildable and trainable entities for (let ent of selection) { - if ((state = GetEntityState(ent)) && state.production && state.production.entities.length) + let state = GetEntityState(ent); + if (state && state.production && state.production.entities.length) trainableEnts = trainableEnts.concat(state.production.entities); } Index: ps/trunk/binaries/data/mods/public/gui/summary/layout.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/summary/layout.js +++ ps/trunk/binaries/data/mods/public/gui/summary/layout.js @@ -219,7 +219,7 @@ { for (let h = 0; h < g_MaxHeadingTitle; ++h) { - Engine.GetGUIObjectByName("titleHeading["+ h +"]").hidden = true; + Engine.GetGUIObjectByName("titleHeading[" + h + "]").hidden = true; Engine.GetGUIObjectByName("Heading[" + h + "]").hidden = true; for (let p = 0; p < g_MaxPlayers; ++p) { @@ -263,7 +263,7 @@ if (titleHeadings[th].xOffset) left += titleHeadings[th].xOffset; - let headerGUI = Engine.GetGUIObjectByName("titleHeading["+ th +"]"); + let headerGUI = Engine.GetGUIObjectByName("titleHeading[" + th + "]"); headerGUI.caption = titleHeadings[th].caption; headerGUI.size = left + " " + titleHeadings[th].yStart + " " + (left + titleHeadings[th].width) + " 100%"; headerGUI.hidden = false; @@ -343,9 +343,9 @@ yStart += 30 + g_Teams[i].length * (g_PlayerBoxYSize + g_PlayerBoxGap) + 32; - Engine.GetGUIObjectByName("teamNameHeadingt["+i+"]").caption = "Team " + (+i + 1); + Engine.GetGUIObjectByName("teamNameHeadingt[" + i + "]").caption = "Team " + (+i + 1); - let teamHeading = Engine.GetGUIObjectByName("teamHeadingt["+i+"]"); + let teamHeading = Engine.GetGUIObjectByName("teamHeadingt[" + i + "]"); let yStartTotal = 30 + g_Teams[i].length * (g_PlayerBoxYSize + g_PlayerBoxGap) + 10; teamHeading.size = "50 " + yStartTotal + " 100% " + (yStartTotal + 20); teamHeading.caption = translate("Team total"); Index: ps/trunk/binaries/data/mods/public/gui/summary/summary.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/summary/summary.js +++ ps/trunk/binaries/data/mods/public/gui/summary/summary.js @@ -12,7 +12,7 @@ "green": "201 255 200", "red": "255 213 213", "yellow": "255 255 157" -} +}; /** * Colors, captions and format used for units, buildings, etc. types @@ -161,7 +161,9 @@ ); } - [0, 1].forEach(i => Engine.GetGUIObjectByName("chart[" + i + "]").series_color = player_colors); + [0, 1].forEach(i => { + Engine.GetGUIObjectByName("chart[" + i + "]").series_color = player_colors; + }); let chartLegend = Engine.GetGUIObjectByName("chartLegend"); chartLegend.caption = g_GameData.sim.playerStates.slice(1).map( @@ -200,7 +202,7 @@ g_SelectedChart.value[number] = 0; g_SelectedChart.type[number] = 0; } - + resizeDropdown(this); updateValueDropdown(number, this.list_data[this.selected]); }; @@ -311,14 +313,14 @@ let playerBoxesCounts = []; for (let i = 0; i < g_PlayerCount; ++i) { - let playerState = g_GameData.sim.playerStates[i+1]; + let playerState = g_GameData.sim.playerStates[i + 1]; - if (!playerBoxesCounts[playerState.team+1]) - playerBoxesCounts[playerState.team+1] = 1; + if (!playerBoxesCounts[playerState.team + 1]) + playerBoxesCounts[playerState.team + 1] = 1; else - playerBoxesCounts[playerState.team+1] += 1; + playerBoxesCounts[playerState.team + 1] += 1; - let positionObject = playerBoxesCounts[playerState.team+1] - 1; + let positionObject = playerBoxesCounts[playerState.team + 1] - 1; let rowPlayer = "playerBox[" + positionObject + "]"; let playerOutcome = "playerOutcome[" + positionObject + "]"; let playerNameColumn = "playerName[" + positionObject + "]"; @@ -349,7 +351,7 @@ setOutcomeIcon(playerState.state, playerOutcome); - Engine.GetGUIObjectByName(playerNameColumn).caption = g_GameData.sim.playerStates[i+1].name; + Engine.GetGUIObjectByName(playerNameColumn).caption = g_GameData.sim.playerStates[i + 1].name; let civIcon = Engine.GetGUIObjectByName(playerCivicBoxColumn); civIcon.sprite = "stretched:" + g_CivData[playerState.civ].Emblem; @@ -444,7 +446,7 @@ "time": timeToString(g_GameData.sim.timeElapsed) }); - let mapType = g_Settings.MapTypes.find(mapType => mapType.Name == g_GameData.sim.mapSettings.mapType); + let mapType = g_Settings.MapTypes.find(type => type.Name == g_GameData.sim.mapSettings.mapType); let mapSize = g_Settings.MapSizes.find(size => size.Tiles == g_GameData.sim.mapSettings.Size || 0); Engine.GetGUIObjectByName("mapName").caption = sprintf( @@ -477,10 +479,8 @@ // Erase teams data if teams are not displayed if (!g_Teams) - { for (let p = 0; p < g_PlayerCount; ++p) g_GameData.sim.playerStates[p+1].team = -1; - } calculateTeamCounterDataHelper();