Ticket #3745: backtowork.2.patch
File backtowork.2.patch, 3.4 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/session/selection_panels.js
192 192 { 193 193 return 6; 194 194 }, 195 "getItems": function(unitEntState )195 "getItems": function(unitEntState, selection) 196 196 { 197 var commands = []; 198 for (var c in g_EntityCommands) 197 let commands = []; 198 199 for (let c in g_EntityCommands) 199 200 { 200 201 var info = g_EntityCommands[c].getInfo(unitEntState); 201 202 if (!info) 202 203 continue; 204 203 205 info.name = c; 204 206 commands.push(info); 205 207 } 208 209 // if the given unit state has no back-to-work entry, we need to check the other units as well 210 // otherwise the command back-to-work is not shown 211 if (!commands["back-to-work"]) { 212 for (let id of selection) { 213 let uEntState = GetExtendedEntityState(id); 214 215 let info = g_EntityCommands["back-to-work"].getInfo(uEntState); 216 if (!info) 217 continue; 218 219 info.name = "back-to-work"; 220 commands.push(info); 221 break; 222 } 223 } 224 206 225 return commands; 207 226 }, 208 227 "setTooltip": function(data) -
binaries/data/mods/public/gui/session/unit_commands.js
28 28 * (i.e. panels with rows of icons) for the currently selected unit. 29 29 * 30 30 * @param guiName Short identifier string of this panel. See g_SelectionPanels. 31 * @param unitEntState Entity state of the (first) selected unit.31 * @param unitEntState Entity state of the selected unit with the lowest id. 32 32 * @param payerState Player state 33 * @param selectedEntries All selected units 33 34 */ 34 function setupUnitPanel(guiName, unitEntState, playerState )35 function setupUnitPanel(guiName, unitEntState, playerState, selection) 35 36 { 36 37 if (!g_SelectionPanels[guiName]) 37 38 { … … 38 39 error("unknown guiName used '" + guiName + "'"); 39 40 return; 40 41 } 41 var selection = g_Selection.toList();42 43 42 var items = g_SelectionPanels[guiName].getItems(unitEntState, selection); 44 43 45 44 if (!items || !items.length) … … 146 145 * Delegates to setupUnitPanel to set up individual subpanels, 147 146 * appropriately activated depending on the selected unit's state. 148 147 * 149 * @param entState Entity state of the (first) selected unit.148 * @param entState Entity state of the selected unit with the lowest id 150 149 * @param supplementalDetailsPanel Reference to the 151 150 * "supplementalSelectionDetails" GUI Object 152 151 * @param commandsPanel Reference to the "commandsPanel" GUI Object … … 175 174 ) 176 175 continue; 177 176 178 setupUnitPanel(guiName, entState, simState.players[entState.player] );177 setupUnitPanel(guiName, entState, simState.players[entState.player], selection); 179 178 } 180 179 181 180 supplementalDetailsPanel.hidden = false; … … 185 184 { 186 185 // TODO if there's a second panel needed for a different player 187 186 // we should consider adding the players list to g_SelectionPanels 188 setupUnitPanel("Garrison", entState, playerState );189 setupUnitPanel("AllyCommand", entState, playerState );187 setupUnitPanel("Garrison", entState, playerState, selection); 188 setupUnitPanel("AllyCommand", entState, playerState, selection); 190 189 191 190 supplementalDetailsPanel.hidden = !g_SelectionPanels.Garrison.used; 192 191