Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/selection_panels.js
Show First 20 Lines • Show All 915 Lines • ▼ Show 20 Lines | "setupButton": function(data) | ||||
data.icon.sprite = "stretched:session/icons/stances/" + data.item + ".png"; | data.icon.sprite = "stretched:session/icons/stances/" + data.item + ".png"; | ||||
data.button.enabled = controlsPlayer(data.player); | data.button.enabled = controlsPlayer(data.player); | ||||
setPanelObjectPosition(data.button, data.i, data.rowLength); | setPanelObjectPosition(data.button, data.i, data.rowLength); | ||||
return true; | return true; | ||||
} | } | ||||
}; | }; | ||||
g_SelectionPanels.PrefAttack = { | |||||
"getMaxNumberOfItems": function() | |||||
{ | |||||
return 4; | |||||
Freagarach: 5 | |||||
}, | |||||
"getItems": function(entStates) | |||||
{ | |||||
if (entStates.some(state => !state.attack)) | |||||
return []; | |||||
let items = ["Default"]; | |||||
for (let entState of entStates) | |||||
items = items.concat(Object.keys(entState.attack).filter( | |||||
type => items.indexOf(type) == -1 | |||||
)); | |||||
FreagarachAuthorUnsubmitted Done Inline ActionsSlow. Freagarach: Slow. | |||||
FreagarachAuthorUnsubmitted Done Inline Actions
But attack types should be hardcoded then? Freagarach: > < elexis> "perhaps one can loop through the attack-types, and if one entity having that type… | |||||
FreagarachAuthorUnsubmitted Done Inline ActionsThe items = items.concat-part takes ~10 μs per entity (using Engine.GetMicroseconds()) down to 6 or 7 when multiple entities are selected. Freagarach: The `items = items.concat`-part takes ~10 μs per entity (using `Engine.GetMicroseconds()`) down… | |||||
// No point in showing only "Default" and one extra attack type. | |||||
return items.length > 2 ? items : ""; | |||||
}, | |||||
"setupButton": function(data) | |||||
{ | |||||
let entIds = data.unitEntStates.map(state => state.id); | |||||
data.button.onPress = function() { performPrefAttack(entIds, data.item); }; | |||||
data.button.tooltip = getPrefAttackDisplayName(data.item) + "\n" + | |||||
"[font=\"sans-13\"]" + getPrefAttackTooltip(data.item) + "[/font]"; | |||||
FreagarachAuthorUnsubmitted Done Inline Actionsfont tag. Freagarach: font tag. | |||||
FreagarachAuthorUnsubmitted Done Inline ActionsOught to be done in the entire file, out of scope I would say? Freagarach: Ought to be done in the entire file, out of scope I would say? | |||||
FreagarachAuthorUnsubmitted Done Inline ActionsFreagarach: D2151. | |||||
data.guiSelection.hidden = !Engine.GuiInterfaceCall("IsPrefAttackSelected", { | |||||
"ents": entIds, | |||||
"prefAttack": data.item | |||||
}); | |||||
data.icon.sprite = "stretched:session/icons/attacks/" + data.item.toLowerCase() + ".png"; | |||||
FreagarachAuthorUnsubmitted Not Done Inline Actions
Suggestions? Freagarach: > < elexis> don't construct filenames dynamically, as people will search for filenames… | |||||
data.button.enabled = controlsPlayer(data.player); | |||||
setPanelObjectPosition(data.button, data.i, data.rowLength); | |||||
return true; | |||||
} | |||||
}; | |||||
g_SelectionPanels.Training = { | g_SelectionPanels.Training = { | ||||
"getMaxNumberOfItems": function() | "getMaxNumberOfItems": function() | ||||
{ | { | ||||
return 24 - getNumberOfRightPanelButtons(); | return 24 - getNumberOfRightPanelButtons(); | ||||
}, | }, | ||||
"getItems": function() | "getItems": function() | ||||
{ | { | ||||
return getAllTrainableEntitiesFromSelection(); | return getAllTrainableEntitiesFromSelection(); | ||||
▲ Show 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | |||||
* Note that the panel needs to appear in the list to get rendered. | * Note that the panel needs to appear in the list to get rendered. | ||||
*/ | */ | ||||
let g_PanelsOrder = [ | let g_PanelsOrder = [ | ||||
// LEFT PANE | // LEFT PANE | ||||
"Barter", // Must always be visible on markets | "Barter", // Must always be visible on markets | ||||
"Garrison", // More important than Formation, as you want to see the garrisoned units in ships | "Garrison", // More important than Formation, as you want to see the garrisoned units in ships | ||||
"Alert", | "Alert", | ||||
"Formation", | "Formation", | ||||
"Stance", // Normal together with formation | "PrefAttack", // Normal together with formation and stance. | ||||
"Stance", // Normal together with formation and preferred attack. | |||||
// RIGHT PANE | // RIGHT PANE | ||||
"Gate", // Must always be shown on gates | "Gate", // Must always be shown on gates | ||||
"Pack", // Must always be shown on packable entities | "Pack", // Must always be shown on packable entities | ||||
"Upgrade", // Must always be shown on upgradable entities | "Upgrade", // Must always be shown on upgradable entities | ||||
"Training", | "Training", | ||||
"Construction", | "Construction", | ||||
"Research", // Normal together with training | "Research", // Normal together with training | ||||
// UNIQUE PANES (importance doesn't matter) | // UNIQUE PANES (importance doesn't matter) | ||||
"Command", | "Command", | ||||
"AllyCommand", | "AllyCommand", | ||||
"Queue", | "Queue", | ||||
"Selection", | "Selection", | ||||
]; | ]; |
Wildfire Games · Phabricator
5