Changeset View
Standalone View
binaries/data/mods/public/gui/session/selection_panels.js
Show First 20 Lines • Show All 282 Lines • ▼ Show 20 Lines | g_SelectionPanels.Formation = { | ||||
"getMaxNumberOfItems": function() | "getMaxNumberOfItems": function() | ||||
{ | { | ||||
return 16; | return 16; | ||||
}, | }, | ||||
"rowLength": 4, | "rowLength": 4, | ||||
"conflictsWith": ["Garrison"], | "conflictsWith": ["Garrison"], | ||||
"getItems": function(unitEntStates) | "getItems": function(unitEntStates) | ||||
{ | { | ||||
if (unitEntStates.some(state => !hasClass(state, "Unit"))) | // hide panel if formations are forbidden for some class in selection | ||||
Stan: Comments start with caps. Forbidden -> Disabled. | |||||
if (unitEntStates.some(state => !hasClass(state, "Unit")) || | |||||
StanUnsubmitted Not Done Inline ActionsDon't we have something like MatchClassesList for those kind of operations ? Stan: Don't we have something like MatchClassesList for those kind of operations ? | |||||
unitEntStates.some(state => hasClass(state, "Domestic") || hasClass(state, "FemaleCitizen") || hasClass(state, "Trader")) | |||||
elexisUnsubmitted Not Done Inline ActionsThe commit that had introduced the panel hiding if there are no formations available had the idea to remove the hardcoding. Hardcoded collections of unit classes are deemed and doomed to fail in the future and with mods (that don't use women but cars or aliens for instance). What we want is to display the formations panel if it is possible to enter a formation if the conditions are met, display but disable it if the conditions are not met, and hide it if there are no formations at all, right? So we could check if the Formations part of the template is non-empty to determine the visibility, no? elexis: The commit that had introduced the panel hiding if there are no formations available had the… | |||||
) | |||||
return []; | return []; | ||||
if (!g_AvailableFormations.has(unitEntStates[0].player)) | if (!g_AvailableFormations.has(unitEntStates[0].player)) | ||||
Not Done Inline ActionsIs it supposed to be that way, or wouldn't some subset of entities being able to build a formation suffice? elexis: Is it supposed to be that way, or wouldn't some subset of entities being able to build a… | |||||
Not Done Inline ActionsNo, I didnt realised this will happen for mixed units. Silier: No, I didnt realised this will happen for mixed units. | |||||
Not Done Inline ActionsCheck for length? (unitEntStates[0]) to early return? Stan: Check for length? (unitEntStates[0]) to early return? | |||||
Not Done Inline ActionsCan a unit have no identity? Stan: Can a unit have no identity? | |||||
Done Inline Actionstechnicly yes, thnx Silier: technicly yes, thnx | |||||
g_AvailableFormations.set(unitEntStates[0].player, Engine.GuiInterfaceCall("GetAvailableFormations", unitEntStates[0].player)); | g_AvailableFormations.set(unitEntStates[0].player, Engine.GuiInterfaceCall("GetAvailableFormations", unitEntStates[0].player)); | ||||
let availableFormations = g_AvailableFormations.get(unitEntStates[0].player); | let availableFormations = g_AvailableFormations.get(unitEntStates[0].player); | ||||
// Hide the panel if all formations are disabled | |||||
if (availableFormations.some(formation => canMoveSelectionIntoFormation(formation))) | |||||
return availableFormations; | return availableFormations; | ||||
return []; | |||||
}, | }, | ||||
Not Done Inline ActionsJust wondering, wouldnt it be better to only return those formations in which some unit of the selection can participate, i.e. if you have only infantry selected, that the wedge is not visible, but once you also select one cav you get the wedge aswell. However maybe having all of them listed for all units that can use a formation might be easier for players, dunno i.e. return g_AvailableFormations.get(unitEntStates[0].player).filter(formation => unitEntStates.some(state => state.identity.formations.indexOf(formation) != -1)) where state.identity.formations is the FormationList in retrievable in the identity component. This would then also nuke the check above and the state.identity.canUseSomeFormation allocation bb: Just wondering, wouldnt it be better to only return those formations in which some unit of the… | |||||
"setupButton": function(data) | "setupButton": function(data) | ||||
{ | { | ||||
if (!g_FormationsInfo.has(data.item)) | if (!g_FormationsInfo.has(data.item)) | ||||
g_FormationsInfo.set(data.item, Engine.GuiInterfaceCall("GetFormationInfoFromTemplate", { "templateName": data.item })); | g_FormationsInfo.set(data.item, Engine.GuiInterfaceCall("GetFormationInfoFromTemplate", { "templateName": data.item })); | ||||
let formationInfo = g_FormationsInfo.get(data.item); | let formationInfo = g_FormationsInfo.get(data.item); | ||||
let formationOk = canMoveSelectionIntoFormation(data.item); | let formationOk = canMoveSelectionIntoFormation(data.item); | ||||
Not Done Inline ActionsDoes that imply you are forced to have a "None" formation defined in your mod? Stan: Does that imply you are forced to have a "None" formation defined in your mod? | |||||
Done Inline Actionschanged to template path, is not forced, but on does need it to be able to disable formation using commands anyway and i guess it is on another places too Silier: changed to template path, is not forced, but on does need it to be able to disable formation… | |||||
let unitIds = data.unitEntStates.map(state => state.id); | let unitIds = data.unitEntStates.map(state => state.id); | ||||
let formationSelected = Engine.GuiInterfaceCall("IsFormationSelected", { | let formationSelected = Engine.GuiInterfaceCall("IsFormationSelected", { | ||||
"ents": unitIds, | "ents": unitIds, | ||||
"formationTemplate": data.item | "formationTemplate": data.item | ||||
}); | }); | ||||
data.button.onPress = function() { | data.button.onPress = function() { | ||||
performFormation(unitIds, data.item); | performFormation(unitIds, data.item); | ||||
▲ Show 20 Lines • Show All 861 Lines • Show Last 20 Lines |
Comments start with caps. Forbidden -> Disabled.