-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathGW2_ui.lua
978 lines (832 loc) · 29 KB
/
GW2_ui.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
local addonName, GW = ...
local L = GW.L
local RoundInt = GW.RoundInt
local bloodSpark = GW.BLOOD_SPARK
local CLASS_ICONS = GW.CLASS_ICONS
local IsFrameModified = GW.IsFrameModified
local IsIncompatibleAddonLoadedOrOverride = GW.IsIncompatibleAddonLoadedOrOverride
local Debug = GW.Debug
local AFP = GW.AddProfiling
local animations = GW.animations
local l = CreateFrame("Frame") -- Main event frame
GW.VERSION_STRING = "GW2_UI @project-version@"
-- Make a global GW variable , so others cann access out functions
GW2_ADDON = GW
if WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE then
GW.Notice("You have installed GW2_UI retail version. Please install the classic version to use GW2_UI.")
return
end
if GW.CheckForPasteAddon() and GW.settings.ACTIONBARS_ENABLED and not IsIncompatibleAddonLoadedOrOverride("Actionbars", true) then
GW.Notice("|cffff0000You have installed the Addon 'Paste'. This can cause, that our actionbars are empty. Deactive 'Paste' to use our actionbars.|r")
end
local loaded = false
local forcedMABags = false
local swimAnimation = 0
local lastSwimState = true
local hudArtFrame
function GW2_ADDON_AddonCompartmentOnClickFunc()
GW.ToggleGw2Settings()
end
function GW2_ADDON_OnAddonCompartmentEnter(_, menuButtonFrame)
GameTooltip:SetOwner(menuButtonFrame, "ANCHOR_NONE");
GameTooltip:SetPoint("TOPRIGHT", menuButtonFrame, "BOTTOMRIGHT", 0, 0);
GameTooltip:ClearLines()
GameTooltip:AddDoubleLine(addonName, C_AddOns.GetAddOnMetadata(addonName, "Version"))
GameTooltip:Show()
end
function GW2_ADDON_OnAddonCompartmentLeave(addonName, button)
GameTooltip:Hide();
end
local function disableMABags()
local bags = GW.settings.BAGS_ENABLED and not IsIncompatibleAddonLoadedOrOverride("Inventory", true)
if not bags or not MovAny or not MADB then
return
end
MADB.noBags = true
MAOptNoBags:SetEnabled(false)
forcedMABags = true
end
AFP("disableMABags", disableMABags)
-- https://us.battle.net/forums/en/wow/topic/6036615884
if AchievementMicroButton_Update == nil then
function AchievementMicroButton_Update()
return
end
end
local function AddToAnimation(name, from, to, start, duration, method, easeing, onCompleteCallback, doCompleteOnOverider)
local newAnimation = true
if animations[name] then
newAnimation = (animations[name].start + animations[name].duration) > GetTime()
end
if not doCompleteOnOverider then
newAnimation = true
end
if not newAnimation then
animations[name].duration = duration
animations[name].to = to
animations[name].progress = 0
animations[name].method = method
animations[name].completed = false
animations[name].easeing = easeing
animations[name].onCompleteCallback = onCompleteCallback
else
animations[name] = {}
animations[name].start = start
animations[name].duration = duration
animations[name].from = from
animations[name].to = to
animations[name].progress = 0
animations[name].method = method
animations[name].completed = false
animations[name].easeing = easeing
animations[name].onCompleteCallback = onCompleteCallback
end
end
GW.AddToAnimation = AddToAnimation
--[[
Basic helper function for spritemaps
mapExample = {
width = 100,
height = 10,
colums = 5,
rows = 3
}
]]--
local function getSprite(map,x,y)
local pw = (map.width / map.colums) / map.width
local ph = (map.height / map.rows) / map.height
local left = pw * (x - 1)
local right = pw * x
local top = ph * (y - 1)
local bottom = ph * y
return left, right, top, bottom;
end
GW.getSprite = getSprite
local function getSpriteByIndex(map, index)
if map == nil then
return 0, 0, 0, 0
end
local tileWidth = map.width / map.colums
local tileHeight = map.height / map.rows
local tilesPerColums = map.width / tileWidth
--local tilesPerRow = map.height / tileHeight
local left = tileWidth * (index % tilesPerColums)
local top = tileHeight * math.floor(index / tilesPerColums)
local bottom = top + tileHeight
local right = left + tileWidth
return left / map.width, right / map.width, top / map.height,bottom / map.height
end
GW.getSpriteByIndex = getSpriteByIndex
local function TriggerButtonHoverAnimation(self, hover, to, duration)
local name = self.animationName or self.GetName and self:GetName() or tostring(self)
hover:SetAlpha(1)
duration = duration or math.min(1, self:GetWidth() * 0.002)
AddToAnimation(
name,
self.animationValue or 0,
(to or 1),
GetTime(),
duration,
function(p)
local w = self:GetWidth()
local lerp = GW.lerp(0, w + (w * 0.5), p)
local lerp2 = math.min(1, math.max(0.4, math.min(1, GW.lerp(0.4, 1, p))))
local stripAmount = 1 - math.max(0, (lerp / w) - 1)
if self.limitHoverStripAmount then
stripAmount = math.max(self.limitHoverStripAmount, stripAmount)
end
hover:SetPoint("RIGHT", self, "LEFT", math.min(w, lerp) , 0)
hover:SetVertexColor(hover.r or 1, hover.g or 1, hover.b or 1, lerp2)
hover:SetTexCoord(0, stripAmount, 0, 1)
end
)
end
GW.TriggerButtonHoverAnimation = TriggerButtonHoverAnimation
function GwStandardButton_OnEnter(self)
if not self.hover or (self.IsEnabled and not self:IsEnabled()) then
return
end
self.animationValue = self.hover.skipHover and 1 or 0
TriggerButtonHoverAnimation(self, self.hover)
end
function GwStandardButton_OnLeave(self)
if not self.hover or (self.IsEnabled and not self:IsEnabled()) then
return
end
if self.hover.skipHover then return end
self.hover:SetAlpha(1)
self.animationValue = 1
TriggerButtonHoverAnimation(self, self.hover, 0, 0.1)
end
local function barAnimation(self, barWidth, sparkWidth)
local snap = (animations[self.animationName].progress * 100) / 5
local round_closest = 0.05 * snap
local spark_min = math.floor(snap)
local spark_current = snap
local spark_prec = spark_current - spark_min
local spark =
math.min(barWidth - sparkWidth, math.floor(barWidth * round_closest) - math.floor(sparkWidth * spark_prec))
local bI = 17 - math.max(1, RoundInt(16 * spark_prec))
self.spark:SetTexCoord(bloodSpark[bI].left, bloodSpark[bI].right, bloodSpark[bI].top, bloodSpark[bI].bottom)
self:SetValue(round_closest)
self.spark:ClearAllPoints()
self.spark:SetPoint("LEFT", spark, 0)
end
AFP("barAnimation", barAnimation)
local function Bar(self, value)
if self == nil then
return
end
local barWidth = self:GetWidth()
local sparkWidth = self.spark:GetWidth()
AddToAnimation(
self.animationName,
self.animationValue,
value,
GetTime(),
0.2,
function()
barAnimation(self, barWidth, sparkWidth)
end
)
self.animationValue = value
end
GW.Bar = Bar
local function SetClassIcon(self, class)
if class == nil then
class = 0
end
self:SetTexCoord(CLASS_ICONS[class].l, CLASS_ICONS[class].r, CLASS_ICONS[class].t, CLASS_ICONS[class].b)
end
GW.SetClassIcon = SetClassIcon
local function SetDeadIcon(self)
self:SetTexCoord(CLASS_ICONS["dead"].l, CLASS_ICONS["dead"].r, CLASS_ICONS["dead"].t, CLASS_ICONS["dead"].b)
end
GW.SetDeadIcon = SetDeadIcon
local function StopAnimation(name)
if animations[name] then
animations[name].completed = true
return true
end
return false
end
GW.StopAnimation = StopAnimation
local function swimAnim()
local r, g, b = hudArtFrame.actionBarHud.RightSwim:GetVertexColor()
hudArtFrame.actionBarHud.RightSwim:SetVertexColor(r, g, b, animations.swimAnimation.progress)
hudArtFrame.actionBarHud.LeftSwim:SetVertexColor(r, g, b, animations.swimAnimation.progress)
end
AFP("swimAnim", swimAnim)
local updateCB = {}
local function AddUpdateCB(func, payload)
if type(func) ~= "function" then
return
end
tinsert(updateCB,{func = func, payload = payload})
end
GW.AddUpdateCB = AddUpdateCB
local function gw_OnUpdate(_, elapsed)
local foundAnimation = false
local count = 0
local time = GetTime()
for _, v in pairs(animations) do
count = count + 1
if v.completed == false and time >= (v.start + v.duration) then
if v.easeing == nil then
v.progress = GW.lerp(v.from, v.to, math.sin(1 * math.pi * 0.5))
else
v.progress = GW.lerp(v.from, v.to, 1)
end
if v.method then
v.method(v.progress)
end
if v.onCompleteCallback then
v.onCompleteCallback()
end
v.completed = true
foundAnimation = true
end
if v.completed == false then
if v.easeing == nil then
v.progress = GW.lerp(v.from, v.to, math.sin((time - v.start) / v.duration * math.pi * 0.5))
else
v.progress = GW.lerp(v.from, v.to, (time - v.start) / v.duration)
end
v.method(v.progress)
foundAnimation = true
end
end
if not foundAnimation and count > 0 then
table.wipe(animations)
end
--Swim hud
if lastSwimState ~= IsSwimming() then
if IsSwimming() then
AddToAnimation("swimAnimation", swimAnimation, 1, time, 0.1, swimAnim)
swimAnimation = 1
else
AddToAnimation("swimAnimation", swimAnimation, 0, time, 3.0, swimAnim)
swimAnimation = 0
end
lastSwimState = IsSwimming()
end
for _, cb in ipairs(updateCB) do
cb.func(cb.payload, elapsed)
end
end
AFP("gw_OnUpdate", gw_OnUpdate)
local function getBestPixelScale()
return max(0.4, min(1.15, 768 / GW.screenHeight))
end
GW.getBestPixelScale = getBestPixelScale
local function PixelPerfection()
if GW.settings.PIXEL_PERFECTION and not GetCVarBool("useUiScale") then
GW.scale = getBestPixelScale()
GW.border = ((1 / GW.scale) - ((1 - (768 / GW.screenHeight)) / GW.scale)) * 2
UIParent:SetScale(GW.scale)
end
end
GW.PixelPerfection = PixelPerfection
local SCALE_HUD_FRAMES = {}
local function UpdateHudScale()
local hudScale = tonumber(GW.settings.HUD_SCALE) or 1
for _, f in ipairs(SCALE_HUD_FRAMES) do
if f then
local fm = f.gwMover
local sf = 1.0
if f.gwScaleMulti then
sf = f.gwScaleMulti
end
f:SetScale(hudScale * sf)
if fm then
fm:SetScale(hudScale * sf)
end
end
end
-- let all mainhub frames scale with the HUD scaler, but only if they are not moved and not individual scaled
for _, mf in pairs(GW.scaleableMainHudFrames) do
if not mf.parent.isMoved and mf:GetScale() ~= hudScale then
mf.parent:SetScale(hudScale)
mf:SetScale(hudScale)
GW.settings[mf.setting .. "_scale"] = hudScale
end
end
end
GW.UpdateHudScale = UpdateHudScale
local function RegisterScaleFrame(f, modifier)
if not f then
return
end
if modifier and modifier > 0 then
f.gwScaleMulti = modifier
end
local num = #SCALE_HUD_FRAMES
SCALE_HUD_FRAMES[num + 1] = f
end
GW.RegisterScaleFrame = RegisterScaleFrame
-- Functions to run when various addons load. Registering these
-- works on the honor system for now; don't blow away a prior hook :)
-- Primarily for on-demand addons; if the addon has already loaded
-- (based on the cond arg), the hook will run immediately.
local function errorhandler(err)
return geterrorhandler()(err)
end
local addonLoadHooks = {}
local function RegisterLoadHook(func, name, cond)
if not func or type(func) ~= "function" or not name or type(name) ~= "string" then
return
end
if cond then
func(l)
else
addonLoadHooks[name] = func
end
end
GW.RegisterLoadHook = RegisterLoadHook
local function UpdateDb()
GW.settings = GW.globalSettings.profile
end
local function evAddonLoaded(self, loadedAddonName)
if loadedAddonName ~= "GW2_UI" then
local loadHook = addonLoadHooks[loadedAddonName]
if loadHook and type(loadHook) == "function" then
Debug("run load hook for addon", loadedAddonName)
xpcall(loadHook, errorhandler)
addonLoadHooks[loadedAddonName] = nil
end
return
else
-- init databse
GW.globalSettings = GW.Libs.AceDB:New('GW2UI_DATABASE', GW.globalDefault, true)
GW.globalSettings.RegisterCallback(self, 'OnProfileChanged', UpdateDb)
GW.settings = GW.globalSettings.profile
GW.global = GW.globalSettings.global
GW.charSettings = GW.Libs.AceDB:New('GW2UI_PRIVATE_DB', GW.privateDefaults)
GW.private = GW.charSettings.profile
GW.UpdateGw2ClassColors()
-- setup default values on load, which are required for same skins
if GW.settings.PIXEL_PERFECTION and not GetCVarBool("useUiScale") then
PixelPerfection()
GW.Notice("Pixel Perfection-Mode enabled. UIScale down to perfect pixel size. Can be deactivated in HUD settings. |cFF00FF00/gw2|r")
else
GW.scale = UIParent:GetScale()
GW.border = ((1 / GW.scale) - ((1 - (768 / GW.screenHeight)) / GW.scale)) * 2
end
GW.mult = (1 / GW.scale) - ((1 - (768 / GW.screenHeight)) / GW.scale)
end
Debug("OK~EVENT~In ADDON_LOADED event")
GW.LoadStorage()
-- TODO: A lot of what happens in player login should probably happen here instead
-- check for DeModal
local _, _, _, enabled, _ = C_AddOns.GetAddOnInfo("DeModal")
if enabled then
GW.HasDeModal = true
else
GW.HasDeModal = false
end
Debug("DeModal status:", GW.HasDeModal)
-- TODO: moving skinning from player login to here
-- Skins: BLizzard & Addons
GW.LoadWorldMapSkin()
GW.LoadEncounterJournalSkin()
GW.LoadAchivementSkin()
GW.LoadAlliedRacesUISkin()
GW.LoadBarShopUISkin()
GW.LoadChromieTimerSkin()
GW.LoadCovenantSanctumSkin()
GW.LoadDeathRecapSkin()
GW.LoadFlightMapSkin()
GW.LoadInspectFrameSkin()
GW.LoadItemUpgradeSkin()
GW.LoadLFGSkin()
GW.LoadMacroOptionsSkin()
GW.LoadOrderHallTalentFrameSkin()
GW.LoadSocketUISkin()
GW.LoadSoulbindsSkin()
GW.LoadWeeklyRewardsSkin()
GW.LoadPerksProgramSkin()
GW.LoadAdventureMapSkin()
GW.LoadPlayerSpellsSkin()
GW.LoadAuctionHouseSkin()
GW.LoadBattlefieldMapSkin()
GW.LoadMajorFactionsFrameSkin()
GW.PreloadStatusBarMaskTextures()
end
AFP("evAddonLoaded", evAddonLoaded)
local function evNeutralFactionSelectResult()
GW.myfaction, GW.myLocalizedFaction = UnitFactionGroup("player")
Debug("OK~EVENT~New faction:", GW.myfaction, GW.myLocalizedFaction)
end
AFP("evNeutralFactionSelectResult", evNeutralFactionSelectResult)
local function evPlayerSpecializationChanged()
GW.CheckRole()
end
AFP("evPlayerSpecializationChanged", evPlayerSpecializationChanged)
local function evUiScaleChanged()
if not GetCVarBool("useUiScale") then
return
end
GW.settings.PIXEL_PERFECTION = false
GW.scale = UIParent:GetScale()
GW.screenwidth, GW.screenheight = GetPhysicalScreenSize()
GW.resolution = format("%dx%d", GW.screenwidth, GW.screenheight)
GW.border = ((1 / GW.scale) - ((1 - (768 / GW.screenHeight)) / GW.scale)) * 2
end
AFP("evUiScaleChanged", evUiScaleChanged)
local function evPlayerLevelUp(_, newLevel)
GW.mylevel = newLevel
Debug("OK~EVENT~New level:", newLevel)
end
AFP("evPlayerLevelUp", evPlayerLevelUp)
local function evPlayerLeavingWorld()
GW.inWorld = false
end
AFP("evPlayerLeavingWorld", evPlayerLeavingWorld)
local function commonEntering()
GW.inWorld = true
GW.CheckRole()
if GW.settings.PIXEL_PERFECTION and not GetCVarBool("useUiScale") and not UnitAffectingCombat("player") then
PixelPerfection()
end
C_Timer.After(0.5, function()
if UnitInBattleground("player") == nil and not IsActiveBattlefieldArena() then
GW.RemoveTrackerNotificationOfType("ARENA")
end
end)
end
local migrationDone = false
local function evPlayerEnteringWorld()
commonEntering()
-- do migration one on first login
if not migrationDone then
--migration things
GW.Migration()
migrationDone = true
end
local dbMigrated = false
if not GW.private.dbConverted then
GW.DatabaseMigration(false, true)
GW.private.dbConverted = true
dbMigrated = true
end
if not GW.global.dbConverted then
GW.DatabaseMigration(true, false)
GW.global.dbConverted = true
dbMigrated = true
end
if dbMigrated then
C_Timer.After(3, function() GW.WarningPrompt(
L["DB was converted Reload is needed /reload"],
function() C_UI.Reload() end
)
end)
GW.Notice("DB was converted Reload is needed /reload")
end
-- remove old databse
GW2UI_PRIVATE_SETTINGS = nil
GW2UI_PRIVATE_LAYOUTS = nil
GW2UI_SETTINGS_PROFILES = nil
GW2UI_LAYOUTS = nil
GW2UI_SETTINGS_DB_03 = nil
end
AFP("evPlayerEnteringWorld", evPlayerEnteringWorld)
local function evPlayerEnteringBattleground()
commonEntering()
end
AFP("evPlayerEnteringBattleground", evPlayerEnteringBattleground)
local function evPlayerLogin(self)
Debug("OK~EVENT~PLAYER_LOGIN; loaded:", loaded)
if loaded then
GW.UpdateCharData()
return
end
-- fetch data
-- Loop through the expansions to collect the textures
local numTiers = (EJ_GetNumTiers() or 0)
if numTiers > 0 then
local currentTier = EJ_GetCurrentTier()
for i = 1, numTiers do
EJ_SelectTier(i)
GW.GetInstanceImages(false)
GW.GetInstanceImages(true)
end
-- Set it back to the previous tier
if currentTier then
EJ_SelectTier(currentTier)
end
end
-- Remove old debuffs from db
GW.RemoveOldRaidDebuffsFormProfiles()
GW.DisableBlizzardFrames()
loaded = true
GW.CheckRole() -- some API's deliver a nil value on init.lua load, we we fill this values also here
if GW.inDebug then
GW.AlertTestsSetup()
end
GW.CombatQueue_Initialize()
--Create the mainbar layout manager
local lm = GW.LoadMainbarLayout()
--Create Settings window
GW.SetUpDatabaseForProfileSpecSwitch()
GW.LoadMovers(lm.layoutFrame)
GW.LoadSettings()
GW.BuildPrefixValues()
GW.LoadFonts()
-- Create Warning Prompt
GW.CreateWarningPrompt()
-- disable Move Anything bag handling
disableMABags()
-- Load Slash commands
GW.LoadSlashCommands()
-- Misc
GW.InitializeMiscFunctions()
GW.LoadRaidMarkerCircle()
--Create general skins
GW.StoreGameMenuButton()
if GW.settings.MAINMENU_SKIN_ENABLED then
GW.SkinMainMenu()
else
hooksecurefunc(GameMenuFrame, 'InitButtons', function(self)
self:AddSection()
self:AddButton(format(("*%s|r"):gsub("*", GW.Gw2Color), GW.addonName), GW.ToggleGw2Settings)
end)
end
-- Skins: BLizzard & Addons
GW.LoadStaticPopupSkin()
GW.LoadBNToastSkin()
GW.LoadDropDownSkin()
GW.LoadLFGSkins()
GW.LoadReadyCheckSkin()
GW.LoadTalkingHeadSkin()
GW.LoadMiscBlizzardFrameSkins()
GW.LoadAddonListSkin()
GW.LoadMailSkin()
GW.LoadDressUpFrameSkin()
GW.LoadHelperFrameSkin()
GW.LoadGossipSkin()
GW.LoadTimeManagerSkin()
GW.LoadMerchantFrameSkin()
GW.LoadLootFrameSkin()
GW.LoadExpansionLadningPageSkin()
GW.LoadGenericTraitFrameSkin()
GW.LoadDetailsSkin()
GW.LoadImmersionAddonSkin()
GW.AddMasqueSkin()
GW.LoadAuctionatorAddonSkin()
GW.LoadTSMAddonSkin()
GW.SkinAndEnhanceColorPicker()
GW.AddCoordsToWorldMap()
GW.MakeAltPowerBarMovable()
GW.WidgetUISetup()
-- make sure to load the objetives tracker before we load the altert system prevent some errors with other addons
if GW.settings.QUESTTRACKER_ENABLED and not IsIncompatibleAddonLoadedOrOverride("Objectives", true) then
GW.LoadQuestTracker()
end
-- load alert settings
GW.LoadAlertSystem()
GW.SetupAlertFramePosition()
GW.LoadOurAlertSubSystem()
--Create hud art
hudArtFrame = GW.LoadHudArt()
--Create experiencebar
if GW.settings.XPBAR_ENABLED then
GW.LoadXPBar()
else
hudArtFrame.actionBarHud:ClearAllPoints()
hudArtFrame.actionBarHud:SetPoint("BOTTOM", UIParent, "BOTTOM", 0, 0)
hudArtFrame.edgeTintBottomCornerLeft:ClearAllPoints()
hudArtFrame.edgeTintBottomCornerLeft:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 0, 0)
hudArtFrame.edgeTintBottomCornerRight:ClearAllPoints()
hudArtFrame.edgeTintBottomCornerRight:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", 0, 0)
end
if not IsIncompatibleAddonLoadedOrOverride("FloatingCombatText", true) then -- Only touch this setting if no other addon for this is loaded
if GW.settings.GW_COMBAT_TEXT_MODE == "GW2" then
C_CVar.SetCVar("floatingCombatTextCombatDamage", "0")
if GW.settings.GW_COMBAT_TEXT_SHOW_HEALING_NUMBERS then
C_CVar.SetCVar("floatingCombatTextCombatHealing", "0")
else
C_CVar.SetCVar("floatingCombatTextCombatHealing", "1")
end
GW.LoadDamageText(true)
elseif GW.settings.GW_COMBAT_TEXT_MODE == "BLIZZARD" then
C_CVar.SetCVar("floatingCombatTextCombatDamage", "1")
C_CVar.SetCVar("floatingCombatTextCombatHealing", "1")
else
C_CVar.SetCVar("floatingCombatTextCombatDamage", "0")
C_CVar.SetCVar("floatingCombatTextCombatHealing", "0")
end
end
if GW.settings.CASTINGBAR_ENABLED then
GW.LoadCastingBar("GwCastingBarPlayer", "player", true)
GW.LoadCastingBar("GwCastingBarPet", "pet", false)
end
if GW.settings.MINIMAP_ENABLED and not IsIncompatibleAddonLoadedOrOverride("Minimap", true) then
GW.LoadMinimap()
else
QueueStatusButton:ClearAllPoints()
QueueStatusButton:SetPoint("TOPRIGHT", Minimap, "TOPRIGHT", 0, 0)
QueueStatusButton:SetSize(26, 26)
QueueStatusButton:SetParent(UIParent)
end
if GW.settings.TOOLTIPS_ENABLED then
GW.LoadTooltips()
end
if GW.settings.QUESTVIEW_ENABLED and not IsIncompatibleAddonLoadedOrOverride("ImmersiveQuesting", true) then
GW.LoadQuestview()
end
GW.LoadChat()
--Create player hud
if GW.settings.HEALTHGLOBE_ENABLED and not GW.settings.PLAYER_AS_TARGET_FRAME then
local hg = GW.LoadHealthGlobe()
GW.LoadDodgeBar(hg, false)
GW.LoadDragonBar(hg, false)
elseif GW.settings.HEALTHGLOBE_ENABLED and GW.settings.PLAYER_AS_TARGET_FRAME then
local hg = GW.LoadPlayerFrame()
GW.LoadDodgeBar(hg, true)
GW.LoadDragonBar(hg, true)
end
GW.LoadPowerBar()
if not IsIncompatibleAddonLoadedOrOverride("Inventory", true) then -- Only touch this setting if no other addon for this is loaded
if GW.settings.BAGS_ENABLED then
GW.LoadInventory()
end
end
GW.SetUpExtendedVendor()
if GW.settings.USE_BATTLEGROUND_HUD then
GW.LoadBattlegrounds()
end
GW.LoadCharacter()
GW.LoadSocialFrame()
GW.Create_Raid_Counter()
GW.LoadRaidbuffReminder()
GW.LoadMirrorTimers()
GW.LoadAutoRepair()
GW.LoadDragonFlightWorldEvents()
GW.ToggleInterruptAnncouncement()
--Create unitframes
if GW.settings.FOCUS_ENABLED then
GW.LoadFocus()
GW.LoadTargetOfUnit("Focus")
end
if GW.settings.TARGET_ENABLED then
GW.LoadTarget()
GW.LoadTargetOfUnit("Target")
-- move zone text frame
if not IsFrameModified("ZoneTextFrame") then
ZoneTextFrame:ClearAllPoints()
ZoneTextFrame:SetPoint("TOP", UIParent, "TOP", 0, -175)
end
-- move error frame
if not IsFrameModified("UIErrorsFrame") then
UIErrorsFrame:ClearAllPoints()
UIErrorsFrame:SetPoint("TOP", UIParent, "TOP", 0, -190)
UIErrorsFrame:SetFont(STANDARD_TEXT_FONT, 14, "")
end
end
GW.LoadMarkers()
if GW.settings.CLASS_POWER then
GW.LoadClassPowers()
end
-- create action bars
if GW.settings.ACTIONBARS_ENABLED and not IsIncompatibleAddonLoadedOrOverride("Actionbars", true) then
if GW.settings.BAR_LAYOUT_ENABLED then
GW.LoadActionBars(lm, false)
GW.ExtraAB_BossAB_Setup()
else
GW.LoadActionBars(lm, true)
end
end
-- create pet frame
if GW.settings.PETBAR_ENABLED then
GW.LoadPetFrame(lm)
end
-- create buff frame
if GW.settings.PLAYER_BUFFS_ENABLED then
GW.LoadPlayerAuras(lm)
end
if not IsIncompatibleAddonLoadedOrOverride("DynamicCam", true) then -- Only touch this setting if no other addon for this is loaded
if GW.settings.DYNAMIC_CAM then
C_CVar.SetCVar("test_cameraDynamicPitch", "1")
C_CVar.SetCVar("cameraKeepCharacterCentered", "0")
C_CVar.SetCVar("cameraReduceUnexpectedMovement", "0")
end
hooksecurefunc("StaticPopup_Show", function(which)
if which == "EXPERIMENTAL_CVAR_WARNING" then
StaticPopup_Hide("EXPERIMENTAL_CVAR_WARNING")
end
end)
end
GW.loadAFKAnimation()
if GW.settings.CHATBUBBLES_ENABLED then
GW.LoadChatBubbles()
end
-- create new microbuttons
GW.LoadMicroMenu()
GW.LoadOrderBar()
if GW.settings.PARTY_FRAMES then
GW.LoadPartyFrames()
end
if GW.settings.RAID_FRAMES then
GW.InitializeRaidFrames()
end
GW.UpdateHudScale()
if (forcedMABags) then
GW.Notice(L["MoveAnything bag handling disabled."])
end
--Check if we should show Welcomepage or Changelog
if GW.private.GW2_UI_VERSION == "WELCOME" then
GW.ShowWelcomePanel()
GW.private.GW2_UI_VERSION = GW.VERSION_STRING
elseif GW.private.GW2_UI_VERSION ~= GW.VERSION_STRING then
ShowUIPanel(GwSettingsWindow)
HideUIPanel(GameMenuFrame)
GW.private.GW2_UI_VERSION = GW.VERSION_STRING
end
self:SetScript("OnUpdate", gw_OnUpdate)
GW.UpdateCharData()
GW.HandleBlizzardEditMode()
end
AFP("evPlayerLogin", evPlayerLogin)
-- generic event router
local function gw_OnEvent(self, event, ...)
if event == "PLAYER_LOGIN" then
evPlayerLogin(self)
elseif event == "UI_SCALE_CHANGED" then
C_Timer.After(0, evUiScaleChanged) -- We need one frame time for setting the cvar values
elseif event == "PLAYER_LEAVING_WORLD" then
evPlayerLeavingWorld()
elseif event == "PLAYER_ENTERING_WORLD" then
evPlayerEnteringWorld()
elseif event == "PLAYER_ENTERING_BATTLEGROUND" then
evPlayerEnteringBattleground()
elseif event == "PLAYER_LEVEL_UP" then
evPlayerLevelUp(self, ...)
elseif event == "NEUTRAL_FACTION_SELECT_RESULT" then
evNeutralFactionSelectResult()
elseif event == "PLAYER_SPECIALIZATION_CHANGED" then
evPlayerSpecializationChanged()
elseif event == "ADDON_LOADED" then
evAddonLoaded(self, ...)
end
end
AFP("gw_OnEvent", gw_OnEvent)
l:SetScript("OnEvent", gw_OnEvent)
l:RegisterEvent("PLAYER_LOGIN")
l:RegisterEvent("PLAYER_LEAVING_WORLD")
l:RegisterEvent("PLAYER_ENTERING_WORLD")
l:RegisterEvent("PLAYER_ENTERING_BATTLEGROUND")
l:RegisterEvent("UI_SCALE_CHANGED")
l:RegisterEvent("PLAYER_LEVEL_UP")
l:RegisterEvent("NEUTRAL_FACTION_SELECT_RESULT")
l:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED")
l:RegisterEvent("ADDON_LOADED")
local function AddToClique(frame)
if type(frame) == "string" then
local frameName = frame
frame = _G[frameName]
end
if frame and frame.RegisterForClicks and ClickCastFrames ~= nil then
ClickCastFrames[frame] = true
end
end
GW.AddToClique = AddToClique
local waitTable = {}
local waitFrame = nil
local function wait_OnUpdate(_, elapse)
local count = #waitTable
local i = 1
while (i <= count) do
local waitRecord = tremove(waitTable, i)
local d = tremove(waitRecord, 1)
local f = tremove(waitRecord, 1)
local p = tremove(waitRecord, 1)
if (d > elapse) then
tinsert(waitTable, i, {d - elapse, f, p})
i = i + 1
else
count = count - 1
f(unpack(p))
end
end
end
AFP("wait_OnUpdate", wait_OnUpdate)
local function Wait(delay, func, ...)
if type(delay) ~= "number" or type(func) ~= "function" then
return false
end
if waitFrame == nil then
waitFrame = CreateFrame("Frame", "GwWaitFrame", UIParent)
waitFrame:SetScript("OnUpdate", wait_OnUpdate)
end
tinsert(waitTable, {delay, func, {...}})
return true
end
GW.Wait = Wait
local function Self_Hide(self)
self:Hide()
end
GW.Self_Hide = Self_Hide
local function Parent_Hide(self)
self:GetParent():Hide()
end
GW.Parent_Hide = Parent_Hide