Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/common/tooltips.js
var g_TooltipTextFormats = { | var g_TooltipTextFormats = { | ||||
"unit": { "font": "sans-10", "color": "orange" }, | "unit": { "font": "sans-10", "color": "orange" }, | ||||
"header": { "font": "sans-bold-13" }, | "header": { "font": "sans-bold-13" }, | ||||
"body": { "font": "sans-13" }, | "body": { "font": "sans-13" }, | ||||
"comma": { "font": "sans-12" }, | "comma": { "font": "sans-12" }, | ||||
"nameSpecificBig": { "font": "sans-bold-16" }, | "nameSpecificBig": { "font": "sans-bold-16" }, | ||||
"nameSpecificSmall": { "font": "sans-bold-12" }, | "nameSpecificSmall": { "font": "sans-bold-12" }, | ||||
"nameGeneric": { "font": "sans-bold-16" } | "nameGeneric": { "font": "sans-bold-16" } | ||||
}; | }; | ||||
/** | /** | ||||
Freagarach: Is the `bonus` still needed here? (And check the implications of its removal here.) | |||||
* String of four spaces to be used as indentation in gui strings. | * String of four spaces to be used as indentation in gui strings. | ||||
*/ | */ | ||||
var g_Indent = " "; | var g_Indent = " "; | ||||
var g_DamageTypesMetadata = new DamageTypesMetadata(); | var g_DamageTypesMetadata = new DamageTypesMetadata(); | ||||
var g_StatusEffectsMetadata = new StatusEffectsMetadata(); | var g_StatusEffectsMetadata = new StatusEffectsMetadata(); | ||||
/** | /** | ||||
* If true, always shows whether the splash damage deals friendly fire. | * If true, always shows whether the splash damage deals friendly fire. | ||||
* Otherwise display the friendly fire tooltip only if it does. | * Otherwise display the friendly fire tooltip only if it does. | ||||
*/ | */ | ||||
var g_AlwaysDisplayFriendlyFire = false; | var g_AlwaysDisplayFriendlyFire = false; | ||||
function getCostTypes() | function getCostTypes() | ||||
{ | { | ||||
return g_ResourceData.GetCodes().concat(["population", "populationBonus", "time"]); | return g_ResourceData.GetCodes().concat(["population", "time"]); | ||||
} | } | ||||
function resourceIcon(resource) | function resourceIcon(resource) | ||||
{ | { | ||||
return '[icon="icon_' + resource + '"]'; | return '[icon="icon_' + resource + '"]'; | ||||
} | } | ||||
function resourceNameFirstWord(type) | function resourceNameFirstWord(type) | ||||
▲ Show 20 Lines • Show All 609 Lines • ▼ Show 20 Lines | function getEntityCostComponentsTooltipString(template, entity, buildingsCountToTrainFullBatch = 1, fullBatchSize = 1, remainderBatch = 0) | ||||
let totalCosts = multiplyEntityCosts(template, buildingsCountToTrainFullBatch * fullBatchSize + remainderBatch); | let totalCosts = multiplyEntityCosts(template, buildingsCountToTrainFullBatch * fullBatchSize + remainderBatch); | ||||
if (template.cost.time) | if (template.cost.time) | ||||
totalCosts.time = Math.ceil(template.cost.time * (entity ? Engine.GuiInterfaceCall("GetBatchTime", { | totalCosts.time = Math.ceil(template.cost.time * (entity ? Engine.GuiInterfaceCall("GetBatchTime", { | ||||
"entity": entity, | "entity": entity, | ||||
"batchSize": buildingsCountToTrainFullBatch > 0 ? fullBatchSize : remainderBatch | "batchSize": buildingsCountToTrainFullBatch > 0 ? fullBatchSize : remainderBatch | ||||
}) : 1)); | }) : 1)); | ||||
let costs = []; | let costs = []; | ||||
for (let type of getCostTypes()) | for (let type of getCostTypes()) | ||||
// Population bonus is shown in the tooltip | if (totalCosts[type]) | ||||
Done Inline Actions@Freagarach I think this type != "bonus" is also not needed, since we're not doing that anymore in getCostTypes() ? Just totalCosts[type] would be enough, right? lonehawk: @Freagarach I think this `type != "bonus"` is also not needed, since we're not doing that… | |||||
Done Inline ActionsAye :) Freagarach: Aye :) | |||||
Not Done Inline ActionsComment is not needed anymore. Freagarach: Comment is not needed anymore. | |||||
if (type != "populationBonus" && totalCosts[type]) | |||||
costs.push(sprintf(translate("%(component)s %(cost)s"), { | costs.push(sprintf(translate("%(component)s %(cost)s"), { | ||||
"component": resourceIcon(type), | "component": resourceIcon(type), | ||||
"cost": totalCosts[type] | "cost": totalCosts[type] | ||||
})); | })); | ||||
return costs; | return costs; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | function getRequiredTechnologyTooltip(technologyEnabled, requiredTechnology, civ) | ||||
return sprintf(translate("Requires %(technology)s"), { | return sprintf(translate("Requires %(technology)s"), { | ||||
"technology": getEntityNames(GetTechnologyData(requiredTechnology, civ)) | "technology": getEntityNames(GetTechnologyData(requiredTechnology, civ)) | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Returns the population bonus information to display in the specified entity's construction button tooltip. | * Returns the population bonus information to display in the specified entity's construction button tooltip. | ||||
*/ | */ | ||||
function getPopulationBonusTooltip(template) | function getPopulationBonusTooltip(template) | ||||
{ | { | ||||
let popBonus = ""; | if (!template.population || !template.population.bonus) | ||||
if (template.cost && template.cost.populationBonus) | return ""; | ||||
popBonus = sprintf(translate("%(label)s %(populationBonus)s"), { | |||||
"label": headerFont(translate("Population Bonus:")), | return sprintf(translate("%(label)s %(bonus)s"), { | ||||
"populationBonus": template.cost.populationBonus | "label": headerFont(translate("Population Bonus:")), | ||||
}); | "bonus": template.population.bonus | ||||
return popBonus; | }); | ||||
} | } | ||||
/** | /** | ||||
* Returns a message with the amount of each resource needed to create an entity. | * Returns a message with the amount of each resource needed to create an entity. | ||||
*/ | */ | ||||
function getNeededResourcesTooltip(resources) | function getNeededResourcesTooltip(resources) | ||||
{ | { | ||||
if (!resources) | if (!resources) | ||||
▲ Show 20 Lines • Show All 195 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Is the bonus still needed here? (And check the implications of its removal here.)