Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/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" }, | ||||
"objection": { "font": "sans-bold-13", "color": "red" }, | |||||
"comma": { "font": "sans-12" }, | "comma": { "font": "sans-12" }, | ||||
"namePrimaryBig": { "font": "sans-bold-16" }, | "namePrimaryBig": { "font": "sans-bold-16" }, | ||||
"namePrimarySmall": { "font": "sans-bold-12" }, | "namePrimarySmall": { "font": "sans-bold-12" }, | ||||
"nameSecondary": { "font": "sans-bold-16" } | "nameSecondary": { "font": "sans-bold-16" } | ||||
}; | }; | ||||
var g_SpecificNamesPrimary = Engine.ConfigDB_GetValue("user", "gui.session.howtoshownames") == 0 || Engine.ConfigDB_GetValue("user", "gui.session.howtoshownames") == 2; | var g_SpecificNamesPrimary = Engine.ConfigDB_GetValue("user", "gui.session.howtoshownames") == 0 || Engine.ConfigDB_GetValue("user", "gui.session.howtoshownames") == 2; | ||||
var g_ShowSecondaryNames = Engine.ConfigDB_GetValue("user", "gui.session.howtoshownames") == 0 || Engine.ConfigDB_GetValue("user", "gui.session.howtoshownames") == 1; | var g_ShowSecondaryNames = Engine.ConfigDB_GetValue("user", "gui.session.howtoshownames") == 0 || Engine.ConfigDB_GetValue("user", "gui.session.howtoshownames") == 1; | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | function getLocalizedResourceAmounts(resources) | ||||
}); | }); | ||||
} | } | ||||
function bodyFont(text) | function bodyFont(text) | ||||
{ | { | ||||
return setStringTags(text, g_TooltipTextFormats.body); | return setStringTags(text, g_TooltipTextFormats.body); | ||||
} | } | ||||
function objectionFont(text) | |||||
{ | |||||
return setStringTags(text, g_TooltipTextFormats.objection); | |||||
} | |||||
function headerFont(text) | function headerFont(text) | ||||
{ | { | ||||
return setStringTags(text, g_TooltipTextFormats.header); | return setStringTags(text, g_TooltipTextFormats.header); | ||||
} | } | ||||
function unitFont(text) | function unitFont(text) | ||||
{ | { | ||||
return setStringTags(text, g_TooltipTextFormats.unit); | return setStringTags(text, g_TooltipTextFormats.unit); | ||||
▲ Show 20 Lines • Show All 866 Lines • ▼ Show 20 Lines | |||||
function getRequirementsTooltip(enabled, requirements, civ) | function getRequirementsTooltip(enabled, requirements, civ) | ||||
{ | { | ||||
if (enabled) | if (enabled) | ||||
return ""; | return ""; | ||||
// Simple requirements (one tech) can be translated on the fly. | // Simple requirements (one tech) can be translated on the fly. | ||||
if ("Techs" in requirements && !requirements.Techs.includes(" ")) | if ("Techs" in requirements && !requirements.Techs.includes(" ")) | ||||
return sprintf(translate("Requires %(technology)s"), { | return objectionFont(sprintf(translate("Requires %(technology)s"), { | ||||
"technology": getEntityNames(GetTechnologyData(requirements.Techs, civ)) | "technology": getEntityNames(GetTechnologyData(requirements.Techs, civ)) | ||||
}); | })); | ||||
return translate(requirements.Tooltip); | return objectionFont(translate(requirements.Tooltip)); | ||||
} | } | ||||
/** | /** | ||||
* 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) | ||||
{ | { | ||||
if (!template.population || !template.population.bonus) | if (!template.population || !template.population.bonus) | ||||
Show All 14 Lines | if (!resources) | ||||
return ""; | return ""; | ||||
let formatted = []; | let formatted = []; | ||||
for (let resource in resources) | for (let resource in resources) | ||||
formatted.push(sprintf(translate("%(component)s %(cost)s"), { | formatted.push(sprintf(translate("%(component)s %(cost)s"), { | ||||
"component": '[font="sans-12"]' + resourceIcon(resource) + '[/font]', | "component": '[font="sans-12"]' + resourceIcon(resource) + '[/font]', | ||||
"cost": Math.ceil(resources[resource]) | "cost": Math.ceil(resources[resource]) | ||||
})); | })); | ||||
return coloredText( | return objectionFont(translate("Insufficient resources:")) + | ||||
'[font="sans-bold-13"]' + translate("Insufficient resources:") + '[/font]', | " " + formatted.join(" "); | ||||
"red") + " " + | |||||
formatted.join(" "); | |||||
} | } | ||||
function getSpeedTooltip(template) | function getSpeedTooltip(template) | ||||
{ | { | ||||
if (!template.speed) | if (!template.speed) | ||||
return ""; | return ""; | ||||
const walk = template.speed.walk.toFixed(1); | const walk = template.speed.walk.toFixed(1); | ||||
▲ Show 20 Lines • Show All 227 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator