Add support for resource descriptions and display them in the tooltip of the resource counts shown in the top panel.

Differential Revision: https://code.wildfiregames.com/D199
Proposed and tested by: wowgetoffyourcellphone
This was SVN commit r19472.
This commit is contained in:
elexis
2017-04-29 17:57:10 +00:00
parent 185261275f
commit a8ac5ccede
6 changed files with 37 additions and 4 deletions
@@ -12,8 +12,13 @@ const g_VictoryDurations = prepareForDropdown(g_Settings && g_Settings.VictoryDu
/**
* Colors to flash when pop limit reached.
*/
const g_DefaultPopulationColor = "white";
const g_PopulationAlertColor = "orange";
var g_DefaultPopulationColor = "white";
var g_PopulationAlertColor = "orange";
/**
* Seen in the tooltip of the top panel.
*/
var g_ResourceTitleFont = "sans-bold-16";
/**
* A random file will be played. TODO: more variety
@@ -1126,10 +1131,23 @@ function updatePlayerDisplay()
let resNames = g_ResourceData.GetNames();
for (let r = 0; r < resCodes.length; ++r)
{
if (!Engine.GetGUIObjectByName("resource["+r+"]"))
let resourceObj = Engine.GetGUIObjectByName("resource[" + r + "]");
if (!resourceObj)
break;
let res = resCodes[r];
Engine.GetGUIObjectByName("resource["+r+"]").tooltip = getLocalizedResourceName(resNames[res], "firstWord") + getAllyStatTooltip(res);
let tooltip = '[font="' + g_ResourceTitleFont + '"]' +
getLocalizedResourceName(resNames[res], "firstWord") + '[/font]';
let descr = g_ResourceData.GetResource(res).description;
if (descr)
tooltip += "\n" + translate(descr);
tooltip += getAllyStatTooltip(res);
resourceObj.tooltip = tooltip;
Engine.GetGUIObjectByName("resource["+r+"]_count").caption = Math.floor(playerState.resourceCounts[res]);
}
@@ -314,6 +314,17 @@
]
}
},
{
"extractor": "json",
"filemasks": [
"simulation/data/resources/**.json"
],
"options": {
"keywords": [
"description"
]
}
},
{
"extractor": "json",
"filemasks": [
@@ -1,6 +1,7 @@
{
"code": "food",
"name": "Food",
"description": "Harvest from animals, berry bushes, fish, or fields.",
"order": 1,
"subtypes": {
"fish": "Fish",
@@ -1,6 +1,7 @@
{
"code": "metal",
"name": "Metal",
"description": "Mine from metal mines and quarries.",
"order": 4,
"subtypes": {
"ore": "Ore"
@@ -1,6 +1,7 @@
{
"code": "stone",
"name": "Stone",
"description": "Mine from rocks, stone quarries or ruins.",
"order": 3,
"subtypes": {
"rock": "Rock",
@@ -1,6 +1,7 @@
{
"code": "wood",
"name": "Wood",
"description": "Lumber from trees or groves.",
"order": 2,
"subtypes": {
"tree": "Tree",