Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/unit_commands.js
// The number of currently visible buttons (used to optimise showing/hiding) | // The number of currently visible buttons (used to optimise showing/hiding) | ||||
var g_unitPanelButtons = { | var g_unitPanelButtons = { | ||||
"Selection": 0, | "Selection": 0, | ||||
"Queue": 0, | "Queue": 0, | ||||
"Formation": 0, | "Formation": 0, | ||||
"Garrison": 0, | "Garrison": 0, | ||||
"Training": 0, | "Training": 0, | ||||
"Research": 0, | "Research": 0, | ||||
"Alert": 0, | "Alert": 0, | ||||
"Barter": 0, | "Barter": 0, | ||||
"Construction": 0, | "Construction": 0, | ||||
"Command": 0, | "Command": 0, | ||||
"AllyCommand": 0, | |||||
"Stance": 0, | "Stance": 0, | ||||
"Gate": 0, | "Gate": 0, | ||||
"Pack": 0, | "Pack": 0, | ||||
"Upgrade": 0 | "Upgrade": 0 | ||||
}; | }; | ||||
/** | /** | ||||
* Set the position of a panel object according to the index, | * Set the position of a panel object according to the index, | ||||
▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | function updateUnitCommands(entStates, supplementalDetailsPanel, commandsPanel) | ||||
// If the selection is friendly units, add the command panels | // If the selection is friendly units, add the command panels | ||||
// Get player state to check some constraints | // Get player state to check some constraints | ||||
// e.g. presence of a hero or build limits | // e.g. presence of a hero or build limits | ||||
let playerStates = GetSimState().players; | let playerStates = GetSimState().players; | ||||
let playerState = playerStates[Engine.GetPlayerID()]; | let playerState = playerStates[Engine.GetPlayerID()]; | ||||
// Command panel always shown for it can contain non-owned commands. | |||||
setupUnitPanel("Command", entStates, playerState); | |||||
if (g_IsObserver || entStates.every(entState => controlsPlayer(entState.player))) | if (g_IsObserver || entStates.every(entState => controlsPlayer(entState.player))) | ||||
{ | { | ||||
for (let guiName of g_PanelsOrder) | for (let guiName of g_PanelsOrder) | ||||
{ | { | ||||
if (g_SelectionPanels[guiName].conflictsWith && | if (g_SelectionPanels[guiName].conflictsWith && | ||||
g_SelectionPanels[guiName].conflictsWith.some(p => g_SelectionPanels[p].used)) | g_SelectionPanels[guiName].conflictsWith.some(p => g_SelectionPanels[p].used)) | ||||
continue; | continue; | ||||
setupUnitPanel(guiName, entStates, playerStates[entStates[0].player]); | setupUnitPanel(guiName, entStates, playerStates[entStates[0].player]); | ||||
} | } | ||||
supplementalDetailsPanel.hidden = false; | supplementalDetailsPanel.hidden = false; | ||||
commandsPanel.hidden = false; | commandsPanel.hidden = false; | ||||
} | } | ||||
else if (playerState.isMutualAlly[entStates[0].player]) // owned by allied player | else if (playerState.isMutualAlly[entStates[0].player]) // owned by allied player | ||||
{ | { | ||||
// TODO if there's a second panel needed for a different player | // TODO if there's a second panel needed for a different player | ||||
// we should consider adding the players list to g_SelectionPanels | // we should consider adding the players list to g_SelectionPanels | ||||
setupUnitPanel("Garrison", entStates, playerState); | setupUnitPanel("Garrison", entStates, playerState); | ||||
setupUnitPanel("AllyCommand", entStates, playerState); | |||||
supplementalDetailsPanel.hidden = !g_SelectionPanels.Garrison.used; | supplementalDetailsPanel.hidden = !g_SelectionPanels.Garrison.used; | ||||
commandsPanel.hidden = true; | commandsPanel.hidden = true; | ||||
} | } | ||||
else // owned by another player | else // owned by another player | ||||
{ | { | ||||
supplementalDetailsPanel.hidden = true; | supplementalDetailsPanel.hidden = true; | ||||
▲ Show 20 Lines • Show All 64 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator