mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-24 09:13:42 +00:00
Indent attack tooltips
Show splash per attacktype and indent Patch By: Nescio Comments By: Freagarach Differential Revision: D2984 This was SVN commit r24022.
This commit is contained in:
@@ -8,10 +8,10 @@ var g_TooltipTextFormats = {
|
|||||||
"nameGeneric": { "font": "sans-bold-16" }
|
"nameGeneric": { "font": "sans-bold-16" }
|
||||||
};
|
};
|
||||||
|
|
||||||
function getCostTypes()
|
/**
|
||||||
{
|
* String of four spaces to be used as indentation in gui strings.
|
||||||
return g_ResourceData.GetCodes().concat(["population", "populationBonus", "time"]);
|
*/
|
||||||
}
|
var g_Indent = " ";
|
||||||
|
|
||||||
var g_DamageTypesMetadata = new DamageTypesMetadata();
|
var g_DamageTypesMetadata = new DamageTypesMetadata();
|
||||||
var g_StatusEffectsMetadata = new StatusEffectsMetadata();
|
var g_StatusEffectsMetadata = new StatusEffectsMetadata();
|
||||||
@@ -22,6 +22,11 @@ var g_StatusEffectsMetadata = new StatusEffectsMetadata();
|
|||||||
*/
|
*/
|
||||||
var g_AlwaysDisplayFriendlyFire = false;
|
var g_AlwaysDisplayFriendlyFire = false;
|
||||||
|
|
||||||
|
function getCostTypes()
|
||||||
|
{
|
||||||
|
return g_ResourceData.GetCodes().concat(["population", "populationBonus", "time"]);
|
||||||
|
}
|
||||||
|
|
||||||
function resourceIcon(resource)
|
function resourceIcon(resource)
|
||||||
{
|
{
|
||||||
return '[icon="icon_' + resource + '"]';
|
return '[icon="icon_' + resource + '"]';
|
||||||
@@ -176,11 +181,11 @@ function getResistanceTooltip(template)
|
|||||||
if (template.resistance.Capture)
|
if (template.resistance.Capture)
|
||||||
details.push(getCaptureResistanceTooltip(template.resistance.Capture));
|
details.push(getCaptureResistanceTooltip(template.resistance.Capture));
|
||||||
|
|
||||||
// ToDo: Status effects resistance.
|
// TODO: Status effects resistance.
|
||||||
|
|
||||||
return sprintf(translate("%(label)s\n %(details)s"), {
|
return sprintf(translate("%(label)s\n" + g_Indent + "%(details)s"), {
|
||||||
"label": headerFont(translate("Resistance:")),
|
"label": headerFont(translate("Resistance:")),
|
||||||
"details": details.join("\n ")
|
"details": details.join("\n" + g_Indent)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +195,7 @@ function getDamageResistanceTooltip(resistanceTypeTemplate)
|
|||||||
return "";
|
return "";
|
||||||
|
|
||||||
return sprintf(translate("%(label)s %(details)s"), {
|
return sprintf(translate("%(label)s %(details)s"), {
|
||||||
"label": headerFont(translate("Damage Resistance:")),
|
"label": headerFont(translate("Damage:")),
|
||||||
"details":
|
"details":
|
||||||
g_DamageTypesMetadata.sort(Object.keys(resistanceTypeTemplate)).map(
|
g_DamageTypesMetadata.sort(Object.keys(resistanceTypeTemplate)).map(
|
||||||
dmgType => sprintf(translate("%(damage)s %(damageType)s %(resistancePercentage)s"), {
|
dmgType => sprintf(translate("%(damage)s %(damageType)s %(resistancePercentage)s"), {
|
||||||
@@ -211,7 +216,7 @@ function getCaptureResistanceTooltip(resistanceTypeTemplate)
|
|||||||
if (!resistanceTypeTemplate)
|
if (!resistanceTypeTemplate)
|
||||||
return "";
|
return "";
|
||||||
return sprintf(translate("%(label)s %(details)s"), {
|
return sprintf(translate("%(label)s %(details)s"), {
|
||||||
"label": headerFont(translate("Capture Resistance:")),
|
"label": headerFont(translate("Capture:")),
|
||||||
"details":
|
"details":
|
||||||
sprintf(translate("%(damage)s %(damageType)s %(resistancePercentage)s"), {
|
sprintf(translate("%(damage)s %(damageType)s %(resistancePercentage)s"), {
|
||||||
"damage": resistanceTypeTemplate.toFixed(1),
|
"damage": resistanceTypeTemplate.toFixed(1),
|
||||||
@@ -317,6 +322,24 @@ function captureDetails(captureTemplate)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function splashDetails(splashTemplate)
|
||||||
|
{
|
||||||
|
let splashLabel = sprintf(headerFont(translate("%(splashShape)s Splash")), {
|
||||||
|
"splashShape": splashTemplate.shape
|
||||||
|
});
|
||||||
|
let splashDamageTooltip = sprintf(translate("%(label)s: %(effects)s"), {
|
||||||
|
"label": splashLabel,
|
||||||
|
"effects": attackEffectsDetails(splashTemplate)
|
||||||
|
});
|
||||||
|
|
||||||
|
if (g_AlwaysDisplayFriendlyFire || splashTemplate.friendlyFire)
|
||||||
|
splashDamageTooltip += commaFont(translate(", ")) + sprintf(translate("Friendly Fire: %(enabled)s"), {
|
||||||
|
"enabled": splashTemplate.friendlyFire ? translate("Yes") : translate("No")
|
||||||
|
});
|
||||||
|
|
||||||
|
return splashDamageTooltip;
|
||||||
|
}
|
||||||
|
|
||||||
function applyStatusDetails(applyStatusTemplate)
|
function applyStatusDetails(applyStatusTemplate)
|
||||||
{
|
{
|
||||||
if (!applyStatusTemplate)
|
if (!applyStatusTemplate)
|
||||||
@@ -355,68 +378,43 @@ function getAttackTooltip(template)
|
|||||||
if (attackType == "Slaughter")
|
if (attackType == "Slaughter")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
let attackLabel = sprintf(headerFont(translate("%(attackType)s Attack")), {
|
let attackLabel = sprintf(headerFont(translate("%(attackType)s")), {
|
||||||
"attackType": attackType
|
"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
|
let splashTemplate = attackTypeTemplate.splash;
|
||||||
|
|
||||||
|
// 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" + g_Indent + g_Indent + 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%(splash)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),
|
||||||
|
"splash": splashTemplate ? "\n" + g_Indent + g_Indent + splashDetails(splashTemplate) : "",
|
||||||
"statusEffects": statusEffectsDetails
|
"statusEffects": statusEffectsDetails
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
return tooltips.join("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
function getSplashDamageTooltip(template)
|
return sprintf(translate("%(label)s\n" + g_Indent + "%(details)s"), {
|
||||||
{
|
"label": headerFont(translate("Attack:")),
|
||||||
if (!template.attack)
|
"details": tooltips.join("\n" + g_Indent)
|
||||||
return "";
|
});
|
||||||
|
|
||||||
let tooltips = [];
|
|
||||||
for (let attackType in template.attack)
|
|
||||||
{
|
|
||||||
let splashTemplate = template.attack[attackType].splash;
|
|
||||||
if (!splashTemplate)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
let splashLabel = sprintf(headerFont(translate("%(splashShape)s Splash Damage")), {
|
|
||||||
"splashShape": splashTemplate.shape
|
|
||||||
});
|
|
||||||
let splashDamageTooltip = sprintf(translate("%(label)s: %(effects)s"), {
|
|
||||||
"label": splashLabel,
|
|
||||||
"effects": attackEffectsDetails(splashTemplate)
|
|
||||||
});
|
|
||||||
|
|
||||||
if (g_AlwaysDisplayFriendlyFire || splashTemplate.friendlyFire)
|
|
||||||
splashDamageTooltip += commaFont(translate(", ")) + sprintf(translate("Friendly Fire: %(enabled)s"), {
|
|
||||||
"enabled": splashTemplate.friendlyFire ? translate("Yes") : translate("No")
|
|
||||||
});
|
|
||||||
|
|
||||||
tooltips.push(splashDamageTooltip);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If multiple attack types deal splash damage, the attack type should be shown to differentiate.
|
|
||||||
return tooltips.join("\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -52,9 +52,8 @@ ReferencePage.prototype.IconPath = "session/portraits/";
|
|||||||
*/
|
*/
|
||||||
ReferencePage.prototype.StatsFunctions = [
|
ReferencePage.prototype.StatsFunctions = [
|
||||||
getHealthTooltip,
|
getHealthTooltip,
|
||||||
getHealerTooltip,
|
|
||||||
getAttackTooltip,
|
getAttackTooltip,
|
||||||
getSplashDamageTooltip,
|
getHealerTooltip,
|
||||||
getResistanceTooltip,
|
getResistanceTooltip,
|
||||||
getGarrisonTooltip,
|
getGarrisonTooltip,
|
||||||
getProjectilesTooltip,
|
getProjectilesTooltip,
|
||||||
|
|||||||
@@ -313,7 +313,6 @@ function displaySingle(entState)
|
|||||||
|
|
||||||
Engine.GetGUIObjectByName("attackAndResistanceStats").tooltip = [
|
Engine.GetGUIObjectByName("attackAndResistanceStats").tooltip = [
|
||||||
getAttackTooltip,
|
getAttackTooltip,
|
||||||
getSplashDamageTooltip,
|
|
||||||
getHealerTooltip,
|
getHealerTooltip,
|
||||||
getResistanceTooltip,
|
getResistanceTooltip,
|
||||||
getGatherTooltip,
|
getGatherTooltip,
|
||||||
|
|||||||
@@ -978,7 +978,6 @@ g_SelectionPanels.Training = {
|
|||||||
tooltips = tooltips.concat([
|
tooltips = tooltips.concat([
|
||||||
getHealthTooltip,
|
getHealthTooltip,
|
||||||
getAttackTooltip,
|
getAttackTooltip,
|
||||||
getSplashDamageTooltip,
|
|
||||||
getHealerTooltip,
|
getHealerTooltip,
|
||||||
getResistanceTooltip,
|
getResistanceTooltip,
|
||||||
getGarrisonTooltip,
|
getGarrisonTooltip,
|
||||||
|
|||||||
Reference in New Issue
Block a user