Ticket #3395: ticket3395unitactions_8.diff
File ticket3395unitactions_8.diff, 5.0 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/common/tooltips.js
233 233 { 234 234 return "\n" + sprintf(translate("%(repairRateLabel)s %(value)s %(health)s / %(second)s / %(worker)s"), { 235 235 "repairRateLabel": g_TooltipTextFormats.header[0] + translate("Repair Rate:") + g_TooltipTextFormats.header[1], 236 "value": Math.round(rate * 10 236 "value": Math.round(rate * 10) / 10, 237 237 "health": g_TooltipTextFormats.unit[0] + translate("health") + g_TooltipTextFormats.unit[1], 238 238 "second": g_TooltipTextFormats.unit[0] + translate("second") + g_TooltipTextFormats.unit[1], 239 239 "worker": g_TooltipTextFormats.unit[0] + translate("worker") + g_TooltipTextFormats.unit[1] … … 240 240 }); 241 241 } 242 242 243 function getBuildRateTooltip(rate) 244 { 245 return "\n" + sprintf(translate("%(buildRateLabel)s %(value)s %(health)s / %(second)s / %(worker)s"), { 246 "buildRateLabel": g_TooltipTextFormats.header[0] + translate("Build Rate:") + g_TooltipTextFormats.header[1], 247 "value": Math.round(rate * 10) / 10, 248 "health": g_TooltipTextFormats.unit[0] + translate("health") + g_TooltipTextFormats.unit[1], 249 "second": g_TooltipTextFormats.unit[0] + translate("second") + g_TooltipTextFormats.unit[1], 250 "worker": g_TooltipTextFormats.unit[0] + translate("worker") + g_TooltipTextFormats.unit[1] 251 }); 252 } 253 243 254 /** 244 255 * Translates a cost component identifier as they are used internally 245 256 * (e.g. "population", "food", etc.) to proper display names. -
binaries/data/mods/public/gui/session/selection_details.js
265 265 if (entState.repairRate) 266 266 Engine.GetGUIObjectByName("attackAndArmorStats").tooltip += getRepairRateTooltip(entState.repairRate); 267 267 268 // Build Rate 269 if (entState.buildRate) 270 Engine.GetGUIObjectByName("attackAndArmorStats").tooltip += getBuildRateTooltip(entState.buildRate); 271 268 272 // Icon Tooltip 269 273 let iconTooltip = ""; 270 274 -
binaries/data/mods/public/simulation/components/Foundation.js
247 247 this.committed = true; 248 248 } 249 249 250 // Calculate the amount of progress that will be added (where 1.0 = completion)251 var cmpCost = Engine.QueryInterface(this.entity, IID_Cost);252 var amount = work / cmpCost.GetBuildTime();253 254 250 // Add an appropriate proportion of hitpoints 255 251 var cmpHealth = Engine.QueryInterface(this.entity, IID_Health); 256 252 var maxHealth = cmpHealth.GetMaxHitpoints(); 257 var deltaHP = Math.max(work, Math.min(maxHealth, Math.floor( maxHealth * (amount * this.buildMultiplier))));253 var deltaHP = Math.max(work, Math.min(maxHealth, Math.floor(work * this.GetBuildRate() * this.buildMultiplier))); 258 254 if (deltaHP > 0) 259 {260 255 cmpHealth.Increase(deltaHP); 261 }262 256 263 257 var progress = this.GetBuildProgress(); 264 258 … … 344 338 } 345 339 }; 346 340 341 Foundation.prototype.GetBuildRate = function() 342 { 343 let cmpHealth = Engine.QueryInterface(this.entity, IID_Health); 344 let cmpCost = Engine.QueryInterface(this.entity, IID_Cost); 345 let buildRate = cmpHealth.GetMaxHitpoints() / cmpCost.GetBuildTime(); 346 return buildRate; 347 }; 348 347 349 Engine.RegisterComponentType(IID_Foundation, "Foundation", Foundation); 348 350 -
binaries/data/mods/public/simulation/components/GuiInterface.js
405 405 "turretParent":null, 406 406 "promotion": null, 407 407 "repairRate": null, 408 "buildRate": null, 408 409 "resourceDropsite": null, 409 410 "resourceGatherRates": null, 410 411 "resourceSupply": null, … … 489 490 if (cmpRepairable) 490 491 ret.repairRate = cmpRepairable.GetRepairRate(); 491 492 493 let cmpFoundation = Engine.QueryInterface(ent, IID_Foundation); 494 if (cmpFoundation) 495 ret.buildRate = cmpFoundation.GetBuildRate(); 496 492 497 let cmpResourceSupply = QueryMiragedInterface(ent, IID_ResourceSupply); 493 498 if (cmpResourceSupply) 494 499 ret.resourceSupply = { -
binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
513 513 turretParent: null, 514 514 promotion: null, 515 515 repairRate: null, 516 buildRate: null, 516 517 resourceDropsite: null, 517 518 resourceGatherRates: null, 518 519 resourceSupply: null,