mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-29 11:12:39 +00:00
Correct resource order in the GUI.
Differential Revision: https://code.wildfiregames.com/D23 Reviewed By: s0600204 This was SVN commit r19762.
This commit is contained in:
@@ -8,8 +8,8 @@ function getLocalizedResourceName(resourceName, context)
|
|||||||
*/
|
*/
|
||||||
function getLocalizedResourceAmounts(resources)
|
function getLocalizedResourceAmounts(resources)
|
||||||
{
|
{
|
||||||
let amounts = Object.keys(resources)
|
let amounts = g_ResourceData.GetCodes()
|
||||||
.filter(type => resources[type] > 0)
|
.filter(type => resources[type])
|
||||||
.map(type => sprintf(translate("%(amount)s %(resourceType)s"), {
|
.map(type => sprintf(translate("%(amount)s %(resourceType)s"), {
|
||||||
"amount": resources[type],
|
"amount": resources[type],
|
||||||
"resourceType": getLocalizedResourceName(g_ResourceData.GetResource(type).name, "withinSentence")
|
"resourceType": getLocalizedResourceName(g_ResourceData.GetResource(type).name, "withinSentence")
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ var g_RangeTooltipString = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function getCostTypes()
|
||||||
|
{
|
||||||
|
return g_ResourceData.GetCodes().concat(["population", "populationBonus", "time"]);
|
||||||
|
}
|
||||||
|
|
||||||
function resourceIcon(resource)
|
function resourceIcon(resource)
|
||||||
{
|
{
|
||||||
return '[icon="icon_' + resource + '"]';
|
return '[icon="icon_' + resource + '"]';
|
||||||
@@ -344,8 +349,9 @@ function getBuildRateTooltip(template)
|
|||||||
function multiplyEntityCosts(template, trainNum)
|
function multiplyEntityCosts(template, trainNum)
|
||||||
{
|
{
|
||||||
let totalCosts = {};
|
let totalCosts = {};
|
||||||
for (let r in template.cost)
|
for (let r of getCostTypes())
|
||||||
totalCosts[r] = Math.floor(template.cost[r] * trainNum);
|
if (template.cost[r])
|
||||||
|
totalCosts[r] = Math.floor(template.cost[r] * trainNum);
|
||||||
|
|
||||||
return totalCosts;
|
return totalCosts;
|
||||||
}
|
}
|
||||||
@@ -363,7 +369,7 @@ function getEntityCostComponentsTooltipString(template, entity, buildingsCountTo
|
|||||||
}) : 1));
|
}) : 1));
|
||||||
|
|
||||||
let costs = [];
|
let costs = [];
|
||||||
for (let type in template.cost)
|
for (let type of getCostTypes())
|
||||||
// Population bonus is shown in the tooltip
|
// Population bonus is shown in the tooltip
|
||||||
if (type != "populationBonus" && totalCosts[type])
|
if (type != "populationBonus" && totalCosts[type])
|
||||||
costs.push(sprintf(translate("%(component)s %(cost)s"), {
|
costs.push(sprintf(translate("%(component)s %(cost)s"), {
|
||||||
@@ -418,7 +424,7 @@ function getResourceTrickleTooltip(template)
|
|||||||
if (!template.resourceTrickle)
|
if (!template.resourceTrickle)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
let resCodes = Object.keys(template.resourceTrickle.rates).filter(res => template.resourceTrickle.rates[res]);
|
let resCodes = g_ResourceData.GetCodes().filter(res => template.resourceTrickle.rates[res]);
|
||||||
if (!resCodes.length)
|
if (!resCodes.length)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
@@ -446,9 +452,7 @@ function getWallPieceTooltip(wallTypes)
|
|||||||
{
|
{
|
||||||
let out = [];
|
let out = [];
|
||||||
let resourceCount = {};
|
let resourceCount = {};
|
||||||
|
for (let resource of getCostTypes())
|
||||||
// Initialize the acceptable types for '$x to $y $resource' mode.
|
|
||||||
for (let resource in wallTypes[0].cost)
|
|
||||||
if (wallTypes[0].cost[resource])
|
if (wallTypes[0].cost[resource])
|
||||||
resourceCount[resource] = [wallTypes[0].cost[resource]];
|
resourceCount[resource] = [wallTypes[0].cost[resource]];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user