-
Notifications
You must be signed in to change notification settings - Fork 4
/
summon.lua
1834 lines (1647 loc) · 63.2 KB
/
summon.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
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
local _, addonData = ...
local L = LibStub("AceLocale-3.0"):GetLocale("SteaSummon")
local g_self -- for callbacks
local summon = {
waiting = {}, -- the summon list
numwaiting = 0, -- the summon list length
hasSummoned = false, -- when true we believe you more
tainted = false, -- indicates player has cancelled something that's nothing to do with them
myLocation = "", -- the location player is
myZone = "", -- the zone player is
location = "", -- area of zone summons are going to
zone = "", -- the zone summons are going to
summoningPlayer = "", -- the player currently being summoned
shards = 0, -- the number of shards in our bag
isWarlock = false,
infoSend = false,
me = "",
dirty = true, -- waiting list changed flag, to begin we want to show load list so default dirty
postInit = false,
isCasting = false,
buffLetter = {
["Warlock"] = L["W"],
["Buffed"] = L["B"],
["Normal"] = L["N"],
["Prioritized"] = L["P"],
["Last"] = L["L"]
},
localLocks = 0,
localClickers = 0,
needBoost = false,
show = nil,
nextIdx = nil,
countSummoned = 0,
shrunk = false,
---------------------------------
init = function(self)
g_self = self
addonData.debug:registerCategory("summon.display")
addonData.debug:registerCategory("summon.waitlist.record")
addonData.debug:registerCategory("summon.tick")
addonData.debug:registerCategory("summon.misc")
addonData.debug:registerCategory("summon.spellcast")
self.isWarlock = addonData.util:playerIsWarlock()
self.me, _ = UnitName("player")
self.me = strsplit("-", self.me)
self.waiting = SteaSummonSave.waiting
self.numwaiting = #self.waiting
self.postInit = true
-- fix up for old version things (they could be lurking in alts for months)
-- and before the table gets cleared something may access the data and blow up
if self.waiting then
for _,v in pairs(self.waiting) do
-- make sure altwhispered is numeric (was a string)
if #v > 6 then -- have alts
if type(self:recAltWhispered(v) == "string") then
self:recAltWhispered(v, "x")
end
end
end
end
-- there seems to be no good event/time to check if we are in a group
-- group roster changes fail to tell us when we are NOT in a group
-- so we're gonna bodge this one, worst case is it takes a while to clear the list
C_Timer.After(10, self.postInitSetup) -- bumped to 10 seconds, after laggy server experiences, an eternity I know
end,
---------------------------------
postInitSetup = function(self)
self = addonData.summon
if not self.postInit then
return
end
self.postInit = false
local ts = GetTime()
if not IsInGroup(LE_PARTY_CATEGORY_HOME)
or SteaSummonSave.waitingKeepTime == 0
or ts - 10 - SteaSummonSave.timeStamp > SteaSummonSave.waitingKeepTime * 60 then -- -10 for the bodge factor
db("wiping wait list")
db("saved mins", (ts - 10 - SteaSummonSave.timeStamp)/60, "keep mins", SteaSummonSave.waitingKeepTime)
db("group status:", IsInGroup(LE_PARTY_CATEGORY_HOME))
self:listClear()
else
addonData.gossip:raidJoined()
end
-- good time for a version check -- this goes to guild if not in raid
addonData.gossip:SteaSummonVersion()
end,
---------------------------------
setClicks = function(self, locks, clicks)
self.localLocks = tonumber(locks)
self.localClickers = tonumber(clicks)
if SteaSummonFrame then
if IsInGroup(LE_PARTY_CATEGORY_HOME) and self.location ~= "" and self.zone ~= nil then
if self.localLocks and self.localLocks + self.localClickers > 2 then
SteaSummonFrame.status:SetTextColor(0,1,0,.5)
else
SteaSummonFrame.status:SetTextColor(.8,.8,.8,.5)
end
SteaSummonFrame.status:SetText(L["Warlocks"] .. " " .. locks .. "\n" .. L["Clickers"] .. " ".. clicks)
else
SteaSummonFrame.status:SetText("")
end
end
end,
---------------------------------
listClear = function(self)
wipe(self.waiting)
self.numwaiting = 0
self:listDirty(true)
end,
---------------------------------
listDirty = function(self, dirty)
if dirty ~= nil then
self.dirty = dirty
end
addonData.monitor:start()
return self.dirty
end,
---------------------------------
waitRecord = function(self, player, time, status, prioReason, buffs, alts, altwhispered)
local rec
assert(player)
rec = {
player,
time or 0,
status or "requested",
prioReason or "Normal",
true, -- dirty flag
buffs or {},
alts or {},
altwhispered or "x"
}
db("summon.waitlist.record","Created record {",
self:recPlayer(rec), self:recTime(rec), self:recStatus(rec), self:recPrio(rec), true,
self:recBuffs(rec), self:recAlts(rec), self:recAltWhispered(rec), "}")
return rec
end,
---------------------------------
recMarshal = function(self, rec)
return self:recPlayer(rec)
.. "+" .. self:recTime(rec)
.. "+" .. self:recStatus(rec)
.. "+" .. self:recPrio(rec)
.. "+" .. addonData.buffs:marshallBuffs(self:recBuffs(rec))
.. "+" .. self:recMarshallAlts(rec)
.. "+" .. self:recAltWhispered(rec)
end,
---------------------------------
recUnMarshal = function(self, data)
if data then
local player, time, status, prio, buffs, alts, altwhispered = strsplit("+", data)
if player and time and status and prio and buffs and alts and altwhispered then
return self:waitRecord(player, time, status, prio, addonData.buffs:unmarshallBuffs(buffs),
self:unmarshallAlts(alts), altwhispered)
else
db("summon.waitlist.record", "unmarshalled data contains nil", player, time, status, prio, buffs)
end
else
db("summon.waitlist.record", "tried to unmarshal nil")
end
end,
---------------------------------
recPlayer = function(self, rec, val)
if val then
self:listDirty(true)
db("summon.waitlist.record","setting record player value:", val)
rec[1] = val
end
return rec[1]
end,
---------------------------------
recTime = function(self, rec, val)
if val then
self:listDirty(true)
db("summon.waitlist.record","setting record time value:", val)
rec[2] = val
end
return rec[2]
end,
---------------------------------
recTimeIncr = function(self, rec)
self:listDirty(true)
rec[2] = rec[2] + 1
if rec[8] and rec[8] ~= "x" then
rec[8] = rec[8] + 1
end
db("summon.tick","setting record time value:", rec[2], rec[8]) -- too verbose for summon.waitlist.record
return rec[2]
end,
---------------------------------
recStatus = function(self, rec, val)
if val then
self:listDirty(true)
db("summon.waitlist.record","setting record status value:", val)
rec[3] = val
end
return rec[3]
end,
---------------------------------
recPrio = function(self, rec, val)
if val then
self:listDirty(true)
db("summon.waitlist.record","setting record priority reason value:", val)
rec[4] = val
end
return rec[4]
end,
---------------------------------
recNew = function(self, rec, val)
if val ~= nil then
self:listDirty(true)
db("summon.waitlist.record","setting record new value:", val)
rec[5] = val
end
return rec[5]
end,
---------------------------------
recBuffs = function(self, rec, val)
if val ~= nil then
self:listDirty(true)
db("summon.waitlist.record","setting record buffs value:", val)
rec[6] = val
end
return rec[6] or {}
end,
---------------------------------
recAlts = function(self, rec, val)
if val ~= nil then
self:listDirty(true)
db("summon.waitlist.record","setting record alts value:", val)
rec[7] = {}
rec[7] = self:recMergeAlts(rec, val) -- duplicate proof add
end
return rec[7] or {}
end,
---------------------------------
marshallAlts = function(_, alts)
local out = ""
local spacer = ""
for _,v in pairs(alts) do
if v and v ~= "" then
out = out .. spacer .. v
spacer = "&"
end
end
return out
end,
---------------------------------
recMarshallAlts = function(self, rec)
return self:marshallAlts(rec[7])
end,
---------------------------------
unmarshallAlts = function(_, marshalled)
local out = {}
local tmpOut = { strsplit("&", marshalled) }
for i,v in pairs(tmpOut) do
if v and v ~= "" then
db("summon.waitlist.record", "unmarshalling", v)
out[i] = v
end
end
return out
end,
---------------------------------
recMergeAlts = function(_, rec, alts)
db("summon.waitlist.record","merging alts:", alts)
local oldAlts = rec[7] or {}
local newAlts = {}
local altMap = {} -- for duplicates in new map
local newIdx = 1
for _,alt in pairs(alts) do
if not altMap[alt] then
local add = true
for _,oldAlt in pairs(oldAlts) do
if alt == oldAlt then
add = false
break
end
end
if add then
altMap[alt] = true
newAlts[newIdx] = alt
newIdx = newIdx + 1
end
end
end
for _,v in pairs(newAlts) do
db("summon.waitlist.record", "merging alt", v)
table.insert(oldAlts, v)
end
rec[7] = oldAlts -- in case we made it
return rec[7]
end,
---------------------------------
recAltWhispered = function(self, rec, val)
if val ~= nil then
self:listDirty(true)
db("summon.waitlist.record","setting record alt whispered:", val)
rec[8] = val
end
return rec[8]
end,
---------------------------------
recRemove = function(self, player)
local ret = false
local idx = self:findWaitingPlayerIdx(player)
if idx then
ret = self:recRemoveIdx(idx)
end
return ret
end,
---------------------------------
recRemoveIdx = function(self, idx)
local ret = false
if idx and type(idx) == "string" then
idx = tonumber(string)
end
if idx and idx <= self.numwaiting then
self:listDirty(true)
db("summon.waitlist.record", "removing", self:recPlayer(self.waiting[idx]), "from the waiting list")
table.remove(self.waiting, idx)
self.numwaiting = self.numwaiting - 1
ret = true
else
db("summon.waitlist.record","invalid index for remove", idx, "max:", self.numwaiting)
end
return ret
end,
recAdd = function(self, rec, pos)
self:listDirty(true)
if not pos or pos > self.numwaiting then
db("summon.waitlist.record","appending record to waiting list for", self:recPlayer(rec))
table.insert(self.waiting, rec)
else
db("summon.waitlist.record","adding record to waiting list index", pos,"for", self:recPlayer(rec))
table.insert(self.waiting, pos, rec)
end
self.numwaiting = self.numwaiting + 1
end,
---------------------------------
addWaiting = function(self, player, fromPlayer)
player = strsplit("-", player)
if not IsInGroup(player) then
return nil
end
if (fromPlayer) then
local isWaiting = self:findWaitingPlayer(player)
if isWaiting then
db("summon.waitlist", "Resetting status of player", player, "to requested")
self:recStatus(isWaiting, "requested")-- allow those in summon queue to reset status when things go wrong
return
end
else
if self:findWaitingPlayer(player) then
return nil
end
end
db("summon.waitlist", "Making some space for ", player)
-- priorities
local inserted = false
local buffs = addonData.buffs:report(player)
-- Prio warlock
if SteaSummonSave.warlocks and addonData.util:playerCanSummon(player)
and #buffs == 0 and self.localLocks < SteaSummonSave.maxLocks then
for k, wait in pairs(self.waiting) do
if self:recPrio(wait) ~= "Warlock" then
db("summon.waitlist", "Warlock", player, "gets prio")
self:recAdd(self:waitRecord(player, 0, "requested", "Warlock"), k)
inserted = true
break
end
end
if not inserted then
db("summon.waitlist", "Warlock", player, "gets prio")
self:recAdd(self:waitRecord(player, 0, "requested", "Warlock"))
inserted = true
end
end
-- Prio buffs
if not inserted and SteaSummonSave.buffs == true and #buffs > 0 then
for k, wait in pairs(self.waiting) do
if (self:recPrio(wait) ~= "Warlock" and self:recPrio(wait) ~= "Buffed")
or (self:recPrio(wait) == "Buffed" and #self:recBuffs(wait) < #buffs) then
self:recAdd(self:waitRecord(player, 0, "requested", "Buffed"), k)
db("summon.waitlist", "Buffed " .. player .. " gets prio")
inserted = true
break
end
end
if not inserted then
self:recAdd(self:waitRecord(player, 0, "requested", "Buffed"))
db("summon.waitlist", "Buffed " .. player .. " gets prio")
inserted = true
end
end
-- Prio list
if not inserted and addonData.settings:findPrioPlayer(player) ~= nil then
for k, wait in pairs(self.waiting) do
if not (self:recPrio(wait) == "Warlock" or self:recPrio(wait) == "Buffed"
or addonData.settings:findPrioPlayer(self:recPlayer(wait))) then
self:recAdd(self:waitRecord(player, 0, "requested", "Prioritized"), k)
db("summon.waitlist", "Priority " .. player .. " gets prio")
inserted = true
break
end
end
if not inserted then
self:recAdd(self:waitRecord(player, 0, "requested", "Prioritized"))
db("summon.waitlist", "Priority " .. player .. " gets prio")
inserted = true
end
end
-- Prio last
if not inserted and addonData.settings:findShitlistPlayer(player) ~= nil then
self:recAdd(self:waitRecord(player, 0, "requested", "Last"))
inserted = true
end
-- Prio normal
if not inserted then
local i = self.numwaiting + 1
while i > 1 and self:recPrio(self.waiting[i-1]) == "Last"
and not (self:recPrio(self.waiting[i-1]) == "Buffed"
or self:recPrio(self.waiting[i-1]) == "Warlock"
or self:recPrio(self.waiting[i-1]) == "Prioritized") do
db("summon.waitlist", self:recPlayer(self.waiting[i-1]), "on shitlist, finding a better spot")
i = i - 1
end
self:recAdd(self:waitRecord(player, 0, "requested", "Normal"), i)
end
local rec = self:findWaitingPlayer(player)
self:recBuffs(rec, buffs)
db("summon.waitlist", player .. " added to waiting list")
self:showSummons()
end,
---------------------------------
timerSecondTick = function(self)
--- update timers
-- yea this is dumb, but time doesnt really work in wow
-- so we count (rough) second ticks for how long someone has been waiting
-- and need to update each individually (a global would wrap)
for _, wait in pairs(self.waiting) do
self:recTimeIncr(wait)
end
end,
---------------------------------
tick = function(self)
--- detect arriving players
local players = {}
for _, wait in pairs(self.waiting) do
local player = self:recPlayer(wait)
if addonData.util:playerClose(player) then
db("summon.tick", player .. " detected close by")
table.insert(players, player) -- don't mess with tables while iterating on them
end
end
for _, player in pairs(players) do
local z, l = self:getCurrentLocation()
if z == self.zone and l == self.location -- at destination, anyone can report
or (self.countSummoned > 0 and self.zone == "" and self.location == "") -- no destination, anyone can report
or player == self.summoningPlayer then -- summoner can report
addonData.gossip:arrived(player, false) -- let everyone else know
end
end
--- update display
self:showSummons()
--- update our location
self:setCurrentLocation()
end,
---------------------------------
getWaiting = function(self) return self.waiting end,
---------------------------------
showSummons = function(self)
if InCombatLockdown() then
return
end
self = addonData.summon -- often we are not ourselves, be positive
if not SteaSummonFrame then
local f = CreateFrame("Frame", "SteaSummonFrame", UIParent, "AnimatedShineTemplate")
f:SetPoint("CENTER")
f:SetSize(300, 250)
f:SetScale(SteaSummonSave.windowSize)
local wpos = addonData.settings:getWindowPos()
if wpos and #wpos > 0 then
db("summon.display", wpos[1], wpos[2], wpos[3], wpos[4], wpos[5], "width:", wpos["width"], "height:", wpos["height"])
f:ClearAllPoints()
f:SetPoint(wpos[1], wpos[2], wpos[3], wpos[4], wpos[5])
f:SetSize(wpos["width"], wpos["height"])
end
f:SetBackdrop({
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
edgeFile = "Interface\\PVPFrame\\UI-Character-PVP-Highlight",
edgeSize = 16,
insets = { left = 8, right = 6, top = 8, bottom = 8 },
})
f:SetBackdropColor(.57, .47, .85, 0.5)
f:SetBackdropBorderColor(.57, .47, .85, 0.5)
--- Movable
f:SetMovable(true)
f:SetClampedToScreen(true)
f:SetScript("OnMouseDown", function(this, button)
if button == "LeftButton" then
this:StartMoving()
end
end)
local movefunc = function()
SteaSummonFrame:StopMovingOrSizing()
SteaSummonFrame:SetUserPlaced(false)
local p1, p2, p3, p4, p5 = SteaSummonFrame:GetPoint()
local pos = {p1, p2, p3, p4, p5}
pos["width"] = SteaSummonFrame:GetWidth()
pos["height"] = SteaSummonFrame:GetHeight()
addonData.settings:setWindowPos(pos)
db("summon.display", pos[1], pos[2], pos[3], pos[4], pos[5], "width:", pos["width"], "height:", pos["height"])
if pos["height"] < 65 then
SteaSummonButtonFrame:Hide()
SteaSummonScrollFrame:Hide()
else
SteaSummonScrollFrame:Show()
SteaSummonButtonFrame:Show()
end
if pos["height"] < 42 then
if SteaSummonShardIcon then SteaSummonShardIcon:Hide() end
else
if SteaSummonShardIcon then SteaSummonShardIcon:Show() end
end
if pos["height"] < 28 then
if SteaSummonToButton then SteaSummonToButton:Hide() end
else
if SteaSummonToButton then SteaSummonToButton:Show() end
end
if pos["width"] < 100 or pos["height"] < 28 then
if SteaSummonContextMenuButton then SteaSummonContextMenuButton:Hide() end
else
if SteaSummonContextMenuButton then SteaSummonContextMenuButton:Show() end
end
if pos["width"] < 140 then
SteaSummonFrame.location:Hide()
SteaSummonFrame.destination:Hide()
else
SteaSummonFrame.location:Show()
SteaSummonFrame.destination:Show()
end
end
f:SetScript("OnMouseUp", movefunc)
--- SteaSummonScrollFrame
local sf = CreateFrame("ScrollFrame", "SteaSummonScrollFrame", SteaSummonFrame, "UIPanelScrollFrameTemplate")
sf:SetPoint("LEFT", 8, 0)
sf:SetPoint("RIGHT", -40, 0)
sf:SetPoint("TOP", 0, -84)
sf:SetPoint("BOTTOM", 0, 30)
sf:SetScale(0.5)
addonData.buttonFrame = CreateFrame("Frame", "SteaSummonButtonFrame", SteaSummonFrame)
local x, y = sf:GetSize()
addonData.buttonFrame:SetSize(x-10, y)
addonData.buttonFrame:SetScale(SteaSummonSave.listSize)
sf:SetScrollChild(addonData.buttonFrame)
--- Table of summon info
addonData.buttons = {}
for i=1, 39 do
self:createButton(i)
end
--- Setup Next button
addonData.buttons[38].Button:SetPoint("TOPLEFT","SteaSummonFrame","TOPLEFT", -10, 10)
addonData.buttons[38].Button:SetText(L["Next"])
--- Setup Summon Me button
addonData.buttons[39].Button:SetPoint("TOPLEFT","SteaSummonFrame","TOPLEFT", -10, 10)
addonData.buttons[39].Button:SetScript("OnClick", function()
if self:findWaitingPlayer(self.me) then
self:resetMe()
else
self:addMe()
end
end)
addonData.buttons[39].Button:SetScript("OnEnter", function(this)
GameTooltip:SetOwner(this, "ANCHOR_RIGHT")
GameTooltip:AddLine(L["Request/Reset Summon"])
GameTooltip:Show()
end)
addonData.buttons[39].Button:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
--- Resizable
f:SetResizable(true)
f:SetMinResize(80, 25)
f:SetClampedToScreen(true)
local rb = CreateFrame("Button", "SteaSummonResizeButton", SteaSummonFrame)
rb:SetPoint("BOTTOMRIGHT", -6, 7)
rb:SetSize(8, 8)
rb:SetNormalTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
rb:SetHighlightTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
rb:SetPushedTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
rb:SetScript("OnMouseDown", function(this, button)
if button == "LeftButton" then
f:StartSizing("BOTTOMRIGHT")
this:GetHighlightTexture():Hide() -- more noticeable
end
end)
rb:SetScript("OnMouseUp", movefunc)
if addonData.util:playerCanSummon() then
local summonTo = function()
if not self.infoSend then
SteaSummonToButton:SetNormalTexture("Interface\\Buttons\\UI-GuildButton-MOTD-Up")
addonData.gossip:destination(self.myZone, self.myLocation)
else
SteaSummonToButton:SetNormalTexture("Interface\\Buttons\\UI-GuildButton-MOTD-Disabled")
addonData.gossip:destination("", "")
end
self.infoSend = not self.infoSend
addonData.gossip:nag(self.infoSend)
end
--- summon to button
local place = CreateFrame("Button", "SteaSummonToButton", SteaSummonFrame, "TruncatedButtonTemplate")
place:SetNormalTexture("Interface\\Buttons\\UI-GuildButton-MOTD-Disabled")
place:SetHighlightTexture("Interface\\Buttons\\UI-GuildButton-MOTD-Disabled")
place:SetPushedTexture("Interface\\Buttons\\UI-GuildButton-MOTD-Disabled")
place:SetPoint("TOPLEFT","SteaSummonFrame", "TOPLEFT", 42, -8)
place:SetSize(16,16)
place:RegisterForClicks()
place:SetScript("OnMouseUp", summonTo)
place:SetScript("OnClick", summonTo)
place:SetScript("OnEnter", function(this)
GameTooltip:SetOwner(this, "ANCHOR_RIGHT")
GameTooltip:AddLine(L["Toggle Raid Information"])
GameTooltip:Show()
end)
place:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
place:Hide()
end
--- invisible set/unset destination button button
if addonData.util.playerCanSummon() then
local function invisDest()
if self.zone ~= "" then
addonData.gossip:destination("", "")
else
addonData.gossip:destination(self.myZone, self.myLocation)
end
end
local invdest = CreateFrame("Button", "SteaSummonInvisibleSetDestinationButton", SteaSummonFrame, "UIPanelButtonTemplate")
invdest:SetPoint("TOPLEFT","SteaSummonFrame", "TOPLEFT", 75, -8)
invdest:SetPoint("RIGHT","SteaSummonFrame", "RIGHT", 24)
invdest:SetAlpha(0)
invdest:SetFrameLevel(2)
invdest:RegisterForClicks()
invdest:SetScript("OnMouseUp", invisDest)
invdest:SetScript("OnClick", invisDest)
invdest:SetScript("OnEnter", function(this)
GameTooltip:SetOwner(this, "ANCHOR_RIGHT")
GameTooltip:AddLine(L["Set/Unset Destination"])
GameTooltip:Show()
end)
invdest:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
end
--- shard count icon
if self.isWarlock then
f.shards = CreateFrame("Frame", "SteaSummonShardIcon", SteaSummonFrame)
f.shards:SetBackdrop({
bgFile = "Interface\\ICONS\\INV_Misc_Gem_Amethyst_02",
})
f.shards:SetPoint("TOPLEFT","SteaSummonFrame", "TOPLEFT", 45, -24)
f.shards:SetSize(12,12)
f.shards.count = f.shards:CreateFontString(nil,"ARTWORK", nil, 7)
f.shards.count:SetFont("Fonts\\ARIALN.ttf", 12, "BOLD")
f.shards.count:SetPoint("CENTER","SteaSummonShardIcon", "CENTER", 5, -5)
f.shards.count:SetText("0")
f.shards.count:SetTextColor(1,1,1,1)
f.shards.count:Show()
self.shards = self:shardCount()
end
--- context menu
f.context = CreateFrame("Button", "SteaSummonContextMenuButton",
SteaSummonFrame, "UIPanelButtonTemplate")
f.context:SetWidth(10)
f.context:SetHeight(10)
f.context:SetText(">")
f.context:SetPoint("TOPLEFT","SteaSummonFrame","TOPRIGHT", -17, -7)
f.context:SetScript("OnMouseUp", function() addonData.appbutton:menu() end)
f.context:SetFrameLevel(3)
f.context:SetAlpha(0.5)
--- raid lead button
local function relinquishLead()
addonData.raid:relinquish()
end
local lead = CreateFrame("Button", "SteaSummonRelinquishRaidLeadButton", SteaSummonFrame, "TruncatedButtonTemplate")
lead:SetNormalTexture("Interface\\GROUPFRAME\\UI-Group-LeaderIcon")
lead:SetPoint("TOPLEFT","SteaSummonFrame", "TOPLEFT", 60, 4)
lead:SetSize(16,16)
lead:RegisterForClicks()
lead:SetScript("OnMouseUp", relinquishLead)
lead:SetScript("OnClick", relinquishLead)
lead:SetFrameLevel(102)
lead:SetScript("OnEnter", function(this)
GameTooltip:SetOwner(this, "ANCHOR_RIGHT")
GameTooltip:AddLine(L["Relinquish Raid Lead"])
GameTooltip:Show()
end)
lead:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
if not UnitIsGroupLeader("player") then
lead:Hide()
end
--- Text items
f.location = f:CreateFontString(nil,"ARTWORK")
f.location:SetFont("Fonts\\ARIALN.ttf", 8, "OUTLINE")
f.location:SetPoint("TOPLEFT","SteaSummonFrame", "TOPLEFT", 70, -8)
f.location:SetPoint("RIGHT", -20, 0)
f.location:SetJustifyH("RIGHT")
f.location:SetJustifyV("TOP")
f.location:SetAlpha(.5)
f.location:SetText("")
f.destination = f:CreateFontString(nil,"ARTWORK")
f.destination:SetFont("Fonts\\ARIALN.ttf", 8, "OUTLINE")
f.destination:SetPoint("TOP", f.location, "BOTTOM", 0, 0)
f.destination:SetPoint("LEFT", f.location)
f.destination:SetPoint("RIGHT", -20, 0)
f.destination:SetJustifyH("RIGHT")
f.destination:SetJustifyV("TOP")
f.destination:SetAlpha(.5)
f.destination:SetText("")
f.status = f:CreateFontString(nil,"ARTWORK")
f.status:SetFont("Fonts\\ARIALN.ttf", 8, "OUTLINE")
f.status:SetPoint("TOPRIGHT","SteaSummonFrame", "TOPRIGHT", -10, 10)
f.status:SetAlpha(.5)
f.status:SetText("")
movefunc()
db("summon.display","Screen Size (w/h):", GetScreenWidth(), GetScreenHeight() )
end
------------------------------------------------------------
--- Start of on tick visual updates
------------------------------------------------------------
--- update buttons
local next = false
self.nextIdx = nil
local listActive = false
for i=1, 37 do
local player
local summonClick
local cancelClick
local r,g,b,_ = 0.5, 0.5, 0.5
if self.waiting[i] ~= nil then
player = self:recPlayer(self.waiting[i])
self:enableButton(i, true, player)
addonData.buttons[i].Button:SetText(player)
addonData.buttons[i].Priority["FS"]:SetText(self.buffLetter[self:recPrio(self.waiting[i])])
-- alts tooltip
if #self:recAlts(self.waiting[i]) > 0 then
addonData.buttons[i].Status:SetScript("OnEnter", function(this)
GameTooltip:SetOwner(this, "ANCHOR_RIGHT")
GameTooltip:AddLine(L["Alt Support"])
for _,v in pairs(self:recAlts(self.waiting[i])) do
GameTooltip:AddLine(v)
end
GameTooltip:Show()
end)
addonData.buttons[i].Status:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
else
addonData.buttons[i].Status:SetScript("OnEnter", nil)
addonData.buttons[i].Status:SetScript("OnLeave", nil)
end
if self:offline(player) or self:dead(player) then
addonData.buttons[i].Button:SetEnabled(false)
if self:offline(player) and #self:recAlts(self.waiting[i]) > 0 then
addonData.buttons[i].Status["FS"]:SetTextColor(0,0.5,0, 1)
else
addonData.buttons[i].Status["FS"]:SetTextColor(0.5,0.5,0.5, 1)
end
if self:recAltWhispered(self.waiting[i]) ~= "x" then
addonData.buttons[i].Status["FS"]:SetTextColor(0.5,1,0.5, 1)
end
addonData.buttons[i].Button:SetAttribute("macrotext", "")
addonData.buttons[i].Button:SetScript("OnMouseUp", nil)
elseif self:listDirty() then
local _, class = UnitClass(player)
r,g,b,_ = GetClassColor(class)
addonData.buttons[i].Button:SetEnabled(true)
addonData.buttons[i].Status["FS"]:SetTextColor(r,g,b, 1)
self:SetMacro(i, player)
-- check the status of summons - apparently this api doesn't exist in Classic really but is doc'd
-- and used in the classic UI code download...
-- I may have misread the error during raid, just adding extra caution detects
if player and C_IncomingSummon and C_IncomingSummon.HasIncomingSummon then -- paranoia
if C_IncomingSummon.HasIncomingSummon(player) then
local status = self:recStatus(self.waiting[i])
if status ~= "summoned" and status ~= "accepted" and status ~= "declined" then
self:recStatus(self.waiting[i], "summoned")
end
if status ~= "accepted" and status ~= "declined" then
if C_IncomingSummon.IncomingSummonStatus then -- paranoia
local summonStatus = C_IncomingSummon.IncomingSummonStatus(player)
if summonStatus == 2 then
self:recStatus(self.waiting[i], "accepted")
elseif summonStatus == 3 then
self:recStatus(self.waiting[i], "declined")
end
end
end
end
end
local z,l = self:getCurrentLocation()
if (addonData.util:playerCanSummon()) then
summonClick = function(_, button)
if button == nil or button == "LeftButton" then
if not addonData.summon.isCasting then
if UnitPower("player") >= 300 then
db("summon.display","summoning ", player)
addonData.gossip:status(player, "pending")
addonData.chat:raid(SteaSummonSave.raidchat, player)
addonData.chat:say(SteaSummonSave.saychat, player)
addonData.chat:whisper(SteaSummonSave.whisperchat, player)
self.summoningPlayer = player
addonData.gossip:destination(z, l)
self.hasSummoned = true
end
else
addonData.chat:say(SteaSummonSave.clicknag, player)
end
end
end
addonData.buttons[i].Button:SetScript("OnMouseUp", summonClick)
end
end
else
self:enableButton(i, false)
end
if self:listDirty() then
--- flare size
addonData.buttons[i].flare:SetBackdrop( {
bgFile = "Interface\\TradeFrame\\UI-TradeFrame-Highlight",
tile = true, tileSize = SteaSummonButtonFrame:GetWidth(),
edgeSize = 15, insets = { left = 1, right = 1, top = 1, bottom = 1 }
});
--- Cancel Button
cancelClick = function(_, button, worked)
if button == "LeftButton" and worked then
addonData.gossip:arrived(player, true)
db("summon.display","cancelling", player)
end
end
addonData.buttons[i].Cancel:SetScript("OnMouseUp", cancelClick)
if self.waiting[i] then
--- Next Button
if self:recStatus(self.waiting[i]) == "requested" then
if not next and (addonData.util:playerCanSummon()) then
next = true
self.nextIdx = i
self:SetMacro(38, player)
addonData.buttons[38].Button:SetScript("OnMouseUp", summonClick)
addonData.buttons[38].Button:Show()
end
listActive = true
elseif next and self.isCasting then
addonData.buttons[38].Button:Show()
local nextplayer = self:recPlayer(self.waiting[self.nextIdx])
self:SetMacro(38, nextplayer)
end
--- Time
local noSecs = false
if tonumber(self:recTime(self.waiting[i])) > 59 then
noSecs = true
end
addonData.buttons[i].Time["FS"]:SetText(string.format(SecondsToTime(self:recTime(self.waiting[i]), noSecs)))
local strwd = addonData.buttons[i].Time["FS"]:GetStringWidth()
if strwd < 70 then
addonData.buttons[i].Time["FS"]:SetWidth(80)
else
addonData.buttons[i].Time:SetWidth(strwd+20)
addonData.buttons[i].Time["FS"]:SetWidth(strwd+10)
end
--- Status
addonData.buttons[i].Status["FS"]:SetText(L[self:recStatus(self.waiting[i])])
--- New flare
if self:recNew(self.waiting[i]) then
addonData.buttons[i].flare.ag:Play()
self:recNew(self.waiting[i],false)
end
end
self.needBoost = not listActive
if not next then
if not self.isCasting then
-- all summons left are pending, disable the next button
addonData.buttons[38].Button:Hide()
end
end