vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | DurabilityFu = AceLibrary("AceAddon-2.0"):new("FuBarPlugin-2.0", "AceDB-2.0", "AceEvent-2.0", "AceHook-2.0", "AceConsole-2.0") |
2 | |||
3 | DurabilityFu:RegisterDB("DurabilityFuDB") |
||
4 | DurabilityFu:RegisterDefaults('profile', { |
||
5 | showPopup = true, |
||
6 | showMan = false, |
||
7 | showAverage = false, |
||
8 | showHealthy = true, |
||
9 | popupX = 0, |
||
10 | popupY = -200, |
||
11 | autoRepairEquipment = false, |
||
12 | autoRepairInventory = false, |
||
13 | }) |
||
14 | |||
15 | DurabilityFu.version = "2.0." .. string.sub("$Revision: 9763 $", 12, -3) |
||
16 | DurabilityFu.date = string.sub("$Date: 2006-09-01 11:45:46 -1000 (Fri, 01 Sep 2006) $", 8, 17) |
||
17 | DurabilityFu.hasIcon = true |
||
18 | DurabilityFu.canHideText = true |
||
19 | |||
20 | local L = AceLibrary("AceLocale-2.0"):new("FuBar_DurabilityFu") |
||
21 | |||
22 | local Gratuity = AceLibrary("Gratuity-2.0") |
||
23 | local Tablet = AceLibrary("Tablet-2.0") |
||
24 | local Abacus = AceLibrary("Abacus-2.0") |
||
25 | local Crayon = AceLibrary("Crayon-2.0") |
||
26 | |||
27 | local TEXT_SERGEANT, TEXT_HONORED |
||
28 | if AceLibrary("AceDB-2.0").FACTION == FACTION_HORDE then |
||
29 | TEXT_SERGEANT = PVP_RANK_7_0 |
||
30 | else |
||
31 | TEXT_SERGEANT = PVP_RANK_7_1 |
||
32 | end |
||
33 | TEXT_HONORED = FACTION_STANDING_LABEL6 |
||
34 | |||
35 | function DurabilityFu:IsShowingPopup() |
||
36 | return self.db.profile.showPopup |
||
37 | end |
||
38 | |||
39 | function DurabilityFu:ToggleShowingPopup() |
||
40 | self.db.profile.showPopup = not self.db.profile.showPopup |
||
41 | end |
||
42 | |||
43 | function DurabilityFu:IsAutoRepairingEquipment() |
||
44 | return self.db.profile.autoRepairEquipment |
||
45 | end |
||
46 | |||
47 | function DurabilityFu:ToggleAutoRepairingEquipment() |
||
48 | self.db.profile.autoRepairEquipment = not self.db.profile.autoRepairEquipment |
||
49 | end |
||
50 | |||
51 | function DurabilityFu:IsAutoRepairingInventory() |
||
52 | return self.db.profile.autoRepairInventory |
||
53 | end |
||
54 | |||
55 | function DurabilityFu:ToggleAutoRepairingInventory() |
||
56 | self.db.profile.autoRepairInventory = not self.db.profile.autoRepairInventory |
||
57 | end |
||
58 | |||
59 | function DurabilityFu:IsShowingMan() |
||
60 | return self.db.profile.showMan |
||
61 | end |
||
62 | |||
63 | function DurabilityFu:ToggleShowingMan() |
||
64 | self.db.profile.showMan = not self.db.profile.showMan |
||
65 | --[[ if self.db.profile.showMan and self.manX ~= nil and self.manY ~= nil then |
||
66 | DurabilityFrame:ClearAllPoints() |
||
67 | DurabilityFrame:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", self.manX, self.manY) |
||
68 | elseif DurabilityFrame:GetRight() ~= nil and DurabilityFrame:GetTop() ~= nil then |
||
69 | self.manX = DurabilityFrame:GetRight() - GetScreenWidth() |
||
70 | self.manY = DurabilityFrame:GetTop() - GetScreenHeight() |
||
71 | DurabilityFrame:ClearAllPoints() |
||
72 | DurabilityFrame:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", self.manX + 3000, self.manY + 3000) |
||
73 | end]] |
||
74 | DurabilityFrame_SetAlerts() |
||
75 | end |
||
76 | |||
77 | function DurabilityFu:IsShowingAverage() |
||
78 | return self.db.profile.showAverage |
||
79 | end |
||
80 | |||
81 | function DurabilityFu:ToggleShowingAverage() |
||
82 | self.db.profile.showAverage = not self.db.profile.showAverage |
||
83 | self:Update() |
||
84 | end |
||
85 | |||
86 | function DurabilityFu:IsShowingHealthyItems() |
||
87 | return self.db.profile.showHealthy |
||
88 | end |
||
89 | |||
90 | function DurabilityFu:ToggleShowingHealthyItems() |
||
91 | self.db.profile.showHealthy = not self.db.profile.showHealthy |
||
92 | self:UpdateTooltip() |
||
93 | end |
||
94 | |||
95 | function DurabilityFu:OnEnable() |
||
96 | self.repairIndex = 0 |
||
97 | self.repairMoney = 0 |
||
98 | self.itemStatus = { |
||
99 | { value = 0, max = 0, cost = 0, name = INVTYPE_HEAD, slot = "Head" }, |
||
100 | { value = 0, max = 0, cost = 0, name = INVTYPE_SHOULDER, slot = "Shoulder" }, |
||
101 | { value = 0, max = 0, cost = 0, name = INVTYPE_CHEST, slot = "Chest" }, |
||
102 | { value = 0, max = 0, cost = 0, name = INVTYPE_WAIST, slot = "Waist" }, |
||
103 | { value = 0, max = 0, cost = 0, name = INVTYPE_LEGS, slot = "Legs" }, |
||
104 | { value = 0, max = 0, cost = 0, name = INVTYPE_FEET, slot = "Feet" }, |
||
105 | { value = 0, max = 0, cost = 0, name = INVTYPE_WRIST, slot = "Wrist" }, |
||
106 | { value = 0, max = 0, cost = 0, name = INVTYPE_HAND, slot = "Hands" }, |
||
107 | { value = 0, max = 0, cost = 0, name = INVTYPE_WEAPONMAINHAND, slot = "MainHand" }, |
||
108 | { value = 0, max = 0, cost = 0, name = INVTYPE_WEAPONOFFHAND, slot = "SecondaryHand" }, |
||
109 | { value = 0, max = 0, cost = 0, name = INVTYPE_RANGED, slot = "Ranged" }, |
||
110 | { value = 0, max = 0, cost = 0, name = INVENTORY_TOOLTIP }, |
||
111 | } |
||
112 | |||
113 | self:RegisterEvent("PLAYER_UNGHOST", "OnBagUpdate") |
||
114 | self:RegisterEvent("PLAYER_DEAD", "OnBagUpdate") |
||
115 | self:RegisterEvent("PLAYER_REGEN_ENABLED", "OnBagUpdate") |
||
116 | self:RegisterEvent("PLAYER_ENTERING_WORLD") |
||
117 | self:RegisterEvent("UPDATE_INVENTORY_ALERTS") |
||
118 | self:RegisterEvent("MERCHANT_SHOW") |
||
119 | self:RegisterEvent("MERCHANT_CLOSED") |
||
120 | self:RegisterEvent("FACTION_UPDATE") |
||
121 | |||
122 | self:Hook("DurabilityFrame_SetAlerts") |
||
123 | DurabilityFrame_SetAlerts() |
||
124 | end |
||
125 | |||
126 | function DurabilityFu:OnDisable() |
||
127 | StaticPopup_Hide("BOSSPANEL_DURABILITY_POPUP") |
||
128 | if not self.db.profile.showMan then |
||
129 | self:ToggleShowingMan() |
||
130 | self.db.profile.showMan = false |
||
131 | end |
||
132 | end |
||
133 | |||
134 | local options = { |
||
135 | type = 'group', |
||
136 | args = { |
||
137 | popup = { |
||
138 | type = 'toggle', |
||
139 | name = L["Show repair popup at vendor"], |
||
140 | desc = L["Toggle whether to show the popup at the merchant window"], |
||
141 | get = "IsShowingPopup", |
||
142 | set = "ToggleShowingPopup", |
||
143 | }, |
||
144 | showMan = { |
||
145 | type = 'toggle', |
||
146 | name = L["Show the armored man"], |
||
147 | desc = L["Toggle whether to show Blizzard's armored man"], |
||
148 | get = "IsShowingMan", |
||
149 | set = "ToggleShowingMan", |
||
150 | }, |
||
151 | average = { |
||
152 | type = 'toggle', |
||
153 | name = L["Show average value"], |
||
154 | desc = L["Toggle whether to show your average or minimum durability"], |
||
155 | get = "IsShowingAverage", |
||
156 | set = "ToggleShowingAverage", |
||
157 | }, |
||
158 | healthy = { |
||
159 | type = 'toggle', |
||
160 | name = L["Show healthy items"], |
||
161 | desc = L["Toggle whether to show items that are healthy (100% repaired)"], |
||
162 | get = "IsShowingHealthyItems", |
||
163 | set = "ToggleShowingHealthyItems", |
||
164 | }, |
||
165 | autoRepair = { |
||
166 | type = 'group', |
||
167 | name = L["Auto repair"], |
||
168 | desc = L["Auto repair"], |
||
169 | args = { |
||
170 | equipment = { |
||
171 | type = 'toggle', |
||
172 | name = L["Equipment"], |
||
173 | desc = L["Equipment"], |
||
174 | get = "IsAutoRepairingEquipment", |
||
175 | set = "ToggleAutoRepairingEquipment", |
||
176 | }, |
||
177 | inventory = { |
||
178 | type = 'toggle', |
||
179 | name = L["Inventory"], |
||
180 | desc = L["Inventory"], |
||
181 | get = "IsAutoRepairingInventory", |
||
182 | set = "ToggleAutoRepairingInventory", |
||
183 | }, |
||
184 | } |
||
185 | }, |
||
186 | }, |
||
187 | handler = DurabilityFu, |
||
188 | } |
||
189 | |||
190 | DurabilityFu:RegisterChatCommand(L["AceConsole-Commands"], options) |
||
191 | DurabilityFu.OnMenuRequest = options |
||
192 | |||
193 | function DurabilityFu:PLAYER_ENTERING_WORLD() |
||
194 | if not self.isHonored then |
||
195 | for i = 1, GetNumFactions() do |
||
196 | local _, _, standing = GetFactionInfo(i) |
||
197 | if standing >= 6 then |
||
198 | self.isHonored = true |
||
199 | break |
||
200 | end |
||
201 | end |
||
202 | end |
||
203 | if not self.isSergeant then |
||
204 | local _, rankNumber = GetPVPRankInfo(UnitPVPRank("player")) |
||
205 | if rankNumber >= 3 then |
||
206 | self.isSergeant = true |
||
207 | end |
||
208 | end |
||
209 | end |
||
210 | |||
211 | function DurabilityFu:FACTION_UPDATE() |
||
212 | if GetNumFactions() > 0 and not self.isHonored then |
||
213 | for i = 1, GetNumFactions() do |
||
214 | local _, _, standing = GetFactionInfo(i) |
||
215 | if standing >= 6 then |
||
216 | self.isHonored = true |
||
217 | break |
||
218 | end |
||
219 | end |
||
220 | self:UnregisterEvent("FACTION_UPDATE") |
||
221 | elseif self.isHonored then |
||
222 | self:UnregisterEvent("FACTION_UPDATE") |
||
223 | end |
||
224 | end |
||
225 | |||
226 | local lastUpdate |
||
227 | function DurabilityFu:UpdateBagData() |
||
228 | if lastUpdate and GetTime() - lastUpdate < 1 then |
||
229 | return |
||
230 | end |
||
231 | lastUpdate = GetTime() |
||
232 | local minStatus = 1.0 |
||
233 | local minValue = 0 |
||
234 | local minMax = 0 |
||
235 | |||
236 | self.itemStatus[12].value = 0 |
||
237 | self.itemStatus[12].max = 0 |
||
238 | self.itemStatus[12].cost = 0 |
||
239 | |||
240 | for bag = 0, 4 do |
||
241 | for slot = 1, GetContainerNumSlots(bag) do |
||
242 | |||
243 | local status, value, max, cost = self:GetStatus(slot, bag) |
||
244 | if not self:IsShowingAverage() then |
||
245 | if status ~= nil and status < minStatus then |
||
246 | minStatus = status |
||
247 | minValue = value |
||
248 | minMax = max |
||
249 | |||
250 | if (self.repairIndex == 0 or status < self:GetPercent(self.itemStatus[self.repairIndex].value, self.itemStatus[self.repairIndex].max)) and max ~= 0 then |
||
251 | self.repairIndex = 12 |
||
252 | end |
||
253 | |||
254 | self.itemStatus[12].value = value |
||
255 | self.itemStatus[12].max = max |
||
256 | end |
||
257 | elseif cost ~= nil then |
||
258 | self.itemStatus[12].value = self.itemStatus[12].value + value |
||
259 | self.itemStatus[12].max = self.itemStatus[12].max + max |
||
260 | end |
||
261 | if cost ~= nil then |
||
262 | self.itemStatus[12].cost = self.itemStatus[12].cost + cost |
||
263 | end |
||
264 | end |
||
265 | end |
||
266 | if self:IsShowingAverage() then |
||
267 | local status = self:GetPercent(self.itemStatus[12].value, self.itemStatus[12].max) |
||
268 | if (self.repairIndex == 0 or status < self:GetPercent(self.itemStatus[self.repairIndex].value, self.itemStatus[self.repairIndex].max)) and self.itemStatus[12].max ~= 0 then |
||
269 | self.repairIndex = 12 |
||
270 | end |
||
271 | end |
||
272 | end |
||
273 | |||
274 | function DurabilityFu:OnBagUpdate() |
||
275 | self:UpdateBagData() |
||
276 | self:UpdateText() |
||
277 | self:UpdateTooltip() |
||
278 | end |
||
279 | |||
280 | local lastUpdate |
||
281 | function DurabilityFu:UpdateInventoryData(toCheck) |
||
282 | if lastUpdate and GetTime() - lastUpdate < 1 then |
||
283 | return |
||
284 | end |
||
285 | lastUpdate = GetTime() |
||
286 | if toCheck == nil then |
||
287 | toCheck = {} |
||
288 | for i = 1, 11 do |
||
289 | toCheck[i] = true |
||
290 | end |
||
291 | end |
||
292 | |||
293 | local minStatus = 1.0 |
||
294 | local minValue = 0 |
||
295 | local minMax = 0 |
||
296 | local minIndex = 0 |
||
297 | |||
298 | for index,_ in toCheck do |
||
299 | local status, value, max, cost = self:GetStatus(index) |
||
300 | if status ~= nil and status < minStatus then |
||
301 | minStatus = status |
||
302 | minValue = value |
||
303 | minMax = max |
||
304 | minIndex = index |
||
305 | end |
||
306 | |||
307 | self.itemStatus[index].value = value or 0 |
||
308 | self.itemStatus[index].max = max or 0 |
||
309 | self.itemStatus[index].cost = cost or 0 |
||
310 | end |
||
311 | |||
312 | self.repairIndex = minIndex |
||
313 | |||
314 | if not self:IsShowingMan() then |
||
315 | self.db.profile.showMan = true |
||
316 | self:ToggleShowingMan() |
||
317 | end |
||
318 | end |
||
319 | |||
320 | function DurabilityFu:UPDATE_INVENTORY_ALERTS() |
||
321 | self:UpdateInventoryData(INVENTORY_ALERT_STATUS_SLOTS) |
||
322 | self:UpdateText() |
||
323 | self:UpdateTooltip() |
||
324 | end |
||
325 | |||
326 | function DurabilityFu:MERCHANT_SHOW() |
||
327 | local dirty = false |
||
328 | local stop = false |
||
329 | if CanMerchantRepair() then |
||
330 | if self:IsAutoRepairingEquipment() then |
||
331 | local repairCost = GetRepairAllCost() |
||
332 | local money = GetMoney() |
||
333 | if money < repairCost then |
||
334 | self:Print("Cannot auto-repair equipment. Your money: %s. Needed: %s", Abacus:FormatMoneyFull(money, true), Abacus:FormatMoneyFull(repairCost, true)) |
||
335 | stop = true |
||
336 | elseif repairCost > 0 then |
||
337 | RepairAllItems() |
||
338 | self:Print("Auto-repaired equipment: %s", Abacus:FormatMoneyFull(repairCost)) |
||
339 | dirty = true |
||
340 | else |
||
341 | self:Print("No equipment to auto-repair") |
||
342 | end |
||
343 | end |
||
344 | if not stop and self:IsAutoRepairingInventory() then |
||
345 | local repairCost = self:CalculateInventoryCost() |
||
346 | local money = GetMoney() |
||
347 | if money < repairCost then |
||
348 | self:Print("Cannot auto-repair inventory. Your money: %s. Needed: %s", Abacus:FormatMoneyFull(money, true), Abacus:FormatMoneyFull(repairCost, true)) |
||
349 | elseif repairCost > 0 then |
||
350 | ShowRepairCursor() |
||
351 | for bag = 0, 4 do |
||
352 | for slot = 1, GetContainerNumSlots(bag) do |
||
353 | local _,repairCost = Gratuity:SetBagItem(bag, slot) |
||
354 | if repairCost ~= nil and repairCost > 0 then |
||
355 | PickupContainerItem(bag, slot) |
||
356 | end |
||
357 | end |
||
358 | end |
||
359 | HideRepairCursor() |
||
360 | self:Print("Auto-repaired inventory: %s", Abacus:FormatMoneyFull(repairCost)) |
||
361 | dirty = true |
||
362 | else |
||
363 | self:Print("No items in inventory to auto-repair") |
||
364 | end |
||
365 | end |
||
366 | end |
||
367 | self.merchantShown = true |
||
368 | if self:IsShowingPopup() then |
||
369 | local canRepair, repairCost = CanMerchantRepair(), GetRepairAllCost() |
||
370 | if canRepair then |
||
371 | repairCost = repairCost + self:CalculateInventoryCost() |
||
372 | if repairCost > 0 then |
||
373 | if dirty then |
||
374 | self:ScheduleEvent(self.OpenPopup, 1, self) |
||
375 | else |
||
376 | self:OpenPopup() |
||
377 | end |
||
378 | end |
||
379 | end |
||
380 | end |
||
381 | self:ScheduleRepeatingEvent(self.name, self.OnUpdate, 1, self) |
||
382 | self.updateNum = nil |
||
383 | self:Update() |
||
384 | end |
||
385 | |||
386 | function DurabilityFu:MERCHANT_CLOSED() |
||
387 | self.merchantShown = false |
||
388 | self:ClosePopup() |
||
389 | self:ScheduleRepeatingEvent(self.name, self.OnUpdate, 1, self) |
||
390 | self.updateNum = nil |
||
391 | self:Update() |
||
392 | end |
||
393 | |||
394 | function DurabilityFu:CalculateInventoryCost() |
||
395 | local result = 0 |
||
396 | for bag = 0, 4 do |
||
397 | for slot = 1, GetContainerNumSlots(bag) do |
||
398 | local _,repairCost = Gratuity:SetBagItem(bag, slot) |
||
399 | if repairCost ~= nil and repairCost > 0 then |
||
400 | result = result + repairCost |
||
401 | end |
||
402 | end |
||
403 | end |
||
404 | |||
405 | return result |
||
406 | end |
||
407 | |||
408 | function DurabilityFu:GetPercent(quotient, denominator) |
||
409 | if denominator ~= 0 then |
||
410 | return quotient / denominator |
||
411 | else |
||
412 | return 1 |
||
413 | end |
||
414 | end |
||
415 | |||
416 | function DurabilityFu:GetStatus(index, bag) |
||
417 | local value = 0 |
||
418 | local max = 0 |
||
419 | local cost = 0 |
||
420 | |||
421 | local hasItem, repairCost |
||
422 | if bag ~= nil then |
||
423 | _,repairCost = Gratuity:SetBagItem(bag, index) |
||
424 | hasItem = GetContainerItemInfo(bag, index) ~= nil |
||
425 | else |
||
426 | local slotName = self.itemStatus[index].slot .. "Slot" |
||
427 | |||
428 | local id = GetInventorySlotInfo(slotName) |
||
429 | hasItem,_,repairCost = Gratuity:SetInventoryItem("player", id) |
||
430 | end |
||
431 | |||
432 | if hasItem then |
||
433 | if repairCost ~= nil then |
||
434 | cost = repairCost |
||
435 | end |
||
436 | |||
437 | local value, max = Gratuity:FindDeformat(DURABILITY_TEMPLATE, nil, nil, nil, true) |
||
438 | if value then |
||
439 | value = tonumber(value) |
||
440 | max = tonumber(max) |
||
441 | return self:GetPercent(value, max), value, max, cost |
||
442 | end |
||
443 | end |
||
444 | end |
||
445 | |||
446 | function DurabilityFu:OnDataUpdate() |
||
447 | self:UpdateBagData() |
||
448 | self:UpdateInventoryData() |
||
449 | end |
||
450 | |||
451 | function DurabilityFu:OnTextUpdate() |
||
452 | local percent |
||
453 | if not self:IsShowingAverage() then |
||
454 | if self.repairIndex == 0 then |
||
455 | percent = 1 |
||
456 | else |
||
457 | percent = self:GetPercent(self.itemStatus[self.repairIndex].value, self.itemStatus[self.repairIndex].max) |
||
458 | end |
||
459 | else |
||
460 | local value = 0 |
||
461 | local max = 0 |
||
462 | for i,item in self.itemStatus do |
||
463 | if i ~= 12 then |
||
464 | value = value + item.value |
||
465 | max = max + item.max |
||
466 | end |
||
467 | end |
||
468 | percent = self:GetPercent(value, max) |
||
469 | end |
||
470 | self:SetText(string.format("|cff%s%d%%|r", Crayon:GetThresholdHexColor(percent), percent * 100)) |
||
471 | end |
||
472 | |||
473 | function DurabilityFu:OnTooltipUpdate() |
||
474 | local cost = 0 |
||
475 | local cat = Tablet:AddCategory( |
||
476 | 'columns', 3, |
||
477 | 'child_textR', 1, |
||
478 | 'child_textG', 1, |
||
479 | 'child_textB', 0 |
||
480 | ) |
||
481 | for index, item in self.itemStatus do |
||
482 | if item.max > 0 then |
||
483 | cost = cost + item.cost |
||
484 | local percent = self:GetPercent(item.value, item.max) |
||
485 | if self:IsShowingHealthyItems() or percent < 1 then |
||
486 | local r, g, b = Crayon:GetThresholdColor(percent) |
||
487 | cat:AddLine( |
||
488 | 'text', item.name, |
||
489 | 'text2', string.format("%.0f%%", percent * 100), |
||
490 | 'text2R', r, |
||
491 | 'text2G', g, |
||
492 | 'text2B', b, |
||
493 | 'text3', Abacus:FormatMoneyShort(item.cost, true) |
||
494 | ) |
||
495 | end |
||
496 | end |
||
497 | end |
||
498 | local value = 0 |
||
499 | local max = 0 |
||
500 | for i,item in self.itemStatus do |
||
501 | if i ~= 12 then |
||
502 | value = value + item.value |
||
503 | max = max + item.max |
||
504 | end |
||
505 | end |
||
506 | cat = Tablet:AddCategory( |
||
507 | 'columns', 2, |
||
508 | 'text', L["Total"], |
||
509 | 'child_textR', 1, |
||
510 | 'child_textG', 1, |
||
511 | 'child_textB', 0, |
||
512 | 'child_text2R', 1, |
||
513 | 'child_text2G', 1, |
||
514 | 'child_text2B', 1 |
||
515 | ) |
||
516 | local r, g, b = Crayon:GetThresholdColor(value / max) |
||
517 | cat:AddLine( |
||
518 | 'text', L["Percent"], |
||
519 | 'text2', string.format("%.0f%%", value / max * 100), |
||
520 | 'text2R', r, |
||
521 | 'text2G', g, |
||
522 | 'text2B', b |
||
523 | ) |
||
524 | |||
525 | cat:AddLine( |
||
526 | 'text', L["Repair cost"], |
||
527 | 'text2', Abacus:FormatMoneyFull(cost, true) |
||
528 | ) |
||
529 | if not self.merchantShown then |
||
530 | if self.isSergeant then |
||
531 | if self.isHonored then |
||
532 | cat:AddLine( |
||
533 | 'text', TEXT_HONORED .. " / " .. TEXT_SERGEANT, |
||
534 | 'text2', Abacus:FormatMoneyFull(cost * 0.9, true) |
||
535 | ) |
||
536 | cat:AddLine( |
||
537 | 'text', TEXT_HONORED .. " & " .. TEXT_SERGEANT, |
||
538 | 'text2', Abacus:FormatMoneyFull(cost * 0.8, true) |
||
539 | ) |
||
540 | else |
||
541 | cat:AddLine( |
||
542 | 'text', TEXT_SERGEANT, |
||
543 | 'text2', Abacus:FormatMoneyFull(cost * 0.9, true) |
||
544 | ) |
||
545 | end |
||
546 | elseif self.isHonored then |
||
547 | cat:AddLine( |
||
548 | 'text', TEXT_HONORED, |
||
549 | 'text2', Abacus:FormatMoneyFull(cost * 0.9, true) |
||
550 | ) |
||
551 | end |
||
552 | end |
||
553 | end |
||
554 | |||
555 | function DurabilityFu:PromptEquipment_OnClick() |
||
556 | RepairAllItems() |
||
557 | self:ClosePopup() |
||
558 | self:Update() |
||
559 | end |
||
560 | |||
561 | function DurabilityFu:PromptInventory_OnClick() |
||
562 | ShowRepairCursor() |
||
563 | for bag = 0, 4 do |
||
564 | for slot = 1, GetContainerNumSlots(bag) do |
||
565 | local _,repairCost = Gratuity:SetBagItem(bag, slot) |
||
566 | if repairCost ~= nil and repairCost > 0 then |
||
567 | PickupContainerItem(bag, slot) |
||
568 | end |
||
569 | end |
||
570 | end |
||
571 | HideRepairCursor() |
||
572 | self:ClosePopup() |
||
573 | self:Update() |
||
574 | self:ScheduleRepeatingEvent(self.name, self.OnUpdate, 1, self) |
||
575 | end |
||
576 | |||
577 | function DurabilityFu:OnUpdate() |
||
578 | if self.updateNum == nil then |
||
579 | self.updateNum = 0 |
||
580 | end |
||
581 | self:Update() |
||
582 | self.updateNum = self.updateNum + 1 |
||
583 | if self.updateNum >= 5 then |
||
584 | self:CancelScheduledEvent(self.name) |
||
585 | self.updateNum = 0 |
||
586 | end |
||
587 | end |
||
588 | |||
589 | function DurabilityFu:PromptBoth_OnClick() |
||
590 | RepairAllItems() |
||
591 | self:PromptInventory_OnClick() |
||
592 | end |
||
593 | |||
594 | local popup |
||
595 | function DurabilityFu:ClosePopup() |
||
596 | if popup then |
||
597 | popup:Hide() |
||
598 | end |
||
599 | end |
||
600 | |||
601 | local buttonSize = 32 |
||
602 | |||
603 | function DurabilityFu:OpenPopup() |
||
604 | local canRepair, repairCost = CanMerchantRepair(), GetRepairAllCost() |
||
605 | if not canRepair then |
||
606 | return |
||
607 | end |
||
608 | repairCost = repairCost + self:CalculateInventoryCost() |
||
609 | if repairCost == 0 then |
||
610 | return |
||
611 | end |
||
612 | if not popup then |
||
613 | popup = CreateFrame("Frame", "DurabilityFuPrompt", UIParent) |
||
614 | popup:SetFrameStrata("DIALOG") |
||
615 | popup:EnableMouse(true) |
||
616 | popup:SetMovable(true) |
||
617 | popup:Hide() |
||
618 | popup:SetWidth(256) |
||
619 | popup:SetHeight(160) |
||
620 | popup:SetPoint("TOP", UIParent, "TOP", self.db.profile.popupX, self.db.profile.popupY) |
||
621 | |||
622 | local header = CreateFrame("Frame", popup:GetName() .. "Header", popup) |
||
623 | header:SetWidth(192) |
||
624 | header:SetHeight(32) |
||
625 | header:SetPoint("TOP", popup, "TOP", 0, 6) |
||
626 | local texture = header:CreateTexture(popup:GetName() .. "HeaderBar", "ARTWORK") |
||
627 | texture:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header") |
||
628 | texture:SetWidth(384) |
||
629 | texture:SetHeight(64) |
||
630 | texture:SetPoint("TOP", header, "TOP", 0, 5) |
||
631 | texture:Show() |
||
632 | local text = header:CreateFontString(popup:GetName() .. "HeaderTitle", "ARTWORK") |
||
633 | text:SetFontObject(GameFontNormal) |
||
634 | text:SetPoint("CENTER", header, "CENTER", 0, 0) |
||
635 | text:SetText(self:GetTitle() .. " " .. L["Repair"]) |
||
636 | header:EnableMouse(true) |
||
637 | header:SetMovable(true) |
||
638 | header:SetScript("OnMouseDown", function() |
||
639 | popup:StartMoving() |
||
640 | end) |
||
641 | header:SetScript("OnMouseUp", function() |
||
642 | popup:StopMovingOrSizing() |
||
643 | self.db.profile.popupY = popup:GetTop() - GetScreenHeight() |
||
644 | self.db.profile.popupX = popup:GetCenter() - GetScreenWidth() / 2 |
||
645 | end) |
||
646 | |||
647 | local eqButton = CreateFrame("Button", popup:GetName() .. "EquipmentButton", popup) |
||
648 | popup.eqButton = eqButton |
||
649 | eqButton:SetWidth(buttonSize) |
||
650 | eqButton:SetHeight(buttonSize) |
||
651 | local texture = eqButton:CreateTexture() |
||
652 | texture:SetWidth(buttonSize * 1.6458333) |
||
653 | texture:SetHeight(buttonSize * 1.6458333) |
||
654 | texture:SetPoint("CENTER", eqButton, "CENTER") |
||
655 | texture:SetTexture("Interface\\Buttons\\UI-Quickslot2") |
||
656 | eqButton:SetNormalTexture(texture) |
||
657 | local texture = eqButton:CreateTexture(nil, "BACKGROUND") |
||
658 | texture:SetTexture("Interface\\Icons\\INV_Chest_Leather_08") |
||
659 | texture:SetAllPoints(eqButton) |
||
660 | eqButton:SetPushedTexture("Interface\\Buttons\\UI-Quickslot-Depress") |
||
661 | local texture = eqButton:CreateTexture() |
||
662 | texture:SetTexture("Interface\\Buttons\\ButtonHilight-Square") |
||
663 | texture:SetAllPoints(eqButton) |
||
664 | eqButton:SetHighlightTexture(texture) |
||
665 | local texture = eqButton:CreateTexture() |
||
666 | texture:SetTexture("Interface\\Icons\\INV_Chest_Leather_08") |
||
667 | texture:SetDesaturated(true) |
||
668 | texture:SetAllPoints(eqButton) |
||
669 | eqButton:SetDisabledTexture(texture) |
||
670 | eqButton:SetPoint("TOPRIGHT", popup, "TOPRIGHT", -18, -36) |
||
671 | eqButton:SetScript("OnClick", function() |
||
672 | self:PromptEquipment_OnClick() |
||
673 | end) |
||
674 | local texture = eqButton:CreateTexture(nil, "ARTWORK") |
||
675 | texture:SetTexture(0, 0, 0, 0.5) |
||
676 | texture:SetAllPoints(eqButton) |
||
677 | local button_Enable = eqButton.Enable |
||
678 | function eqButton:Enable() |
||
679 | button_Enable(self) |
||
680 | texture:Hide() |
||
681 | end |
||
682 | local button_Disable = eqButton.Disable |
||
683 | function eqButton:Disable() |
||
684 | button_Disable(self) |
||
685 | texture:Show() |
||
686 | end |
||
687 | |||
688 | local invButton = CreateFrame("Button", popup:GetName() .. "InventoryButton", popup) |
||
689 | popup.invButton = invButton |
||
690 | invButton:SetWidth(buttonSize) |
||
691 | invButton:SetHeight(buttonSize) |
||
692 | local texture = invButton:CreateTexture() |
||
693 | texture:SetWidth(buttonSize * 1.6458333) |
||
694 | texture:SetHeight(buttonSize * 1.6458333) |
||
695 | texture:SetPoint("CENTER", invButton, "CENTER") |
||
696 | texture:SetTexture("Interface\\Buttons\\UI-Quickslot2") |
||
697 | invButton:SetNormalTexture(texture) |
||
698 | local texture = invButton:CreateTexture(nil, "BACKGROUND") |
||
699 | texture:SetTexture("Interface\\Icons\\INV_Misc_Bag_10") |
||
700 | texture:SetAllPoints(invButton) |
||
701 | invButton:SetPushedTexture("Interface\\Buttons\\UI-Quickslot-Depress") |
||
702 | local texture = invButton:CreateTexture() |
||
703 | texture:SetTexture("Interface\\Buttons\\ButtonHilight-Square") |
||
704 | texture:SetAllPoints(invButton) |
||
705 | invButton:SetHighlightTexture(texture) |
||
706 | local texture = invButton:CreateTexture() |
||
707 | texture:SetTexture("Interface\\Icons\\INV_Misc_Bag_10") |
||
708 | texture:SetDesaturated(true) |
||
709 | texture:SetAllPoints(invButton) |
||
710 | invButton:SetDisabledTexture(texture) |
||
711 | invButton:SetPoint("TOP", eqButton, "BOTTOM", 0, -8) |
||
712 | invButton:SetScript("OnClick", function() |
||
713 | self:PromptInventory_OnClick() |
||
714 | end) |
||
715 | local texture = invButton:CreateTexture(nil, "ARTWORK") |
||
716 | texture:SetTexture(0, 0, 0, 0.5) |
||
717 | texture:SetAllPoints(invButton) |
||
718 | local button_Enable = invButton.Enable |
||
719 | function invButton:Enable() |
||
720 | button_Enable(self) |
||
721 | texture:Hide() |
||
722 | end |
||
723 | local button_Disable = invButton.Disable |
||
724 | function invButton:Disable() |
||
725 | button_Disable(self) |
||
726 | texture:Show() |
||
727 | end |
||
728 | |||
729 | local bothButton = CreateFrame("Button", popup:GetName() .. "BothButton", popup) |
||
730 | popup.bothButton = bothButton |
||
731 | bothButton:SetWidth(buttonSize) |
||
732 | bothButton:SetHeight(buttonSize) |
||
733 | local texture = bothButton:CreateTexture() |
||
734 | texture:SetWidth(buttonSize * 1.6458333) |
||
735 | texture:SetHeight(buttonSize * 1.6458333) |
||
736 | texture:SetPoint("CENTER", bothButton, "CENTER") |
||
737 | texture:SetTexture("Interface\\Buttons\\UI-Quickslot2") |
||
738 | bothButton:SetNormalTexture(texture) |
||
739 | local texture = bothButton:CreateTexture(nil, "BACKGROUND") |
||
740 | texture:SetTexture("Interface\\Icons\\Trade_Blacksmithing") |
||
741 | texture:SetAllPoints(bothButton) |
||
742 | bothButton:SetPushedTexture("Interface\\Buttons\\UI-Quickslot-Depress") |
||
743 | local texture = bothButton:CreateTexture() |
||
744 | texture:SetTexture("Interface\\Buttons\\ButtonHilight-Square") |
||
745 | texture:SetAllPoints(bothButton) |
||
746 | bothButton:SetHighlightTexture(texture) |
||
747 | local texture = bothButton:CreateTexture() |
||
748 | texture:SetTexture("Interface\\Icons\\Trade_Blacksmithing") |
||
749 | texture:SetDesaturated(true) |
||
750 | texture:SetAllPoints(bothButton) |
||
751 | bothButton:SetDisabledTexture(texture) |
||
752 | bothButton:SetPoint("TOP", invButton, "BOTTOM", 0, -8) |
||
753 | bothButton:SetScript("OnClick", function() |
||
754 | self:PromptBoth_OnClick() |
||
755 | end) |
||
756 | local texture = bothButton:CreateTexture(nil, "ARTWORK") |
||
757 | texture:SetTexture(0, 0, 0, 0.5) |
||
758 | texture:SetAllPoints(bothButton) |
||
759 | local button_Enable = bothButton.Enable |
||
760 | function bothButton:Enable() |
||
761 | button_Enable(self) |
||
762 | texture:Hide() |
||
763 | end |
||
764 | local button_Disable = bothButton.Disable |
||
765 | function bothButton:Disable() |
||
766 | button_Disable(self) |
||
767 | texture:Show() |
||
768 | end |
||
769 | |||
770 | local closeButton = CreateFrame("Button", popup:GetName() .. "CloseButton", popup) |
||
771 | popup.closeButton = closeButton |
||
772 | closeButton:SetWidth(32) |
||
773 | closeButton:SetHeight(32) |
||
774 | closeButton:SetPoint("TOPRIGHT", popup, "TOPRIGHT", 0, 0) |
||
775 | closeButton:SetNormalTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Up") |
||
776 | closeButton:SetPushedTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Down") |
||
777 | local texture = closeButton:CreateTexture() |
||
778 | texture:SetTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Highlight") |
||
779 | texture:SetBlendMode("ADD") |
||
780 | closeButton:SetHighlightTexture(texture) |
||
781 | closeButton:SetScript("OnClick", function() |
||
782 | self:ClosePopup() |
||
783 | end) |
||
784 | closeButton:Show() |
||
785 | |||
786 | local eqCost = CreateFrame("Frame", popup:GetName() .. "EquipmentCost", popup) |
||
787 | popup.eqCost = eqCost |
||
788 | eqCost:SetWidth(96) |
||
789 | eqCost:SetHeight(13) |
||
790 | eqCost:SetPoint("RIGHT", eqButton, "LEFT", -8, 0) |
||
791 | local copper = CreateFrame("Frame", eqCost:GetName() .. "Copper", eqCost) |
||
792 | copper:SetWidth(32) |
||
793 | copper:SetHeight(13) |
||
794 | copper:SetPoint("RIGHT", eqCost, "RIGHT") |
||
795 | local texture = copper:CreateTexture(copper:GetName() .. "Texture", "ARTWORK") |
||
796 | texture:SetPoint("RIGHT", copper, "RIGHT") |
||
797 | texture:SetWidth(13) |
||
798 | texture:SetHeight(13) |
||
799 | texture:SetTexture("Interface\\MoneyFrame\\UI-MoneyIcons") |
||
800 | texture:SetTexCoord(0.5, 0.75, 0, 1) |
||
801 | local copperText = copper:CreateFontString(copper:GetName() .. "Text", "ARTWORK") |
||
802 | copperText:SetPoint("RIGHT", texture, "LEFT") |
||
803 | copperText:SetHeight(13) |
||
804 | copperText:SetFontObject(NumberFontNormal) |
||
805 | copperText:SetText(0) |
||
806 | copperText:SetJustifyH("RIGHT") |
||
807 | |||
808 | local silver = CreateFrame("Frame", eqCost:GetName() .. "Silver", eqCost) |
||
809 | silver:SetWidth(32) |
||
810 | silver:SetHeight(13) |
||
811 | silver:SetPoint("RIGHT", copper, "LEFT") |
||
812 | local texture = silver:CreateTexture(silver:GetName() .. "Texture", "ARTWORK") |
||
813 | texture:SetPoint("RIGHT", silver, "RIGHT") |
||
814 | texture:SetWidth(13) |
||
815 | texture:SetHeight(13) |
||
816 | texture:SetTexture("Interface\\MoneyFrame\\UI-MoneyIcons") |
||
817 | texture:SetTexCoord(0.25, 0.5, 0, 1) |
||
818 | local silverText = silver:CreateFontString(silver:GetName() .. "Text", "ARTWORK") |
||
819 | silverText:SetPoint("RIGHT", texture, "LEFT") |
||
820 | silverText:SetHeight(13) |
||
821 | silverText:SetFontObject(NumberFontNormal) |
||
822 | silverText:SetText(0) |
||
823 | silverText:SetJustifyH("RIGHT") |
||
824 | |||
825 | local gold = CreateFrame("Frame", eqCost:GetName() .. "Gold", eqCost) |
||
826 | gold:SetWidth(32) |
||
827 | gold:SetHeight(13) |
||
828 | gold:SetPoint("RIGHT", silver, "LEFT") |
||
829 | local texture = gold:CreateTexture(gold:GetName() .. "Texture", "ARTWORK") |
||
830 | texture:SetPoint("RIGHT", gold, "RIGHT") |
||
831 | texture:SetWidth(13) |
||
832 | texture:SetHeight(13) |
||
833 | texture:SetTexture("Interface\\MoneyFrame\\UI-MoneyIcons") |
||
834 | texture:SetTexCoord(0, 0.25, 0, 1) |
||
835 | local goldText = gold:CreateFontString(gold:GetName() .. "Text", "ARTWORK") |
||
836 | goldText:SetPoint("RIGHT", texture, "LEFT") |
||
837 | goldText:SetHeight(13) |
||
838 | goldText:SetFontObject(NumberFontNormal) |
||
839 | goldText:SetText(0) |
||
840 | goldText:SetJustifyH("RIGHT") |
||
841 | function eqCost:SetValue(value) |
||
842 | local g = floor(value / 10000) |
||
843 | local s = mod(floor(value / 100), 100) |
||
844 | local c = mod(value, 100) |
||
845 | goldText:SetText(g) |
||
846 | silverText:SetText(s) |
||
847 | copperText:SetText(c) |
||
848 | if g == 0 then |
||
849 | gold:Hide() |
||
850 | if s == 0 then |
||
851 | silver:Hide() |
||
852 | else |
||
853 | silver:Show() |
||
854 | end |
||
855 | else |
||
856 | gold:Show() |
||
857 | silver:Show() |
||
858 | end |
||
859 | end |
||
860 | |||
861 | local invCost = CreateFrame("Frame", popup:GetName() .. "InventoryCost", popup) |
||
862 | popup.invCost = invCost |
||
863 | invCost:SetWidth(96) |
||
864 | invCost:SetHeight(13) |
||
865 | invCost:SetPoint("RIGHT", invButton, "LEFT", -8, 0) |
||
866 | local copper = CreateFrame("Frame", invCost:GetName() .. "Copper", invCost) |
||
867 | copper:SetWidth(32) |
||
868 | copper:SetHeight(13) |
||
869 | copper:SetPoint("RIGHT", invCost, "RIGHT") |
||
870 | local texture = copper:CreateTexture(copper:GetName() .. "Texture", "ARTWORK") |
||
871 | texture:SetPoint("RIGHT", copper, "RIGHT") |
||
872 | texture:SetWidth(13) |
||
873 | texture:SetHeight(13) |
||
874 | texture:SetTexture("Interface\\MoneyFrame\\UI-MoneyIcons") |
||
875 | texture:SetTexCoord(0.5, 0.75, 0, 1) |
||
876 | local copperText = copper:CreateFontString(copper:GetName() .. "Text", "ARTWORK") |
||
877 | copperText:SetPoint("RIGHT", texture, "LEFT") |
||
878 | copperText:SetHeight(13) |
||
879 | copperText:SetFontObject(NumberFontNormal) |
||
880 | copperText:SetText(0) |
||
881 | copperText:SetJustifyH("RIGHT") |
||
882 | |||
883 | local silver = CreateFrame("Frame", invCost:GetName() .. "Silver", invCost) |
||
884 | silver:SetWidth(32) |
||
885 | silver:SetHeight(13) |
||
886 | silver:SetPoint("RIGHT", copper, "LEFT") |
||
887 | local texture = silver:CreateTexture(silver:GetName() .. "Texture", "ARTWORK") |
||
888 | texture:SetPoint("RIGHT", silver, "RIGHT") |
||
889 | texture:SetWidth(13) |
||
890 | texture:SetHeight(13) |
||
891 | texture:SetTexture("Interface\\MoneyFrame\\UI-MoneyIcons") |
||
892 | texture:SetTexCoord(0.25, 0.5, 0, 1) |
||
893 | local silverText = silver:CreateFontString(silver:GetName() .. "Text", "ARTWORK") |
||
894 | silverText:SetPoint("RIGHT", texture, "LEFT") |
||
895 | silverText:SetHeight(13) |
||
896 | silverText:SetFontObject(NumberFontNormal) |
||
897 | silverText:SetText(0) |
||
898 | silverText:SetJustifyH("RIGHT") |
||
899 | |||
900 | local gold = CreateFrame("Frame", invCost:GetName() .. "Gold", invCost) |
||
901 | gold:SetWidth(32) |
||
902 | gold:SetHeight(13) |
||
903 | gold:SetPoint("RIGHT", silver, "LEFT") |
||
904 | local texture = gold:CreateTexture(gold:GetName() .. "Texture", "ARTWORK") |
||
905 | texture:SetPoint("RIGHT", gold, "RIGHT") |
||
906 | texture:SetWidth(13) |
||
907 | texture:SetHeight(13) |
||
908 | texture:SetTexture("Interface\\MoneyFrame\\UI-MoneyIcons") |
||
909 | texture:SetTexCoord(0, 0.25, 0, 1) |
||
910 | local goldText = gold:CreateFontString(gold:GetName() .. "Text", "ARTWORK") |
||
911 | goldText:SetPoint("RIGHT", texture, "LEFT") |
||
912 | goldText:SetHeight(13) |
||
913 | goldText:SetFontObject(NumberFontNormal) |
||
914 | goldText:SetText(0) |
||
915 | goldText:SetJustifyH("RIGHT") |
||
916 | function invCost:SetValue(value) |
||
917 | local g = floor(value / 10000) |
||
918 | local s = mod(floor(value / 100), 100) |
||
919 | local c = mod(value, 100) |
||
920 | goldText:SetText(g) |
||
921 | silverText:SetText(s) |
||
922 | copperText:SetText(c) |
||
923 | if g == 0 then |
||
924 | gold:Hide() |
||
925 | if s == 0 then |
||
926 | silver:Hide() |
||
927 | else |
||
928 | silver:Show() |
||
929 | end |
||
930 | else |
||
931 | gold:Show() |
||
932 | silver:Show() |
||
933 | end |
||
934 | end |
||
935 | |||
936 | local bothCost = CreateFrame("Frame", popup:GetName() .. "BothCost", popup) |
||
937 | popup.bothCost = bothCost |
||
938 | bothCost:SetWidth(96) |
||
939 | bothCost:SetHeight(13) |
||
940 | bothCost:SetPoint("RIGHT", bothButton, "LEFT", -8, 0) |
||
941 | local copper = CreateFrame("Frame", bothCost:GetName() .. "Copper", bothCost) |
||
942 | copper:SetWidth(32) |
||
943 | copper:SetHeight(13) |
||
944 | copper:SetPoint("RIGHT", bothCost, "RIGHT") |
||
945 | local texture = copper:CreateTexture(copper:GetName() .. "Texture", "ARTWORK") |
||
946 | texture:SetPoint("RIGHT", copper, "RIGHT") |
||
947 | texture:SetWidth(13) |
||
948 | texture:SetHeight(13) |
||
949 | texture:SetTexture("Interface\\MoneyFrame\\UI-MoneyIcons") |
||
950 | texture:SetTexCoord(0.5, 0.75, 0, 1) |
||
951 | local copperText = copper:CreateFontString(copper:GetName() .. "Text", "ARTWORK") |
||
952 | copperText:SetPoint("RIGHT", texture, "LEFT") |
||
953 | copperText:SetHeight(13) |
||
954 | copperText:SetFontObject(NumberFontNormal) |
||
955 | copperText:SetText(0) |
||
956 | copperText:SetJustifyH("RIGHT") |
||
957 | |||
958 | local silver = CreateFrame("Frame", bothCost:GetName() .. "Silver", bothCost) |
||
959 | silver:SetWidth(32) |
||
960 | silver:SetHeight(13) |
||
961 | silver:SetPoint("RIGHT", copper, "LEFT") |
||
962 | local texture = silver:CreateTexture(silver:GetName() .. "Texture", "ARTWORK") |
||
963 | texture:SetPoint("RIGHT", silver, "RIGHT") |
||
964 | texture:SetWidth(13) |
||
965 | texture:SetHeight(13) |
||
966 | texture:SetTexture("Interface\\MoneyFrame\\UI-MoneyIcons") |
||
967 | texture:SetTexCoord(0.25, 0.5, 0, 1) |
||
968 | local silverText = silver:CreateFontString(silver:GetName() .. "Text", "ARTWORK") |
||
969 | silverText:SetPoint("RIGHT", texture, "LEFT") |
||
970 | silverText:SetHeight(13) |
||
971 | silverText:SetFontObject(NumberFontNormal) |
||
972 | silverText:SetText(0) |
||
973 | silverText:SetJustifyH("RIGHT") |
||
974 | |||
975 | local gold = CreateFrame("Frame", bothCost:GetName() .. "Gold", bothCost) |
||
976 | gold:SetWidth(32) |
||
977 | gold:SetHeight(13) |
||
978 | gold:SetPoint("RIGHT", silver, "LEFT") |
||
979 | local texture = gold:CreateTexture(gold:GetName() .. "Texture", "ARTWORK") |
||
980 | texture:SetPoint("RIGHT", gold, "RIGHT") |
||
981 | texture:SetWidth(13) |
||
982 | texture:SetHeight(13) |
||
983 | texture:SetTexture("Interface\\MoneyFrame\\UI-MoneyIcons") |
||
984 | texture:SetTexCoord(0, 0.25, 0, 1) |
||
985 | local goldText = gold:CreateFontString(gold:GetName() .. "Text", "ARTWORK") |
||
986 | goldText:SetPoint("RIGHT", texture, "LEFT") |
||
987 | goldText:SetHeight(13) |
||
988 | goldText:SetFontObject(NumberFontNormal) |
||
989 | goldText:SetText(0) |
||
990 | goldText:SetJustifyH("RIGHT") |
||
991 | function bothCost:SetValue(value) |
||
992 | local g = floor(value / 10000) |
||
993 | local s = mod(floor(value / 100), 100) |
||
994 | local c = mod(value, 100) |
||
995 | goldText:SetText(g) |
||
996 | silverText:SetText(s) |
||
997 | copperText:SetText(c) |
||
998 | if g == 0 then |
||
999 | gold:Hide() |
||
1000 | if s == 0 then |
||
1001 | silver:Hide() |
||
1002 | else |
||
1003 | silver:Show() |
||
1004 | end |
||
1005 | else |
||
1006 | gold:Show() |
||
1007 | silver:Show() |
||
1008 | end |
||
1009 | end |
||
1010 | |||
1011 | local eqLabel = popup:CreateFontString(popup:GetName() .. "EquipmentLabel", "ARTWORK") |
||
1012 | eqLabel:SetPoint("RIGHT", eqCost, "LEFT", -8, 0) |
||
1013 | eqLabel:SetFontObject(GameFontNormal) |
||
1014 | eqLabel:SetText(L["Equipment"]) |
||
1015 | |||
1016 | local invLabel = popup:CreateFontString(popup:GetName() .. "InventoryLabel", "ARTWORK") |
||
1017 | invLabel:SetPoint("RIGHT", invCost, "LEFT", -8, 0) |
||
1018 | invLabel:SetFontObject(GameFontNormal) |
||
1019 | invLabel:SetText(L["Inventory"]) |
||
1020 | |||
1021 | local bothLabel = popup:CreateFontString(popup:GetName() .. "BothLabel", "ARTWORK") |
||
1022 | bothLabel:SetPoint("RIGHT", bothCost, "LEFT", -8, 0) |
||
1023 | bothLabel:SetFontObject(GameFontNormal) |
||
1024 | bothLabel:SetText(L["Total"]) |
||
1025 | |||
1026 | popup:SetBackdrop({ |
||
1027 | bgFile = "Interface\\TutorialFrame\\TutorialFrameBackground", |
||
1028 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", |
||
1029 | tile = true, |
||
1030 | edgeSize = 16, |
||
1031 | tileSize = 32, |
||
1032 | insets = { |
||
1033 | left = 5, |
||
1034 | right = 5, |
||
1035 | top = 5, |
||
1036 | bottom = 5 |
||
1037 | } |
||
1038 | }) |
||
1039 | end |
||
1040 | |||
1041 | popup:Show() |
||
1042 | |||
1043 | local equipment = GetRepairAllCost() |
||
1044 | local inventory = self:CalculateInventoryCost() |
||
1045 | local both = equipment + inventory |
||
1046 | popup.bothButton:Disable() |
||
1047 | if equipment == 0 then |
||
1048 | popup.eqButton:Disable() |
||
1049 | else |
||
1050 | popup.eqButton:Enable() |
||
1051 | popup.bothButton:Enable() |
||
1052 | end |
||
1053 | if inventory == 0 then |
||
1054 | popup.invButton:Disable() |
||
1055 | else |
||
1056 | popup.invButton:Enable() |
||
1057 | popup.bothButton:Enable() |
||
1058 | end |
||
1059 | popup.eqCost:SetValue(equipment) |
||
1060 | popup.invCost:SetValue(inventory) |
||
1061 | popup.bothCost:SetValue(both) |
||
1062 | end |
||
1063 | |||
1064 | function DurabilityFu:DurabilityFrame_SetAlerts() |
||
1065 | self.hooks.DurabilityFrame_SetAlerts.orig() |
||
1066 | if not self:IsShowingMan() then |
||
1067 | DurabilityFrame:Hide() |
||
1068 | end |
||
1069 | end |