Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/PerPlayer/Dropdowns/PlayerColor.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/PerPlayer/Dropdowns/PlayerColor.js +++ ps/trunk/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/PerPlayer/Dropdowns/PlayerColor.js @@ -20,17 +20,21 @@ if (g_GameSettings.playerCount.nbPlayers < this.playerIndex + 1) return; - let hidden = !g_IsController || g_GameSettings.map.type == "scenario"; + const hidden = !g_IsController || g_GameSettings.map.type == "scenario"; this.dropdown.hidden = hidden; this.playerColorHeading.hidden = hidden; - let value = g_GameSettings.playerColor.get(this.playerIndex); - this.setSelectedValue(value); + const value = g_GameSettings.playerColor.get(this.playerIndex); this.playerBackgroundColor.sprite = "color:" + rgbToGuiColor(value, 100); this.values = g_GameSettings.playerColor.available; this.dropdown.list = this.values.map(color => coloredText(this.ColorIcon, rgbToGuiColor(color))); this.dropdown.list_data = this.values.map((color, i) => i); + this.setSelectedValue(this.values.map((color, i) => { + if (color.r === value.r && color.g === value.g && color.b === value.b) + return i; + return undefined; + }).filter(x => x !== undefined)?.[0] ?? -1); } onSelectionChange(itemIdx) Index: ps/trunk/source/gui/ObjectTypes/CDropDown.cpp =================================================================== --- ps/trunk/source/gui/ObjectTypes/CDropDown.cpp +++ ps/trunk/source/gui/ObjectTypes/CDropDown.cpp @@ -169,7 +169,10 @@ m_ElementHighlight = m_Selected; // Start at the position of the selected item, if possible. - GetScrollBar(0).SetPos(m_ItemsYPositions.empty() ? 0 : m_ItemsYPositions[m_ElementHighlight] - 60); + if (m_ItemsYPositions.empty() || m_ElementHighlight < 0 || static_cast(m_ElementHighlight) >= m_ItemsYPositions.size()) + GetScrollBar(0).SetPos(0); + else + GetScrollBar(0).SetPos(m_ItemsYPositions[m_ElementHighlight] - 60); PlaySound(m_SoundOpened); return; // overshadow