-
Notifications
You must be signed in to change notification settings - Fork 9
/
Templates.lua
2472 lines (2002 loc) · 73 KB
/
Templates.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 _, addon = ...
local L = addon.Locales
local Database = addon.Database;
local Talents = addon.Talents;
local Tradeskills = addon.Tradeskills;
local Comms = addon.Comms;
--- basic button mixin
GuildbookButtonMixin = {}
function GuildbookButtonMixin:OnLoad()
--self.anchor = AnchorUtil.CreateAnchor(self:GetPoint());
--self.point, self.relativeTo, self.relativePoint, self.xOfs, self.yOfs = self:GetPoint()
end
function GuildbookButtonMixin:OnShow()
--self.anchor:SetPoint(self);
-- if self.point and self.relativeTo and self.relativePoint and self.xOfs and self.yOfs then
-- self:SetPoint(self.point, self.relativeTo, self.relativePoint, self.xOfs, self.yOfs)
-- end
end
function GuildbookButtonMixin:OnMouseDown()
if self.disabled then
return;
end
--self:AdjustPointsOffset(-1,-1)
end
function GuildbookButtonMixin:OnMouseUp()
if self.disabled then
return;
end
--self:AdjustPointsOffset(1,1)
if self.func then
--C_Timer.After(0, self.func)
self.func(self)
end
end
function GuildbookButtonMixin:OnEnter()
if self.tooltipText and L[self.tooltipText] then
GameTooltip:SetOwner(self, 'ANCHOR_TOP')
GameTooltip:AddLine("|cffffffff"..L[self.tooltipText])
GameTooltip:Show()
elseif self.tooltipText and not L[self.tooltipText] then
GameTooltip:SetOwner(self, 'ANCHOR_TOP')
GameTooltip:AddLine(self.tooltipText)
GameTooltip:Show()
elseif self.link then
GameTooltip:SetOwner(self, 'ANCHOR_TOP')
GameTooltip:SetHyperlink(self.link)
GameTooltip:Show()
else
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
end
end
function GuildbookButtonMixin:OnLeave()
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
end
--- basic button with an icon and text area
GuildbookListviewItemMixin = {}
function GuildbookListviewItemMixin:OnLoad()
-- local _, size, flags = self.Text:GetFont()
-- self.Text:SetFont([[Interface\Addons\Guildbook\Media\Fonts\Acme-Regular.ttf]], size+4, flags)
end
function GuildbookListviewItemMixin:ResetDataBinding()
end
function GuildbookListviewItemMixin:SetDataBinding(info, height)
self:SetHeight(height)
self.icon:SetSize(height-2, height-2)
if info.atlas then
self.icon:SetAtlas(info.atlas)
elseif info.icon then
self.icon:SetTexture(info.icon)
end
self.text:SetText(info.label)
if info.showMask then
self.mask:Show()
-- local x, y = self.icon:GetSize()
-- self.icon:SetSize(x + 2, y + 2)
end
if self.selected then
if info.showSelected then
self.selected:Show()
else
self.selected:Hide()
end
end
self:SetScript("OnMouseDown", function()
self:AdjustPointsOffset(-1,-1)
if info.func then
info.func()
end
end)
end
function GuildbookListviewItemMixin:OnMouseUp()
self:AdjustPointsOffset(1,1)
end
GuildbookSearchListviewItemMixin = {}
function GuildbookSearchListviewItemMixin:OnLoad()
end
function GuildbookSearchListviewItemMixin:ResetDataBinding()
end
function GuildbookSearchListviewItemMixin:UpdateInfo(info)
end
function GuildbookSearchListviewItemMixin:SetDataBinding(binding)
-- self.icon:SetAtlas(info.atlas)
-- self.text:SetText(Ambiguate(info.label, "short"))
-- if info.showMask then
-- self.mask:Show()
-- local x, y = self.icon:GetSize()
-- self.icon:SetSize(x + 2, y + 2)
-- end
if binding.type == "tradeskillItem" then
self.text:SetText(binding.data.itemLink)
elseif binding.type == "character" then
self.text:SetText(binding.data.data.name)
elseif binding.type == "bankItem" then
self.text:SetText(binding.data:GetItemLink())
elseif binding.type == "inventory" then
self.text:SetText(binding.data:GetItemLink())
end
self:SetScript("OnMouseDown", function()
end)
end
GuildbookChatCharacterListviewItemMixin = {
contextMenu = {},
}
function GuildbookChatCharacterListviewItemMixin:OnLoad()
addon:RegisterCallback("Chat_OnMessageReceived", self.UpdateInfo, self)
self.delete:SetScript("OnMouseDown", function()
if self.characterName then
addon:TriggerEvent("Chat_OnHistoryDeleted", self.characterName)
end
end)
end
function GuildbookChatCharacterListviewItemMixin:ResetDataBinding()
self.info:SetText("")
self.characterName = ""
end
function GuildbookChatCharacterListviewItemMixin:UpdateInfo(msg)
--the chat view will run its update script which causes the listview to be repopulated making the self.characterName field == ""
--wait to check the values
C_Timer.After(0.5, function()
if (msg.sender == self.characterName) and (msg.channel == "whisper") then
self.info:SetText("new message")
end
end)
end
function GuildbookChatCharacterListviewItemMixin:SetDataBinding(info, height)
if info.label == "Guild" then
self.delete:Hide()
end
self.characterName = info.characterName
self.icon:SetAtlas(info.atlas)
self.text:SetText(Ambiguate(info.label, "short"))
self.icon:SetSize(height-2, height-2)
if info.showMask then
self.mask:Show()
end
self.contextMenu = {
{
text = self.characterName,
isTitle = true,
notCheckable = true,
},
}
table.insert(self.contextMenu, addon.contextMenuSeparator)
table.insert(self.contextMenu, {
text = "Invite",
notCheckable = true,
func = function()
InviteUnit(info.characterName)
print(info.characterName)
end,
})
self:SetScript("OnMouseDown", function(_, button)
if button == "RightButton" then
EasyMenu(self.contextMenu, addon.contextMenu, "cursor", 0, 0, "MENU", 0.2)
else
self:AdjustPointsOffset(-1,-1)
if info.func then
info.func()
self.info:SetText("")
end
end
end)
end
function GuildbookChatCharacterListviewItemMixin:OnMouseUp()
self:AdjustPointsOffset(1,1)
end
GuildbookGuildbankCharacterListviewItemMixin = {}
function GuildbookGuildbankCharacterListviewItemMixin:OnLoad()
addon:RegisterCallback("Guildbank_StatusInfo", self.UpdateInfo, self)
end
function GuildbookGuildbankCharacterListviewItemMixin:ResetDataBinding()
self.info:SetText("")
self.characterName = ""
end
function GuildbookGuildbankCharacterListviewItemMixin:UpdateInfo(info)
if info.characterName == self.characterName then
self.info:SetText(info.status)
end
end
function GuildbookGuildbankCharacterListviewItemMixin:SetDataBinding(binding, height)
self.characterName = binding.label
self.icon:SetAtlas(binding.atlas)
self.text:SetText(Ambiguate(binding.label, "short"))
self.icon:SetSize(height-2, height-2)
if binding.showMask then
self.mask:Show()
end
if binding.status then
self.info:SetText(binding.status)
end
self:SetScript("OnMouseDown", function()
self:AdjustPointsOffset(-1,-1)
if binding.func then
binding.func()
end
end)
end
function GuildbookGuildbankCharacterListviewItemMixin:OnMouseUp()
self:AdjustPointsOffset(1,1)
end
GuildbookItemIconFrameMixin = {}
function GuildbookItemIconFrameMixin:OnEnter()
if self.link then
GameTooltip:SetOwner(self, 'ANCHOR_LEFT')
GameTooltip:SetHyperlink(self.link)
GameTooltip:Show()
else
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
end
end
function GuildbookItemIconFrameMixin:OnLeave()
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
end
function GuildbookItemIconFrameMixin:OnMouseDown()
if self.link and IsShiftKeyDown() then
HandleModifiedItemClick(self.link)
end
end
function GuildbookItemIconFrameMixin:SetItem(itemID, count)
local item = Item:CreateFromItemID(itemID)
if item and item:GetItemID() and not item:IsItemEmpty() then
item:ContinueOnItemLoad(function()
self.link = item:GetItemLink()
self.icon:SetTexture(item:GetItemIcon())
end)
end
self.count:SetText(count)
end
--[[
hijacked this template to use in the list gridview
the gridview uses SetDataBinding when items are :Insert'd
]]
function GuildbookItemIconFrameMixin:SetDataBinding(itemID, count)
local item = Item:CreateFromItemID(itemID)
self.itemID = itemID
if item and item:GetItemID() and not item:IsItemEmpty() then
item:ContinueOnItemLoad(function()
self.link = item:GetItemLink()
self.icon:SetTexture(item:GetItemIcon())
local itemCount = GetItemCount(itemID)
if itemCount > 0 then
self.blur:Show()
self.checkmark:Show()
else
self.checkmark:Hide()
self.blur:Hide()
end
end)
end
self:SetScript("OnMouseDown", function(f, button)
if button == "RightButton" then
addon:TriggerEvent("Database_OnItemListItemRemoved", self)
end
end)
end
function GuildbookItemIconFrameMixin:ResetDataBinding()
self.link = nil
self.icon:SetTexture(nil)
self.count:SetText("")
self.itemID = nil
self.checkmark:Hide()
self.blur:Hide()
end
GuildbookSearchResultMixin = {}
function GuildbookSearchResultMixin:OnMouseDown()
if self.func then
C_Timer.After(0, self.func)
end
end
function GuildbookSearchResultMixin:OnEnter()
if self.link and self.link:find("|Hitem") then
GameTooltip:SetOwner(self, 'ANCHOR_LEFT')
GameTooltip:SetHyperlink(self.link)
GameTooltip:Show()
else
GameTooltip:SetOwner(self, 'ANCHOR_LEFT')
GameTooltip:AddLine(self.link)
GameTooltip:Show()
end
end
function GuildbookSearchResultMixin:OnLeave()
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
end
function GuildbookSearchResultMixin:ClearRow()
self.icon:SetTexture(nil)
self.text:SetText(nil)
self.info:SetText(nil)
self.link = nil;
self.func = nil;
end
function GuildbookSearchResultMixin:SetResult(info)
self.text:SetText("")
self.info:SetText("")
self.link = nil
self.func = nil
if not info then
return;
end
if info.iconType == "fileID" then
self.icon:SetTexture(info.icon)
else
self.icon:SetAtlas(info.icon)
end
self.text:SetText(info.title)
self.info:SetText(info.info)
self.link = info.title;
self.func = info.func;
end
--- custom dropdown widget supporting a single menu layer
GuildbookDropDownFrameMixin = {}
local DROPDOWN_CLOSE_DELAY = 2.0
-- this is the dropdown button mixin, all that needs to happen is set the text and call any func if passed
GuildbookDropDownFlyoutButtonMixin = {}
function GuildbookDropDownFlyoutButtonMixin:OnEnter()
end
function GuildbookDropDownFlyoutButtonMixin:OnLeave()
end
function GuildbookDropDownFlyoutButtonMixin:SetText(text)
self.Text:SetText(text)
end
function GuildbookDropDownFlyoutButtonMixin:GetText(text)
return self.Text:GetText()
end
function GuildbookDropDownFlyoutButtonMixin:OnMouseDown()
local text = self.Text:GetText()
if self.func then
self:func()
self:GetParent():GetParent().Text:SetTextColor(1,1,1,1)
self:GetParent():GetParent().Text:SetText(text)
end
if self:GetParent().delay then
self:GetParent().delay:Cancel()
end
self:GetParent():Hide()
end
-- if we need to get the flyout although its a child so can be accessed via dropdown.Flyout
GuildbookDropdownMixin = {}
function GuildbookDropdownMixin:GetFlyout()
return self.Flyout
end
function GuildbookDropdownMixin:OnLoad()
self:SetSize(self:GetWidth(), self:GetHeight())
if self.Background then
self.Background:SetSize(self:GetWidth(), self:GetHeight())
end
self.Button:SetHeight(self:GetHeight())
if not addon.dropdownWidgets then
addon.dropdownWidgets = {}
end
table.insert(addon.dropdownWidgets, self)
end
function GuildbookDropdownMixin:OnShow()
--local width = self:GetWidth()
end
GuildbookDropdownButtonMixin = {}
function GuildbookDropdownButtonMixin:OnEnter()
self.ButtonHighlight:Show()
end
function GuildbookDropdownButtonMixin:OnLeave()
self.ButtonHighlight:Hide()
end
function GuildbookDropdownButtonMixin:OnMouseDown()
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON);
self.ButtonUp:Hide()
self.ButtonDown:Show()
if addon.dropdownWidgets and (#addon.dropdownWidgets > 0) then -- quick fix, need to make sure all dropdowns/flyouts are in table
for k, dd in ipairs(addon.dropdownWidgets) do
dd.Flyout:Hide()
end
end
local flyout = self:GetParent().Flyout
if flyout:IsVisible() then
flyout:Hide()
else
flyout:Show()
end
end
function GuildbookDropdownButtonMixin:OnMouseUp()
self.ButtonDown:Hide()
self.ButtonUp:Show()
end
GuildbookDropdownFlyoutMixin = {}
function GuildbookDropdownFlyoutMixin:OnLoad()
if not addon.dropdownFlyouts then
addon.dropdownFlyouts = {}
end
table.insert(addon.dropdownFlyouts, self)
end
function GuildbookDropdownFlyoutMixin:OnLeave()
self.delay = C_Timer.NewTicker(DROPDOWN_CLOSE_DELAY, function()
if not self:IsMouseOver() then
self:Hide()
end
end)
end
function GuildbookDropdownFlyoutMixin:OnShow()
for k, flyout in ipairs(addon.dropdownFlyouts) do
flyout:Hide()
end
self:Show()
self:SetFrameStrata("DIALOG")
if self.delay then
self.delay:Cancel()
end
self.delay = C_Timer.NewTicker(self.delayTimer or DROPDOWN_CLOSE_DELAY, function()
if not self:IsMouseOver() then
self:Hide()
end
end)
-- the .menu needs to a table that mimics the blizz dropdown
-- t = {
-- text = buttonText,
-- func = functionToRun,
-- }
if self:GetParent().menu then
if not self.buttons then
self.buttons = {}
end
for i = 1, #self.buttons do
self.buttons[i]:SetText("")
self.buttons[i].func = nil
self.buttons[i]:Hide()
end
for buttonIndex, info in ipairs(self:GetParent().menu) do
if not self.buttons[buttonIndex] then
self.buttons[buttonIndex] = CreateFrame("FRAME", nil, self, "GuildbookDropDownButton")
self.buttons[buttonIndex]:SetPoint("TOP", 0, (buttonIndex * -22) + 22)
end
self.buttons[buttonIndex]:SetText(info.text)
while self.buttons[buttonIndex].Text:IsTruncated() do
self:SetWidth(self:GetWidth() + 2)
end
--self.buttons[buttonIndex].arg1 = info.arg1
self.buttons[buttonIndex].func = info.func
self.buttons[buttonIndex]:Show()
self:SetHeight(buttonIndex * 22)
buttonIndex = buttonIndex + 1
end
for i = 1, #self.buttons do
self.buttons[i]:SetWidth(self:GetWidth() - 2)
end
end
end
GuildbookCircleIconMixin = {}
function GuildbookCircleIconMixin:OnLoad()
end
function GuildbookCircleIconMixin:SetDataBinding()
end
--make this % based to be reusable
function GuildbookCircleIconMixin:OnEnter()
self.selected:SetSize(120,120)
self.border:SetSize(120,120)
self.icon:SetSize(72,72)
self.mask:SetSize(60,60)
end
function GuildbookCircleIconMixin:OnLeave()
self.selected:SetSize(100,100)
self.border:SetSize(100,100)
self.icon:SetSize(60,60)
self.mask:SetSize(50,50)
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
end
GuildbookProfileSummaryRowAvatarTemplateMixin = {}
function GuildbookProfileSummaryRowAvatarTemplateMixin:OnLoad()
addon:RegisterCallback("Character_OnDataChanged", self.Character_OnDataChanged, self)
end
function GuildbookProfileSummaryRowAvatarTemplateMixin:Character_OnDataChanged(character)
if self.character and (self.character.data.name == character.data.name) then
self.avatar:SetAtlas(self.character:GetProfileAvatar())
end
end
function GuildbookProfileSummaryRowAvatarTemplateMixin:SetCharacter(character)
self.character = character;
self.avatar:SetAtlas(self.character:GetProfileAvatar())
self.name:SetText("|cffffffff"..Ambiguate(self.character.data.name, "short"))
local _, class = GetClassInfo(self.character.data.class)
local colour = RAID_CLASS_COLORS[class]
self.border:SetVertexColor(colour:GetRGB())
end
function GuildbookProfileSummaryRowAvatarTemplateMixin:OnEnter()
if self:IsVisible() then
self.whirl:Show()
self.anim:Play()
else
self.whirl:Hide()
self.anim:Stop()
end
if self.showTooltip then
end
end
function GuildbookProfileSummaryRowAvatarTemplateMixin:OnLeave()
self.anim:Stop()
end
function GuildbookProfileSummaryRowAvatarTemplateMixin:OnMouseUp()
if self.character then
addon:TriggerEvent("Character_OnProfileSelected", self.character)
end
end
GuildbookRecipeListviewItemMixin = {}
function GuildbookRecipeListviewItemMixin:OnLoad()
for k = 1, 8 do
self.reagentIcons[k]:Raise()
end
addon:RegisterCallback("UI_OnSizeChanged", self.UpdateLayout, self)
addon:RegisterCallback("Database_OnConfigChanged", self.Database_OnConfigChanged, self)
end
function GuildbookRecipeListviewItemMixin:UpdateLayout()
local reagentWidth = self:GetWidth() - 200;
if reagentWidth < 169 then
for k, v in ipairs(self.reagentIcons) do
v:Hide()
end
else
for k, v in ipairs(self.reagentIcons) do
v:Show()
end
end
end
function GuildbookRecipeListviewItemMixin:Database_OnConfigChanged()
if self.item and not self.item:IsItemEmpty() then
if Database:GetConfig("tradeskillsRecipesListviewShowItemID") then
self.label:SetText(self.item:GetItemID().." "..self.item:GetItemLink())
else
self.label:SetText(self.item:GetItemLink())
end
self.anim:Play()
end
end
function GuildbookRecipeListviewItemMixin:SetDataBinding(binding, height)
self.icon:SetWidth(height - 2)
self.icon:SetTexture(binding.icon)
for k, v in ipairs(self.reagentIcons) do
v:Hide()
end
self.item = nil;
if binding.tradeskillID == 333 then
self.spell = Spell:CreateFromSpellID(binding.spellID)
if not self.spell:IsSpellEmpty() then
self.spell:ContinueOnSpellLoad(function()
self.label:SetText(self.spell:GetSpellName())
self.anim:Play()
self:SetScript("OnEnter", function()
if self.spell then
GameTooltip:SetOwner(self, "ANCHOR_LEFT")
GameTooltip:SetSpellByID(self.spell:GetSpellID())
GameTooltip:Show()
end
end)
end)
end
else
self.item = Item:CreateFromItemID(binding.itemID)
if not self.item:IsItemEmpty() then
self.item:ContinueOnItemLoad(function()
if Database:GetConfig("tradeskillsRecipesListviewShowItemID") then
self.label:SetText(binding.itemID.." "..self.item:GetItemLink())
else
self.label:SetText(self.item:GetItemLink())
end
self.anim:Play()
self:SetScript("OnEnter", function()
if self.item then
GameTooltip:SetOwner(self, "ANCHOR_LEFT")
GameTooltip:SetHyperlink(self.item:GetItemLink())
GameTooltip:Show()
end
end)
end)
end
end
local i = 1;
local reagents = {}
for k, v in pairs(binding.reagents) do
table.insert(reagents, {
itemID = k,
count = v
})
end
table.sort(reagents, function(a, b)
return a.count > b.count;
end)
for k, v in ipairs(reagents) do
self.reagentIcons[k]:SetItem(v.itemID, v.count)
self.reagentIcons[k]:Show()
end
self:SetScript("OnLeave", function()
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
end)
self:SetScript("OnMouseDown", function()
if IsLeftAltKeyDown() then
if AuctionFrameBrowse and AuctionFrameBrowse:IsVisible() then
BrowseName:SetText(string.format('"%s"', self.item:GetItemName()))
BrowseSearchButton:Click()
end
else
if binding.func then
binding.func()
end
end
if self.item then
if IsControlKeyDown() then
DressUpItemLink(self.item:GetItemLink())
elseif IsShiftKeyDown() then
HandleModifiedItemClick(self.item:GetItemLink())
end
end
if self.spell then
if IsShiftKeyDown() then
HandleModifiedItemClick(GetSpellLink(self.spell:GetSpellID()))
end
end
end)
end
function GuildbookRecipeListviewItemMixin:ResetDataBinding()
for k, v in ipairs(self.reagentIcons) do
v:Hide()
end
self.item = nil;
self.label:SetText("")
for i = 1, 8 do
self.reagentIcons[i]:SetAlpha(0)
end
self:SetScript("OnEnter", nil)
end
GuildbookRosterListviewItemMixin = {}
function GuildbookRosterListviewItemMixin:OnLoad()
self.prof1:SetScript("OnMouseDown", function()
if self.character then
addon:TriggerEvent("Character_OnTradeskillSelected", self.character.data.profession1, self.character.data.profession1Recipes)
end
end)
self.prof2:SetScript("OnMouseDown", function()
if self.character then
addon:TriggerEvent("Character_OnTradeskillSelected", self.character.data.profession2, self.character.data.profession2Recipes)
end
end)
self.prof1:SetScript("OnEnter", function()
if self.character and self.character.data.profession1Spec then
GameTooltip:SetOwner(self.prof1, "ANCHOR_RIGHT")
GameTooltip:SetSpellByID(self.character.data.profession1Spec)
GameTooltip:Show()
end
end)
self.prof2:SetScript("OnEnter", function()
if self.character and self.character.data.profession2Spec then
GameTooltip:SetOwner(self.prof1, "ANCHOR_RIGHT")
GameTooltip:SetSpellByID(self.character.data.profession2Spec)
GameTooltip:Show()
end
end)
self.prof1:SetScript("OnLeave", function()
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
end)
self.prof2:SetScript("OnLeave", function()
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
end)
self.inviteToGroup:SetScript("OnMouseDown", function()
if self.character then
InviteUnit(self.character.data.name)
end
end)
self.openProfile:SetScript("OnMouseDown", function()
if self.character then
addon:TriggerEvent("Character_OnProfileSelected", self.character)
end
end)
self.openChat:SetScript("OnMouseDown", function()
if self.character then
addon:TriggerEvent("Chat_OnChatOpened", self.character.data.name)
end
end)
self:SetScript("OnMouseDown", function(f, b)
if b == "RightButton" then
EasyMenu(self.contextMenu, addon.contextMenu, "cursor", 0, 0, "MENU", 0.2)
end
end)
addon:RegisterCallback("UI_OnSizeChanged", self.UpdateLayout, self)
addon:RegisterCallback("Character_OnDataChanged", self.Character_OnDataChanged, self)
end
function GuildbookRosterListviewItemMixin:SetDataBinding(binding, height)
self.character = binding;
local atlas, _ = self.character:GetClassSpecAtlasName()
self.classIcon:SetAtlas(atlas)
-- local r, g, b = RAID_CLASS_COLORS[select(2, GetClassInfo(self.character.data.class))]:GetRGB()
-- self.background:SetColorTexture(r, g, b)
if binding.showBackground == true then
self.background:Show()
else
self.background:Hide()
end
self:Update()
end
function GuildbookRosterListviewItemMixin:UpdateLayout()
local x, y = self:GetSize()
if x > 850 then
--self.name:SetWidth(160)
-- self.rank:SetWidth(110)
-- self.rank:Show()
self.zone:SetWidth(110)
self.zone:Show()
self.publicNote:SetWidth(250)
self.publicNote:Show()
elseif x < 850 and x > 740 then
--self.name:SetWidth(140)
-- self.rank:SetWidth(1)
-- self.rank:Hide()
self.zone:SetWidth(110)
self.zone:Show()
self.publicNote:SetWidth(150)
self.publicNote:Show()
elseif x < 741 and x > 630 then
--self.name:SetWidth(120)
-- self.rank:SetWidth(1)
-- self.rank:Hide()
self.zone:SetWidth(1)
self.zone:Hide()
self.publicNote:SetWidth(150)
self.publicNote:Show()
elseif x < 631 then
--self.name:SetWidth(110)
self.publicNote:SetWidth(1)
self.publicNote:Hide()
-- self.rank:SetWidth(1)
-- self.rank:Hide()
self.zone:SetWidth(1)
self.zone:Hide()
end
end
function GuildbookRosterListviewItemMixin:Update()
local main = self.character:GetMainCharacter()
if type(main) == "string" then
self.name:SetFontObject("GameFontNormalSmall")
local name = self.character:GetName(true, "short")
self.name:SetText(string.format("%s\n[%s]", name, Ambiguate(main, "short")))
else
self.name:SetFontObject("GameFontNormal")
self.name:SetText(self.character:GetName(true, "short"))
end
self.level:SetText(self.character.data.level)
self.zone:SetText(self.character.data.onlineStatus.zone)
--self.rank:SetText(GuildControlGetRankName(self.character.data.rank + 1))
self.prof1.icon:SetAtlas(self.character:GetTradeskillIcon(1))
self.prof2.icon:SetAtlas(self.character:GetTradeskillIcon(2))
local ilvl = self.character:GetItemLevel()
self.ilvl:SetText(string.format("ilvl: %0.2f", ilvl or 0))
self.ilvlData = {}
for name, _ in pairs(self.character.data.inventory) do
local ilvl = self.character:GetItemLevel(name)
self.ilvlData[name] = ilvl
end
self.ilvl:SetScript("OnLeave", function()
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
end)
self.ilvl:SetScript("OnEnter", function()
GameTooltip:SetOwner(self, "ANCHOR_TOP")
GameTooltip_SetTitle(GameTooltip, "Equipment Sets")
for name, ilvl in pairs(self.ilvlData) do
GameTooltip_AddColoredLine(GameTooltip, string.format("%s ilvl: %0.2f", name, ilvl), BLUE_FONT_COLOR)
end
GameTooltip:Show()
end)