Move the view player list initialization in session.js to a separate function.
In D754 we'll need to call this function when changing player colors.
Details
I kept the viewPlayer name, but maybe it could be changed to viewedPlayerDropdown or something, I don't have a strong opinion.
Diff Detail
- Repository
- rP 0 A.D. Public Repository
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Event Timeline
binaries/data/mods/public/gui/session/session.js | ||
---|---|---|
449–450 ↗ | (On Diff #4634) | swap the order since names before id in the other two places |
Successful build - Chance fights ever on the side of the prudent.
Updating workspaces... Build (release)... Build (debug)... Running release tests... Running cxxtest tests (308 tests)....................................................................................................................................................................................................................................................................................................................OK! Running debug tests... Running cxxtest tests (308 tests)....................................................................................................................................................................................................................................................................................................................OK! Checking XML files...
Thanks for splitting it
binaries/data/mods/public/gui/session/session.js | ||
---|---|---|
456 ↗ | (On Diff #4634) | Could we end up with 3 statements by using [-1].concat(g_Players.map(player, playerID) => calls like we do in modmod.js? |
Successful build - Chance fights ever on the side of the prudent.
Updating workspaces... Build (release)... Build (debug)... Running release tests... Running cxxtest tests (308 tests)....................................................................................................................................................................................................................................................................................................................OK! Running debug tests... Running cxxtest tests (308 tests)....................................................................................................................................................................................................................................................................................................................OK! Checking XML files...
Will commit after testing in case you agree with the 2 renames
binaries/data/mods/public/gui/session/session.js | ||
---|---|---|
293 ↗ | (On Diff #4654) | viewedPlayer might not have been the best name choice at the time, given that it is about a player different from g_ViewedPlayer, nor a playerID. player should do. (That + 1 is a "hardcoded" / "magic number". We could use Engine.GetGUIObjectByName("viewPlayer").list_data.indexOf(Engine.GetPlayerID()). |
443 ↗ | (On Diff #4654) | updateViewedPlayerDropdown or updateViewedPlayerControl to make it slightly more clear which list is meant. (Was wondering if it fits better to menu.js (near the gamespeed choices). Seems like the place might use some sorting. But the rest of the viewed-player logic is in session.js, so we can keep it there). |
446 ↗ | (On Diff #4654) | (Array(g_MaxPlayers).fill(0).map((v, i) => i + 1) wouldn't be any better either, as seen in gamesetup.js g_NumPlayersList, nor any use of prepareForDropdown) |