forked from parnic/ice-hud
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIceCore.lua
More file actions
1274 lines (1075 loc) · 35 KB
/
IceCore.lua
File metadata and controls
1274 lines (1075 loc) · 35 KB
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 L = LibStub("AceLocale-3.0"):GetLocale("IceHUD", false)
function IceCore_CreateClass(parent)
local class = { prototype = {} }
if parent then
class.super = parent
setmetatable(class.prototype, { __index = parent.prototype })
end
local mt = { __index = class.prototype }
function class:new(...)
local self = setmetatable({}, mt)
if self.init then
self:init(...)
end
return self
end
return class
end
local DogTag = LibStub("LibDogTag-3.0", true)
local GetSpellInfo = GetSpellInfo
if not GetSpellInfo and C_Spell and C_Spell.GetSpellInfo then
GetSpellInfo = function(spellID)
if not spellID then
return nil
end
local spellInfo = C_Spell.GetSpellInfo(spellID)
if spellInfo then
return spellInfo.name, nil, spellInfo.iconID, spellInfo.castTime, spellInfo.minRange, spellInfo.maxRange, spellInfo.spellID, spellInfo.originalIconID
end
end
end
local GetSpellName = GetSpellInfo
if C_Spell and C_Spell.GetSpellName then
GetSpellName = C_Spell.GetSpellName
end
IceCore = IceCore_CreateClass()
IceCore.Side = { Left = "LEFT", Right = "RIGHT" }
IceCore.BuffLimit = 40
IceCore.prototype.defaults = {}
IceCore.prototype.settings = nil
IceCore.prototype.IceHUDFrame = nil
IceCore.prototype.updatees = {}
IceCore.prototype.update_elapsed = 0
IceCore.prototype.elements = {}
IceCore.prototype.enabled = nil
IceCore.prototype.presets = {}
IceCore.prototype.bConfigMode = false
IceCore.TextDecorationStyle = {
Shadow = L["Shadow"],
Outline = L["Outline"],
ThickOutline = L["Thick outline"],
NoDecoration = L["No decoration"],
}
local ZM_MAP_ID = 1970
IceCore.zmPuzzleIds = {
--Fugueal Protolock
366046,
366108,
359488,
--Mezzonic Protolock
366042,
366106,
351405,
--Cantaric Protolock
365840,
366107,
348792,
}
IceCore.zmPuzzleMap = {}
for i=1, #IceCore.zmPuzzleIds do
IceCore.zmPuzzleMap[IceCore.zmPuzzleIds[i]] = true
end
local SUNDER_SPELL_ID = 7386
local LACERATE_SPELL_ID = 33745
local MAELSTROM_SPELL_ID = 53817
-- Constructor --
function IceCore.prototype:init()
IceHUD:Debug("IceCore.prototype:init()")
self.IceHUDFrame = CreateFrame("Frame","IceHUDFrame", UIParent)
end
function IceCore.prototype:SetupDefaults()
-- DEFAULT SETTINGS
local defaultPreset = "RoundBar"
self.defaults = {
profile = {
enable = true,
gap = 150,
verticalPos = -110,
horizontalPos = 0,
scale = 0.9,
alphaooc = 0.3,
alphaic = 0.6,
alphaTarget = 0.4,
alphaNotFull = 0.4,
alphaoocbg = 0.2,
alphaicbg = 0.3,
alphaTargetbg = 0.25,
alphaNotFullbg = 0.25,
bTreatFriendlyAsTarget = true,
backgroundToggle = false,
backgroundColor = {r = 0.5, g = 0.5, b = 0.5},
barTexture = "Bar",
barPreset = defaultPreset,
fontFamily = "Arial Narrow",
debug = false,
barBlendMode = "BLEND",
barBgBlendMode = "BLEND",
bShouldUseDogTags = true,
updatePeriod = 0.033,
minimap = {},
TextDecoration = "Shadow",
bHideDuringPetBattles = true,
bHideInBarberShop = true,
bHideDuringShellGame = true,
bHideDuringCataloging = true,
addedStrata = 0,
},
global = {
lastRunVersion = 0,
},
}
self:LoadPresets()
for k, v in pairs(self.presets[defaultPreset]) do
self.defaults.profile[k] = v
end
-- get default settings from the modules
self.defaults.profile.modules = {}
for i = 1, table.getn(self.elements) do
local name = self.elements[i]:GetElementName()
self.defaults.profile.modules[name] = self.elements[i]:GetDefaultSettings()
end
if (table.getn(self.elements) > 0) then
self.defaults.profile.colors = self.elements[1].defaultColors
end
end
StaticPopupDialogs["ICEHUD_CONVERTED_TO_ACE3"] =
{
text = "(If this is your first time running IceHUD, please disregard this message)\n\nSince the last version of IceHUD you ran, we have upgraded to Ace3! This means that if you were using a custom profile for your settings you may need to open the /icehud options and re-choose it. You'll only need to do this once.\n\nThanks for using IceHUD!",
button1 = OKAY,
timeout = 0,
whileDead = 1,
hideOnEscape = 0,
}
StaticPopupDialogs["ICEHUD_UPDATE_PERIOD_MATTERS"] =
{
text = L["Since the last time you updated IceHUD, many significant CPU and memory optimizations have been made. If bar animation looks jumpy to you, open the /icehud configuration page and raise the 'Update Period' slider. This will cause higher CPU usage but will look nicer. Enjoy IceHUD!"],
button1 = OKAY,
timeout = 0,
whileDead = 1,
hideOnEscape = 0,
}
function IceCore.prototype:CheckDisplayUpdateMessage()
local thisVersion
--[===[@non-debug@
thisVersion = @project-date-integer@
--@end-non-debug@]===]
--@debug@
thisVersion = 99999999999999
--@end-debug@
if self.accountSettings.lastRunVersion < thisVersion then
if self.accountSettings.lastRunVersion < 549 then
--StaticPopup_Show("ICEHUD_CONVERTED_TO_ACE3")
end
if self.accountSettings.lastRunVersion < 707 and self.accountSettings.lastRunVersion > 0 then
-- update from the old default that may have been saved with the user's settings
if self.settings.updatePeriod == 0.1 then
self.settings.updatePeriod = 0.033
end
--StaticPopup_Show("ICEHUD_UPDATE_PERIOD_MATTERS")
end
if self.accountSettings.lastRunVersion < 710 then
if self.settings.modules["MaelstromCount"] == nil then
self.settings.modules["MaelstromCount"] = {}
end
if self.settings.modules["SunderCount"] == nil then
self.settings.modules["SunderCount"] = {}
end
if self.settings.modules["LacerateCount"] == nil then
self.settings.modules["LacerateCount"] = {}
end
end
if self.accountSettings.lastRunVersion <= 20160527053225 then
if self.settings.modules["DruidMana"] ~= nil then
self.settings.modules["PlayerAltMana"] = self.settings.modules["DruidMana"]
self.settings.modules["DruidMana"] = nil
end
end
if self.accountSettings.lastRunVersion <= 20180720033008 then
if self.settings.modules["HarmonyPower"] ~= nil then
self.settings.modules["Chi"] = self.settings.modules["HarmonyPower"]
self.settings.modules["HarmonyPower"] = nil
self.settings.colors["ChiNumeric"] = self.settings.colors["HarmonyPowerNumeric"]
end
end
self.accountSettings.lastRunVersion = thisVersion
end
end
function IceCore.prototype:Enable(userToggle)
if userToggle then
self.settings.enable = true
end
self:DrawFrame()
for i = 1, table.getn(self.elements) do
-- make sure there are settings for this bar (might not if we make a new profile with existing custom bars)
if self.settings.modules[self.elements[i].elementName] then
self.elements[i]:Create(self.IceHUDFrame)
if (self.elements[i]:IsEnabled()) then
self.elements[i]:Enable(true)
end
end
end
-- go through the list of loaded elements that don't have associated settings and dump them
do
local toRemove = {}
for i = #self.elements, 1, -1 do
if not self.settings.modules[self.elements[i]:GetElementName()] then
toRemove[#toRemove + 1] = i
end
end
for i=1,#toRemove do
table.remove(self.elements, toRemove[i])
end
end
for k,v in pairs(self.settings.modules) do
local newModule
if self.settings.modules[k].customBarType == "Bar" and IceCustomBar ~= nil then
newModule = IceCustomBar:new()
elseif self.settings.modules[k].customBarType == "Counter" and IceCustomCount ~= nil then
newModule = IceCustomCount:new()
elseif self.settings.modules[k].customBarType == "CounterBar" and IceCustomCounterBar ~= nil then
newModule = IceCustomCounterBar:new()
elseif self.settings.modules[k].customBarType == "CD" and IceCustomCDBar ~= nil then
newModule = IceCustomCDBar:new()
elseif self.settings.modules[k].customBarType == "Health" and IceCustomHealth ~= nil then
newModule = IceCustomHealth:new()
elseif self.settings.modules[k].customBarType == "Mana" and IceCustomMana ~= nil then
newModule = IceCustomMana:new()
end
if newModule ~= nil then
newModule.elementName = k
self:AddNewDynamicModule(newModule, true)
end
end
if self.settings.updatePeriod == nil then
self.settings.updatePeriod = 0.033
end
self.settings.updatePeriod = IceHUD:Clamp(self.settings.updatePeriod, 0, 0.067)
self:RedirectRemovedModules()
-- make sure the module options are re-generated. if we switched profiles, we don't want the old elements hanging around
if IceHUD.optionsLoaded then
IceHUD_Options:GenerateModuleOptions()
end
if UnitCanPetBattle then
self.IceHUDFrame:RegisterEvent("PET_BATTLE_OPENING_START")
self.IceHUDFrame:RegisterEvent("PET_BATTLE_OVER")
end
if GetBarberShopStyleInfo then
self.IceHUDFrame:RegisterEvent("BARBER_SHOP_OPEN")
self.IceHUDFrame:RegisterEvent("BARBER_SHOP_CLOSE")
end
if C_Map then
self.IceHUDFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
self.IceHUDFrame:RegisterEvent("ZONE_CHANGED")
end
self.IceHUDFrame:RegisterEvent("UNIT_AURA")
self.IceHUDFrame:RegisterEvent("UNIT_ENTERED_VEHICLE")
self.IceHUDFrame:RegisterEvent("PLAYER_REGEN_ENABLED", IceHUD.PLAYER_REGEN_ENABLED)
self.IceHUDFrame:RegisterEvent("PLAYER_REGEN_DISABLED", IceHUD.PLAYER_REGEN_DISABLED)
self.IceHUDFrame:SetScript("OnEvent", function(self, event, ...)
if (event == "PET_BATTLE_OPENING_START") then
if IceHUD.IceCore.settings.bHideDuringPetBattles then
self:Hide()
end
elseif (event == "PET_BATTLE_OVER") then
if IceHUD.IceCore.settings.bHideDuringPetBattles then
self:Show()
end
elseif (event == "BARBER_SHOP_OPEN") then
if IceHUD.IceCore.settings.bHideInBarberShop then
self:Hide()
end
elseif (event == "BARBER_SHOP_CLOSE") then
if IceHUD.IceCore.settings.bHideInBarberShop then
self:Show()
end
elseif event == "UNIT_ENTERED_VEHICLE" then
if IceHUD.IceCore.settings.bHideDuringCataloging and IceHUD:HasAnyBuff("player", IceHUD.CatalogingSpellIDs) then
self:RegisterEvent("UNIT_EXITED_VEHICLE")
self:Hide()
end
elseif (event == "UNIT_AURA") then
local unit = ...
if unit ~= "player" then
return
end
if IceHUD.IceCore.settings.bHideDuringShellGame and IceHUD:HasAnyDebuff("player", {IceHUD.ShellGameSpellID}) and UnitInVehicle("player") then
self:RegisterEvent("UNIT_EXITED_VEHICLE")
self:Hide()
elseif IceHUD.IceCore.settings.bHideDuringCataloging and IceHUD:HasAnyBuff("player", IceHUD.CatalogingSpellIDs) and UnitInVehicle("player") then
self:RegisterEvent("UNIT_EXITED_VEHICLE")
self:Hide()
elseif C_Map then
local bestMapID = C_Map.GetBestMapForUnit("player")
if bestMapID ~= ZM_MAP_ID then
return
end
if IceHUD:HasAnyBuff("player", IceCore.zmPuzzleIds) then
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
self:Hide()
end
end
elseif (event == "UNIT_EXITED_VEHICLE") then
self:UnregisterEvent("UNIT_EXITED_VEHICLE")
self:Show()
elseif (event == "PLAYER_ENTERING_WORLD" or event == "ZONE_CHANGED") then
if C_Map then
local bestMapID = C_Map.GetBestMapForUnit("player")
if bestMapID == ZM_MAP_ID then
if IceHUD:HasAnyBuff("player", IceCore.zmPuzzleIds) then
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
self:Hide()
end
end
end
elseif (event == "COMBAT_LOG_EVENT_UNFILTERED") then
local _,subevent,_,_,_,_,_,_,destName,_,_,spellId = CombatLogGetCurrentEventInfo()
if subevent == "SPELL_AURA_REMOVED" then
if destName == UnitName("player") then
if IceCore.zmPuzzleMap[spellId] then
self:Show()
self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end
end
end
end
end)
self.enabled = true
end
function IceCore.prototype:RedirectRemovedModules()
local _, class = UnitClass("player")
if class == "WARRIOR" and self.settings.modules["SunderCount"] and GetSpellName(SUNDER_SPELL_ID) and IceHUD.WowVer < 60000 then
if self.settings.modules["SunderCount"].enabled or self.settings.modules["SunderCount"].enabled == nil then
local bFound = false
for k,v in pairs(self.elements) do
if v.moduleSettings.customBarType == "Counter" and v.moduleSettings.auraName
and string.upper(v.moduleSettings.auraName) == string.upper(GetSpellName(SUNDER_SPELL_ID)) then
bFound = true
break
end
end
if not bFound then
local newCounter
newCounter = IceCustomCount:new()
newCounter.elementName = "Sunders"
self.settings.modules[newCounter.elementName] = newCounter:GetDefaultSettings()
self:AddNewDynamicModule(newCounter, true)
newCounter.moduleSettings.alwaysFullAlpha = self.settings.modules["SunderCount"].alwaysFullAlpha or newCounter.moduleSettings.alwaysFullAlpha
newCounter.moduleSettings.scale = self.settings.modules["SunderCount"].scale or newCounter.moduleSettings.scale
newCounter.moduleSettings.vpos = self.settings.modules["SunderCount"].vpos or newCounter.moduleSettings.vpos
newCounter.moduleSettings.countFontSize = self.settings.modules["SunderCount"].sunderFontSize or newCounter.moduleSettings.countFontSize
newCounter.moduleSettings.countMode = self.settings.modules["SunderCount"].sunderMode or newCounter.moduleSettings.countMode
newCounter.moduleSettings.countGap = self.settings.modules["SunderCount"].sunderGap or newCounter.moduleSettings.countGap
newCounter.moduleSettings.gradient = self.settings.modules["SunderCount"].gradient or newCounter.moduleSettings.gradient
newCounter.moduleSettings.maxCount = 3
newCounter.moduleSettings.auraTarget = "target"
newCounter.moduleSettings.auraType = "debuff"
newCounter.moduleSettings.auraName = GetSpellName(SUNDER_SPELL_ID)
newCounter:Enable()
end
end
self.settings.modules["SunderCount"] = nil
end
if class == "DRUID" and self.settings.modules["LacerateCount"] and GetSpellName(LACERATE_SPELL_ID) then
if self.settings.modules["LacerateCount"].enabled or self.settings.modules["LacerateCount"].enabled == nil then
local bFound = false
for k,v in pairs(self.elements) do
if v.moduleSettings.customBarType == "Counter" and v.moduleSettings.auraName
and string.upper(v.moduleSettings.auraName) == string.upper(GetSpellName(LACERATE_SPELL_ID)) then
bFound = true
break
end
end
if not bFound then
local newCounter
newCounter = IceCustomCount:new()
newCounter.elementName = "Lacerates"
self.settings.modules[newCounter.elementName] = newCounter:GetDefaultSettings()
self:AddNewDynamicModule(newCounter, true)
newCounter.moduleSettings.alwaysFullAlpha = self.settings.modules["LacerateCount"].alwaysFullAlpha or newCounter.moduleSettings.alwaysFullAlpha
newCounter.moduleSettings.scale = self.settings.modules["LacerateCount"].scale or newCounter.moduleSettings.scale
newCounter.moduleSettings.vpos = self.settings.modules["LacerateCount"].vpos or newCounter.moduleSettings.vpos
newCounter.moduleSettings.hpos = self.settings.modules["LacerateCount"].hpos or newCounter.moduleSettings.hpos
newCounter.moduleSettings.countFontSize = self.settings.modules["LacerateCount"].lacerateFontSize or newCounter.moduleSettings.countFontSize
newCounter.moduleSettings.countMode = self.settings.modules["LacerateCount"].lacerateMode or newCounter.moduleSettings.countMode
newCounter.moduleSettings.countGap = self.settings.modules["LacerateCount"].lacerateGap or newCounter.moduleSettings.countGap
newCounter.moduleSettings.gradient = self.settings.modules["LacerateCount"].gradient or newCounter.moduleSettings.gradient
newCounter.moduleSettings.maxCount = 3
newCounter.moduleSettings.auraTarget = "target"
newCounter.moduleSettings.auraType = "debuff"
newCounter.moduleSettings.auraName = GetSpellName(LACERATE_SPELL_ID)
newCounter:Enable()
end
end
self.settings.modules["LacerateCount"] = nil
end
if class == "SHAMAN" and self.settings.modules["MaelstromCount"] and GetSpellName(MAELSTROM_SPELL_ID) then
if self.settings.modules["MaelstromCount"].enabled or self.settings.modules["MaelstromCount"].enabled == nil then
local bFound = false
for k,v in pairs(self.elements) do
if v.moduleSettings.customBarType == "Counter" and v.moduleSettings.auraName
and string.upper(v.moduleSettings.auraName) == string.upper(GetSpellName(MAELSTROM_SPELL_ID)) then
bFound = true
break
end
end
if not bFound then
local newCounter
newCounter = IceCustomCount:new()
newCounter.elementName = "Maelstroms"
self.settings.modules[newCounter.elementName] = newCounter:GetDefaultSettings()
self:AddNewDynamicModule(newCounter, true)
newCounter.moduleSettings.alwaysFullAlpha = self.settings.modules["MaelstromCount"].alwaysFullAlpha or newCounter.moduleSettings.alwaysFullAlpha
newCounter.moduleSettings.scale = self.settings.modules["MaelstromCount"].scale or newCounter.moduleSettings.scale
newCounter.moduleSettings.vpos = self.settings.modules["MaelstromCount"].vpos or newCounter.moduleSettings.vpos
newCounter.moduleSettings.countFontSize = self.settings.modules["MaelstromCount"].maelstromFontSize or newCounter.moduleSettings.countFontSize
newCounter.moduleSettings.countMode = self.settings.modules["MaelstromCount"].maelstromMode or newCounter.moduleSettings.countMode
newCounter.moduleSettings.countGap = self.settings.modules["MaelstromCount"].maelstromGap or newCounter.moduleSettings.countGap
newCounter.moduleSettings.gradient = self.settings.modules["MaelstromCount"].gradient or newCounter.moduleSettings.gradient
newCounter.moduleSettings.auraName = GetSpellName(MAELSTROM_SPELL_ID)
newCounter:Enable()
end
end
self.settings.modules["MaelstromCount"] = nil
end
end
function IceCore.prototype:AddNewDynamicModule(module, hasSettings)
if not hasSettings then
self.settings.modules[module.elementName] = module:GetDefaultSettings()
elseif type(hasSettings) == "table" then
self.settings.modules[module.elementName] = IceHUD.deepcopy(hasSettings)
end
module:SetDatabase(self.settings)
if not hasSettings or type(hasSettings) == "table" then
local numExisting = self:GetNumCustomModules(module, module:GetDefaultSettings().customBarType)
self:RenameDynamicModule(module, "MyCustom"..module:GetDefaultSettings().customBarType..(numExisting+1))
end
module:Create(self.IceHUDFrame)
if (module:IsEnabled()) then
module:Enable(true)
end
if IceHUD.optionsLoaded then
IceHUD_Options:GenerateModuleOptions()
end
end
function IceCore.prototype:GetNumCustomModules(exceptMe, customBarType)
local num = 0
local foundNum = 0
for i=1,table.getn(self.elements) do
if (self.elements[i] and self.elements[i] ~= exceptMe and
customBarType == self.elements[i].moduleSettings.customBarType) then
local str = self.elements[i].elementName:match("MyCustom"..(customBarType).."%d+")
if str then
foundNum = str:match("%d+")
end
num = max(num, foundNum)
end
end
return num
end
function IceCore.prototype:DeleteDynamicModule(module)
if module:IsEnabled() then
module:Disable()
end
local ndx
for i = 1,table.getn(self.elements) do
if (self.elements[i] == module) then
ndx = i
break
end
end
table.remove(self.elements,ndx)
self.settings.modules[module.elementName] = nil
if IceHUD.optionsLoaded then
IceHUD_Options:GenerateModuleOptions()
end
end
function IceCore.prototype:RenameDynamicModule(module, newName)
self.settings.modules[newName] = self.settings.modules[module.elementName]
self.settings.modules[module.elementName] = nil
module.elementName = newName
if IceHUD.optionsLoaded then
IceHUD_Options:GenerateModuleOptions()
end
LibStub("AceConfigDialog-3.0"):SelectGroup("IceHUD", "modules", newName)
end
function IceCore.prototype:ProfileChanged()
self:SetModuleDatabases()
self:Redraw()
end
function IceCore.prototype:SetModuleDatabases()
for i = 1, table.getn(self.elements) do
self.elements[i]:SetDatabase(self.settings)
end
end
function IceCore.prototype:Disable(userToggle)
if userToggle then
self.settings.enable = false
end
self:ConfigModeToggle(false)
for i=1, #self.elements do
if (self.elements[i]:IsEnabled()) then
self.elements[i]:Disable(true)
end
end
self.IceHUDFrame:Hide()
self:EmptyUpdates()
for i=#self.elements, 1, -1 do
if self.elements[i].moduleSettings.customBarType ~= nil then
table.remove(self.elements, i)
end
end
if UnitCanPetBattle then
self.IceHUDFrame:UnregisterEvent("PET_BATTLE_OPENING_START")
self.IceHUDFrame:UnregisterEvent("PET_BATTLE_OVER")
end
if GetBarberShopStyleInfo then
self.IceHUDFrame:UnregisterEvent("BARBER_SHOP_OPEN")
self.IceHUDFrame:UnregisterEvent("BARBER_SHOP_CLOSE")
end
self.IceHUDFrame:SetScript("OnEvent", nil)
self.enabled = false
end
function IceCore.prototype:IsEnabled()
return self.enabled
end
function IceCore.prototype:DrawFrame()
self.IceHUDFrame:SetFrameStrata(self:DetermineStrata("BACKGROUND"))
self.IceHUDFrame:SetWidth(self.settings.gap)
self.IceHUDFrame:SetHeight(20)
self:SetScale(self.settings.scale)
self.IceHUDFrame:SetPoint("CENTER", self.settings.horizontalPos, self.settings.verticalPos)
self.IceHUDFrame:Show()
end
function IceCore.prototype:Redraw()
for i = 1, table.getn(self.elements) do
self.elements[i]:Redraw()
end
end
function IceCore.prototype:GetModuleOptions()
local options = {}
options["aaaClickPlus"] = {
type = 'description',
fontSize = 'large',
name = L["Click the + next to |cffffdc42Module Settings|r to see the available modules that you can tweak.\n\nAlso notice that some modules have a + next to them. This will open up additional settings such as text tweaks and icon tweaks on that module."],
order = 1
}
options["bbbGlobalTextSettings"] = {
type = 'select',
name = L["Text appearance"],
desc = L["This controls how all non-DogTag text on all modules appears.\n\nNOTE: Requires a UI reload to take effect."],
get = function(info)
return self.settings.TextDecoration
end,
set = function(info, v)
self.settings.TextDecoration = v
StaticPopup_Show("ICEHUD_CHANGED_DOGTAG")
end,
values = IceCore.TextDecorationStyle,
order = 2
}
for i = 1, table.getn(self.elements) do
local modName = self.elements[i]:GetElementName()
local modDesc = self.elements[i]:GetElementDescription()
local opt = self.elements[i]:GetOptions()
options[modName] = {
type = 'group',
desc = modDesc,
name = modName,
args = opt
}
end
return options
end
function IceCore.prototype:GetColorOptions()
local options = {}
if #self.elements > 0 then
for k, v in pairs(self.elements[1]:GetColors()) do
options[k] = {
type = 'color',
desc = k,
name = k,
get = function()
return IceHUD.IceCore:GetColor(k)
end,
set = function(info, r, g, b)
local color = k
IceHUD.IceCore:SetColor(k, r, g, b)
end
}
end
end
return options
end
-- Method to handle module registration
function IceCore.prototype:Register(element)
assert(element, "Trying to register a nil module")
IceHUD:Debug("Registering: " .. element:ToString())
table.insert(self.elements, element)
end
-------------------------------------------------------------------------------
-- Configuration methods --
-------------------------------------------------------------------------------
function IceCore.prototype:GetVerticalPos()
return self.settings.verticalPos
end
function IceCore.prototype:SetVerticalPos(value)
self.settings.verticalPos = value
self.IceHUDFrame:ClearAllPoints()
self.IceHUDFrame:SetPoint("CENTER", self.settings.horizontalPos, self.settings.verticalPos)
end
function IceCore.prototype:GetHorizontalPos()
return self.settings.horizontalPos
end
function IceCore.prototype:SetHorizontalPos(value)
self.settings.horizontalPos = value
self.IceHUDFrame:ClearAllPoints()
self.IceHUDFrame:SetPoint("CENTER", self.settings.horizontalPos, self.settings.verticalPos)
end
function IceCore.prototype:GetGap()
return self.settings.gap
end
function IceCore.prototype:SetGap(value)
self.settings.gap = value
self.IceHUDFrame:SetWidth(self.settings.gap)
self:Redraw()
end
function IceCore.prototype:GetScale()
return self.settings.scale
end
function IceCore.prototype:SetScale(value)
self.settings.scale = value
self.IceHUDFrame:SetScale(value)
end
function IceCore.prototype:GetAlpha(mode)
if (mode == "IC") then
return self.settings.alphaic
elseif (mode == "Target") then
return self.settings.alphaTarget
elseif (mode == "NotFull") then
return self.settings.alphaNotFull
else
return self.settings.alphaooc
end
end
function IceCore.prototype:SetAlpha(mode, value)
if (mode == "IC") then
self.settings.alphaic = value
elseif (mode == "Target") then
self.settings.alphaTarget = value
elseif (mode == "NotFull") then
self.settings.alphaNotFull = value
else
self.settings.alphaooc = value
end
self:Redraw()
end
function IceCore.prototype:GetAlphaBG(mode)
if (mode == "IC") then
return self.settings.alphaicbg
elseif (mode == "Target") then
return self.settings.alphaTargetbg
elseif (mode == "NotFull") then
return self.settings.alphaNotFullbg
else
return self.settings.alphaoocbg
end
end
function IceCore.prototype:SetAlphaBG(mode, value)
if (mode == "IC") then
self.settings.alphaicbg = value
elseif (mode == "Target") then
self.settings.alphaTargetbg = value
elseif (mode == "NotFull") then
self.settings.alphaNotFullbg = value
else
self.settings.alphaoocbg = value
end
self:Redraw()
end
function IceCore.prototype:GetBackgroundToggle()
return self.settings.backgroundToggle
end
function IceCore.prototype:SetBackgroundToggle(value)
self.settings.backgroundToggle = value
self:Redraw()
end
function IceCore.prototype:GetBackgroundColor()
local c = self.settings.backgroundColor
return c.r, c.g, c.b
end
function IceCore.prototype:SetBackgroundColor(r, g, b)
self.settings.backgroundColor.r = r
self.settings.backgroundColor.g = g
self.settings.backgroundColor.b = b
self:Redraw()
end
function IceCore.prototype:GetBarTexture()
return self.settings.barTexture
end
function IceCore.prototype:SetBarTexture(value)
self.settings.barTexture = value
self:Redraw()
end
function IceCore.prototype:GetBarBlendMode()
return self.settings.barBlendMode
end
function IceCore.prototype:SetBarBlendMode(value)
self.settings.barBlendMode = value
self:Redraw()
end
function IceCore.prototype:GetBarBgBlendMode()
return self.settings.barBgBlendMode
end
function IceCore.prototype:SetBarBgBlendMode(value)
self.settings.barBgBlendMode = value
self:Redraw()
end
function IceCore.prototype:GetBarWidth()
return self.settings.barWidth
end
function IceCore.prototype:SetBarWidth(value)
self.settings.barWidth = value
self:Redraw()
end
function IceCore.prototype:GetBarHeight()
return self.settings.barHeight
end
function IceCore.prototype:SetBarHeight(value)
self.settings.barHeight = value
self:Redraw()
end
function IceCore.prototype:GetBarProportion()
return self.settings.barProportion
end
function IceCore.prototype:SetBarProportion(value)
self.settings.barProportion = value
self:Redraw()
end
function IceCore.prototype:GetBarSpace()
return self.settings.barSpace
end
function IceCore.prototype:SetBarSpace(value)
self.settings.barSpace = value
self:Redraw()
end
function IceCore.prototype:GetBarPreset()
return self.settings.barPreset
end
function IceCore.prototype:SetBarPreset(value)
self.settings.barPreset = value
self:ChangePreset(value)
self:Redraw()
end
function IceCore.prototype:ChangePreset(value)
self:SetBarTexture(self.presets[value].barTexture)
self:SetBarHeight(self.presets[value].barHeight)
self:SetBarWidth(self.presets[value].barWidth)
self:SetBarSpace(self.presets[value].barSpace)
self:SetBarProportion(self.presets[value].barProportion)
self:SetBarBlendMode(self.presets[value].barBlendMode)
self:SetBarBgBlendMode(self.presets[value].barBgBlendMode)
IceHUD:NotifyOptionsChange()
end
function IceCore.prototype:GetFontFamily()
return self.settings.fontFamily
end
function IceCore.prototype:SetFontFamily(value)
self.settings.fontFamily = value
self:Redraw()
end
function IceCore.prototype:GetDebug()
return self.settings.debug
end
function IceCore.prototype:SetDebug(value)
self.settings.debug = value
IceHUD:SetDebugging(value)
end
function IceCore.prototype:GetColor(color)
return self.settings.colors[color].r,
self.settings.colors[color].g,
self.settings.colors[color].b
end
function IceCore.prototype:SetColor(color, r, g, b)
self.settings.colors[color].r = r
self.settings.colors[color].g = g
self.settings.colors[color].b = b
self:Redraw()
end
function IceCore.prototype:GetAddedStrata()
return self.settings.addedStrata
end
function IceCore.prototype:SetAddedStrata(value)
self.settings.addedStrata = value
end
-- Preventing ugly if-else blocks in module creations
-- (but could probably itself be smarter/prettier)
-- Frisbees/AddonWhiner
function IceCore.prototype:DetermineStrata(baseStrata)
if self.settings.addedStrata == 0 then
return baseStrata
end
if self.settings.addedStrata == 1 then
if baseStrata == "BACKGROUND" then
return "LOW"
elseif baseStrata == "LOW" then
return "MEDIUM"
elseif baseStrata == "MEDIUM" then
return "HIGH"
elseif baseStrata == "HIGH" then
return "DIALOG"
end
end
if self.settings.addedStrata == 2 then
if baseStrata == "BACKGROUND" then
return "MEDIUM"
elseif baseStrata == "LOW" then
return "HIGH"
elseif baseStrata == "MEDIUM" then
return "DIALOG"
elseif baseStrata == "HIGH" then
return "FULLSCREEN"
end
end
return baseStrata -- failsafe
end
function IceCore.prototype:IsInConfigMode()
return self.bConfigMode
end