Ticket #3395: ticket3395unitactions_5.diff
File ticket3395unitactions_5.diff, 9.1 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/common/tooltips.js
157 157 else 158 158 var rateLabel = txtFormats.header[0] + translate("Rate:") + txtFormats.header[1]; 159 159 160 for ( vartype in template.attack)160 for (let type in template.attack) 161 161 { 162 162 if (type == "Slaughter") 163 163 continue; // Slaughter is not a real attack, so do not show it. … … 225 225 return attacks.join("\n"); 226 226 } 227 227 228 function getRepairRatioTooltip(ratio) 229 { 230 var unit = sprintf(translate("%(health)s / %(second)s / %(worker)s"), { 231 health: txtFormats.unit[0] + translate("Health") + txtFormats.unit[1], 232 second: txtFormats.unit[0] + translate("second") + txtFormats.unit[1], 233 worker: txtFormats.unit[0] + translate("worker") + txtFormats.unit[1] 234 }); 235 236 return "\n" + sprintf(translate("%(repairRateLabel)s %(detail)s %(unit)s"), { 237 repairRateLabel: txtFormats.header[0] + translate("Repair Rate:") + txtFormats.header[1], 238 detail: ratio, 239 unit: unit 240 }); 241 } 242 228 243 /** 229 244 * Translates a cost component identifier as they are used internally 230 245 * (e.g. "population", "food", etc.) to proper display names. -
binaries/data/mods/public/gui/session/selection_details.js
255 255 var armorString = getArmorTooltip(entState.armour); 256 256 257 257 // Attack and Armor 258 if ( "attack" in entState &&entState.attack)258 if (entState.attack) 259 259 Engine.GetGUIObjectByName("attackAndArmorStats").tooltip = getAttackTooltip(entState) + "\n" + armorString; 260 260 else 261 261 Engine.GetGUIObjectByName("attackAndArmorStats").tooltip = armorString; 262 262 263 // Repair Rate 264 if (entState.repairRatio) 265 Engine.GetGUIObjectByName("attackAndArmorStats").tooltip += getRepairRatioTooltip(entState.repairRatio); 266 263 267 // Icon Tooltip 264 268 var iconTooltip = ""; 265 269 -
binaries/data/mods/public/gui/session/unit_actions.js
677 677 count += state.garrisonHolder.entities.length; 678 678 } 679 679 return { 680 "tooltip": translate("Unload All"),680 "tooltip": '[font="sans-bold-16"]' + translate("Unload All") + "[/font]\n" + translate("Release all garrisoned units"), 681 681 "icon": "garrison-out.png", 682 682 "count": count, 683 683 }; … … 708 708 709 709 710 710 return { 711 "tooltip": translate("Delete"),711 "tooltip": '[font="sans-bold-16"]' + translate("Delete") + "[/font]\n" + translate("Destroy everything selected"), 712 712 "icon": "kill_small.png" 713 713 }; 714 714 }, … … 734 734 if (!entState.unitAI) 735 735 return false; 736 736 return { 737 "tooltip": translate("Stop"),737 "tooltip": '[font="sans-bold-16"]' + translate("Stop") + "[/font]\n" + translate("Cancel all existing orders"), 738 738 "icon": "stop.png" 739 739 }; 740 740 }, … … 752 752 if (!entState.unitAI || entState.turretParent) 753 753 return false; 754 754 return { 755 "tooltip": translate("Garrison"),755 "tooltip": '[font="sans-bold-16"]' + translate("Garrison") + "[/font]\n" + translate("Lock selected units inside and shoot arrows from warships and defensive buildings"), 756 756 "icon": "garrison.png" 757 757 }; 758 758 }, … … 773 773 if (!p.garrisonHolder || p.garrisonHolder.entities.indexOf(entState.id) == -1) 774 774 return false; 775 775 return { 776 "tooltip": translate("Unload"),776 "tooltip": '[font="sans-bold-16"]' + translate("Unload") + "[/font]\n" + translate("Release one unit"), 777 777 "icon": "garrison-out.png" 778 778 }; 779 779 }, … … 789 789 if (!entState.builder) 790 790 return false; 791 791 return { 792 "tooltip": translate("Repair"),792 "tooltip": '[font="sans-bold-16"]' + translate("Repair") + "[/font]\n" + translate("Restore health, rate depends on structure"), 793 793 "icon": "repair.png" 794 794 }; 795 795 }, … … 806 806 if (!entState.rallyPoint) 807 807 return false; 808 808 return { 809 "tooltip": translate("Focus on Rally Point"),809 "tooltip": '[font="sans-bold-16"]' + translate("Focus on Rally Point") + "[/font]\n" + translate("Move camera to entity"), 810 810 "icon": "focus-rally.png" 811 811 }; 812 812 }, … … 829 829 if (!entState.unitAI || !entState.unitAI.hasWorkOrders) 830 830 return false; 831 831 return { 832 "tooltip": translate("Back to Work"),832 "tooltip": '[font="sans-bold-16"]' + translate("Back to Work") + "[/font]\n" + translate("Order unit the last given task"), 833 833 "icon": "production.png" 834 834 }; 835 835 }, … … 845 845 if (!entState.unitAI || !entState.unitAI.canGuard || entState.unitAI.isGuarding) 846 846 return false; 847 847 return { 848 "tooltip": translate("Guard"),848 "tooltip": '[font="sans-bold-16"]' + translate("Guard") + "[/font]\n" + translate("Follow another entity, repair/heal it and protect when attacked"), 849 849 "icon": "add-guard.png" 850 850 }; 851 851 }, … … 862 862 if (!entState.unitAI || !entState.unitAI.isGuarding) 863 863 return false; 864 864 return { 865 "tooltip": translate("Remove guard"),865 "tooltip": '[font="sans-bold-16"]' + translate("Remove guard") +"[/font]\n" + translate("Stop guarding"), 866 866 "icon": "remove-guard.png" 867 867 }; 868 868 }, … … 913 913 } 914 914 } 915 915 return { 916 "tooltip": translate("Unload All"),916 "tooltip": '[font="sans-bold-16"]' + translate("Unload All") + "[/font]\n" + translate("Release all garrisoned units"), 917 917 "icon": "garrison-out.png", 918 918 "count": count, 919 919 }; -
binaries/data/mods/public/simulation/components/GuiInterface.js
342 342 343 343 var cmpOwnership = Engine.QueryInterface(ent, IID_Ownership); 344 344 if (cmpOwnership) 345 {346 345 ret.player = cmpOwnership.GetOwner(); 347 }348 346 349 347 var cmpRallyPoint = Engine.QueryInterface(ent, IID_RallyPoint); 350 348 if (cmpRallyPoint) 351 {352 349 ret.rallyPoint = {'position': cmpRallyPoint.GetPositions()[0]}; // undefined or {x,z} object 353 }354 350 355 351 var cmpGarrisonHolder = Engine.QueryInterface(ent, IID_GarrisonHolder); 356 352 if (cmpGarrisonHolder) … … 432 428 "obstruction": null, 433 429 "turretParent":null, 434 430 "promotion": null, 431 "repairTime": null, 435 432 "resourceDropsite": null, 436 433 "resourceGatherRates": null, 437 434 "resourceSupply": null, … … 488 485 489 486 var cmpArmour = Engine.QueryInterface(ent, IID_DamageReceiver); 490 487 if (cmpArmour) 491 {492 488 ret.armour = cmpArmour.GetArmourStrengths(); 493 }494 489 495 490 var cmpAuras = Engine.QueryInterface(ent, IID_Auras); 496 491 if (cmpAuras) 497 {498 492 ret.auras = cmpAuras.GetDescriptions(); 499 }500 493 501 494 var cmpBuildingAI = Engine.QueryInterface(ent, IID_BuildingAI); 502 495 if (cmpBuildingAI) … … 522 515 if (cmpPosition && cmpPosition.GetTurretParent() != INVALID_ENTITY) 523 516 ret.turretParent = cmpPosition.GetTurretParent(); 524 517 518 var cmpRepairable = Engine.QueryInterface(ent, IID_Repairable); 519 if (cmpRepairable) 520 ret.repairRatio = cmpRepairable.GetRepairRatio(); 521 525 522 var cmpResourceSupply = QueryMiragedInterface(ent, IID_ResourceSupply); 526 523 if (cmpResourceSupply) 527 524 { … … 538 535 539 536 var cmpResourceGatherer = Engine.QueryInterface(ent, IID_ResourceGatherer); 540 537 if (cmpResourceGatherer) 541 {542 538 ret.resourceGatherRates = cmpResourceGatherer.GetGatherRates(); 543 }544 539 545 540 var cmpResourceDropsite = Engine.QueryInterface(ent, IID_ResourceDropsite); 546 541 if (cmpResourceDropsite) -
binaries/data/mods/public/simulation/components/Repairable.js
74 74 Engine.PostMessage(this.entity, MT_ConstructionFinished, { "entity": this.entity, "newentity": this.entity }); 75 75 }; 76 76 77 Repairable.prototype.GetRepairRatio = function() 78 { 79 let cmpHealth = Engine.QueryInterface(this.entity, IID_Health); 80 let cmpCost = Engine.QueryInterface(this.entity, IID_Cost); 81 let repairTime = this.repairTimeRatio * cmpCost.GetBuildTime(); 82 let repairRatio = (cmpHealth.GetMaxHitpoints() / repairTime); 83 return (Math.round(repairRatio * 10 ) / 10); 84 }; 85 77 86 Engine.RegisterComponentType(IID_Repairable, "Repairable", Repairable); -
binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
510 510 obstruction: null, 511 511 turretParent: null, 512 512 promotion: null, 513 repairTime: null, 513 514 resourceDropsite: null, 514 515 resourceGatherRates: null, 515 516 resourceSupply: null,