Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/unit_actions.js
Show First 20 Lines • Show All 1,089 Lines • ▼ Show 20 Lines | "stop": { | ||||||||||||||
}, | }, | ||||||||||||||
"execute": function(entStates) | "execute": function(entStates) | ||||||||||||||
{ | { | ||||||||||||||
if (entStates.length) | if (entStates.length) | ||||||||||||||
stopUnits(entStates.map(entState => entState.id)); | stopUnits(entStates.map(entState => entState.id)); | ||||||||||||||
}, | }, | ||||||||||||||
}, | }, | ||||||||||||||
"formBattalion": { | |||||||||||||||
"getInfo": function(entStates) | |||||||||||||||
{ | |||||||||||||||
// Return false when multiple types of units are selected. | |||||||||||||||
Stan: Can entStates be null or empty? | |||||||||||||||
let refTemplateName = entStates[0].template.selectionGroupName || entStates[0].template; | |||||||||||||||
Not Done Inline Actions2 Constant/ Magic number? Stan: 2 Constant/ Magic number? | |||||||||||||||
if (entStates.length < 2 || | |||||||||||||||
entStates.some(entState => | |||||||||||||||
Done Inline Actions
Please change template.selectionGroupName to identity.selectionGroupName azayrahmad: Please change template.selectionGroupName to identity.selectionGroupName | |||||||||||||||
(entState.template.selectionGroupName || entState.template) != refTemplateName | |||||||||||||||
) | |||||||||||||||
) | |||||||||||||||
return false; | |||||||||||||||
Done Inline ActionsI guess that's a leftover :) Stan: I guess that's a leftover :) | |||||||||||||||
Done Inline ActionsIf you mean the commented code: not really, depens on whether we will allow more types of unit in the same group. The return false is also used in other "getInfo"s so I gues that is needed. Freagarach: If you mean the commented code: not really, depens on whether we will allow more types of unit… | |||||||||||||||
Done Inline ActionsOh my bad, I didn't see the indent :) NVM Stan: Oh my bad, I didn't see the indent :) NVM | |||||||||||||||
Done Inline ActionsNo problem! Freagarach: No problem! | |||||||||||||||
return { | |||||||||||||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.formbattalion") + | |||||||||||||||
translate("Form a battalion with the currently selected units."), | |||||||||||||||
"icon": "training.png" | |||||||||||||||
}; | |||||||||||||||
}, | |||||||||||||||
"execute": function(entStates) | |||||||||||||||
{ | |||||||||||||||
if (entStates.length) | |||||||||||||||
formBattalion(entStates.map(entState => entState.id)); | |||||||||||||||
}, | |||||||||||||||
}, | |||||||||||||||
"disbandBattalion": { | |||||||||||||||
"getInfo": function(entStates) | |||||||||||||||
{ | |||||||||||||||
// Only return false when no battalions are selected. | |||||||||||||||
if (entStates.every(entState => | |||||||||||||||
entState.battalion == false | |||||||||||||||
)) | |||||||||||||||
return false; | |||||||||||||||
Done Inline ActionsSame here. Stan: Same here. | |||||||||||||||
return { | |||||||||||||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.disbandbattalion") + | |||||||||||||||
translate("Disband all currently selected battalion(s)."), | |||||||||||||||
"icon": "cancel.png" | |||||||||||||||
}; | |||||||||||||||
}, | |||||||||||||||
"execute": function(entStates) | |||||||||||||||
{ | |||||||||||||||
if (entStates.length) | |||||||||||||||
disbandBattalion(entStates.map(entState => entState.battalion)); | |||||||||||||||
StanUnsubmitted Done Inline ActionsShouldn't you return something. Stan: Shouldn't you return something. | |||||||||||||||
FreagarachAuthorUnsubmitted Done Inline ActionsNot according to other actions :) Freagarach: Not according to other actions :) | |||||||||||||||
}, | |||||||||||||||
}, | |||||||||||||||
Done Inline Actionsif(!bat) return undefined (|| [] ?) return bat ? Stan: ```lang=js
if(!bat)
return undefined (|| [] ?)
return bat ?
``` | |||||||||||||||
"garrison": { | "garrison": { | ||||||||||||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||||||||||||
{ | { | ||||||||||||||
if (entStates.every(entState => !entState.unitAI || entState.turretParent || false)) | if (entStates.every(entState => !entState.unitAI || entState.turretParent || false)) | ||||||||||||||
return false; | return false; | ||||||||||||||
return { | return { | ||||||||||||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.garrison") + | "tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.garrison") + | ||||||||||||||
▲ Show 20 Lines • Show All 437 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Can entStates be null or empty?