Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/session/session.js
Show First 20 Lines • Show All 745 Lines • ▼ Show 20 Lines | function updateGroups() | ||||
// Determine the sum of the costs of a given template | // Determine the sum of the costs of a given template | ||||
let getCostSum = (ent) => { | let getCostSum = (ent) => { | ||||
let cost = GetTemplateData(GetEntityState(ent).template).cost; | let cost = GetTemplateData(GetEntityState(ent).template).cost; | ||||
return cost ? Object.keys(cost).map(key => cost[key]).reduce((sum, cur) => sum + cur) : 0; | return cost ? Object.keys(cost).map(key => cost[key]).reduce((sum, cur) => sum + cur) : 0; | ||||
}; | }; | ||||
for (let i in Engine.GetGUIObjectByName("unitGroupPanel").children) | for (let i in Engine.GetGUIObjectByName("unitGroupPanel").children) | ||||
{ | { | ||||
Engine.GetGUIObjectByName("unitGroupLabel[" + i + "]").caption = i; | Engine.GetGUIObjectByName("unitGroupLabel[" + i + "]").caption = +i + 1; | ||||
let button = Engine.GetGUIObjectByName("unitGroupButton[" + i + "]"); | let button = Engine.GetGUIObjectByName("unitGroupButton[" + i + "]"); | ||||
button.hidden = g_Groups.groups[i].getTotalCount() == 0; | button.hidden = g_Groups.groups[i].getTotalCount() == 0; | ||||
button.onPress = (function(i) { return function() { performGroup((Engine.HotkeyIsPressed("selection.add") ? "add" : "select"), i); }; })(i); | button.onPress = (function(i) { return function() { performGroup((Engine.HotkeyIsPressed("selection.add") ? "add" : "select"), i); }; })(i); | ||||
button.onDoublePress = (function(i) { return function() { performGroup("snap", i); }; })(i); | button.onDoublePress = (function(i) { return function() { performGroup("snap", i); }; })(i); | ||||
button.onPressRight = (function(i) { return function() { performGroup("breakUp", i); }; })(i); | button.onPressRight = (function(i) { return function() { performGroup("breakUp", i); }; })(i); | ||||
// Choose the icon of the most common template (or the most costly if it's not unique) | // Choose the icon of the most common template (or the most costly if it's not unique) | ||||
▲ Show 20 Lines • Show All 119 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator