Ticket #4193: 4193-loot-tooltip.patch
File 4193-loot-tooltip.patch, 6.2 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/globalscripts/Templates.js
244 244 "rate": getEntityValue("Heal/Rate") 245 245 }; 246 246 247 if (template.Loot) 248 { 249 ret.loot = {}; 250 if (template.Loot.xp) 251 ret.loot.xp = getEntityValue("Loot/xp"); 252 if (template.Loot.food) 253 ret.loot.food = getEntityValue("Loot/food"); 254 255 if (template.Loot.wood) 256 ret.loot.wood = getEntityValue("Loot/wood"); 257 258 if (template.Loot.stone) 259 ret.loot.stone = getEntityValue("Loot/stone"); 260 261 if (template.Loot.metal) 262 ret.loot.metal = getEntityValue("Loot/metal"); 263 } 264 247 265 if (template.Obstruction) 248 266 { 249 267 ret.obstruction = { -
binaries/data/mods/public/gui/common/setup_resources.xml
25 25 sprite="stretched:session/icons/resources/time_small.png" 26 26 size="16 16" 27 27 /> 28 <icon name="icon_xp" 29 sprite="stretched:session/icons/resources/xp_small.png" 30 size="16 16" 31 /> 28 32 </setup> -
binaries/data/mods/public/gui/common/tooltips.js
575 575 return headerFont(translate("Classes:")) + ' ' + 576 576 bodyFont(template.visibleIdentityClasses.map(c => translate(c)).join(translate(", "))); 577 577 } 578 579 function getLootTooltip(template, trainNum, entity) 580 { 581 if (template.loot) 582 { 583 let loots = []; 584 for (let type in template.loot) 585 loots.push(sprintf(translate("%(component)s %(loot)s"), { 586 "component": costIcon(type), 587 "loot": template.loot[type] 588 })); 589 590 return headerFont("Loot: ") + loots; 591 } 592 return ""; 593 } -
binaries/data/mods/public/gui/session/selection_details.js
1 const lootTypes = ["xp", "food", "wood", "stone", "metal"]; 2 1 3 function layoutSelectionSingle() 2 4 { 3 5 Engine.GetGUIObjectByName("detailsAreaSingle").hidden = false; … … 291 293 getBuildRateTooltip, 292 294 getSpeedTooltip, 293 295 getGarrisonTooltip, 294 getProjectilesTooltip 296 getProjectilesTooltip, 297 getLootTooltip 295 298 ].map(func => func(entState)).filter(tip => tip).join("\n"); 296 299 297 300 let iconTooltips = []; … … 320 323 let capturePoints = (new Array(g_MaxPlayers + 1)).fill(0); 321 324 let playerID = 0; 322 325 let totalResourcesCarried = {}; 326 let totalTrade = {}; 327 let totalLoot = {}; 323 328 324 329 for (let i = 0; i < selection.length; ++i) 325 330 { 326 331 let entState = GetEntityState(selection[i]); 332 let extEntState = GetExtendedEntityState(selection[i]); 327 333 if (!entState) 328 334 continue; 329 335 playerID = entState.player; // trust that all selected entities have the same owner … … 338 344 capturePoints = entState.capturePoints.map((v, i) => v + capturePoints[i]); 339 345 } 340 346 347 if (extEntState.loot) 348 { 349 for (let i in lootTypes) 350 { 351 let type = lootTypes[i]; 352 totalLoot[type] = (totalLoot[type] || 0) + extEntState.loot[type]; 353 } 354 } 355 341 356 if (entState.resourceCarrying && entState.resourceCarrying.length) 342 357 { 343 358 let carrying = entState.resourceCarrying[0]; 344 359 totalResourcesCarried[carrying.type] = (totalResourcesCarried[carrying.type] || 0) + carrying.amount; 345 360 } 361 362 if (entState.trader && entState.trader.goods) 363 { 364 let totalGain = entState.trader.goods.amount.traderGain; 365 if (entState.trader.goods.amount.market1Gain) 366 totalGain += entState.trader.goods.amount.market1Gain; 367 if (entState.trader.goods.amount.market2Gain) 368 totalGain += entState.trader.goods.amount.market2Gain; 369 370 totalTrade[entState.trader.goods.type] = totalGain; 371 } 346 372 } 347 373 374 for (let i in lootTypes) 375 { 376 let type = lootTypes[i]; 377 totalLoot[type] += totalResourcesCarried[type] || 0; 378 totalLoot[type] += totalTrade[type] || 0; 379 if (totalLoot[type] == 0) 380 delete totalLoot[type]; 381 } 382 348 383 Engine.GetGUIObjectByName("healthMultiple").hidden = averageHealth <= 0; 349 384 if (averageHealth > 0) 350 385 { … … 394 429 395 430 let numberOfUnits = Engine.GetGUIObjectByName("numberOfUnits"); 396 431 numberOfUnits.caption = selection.length; 397 numberOfUnits.tooltip = Object.keys(totalResourcesCarried).map(res =>398 costIcon(res) + total ResourcesCarried[res]432 numberOfUnits.tooltip = (Object.keys(totalLoot)).map(res => 433 costIcon(res) + totalLoot[res] 399 434 ).join(" "); 400 435 401 436 // Unhide Details Area -
binaries/data/mods/public/gui/structree/draw.js
14 14 getProjectilesTooltip, 15 15 getSpeedTooltip, 16 16 getGatherTooltip, 17 getPopulationBonusTooltip 17 getPopulationBonusTooltip, 18 getLootTooltip 18 19 ]; 19 20 20 21 /** -
binaries/data/mods/public/simulation/components/GuiInterface.js
421 421 "barterMarket": null, 422 422 "buildingAI": null, 423 423 "heal": null, 424 "loot": null, 424 425 "obstruction": null, 425 426 "turretParent":null, 426 427 "promotion": null, … … 568 569 "healableClasses": cmpHeal.GetHealableClasses(), 569 570 }; 570 571 572 let cmpLoot = Engine.QueryInterface(ent, IID_Loot); 573 if (cmpLoot) 574 { 575 let resources = cmpLoot.GetResources(); 576 ret.loot = { 577 "xp": cmpLoot.GetXp(), 578 "food": resources.food, 579 "wood": resources.wood, 580 "stone": resources.stone, 581 "metal": resources.metal 582 }; 583 } 584 571 585 let cmpUnitMotion = Engine.QueryInterface(ent, IID_UnitMotion); 572 586 if (cmpUnitMotion) 573 587 ret.speed = {