Ticket #3113: total_carried_resources_v1.7.1.patch
File total_carried_resources_v1.7.1.patch, 6.3 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/common/tooltips.js
1 const g_CostDisplay Names = {1 const g_CostDisplayIcons = { 2 2 "food": '[icon="iconFood"]', 3 3 "wood": '[icon="iconWood"]', 4 4 "stone": '[icon="iconStone"]', … … 258 258 * Translates a cost component identifier as they are used internally 259 259 * (e.g. "population", "food", etc.) to proper display names. 260 260 */ 261 function getCostComponentDisplay Name(costComponentName)261 function getCostComponentDisplayIcon(costComponentName) 262 262 { 263 if (costComponentName in g_CostDisplay Names)264 return g_CostDisplay Names[costComponentName];263 if (costComponentName in g_CostDisplayIcons) 264 return g_CostDisplayIcons[costComponentName]; 265 265 266 266 warn(sprintf("The specified cost component, ‘%(component)s’, is not currently supported.", { "component": costComponentName })); 267 267 return ""; … … 292 292 293 293 let costs = []; 294 294 295 for (let type in g_CostDisplay Names)295 for (let type in g_CostDisplayIcons) 296 296 if (totalCosts[type]) 297 297 costs.push(sprintf(translate("%(component)s %(cost)s"), { 298 "component": getCostComponentDisplay Name(type),298 "component": getCostComponentDisplayIcon(type), 299 299 "cost": totalCosts[type] 300 300 })); 301 301 … … 353 353 // Translation: This string is part of the resources cost string on 354 354 // the tooltip for wall structures. 355 355 out.push(sprintf(translate("%(resourceIcon)s %(minimum)s to %(resourceIcon)s %(maximum)s"), { 356 "resourceIcon": getCostComponentDisplay Name(resource),356 "resourceIcon": getCostComponentDisplayIcon(resource), 357 357 "minimum": resourceMin, 358 358 "maximum": resourceMax 359 359 })); … … 415 415 let formatted = []; 416 416 for (let resource in resources) 417 417 formatted.push(sprintf(translate("%(component)s %(cost)s"), { 418 "component": '[font="sans-12"]' + getCostComponentDisplay Name(resource) + '[/font]',418 "component": '[font="sans-12"]' + getCostComponentDisplayIcon(resource) + '[/font]', 419 419 "cost": resources[resource] 420 420 })); 421 421 -
binaries/data/mods/public/gui/session/selection_details.js
338 338 let maxCapturePoints = 0; 339 339 let capturePoints = (new Array(g_MaxPlayers + 1)).fill(0); 340 340 let playerID = 0; 341 let totalResourcesCarried = {}; 341 342 342 343 for (let i = 0; i < selection.length; ++i) 343 344 { … … 355 356 maxCapturePoints += entState.maxCapturePoints; 356 357 capturePoints = entState.capturePoints.map((v, i) => v + capturePoints[i]); 357 358 } 359 360 if (entState.resourceCarrying && entState.resourceCarrying.length != 0) 361 { 362 let carrying = entState.resourceCarrying[0]; 363 totalResourcesCarried[carrying.type] = (totalResourcesCarried[carrying.type] || 0) + carrying.amount; 364 } 358 365 } 359 366 360 367 Engine.GetGUIObjectByName("healthMultiple").hidden = averageHealth <= 0; … … 404 411 }); 405 412 } 406 413 407 Engine.GetGUIObjectByName("numberOfUnits").caption = selection.length; 414 let numberOfUnits = Engine.GetGUIObjectByName("numberOfUnits"); 415 numberOfUnits.caption = selection.length; 408 416 417 numberOfUnits.tooltip = Object.keys(totalResourcesCarried).map 418 ( 419 res => getCostComponentDisplayIcon(res) + totalResourcesCarried[res] 420 ).join(" "); 421 409 422 // Unhide Details Area 410 423 Engine.GetGUIObjectByName("detailsAreaMultiple").hidden = false; 411 424 Engine.GetGUIObjectByName("detailsAreaSingle").hidden = true; -
binaries/data/mods/public/gui/session/selection_panels.js
737 737 { 738 738 tooltip += "\n[color=\"red\"]" + translate("Insufficient population capacity:") + "\n[/color]"; 739 739 tooltip += sprintf(translate("%(population)s %(neededSlots)s"), { 740 "population": getCostComponentDisplay Name("population"),740 "population": getCostComponentDisplayIcon("population"), 741 741 "neededSlots": data.item.neededSlots 742 742 }); 743 743 } … … 977 977 }, 978 978 "setTooltip": function(data) 979 979 { 980 let str = data.name; 980 981 if (data.carried) 981 { 982 var str = data.name + "\n"; 983 var ress = ["food", "wood", "stone", "metal"]; 984 for (var i = 0; i < 4; ++i) 985 { 986 if (data.carried[ress[i]]) 987 { 988 str += getCostComponentDisplayName(ress[i]) + data.carried[ress[i]]; 989 if (i !== 3) 990 str += " "; 991 } 992 } 993 data.button.tooltip = str; 994 } 995 else 996 data.button.tooltip = data.name; 982 str += "\n" + Object.keys(data.carried).map 983 ( 984 res => getCostComponentDisplayIcon(res) + data.carried[res] 985 ).join(" "); 986 data.button.tooltip = str; 997 987 }, 998 988 "setCountDisplay": function(data) 999 989 { -
binaries/data/mods/public/gui/session/selection_panels_middle/multiple_details_area.xml
19 19 20 20 <!-- Total --> 21 21 <object size="100%-42 12 100%-8 46" type="image" sprite="groupsIcon"> 22 <object size="0 0 100% 100%" type="text" style="largeCenteredOutlinedText" name="numberOfUnits" />22 <object size="0 0 100% 100%" type="text" style="largeCenteredOutlinedText" name="numberOfUnits" tooltip_style="sessionToolTipBold"/> 23 23 </object> 24 24 25 25 <!-- Stats Bars --> -
binaries/data/mods/public/gui/structree/draw.js
366 366 let rates = []; 367 367 for (let type in template.gather) 368 368 rates.push(sprintf(translate("%(resourceIcon)s %(rate)s"), { 369 "resourceIcon": getCostComponentDisplay Name(type),369 "resourceIcon": getCostComponentDisplayIcon(type), 370 370 "rate": template.gather[type] 371 371 })); 372 372