Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/common/tooltips.js
Show First 20 Lines • Show All 754 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* Returns the resources this entity supplies in the specified entity's tooltip | * Returns the resources this entity supplies in the specified entity's tooltip | ||||
*/ | */ | ||||
function getResourceSupplyTooltip(template) | function getResourceSupplyTooltip(template) | ||||
{ | { | ||||
if (!template.supply) | if (!template.supply) | ||||
return ""; | return ""; | ||||
let supply = template.supply; | let supply = template.supply; | ||||
let type = supply.type[0] == "treasure" ? supply.type[1] : supply.type[0]; | |||||
// Translation: Label in tooltip showing the resource type and quantity of a given resource supply. | // Translation: Label in tooltip showing the resource type and quantity of a given resource supply. | ||||
Stan: Inline? | |||||
return sprintf(translate("%(label)s %(component)s %(amount)s"), { | return sprintf(translate("%(label)s %(component)s %(amount)s"), { | ||||
"label": headerFont(translate("Resource Supply:")), | "label": headerFont(translate("Resource Supply:")), | ||||
"component": resourceIcon(type), | "component": resourceIcon(supply.type[0]), | ||||
// Translation: Marks that a resource supply entity has an unending, infinite, supply of its resource. | // Translation: Marks that a resource supply entity has an unending, infinite, supply of its resource. | ||||
"amount": Number.isFinite(+supply.amount) ? supply.amount : translate("∞") | "amount": Number.isFinite(+supply.amount) ? supply.amount : translate("∞") | ||||
Done Inline Actionsshould be template.supply I think. Sorry I only meant inlining type. Stan: should be template.supply I think. Sorry I only meant inlining type. | |||||
Done Inline ActionsI assumed inlining type xD (So the supply removal was an accident.) Freagarach: I assumed inlining type xD (So the `supply` removal was an accident.) | |||||
}); | }); | ||||
} | } | ||||
/** | |||||
* @param {Object} template - The entity's template. | |||||
Done Inline ActionsI don't understand this sentence wraitii: I don't understand this sentence | |||||
* @return {string} - The resources this entity rewards to a collecter. | |||||
*/ | |||||
function getTreasureTooltip(template) | |||||
{ | |||||
if (!template.treasure) | |||||
return ""; | |||||
let resources = {}; | |||||
for (let resource of g_ResourceData.GetResources()) | |||||
{ | |||||
let type = resource.code; | |||||
if (template.treasure.resources[type]) | |||||
resources[type] = template.treasure.resources[type]; | |||||
} | |||||
Done Inline ActionsMake it a variable :) and reuse it below. Stan: Make it a variable :) and reuse it below. | |||||
let resourceNames = Object.keys(resources); | |||||
if (!resourceNames.length) | |||||
return ""; | |||||
return sprintf(translate("%(label)s %(details)s"), { | |||||
"label": headerFont(translate("Reward:")), | |||||
"details": | |||||
resourceNames.map( | |||||
type => sprintf(translate("%(resourceIcon)s %(reward)s"), { | |||||
"resourceIcon": resourceIcon(type), | |||||
"reward": resources[type] | |||||
}) | |||||
).join(" ") | |||||
}); | |||||
} | |||||
function getResourceTrickleTooltip(template) | function getResourceTrickleTooltip(template) | ||||
{ | { | ||||
if (!template.resourceTrickle) | if (!template.resourceTrickle) | ||||
return ""; | return ""; | ||||
let resCodes = g_ResourceData.GetCodes().filter(res => !!template.resourceTrickle.rates[res]); | let resCodes = g_ResourceData.GetCodes().filter(res => !!template.resourceTrickle.rates[res]); | ||||
if (!resCodes.length) | if (!resCodes.length) | ||||
return ""; | return ""; | ||||
▲ Show 20 Lines • Show All 334 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Inline?