Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/GameSettings/Single/Dropdowns/Landscape.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/gamesetup/GameSettings/Single/Dropdowns/Landscape.js (revision 23397) +++ ps/trunk/binaries/data/mods/public/gui/gamesetup/GameSettings/Single/Dropdowns/Landscape.js (revision 23398) @@ -1,145 +1,148 @@ GameSettingControls.Landscape = class extends GameSettingControlDropdown { constructor(...args) { super(...args); this.values = undefined; this.lastLandscape = undefined; this.mapData = undefined; } onHoverChange() { this.dropdown.tooltip = this.values.Description[this.dropdown.hovered] || this.Tooltip; } onMapChange(mapData) { this.mapData = mapData; if (mapData && mapData.settings && mapData.settings.Landscapes) { let randomItems = []; for (let item of this.RandomItems) if (item.Id == "random" || mapData.settings.Landscapes.land && mapData.settings.Landscapes.naval) randomItems.push({ "Id": item.Id, "Name": setStringTags(item.Name, this.RandomItemTags), "Description": item.Description, "Preview": mapData.settings.Preview || this.mapCache.DefaultPreview }); let sort = (item1, item2) => item1.Name > item2.Name; this.values = prepareForDropdown([ ...randomItems, ...mapData.settings.Landscapes.land.sort(sort), ...mapData.settings.Landscapes.naval.sort(sort) ]); this.dropdown.list = this.values.Name; this.dropdown.list_data = this.values.Id; } else this.values = undefined; this.lastLandscape = undefined; this.setHidden(!this.values); } onGameAttributesChange() { if (this.values) { if (this.values.Id.indexOf(g_GameAttributes.settings.Landscape || undefined) == -1) { g_GameAttributes.settings.Landscape = "random"; this.gameSettingsControl.updateGameAttributes(); } if (this.lastLandscape != g_GameAttributes.settings.Landscape) { g_GameAttributes.settings.Preview = this.values.Preview[this.values.Id.indexOf(g_GameAttributes.settings.Landscape)]; this.lastLandscape = g_GameAttributes.settings.Biome; } } else if (g_GameAttributes.settings.Landscape !== undefined) { delete g_GameAttributes.settings.Landscape; this.gameSettingsControl.updateGameAttributes(); } } onGameAttributesBatchChange() { if (g_GameAttributes.settings.Landscape) this.setSelectedValue(g_GameAttributes.settings.Landscape); } getAutocompleteEntries() { return this.values.Name; } onSelectionChange(itemIdx) { g_GameAttributes.settings.Landscape = this.values.Id[itemIdx]; this.gameSettingsControl.updateGameAttributes(); this.gameSettingsControl.setNetworkGameAttributes(); } onPickRandomItems() { + if (!this.mapData) + return; + let items; let landscapes = this.mapData.settings.Landscapes; switch (g_GameAttributes.settings.Landscape || undefined) { case "random": items = [...landscapes.land, ...landscapes.naval]; break; case "random_land": items = landscapes.land; break; case "random_naval": items = landscapes.naval; break; default: return; } g_GameAttributes.settings.Landscape = pickRandom(items).Id; this.gameSettingsControl.updateGameAttributes(); this.gameSettingsControl.pickRandomItems(); } }; GameSettingControls.Landscape.prototype.TitleCaption = translate("Landscape"); GameSettingControls.Landscape.prototype.Tooltip = translate("Select one of the landscapes of this map."); GameSettingControls.Landscape.prototype.RandomItems = [ { "Id": "random", "Name": translateWithContext("landscape selection", "Random Land or Naval"), "Description": translateWithContext("landscape selection", "Select a random land or naval map generation.") }, { "Id": "random_land", "Name": translateWithContext("landscape selection", "Random Land"), "Description": translateWithContext("landscape selection", "Select a random land map generation.") }, { "Id": "random_naval", "Name": translateWithContext("landscape selection", "Random Naval"), "Description": translateWithContext("landscape selection", "Select a random naval map generation.") } ]; GameSettingControls.Landscape.prototype.AutocompleteOrder = 0; Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/GameSettings/Single/Dropdowns/RelicCount.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/gamesetup/GameSettings/Single/Dropdowns/RelicCount.js (revision 23397) +++ ps/trunk/binaries/data/mods/public/gui/gamesetup/GameSettings/Single/Dropdowns/RelicCount.js (revision 23398) @@ -1,85 +1,86 @@ GameSettingControls.RelicCount = class extends GameSettingControlDropdown { constructor(...args) { super(...args); - this.values = Array.from(new Array(g_CivData.length), (v, i) => i + 1); + this.values = Object.keys(g_CivData).map((v, i) => i + 1); + this.dropdown.list = this.values; this.dropdown.list_data = this.values; this.available = false; } onMapChange(mapData) { this.setEnabled(g_GameAttributes.mapType != "scenario"); let mapValue = mapData && mapData.settings && mapData.settings.VictoryConditions && mapData.settings.VictoryConditions.indexOf(this.NameCaptureTheRelic) != -1 && mapData.settings.RelicCount || undefined; if (mapValue === undefined || mapValue == g_GameAttributes.settings.RelicCount) return; if (!g_GameAttributes.settings.VictoryConditions) g_GameAttributes.settings.VictoryConditions = []; if (g_GameAttributes.settings.VictoryConditions.indexOf(this.NameCaptureTheRelic) == -1) g_GameAttributes.settings.VictoryConditions.push(this.NameCaptureTheRelic); g_GameAttributes.settings.RelicCount = mapValue; this.gameSettingsControl.updateGameAttributes(); } onGameAttributesChange() { if (!g_GameAttributes.settings.VictoryConditions) return; this.available = g_GameAttributes.settings.VictoryConditions.indexOf(this.NameCaptureTheRelic) != -1; if (this.available) { if (g_GameAttributes.settings.RelicCount === undefined) { g_GameAttributes.settings.RelicCount = this.DefaultRelicCount; this.gameSettingsControl.updateGameAttributes(); } } else if (g_GameAttributes.settings.RelicCount !== undefined) { delete g_GameAttributes.settings.RelicCount; this.gameSettingsControl.updateGameAttributes(); } } onGameAttributesBatchChange() { this.setHidden(!this.available); if (this.available) this.setSelectedValue(g_GameAttributes.settings.RelicCount); } onSelectionChange(itemIdx) { g_GameAttributes.settings.RelicCount = this.values[itemIdx]; this.gameSettingsControl.updateGameAttributes(); this.gameSettingsControl.setNetworkGameAttributes(); } }; GameSettingControls.RelicCount.prototype.TitleCaption = translate("Relic Count"); GameSettingControls.RelicCount.prototype.Tooltip = translate("Total number of relics spawned on the map. Relic victory is most realistic with only one or two relics. With greater numbers, the relics are important to capture to receive aura bonuses."); GameSettingControls.RelicCount.prototype.NameCaptureTheRelic = - this.NameCaptureTheRelic; + "capture_the_relic"; GameSettingControls.RelicCount.prototype.DefaultRelicCount = 2; Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Panels/GameSettingsPanel.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/gamesetup/Panels/GameSettingsPanel.js (revision 23397) +++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Panels/GameSettingsPanel.js (revision 23398) @@ -1,186 +1,188 @@ class GameSettingsPanel { constructor(gamesetupPage, gameSettingTabs, gameSettingsControl, gameSettingControlManager) { + this.centerRightPanel = Engine.GetGUIObjectByName("centerRightPanel"); this.settingTabButtonsFrame = Engine.GetGUIObjectByName("settingTabButtonsFrame"); this.settingsPanelFrame = Engine.GetGUIObjectByName("settingsPanelFrame"); this.gameSettingControlManager = gameSettingControlManager; this.gameSettingsPanelResizeHandlers = new Set(); this.setupWindow = Engine.GetGUIObjectByName("setupWindow"); - this.setupWindow.onWindowResized = this.triggerResizeHandlers.bind(this); + this.setupWindow.onWindowResized = this.onWindowResized.bind(this); this.settingsPanel = Engine.GetGUIObjectByName("settingsPanel"); this.enabled = Engine.ConfigDB_GetValue("user", this.ConfigNameSlide) == "true"; this.slideSpeed = this.enabled ? this.SlideSpeed : Infinity; this.lastTickTime = undefined; - gameSettingTabs.registerTabSelectHandler(this.onTabSelect.bind(this)); - gameSettingsControl.registerGameAttributesBatchChangeHandler(this.onGameAttributesBatchChange.bind(this)); + gameSettingTabs.registerTabSelectHandler(this.updateSize.bind(this)); + gameSettingsControl.registerGameAttributesBatchChangeHandler(this.updateSize.bind(this)); gamesetupPage.registerLoadHandler(this.triggerResizeHandlers.bind(this)); } registerGameSettingsPanelResizeHandler(handler) { this.gameSettingsPanelResizeHandlers.add(handler); } triggerResizeHandlers() { for (let handler of this.gameSettingsPanelResizeHandlers) handler(this.settingsPanelFrame); } - onGameAttributesBatchChange() + onWindowResized() { - this.gameSettingControlManager.updateSettingVisibility(); - this.positionSettings(); + this.updateSize(); + this.triggerResizeHandlers(); } - onTabSelect() + updateSize() { this.gameSettingControlManager.updateSettingVisibility(); this.positionSettings(); this.lastTickTime = undefined; this.settingsPanelFrame.onTick = this.onTick.bind(this); } onTick() { let now = Date.now(); let tickLength = now - this.lastTickTime; let previousTime = this.lastTickTime; this.lastTickTime = now; if (previousTime === undefined) return; let distance = this.slideSpeed * tickLength; let rightBorder = this.settingTabButtonsFrame.size.left; let offset = 0; if (g_TabCategorySelected === undefined) { let maxOffset = rightBorder - this.settingsPanelFrame.size.left; if (maxOffset > 0) offset = Math.min(distance, maxOffset); } else if (rightBorder > this.settingsPanelFrame.size.right) { offset = Math.min(distance, rightBorder - this.settingsPanelFrame.size.right); } else { let maxOffset = this.settingsPanelFrame.size.left - rightBorder + (this.settingsPanelFrame.size.right - this.settingsPanelFrame.size.left); if (maxOffset > 0) offset = -Math.min(distance, maxOffset); } if (offset) this.changePanelWidth(offset); else { delete this.settingsPanelFrame.onTick; this.lastTickTime = undefined; } } changePanelWidth(offset) { if (!offset) return; let size = this.settingsPanelFrame.size; size.left += offset; size.right += offset; this.settingsPanelFrame.size = size; this.triggerResizeHandlers(); } /** * Distribute the currently visible settings over the settings panel. * First calculate the number of columns required, then place the setting frames. */ positionSettings() { let setupWindowSize = this.setupWindow.getComputedSize(); + let columnWidth = Math.min( this.MaxColumnWidth, - (setupWindowSize.right - setupWindowSize.left + this.settingTabButtonsFrame.size.left) / 2); + (setupWindowSize.right - setupWindowSize.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; settingsPerColumn = settingCount / Math.ceil(settingCount / maxSettingsPerColumn); } let yPos = this.SettingMarginBottom; let column = 0; let settingsThisColumn = 0; let selectedTab = g_GameSettingsLayout[g_TabCategorySelected]; if (!selectedTab) return; for (let name of selectedTab.settings) { let settingFrame = this.gameSettingControlManager.gameSettingControls[name].frame; if (settingFrame.hidden) continue; if (settingsThisColumn >= settingsPerColumn) { yPos = this.SettingMarginBottom; ++column; settingsThisColumn = 0; } settingFrame.size = new GUISize( columnWidth * column, yPos, columnWidth * (column + 1) - this.SettingMarginRight, yPos + this.SettingHeight - this.SettingMarginBottom); yPos += this.SettingHeight; ++settingsThisColumn; } { let size = this.settingsPanelFrame.size; size.right = size.left + (column + 1) * columnWidth; this.settingsPanelFrame.size = size; } } } GameSettingsPanel.prototype.ConfigNameSlide = "gui.gamesetup.settingsslide"; /** * Maximum width of a column in the settings panel. */ GameSettingsPanel.prototype.MaxColumnWidth = 470; /** * Pixels per millisecond the settings panel slides when opening/closing. */ GameSettingsPanel.prototype.SlideSpeed = 1.2; /** * Vertical size of a setting frame. */ GameSettingsPanel.prototype.SettingHeight = 32; /** * Horizontal space between two setting frames. */ GameSettingsPanel.prototype.SettingMarginRight = 10; /** * Vertical space between two setting frames. */ GameSettingsPanel.prototype.SettingMarginBottom = 2; Index: ps/trunk/binaries/data/mods/public/gui/loadgame/SavegameDetails.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/loadgame/SavegameDetails.js (revision 23397) +++ ps/trunk/binaries/data/mods/public/gui/loadgame/SavegameDetails.js (revision 23398) @@ -1,48 +1,49 @@ /** * Needed for formatPlayerInfo to show the player civs in the details. */ const g_CivData = loadCivData(false, false); /** * This class is responsible for showing the map preview, description and other details * of the currently selected savegame, or showing a placeholder if no savegame is selected. */ class SavegameDetails { constructor() { this.mapCache = new MapCache(); this.onSelectionChange(); } onSelectionChange(gameID, metadata, label) { Engine.GetGUIObjectByName("invalidGame").hidden = !!metadata; Engine.GetGUIObjectByName("validGame").hidden = !metadata; if (!metadata) return; Engine.GetGUIObjectByName("savedMapName").caption = - this.mapCache.getMapName(metadata.initAttributes.mapType, metadata.initAttributes.map); + this.mapCache.translateMapName( + this.mapCache.getTranslatableMapName(metadata.initAttributes.mapType, metadata.initAttributes.map)); Engine.GetGUIObjectByName("savedInfoPreview").sprite = this.mapCache.getMapPreview(metadata.initAttributes.mapType, metadata.initAttributes.map, metadata.initAttributes); Engine.GetGUIObjectByName("savedPlayers").caption = metadata.initAttributes.settings.PlayerData.length - 1; Engine.GetGUIObjectByName("savedPlayedTime").caption = timeToString(metadata.gui.timeElapsed ? metadata.gui.timeElapsed : 0); Engine.GetGUIObjectByName("savedMapType").caption = translateMapType(metadata.initAttributes.mapType); Engine.GetGUIObjectByName("savedMapSize").caption = translateMapSize(metadata.initAttributes.settings.Size || -1); Engine.GetGUIObjectByName("savedVictory").caption = metadata.initAttributes.settings.VictoryConditions.map(victoryConditionName => translateVictoryCondition(victoryConditionName)).join(translate(", ")); let caption = sprintf(translate("Mods: %(mods)s"), { "mods": modsToString(metadata.mods) }); if (!hasSameMods(metadata.mods, Engine.GetEngineInfo().mods)) caption = coloredText(caption, "orange"); Engine.GetGUIObjectByName("savedMods").caption = caption; Engine.GetGUIObjectByName("savedPlayersNames").caption = formatPlayerInfo( metadata.initAttributes.settings.PlayerData, metadata.gui.states); } }