-
Notifications
You must be signed in to change notification settings - Fork 2
/
portals.lua
768 lines (691 loc) · 24.8 KB
/
portals.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
if not LibStub then return end
local dewdrop = LibStub('Dewdrop-2.0', true)
local icon = LibStub('LibDBIcon-1.0')
local _
local CreateFrame = CreateFrame
local C_ToyBox = C_ToyBox
local GetBindLocation = GetBindLocation
local GetContainerItemCooldown = GetContainerItemCooldown
local GetContainerItemInfo = GetContainerItemInfo
local GetContainerItemLink = GetContainerItemLink
local GetContainerNumSlots = GetContainerNumSlots
local GetItemCooldown = GetItemCooldown
local GetInventoryItemCooldown = GetInventoryItemCooldown
local GetInventoryItemLink = GetInventoryItemLink
local GetNumGroupMembers = GetNumGroupMembers
local GetSpellBookItemName = GetSpellBookItemName
local GetSpellCooldown = GetSpellCooldown
local GetSpellInfo = GetSpellInfo
local GetTime = GetTime
local IsPlayerSpell = IsPlayerSpell
local PlayerHasToy = PlayerHasToy
local SecondsToTime = SecondsToTime
local SendChatMessage = SendChatMessage
local UnitInRaid = UnitInRaid
local UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT = UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT
local addonName, addonTable = ...
local L = addonTable.L
-- IDs of items usable for transportation
local items = {
-- Dalaran rings
40586, -- Band of the Kirin Tor
48954, -- Etched Band of the Kirin Tor
48955, -- Etched Loop of the Kirin Tor
48956, -- Etched Ring of the Kirin Tor
48957, -- Etched Signet of the Kirin Tor
45688, -- Inscribed Band of the Kirin Tor
45689, -- Inscribed Loop of the Kirin Tor
45690, -- Inscribed Ring of the Kirin Tor
45691, -- Inscribed Signet of the Kirin Tor
44934, -- Loop of the Kirin Tor
44935, -- Ring of the Kirin Tor
40585, -- Signet of the Kirin Tor
51560, -- Runed Band of the Kirin Tor
51558, -- Runed Loop of the Kirin Tor
51559, -- Runed Ring of the Kirin Tor
51557, -- Runed Signet of the Kirin Tor
139599, -- Empowered Ring of the Kirin Tor
-- Engineering Gadgets
30542, -- Dimensional Ripper - Area 52
18984, -- Dimensional Ripper - Everlook
18986, -- Ultrasafe Transporter: Gadgetzan
30544, -- Ultrasafe Transporter: Toshley's Station
48933, -- Wormhole Generator: Northrend
87215, -- Wormhole Generator: Pandaria
112059, -- Wormhole Centrifuge
151652, -- Wormhole Generator: Argus
-- Seasonal items
37863, -- Direbrew's Remote
21711, -- Lunar Festival Invitation
-- Miscellaneous
46874, -- Argent Crusader's Tabard
32757, -- Blessed Medallion of Karabor
35230, -- Darnarian's Scroll of Teleportation
50287, -- Boots of the Bay
52251, -- Jaina's Locket
43824, -- The Schools of Arcane Magic - Mastery
58487, -- Potion of Deepholm
65274, -- Cloak of Coordination (Horde)
65360, -- Cloak of Coordination (Alliance)
63378, -- Hellscream's Reach Tabard
63379, -- Baradin's Wardens Tabard
64457, -- The Last Relic of Argus
63206, -- Wrap of Unity (Alliance)
63207, -- Wrap of Unity (Horde)
63352, -- Shroud of Cooperation (Alliance)
63353, -- Shroud of Cooperation (Horde)
95050, -- The Brassiest Knuckle (Horde)
95051, -- The Brassiest Knuckle (Alliance)
95567, -- Kirin Tor Beacon
95568, -- Sunreaver Beacon
17690, -- Frostwolf Insignia Rank 1 (Horde)
17905, -- Frostwolf Insignia Rank 2 (Horde)
17906, -- Frostwolf Insignia Rank 3 (Horde)
17907, -- Frostwolf Insignia Rank 4 (Horde)
17908, -- Frostwolf Insignia Rank 5 (Horde)
17909, -- Frostwolf Insignia Rank 6 (Horde)
17691, -- Stormpike Insignia Rank 1 (Alliance)
17900, -- Stormpike Insignia Rank 2 (Alliance)
17901, -- Stormpike Insignia Rank 3 (Alliance)
17902, -- Stormpike Insignia Rank 4 (Alliance)
17903, -- Stormpike Insignia Rank 5 (Alliance)
17904, -- Stormpike Insignia Rank 6 (Alliance)
22631, -- Atiesh, Greatstaff of the Guardian
87548, -- Lorewalker's Lodestone
54452, -- Ethereal Portal
93672, -- Dark Portal
103678, -- Time-Lost Artifact
110560, -- Garrison Hearthstone
118662, -- Bladespire Relic
118663, -- Relic of Karabor
118907, -- Pit Fighter's Punching Ring
128353, -- Admiral's Compass
128502, -- Hunter's Seeking Crystal
128503, -- Master Hunter's Seeking Crystal
136849, -- Nature's Beacon
139590, -- Scroll of Teleport: Ravenholdt
140192, -- Dalaran Hearthstone
140324, -- Mobile Telemancy Beacon
142469, -- Violet Seal of the Grand Magus
144391, -- Pugilist's Powerful Punching Ring (Alliance)
144392 -- Pugilist's Powerful Punching Ring (Horde)
}
-- IDs of items usable instead of hearthstone
local scrolls = {
44315, -- Scroll of Recall III
44314, -- Scroll of Recall II
37118, -- Scroll of Recall
142298, -- Astonishingly Scarlet Slippers
28585, -- Ruby Slippers
162973, -- Greatfather Winter's Hearthstone
163045, -- Headless Horseman's Hearthstone
142542, -- Tome of Town Portal
64488, -- The Innkeeper's Daughter
6948 -- Hearthstone
}
local whistle = 141605 -- Flight Master's Whistle
-- Gold Challenge portals
local challengeSpells = {
{ 131204, 'TRUE' }, -- Path of the Jade Serpent
{ 131205, 'TRUE' }, -- Path of the Stout Brew
{ 131206, 'TRUE' }, -- Path of the Shado-Pan
{ 131222, 'TRUE' }, -- Path of the Mogu King
{ 131225, 'TRUE' }, -- Path of the Setting Sun
{ 131231, 'TRUE' }, -- Path of the Scarlet Blade
{ 131229, 'TRUE' }, -- Path of the Scarlet Mitre
{ 131232, 'TRUE' }, -- Path of the Necromancer
{ 131228, 'TRUE' }, -- Path of the Black Ox
{ 159895, 'TRUE' }, -- Path of the Bloodmaul
{ 159896, 'TRUE' }, -- Path of the Iron Prow
{ 159897, 'TRUE' }, -- Path of the Vigilant
{ 159898, 'TRUE' }, -- Path of the Skies
{ 159899, 'TRUE' }, -- Path of the Crescent Moon
{ 159900, 'TRUE' }, -- Path of the Dark Rail
{ 159901, 'TRUE' }, -- Path of the Verdant
{ 159902, 'TRUE' } -- Path of the Burning Mountain
}
local obj = LibStub:GetLibrary('LibDataBroker-1.1'):NewDataObject(addonName, {
type = 'data source',
text = L['P'],
icon = 'Interface\\Icons\\INV_Misc_Rune_06',
})
local methods = {}
local portals
local frame = CreateFrame('frame')
frame:SetScript('OnEvent', function(self, event, ...) if self[event] then return self[event](self, event, ...) end end)
frame:RegisterEvent('PLAYER_LOGIN')
frame:RegisterEvent('SKILL_LINES_CHANGED')
local function pairsByKeys(t)
local a = {}
for n in pairs(t) do
table.insert(a, n)
end
table.sort(a)
local i = 0
local iter = function()
i = i + 1
if a[i] == nil then
return nil
else
return a[i], t[a[i]]
end
end
return iter
end
local function tconcat(t1, t2)
for i = 1, #t2 do
t1[#t1 + 1] = t2[i]
end
return t1
end
function findSpell(spellName)
local i = 1
while true do
local s = GetSpellBookItemName(i, BOOKTYPE_SPELL)
if not s then
break
end
if s == spellName then
return i
end
i = i + 1
end
end
-- returns true, if player has item with given ID in inventory or bags and it's not on cooldown
local function hasItem(itemID)
local item, found, id
-- scan inventory
for slotId = 1, 19 do
item = GetInventoryItemLink('player', slotId)
if item then
found, _, id = item:find('^|c%x+|Hitem:(%d+):.+')
if found and tonumber(id) == itemID then
if GetInventoryItemCooldown('player', slotId) ~= 0 then
return false
else
return true
end
end
end
end
-- scan bags
for bag = 0, 4 do
for slot = 1, GetContainerNumSlots(bag) do
item = GetContainerItemLink(bag, slot)
if item then
found, _, id = item:find('^|c%x+|Hitem:(%d+):.+')
if found and tonumber(id) == itemID then
if GetContainerItemCooldown(bag, slot) ~= 0 then
return false
else
return true
end
end
end
end
end
-- check Toybox
if PlayerHasToy(itemID) and C_ToyBox.IsToyUsable(itemID) then
local startTime, duration, cooldown
startTime, duration = GetItemCooldown(itemID)
cooldown = duration - (GetTime() - startTime)
if cooldown > 0 then
return false
else
return true
end
end
return false
end
local function getReagentCount(name)
local count = 0
for bag = 0, 4 do
for slot = 1, GetContainerNumSlots(bag) do
local item = GetContainerItemLink(bag, slot)
if item then
if item:find(name) then
local _, itemCount = GetContainerItemInfo(bag, slot)
count = count + itemCount
end
end
end
end
return count
end
local function SetupSpells()
local spells = {
Alliance = {
{ 3561, 'TP_RUNE' }, -- TP:Stormwind
{ 3562, 'TP_RUNE' }, -- TP:Ironforge
{ 3565, 'TP_RUNE' }, -- TP:Darnassus
{ 32271, 'TP_RUNE' }, -- TP:Exodar
{ 49359, 'TP_RUNE' }, -- TP:Theramore
{ 33690, 'TP_RUNE' }, -- TP:Shattrath
{ 53140, 'TP_RUNE' }, -- TP:Dalaran
{ 88342, 'TP_RUNE' }, -- TP:Tol Barad
{ 132621, 'TP_RUNE' }, -- TP:Vale of Eternal Blossoms
{ 120145, 'TP_RUNE' }, -- TP:Ancient Dalaran
{ 176248, 'TP_RUNE' }, -- TP:StormShield
{ 224869, 'TP_RUNE' }, -- TP:Dalaran - Broken Isles
{ 193759, 'TP_RUNE' }, -- TP:Hall of the Guardian
{ 281403, 'TP_RUNE' }, -- TP:Boralus
{ 10059, 'P_RUNE' }, -- P:Stormwind
{ 11416, 'P_RUNE' }, -- P:Ironforge
{ 11419, 'P_RUNE' }, -- P:Darnassus
{ 32266, 'P_RUNE' }, -- P:Exodar
{ 49360, 'P_RUNE' }, -- P:Theramore
{ 33691, 'P_RUNE' }, -- P:Shattrath
{ 53142, 'P_RUNE' }, -- P:Dalaran
{ 88345, 'P_RUNE' }, -- P:Tol Barad
{ 120146, 'P_RUNE' }, -- P:Ancient Dalaran
{ 132620, 'P_RUNE' }, -- P:Vale of Eternal Blossoms
{ 176246, 'P_RUNE' }, -- P:StormShield
{ 224871, 'P_RUNE' }, -- P:Dalaran - Broken Isles
{ 281400, 'P_RUNE' } -- P:Boralus
},
Horde = {
{ 3563, 'TP_RUNE' }, -- TP:Undercity
{ 3566, 'TP_RUNE' }, -- TP:Thunder Bluff
{ 3567, 'TP_RUNE' }, -- TP:Orgrimmar
{ 32272, 'TP_RUNE' }, -- TP:Silvermoon
{ 49358, 'TP_RUNE' }, -- TP:Stonard
{ 35715, 'TP_RUNE' }, -- TP:Shattrath
{ 53140, 'TP_RUNE' }, -- TP:Dalaran
{ 88344, 'TP_RUNE' }, -- TP:Tol Barad
{ 132627, 'TP_RUNE' }, -- TP:Vale of Eternal Blossoms
{ 120145, 'TP_RUNE' }, -- TP:Ancient Dalaran
{ 176242, 'TP_RUNE' }, -- TP:Warspear
{ 224869, 'TP_RUNE' }, -- TP:Dalaran - Broken Isles
{ 193759, 'TP_RUNE' }, -- TP:Hall of the Guardian
{ 281404, 'TP_RUNE' }, -- TP:Dazar'alor
{ 11418, 'P_RUNE' }, -- P:Undercity
{ 11420, 'P_RUNE' }, -- P:Thunder Bluff
{ 11417, 'P_RUNE' }, -- P:Orgrimmar
{ 32267, 'P_RUNE' }, -- P:Silvermoon
{ 49361, 'P_RUNE' }, -- P:Stonard
{ 35717, 'P_RUNE' }, -- P:Shattrath
{ 53142, 'P_RUNE' }, -- P:Dalaran
{ 88346, 'P_RUNE' }, -- P:Tol Barad
{ 120146, 'P_RUNE' }, -- P:Ancient Dalaran
{ 132626, 'P_RUNE' }, -- P:Vale of Eternal Blossoms
{ 176244, 'P_RUNE' }, -- P:Warspear
{ 224871, 'P_RUNE' }, -- P:Dalaran - Broken Isles
{ 281402, 'P_RUNE' } -- P:Dazar'alor
}
}
local _, class = UnitClass('player')
if class == 'MAGE' then
portals = spells[select(1, UnitFactionGroup('player'))]
elseif class == 'DEATHKNIGHT' then
portals = {
{ 50977, 'TRUE' } -- Death Gate
}
elseif class == 'DRUID' then
portals = {
{ 18960, 'TRUE' }, -- TP:Moonglade
{ 147420, 'TRUE' }, -- TP:One with Nature
{ 193753, 'TRUE' } -- TP:Dreamwalk
}
elseif class == 'SHAMAN' then
portals = {
{ 556, 'TRUE' } -- Astral Recall
}
elseif class == 'MONK' then
portals = {
{ 126892, 'TRUE' }, -- Zen Pilgrimage
{ 126895, 'TRUE' } -- Zen Pilgrimage: Return
}
else
portals = {}
end
wipe(spells)
end
local function GenerateLinks(spells)
local itemsGenerated = 0
for _, unTransSpell in ipairs(spells) do
if IsPlayerSpell(unTransSpell[1]) then
local spell, _, spellIcon = GetSpellInfo(unTransSpell[1])
local spellid = findSpell(spell)
if spellid then
methods[spell] = {
spellid = spellid,
text = spell,
spellIcon = spellIcon,
isPortal = unTransSpell[2] == 'P_RUNE',
secure = {
type = 'spell',
spell = spell
}
}
itemsGenerated = itemsGenerated + 1
end
end
end
return itemsGenerated
end
local function UpdateClassSpells()
if not portals then
SetupSpells()
end
if portals then
return GenerateLinks(portals)
end
end
local function UpdateChallengeSpells()
return GenerateLinks(challengeSpells)
end
local function UpdateIcon(icon)
obj.icon = icon
end
local function GetScrollCooldown()
local cooldown, startTime, duration
for i = 1, #scrolls do
if GetItemCount(scrolls[i]) > 0 or (PlayerHasToy(scrolls[i]) and C_ToyBox.IsToyUsable(scrolls[i])) then
startTime, duration = GetItemCooldown(scrolls[i])
cooldown = duration - (GetTime() - startTime)
if cooldown <= 0 then
return L['READY']
else
return SecondsToTime(cooldown)
end
end
end
return L['N/A']
end
local function GetWhistleCooldown()
local cooldown, startTime, duration
if GetItemCount(whistle) > 0 then
startTime, duration = GetItemCooldown(whistle)
cooldown = duration - (GetTime() - startTime)
if cooldown <= 0 then
return L['READY']
else
return SecondsToTime(cooldown)
end
end
return L['N/A']
end
local function GetItemCooldowns()
local cooldown, cooldowns, hours, mins, secs
for i = 1, #items do
if GetItemCount(items[i]) > 0 or (PlayerHasToy(items[i]) and C_ToyBox.IsToyUsable(items[i])) then
startTime, duration = GetItemCooldown(items[i])
cooldown = duration - (GetTime() - startTime)
if cooldown <= 0 then
cooldown = L['READY']
else
cooldown = SecondsToTime(cooldown)
end
if cooldowns == nil then
cooldowns = {}
end
local name = GetItemInfo(items[i]) or select(2, C_ToyBox.GetToyInfo(items[i]))
if name then
cooldowns[name] = cooldown
end
end
end
return cooldowns
end
local function ShowHearthstone()
local bindLoc = GetBindLocation()
local secure, text, icon, name
for i = 1, #scrolls do
if hasItem(scrolls[i]) then
name, _, _, _, _, _, _, _, _, icon = GetItemInfo(scrolls[i])
text = L['INN'] .. ' ' .. bindLoc
secure = {
type = 'item',
item = name
}
break
end
end
if secure ~= nil then
dewdrop:AddLine(
'textHeight', PortalsDB.fontSize,
'text', text,
'secure', secure,
'icon', tostring(icon),
'func', function() UpdateIcon(icon) end,
'closeWhenClicked', true)
dewdrop:AddLine()
end
end
local function ShowWhistle()
local secure, icon, name
if hasItem(whistle) then
name, _, _, _, _, _, _, _, _, icon = GetItemInfo(whistle)
secure = {
type = 'item',
item = name
}
end
if secure ~= nil then
dewdrop:AddLine()
dewdrop:AddLine(
'textHeight', PortalsDB.fontSize,
'text', name,
'secure', secure,
'icon', tostring(icon),
'func', function() UpdateIcon(icon) end,
'closeWhenClicked', true)
dewdrop:AddLine()
end
end
local function ShowOtherItems()
local secure, icon, quality, name
local i = 0
for i = 1, #items do
if hasItem(items[i]) then
name, _, quality, _, _, _, _, _, _, icon = GetItemInfo(items[i])
secure = {
type = 'item',
item = name
}
if secure ~= nil then
dewdrop:AddLine(
'textHeight', PortalsDB.fontSize,
'text', name,
'textR', ITEM_QUALITY_COLORS[quality].r,
'textG', ITEM_QUALITY_COLORS[quality].g,
'textB', ITEM_QUALITY_COLORS[quality].b,
'secure', secure,
'icon', tostring(icon),
'func', function() UpdateIcon(icon) end,
'closeWhenClicked', true)
end
end
end
if i > 0 then
dewdrop:AddLine()
end
end
local function ToggleMinimap()
local hide = not PortalsDB.minimap.hide
PortalsDB.minimap.hide = hide
if hide then
icon:Hide('Broker_Portals')
else
icon:Show('Broker_Portals')
end
end
local function UpdateMenu(level, value)
if level == 1 then
dewdrop:AddLine('text', 'Broker_Portals', 'isTitle', true)
methods = {}
local spells = UpdateClassSpells()
if spells > 0 then
dewdrop:AddLine()
end
local challengeSpells = UpdateChallengeSpells()
if challengeSpells > 0 then
dewdrop:AddLine()
end
local chatType = (UnitInRaid("player") and "RAID") or (GetNumGroupMembers() > 0 and "PARTY") or nil
local announce = PortalsDB.announce
for k, v in pairsByKeys(methods) do
if v.secure and GetSpellCooldown(v.text) == 0 then
dewdrop:AddLine(
'textHeight', PortalsDB.fontSize,
'text', v.text,
'secure', v.secure,
'icon', tostring(v.spellIcon),
'func', function()
UpdateIcon(v.spellIcon)
if announce and v.isPortal and chatType then
SendChatMessage(L['ANNOUNCEMENT'] .. ' ' .. v.text, chatType)
end
end,
'closeWhenClicked', true)
end
end
dewdrop:AddLine()
ShowHearthstone()
if PortalsDB.showItems then
ShowOtherItems()
ShowWhistle()
end
dewdrop:AddLine(
'textHeight', PortalsDB.fontSize,
'text', L['OPTIONS'],
'hasArrow', true,
'value', 'options')
dewdrop:AddLine(
'textHeight', PortalsDB.fontSize,
'text', CLOSE,
'tooltipTitle', CLOSE,
'tooltipText', CLOSE_DESC,
'closeWhenClicked', true)
elseif level == 2 and value == 'options' then
dewdrop:AddLine(
'textHeight', PortalsDB.fontSize,
'text', L['SHOW_ITEMS'],
'checked', PortalsDB.showItems,
'func', function() PortalsDB.showItems = not PortalsDB.showItems end,
'closeWhenClicked', true)
dewdrop:AddLine(
'textHeight', PortalsDB.fontSize,
'text', L['SHOW_ITEM_COOLDOWNS'],
'checked', PortalsDB.showItemCooldowns,
'func', function() PortalsDB.showItemCooldowns = not PortalsDB.showItemCooldowns end,
'closeWhenClicked', true)
dewdrop:AddLine(
'textHeight', PortalsDB.fontSize,
'text', L['ATT_MINIMAP'],
'checked', not PortalsDB.minimap.hide,
'func', function() ToggleMinimap() end,
'closeWhenClicked', true)
dewdrop:AddLine(
'textHeight', PortalsDB.fontSize,
'text', L['ANNOUNCE'],
'checked', PortalsDB.announce,
'func', function() PortalsDB.announce = not PortalsDB.announce end,
'closeWhenClicked', true)
dewdrop:AddLine(
'textHeight', PortalsDB.fontSize,
'text', L['DROPDOWN_FONT_SIZE'],
'hasArrow', true,
'hasEditBox', true,
'editBoxText', PortalsDB.fontSize,
'editBoxFunc', function(value)
if value ~= '' and tonumber(value) ~= nil then
PortalsDB.fontSize = tonumber(value)
else
PortalsDB.fontSize = UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT
end
end)
end
end
function frame:PLAYER_LOGIN()
-- PortalsDB.minimap is there for smooth upgrade of SVs from old version
if (not PortalsDB) or (PortalsDB.version == nil) then
PortalsDB = {}
PortalsDB.minimap = {}
PortalsDB.minimap.hide = false
PortalsDB.showItems = true
PortalsDB.showItemCooldowns = true
PortalsDB.announce = false
PortalsDB.fontSize = UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT
PortalsDB.version = 5
end
-- upgrade from versions
if PortalsDB.version == 4 then
PortalsDB.fontSize = UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT
PortalsDB.version = 5
elseif PortalsDB.version == 3 then
PortalsDB.announce = false
PortalsDB.version = 4
elseif PortalsDB.version == 2 then
PortalsDB.showItemCooldowns = true
PortalsDB.announce = false
PortalsDB.version = 4
elseif PortalsDB.version < 2 then
PortalsDB.showItems = true
PortalsDB.showItemCooldowns = true
PortalsDB.announce = false
PortalsDB.version = 4
end
if icon then
icon:Register('Broker_Portals', obj, PortalsDB.minimap)
end
self:UnregisterEvent('PLAYER_LOGIN')
end
function frame:SKILL_LINES_CHANGED()
UpdateClassSpells()
UpdateChallengeSpells()
end
-- All credit for this func goes to Tekkub and his picoGuild!
local function GetTipAnchor(frame)
local x, y = frame:GetCenter()
if not x or not y then return 'TOPLEFT', 'BOTTOMLEFT' end
local hhalf = (x > UIParent:GetWidth() * 2 / 3) and 'RIGHT' or (x < UIParent:GetWidth() / 3) and 'LEFT' or ''
local vhalf = (y > UIParent:GetHeight() / 2) and 'TOP' or 'BOTTOM'
return vhalf .. hhalf, frame, (vhalf == 'TOP' and 'BOTTOM' or 'TOP') .. hhalf
end
function obj.OnClick(self, button)
GameTooltip:Hide()
if button == 'RightButton' then
dewdrop:Open(self, 'children', function(level, value) UpdateMenu(level, value) end)
end
end
function obj.OnLeave()
GameTooltip:Hide()
end
function obj.OnEnter(self)
GameTooltip:SetOwner(self, 'ANCHOR_NONE')
GameTooltip:SetPoint(GetTipAnchor(self))
GameTooltip:ClearLines()
GameTooltip:AddLine('Broker Portals')
GameTooltip:AddDoubleLine(L['RCLICK'], L['SEE_SPELLS'], 0.9, 0.6, 0.2, 0.2, 1, 0.2)
GameTooltip:AddLine(' ')
local scrollCooldown = GetScrollCooldown()
if scrollCooldown == L['READY'] then
GameTooltip:AddDoubleLine(L['HEARTHSTONE'] .. ': ' .. GetBindLocation(), scrollCooldown, 0.9, 0.6, 0.2, 0.2, 1, 0.2)
else
GameTooltip:AddDoubleLine(L['HEARTHSTONE'] .. ': ' .. GetBindLocation(), scrollCooldown, 0.9, 0.6, 0.2, 1, 1, 0.2)
end
if PortalsDB.showItemCooldowns then
local cooldowns = GetItemCooldowns()
if cooldowns ~= nil then
GameTooltip:AddLine(' ')
for name, cooldown in pairs(cooldowns) do
if cooldown == L['READY'] then
GameTooltip:AddDoubleLine(name, cooldown, 0.9, 0.6, 0.2, 0.2, 1, 0.2)
else
GameTooltip:AddDoubleLine(name, cooldown, 0.9, 0.6, 0.2, 1, 1, 0.2)
end
end
end
end
local whistleCooldown = GetWhistleCooldown()
if whistleCooldown == L['READY'] then
GameTooltip:AddDoubleLine(GetItemInfo(whistle), whistleCooldown, 0.9, 0.6, 0.2, 0.2, 1, 0.2)
else
GameTooltip:AddDoubleLine(GetItemInfo(whistle), whistleCooldown, 0.9, 0.6, 0.2, 1, 1, 0.2)
end
GameTooltip:Show()
end
-- slash command definition
SlashCmdList['BROKER_PORTALS'] = function() ToggleMinimap() end
SLASH_BROKER_PORTALS1 = '/portals'