Index: binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/PerPlayer/Dropdowns/PlayerCiv.js =================================================================== --- binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/PerPlayer/Dropdowns/PlayerCiv.js +++ binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/PerPlayer/Dropdowns/PlayerCiv.js @@ -4,13 +4,13 @@ { super(...args); - this.values = prepareForDropdown(this.getItems()); + g_GameSettings.playerCiv.watch(() => this.rebuild(), ["values", "locked"]); - this.dropdown.list = this.values.name; - this.dropdown.list_data = this.values.civ; + this.items = this.getItems(); + this.allItems = this.getAllItems(); + this.wasLocked = undefined; - g_GameSettings.playerCiv.watch(() => this.render(), ["values", "locked"]); - this.render(); + this.rebuild(); } setControl() @@ -24,6 +24,24 @@ this.dropdown.tooltip = this.values && this.values.tooltip[this.dropdown.hovered] || this.Tooltip; } + rebuild() + { + const isLocked = g_GameSettings.playerCiv.locked[this.playerIndex]; + if (this.wasLocked !== isLocked) + { + this.wasLocked = isLocked; + this.values = prepareForDropdown(isLocked ? this.allItems : this.items); + + this.dropdown.list = this.values.name; + this.dropdown.list_data = this.values.civ; + + // If not locked, reset selection, else we can end up with empty label + if (!isLocked) + this.onSelectionChange(0); + } + this.render(); + } + render() { this.setEnabled(!g_GameSettings.playerCiv.locked[this.playerIndex]); @@ -55,6 +73,30 @@ return values; } + getAllItems() + { + const values = []; + + for (const civ in g_CivData) + values.push({ + "name": g_CivData[civ].Name, + "autocomplete": g_CivData[civ].Name, + "tooltip": g_CivData[civ].History, + "civ": civ + }); + + values.sort(sortNameIgnoreCase); + + values.unshift({ + "name": setStringTags(this.RandomCivCaption, this.RandomItemTags), + "autocomplete": this.RandomCivCaption, + "tooltip": this.RandomCivTooltip, + "civ": this.RandomCivId + }); + + return values; + } + getAutocompleteEntries() { return this.values.autocomplete; Index: binaries/data/mods/public/simulation/data/civs/spart.json =================================================================== --- binaries/data/mods/public/simulation/data/civs/spart.json +++ binaries/data/mods/public/simulation/data/civs/spart.json @@ -88,5 +88,5 @@ "skirmish/structures/default_wall_medium": "", "skirmish/structures/default_wall_long": "" }, - "SelectableInGameSetup": true + "SelectableInGameSetup": false }