forked from stpain/guildbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGuildbook.lua
4538 lines (3678 loc) · 162 KB
/
Guildbook.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
-- grab the addon table
local _, gb = ...
local L = gb.Locales
local LCI = LibStub:GetLibrary("LibCraftInfo-1.0")
local LibGraph = LibStub("LibGraph-2.0");
local GUILD_NAME;
---set value to stagger comms when loading a character profile, if issues occur with comm spam increase this to ease load on comms channel
local transmitStagger = 0.5;
---the tradeskill import/export interface
GuildbookDataShareMixin = {}
---setup the import/export ui
function GuildbookDataShareMixin:OnLoad()
self:RegisterForDrag("LeftButton")
self:SetBackdrop({
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
tile = true,
tileSize = 32,
edgeSize = 32,
insets = { left = 8, right = 8, top = 8, bottom = 8 }
})
self.close:SetSize(24, 22)
self.close:SetNormalTexture(130832)
self.close:GetNormalTexture():SetTexCoord(0.1, 0.9, 0.1, 0.85)
self.close:SetHighlightTexture(130831)
self.close:GetHighlightTexture(130831):SetTexCoord(0.1, 0.9, 0.1, 0.85)
self.close:SetScript("OnClick", function()
self:Hide()
end)
---when a user clicks in the text area we highlight all the text so its easier to copy/paste out of the game
self.dataString.EditBox:SetScript("OnEditFocusGained", function(self)
self:HighlightText()
end)
self.dataString.CharCount:ClearAllPoints()
self.dataString.CharCount:SetPoint("TOPRIGHT", self.dataString, "BOTTOMRIGHT", 0, -25)
self.header:SetText(L["GUILDBOOK_DATA_SHARE_HEADER"])
self.import:SetText(L["IMPORT"])
---if there is a valid string then call the import script
self.import:SetScript("OnClick", function()
local data = self.dataString.EditBox:GetText()
if not data then
return
end
gb:ImportGuildTradeskillRecipes(data)
end)
self.export:SetText(L["EXPORT"])
---call the script to serialize all tradeskill data then set the textbox text for users to copy/paste
self.export:SetScript("OnClick", function()
local s = gb:SerializeGuildTradeskillRecipes()
GuildbookDataShare.dataString.EditBox:SetText("")
GuildbookDataShare.dataString.EditBox:SetText(s)
end)
end
function GuildbookDataShareMixin:OnShow()
self.dataString.EditBox:SetText("")
end
---this function is called from the roster listview when clicking a characters profession icon
---@param guid string the character guid
---@param prof string the profession name to use
local function loadGuildMemberTradeskills(guid, prof)
--hide the selected texture and flush the listviews
for _, button in ipairs(GuildbookTradeskillProfessionListview.profButtons) do
button.selected:Hide()
end
GuildbookUI.tradeskills.tradeskillItemsListview.DataProvider:Flush()
GuildbookUI.tradeskills.tradeskillItemsCharacterListview.DataProvider:Flush()
if next(gb.tradeskillRecipesKeys) == nil then
GuildbookUI.statusText:SetText("tradeskill recipes not processed yet, key mapping not ready")
return
end
if next(gb.tradeskillEnchantRecipesKeys) == nil then
GuildbookUI.statusText:SetText("tradeskill enchant recipes not processed yet, key mapping not ready")
return
end
local character = gb:GetCharacterFromCache(guid)
if not character then
return
end
GuildbookUI.tradeskills.awaitingCharacterRecipes = true;
if prof == "Enginnering" then prof = "Engineering" end -- fix it back due to blizz spelling error
gb:DB_RequestCharacterData(guid, prof, "WHISPER", character.Name, "NORMAL")
-- local recipes = {}
-- if prof ~= "allRecipes" and character[prof] then
-- for itemID, _ in pairs(character[prof]) do
-- if prof == "Enchanting" then
-- local key = gb.tradeskillEnchantRecipesKeys[itemID]
-- table.insert(recipes, gb.tradeskillRecipes[key])
-- else
-- local key = gb.tradeskillRecipesKeys[itemID]
-- table.insert(recipes, gb.tradeskillRecipes[key])
-- end
-- end
-- ---if no prof is given then load all the characters recipes
-- elseif prof == "allRecipes" then
-- local prof1 = character.Profession1
-- if prof1 and character[prof1] then
-- for itemID, _ in pairs(character[prof1]) do
-- if prof1 == "Enchanting" then
-- local key = gb.tradeskillEnchantRecipesKeys[itemID]
-- table.insert(recipes, gb.tradeskillRecipes[key])
-- else
-- local key = gb.tradeskillRecipesKeys[itemID]
-- table.insert(recipes, gb.tradeskillRecipes[key])
-- end
-- end
-- end
-- local prof2 = character.Profession2
-- if prof2 and character[prof2] then
-- for itemID, _ in pairs(character[prof2]) do
-- if prof2 == "Enchanting" then
-- local key = gb.tradeskillEnchantRecipesKeys[itemID]
-- table.insert(recipes, gb.tradeskillRecipes[key])
-- else
-- local key = gb.tradeskillRecipesKeys[itemID]
-- table.insert(recipes, gb.tradeskillRecipes[key])
-- end
-- end
-- end
-- end
-- if recipes and next(recipes) ~= nil then
-- GuildbookUI.statusText:SetText(string.format("found %s recipes for %s [%s]", #recipes, prof, character.Name))
-- table.sort(recipes, function(a,b)
-- if a.expansion == b.expansion then
-- if a.rarity == b.rarity then
-- return a.name < b.name
-- else
-- return a.rarity > b.rarity
-- end
-- else
-- return a.expansion > b.expansion
-- end
-- end)
-- GuildbookUI.tradeskills.tradeskillItemsListview.DataProvider:InsertTable(recipes)
-- end
-- GuildbookUI:OpenTo("tradeskills")
end
---returns a list of player GUIDs that have a match for the given prof
---@param prof string the profession to search for
---@return table
local function getAllPlayersWithTradeskill(prof)
local characters = {}
if GUILD_NAME then
if GUILDBOOK_GLOBAL and GUILDBOOK_GLOBAL.GuildRosterCache and GUILDBOOK_GLOBAL.GuildRosterCache[GUILD_NAME] then
for guid, character in pairs(GUILDBOOK_GLOBAL.GuildRosterCache[GUILD_NAME]) do
if character.Profession1 and (character.Profession1:lower() == prof:lower()) then
table.insert(characters, guid)
elseif character.Profession2 and (character.Profession2:lower() == prof:lower()) then
table.insert(characters, guid)
end
end
return characters
end
end
return false;
end
---load characters into the characters with recipe listview sorted by online status
---@param recipe table the recipe table or at least a table with a .itemID field
local function loadCharactersWithRecipe(recipe)
GuildbookUI.tradeskills.tradeskillItemsCharacterListview.DataProvider:Flush()
local charactersWithRecipe = {}
local sorting = {}
if recipe.enchant == true then
for k, guid in ipairs(gb.charactersWithEnchantRecipe[recipe.itemID]) do
table.insert(sorting, {
guid = guid,
online = gb.onlineZoneInfo[guid].online and 1 or 0,
})
end
else
for k, guid in ipairs(gb.charactersWithRecipe[recipe.itemID]) do
table.insert(sorting, {
guid = guid,
online = gb.onlineZoneInfo[guid].online and 1 or 0,
})
end
end
table.sort(sorting, function(a,b)
return a.online > b.online
end)
for k, character in ipairs(sorting) do
table.insert(charactersWithRecipe, character.guid)
end
GuildbookUI.tradeskills.tradeskillItemsCharacterListview.DataProvider:InsertTable(charactersWithRecipe)
end
--[[
this is the character listview for the tradeskill ui
its purpose is to show which characters have a certain tradeskill
it can then be filtered by tradeskill recipes by clicking the recipe
selecting a character will show that characters recipes for the currently selected tradeskill
]]--
GuildbookTradeskillCharacterListviewItemMixin = {}
---add the circluar mask to the portrait, this was doen in lua however can be moved into the xml template
function GuildbookTradeskillCharacterListviewItemMixin:OnLoad()
self.mask = self:CreateMaskTexture()
self.mask:SetSize(31,31)
self.mask:SetPoint("LEFT", 10, 0)
self.mask:SetTexture("Interface/CHARACTERFRAME/TempPortraitAlphaMask", "CLAMPTOBLACKADDITIVE", "CLAMPTOBLACKADDITIVE")
self.Icon:AddMaskTexture(self.mask)
end
function GuildbookTradeskillCharacterListviewItemMixin:OnMouseDown()
self:AdjustPointsOffset(-1,-1)
end
---call the items .func in the OnMouseUp event
function GuildbookTradeskillCharacterListviewItemMixin:OnMouseUp()
self:AdjustPointsOffset(1,1)
if self.func then
C_Timer.After(0, self.func)
end
end
---sets the character info, this displays character avatar, name and location - formats grey for offline characters
---@param guid string the characters guid
function GuildbookTradeskillCharacterListviewItemMixin:SetCharacter(guid)
-- this will become the new system using a guid
if guid:find("Player") then
local character = gb:GetCharacterFromCache(guid)
if not character then
return;
end
local race;
if character.Race:lower() == "scourge" then
race = "undead";
else
race = character.Race:lower()
end
self.Icon:SetAtlas(string.format("raceicon-%s-%s", race, character.Gender:lower()))
self.Name:SetText(character.Name)
if gb.onlineZoneInfo[guid].online == true then
self.Name:SetTextColor(1,1,1,1)
self.Zone:SetTextColor(1,1,1,1)
self.Zone:SetText("["..gb.onlineZoneInfo[guid].zone.."]")
else
self.Name:SetTextColor(0.5,0.5,0.5,0.7)
self.Zone:SetText("[offline]")
self.Zone:SetTextColor(0.5,0.5,0.5,0.7)
end
self.func = function()
loadGuildMemberTradeskills(guid, GuildbookMixin.selectedProfession and GuildbookMixin.selectedProfession or "allRecipes")
end
end
end
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- chats character listview
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
GuildbookCharacterListviewItemMixin = {}
function GuildbookCharacterListviewItemMixin:OnLoad()
self.mask = self:CreateMaskTexture()
self.mask:SetSize(31,31)
self.mask:SetPoint("LEFT", 10, 0)
self.mask:SetTexture("Interface/CHARACTERFRAME/TempPortraitAlphaMask", "CLAMPTOBLACKADDITIVE", "CLAMPTOBLACKADDITIVE")
self.Icon:AddMaskTexture(self.mask)
end
function GuildbookCharacterListviewItemMixin:OnMouseDown()
self:AdjustPointsOffset(-1,-1)
end
function GuildbookCharacterListviewItemMixin:OnMouseUp()
self:AdjustPointsOffset(1,1)
if self.func then
C_Timer.After(0, self.func)
end
end
function GuildbookCharacterListviewItemMixin:SetCharacter(guid)
-- this will become the new system using a guid
if guid:find("Player") then
local character = gb:GetCharacterFromCache(guid)
if not character then
return;
end
local race;
if character.Race:lower() == "scourge" then
race = "undead";
else
race = character.Race:lower()
end
self.Icon:SetAtlas(string.format("raceicon-%s-%s", race, character.Gender:lower()))
self.Name:SetText(character.Name)
-- this is kept for some compatability
else
local race;
if guid.race:lower() == "scourge" then
race = "undead";
else
race = guid.race:lower()
end
self.Icon:SetAtlas(string.format("raceicon-%s-%s", race, guid.gender:lower()))
self.Name:SetText(guid.name)
if guid.online == true then
self.Name:SetTextColor(1,1,1,1)
self.Zone:SetTextColor(1,1,1,1)
self.Zone:SetText("["..guid.zone.."]")
self.sendMessage:Show()
else
self.Name:SetTextColor(0.5,0.5,0.5,0.7)
self.sendMessage:Hide()
self.Zone:SetText("[offline]")
self.Zone:SetTextColor(0.5,0.5,0.5,0.7)
end
self.itemLink = guid.link;
self.guid = guid;
end
end
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- tradeskill recipe listview
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
GuildbookRecipeListviewItemMixin = {}
-- item has the following fields
-- itemID
-- reagents
-- rarity
-- link
-- icon
-- enchant
-- expansion
-- name
-- profession
-- equipLocation
function GuildbookRecipeListviewItemMixin:Init(item)
self.item = item;
for _, reagent in pairs(self.reagentIcons) do
reagent:SetFrameStrata("TOOLTIP")
reagent.icon:SetTexture(nil)
reagent.greenBorder:Hide()
reagent.orangeBorder:Hide()
reagent.purpleBorder:Hide()
reagent.count:SetText("")
reagent.link = nil
end
local reagentNum = 1
for reagentID, count in pairs(item.reagents) do
if self.reagentIcons[reagentNum] then
if GuildbookUI.playerContainerItems[reagentID] then
if GuildbookUI.playerContainerItems[reagentID] >= count then
self.reagentIcons[reagentNum].greenBorder:Show()
elseif GuildbookUI.playerContainerItems[reagentID] < count then
self.reagentIcons[reagentNum].purpleBorder:Show()
end
else
self.reagentIcons[reagentNum].orangeBorder:Show()
end
self.reagentIcons[reagentNum]:SetItem(reagentID)
self.reagentIcons[reagentNum].count:SetText(count)
reagentNum = reagentNum + 1;
end
end
self.Text:SetText(item.link)
end
function GuildbookRecipeListviewItemMixin:OnLoad()
end
function GuildbookRecipeListviewItemMixin:OnEnter()
if self.item.link then
GameTooltip:SetOwner(self, 'ANCHOR_RIGHT')
if self.item.enchant then
GameTooltip:SetSpellByID(self.item.itemID)
else
GameTooltip:SetHyperlink(self.item.link)
end
-- GameTooltip:AddLine(" ")
-- GameTooltip:AddLine(gb.Colours.Blue:WrapTextInColorCode(L["REMOVE_RECIPE_FROM_PROF"]))
GameTooltip:AddLine(" ")
GameTooltip:AddLine(gb.Colours.BlizzBlue:WrapTextInColorCode(L["TRADESKILLS_REAGENTS"]))
if self.item.reagents then
for reagentID, count in pairs(self.item.reagents) do
local name, _, _, _, _, _, _, _, _, icon = GetItemInfo(reagentID)
if not name then
local item = Item:CreateFromItemID(reagentID)
item:ContinueOnItemLoad(function()
local name = item:GetItemName()
GameTooltip:AddDoubleLine(name, count, 1,1,1, 1,1,1)
end)
else
GameTooltip:AddDoubleLine(name, count, 1,1,1, 1,1,1)
end
end
end
-- this adds the item table to the tooltip for debugging reasons
if GUILDBOOK_GLOBAL.Debug then
GameTooltip:AddLine(" ")
GameTooltip:AddLine("Guildbook debug:")
for k, v in pairs(self.item) do
if k ~= "reagents" and k ~= "charactersWithRecipe" then
GameTooltip:AddDoubleLine(k,v)
elseif k == "enchant" then
GameTooltip:AddDoubleLine(k, v == true and "true" or "false")
end
end
end
GameTooltip:Show()
-- fade the character listview to make the tooltip easier to view/read
GuildbookUI.tradeskills.tradeskillItemsCharacterListview:SetAlpha(0.3)
else
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
end
end
function GuildbookRecipeListviewItemMixin:OnLeave()
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
GuildbookUI.tradeskills.tradeskillItemsCharacterListview:SetAlpha(1)
end
function GuildbookRecipeListviewItemMixin:OnMouseDown(button)
--local index = self:GetOrderIndex();
-- this is an option for users to remove an item from a tradeskill if its somehow been mixed up
-- its not the best option to use however
-- if button == "RightButton" then
-- local characters = getAllPlayersWithTradeskill(self.item.profession)
-- StaticPopup_Show('GuildbookDeleteRecipeFromCharacters', string.format(L["REMOVE_RECIPE_FROM_PROF_SS"], self.item.link, self.item.profession), nil, {
-- itemLink = self.item.link,
-- characters = characters,
-- prof = self.item.profession,
-- listviewIndex = index,
-- listview = GuildbookUI.tradeskills.tradeskillItemsListview,
-- })
-- return;
-- end
-- enable the ctrl click to view item
if IsControlKeyDown() then
DressUpItemLink(self.item.link)
-- enable the shift click to link item
elseif IsShiftKeyDown() then
HandleModifiedItemClick(self.item.link)
-- load the characters who can craft the item
else
loadCharactersWithRecipe(self.item)
end
end
function GuildbookRecipeListviewItemMixin:OnMouseUp()
end
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- roster
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
GuildbookRosterListviewItemMixin = {}
GuildbookRosterListviewItemMixin.tooltipIcon = CreateFrame("FRAME", "GuildbookRosterListviewItemTooltipIcon")
GuildbookRosterListviewItemMixin.tooltipIcon:SetSize(24, 24)
GuildbookRosterListviewItemMixin.tooltipIcon.icon = GuildbookRosterListviewItemMixin.tooltipIcon:CreateTexture(nil, "BACKGROUND")
GuildbookRosterListviewItemMixin.tooltipIcon.icon:SetPoint("CENTER", 0, 0)
GuildbookRosterListviewItemMixin.tooltipIcon.icon:SetSize(56, 56)
GuildbookRosterListviewItemMixin.tooltipIcon.mask = GuildbookRosterListviewItemMixin.tooltipIcon:CreateMaskTexture()
GuildbookRosterListviewItemMixin.tooltipIcon.mask:SetSize(50,50)
GuildbookRosterListviewItemMixin.tooltipIcon.mask:SetPoint("CENTER", 0, 0)
GuildbookRosterListviewItemMixin.tooltipIcon.mask:SetTexture("Interface/CHARACTERFRAME/TempPortraitAlphaMask", "CLAMPTOBLACKADDITIVE", "CLAMPTOBLACKADDITIVE")
GuildbookRosterListviewItemMixin.tooltipIcon.icon:AddMaskTexture(GuildbookRosterListviewItemMixin.tooltipIcon.mask)
function GuildbookRosterListviewItemMixin:OnEnter()
if not self.character then
return;
end
local character = gb:GetCharacterFromCache(self.guid)
if not character then
return;
end
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
-- this was to change the tooltip background
--self.tooltipBackground:SetAtlas(string.format("UI-Character-Info-%s-BG", character.Class:sub(1,1):upper()..character.Class:sub(2)))
local rPerc, gPerc, bPerc, argbHex = GetClassColor(character.Class:upper())
GameTooltip_SetTitle(GameTooltip, character.Name.."\n\n|cffffffff"..L['level'].." "..character.Level, CreateColor(rPerc, gPerc, bPerc), nil)
if self.tooltipIcon then
if character.profile and character.profile.avatar then
self.tooltipIcon.icon:SetTexture(character.profile.avatar)
elseif character.Race and character.Gender then
local race;
if character.Race:lower() == "scourge" then
race = "undead";
else
race = character.Race:lower()
end
self.tooltipIcon.icon:SetAtlas(string.format("raceicon-%s-%s", race, character.Gender:lower()))
end
GameTooltip_InsertFrame(GameTooltip, self.tooltipIcon)
for k, frame in pairs(GameTooltip.insertedFrames) do
if frame:GetName() == "GuildbookRosterListviewItemTooltipIcon" then
frame:ClearAllPoints()
frame:SetPoint("TOPRIGHT", -20, -20)
end
end
end
local colour = CreateColor(0.1, 0.58, 0.92, 1)
local function formatTradeskill(prof, spec)
if spec then
return string.format("%s [%s]", prof, gb.Colours.Blue:WrapTextInColorCode((GetSpellInfo(spec))));
elseif prof then
return prof;
else
return "-";
end
end
GameTooltip:AddLine(L["TRADESKILLS"])
GameTooltip:AddDoubleLine(formatTradeskill(character.Profession1, character.Profession1Spec), character.Profession1Level or 0, 1,1,1,1, 1,1,1,1)
-- GameTooltip_ShowStatusBar(GameTooltip, 0, 300, 245)
-- GameTooltip_ShowProgressBar(GameTooltip, 0, 300, 245)
GameTooltip:AddDoubleLine(formatTradeskill(character.Profession2, character.Profession2Spec), character.Profession2Level or 0, 1,1,1,1, 1,1,1,1)
if character.PublicNote then
GameTooltip:AddLine(" ")
GameTooltip:AddDoubleLine(L['publicNote'], "|cffffffff"..character.PublicNote)
end
if character.MainCharacter and GUILDBOOK_GLOBAL.GuildRosterCache[GUILD_NAME][character.MainCharacter] then
GameTooltip:AddLine(" ")
GameTooltip:AddLine(L['MAIN_CHARACTER'])
local s = string.format("%s %s %s",
gb.Data.Class[GUILDBOOK_GLOBAL.GuildRosterCache[GUILD_NAME][character.MainCharacter].Class].FontStringIconMEDIUM,
gb.Data.Class[GUILDBOOK_GLOBAL.GuildRosterCache[GUILD_NAME][character.MainCharacter].Class].FontColour,
GUILDBOOK_GLOBAL.GuildRosterCache[GUILD_NAME][character.MainCharacter].Name
)
GameTooltip:AddLine(s)
end
if character.Alts then
GameTooltip:AddLine(" ")
GameTooltip:AddLine(L['ALTS'])
for _, guid in pairs(character.Alts) do
if guid ~= character.MainCharacter then
local s = string.format("%s %s %s",
gb.Data.Class[GUILDBOOK_GLOBAL.GuildRosterCache[GUILD_NAME][guid].Class].FontStringIconMEDIUM,
gb.Data.Class[GUILDBOOK_GLOBAL.GuildRosterCache[GUILD_NAME][guid].Class].FontColour,
GUILDBOOK_GLOBAL.GuildRosterCache[GUILD_NAME][guid].Name
)
GameTooltip:AddLine(s)
end
--GameTooltip:AddTexture(gb.Data.Class[GUILDBOOK_GLOBAL.GuildRosterCache[GUILD_NAME][guid].Class].Icon)
end
end
--GameTooltip:AddLine(" ")
-- i contacted the author of attune to check it was ok to add their addon data
if Attune_DB and Attune_DB.toons[character.Name.."-"..GetRealmName()] then
GameTooltip:AddLine(" ")
GameTooltip:AddLine(L["attunements"])
local db = Attune_DB.toons[character.Name.."-"..GetRealmName()]
for _, instance in ipairs(Attune_Data.attunes) do
if db.attuned[instance.ID] and (instance.FACTION == "Both" or instance.FACTION == character.Faction) then
local formatPercent = db.attuned[instance.ID] < 100 and "|cffff0000"..db.attuned[instance.ID].."%" or "|cff00ff00"..db.attuned[instance.ID].."%"
GameTooltip:AddDoubleLine("|cffffffff"..instance.NAME, formatPercent)
end
end
end
GameTooltip:Show()
end
function GuildbookRosterListviewItemMixin:OnLeave()
if GameTooltip.insertedFrames and next(GameTooltip.insertedFrames) ~= nil then
for k, frame in pairs(GameTooltip.insertedFrames) do
if frame:GetName() == "GuildbookRosterListviewItemTooltipIcon" then
frame:Hide()
end
end
end
GameTooltip_SetDefaultAnchor(GameTooltip, UIParent)
end
function GuildbookRosterListviewItemMixin:OnLoad()
end
function GuildbookRosterListviewItemMixin:SetOffline(online)
if online then
self.Name:SetTextColor(1,1,1,1)
self.Level:SetTextColor(1,1,1,1)
self.MainSpec:SetTextColor(1,1,1,1)
self.Location:SetTextColor(1,1,1,1)
self.PublicNote:SetTextColor(1,1,1,1)
self.Rank:SetTextColor(1,1,1,1)
else
self.Name:SetTextColor(0.5,0.5,0.5,0.5)
self.Level:SetTextColor(0.5,0.5,0.5,0.5)
self.MainSpec:SetTextColor(0.5,0.5,0.5,0.5)
self.Location:SetTextColor(0.5,0.5,0.5,0.5)
self.PublicNote:SetTextColor(0.5,0.5,0.5,0.5)
self.Rank:SetTextColor(0.5,0.5,0.5,0.5)
end
end
-- this function needs to be cleaned up, its using a nasty set of variables
function GuildbookRosterListviewItemMixin:SetCharacter(member)
self.guid = member.guid
self.character = gb:GetCharacterFromCache(member.guid)
self.ClassIcon:SetAtlas(string.format("GarrMission_ClassIcon-%s", self.character.Class))
self.ClassIcon:Show()
--self.Name:SetText(character.isOnline and self.character.Name or "|cffB1B3AB"..self.character.Name)
self.Name:SetText(self.character.Name)
self.Level:SetText(self.character.Level)
local mainSpec = false;
if self.character.MainSpec == "Bear" then
mainSpec = "Guardian"
elseif self.character.MainSpec == "Cat" then
mainSpec = "Feral"
elseif self.character.MainSpec == "Beast Master" or self.character.MainSpec == "BeastMaster" then
mainSpec = "BeastMastery"
elseif self.character.MainSpec == "Combat" then
mainSpec = "Outlaw"
end
if self.character.MainSpec and self.character.MainSpec ~= "-" then
--print(mainSpec, self.character.MainSpec, self.character.Name)
local icon = gb:GetClassSpecAtlasName(self.character.Class, self.character.MainSpec)
self.MainSpecIcon:SetAtlas(icon)
self.MainSpecIcon:Show()
self.MainSpec:SetText(L[self.character.MainSpec])
else
self.MainSpecIcon:Hide()
end
if self.character.Profession1 ~= "-" then
local prof1 = self.character.Profession1
if prof1 then
if prof1 == "Engineering" then
self.Prof1.icon:SetAtlas("Mobile-Enginnering")
else
self.Prof1.icon:SetAtlas(string.format("Mobile-%s", prof1))
end
if self.character.Profession1Spec then
--local profSpec = GetSpellDescription(self.character.Profession1Spec)
local profSpec = GetSpellInfo(self.character.Profession1Spec)
self.Prof1.tooltipText = gb:GetLocaleProf(prof1).." |cffffffff"..profSpec.."\n\n"..gb.Colours.BlizzBlue:WrapTextInColorCode(L["ROSTER_VIEW_RECIPES"])
else
self.Prof1.tooltipText = gb:GetLocaleProf(prof1).."\n\n"..gb.Colours.BlizzBlue:WrapTextInColorCode(L["ROSTER_VIEW_RECIPES"])
end
self.Prof1.func = function()
loadGuildMemberTradeskills(self.guid, prof1)
end
self.Prof1:Show()
end
else
self.Prof1:Hide()
end
if self.character.Profession2 ~= "-" then
local prof2 = self.character.Profession2
if prof2 then
if prof2 == "Engineering" then
self.Prof2.icon:SetAtlas("Mobile-Enginnering")
else
self.Prof2.icon:SetAtlas(string.format("Mobile-%s", prof2))
end
if self.character.Profession2Spec then
--local profSpec = GetSpellDescription(self.character.Profession2Spec)
local profSpec = GetSpellInfo(self.character.Profession2Spec)
self.Prof2.tooltipText = gb:GetLocaleProf(prof2).." |cffffffff"..profSpec.."\n\n"..gb.Colours.BlizzBlue:WrapTextInColorCode(L["ROSTER_VIEW_RECIPES"])
else
self.Prof2.tooltipText = gb:GetLocaleProf(prof2).."\n\n"..gb.Colours.BlizzBlue:WrapTextInColorCode(L["ROSTER_VIEW_RECIPES"])
end
self.Prof2.func = function()
loadGuildMemberTradeskills(self.guid, prof2)
end
self.Prof2:Show()
end
else
self.Prof2:Hide()
end
self.Location:SetText(member.location)
self.Rank:SetText(member.rankName)
self.PublicNote:SetText(member.publicNote)
if self.character and self.character.profile and self.character.profile.avatar then
self.openProfile.background:SetTexture(self.character.profile.avatar)
elseif self.character.Race and self.character.Gender then
self.openProfile.background:SetAtlas(string.format("raceicon-%s-%s", self.character.Race:lower(), self.character.Gender:lower()))
else
self.openProfile.background:SetAtlas("services-icon-warning")
end
end
function GuildbookRosterListviewItemMixin:OnMouseDown(button)
if button == "RightButton" and self.character then
StaticPopup_Show("GuildbookResetCacheCharacter", self.character.Name, nil, {guid = self.guid})
end
end
function GuildbookRosterListviewItemMixin:OnMouseUp()
end
GuildbookAvatarMixin = {}
function GuildbookAvatarMixin:OnLoad()
end
function GuildbookAvatarMixin:OnMouseDown()
if self.func then
self.func()
end
end
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- main
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
GuildbookMixin = {}
GuildbookMixin.selectedProfession = nil;
GuildbookMixin.charactersWithProfession = {}
GuildbookMixin.playerContainerItems = {}
local function navigateTo(frame)
for _, f in pairs(GuildbookUI.frames) do
f:Hide()
end
GuildbookUI.backgroundModel:Hide()
frame:Show()
end
function GuildbookMixin:OpenTo(frame)
navigateTo(self[frame])
self:Show()
end
function GuildbookMixin:OnHide()
end
function GuildbookMixin:OnShow()
GUILD_NAME = gb:GetGuildName()
if GUILDBOOK_CHARACTER.profile and GUILDBOOK_CHARACTER.profile.avatar then
self.ribbon.myProfile.background:SetTexture(GUILDBOOK_CHARACTER.profile.avatar)
else
SetPortraitTexture(self.ribbon.myProfile.background, "player")
end
end
function GuildbookMixin:OnLoad()
self:RegisterForDrag("LeftButton")
SetPortraitToTexture(GuildbookUIPortrait,134068)
--GuildbookUITitleText:SetText("v0.0.1")
GuildbookDataShare:SetParent(GuildbookUI.tradeskills)
GuildbookDataShare:SetPoint("LEFT", GuildbookUI.tradeskills, "RIGHT", 20, 0)
self.backgroundModel = CreateFrame('PlayerModel', "GuildbookBackgroundModel", self, BackdropTemplateMixin and "BackdropTemplate")
self.backgroundModel:SetPoint('TOPLEFT', 0, -55)
self.backgroundModel:SetPoint('BOTTOMRIGHT', 0, 0)
self.backgroundModel:SetModel("creature/illidan/illidan.m2")
self.backgroundModel:SetPosition(0,0,-0.2)
self.backgroundModel:SetKeepModelOnHide(true)
self.backgroundModel:Hide()
for _, f in pairs(GuildbookUI.frames) do
f:Hide()
end
tinsert(UISpecialFrames, self:GetName());
self.ribbon:SetFrameLevel(self:GetFrameLevel() - 1)
self.ribbon.profiles.func = function()
self.profiles:ShowSummary(true)
navigateTo(self.profiles)
end
self.ribbon.tradeskills.func = function()
navigateTo(self.tradeskills)
end
self.ribbon.chat.func = function()
navigateTo(self.chat)
end
self.ribbon.roster.func = function()
navigateTo(self.roster)
end
self.ribbon.privacy.func = function()
navigateTo(self.privacy)
end
self.ribbon.calendar.func = function()
navigateTo(self.calendar)
gb.GuildFrame.GuildCalendarFrame:ClearAllPoints()
gb.GuildFrame.GuildCalendarFrame:SetParent(self.calendar)
gb.GuildFrame.GuildCalendarFrame:SetPoint("TOPLEFT", 0, -26) --this has button above the frame so lower it a bit
gb.GuildFrame.GuildCalendarFrame:SetPoint("BOTTOMRIGHT", -2, 0)
gb.GuildFrame.GuildCalendarFrame:Show()
gb.GuildFrame.GuildCalendarFrame.EventFrame:ClearAllPoints()
gb.GuildFrame.GuildCalendarFrame.EventFrame:SetPoint('TOPLEFT', self.calendar, 'TOPRIGHT', 4, 50)
gb.GuildFrame.GuildCalendarFrame.EventFrame:SetPoint('BOTTOMRIGHT', self.calendar, 'BOTTOMRIGHT', 254, 0)
end
self.ribbon.guildbank.func = function()
navigateTo(self.guildbank)
end
self.ribbon.search.func = function()