Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/selection_details.js
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | if (entState.identity && entState.identity.rank && entState.identity.classes) | ||||
Engine.GetGUIObjectByName("rankIcon").hidden = false; | Engine.GetGUIObjectByName("rankIcon").hidden = false; | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
Engine.GetGUIObjectByName("rankIcon").hidden = true; | Engine.GetGUIObjectByName("rankIcon").hidden = true; | ||||
Engine.GetGUIObjectByName("rankIcon").tooltip = ""; | Engine.GetGUIObjectByName("rankIcon").tooltip = ""; | ||||
} | } | ||||
let showHealth = entState.hitpoints; | |||||
let showResource = entState.resourceSupply; | |||||
elexis: showCapture unneeded var | |||||
let healthSection = Engine.GetGUIObjectByName("healthSection"); | |||||
Done Inline ActionsI'd make that a local, move it tothe place where its used elexis: I'd make that a local, move it tothe place where its used | |||||
let captureSection = Engine.GetGUIObjectByName("captureSection"); | |||||
let resourceSection = Engine.GetGUIObjectByName("resourceSection"); | |||||
let sectionPosTop = Engine.GetGUIObjectByName("sectionPosTop"); | |||||
let sectionPosMiddle = Engine.GetGUIObjectByName("sectionPosMiddle"); | |||||
let sectionPosBottom = Engine.GetGUIObjectByName("sectionPosBottom"); | |||||
// Hitpoints | // Hitpoints | ||||
Engine.GetGUIObjectByName("healthSection").hidden = !entState.hitpoints; | healthSection.hidden = !showHealth; | ||||
if (entState.hitpoints) | if (showHealth) | ||||
{ | { | ||||
let unitHealthBar = Engine.GetGUIObjectByName("healthBar"); | let unitHealthBar = Engine.GetGUIObjectByName("healthBar"); | ||||
let healthSize = unitHealthBar.size; | let healthSize = unitHealthBar.size; | ||||
healthSize.rright = 100*Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints)); | healthSize.rright = 100*Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints)); | ||||
Not Done Inline Actions(could use spaces in a different diff) elexis: (could use spaces in a different diff) | |||||
unitHealthBar.size = healthSize; | unitHealthBar.size = healthSize; | ||||
if (entState.foundation && entState.visibility == "visible" && entState.foundation.numBuilders !== 0) | if (entState.foundation && entState.visibility == "visible" && entState.foundation.numBuilders !== 0) | ||||
Not Done Inline Actions(could remove the !== 0 in a different diff) elexis: (could remove the !== 0 in a different diff) | |||||
{ | { | ||||
// logic comes from Foundation component. | // logic comes from Foundation component. | ||||
Not Done Inline Actions(meh) elexis: (meh) | |||||
let speed = Math.pow(entState.foundation.numBuilders, 0.7); | let speed = Math.pow(entState.foundation.numBuilders, 0.7); | ||||
let timeLeft = (1.0 - entState.foundation.progress / 100.0) * template.cost.time; | let timeLeft = (1.0 - entState.foundation.progress / 100.0) * template.cost.time; | ||||
let timeToCompletion = Math.ceil(timeLeft/speed); | let timeToCompletion = Math.ceil(timeLeft/speed); | ||||
Engine.GetGUIObjectByName("health").tooltip = sprintf(translatePlural("This foundation will be completed in %(seconds)s second.", "This foundation will be completed in %(seconds)s seconds.", timeToCompletion), { "seconds": timeToCompletion }); | Engine.GetGUIObjectByName("health").tooltip = sprintf(translatePlural("This foundation will be completed in %(seconds)s second.", "This foundation will be completed in %(seconds)s seconds.", timeToCompletion), { "seconds": timeToCompletion }); | ||||
Not Done Inline Actions(could use an \n in a different diff) elexis: (could use an \n in a different diff) | |||||
} | } | ||||
else | else | ||||
Engine.GetGUIObjectByName("health").tooltip = ""; | Engine.GetGUIObjectByName("health").tooltip = ""; | ||||
Engine.GetGUIObjectByName("healthStats").caption = sprintf(translate("%(hitpoints)s / %(maxHitpoints)s"), { | Engine.GetGUIObjectByName("healthStats").caption = sprintf(translate("%(hitpoints)s / %(maxHitpoints)s"), { | ||||
"hitpoints": Math.ceil(entState.hitpoints), | "hitpoints": Math.ceil(entState.hitpoints), | ||||
"maxHitpoints": Math.ceil(entState.maxHitpoints) | "maxHitpoints": Math.ceil(entState.maxHitpoints) | ||||
}); | }); | ||||
healthSection.size = sectionPosTop.size; | |||||
captureSection.size = showResource ? sectionPosMiddle.size : sectionPosBottom.size; | |||||
resourceSection.size = showResource ? sectionPosBottom.size : sectionPosMiddle.size; | |||||
Not Done Inline ActionsIf that isn't straight forward, what is elexis: If that isn't straight forward, what is | |||||
} | |||||
else | |||||
{ | |||||
captureSection.size = sectionPosBottom.size; | |||||
Done Inline ActionsSame order in the two cases of the if elexis: Same order in the two cases of the if | |||||
Done Inline ActionsThe order could be the same as seen in the GUI, i.e. Health, CapturePoints, Resource amounts elexis: The order could be the same as seen in the GUI, i.e. Health, CapturePoints, Resource amounts | |||||
resourceSection.size = sectionPosTop.size; | |||||
} | } | ||||
// CapturePoints | // CapturePoints | ||||
Engine.GetGUIObjectByName("captureSection").hidden = !entState.capturePoints; | captureSection.hidden = !entState.capturePoints; | ||||
if (entState.capturePoints) | if (entState.capturePoints) | ||||
{ | { | ||||
let setCaptureBarPart = function(playerID, startSize) { | let setCaptureBarPart = function(playerID, startSize) { | ||||
let unitCaptureBar = Engine.GetGUIObjectByName("captureBar["+playerID+"]"); | let unitCaptureBar = Engine.GetGUIObjectByName("captureBar["+playerID+"]"); | ||||
let sizeObj = unitCaptureBar.size; | let sizeObj = unitCaptureBar.size; | ||||
sizeObj.rleft = startSize; | sizeObj.rleft = startSize; | ||||
let size = 100*Math.max(0, Math.min(1, entState.capturePoints[playerID] / entState.maxCapturePoints)); | let size = 100*Math.max(0, Math.min(1, entState.capturePoints[playerID] / entState.maxCapturePoints)); | ||||
sizeObj.rright = startSize + size; | sizeObj.rright = startSize + size; | ||||
unitCaptureBar.size = sizeObj; | unitCaptureBar.size = sizeObj; | ||||
unitCaptureBar.sprite = "color: " + rgbToGuiColor(g_Players[playerID].color, 128); | unitCaptureBar.sprite = "color: " + rgbToGuiColor(g_Players[playerID].color, 128); | ||||
unitCaptureBar.hidden=false; | unitCaptureBar.hidden=false; | ||||
return startSize + size; | return startSize + size; | ||||
}; | }; | ||||
// first handle the owner's points, to keep those points on the left for clarity | // first handle the owner's points, to keep those points on the left for clarity | ||||
let size = setCaptureBarPart(entState.player, 0); | let size = setCaptureBarPart(entState.player, 0); | ||||
for (let i in entState.capturePoints) | for (let i in entState.capturePoints) | ||||
if (i != entState.player) | if (i != entState.player) | ||||
size = setCaptureBarPart(i, size); | size = setCaptureBarPart(i, size); | ||||
Engine.GetGUIObjectByName("captureStats").caption = sprintf(translate("%(capturePoints)s / %(maxCapturePoints)s"), { | let captureText = sprintf(translate("%(capturePoints)s / %(maxCapturePoints)s"), { | ||||
"capturePoints": Math.ceil(entState.capturePoints[entState.player]), | "capturePoints": Math.ceil(entState.capturePoints[entState.player]), | ||||
"maxCapturePoints": Math.ceil(entState.maxCapturePoints) | "maxCapturePoints": Math.ceil(entState.maxCapturePoints) | ||||
}); | }); | ||||
Done Inline Actions-1 tab each elexis: -1 tab each | |||||
let showSmallCapture = showResource && showHealth; | |||||
Engine.GetGUIObjectByName("captureStats").caption = showSmallCapture ? "": captureText; | |||||
Engine.GetGUIObjectByName("capture").tooltip = showSmallCapture ? captureText : ""; | |||||
} | } | ||||
// Experience | // Experience | ||||
Engine.GetGUIObjectByName("experience").hidden = !entState.promotion; | Engine.GetGUIObjectByName("experience").hidden = !entState.promotion; | ||||
if (entState.promotion) | if (entState.promotion) | ||||
{ | { | ||||
let experienceBar = Engine.GetGUIObjectByName("experienceBar"); | let experienceBar = Engine.GetGUIObjectByName("experienceBar"); | ||||
let experienceSize = experienceBar.size; | let experienceSize = experienceBar.size; | ||||
Show All 9 Lines | if (entState.promotion) | ||||
else | else | ||||
Engine.GetGUIObjectByName("experience").tooltip = sprintf(translate("%(experience)s %(current)s"), { | Engine.GetGUIObjectByName("experience").tooltip = sprintf(translate("%(experience)s %(current)s"), { | ||||
"experience": "[font=\"sans-bold-13\"]" + translate("Experience:") + "[/font]", | "experience": "[font=\"sans-bold-13\"]" + translate("Experience:") + "[/font]", | ||||
"current": Math.floor(entState.promotion.curr) | "current": Math.floor(entState.promotion.curr) | ||||
}); | }); | ||||
} | } | ||||
// Resource stats | // Resource stats | ||||
Engine.GetGUIObjectByName("resourceSection").hidden = !entState.resourceSupply; | resourceSection.hidden = !showResource; | ||||
if (entState.resourceSupply) | if (entState.resourceSupply) | ||||
{ | { | ||||
let resources = entState.resourceSupply.isInfinite ? translate("∞") : // Infinity symbol | let resources = entState.resourceSupply.isInfinite ? translate("∞") : // Infinity symbol | ||||
sprintf(translate("%(amount)s / %(max)s"), { | sprintf(translate("%(amount)s / %(max)s"), { | ||||
"amount": Math.ceil(+entState.resourceSupply.amount), | "amount": Math.ceil(+entState.resourceSupply.amount), | ||||
"max": entState.resourceSupply.max | "max": entState.resourceSupply.max | ||||
}); | }); | ||||
let unitResourceBar = Engine.GetGUIObjectByName("resourceBar"); | let unitResourceBar = Engine.GetGUIObjectByName("resourceBar"); | ||||
let resourceSize = unitResourceBar.size; | let resourceSize = unitResourceBar.size; | ||||
resourceSize.rright = entState.resourceSupply.isInfinite ? 100 : | resourceSize.rright = entState.resourceSupply.isInfinite ? 100 : | ||||
100 * Math.max(0, Math.min(1, +entState.resourceSupply.amount / +entState.resourceSupply.max)); | 100 * Math.max(0, Math.min(1, +entState.resourceSupply.amount / +entState.resourceSupply.max)); | ||||
unitResourceBar.size = resourceSize; | unitResourceBar.size = resourceSize; | ||||
Engine.GetGUIObjectByName("resourceLabel").caption = sprintf(translate("%(resource)s:"), { | Engine.GetGUIObjectByName("resourceLabel").caption = sprintf(translate("%(resource)s:"), { | ||||
"resource": getResourceTypeDisplayName(entState.resourceSupply.type) | "resource": getResourceTypeDisplayName(entState.resourceSupply.type) | ||||
}); | }); | ||||
Engine.GetGUIObjectByName("resourceStats").caption = resources; | Engine.GetGUIObjectByName("resourceStats").caption = resources; | ||||
if (entState.hitpoints) | |||||
Engine.GetGUIObjectByName("resourceSection").size = Engine.GetGUIObjectByName("captureSection").size; | |||||
else | |||||
Engine.GetGUIObjectByName("resourceSection").size = Engine.GetGUIObjectByName("healthSection").size; | |||||
} | } | ||||
// Resource carrying | // Resource carrying | ||||
if (entState.resourceCarrying && entState.resourceCarrying.length) | if (entState.resourceCarrying && entState.resourceCarrying.length) | ||||
{ | { | ||||
// We should only be carrying one resource type at once, so just display the first | // We should only be carrying one resource type at once, so just display the first | ||||
let carried = entState.resourceCarrying[0]; | let carried = entState.resourceCarrying[0]; | ||||
▲ Show 20 Lines • Show All 323 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
showCapture unneeded var