1 | Index: binaries/data/mods/public/gui/common/tooltips.js
|
---|
2 | ===================================================================
|
---|
3 | --- binaries/data/mods/public/gui/common/tooltips.js (revision 17452)
|
---|
4 | +++ binaries/data/mods/public/gui/common/tooltips.js (working copy)
|
---|
5 | @@ -157,7 +157,7 @@
|
---|
6 | else
|
---|
7 | var rateLabel = txtFormats.header[0] + translate("Rate:") + txtFormats.header[1];
|
---|
8 |
|
---|
9 | - for (var type in template.attack)
|
---|
10 | + for (let type in template.attack)
|
---|
11 | {
|
---|
12 | if (type == "Slaughter")
|
---|
13 | continue; // Slaughter is not a real attack, so do not show it.
|
---|
14 | @@ -225,6 +225,21 @@
|
---|
15 | return attacks.join("\n");
|
---|
16 | }
|
---|
17 |
|
---|
18 | +function getRepairRatioTooltip(ratio)
|
---|
19 | +{
|
---|
20 | + var unit = sprintf(translate("%(health)s / %(second)s / %(worker)s"), {
|
---|
21 | + health: txtFormats.unit[0] + translate("Health") + txtFormats.unit[1],
|
---|
22 | + second: txtFormats.unit[0] + translate("second") + txtFormats.unit[1],
|
---|
23 | + worker: txtFormats.unit[0] + translate("worker") + txtFormats.unit[1]
|
---|
24 | + });
|
---|
25 | +
|
---|
26 | + return "\n" + sprintf(translate("%(repairRateLabel)s %(detail)s %(unit)s"), {
|
---|
27 | + repairRateLabel: txtFormats.header[0] + translate("Repair Rate:") + txtFormats.header[1],
|
---|
28 | + detail: ratio,
|
---|
29 | + unit: unit
|
---|
30 | + });
|
---|
31 | +}
|
---|
32 | +
|
---|
33 | /**
|
---|
34 | * Translates a cost component identifier as they are used internally
|
---|
35 | * (e.g. "population", "food", etc.) to proper display names.
|
---|
36 | Index: binaries/data/mods/public/gui/session/selection_details.js
|
---|
37 | ===================================================================
|
---|
38 | --- binaries/data/mods/public/gui/session/selection_details.js (revision 17452)
|
---|
39 | +++ binaries/data/mods/public/gui/session/selection_details.js (working copy)
|
---|
40 | @@ -255,11 +255,15 @@
|
---|
41 | var armorString = getArmorTooltip(entState.armour);
|
---|
42 |
|
---|
43 | // Attack and Armor
|
---|
44 | - if ("attack" in entState && entState.attack)
|
---|
45 | + if (entState.attack)
|
---|
46 | Engine.GetGUIObjectByName("attackAndArmorStats").tooltip = getAttackTooltip(entState) + "\n" + armorString;
|
---|
47 | else
|
---|
48 | Engine.GetGUIObjectByName("attackAndArmorStats").tooltip = armorString;
|
---|
49 |
|
---|
50 | + // Repair Rate
|
---|
51 | + if (entState.repairRatio)
|
---|
52 | + Engine.GetGUIObjectByName("attackAndArmorStats").tooltip += getRepairRatioTooltip(entState.repairRatio);
|
---|
53 | +
|
---|
54 | // Icon Tooltip
|
---|
55 | var iconTooltip = "";
|
---|
56 | Index: binaries/data/mods/public/gui/session/unit_actions.js
|
---|
57 | ===================================================================
|
---|
58 | --- binaries/data/mods/public/gui/session/unit_actions.js (revision 17452)
|
---|
59 | +++ binaries/data/mods/public/gui/session/unit_actions.js (working copy)
|
---|
60 | @@ -677,7 +677,7 @@
|
---|
61 | count += state.garrisonHolder.entities.length;
|
---|
62 | }
|
---|
63 | return {
|
---|
64 | - "tooltip": translate("Unload All"),
|
---|
65 | + "tooltip": '[font="sans-bold-16"]' + translate("Unload All") + "[/font]\n" + translate("Release all garrisoned units"),
|
---|
66 | "icon": "garrison-out.png",
|
---|
67 | "count": count,
|
---|
68 | };
|
---|
69 | @@ -708,7 +708,7 @@
|
---|
70 |
|
---|
71 |
|
---|
72 | return {
|
---|
73 | - "tooltip": translate("Delete"),
|
---|
74 | + "tooltip": '[font="sans-bold-16"]' + translate("Delete") + "[/font]\n" + translate("Destroy everything selected"),
|
---|
75 | "icon": "kill_small.png"
|
---|
76 | };
|
---|
77 | },
|
---|
78 | @@ -734,7 +734,7 @@
|
---|
79 | if (!entState.unitAI)
|
---|
80 | return false;
|
---|
81 | return {
|
---|
82 | - "tooltip": translate("Stop"),
|
---|
83 | + "tooltip": '[font="sans-bold-16"]' + translate("Stop") + "[/font]\n" + translate("Cancel all existing orders"),
|
---|
84 | "icon": "stop.png"
|
---|
85 | };
|
---|
86 | },
|
---|
87 | @@ -752,7 +752,7 @@
|
---|
88 | if (!entState.unitAI || entState.turretParent)
|
---|
89 | return false;
|
---|
90 | return {
|
---|
91 | - "tooltip": translate("Garrison"),
|
---|
92 | + "tooltip": '[font="sans-bold-16"]' + translate("Garrison") + "[/font]\n" + translate("Lock selected units inside and shoot arrows from warships and defensive buildings"),
|
---|
93 | "icon": "garrison.png"
|
---|
94 | };
|
---|
95 | },
|
---|
96 | @@ -773,7 +773,7 @@
|
---|
97 | if (!p.garrisonHolder || p.garrisonHolder.entities.indexOf(entState.id) == -1)
|
---|
98 | return false;
|
---|
99 | return {
|
---|
100 | - "tooltip": translate("Unload"),
|
---|
101 | + "tooltip": '[font="sans-bold-16"]' + translate("Unload") + "[/font]\n" + translate("Release one unit"),
|
---|
102 | "icon": "garrison-out.png"
|
---|
103 | };
|
---|
104 | },
|
---|
105 | @@ -789,7 +789,7 @@
|
---|
106 | if (!entState.builder)
|
---|
107 | return false;
|
---|
108 | return {
|
---|
109 | - "tooltip": translate("Repair"),
|
---|
110 | + "tooltip": '[font="sans-bold-16"]' + translate("Repair") + "[/font]\n" + translate("Restore health, rate depends on structure"),
|
---|
111 | "icon": "repair.png"
|
---|
112 | };
|
---|
113 | },
|
---|
114 | @@ -806,7 +806,7 @@
|
---|
115 | if (!entState.rallyPoint)
|
---|
116 | return false;
|
---|
117 | return {
|
---|
118 | - "tooltip": translate("Focus on Rally Point"),
|
---|
119 | + "tooltip": '[font="sans-bold-16"]' + translate("Focus on Rally Point") + "[/font]\n" + translate("Move camera to entity"),
|
---|
120 | "icon": "focus-rally.png"
|
---|
121 | };
|
---|
122 | },
|
---|
123 | @@ -829,7 +829,7 @@
|
---|
124 | if (!entState.unitAI || !entState.unitAI.hasWorkOrders)
|
---|
125 | return false;
|
---|
126 | return {
|
---|
127 | - "tooltip": translate("Back to Work"),
|
---|
128 | + "tooltip": '[font="sans-bold-16"]' + translate("Back to Work") + "[/font]\n" + translate("Order unit the last given task"),
|
---|
129 | "icon": "production.png"
|
---|
130 | };
|
---|
131 | },
|
---|
132 | @@ -845,7 +845,7 @@
|
---|
133 | if (!entState.unitAI || !entState.unitAI.canGuard || entState.unitAI.isGuarding)
|
---|
134 | return false;
|
---|
135 | return {
|
---|
136 | - "tooltip": translate("Guard"),
|
---|
137 | + "tooltip": '[font="sans-bold-16"]' + translate("Guard") + "[/font]\n" + translate("Follow another entity, repair/heal it and protect when attacked"),
|
---|
138 | "icon": "add-guard.png"
|
---|
139 | };
|
---|
140 | },
|
---|
141 | @@ -862,7 +862,7 @@
|
---|
142 | if (!entState.unitAI || !entState.unitAI.isGuarding)
|
---|
143 | return false;
|
---|
144 | return {
|
---|
145 | - "tooltip": translate("Remove guard"),
|
---|
146 | + "tooltip": '[font="sans-bold-16"]' + translate("Remove guard") +"[/font]\n" + translate("Stop guarding"),
|
---|
147 | "icon": "remove-guard.png"
|
---|
148 | };
|
---|
149 | },
|
---|
150 | @@ -913,7 +913,7 @@
|
---|
151 | }
|
---|
152 | }
|
---|
153 | return {
|
---|
154 | - "tooltip": translate("Unload All"),
|
---|
155 | + "tooltip": '[font="sans-bold-16"]' + translate("Unload All") + "[/font]\n" + translate("Release all garrisoned units"),
|
---|
156 | "icon": "garrison-out.png",
|
---|
157 | "count": count,
|
---|
158 | };
|
---|
159 |
|
---|
160 | Index: binaries/data/mods/public/simulation/components/GuiInterface.js
|
---|
161 | ===================================================================
|
---|
162 | --- binaries/data/mods/public/simulation/components/GuiInterface.js (revision 17452)
|
---|
163 | +++ binaries/data/mods/public/simulation/components/GuiInterface.js (working copy)
|
---|
164 | @@ -342,15 +342,11 @@
|
---|
165 |
|
---|
166 | var cmpOwnership = Engine.QueryInterface(ent, IID_Ownership);
|
---|
167 | if (cmpOwnership)
|
---|
168 | - {
|
---|
169 | ret.player = cmpOwnership.GetOwner();
|
---|
170 | - }
|
---|
171 |
|
---|
172 | var cmpRallyPoint = Engine.QueryInterface(ent, IID_RallyPoint);
|
---|
173 | if (cmpRallyPoint)
|
---|
174 | - {
|
---|
175 | ret.rallyPoint = {'position': cmpRallyPoint.GetPositions()[0]}; // undefined or {x,z} object
|
---|
176 | - }
|
---|
177 |
|
---|
178 | var cmpGarrisonHolder = Engine.QueryInterface(ent, IID_GarrisonHolder);
|
---|
179 | if (cmpGarrisonHolder)
|
---|
180 | @@ -432,6 +428,7 @@
|
---|
181 | "obstruction": null,
|
---|
182 | "turretParent":null,
|
---|
183 | "promotion": null,
|
---|
184 | + "repairTime": null,
|
---|
185 | "resourceDropsite": null,
|
---|
186 | "resourceGatherRates": null,
|
---|
187 | "resourceSupply": null,
|
---|
188 | @@ -488,15 +485,11 @@
|
---|
189 |
|
---|
190 | var cmpArmour = Engine.QueryInterface(ent, IID_DamageReceiver);
|
---|
191 | if (cmpArmour)
|
---|
192 | - {
|
---|
193 | ret.armour = cmpArmour.GetArmourStrengths();
|
---|
194 | - }
|
---|
195 |
|
---|
196 | var cmpAuras = Engine.QueryInterface(ent, IID_Auras);
|
---|
197 | if (cmpAuras)
|
---|
198 | - {
|
---|
199 | ret.auras = cmpAuras.GetDescriptions();
|
---|
200 | - }
|
---|
201 |
|
---|
202 | var cmpBuildingAI = Engine.QueryInterface(ent, IID_BuildingAI);
|
---|
203 | if (cmpBuildingAI)
|
---|
204 | @@ -522,6 +515,10 @@
|
---|
205 | if (cmpPosition && cmpPosition.GetTurretParent() != INVALID_ENTITY)
|
---|
206 | ret.turretParent = cmpPosition.GetTurretParent();
|
---|
207 |
|
---|
208 | + var cmpRepairable = Engine.QueryInterface(ent, IID_Repairable);
|
---|
209 | + if (cmpRepairable)
|
---|
210 | + ret.repairRatio = cmpRepairable.GetRepairRatio();
|
---|
211 | +
|
---|
212 | var cmpResourceSupply = QueryMiragedInterface(ent, IID_ResourceSupply);
|
---|
213 | if (cmpResourceSupply)
|
---|
214 | {
|
---|
215 | @@ -538,9 +535,7 @@
|
---|
216 |
|
---|
217 | var cmpResourceGatherer = Engine.QueryInterface(ent, IID_ResourceGatherer);
|
---|
218 | if (cmpResourceGatherer)
|
---|
219 | - {
|
---|
220 | ret.resourceGatherRates = cmpResourceGatherer.GetGatherRates();
|
---|
221 | - }
|
---|
222 |
|
---|
223 | var cmpResourceDropsite = Engine.QueryInterface(ent, IID_ResourceDropsite);
|
---|
224 | if (cmpResourceDropsite)
|
---|
225 | Index: binaries/data/mods/public/simulation/components/Repairable.js
|
---|
226 | ===================================================================
|
---|
227 | --- binaries/data/mods/public/simulation/components/Repairable.js (revision 17452)
|
---|
228 | +++ binaries/data/mods/public/simulation/components/Repairable.js (working copy)
|
---|
229 | @@ -74,4 +74,13 @@
|
---|
230 | Engine.PostMessage(this.entity, MT_ConstructionFinished, { "entity": this.entity, "newentity": this.entity });
|
---|
231 | };
|
---|
232 |
|
---|
233 | +Repairable.prototype.GetRepairRatio = function()
|
---|
234 | +{
|
---|
235 | + let cmpHealth = Engine.QueryInterface(this.entity, IID_Health);
|
---|
236 | + let cmpCost = Engine.QueryInterface(this.entity, IID_Cost);
|
---|
237 | + let repairTime = this.repairTimeRatio * cmpCost.GetBuildTime();
|
---|
238 | + let repairRatio = (cmpHealth.GetMaxHitpoints() / repairTime);
|
---|
239 | + return (Math.round(repairRatio * 10 ) / 10);
|
---|
240 | +};
|
---|
241 | +
|
---|
242 | Engine.RegisterComponentType(IID_Repairable, "Repairable", Repairable);
|
---|
243 | Index: binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
|
---|
244 | ===================================================================
|
---|
245 | --- binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js (revision 17452)
|
---|
246 | +++ binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js (working copy)
|
---|
247 | @@ -510,6 +510,7 @@
|
---|
248 | obstruction: null,
|
---|
249 | turretParent: null,
|
---|
250 | promotion: null,
|
---|
251 | + repairTime: null,
|
---|
252 | resourceDropsite: null,
|
---|
253 | resourceGatherRates: null,
|
---|
254 | resourceSupply: null,
|
---|