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" } | ||||
}; | }; | ||||
function getCostTypes() | function getCostTypes() | ||||
{ | { | ||||
return g_ResourceData.GetCodes().concat(["population", "populationBonus", "time"]); | return g_ResourceData.GetCodes().concat(["population", "populationBonus", "time"]); | ||||
} | } | ||||
var g_AttackForms = { | |||||
"Melee": translate("Melee Attack:"), | |||||
"Ranged": translate("Ranged Attack:"), | |||||
"Capture": translate("Capture Attack:"), | |||||
"Slaughter": translate("Slaughter Attack:") | |||||
}; | |||||
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; | ||||
▲ Show 20 Lines • Show All 283 Lines • ▼ Show 20 Lines | |||||
function getAttackTooltip(template) | function getAttackTooltip(template) | ||||
{ | { | ||||
if (!template.attack) | if (!template.attack) | ||||
return ""; | return ""; | ||||
let tooltips = []; | let tooltips = []; | ||||
for (let attackType in template.attack) | for (let attackType in template.attack) | ||||
{ | { | ||||
// Slaughter is used to kill animals, so do not show it. | let attackLabel = headerFont(g_AttackForms[template.attack[attackType].form]); | ||||
Freagarach: (Maybe a tag in ResourceGatherer that allows slaughtering?) | |||||
Done Inline ActionsWe have the restricted classes right to choose the attacktype with (or better dissallow slaughter for anything but Domestics). For the GUI we eventually might want to show the restricted classes, but mehing that here bb: We have the restricted classes right to choose the attacktype with (or better dissallow… | |||||
if (attackType == "Slaughter") | |||||
continue; | |||||
let attackLabel = sprintf(headerFont(translate("%(attackType)s Attack")), { | |||||
"attackType": attackType | |||||
}); | |||||
let attackTypeTemplate = template.attack[attackType]; | let attackTypeTemplate = template.attack[attackType]; | ||||
let projectiles; | let projectiles; | ||||
// Use either current rate from simulation or default count if the sim is not running. | // Use either current rate from simulation or default count if the sim is not running. | ||||
// ToDo: This ought to be extended to include units which fire multiple projectiles. | // ToDo: This ought to be extended to include units which fire multiple projectiles. | ||||
if (template.buildingAI) | if (template.buildingAI) | ||||
projectiles = template.buildingAI.arrowCount || template.buildingAI.defaultArrowCount; | projectiles = template.buildingAI.arrowCount || template.buildingAI.defaultArrowCount; | ||||
// Show the effects of status effects below | // Show the effects of status effects below | ||||
let statusEffectsDetails = []; | let statusEffectsDetails = []; | ||||
if (attackTypeTemplate.ApplyStatus) | if (attackTypeTemplate.ApplyStatus) | ||||
for (let status in attackTypeTemplate.ApplyStatus) | for (let status in attackTypeTemplate.ApplyStatus) | ||||
{ | { | ||||
let status_template = g_StatusEffectsMetadata.augment(status, attackTypeTemplate.ApplyStatus[status]); | let status_template = g_StatusEffectsMetadata.augment(status, attackTypeTemplate.ApplyStatus[status]); | ||||
statusEffectsDetails.push("\n " + getStatusEffectsTooltip(status_template, true)); | statusEffectsDetails.push("\n " + getStatusEffectsTooltip(status_template, true)); | ||||
} | } | ||||
statusEffectsDetails = statusEffectsDetails.join(""); | statusEffectsDetails = statusEffectsDetails.join(""); | ||||
tooltips.push(sprintf(translate("%(attackLabel)s: %(effects)s, %(range)s, %(rate)s%(statusEffects)s"), { | tooltips.push(sprintf(translate("%(attackLabel)s %(effects)s, %(range)s, %(rate)s%(statusEffects)s"), { | ||||
"attackLabel": attackLabel, | "attackLabel": attackLabel, | ||||
"effects": attackEffectsDetails(attackTypeTemplate), | "effects": attackEffectsDetails(attackTypeTemplate), | ||||
"range": rangeDetails(attackTypeTemplate), | "range": rangeDetails(attackTypeTemplate), | ||||
"rate": attackRateDetails(attackTypeTemplate.repeatTime, projectiles), | "rate": attackRateDetails(attackTypeTemplate.repeatTime, projectiles), | ||||
"statusEffects": statusEffectsDetails | "statusEffects": statusEffectsDetails | ||||
})); | })); | ||||
} | } | ||||
return tooltips.join("\n"); | return tooltips.join("\n"); | ||||
▲ Show 20 Lines • Show All 599 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
(Maybe a tag in ResourceGatherer that allows slaughtering?)