Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/session.js
Show First 20 Lines • Show All 401 Lines • ▼ Show 20 Lines | for (let guid in g_PlayerAssignments) | ||||
playerData[playerID].guid = guid; | playerData[playerID].guid = guid; | ||||
playerData[playerID].name = g_PlayerAssignments[guid].name; | playerData[playerID].name = g_PlayerAssignments[guid].name; | ||||
} | } | ||||
g_Players = playerData; | g_Players = playerData; | ||||
} | } | ||||
/** | /** | ||||
* Returns the entity itself except when garrisoned where it returns its garrisonHolder | * @return {number} - The entity itself except when garrisoned then its garrisonHolder. | ||||
Stan: Could specify that it's a number too. | |||||
*/ | */ | ||||
function getEntityOrHolder(ent) | function getEntityOrHolder(ent) | ||||
{ | { | ||||
let entState = GetEntityState(ent); | let entState = GetEntityState(ent); | ||||
if (entState && !entState.position && entState.unitAI && entState.unitAI.orders.length && | if (entState && !entState.position && entState.garrisonable && entState.garrisonable.garrisonHolder != INVALID_ENTITY) | ||||
entState.unitAI.orders[0].type == "Garrison") | return getEntityOrHolder(entState.garrisonable.garrisonHolder); | ||||
return getEntityOrHolder(entState.unitAI.orders[0].data.target); | |||||
return ent; | return ent; | ||||
} | } | ||||
function initializeMusic() | function initializeMusic() | ||||
{ | { | ||||
initMusic(); | initMusic(); | ||||
if (g_ViewedPlayer != -1 && g_CivData[g_Players[g_ViewedPlayer].civ].Music) | if (g_ViewedPlayer != -1 && g_CivData[g_Players[g_ViewedPlayer].civ].Music) | ||||
▲ Show 20 Lines • Show All 265 Lines • ▼ Show 20 Lines | function updateGroups() | ||||
}; | }; | ||||
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; | ||||
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); | ||||
Lint: ESLintBear (no-shadow) 'i' is already declared in the upper scope. Lint: ESLintBear (no-shadow): `'i' is already declared in the upper scope.` | |||||
button.onDoublePress = (function(i) { return function() { performGroup("snap", i); }; })(i); | button.onDoublePress = (function(i) { return function() { performGroup("snap", i); }; })(i); | ||||
Lint: ESLintBear (no-shadow) 'i' is already declared in the upper scope. Lint: ESLintBear (no-shadow): `'i' is already declared in the upper scope.` | |||||
button.onPressRight = (function(i) { return function() { performGroup("breakUp", i); }; })(i); | button.onPressRight = (function(i) { return function() { performGroup("breakUp", i); }; })(i); | ||||
Lint: ESLintBear (no-shadow) 'i' is already declared in the upper scope. Lint: ESLintBear (no-shadow): `'i' is already declared in the upper scope.` | |||||
// 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) | ||||
if (g_Groups.groups[i].getTotalCount() > 0) | if (g_Groups.groups[i].getTotalCount() > 0) | ||||
{ | { | ||||
let icon = GetTemplateData(GetEntityState(g_Groups.groups[i].getEntsGrouped().reduce((pre, cur) => { | let icon = GetTemplateData(GetEntityState(g_Groups.groups[i].getEntsGrouped().reduce((pre, cur) => { | ||||
if (pre.ents.length == cur.ents.length) | if (pre.ents.length == cur.ents.length) | ||||
return getCostSum(pre.ents[0]) > getCostSum(cur.ents[0]) ? pre : cur; | return getCostSum(pre.ents[0]) > getCostSum(cur.ents[0]) ? pre : cur; | ||||
return pre.ents.length > cur.ents.length ? pre : cur; | return pre.ents.length > cur.ents.length ? pre : cur; | ||||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Could specify that it's a number too.