Fix required technology tooltip colour.
Done by creating a function for 'objections' and using that for any unmet requirements. Patch by: @abian Differential revision: https://code.wildfiregames.com/D4899 Comments by: @Langbart Fixes #6694 This was SVN commit r27484.
This commit is contained in:
parent
471b05da04
commit
1078277c59
@ -2,6 +2,7 @@ var g_TooltipTextFormats = {
|
||||
"unit": { "font": "sans-10", "color": "orange" },
|
||||
"header": { "font": "sans-bold-13" },
|
||||
"body": { "font": "sans-13" },
|
||||
"objection": { "font": "sans-bold-13", "color": "red" },
|
||||
"comma": { "font": "sans-12" },
|
||||
"namePrimaryBig": { "font": "sans-bold-16" },
|
||||
"namePrimarySmall": { "font": "sans-bold-12" },
|
||||
@ -81,6 +82,11 @@ function bodyFont(text)
|
||||
return setStringTags(text, g_TooltipTextFormats.body);
|
||||
}
|
||||
|
||||
function objectionFont(text)
|
||||
{
|
||||
return setStringTags(text, g_TooltipTextFormats.objection);
|
||||
}
|
||||
|
||||
function headerFont(text)
|
||||
{
|
||||
return setStringTags(text, g_TooltipTextFormats.header);
|
||||
@ -963,10 +969,10 @@ function getRequirementsTooltip(enabled, requirements, civ)
|
||||
|
||||
// Simple requirements (one tech) can be translated on the fly.
|
||||
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))
|
||||
});
|
||||
return translate(requirements.Tooltip);
|
||||
}));
|
||||
return objectionFont(translate(requirements.Tooltip));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -997,10 +1003,8 @@ function getNeededResourcesTooltip(resources)
|
||||
"component": '[font="sans-12"]' + resourceIcon(resource) + '[/font]',
|
||||
"cost": Math.ceil(resources[resource])
|
||||
}));
|
||||
return coloredText(
|
||||
'[font="sans-bold-13"]' + translate("Insufficient resources:") + '[/font]',
|
||||
"red") + " " +
|
||||
formatted.join(" ");
|
||||
return objectionFont(translate("Insufficient resources:")) +
|
||||
" " + formatted.join(" ");
|
||||
}
|
||||
|
||||
function getSpeedTooltip(template)
|
||||
|
@ -72,6 +72,7 @@
|
||||
{ "name": "Daniel Trevitz" },
|
||||
{ "nick": "Dariost", "name": "Dario Ostuni" },
|
||||
{ "nick": "Dave", "name": "David Protasowski" },
|
||||
{ "name": "David Abián" },
|
||||
{ "name": "David Marshall" },
|
||||
{ "nick": "dax", "name": "Dacian Fiordean" },
|
||||
{ "nick": "deebee", "name": "Deepak Anthony" },
|
||||
|
@ -282,7 +282,7 @@ g_SelectionPanels.Formation = {
|
||||
translate("Right-click to set this as the default formation."));
|
||||
|
||||
if (!formationOk && formationInfo.tooltip)
|
||||
tooltip += "\n" + coloredText(translate(formationInfo.tooltip), "red");
|
||||
tooltip += "\n" + objectionFont(translate(formationInfo.tooltip));
|
||||
data.button.tooltip = tooltip;
|
||||
|
||||
data.button.enabled = formationOk && controlsPlayer(data.player);
|
||||
@ -558,7 +558,7 @@ g_SelectionPanels.Queue = {
|
||||
tooltips.push(translate("The auto-queue will try to train this item later."));
|
||||
if (queuedItem.neededSlots)
|
||||
{
|
||||
tooltips.push(coloredText(translate("Insufficient population capacity:"), "red"));
|
||||
tooltips.push(objectionFont(translate("Insufficient population capacity:")));
|
||||
tooltips.push(sprintf(translate("%(population)s %(neededSlots)s"), {
|
||||
"population": resourceIcon("population"),
|
||||
"neededSlots": queuedItem.neededSlots
|
||||
@ -791,7 +791,7 @@ g_SelectionPanels.Research = {
|
||||
"entityCounts": entityCounts.join(translateWithContext("Separator for a list of entity counts", ", "))
|
||||
});
|
||||
}
|
||||
tooltips.push(tip);
|
||||
tooltips.push(objectionFont(tip));
|
||||
}
|
||||
tooltips.push(getNeededResourcesTooltip(neededResources));
|
||||
button.tooltip = tooltips.filter(tip => tip).join("\n");
|
||||
@ -840,7 +840,7 @@ g_SelectionPanels.Research = {
|
||||
{
|
||||
button.enabled = false;
|
||||
modifier += "color:0 0 0 127:grayscale:";
|
||||
button.tooltip += "\n" + coloredText(translate("Cannot research while upgrading."), "red");
|
||||
button.tooltip += "\n" + objectionFont(translate("Cannot research while upgrading."));
|
||||
|
||||
}
|
||||
|
||||
@ -1070,7 +1070,7 @@ g_SelectionPanels.Training = {
|
||||
{
|
||||
data.button.enabled = false;
|
||||
modifier = "color:0 0 0 127:grayscale:";
|
||||
data.button.tooltip += "\n" + coloredText(translate("Cannot train while upgrading."), "red");
|
||||
data.button.tooltip += "\n" + objectionFont(translate("Cannot train while upgrading."));
|
||||
}
|
||||
|
||||
if (template.icon)
|
||||
@ -1208,10 +1208,10 @@ g_SelectionPanels.Upgrade = {
|
||||
}
|
||||
else
|
||||
{
|
||||
tooltip = coloredText(translatePlural(
|
||||
tooltip = objectionFont(translatePlural(
|
||||
"Cannot upgrade when the entity is training, researching or already upgrading.",
|
||||
"Cannot upgrade when all entities are training, researching or already upgrading.",
|
||||
data.unitEntStates.length), "red");
|
||||
data.unitEntStates.length));
|
||||
|
||||
data.button.onPress = function() {};
|
||||
|
||||
|
@ -98,7 +98,7 @@ function formatLimitString(trainEntLimit, trainEntCount, trainEntLimitChangers)
|
||||
});
|
||||
|
||||
if (trainEntCount >= trainEntLimit)
|
||||
text = coloredText(text, "red");
|
||||
text = objectionFont(text);
|
||||
|
||||
for (var c in trainEntLimitChangers)
|
||||
{
|
||||
@ -176,7 +176,7 @@ function formatMatchLimitString(matchEntLimit, matchEntCount, type)
|
||||
});
|
||||
}
|
||||
|
||||
return passedLimit ? coloredText(text, "red") : text;
|
||||
return passedLimit ? objectionFont(text) : text;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user