Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/selection_details.js
Show First 20 Lines • Show All 312 Lines • ▼ Show 20 Lines | function displaySingle(entState) | ||||
// TODO: we should require all entities to have icons | // TODO: we should require all entities to have icons | ||||
Engine.GetGUIObjectByName("icon").sprite = template.icon ? ("stretched:session/portraits/" + template.icon) : "BackgroundBlack"; | Engine.GetGUIObjectByName("icon").sprite = template.icon ? ("stretched:session/portraits/" + template.icon) : "BackgroundBlack"; | ||||
if (template.icon) | if (template.icon) | ||||
Engine.GetGUIObjectByName("iconBorder").onPressRight = () => { | Engine.GetGUIObjectByName("iconBorder").onPressRight = () => { | ||||
showTemplateDetails(entState.template); | showTemplateDetails(entState.template); | ||||
}; | }; | ||||
let SetupStat = (panel, i, icon, text) => { | |||||
if (!text) | |||||
{ | |||||
Engine.GetGUIObjectByName(`${panel}[${i}]`).hidden = true; | |||||
return; | |||||
} | |||||
Engine.GetGUIObjectByName(`${panel}[${i}]`).hidden = false; | |||||
Engine.GetGUIObjectByName(`${panel}Icon[${i}]`).sprite = "stretched:color:255 255 255 30:textureAsMask:" + icon; | |||||
let size = Engine.GetGUIObjectByName(`${panel}[${i}]`).size; | |||||
size.top = 30*i; | |||||
size.bottom = 30*i+28; | |||||
Engine.GetGUIObjectByName(`${panel}[${i}]`).size = size; | |||||
Engine.GetGUIObjectByName(`${panel}Text[${i}]`).caption = text; | |||||
}; | |||||
// Left-hand side of the stats panel | |||||
// DPS first. | |||||
if (!!template?.attack?.Melee || !!template?.attack?.Ranged) | |||||
Lint: ESLintBear: `Parsing error: Unexpected token .` | |||||
Lint: JSHintBear Expected an identifier and instead saw '.'. Lint: JSHintBear: `Expected an identifier and instead saw '.'.` | |||||
Lint: JSHintBear Expected ':' and instead saw 'attack'. Lint: JSHintBear: `Expected ':' and instead saw 'attack'.` | |||||
Lint: JSHintBear Expected an identifier and instead saw '?'. Lint: JSHintBear: `Expected an identifier and instead saw '?'.` | |||||
FreagarachUnsubmitted Not Done Inline ActionsI guess we need to teach the linter about the new possibilities. Freagarach: I guess we need to teach the linter about the new possibilities. | |||||
{ | |||||
let DPS = (template?.attack?.Melee || template?.attack?.Ranged)?.Damage; | |||||
DPS = (DPS?.Hack || 0) + (DPS?.Pierce || 0) + (DPS?.Crush || 0); | |||||
SetupStat("LHS", 0, "session/icons/dps.png", | |||||
(DPS / (template?.attack?.Melee || template?.attack?.Ranged).repeatTime * 1000).toFixed(1)); | |||||
wraitiiAuthorUnsubmitted Done Inline ActionsI'm showing averaged DPS instead of raw attack or per-damage attack, because I think it's sufficient to get a rough idea of how strong the unit is.
and so on. wraitii: I'm showing averaged DPS instead of raw attack or per-damage attack, because I think it's… | |||||
} | |||||
else | |||||
SetupStat("LHS", 0); | |||||
// Capture DPS | |||||
if (!!template?.attack?.Capture) | |||||
{ | |||||
let CDPS = template.attack.Capture.Capture || 0; | |||||
SetupStat("LHS", 1, "session/icons/cdps.png", | |||||
(CDPS / template.attack.Capture.repeatTime * 1000).toFixed(1)); | |||||
} | |||||
else | |||||
SetupStat("LHS", 1); | |||||
// Range | |||||
if (!!template?.attack?.Ranged) | |||||
SetupStat("LHS", 2, "session/icons/range.png", template.attack.Ranged.maxRange || 0); | |||||
else | |||||
SetupStat("LHS", 2); | |||||
// Right-hand side -> resistances | |||||
if (!!template?.resistance?.Damage) | |||||
{ | |||||
SetupStat("RHS", 0, "session/icons/res_hack.png", template.resistance.Damage?.Hack || 0); | |||||
SetupStat("RHS", 1, "session/icons/res_pierce.png", template.resistance.Damage?.Pierce || 0); | |||||
SetupStat("RHS", 2, "session/icons/res_crush.png", template.resistance.Damage?.Crush || 0); | |||||
} | |||||
else | |||||
{ | |||||
SetupStat("RHS", 0); | |||||
SetupStat("RHS", 1); | |||||
SetupStat("RHS", 2); | |||||
} | |||||
let detailedTooltip = [ | let detailedTooltip = [ | ||||
getAttackTooltip, | getAttackTooltip, | ||||
getHealerTooltip, | getHealerTooltip, | ||||
getResistanceTooltip, | getResistanceTooltip, | ||||
getGatherTooltip, | getGatherTooltip, | ||||
getSpeedTooltip, | getSpeedTooltip, | ||||
getGarrisonTooltip, | getGarrisonTooltip, | ||||
getPopulationBonusTooltip, | getPopulationBonusTooltip, | ||||
getProjectilesTooltip, | getProjectilesTooltip, | ||||
getResourceTrickleTooltip, | getResourceTrickleTooltip, | ||||
getLootTooltip | getLootTooltip | ||||
].map(func => func(entState)).filter(tip => tip).join("\n"); | ].map(func => func(entState)).filter(tip => tip).join("\n"); | ||||
if (detailedTooltip) | if (detailedTooltip) | ||||
{ | { | ||||
Engine.GetGUIObjectByName("attackAndResistanceStats").hidden = false; | Engine.GetGUIObjectByName("attackAndResistanceStats").hidden = true; | ||||
Engine.GetGUIObjectByName("attackAndResistanceStats").tooltip = detailedTooltip; | Engine.GetGUIObjectByName("attackAndResistanceStats").tooltip = detailedTooltip; | ||||
} | } | ||||
else | else | ||||
Engine.GetGUIObjectByName("attackAndResistanceStats").hidden = true; | Engine.GetGUIObjectByName("attackAndResistanceStats").hidden = true; | ||||
let iconTooltips = []; | let iconTooltips = []; | ||||
if (genericName) | if (genericName) | ||||
▲ Show 20 Lines • Show All 215 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Parsing error: Unexpected token .