vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | local dewdrop = DewdropLib:GetInstance('1.0') |
2 | local tablet = TabletLib:GetInstance('1.0') |
||
3 | local metrognome = Metrognome:GetInstance('1') |
||
4 | local chosenProfession = SkillsPlusFuLocals.FUBAR_LABEL |
||
5 | local toonSaveKey = '' |
||
6 | |||
7 | SkillsPlusFu = FuBarPlugin:GetInstance('1.2'):new({ |
||
8 | name = SkillsPlusFuLocals.NAME, |
||
9 | description = SkillsPlusFuLocals.DESCRIPTION, |
||
10 | version = '0.6.'..string.sub('$Revision: 0 $', 12, -3), |
||
11 | releaseDate = string.sub('$Date: 2006-08-19 07:00 +0200 (Sat, 19 August 2006) $', 8, 17), |
||
12 | aceCompatible = 103, |
||
13 | -- fuCompatible = 102, |
||
14 | author = 'Jayhawk', |
||
15 | email = 'jaydehawk@gmail.com', |
||
16 | category = 'others', |
||
17 | db = AceDatabase:new('SkillsPlusFuDB'), |
||
18 | defaults = { |
||
19 | showSkillLabel = true, |
||
20 | showBooleanSkills = false, |
||
21 | showPlayerNames = true, |
||
22 | showNotification = false, |
||
23 | showOtherToonSkills = false, |
||
24 | cooldownSave = {}, |
||
25 | skillsSave = {}, |
||
26 | }, |
||
27 | charDefaults = { hidden = {} }, |
||
28 | -- cmd = AceChatCmd:new(SkillsPlusFuLocals.COMMANDS, SkillsPlusFuLocals.CMD_OPTIONS), |
||
29 | loc = SkillsPlusFuLocals, |
||
30 | hasIcon = 'Interface\\Icons\\Trade_Engineering', |
||
31 | clickableTooltip = true, |
||
32 | }) |
||
33 | |||
34 | -- menu toggles |
||
35 | |||
36 | function SkillsPlusFu:IsShowingSkillLabel() |
||
37 | return self.data.showSkillLabel |
||
38 | end |
||
39 | |||
40 | function SkillsPlusFu:ToggleShowingSkillLabel() |
||
41 | self.data.showSkillLabel = not self.data.showSkillLabel |
||
42 | self:UpdateTooltip() |
||
43 | return self.data.showSkillLabel |
||
44 | end |
||
45 | |||
46 | function SkillsPlusFu:IsShowingOtherToonSkills() |
||
47 | return self.data.showOtherToonSkills |
||
48 | end |
||
49 | |||
50 | function SkillsPlusFu:ToggleOtherToonSkills() |
||
51 | self.data.showOtherToonSkills = not self.data.showOtherToonSkills |
||
52 | self:UpdateData() |
||
53 | self:UpdateTooltip() |
||
54 | return self.data.showOtherToonSkills |
||
55 | end |
||
56 | |||
57 | function SkillsPlusFu:IsShowingBooleanSkills() |
||
58 | return self.data.showBooleanSkills |
||
59 | end |
||
60 | |||
61 | function SkillsPlusFu:ToggleShowingBooleanSkills() |
||
62 | self.data.showBooleanSkills = not self.data.showBooleanSkills |
||
63 | self:UpdateTooltip() |
||
64 | return self.data.showBooleanSkills |
||
65 | end |
||
66 | |||
67 | function SkillsPlusFu:IsShowingPlayerNames() |
||
68 | return self.data.showPlayerNames |
||
69 | end |
||
70 | |||
71 | function SkillsPlusFu:ToggleShowingPlayerNames() |
||
72 | self.data.showPlayerNames = not self.data.showPlayerNames |
||
73 | self:UpdateTooltip() |
||
74 | return self.data.showPlayerNames |
||
75 | end |
||
76 | |||
77 | function SkillsPlusFu:IsShowNotification() |
||
78 | return self.data.showNotification |
||
79 | end |
||
80 | |||
81 | function SkillsPlusFu:ToggleShowNotification() |
||
82 | self.data.showNotification = not self.data.showNotification |
||
83 | self:UpdateTooltip() |
||
84 | return self.data.showNotification |
||
85 | end |
||
86 | |||
87 | -- update |
||
88 | |||
89 | function SkillsPlusFu:OnUpdate(difference) |
||
90 | if( self:IsShowNotification() ) then |
||
91 | for k, v in self.data.cooldownSave do |
||
92 | for itemName, itemTable in v do |
||
93 | local remaining = ((itemTable.Cooldown + itemTable.LastCheck) - time()) |
||
94 | if (remaining <= self.loc.COOLDOWN_NOTIFYTIME) then |
||
95 | if (self.data.cooldownSave[k][itemName].IsReady ~= 1) then |
||
96 | local _, _, realm, player = string.find(k, '^(.+)\|(.+)$') |
||
97 | if (remaining <= 0) then |
||
98 | DEFAULT_CHAT_FRAME:AddMessage(format(self.loc.COOLDOWN_IS_READY, itemName, realm, player)) |
||
99 | else |
||
100 | DEFAULT_CHAT_FRAME:AddMessage(format(self.loc.COOLDOWN_WILL_BE_READY, itemName, realm, player, floor(remaining+0.9))) |
||
101 | end |
||
102 | PlaySound('AuctionWindowOpen') |
||
103 | self.data.cooldownSave[k][itemName].IsReady = 1 |
||
104 | self:Update() |
||
105 | end |
||
106 | end |
||
107 | end |
||
108 | end |
||
109 | end |
||
110 | end |
||
111 | |||
112 | -- init/exit functions |
||
113 | |||
114 | function SkillsPlusFu:Initialize() |
||
115 | -- load icons |
||
116 | self.ICON_ALCHEMY = 'Interface\\Icons\\Trade_Alchemy' |
||
117 | self.ICON_BLACKSMITHING = 'Interface\\Icons\\Trade_Blacksmithing' |
||
118 | self.ICON_COOKING = 'Interface\\Icons\\INV_Misc_Food_15' |
||
119 | self.ICON_DISENCHANTING = 'Interface\\Icons\\Spell_Holy_RemoveCurse' |
||
120 | self.ICON_ENCHANTING = 'Interface\\Icons\\Trade_Engraving' |
||
121 | self.ICON_ENGINEERING = 'Interface\\Icons\\Trade_Engineering' |
||
122 | self.ICON_FIRSTAID = 'Interface\\Icons\\Spell_Holy_SealOfSacrifice' |
||
123 | self.ICON_FISHING = 'Interface\\Icons\\Trade_Fishing' |
||
124 | self.ICON_LEATHERWORKING = 'Interface\\Icons\\Trade_Leatherworking' |
||
125 | self.ICON_LOCKPICKING = 'Interface\\Icons\\INV_Misc_Key_03' |
||
126 | self.ICON_POISONS = 'Interface\\Icons\\Trade_BrewPoison' |
||
127 | self.ICON_SMELTING = 'Interface\\Icons\\Trade_Mining' |
||
128 | self.ICON_TAILORING = 'Interface\\Icons\\Trade_Tailoring' |
||
129 | |||
130 | self.skillList = {} |
||
131 | end |
||
132 | |||
133 | function SkillsPlusFu:Enable() |
||
134 | -- skills management |
||
135 | self:RegisterEvent('SKILL_LINES_CHANGED','Update') |
||
136 | self:RegisterEvent('PLAYER_LEVEL_UP','Update') |
||
137 | |||
138 | -- cooldown management |
||
139 | metrognome:Register(self.name, self.OnUpdate, self.loc.COOLDOWN_TIMER_FREQUENCY, self) |
||
140 | metrognome:Start(self.name) |
||
141 | self:RegisterEvent('TRADE_SKILL_UPDATE') |
||
142 | self:RegisterEvent('CHAT_MSG_SPELL_TRADESKILLS') |
||
143 | self:RegisterEvent('CHAT_MSG_LOOT') |
||
144 | -- variables |
||
145 | toonSaveKey = GetCVar('realmName')..'|'..UnitName('player') |
||
146 | end |
||
147 | |||
148 | function SkillsPlusFu:Disable() |
||
149 | metrognome:Unregister(self.name) |
||
150 | end |
||
151 | |||
152 | -- cooldown management |
||
153 | |||
154 | function SkillsPlusFu:CooldownRemaining(timeStamp) |
||
155 | local timeRemaining = {} |
||
156 | timeRemaining.d = 0 |
||
157 | timeRemaining.h = 0 |
||
158 | timeRemaining.m = 0 |
||
159 | timeRemaining.s = 0 |
||
160 | |||
161 | -- 86,400 seconds equals one day |
||
162 | if (timeStamp >= 86400) then |
||
163 | timeRemaining.d = floor(timeStamp / 86400) |
||
164 | timeStamp = (timeStamp - (timeRemaining.d * 86400)) |
||
165 | end |
||
166 | -- 3,600 seconds equals one hour |
||
167 | if (timeStamp >= 3600) then |
||
168 | timeRemaining.h = floor(timeStamp / 3600) |
||
169 | timeStamp = (timeStamp - (timeRemaining.h * 3600)) |
||
170 | end |
||
171 | -- 60 seconds equals one minute |
||
172 | if ( timeStamp >= 60 ) then |
||
173 | timeRemaining.m = floor(timeStamp / 60) |
||
174 | timeStamp = (timeStamp - (timeRemaining.m * 60)) |
||
175 | end |
||
176 | -- add remaining seconds |
||
177 | timeRemaining.s = timeStamp |
||
178 | |||
179 | return timeRemaining |
||
180 | end |
||
181 | |||
182 | function SkillsPlusFu:TRADE_SKILL_UPDATE() |
||
183 | local numSkills = GetNumTradeSkills() |
||
184 | for i=1, numSkills do |
||
185 | local itemName = GetTradeSkillInfo(i) |
||
186 | local cooldown = GetTradeSkillCooldown(i) |
||
187 | |||
188 | -- check for transmute only, all transmutes share the same cooldown |
||
189 | if (string.find(itemName, self.loc.COOLDOWN_TRANSMUTE_MATCH)) then |
||
190 | itemName = self.loc.COOLDOWN_TRANSMUTES |
||
191 | end |
||
192 | if (itemName == self.loc.COOLDOWN_TRANSMUTES or |
||
193 | itemName == self.loc.COOLDOWN_MOONCLOTH) then |
||
194 | if (cooldown == nil) then |
||
195 | cooldown = 0 |
||
196 | end |
||
197 | if (self.data.cooldownSave[toonSaveKey] == nil) then |
||
198 | self.data.cooldownSave[toonSaveKey] = {} |
||
199 | end |
||
200 | if (self.data.cooldownSave[toonSaveKey][itemName] == nil) then |
||
201 | self.data.cooldownSave[toonSaveKey][itemName] = {} |
||
202 | end |
||
203 | self.data.cooldownSave[toonSaveKey][itemName].Cooldown = cooldown |
||
204 | self.data.cooldownSave[toonSaveKey][itemName].LastCheck = time() |
||
205 | self.data.cooldownSave[toonSaveKey][itemName].IsReady = 0 |
||
206 | end |
||
207 | end |
||
208 | self:Update() |
||
209 | end |
||
210 | |||
211 | function SkillsPlusFu:CHAT_MSG_SPELL_TRADESKILLS() |
||
212 | local _, _, created |
||
213 | created = string.find(arg1, self.loc.COOLDOWN_CREATE_ITEM); |
||
214 | if (created and string.find(arg1, self.loc.COOLDOWN_SNOWBALL)) then |
||
215 | -- we found a snowball |
||
216 | local itemName = self.loc.COOLDOWN_SNOWMASTER |
||
217 | if (self.data.cooldownSave[toonSaveKey] == nil) then |
||
218 | self.data.cooldownSave[toonSaveKey] = {} |
||
219 | end |
||
220 | if (cooldownSave[toonSaveKey][itemName] == nil) then |
||
221 | cooldownSave[toonSaveKey][itemName] = {} |
||
222 | end |
||
223 | self.data.cooldownSave[toonSaveKey][itemName].Cooldown = 86400 |
||
224 | self.data.cooldownSave[toonSaveKey][itemName].LastCheck = time() |
||
225 | self.data.cooldownSave[toonSaveKey][itemName].IsReady = 0 |
||
226 | elseif (created and string.find(arg1, self.loc.COOLDOWN_REFINED_SALT)) then |
||
227 | -- we found refined salt |
||
228 | local itemName = self.loc.COOLDOWN_SALT_SHAKER |
||
229 | if (self.data.cooldownSave[toonSaveKey] == nil) then |
||
230 | self.data.cooldownSave[toonSaveKey] = {} |
||
231 | end |
||
232 | if (self.data.cooldownSave[toonSaveKey][itemName] == nil) then |
||
233 | self.data.cooldownSave[toonSaveKey][itemName] = {} |
||
234 | end |
||
235 | self.data.cooldownSave[toonSaveKey][itemName].Cooldown = 259200 |
||
236 | self.data.cooldownSave[toonSaveKey][itemName].LastCheck = time() |
||
237 | self.data.cooldownSave[toonSaveKey][itemName].IsReady = 0 |
||
238 | end |
||
239 | self:Update() |
||
240 | end |
||
241 | |||
242 | function SkillsPlusFu:CHAT_MSG_LOOT() |
||
243 | if (string.find(arg1, self.loc.COOLDOWN_ELUNE_STONE)) then |
||
244 | local itemName = self.loc.COOLDOWN_ELUNES_LANTERN |
||
245 | if (self.data.cooldownSave[toonSaveKey] == nil) then |
||
246 | self.data.cooldownSave[toonSaveKey] = {} |
||
247 | end |
||
248 | if (self.data.cooldownSave[toonSaveKey][itemName] == nil) then |
||
249 | self.data.cooldownSave[toonSaveKey][itemName] = {} |
||
250 | end |
||
251 | self.data.cooldownSave[toonSaveKey][itemName].Cooldown = 86400 |
||
252 | self.data.cooldownSave[toonSaveKey][itemName].LastCheck = time() |
||
253 | self.data.cooldownSave[toonSaveKey][itemName].IsReady = 0 |
||
254 | end |
||
255 | self:Update() |
||
256 | end |
||
257 | |||
258 | function SkillsPlusFu:ClearCooldownData() |
||
259 | self.data.cooldownSave = {} |
||
260 | self:Update() |
||
261 | end |
||
262 | |||
263 | -- skills management |
||
264 | |||
265 | function SkillsPlusFu:AddProfessionMenu(skillName) |
||
266 | if (skillName == self.loc.SKILL_ALCHEMY) then |
||
267 | dewdrop:AddLine( |
||
268 | 'text', self.loc.SKILL_ALCHEMY, |
||
269 | 'func', function() CastSpellByName(self.loc.SKILL_ALCHEMY) |
||
270 | self:UpdateText(self.loc.SKILL_ALCHEMY,self.ICON_ALCHEMY) |
||
271 | end, |
||
272 | 'arg1', self |
||
273 | ) |
||
274 | end |
||
275 | if (skillName == self.loc.SKILL_BLACKSMITHING) then |
||
276 | dewdrop:AddLine( |
||
277 | 'text', self.loc.SKILL_BLACKSMITHING, |
||
278 | 'func', function() CastSpellByName(self.loc.SKILL_BLACKSMITHING) |
||
279 | self:UpdateText(self.loc.SKILL_BLACKSMITHING,self.ICON_BLACKSMITHING) |
||
280 | end, |
||
281 | 'arg1', self |
||
282 | ) |
||
283 | end |
||
284 | if (skillName == self.loc.SKILL_COOKING) then |
||
285 | dewdrop:AddLine( |
||
286 | 'text', self.loc.SKILL_COOKING, |
||
287 | 'func', function() CastSpellByName(self.loc.SKILL_COOKING) |
||
288 | self:UpdateText(self.loc.SKILL_COOKING,self.ICON_COOKING) |
||
289 | end, |
||
290 | 'arg1', self |
||
291 | ) |
||
292 | end |
||
293 | if (skillName == self.loc.SKILL_ENCHANTING) then |
||
294 | dewdrop:AddLine( |
||
295 | 'text', self.loc.SKILL_DISENCHANTING, |
||
296 | 'func', function() CastSpellByName(self.loc.SKILL_DISENCHANTING) |
||
297 | self:UpdateText(self.loc.SKILL_DISENCHANTING,self.ICON_DISENCHANTING) |
||
298 | end, |
||
299 | 'arg1', self |
||
300 | ) |
||
301 | dewdrop:AddLine( |
||
302 | 'text', self.loc.SKILL_ENCHANTING, |
||
303 | 'func', function() CastSpellByName(self.loc.SKILL_ENCHANTING) |
||
304 | self:UpdateText(self.loc.SKILL_ENCHANTING,self.ICON_ENCHANTING) |
||
305 | end, |
||
306 | 'arg1', self |
||
307 | ) |
||
308 | end |
||
309 | if (skillName == self.loc.SKILL_ENGINEERING) then |
||
310 | dewdrop:AddLine( |
||
311 | 'text', self.loc.SKILL_ENGINEERING, |
||
312 | 'func', function() CastSpellByName(self.loc.SKILL_ENGINEERING) |
||
313 | self:UpdateText(self.loc.SKILL_ENGINEERING,self.ICON_ENGINEERING) |
||
314 | end, |
||
315 | 'arg1', self |
||
316 | ) |
||
317 | end |
||
318 | if (skillName == self.loc.SKILL_FIRSTAID) then |
||
319 | dewdrop:AddLine( |
||
320 | 'text', self.loc.SKILL_FIRSTAID, |
||
321 | 'func', function() CastSpellByName(self.loc.SKILL_FIRSTAID) |
||
322 | self:UpdateText(self.loc.SKILL_FIRSTAID,self.ICON_FIRSTAID) |
||
323 | end, |
||
324 | 'arg1', self |
||
325 | ) |
||
326 | end |
||
327 | if (skillName == self.loc.SKILL_FISHING) then |
||
328 | dewdrop:AddLine( |
||
329 | 'text', self.loc.SKILL_FISHING, |
||
330 | 'func', function() CastSpellByName(self.loc.SKILL_FISHING) |
||
331 | self:UpdateText(self.loc.SKILL_FISHING,self.ICON_FISHING) |
||
332 | end, |
||
333 | 'arg1', self |
||
334 | ) |
||
335 | end |
||
336 | if (skillName == self.loc.SKILL_LEATHERWORKING) then |
||
337 | dewdrop:AddLine( |
||
338 | 'text', self.loc.SKILL_LEATHERWORKING, |
||
339 | 'func', function() CastSpellByName(self.loc.SKILL_LEATHERWORKING) |
||
340 | self:UpdateText(self.loc.SKILL_LEATHERWORKING,self.ICON_LEATHERWORKING) |
||
341 | end, |
||
342 | 'arg1', self |
||
343 | ) |
||
344 | end |
||
345 | if (skillName == self.loc.SKILL_LOCKPICKING) then |
||
346 | dewdrop:AddLine( |
||
347 | 'text', self.loc.SKILL_LOCKPICKING, |
||
348 | 'func', function() CastSpellByName(self.loc.SKILL_PICKLOCK) |
||
349 | self:UpdateText(self.loc.SKILL_PICKLOCK,self.ICON_LOCKPICKING) |
||
350 | end, |
||
351 | 'arg1', self |
||
352 | ) |
||
353 | end |
||
354 | if (skillName == self.loc.SKILL_MINING) then |
||
355 | dewdrop:AddLine( |
||
356 | 'text', self.loc.SKILL_SMELTING, |
||
357 | 'func', function() CastSpellByName(self.loc.SKILL_SMELTING) |
||
358 | self:UpdateText(self.loc.SKILL_SMELTING,self.ICON_SMELTING) |
||
359 | end, |
||
360 | 'arg1', self |
||
361 | ) |
||
362 | end |
||
363 | if (skillName == self.loc.SKILL_POISONS) then |
||
364 | dewdrop:AddLine( |
||
365 | 'text', self.loc.SKILL_POISONS, |
||
366 | 'func', function() CastSpellByName(self.loc.SKILL_POISONS) |
||
367 | self:UpdateText(self.loc.SKILL_POISONS,self.ICON_POISONS) |
||
368 | end, |
||
369 | 'arg1', self |
||
370 | ) |
||
371 | end |
||
372 | if (skillName == self.loc.SKILL_TAILORING) then |
||
373 | dewdrop:AddLine( |
||
374 | 'text', self.loc.SKILL_TAILORING, |
||
375 | 'func', function() CastSpellByName(self.loc.SKILL_TAILORING) |
||
376 | self:UpdateText(self.loc.SKILL_TAILORING,self.ICON_TAILORING) |
||
377 | end, |
||
378 | 'arg1', self |
||
379 | ) |
||
380 | end |
||
381 | end |
||
382 | |||
383 | function SkillsPlusFu:SaveProfession(skillName,skillRank,skillMaxRank,skillModifier) |
||
384 | if (skillName == self.loc.SKILL_ALCHEMY) or |
||
385 | (skillName == self.loc.SKILL_BLACKSMITHING) or |
||
386 | (skillName == self.loc.SKILL_COOKING) or |
||
387 | (skillName == self.loc.SKILL_ENCHANTING) or |
||
388 | (skillName == self.loc.SKILL_ENGINEERING) or |
||
389 | (skillName == self.loc.SKILL_FIRSTAID) or |
||
390 | (skillName == self.loc.SKILL_LEATHERWORKING) or |
||
391 | (skillName == self.loc.SKILL_TAILORING) then |
||
392 | if (self.data.skillsSave[toonSaveKey] == nil) then |
||
393 | self.data.skillsSave[toonSaveKey] = {} |
||
394 | end |
||
395 | if (self.data.skillsSave[toonSaveKey][skillName] == nil) then |
||
396 | self.data.skillsSave[toonSaveKey][skillName] = {} |
||
397 | end |
||
398 | self.data.skillsSave[toonSaveKey][skillName].Rank = skillRank |
||
399 | self.data.skillsSave[toonSaveKey][skillName].MaxRank = skillMaxRank |
||
400 | self.data.skillsSave[toonSaveKey][skillName].Modifier = skillModifier |
||
401 | |||
402 | end |
||
403 | end |
||
404 | |||
405 | -- general |
||
406 | |||
407 | function SkillsPlusFu:MenuSettings(level, value) |
||
408 | if level == 1 then |
||
409 | local cooldownFound = false |
||
410 | for _,category in self.skillList do |
||
411 | -- items are added with other toon skills following cooldown items |
||
412 | -- just stop adding skill menus when cooldown entry is found to stop |
||
413 | -- other toon skills showing up in the menu |
||
414 | if not cooldownFound then |
||
415 | if category.nonBooleanSkills > 0 then |
||
416 | for _,skill in category.skills do |
||
417 | self:AddProfessionMenu(skill.name) |
||
418 | end |
||
419 | end |
||
420 | cooldownFound = category.category == self.loc.COOLDOWN_CATEGORY |
||
421 | end |
||
422 | end |
||
423 | |||
424 | if (GetNumSkillLines() > 0) then dewdrop:AddLine() end |
||
425 | -- add regular menu options |
||
426 | dewdrop:AddLine( |
||
427 | 'text', self.loc.MENU_SHOW_SKILL_LABEL, -- toggles skill name in fubar menu |
||
428 | 'func', 'ToggleShowingSkillLabel', |
||
429 | 'arg1', self, |
||
430 | 'checked', self:IsShowingSkillLabel() |
||
431 | ) |
||
432 | dewdrop:AddLine( |
||
433 | 'text', self.loc.MENU_SHOW_BOOLEAN_SKILLS, -- toggles boolean skill visibility |
||
434 | 'func', 'ToggleShowingBooleanSkills', |
||
435 | 'arg1', self, |
||
436 | 'checked', self:IsShowingBooleanSkills() |
||
437 | ) |
||
438 | dewdrop:AddLine( |
||
439 | 'text', self.loc.MENU_SHOW_OTHER_TOON_SKILLS, -- toggles other player skills |
||
440 | 'func', 'ToggleOtherToonSkills', |
||
441 | 'arg1', self, |
||
442 | 'checked', self:IsShowingOtherToonSkills() |
||
443 | ) |
||
444 | dewdrop:AddLine() -- separator |
||
445 | dewdrop:AddLine( |
||
446 | 'text', self.loc.MENU_SHOW_TOON_NAMES, -- toggles player names in cooldown items |
||
447 | 'func', 'ToggleShowingPlayerNames', |
||
448 | 'arg1', self, |
||
449 | 'checked', self:IsShowingPlayerNames() |
||
450 | ) |
||
451 | dewdrop:AddLine( |
||
452 | 'text', self.loc.MENU_SHOW_NOTIFICATION, -- toggles cooldown notification |
||
453 | 'func', 'ToggleShowNotification', |
||
454 | 'arg1', self, |
||
455 | 'checked', self:IsShowNotification () |
||
456 | ) |
||
457 | dewdrop:AddLine( |
||
458 | 'text', self.loc.MENU_CLEAR_COOLDOWN_DATA, -- clears saved cooldown data |
||
459 | 'func', 'ClearCooldownData', |
||
460 | 'arg1', self |
||
461 | ) |
||
462 | end |
||
463 | end |
||
464 | |||
465 | function SkillsPlusFu:UpdateData() |
||
466 | local skillIndex = 0 |
||
467 | local skillList = {} |
||
468 | local headerIndex = 0 |
||
469 | |||
470 | local numSkills = GetNumSkillLines() |
||
471 | |||
472 | for skillIndex=1, numSkills do |
||
473 | local skillName, isHeader, isExpanded, skillRank, numTempPoints, skillModifier, skillMaxRank, |
||
474 | isAbandonable, stepCost, rankCost, minLevel, skillCostType, |
||
475 | skillDesc = GetSkillLineInfo(skillIndex) |
||
476 | |||
477 | if isHeader then |
||
478 | headerIndex = headerIndex + 1 |
||
479 | table.insert(skillList, {category=skillName, skills={}, nonBooleanSkills = 0}) |
||
480 | else |
||
481 | if skillMaxRank > 1 then |
||
482 | skillList[headerIndex].nonBooleanSkills = skillList[headerIndex].nonBooleanSkills + 1 |
||
483 | end |
||
484 | table.insert(skillList[headerIndex].skills, {name = skillName, rank = skillRank, |
||
485 | maxrank = skillMaxRank, rankbonus = skillModifier}) |
||
486 | self:SaveProfession(skillName,skillRank,skillMaxRank,skillModifier) |
||
487 | end |
||
488 | end |
||
489 | |||
490 | -- add cooldown header and items |
||
491 | local toonName = '' |
||
492 | headerIndex = headerIndex + 1 |
||
493 | table.insert(skillList, {category=self.loc.COOLDOWN_CATEGORY, skills={}, nonBooleanSkills = 0}) |
||
494 | for k, v in self.data.cooldownSave do |
||
495 | if self:IsShowingPlayerNames() then |
||
496 | toonName = string.sub(k,string.find(k,'|')+1)..': ' |
||
497 | end |
||
498 | for itemName, itemTable in v do |
||
499 | skillList[headerIndex].nonBooleanSkills = skillList[headerIndex].nonBooleanSkills + 1 |
||
500 | table.insert(skillList[headerIndex].skills, {name = toonName..itemName, |
||
501 | rank = itemTable.Cooldown, |
||
502 | maxrank = itemTable.LastCheck, |
||
503 | rankbonus = itemTable.IsReady} |
||
504 | ) |
||
505 | end |
||
506 | end |
||
507 | |||
508 | -- add other toon skills |
||
509 | if self.data.showOtherToonSkills then |
||
510 | for k, v in self.data.skillsSave do |
||
511 | toonName = string.sub(k,string.find(k,'|')+1) |
||
512 | local realmName = string.sub(k,1,string.find(k,'|')-1) |
||
513 | if (toonName ~= UnitName('player')) and |
||
514 | (realmName == GetCVar('realmName')) |
||
515 | then |
||
516 | headerIndex = headerIndex + 1 |
||
517 | table.insert(skillList, {category=toonName, skills={}, nonBooleanSkills = 0}) |
||
518 | for skillName, skillTable in v do |
||
519 | skillList[headerIndex].nonBooleanSkills = skillList[headerIndex].nonBooleanSkills + 1 |
||
520 | table.insert(skillList[headerIndex].skills, {name = skillName, |
||
521 | rank = skillTable.Rank, |
||
522 | maxrank = skillTable.MaxRank, |
||
523 | rankbonus = skillTable.Modifier} |
||
524 | ) |
||
525 | end |
||
526 | end |
||
527 | end |
||
528 | end |
||
529 | |||
530 | self.skillList = skillList |
||
531 | end |
||
532 | |||
533 | function SkillsPlusFu:UpdateText(newProfession,newIcon) |
||
534 | if newProfession ~= nil then chosenProfession = newProfession end |
||
535 | if newIcon ~= nil then self:SetIcon(newIcon) end |
||
536 | |||
537 | -- add cooldown information |
||
538 | local cooldownInfo = '' |
||
539 | local totalItems = 0 |
||
540 | local readyItems = 0 |
||
541 | |||
542 | -- loop and add items and ready items |
||
543 | for k, v in self.data.cooldownSave do |
||
544 | for itemName, itemTable in v do |
||
545 | local remaining = ((itemTable.Cooldown + itemTable.LastCheck) - time()) |
||
546 | totalItems = totalItems + 1 |
||
547 | if (remaining <= 0) then |
||
548 | readyItems = readyItems + 1 |
||
549 | end |
||
550 | end |
||
551 | end |
||
552 | |||
553 | -- set label text count colours |
||
554 | local colorCode = self.loc.COOLDOWN_COLOR_READY |
||
555 | if ( readyItems == 0 ) then |
||
556 | colorCode = self.loc.COOLDOWN_COLOR_NOTREADY |
||
557 | end |
||
558 | cooldownInfo = format(colorCode..self.loc.COOLDOWN_FORMAT..FONT_COLOR_CODE_CLOSE, readyItems, totalItems) |
||
559 | |||
560 | -- add skill label is toggle is true |
||
561 | if self:IsShowingSkillLabel() then |
||
562 | self.labelName = chosenProfession..' '..cooldownInfo |
||
563 | else |
||
564 | self.labelName = cooldownInfo |
||
565 | end |
||
566 | |||
567 | -- set the actual label |
||
568 | self:SetText(self.labelName) |
||
569 | |||
570 | dewdrop:Close() |
||
571 | |||
572 | end |
||
573 | |||
574 | function SkillsPlusFu:ToggleCategory(id, button) |
||
575 | if self.charData.hidden[id] then |
||
576 | self.charData.hidden[id] = false |
||
577 | else |
||
578 | self.charData.hidden[id] = true |
||
579 | end |
||
580 | -- refresh in place |
||
581 | self:UpdateTooltip() |
||
582 | end |
||
583 | |||
584 | function SkillsPlusFu:UpdateTooltip() |
||
585 | tablet:SetHint(self.loc.TOOLTIP_HINT) |
||
586 | -- skills |
||
587 | for _,category in self.skillList do |
||
588 | if category.nonBooleanSkills > 0 or self:IsShowingBooleanSkills() then |
||
589 | local tooltipLine = tablet:AddCategory('id', category.category, 'columns', 2, |
||
590 | 'text', category.category, |
||
591 | 'func', 'ToggleCategory', 'arg1', self, 'arg2', category.category, |
||
592 | 'child_textR', 1, 'child_textG', 1, 'child_textB', 0, |
||
593 | 'showWithoutChildren', true, |
||
594 | 'checked', true, 'hasCheck', true, 'checkIcon', |
||
595 | self.charData.hidden[category.category] and 'Interface\\Buttons\\UI-PlusButton-Up' or 'Interface\\Buttons\\UI-MinusButton-Up' |
||
596 | ) |
||
597 | if not self.charData.hidden[category.category] then |
||
598 | for _,skill in category.skills do |
||
599 | if category.category ~= self.loc.COOLDOWN_CATEGORY then |
||
600 | -- is either current toon skill or other toon skill |
||
601 | if skill.maxrank > 1 then |
||
602 | local rank = skill.rank |
||
603 | if skill.rankbonus > 0 then |
||
604 | rank = rank..'(+'..skill.rankbonus..')' |
||
605 | end |
||
606 | rank = rank..'/'..skill.maxrank |
||
607 | local r,g,b = FuBarUtils.GetThresholdColor((skill.rank+(skill.rankbonus or 0)) / skill.maxrank) |
||
608 | tooltipLine:AddLine('text', skill.name, 'text2', rank, |
||
609 | 'text2R', r, 'text2G', g, 'text2B', b) |
||
610 | elseif self:IsShowingBooleanSkills() then |
||
611 | tooltipLine:AddLine('text', skill.name) |
||
612 | end |
||
613 | else -- is cooldown item |
||
614 | -- rank contains itemTable.Cooldown, max rank contains itemTable.LastCheck |
||
615 | local timeRemaining = ((skill.rank + skill.maxrank) - time()) |
||
616 | local timeRemainingText = '' |
||
617 | |||
618 | if (timeRemaining <= 0) then |
||
619 | timeRemainingText = self.loc.COOLDOWN_COLOR_READY..self.loc.COOLDOWN_READY |
||
620 | else |
||
621 | local timeTable = self:CooldownRemaining(timeRemaining) |
||
622 | local timeString = string.format('%dD %02d:%02d', timeTable.d, timeTable.h, timeTable.m) |
||
623 | if ((timeTable.d == 0) and (timeTable.h == 0)) then |
||
624 | timeRemainingText = self.loc.COOLDOWN_COLOR_ALMOSTREADY..timeString |
||
625 | else |
||
626 | timeRemainingText = self.loc.COOLDOWN_COLOR_NOTREADY..timeString |
||
627 | end |
||
628 | end |
||
629 | tooltipLine:AddLine('text', skill.name, 'text2', timeRemainingText) |
||
630 | end |
||
631 | end |
||
632 | end |
||
633 | end |
||
634 | end |
||
635 | end |
||
636 | |||
637 | function SkillsPlusFu:OnClick() |
||
638 | if self.chosenProfession == self.loc.FUBAR_LABEL then |
||
639 | ToggleCharacter('SkillFrame') |
||
640 | else |
||
641 | CastSpellByName(chosenProfession) |
||
642 | end |
||
643 | |||
644 | end |
||
645 | |||
646 | SkillsPlusFu:RegisterForLoad() |