-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathIceBarElement.lua
1647 lines (1430 loc) · 45.5 KB
/
IceBarElement.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
local L = LibStub("AceLocale-3.0"):GetLocale("IceHUD", false)
local DogTag = nil
local IceHUD = _G.IceHUD
IceBarElement = IceCore_CreateClass(IceElement)
IceBarElement.BarTextureWidth = 128
IceBarElement.prototype.barFrame = nil
IceBarElement.prototype.CurrLerpTime = 0
IceBarElement.prototype.LastScale = 1
IceBarElement.prototype.DesiredScale = 1
IceBarElement.prototype.CurrScale = 1
IceBarElement.prototype.Markers = {}
IceBarElement.prototype.IsBarElement = true -- cheating to avoid crawling up the 'super' references looking for this class. see IceCore.lua
IceBarElement.prototype.bTreatEmptyAsFull = false
local lastMarkerPosConfig = 50
local lastMarkerColorConfig = {r=1, b=0, g=0, a=1}
local lastMarkerHeightConfig = 6
local lastEditMarkerConfig = 1
-- Constructor --
function IceBarElement.prototype:init(name, ...)
IceBarElement.super.prototype.init(self, name, ...)
end
-- 'Public' methods -----------------------------------------------------------
-- OVERRIDE
function IceBarElement.prototype:Enable()
IceBarElement.super.prototype.Enable(self)
self:ConditionalSetupUpdate()
if IceHUD.IceCore:ShouldUseDogTags() then
DogTag = LibStub("LibDogTag-3.0", true)
if DogTag then
LibStub("LibDogTag-Unit-3.0", true)
end
end
if self.moduleSettings.myTagVersion < IceHUD.CurrTagVersion then
local origDefaults = self:GetDefaultSettings()
self.moduleSettings.upperText = origDefaults["upperText"]
self.moduleSettings.lowerText = origDefaults["lowerText"]
self.moduleSettings.myTagVersion = IceHUD.CurrTagVersion
end
-- fixup for the old new 'invert' option. (This was here before I got here - Andre)
if not self.moduleSettings.updatedReverseInverse then
self.moduleSettings.updatedReverseInverse = true
if self.moduleSettings.reverse then
self.moduleSettings.reverse = false
self.moduleSettings.inverse = "NORMAL"
self:SetBarFramePoints(self.barFrame)
end
end
-- fixup for the new new 'invert' option
-- This is the new fixup code... Not sure if I'm doin' it right, or if the old and the new fixups can be merged.
-- The way I figure it, someone who hasn't updated in like forever might not have had either fixup occur, and yet
-- people who have been updating frequently will have already had the old fixup occur... DUN DUN DUN.
-- Also... Setting the module default for moduleSettings.inverse seemed to automatically set all my characters
-- to that default... So I'm not I can test whether or not my fixup does what I think it does. o.O
if not self.moduleSettings.updatedInverseExpand then
self.moduleSettings.updatedInverseExpand = true
if self.moduleSettings.inverse == true then
self.moduleSettings.inverse = "INVERSE"
else
self.moduleSettings.inverse = "NORMAL"
end
self:SetBarFramePoints(self.barFrame)
end
self:RegisterFontStrings()
-- allows frames that show/hide via RegisterUnitWatch to not show text when they shouldn't
if self.frame:GetScript("OnHide") == nil then
self.frame:SetScript("OnHide", function()
if self.moduleSettings.textVisible["upper"] then
self.frame.bottomUpperText:Hide()
end
if self.moduleSettings.textVisible["lower"] then
self.frame.bottomLowerText:Hide()
end
self:OnHide()
end)
end
if self.frame:GetScript("OnShow") == nil then
self.frame:SetScript("OnShow", function()
if self.moduleSettings.textVisible["upper"] then
self.frame.bottomUpperText:Show()
end
if self.moduleSettings.textVisible["lower"] then
self.frame.bottomLowerText:Show()
end
self:OnShow()
end)
end
self:Redraw()
end
function IceBarElement.prototype:OnHide()
IceHUD.IceCore:RequestUpdates(self, nil)
end
function IceBarElement.prototype:OnShow()
if not self:IsFull(self.CurrScale) then
self:ConditionalSetupUpdate()
end
end
function IceBarElement.prototype:Disable(core)
IceBarElement.super.prototype.Disable(self, core)
IceHUD.IceCore:RequestUpdates(self, nil)
self:ClearMarkers()
end
function IceBarElement.prototype:RegisterFontStrings()
if DogTag ~= nil and self.moduleSettings ~= nil and self.moduleSettings.usesDogTagStrings then
if self.frame.bottomUpperText and self.moduleSettings.upperText then
DogTag:AddFontString(self.frame.bottomUpperText, self.frame, self.moduleSettings.upperText, "Unit", { unit = self.unit })
end
if self.frame.bottomLowerText and self.moduleSettings.lowerText then
DogTag:AddFontString(self.frame.bottomLowerText, self.frame, self.moduleSettings.lowerText, "Unit", {unit = self.unit })
end
end
end
-- OVERRIDE
function IceBarElement.prototype:GetDefaultSettings()
local settings = IceBarElement.super.prototype.GetDefaultSettings(self)
settings["side"] = IceCore.Side.Left
settings["offset"] = 1
settings["scale"] = 1
settings["inverse"] = "NORMAL"
settings["reverse"] = false
settings["barFontSize"] = 12
settings["lockUpperTextAlpha"] = true
settings["lockLowerTextAlpha"] = false
settings["textVisible"] = {upper = true, lower = true}
settings["upperText"] = ''
settings["lowerText"] = ''
settings["textVerticalOffset"] = -1
settings["textHorizontalOffset"] = 0
settings["shouldAnimate"] = true
settings["desiredLerpTime"] = 0.2
settings["barVisible"] = {bg = true, bar = true}
settings["myTagVersion"] = 2
settings["widthModifier"] = 0
settings["usesDogTagStrings"] = true
settings["barVerticalOffset"] = 0
settings["barHorizontalOffset"] = 0
settings["forceJustifyText"] = "NONE"
settings["shouldUseOverride"] = false
settings["rotateBar"] = false
settings["markers"] = {}
settings["bAllowExpand"] = true
settings["textVerticalGap"] = 0
return settings
end
do
local function getFillOptions(self)
local values = {
["NORMAL"] = "Normal",
["INVERSE"] = "Inverse",
}
if self.moduleSettings.bAllowExpand then
values["EXPAND"] = "Expanding"
end
return values
end
-- OVERRIDE
function IceBarElement.prototype:GetOptions()
local opts = IceBarElement.super.prototype.GetOptions(self)
opts["headerLookAndFeel"] = {
type = 'header',
name = L["Look and Feel"],
order = 29.9
}
opts["side"] =
{
type = 'select',
name = L["Side"],
desc = L["Side of the HUD where the bar appears"],
get = function(info)
if (self.moduleSettings.side == IceCore.Side.Right) then
return 2
else
return 1
end
end,
set = function(info, value)
if (value == 2) then
self.moduleSettings.side = IceCore.Side.Right
else
self.moduleSettings.side = IceCore.Side.Left
end
self:Redraw()
end,
values = { "Left", "Right" },
disabled = function()
return not self.moduleSettings.enabled
end,
order = 30
}
opts["offset"] =
{
type = 'range',
name = L["Offset"],
desc = L["Offset of the bar"],
min = -10,
max = 15,
step = 1,
get = function()
return self.moduleSettings.offset
end,
set = function(info, value)
self.moduleSettings.offset = value
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 30.01
}
opts["scale"] =
{
type = 'range',
name = L["Scale"],
desc = L["Scale of the bar"],
min = 0.1,
max = 2,
step = 0.05,
isPercent = true,
get = function()
return self.moduleSettings.scale
end,
set = function(info, value)
self.moduleSettings.scale = value
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 30.02
}
opts["inverse"] =
{
type = 'select',
name = L["Invert bar"],
desc = L["Controls what it means for the bar to be filled. A normal bar will grow larger as the value grows from 0% to 100%. A reversed bar will shrink as the value grows from 0% to 100%."],
values = getFillOptions(self),
get = function()
return self.moduleSettings.inverse
end,
set = function(info, value)
self.moduleSettings.inverse = value
self:SetBarFramePoints(self.barFrame)
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 30.03
}
opts["reverse"] =
{
type = 'toggle',
name = L["Reverse direction"],
desc = L["Controls what it means for the bar to be filled. A normal bar will grow larger as the value grows from 0% to 100%. A reversed bar will shrink as the value grows from 0% to 100%."],
get = function()
return self.moduleSettings.reverse
end,
set = function(info, value)
self.moduleSettings.reverse = value
self:SetBarFramePoints(self.barFrame)
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 30.04
}
opts["barVisible"] = {
type = 'toggle',
name = L["Bar visible"],
desc = L["Toggle bar visibility"],
get = function()
return self.moduleSettings.barVisible['bar']
end,
set = function(info, v)
self.moduleSettings.barVisible['bar'] = v
self:SetBarVisibility(v)
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 28
}
opts["bgVisible"] = {
type = 'toggle',
name = L["Bar background visible"],
desc = L["Toggle bar background visibility"],
get = function()
return self.moduleSettings.barVisible['bg']
end,
set = function(info, v)
self.moduleSettings.barVisible['bg'] = v
if v then
self.frame.bg:Show()
else
self.frame.bg:Hide()
end
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 29
}
if not self.moduleSettings.hideAnimationSettings then
opts["headerAnimation"] = {
type = 'header',
name = L["Animation Settings"],
order = 110
}
opts["shouldAnimate"] =
{
type = 'toggle',
name = L["Animate changes"],
desc = L["Whether or not to animate the bar falloffs/gains"],
get = function()
return self.moduleSettings.shouldAnimate
end,
set = function(info, value)
self.moduleSettings.shouldAnimate = value
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 111
}
opts["desiredLerpTime"] =
{
type = 'range',
name = L["Animation Duration"],
desc = L["How long the animation should take to play"],
min = 0,
max = 2,
step = 0.05,
get = function()
return self.moduleSettings.desiredLerpTime
end,
set = function(info, value)
self.moduleSettings.desiredLerpTime = value
end,
disabled = function()
return not self.moduleSettings.enabled or not self.moduleSettings.shouldAnimate
end,
order = 112
}
end
opts["widthModifier"] =
{
type = 'range',
name = L["Bar width modifier"],
desc = L["Make this bar wider or thinner than others"],
min = -80,
max = 80,
step = 1,
get = function()
return self.moduleSettings.widthModifier
end,
set = function(info, v)
self.moduleSettings.widthModifier = v
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 30.05
}
opts["barVerticalOffset"] =
{
type='range',
name = L["Bar vertical offset"],
desc = L["Adjust the vertical placement of this bar"],
min = -600,
max = 600,
step = 1,
get = function()
return self.moduleSettings.barVerticalOffset
end,
set = function(info, v)
self.moduleSettings.barVerticalOffset = v
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 30.06
}
opts["barHorizontalAdjust"] =
{
type='range',
name = L["Bar horizontal adjust"],
desc = L["This is a per-pixel horizontal adjustment. You should probably use the 'offset' setting above as it is designed to snap bars together. This may be used in the case of a horizontal bar needing to be positioned outside the normal bar locations."],
min = -600,
max = 600,
step = 1,
get = function()
return self.moduleSettings.barHorizontalOffset
end,
set = function(info, v)
self.moduleSettings.barHorizontalOffset = v
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 30.06
}
opts["shouldUseOverride"] =
{
type = 'toggle',
name = L["Override global texture"],
desc = L["This will override the global bar texture setting for this bar with the one specified below."],
get = function()
return self.moduleSettings.shouldUseOverride
end,
set = function(info, value)
self.moduleSettings.shouldUseOverride = value
IceHUD:NotifyOptionsChange()
self:NotifyBarOverrideChanged()
self:Redraw()
end,
disabled = function()
return not self:IsEnabled()
end,
order = 30.07
}
opts["barTextureOverride"] =
{
type = 'select',
name = L["Bar Texture Override"],
desc = L["This will override the global bar texture setting for this bar."],
get = function(info)
return IceHUD:GetSelectValue(info, self.moduleSettings.barTextureOverride)
end,
set = function(info, value)
self.moduleSettings.barTextureOverride = info.option.values[value]
self:NotifyBarOverrideChanged()
self:Redraw()
end,
disabled = function()
return not self:IsEnabled() or not self.moduleSettings.shouldUseOverride
end,
values = IceHUD.validBarList,
order = 30.08
}
opts["barRotate"] =
{
type = 'toggle',
name = L["Rotate 90 degrees"],
desc = L["This will rotate this module by 90 degrees to give a horizontal orientation.\n\nWARNING: This feature is brand new and a bit rough around the edges. You will need to greatly adjust the vertical and horizontal offset of this bar plus move the text around in order for it to look correct.\n\nAnd I mean greatly."],
get = function(info)
return self.moduleSettings.rotateBar
end,
set = function(info, v)
self.moduleSettings.rotateBar = v
if v then
self:RotateHorizontal()
else
self:ResetRotation()
end
self:Redraw()
end,
disabled = function()
return not self:IsEnabled()
end,
order = 30.09
}
opts["textSettings"] =
{
type = 'group',
name = "|c"..self.configColor..L["Text Settings"].."|r",
desc = L["Settings related to texts"],
order = 32,
args = {
fontsize = {
type = 'range',
name = L["Bar Font Size"],
desc = L["Bar Font Size"],
get = function()
return self.moduleSettings.barFontSize
end,
set = function(info, v)
self.moduleSettings.barFontSize = v
self:Redraw()
end,
min = 8,
max = 20,
step = 1,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 11
},
lockUpperFontAlpha = {
type = "toggle",
name = L["Lock Upper Text Alpha"],
desc = L["Locks upper text alpha to 100%"],
get = function()
return self.moduleSettings.lockUpperTextAlpha
end,
set = function(info, v)
self.moduleSettings.lockUpperTextAlpha = v
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 13
},
lockLowerFontAlpha = {
type = "toggle",
name = L["Lock Lower Text Alpha"],
desc = L["Locks lower text alpha to 100%"],
get = function()
return self.moduleSettings.lockLowerTextAlpha
end,
set = function(info, v)
self.moduleSettings.lockLowerTextAlpha = v
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 14
},
upperTextVisible = {
type = 'toggle',
name = L["Upper text visible"],
desc = L["Toggle upper text visibility"],
get = function()
return self.moduleSettings.textVisible['upper']
end,
set = function(info, v)
self.moduleSettings.textVisible['upper'] = v
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 13.1,
},
lowerTextVisible = {
type = 'toggle',
name = L["Lower text visible"],
desc = L["Toggle lower text visibility"],
get = function()
return self.moduleSettings.textVisible['lower']
end,
set = function(info, v)
self.moduleSettings.textVisible['lower'] = v
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 14.1,
},
upperTextString = {
type = 'input',
name = L["Upper Text"],
desc =
self.moduleSettings.usesDogTagStrings and L["The upper text to display under this bar (accepts LibDogTag formatting)\n\nSee http://www.wowace.com/wiki/LibDogTag-2.0/ or type /dogtag for tag info.\n\nRemember to press ENTER after filling out this box or it will not save."]
or L["The upper text to display under this bar.\n\nNOTE: this text block does NOT support DogTags.\n\nRemember to press ENTER/Accept after filling out this box or it will not save."],
hidden = function()
return DogTag == nil or not self.moduleSettings.usesDogTagStrings
end,
get = function()
return self.moduleSettings.upperText
end,
set = function(info, v)
if DogTag ~= nil and v ~= '' and v ~= nil then
v = DogTag:CleanCode(v)
end
self.moduleSettings.upperText = strtrim(v)
self:RegisterFontStrings()
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
multiline = self.moduleSettings.usesDogTagStrings,
usage = "<upper text to display>",
order = 13.2,
},
lowerTextString = {
type = 'input',
name = L["Lower Text"],
desc =
self.moduleSettings.usesDogTagStrings and L["The lower text to display under this bar (accepts LibDogTag formatting)\n\nSee http://www.wowace.com/wiki/LibDogTag-2.0/ or type /dogtag for tag info.\n\nRemember to press ENTER after filling out this box or it will not save."]
or L["The lower text to display under this bar.\n\nNOTE: this text block does NOT support DogTags.\n\nRemember to press ENTER/Accept after filling out this box or it will not save."],
hidden = function()
return DogTag == nil or not self.moduleSettings.usesDogTagStrings
end,
get = function()
return self.moduleSettings.lowerText
end,
set = function(info, v)
if DogTag ~= nil and v ~= '' and v ~= nil then
v = DogTag:CleanCode(v)
end
self.moduleSettings.lowerText = strtrim(v)
self:RegisterFontStrings()
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
multiline = self.moduleSettings.usesDogTagStrings,
usage = "<lower text to display>",
order = 14.2,
},
forceJustifyText = {
type = 'select',
name = L["Force Text Justification"],
desc = L["This sets the alignment for the text on this bar"],
get = function(info)
return self.moduleSettings.forceJustifyText
end,
set = function(info, value)
self.moduleSettings.forceJustifyText = value
self:Redraw()
end,
values = { NONE = "None", LEFT = "Left", RIGHT = "Right" },
disabled = function()
return not self.moduleSettings.enabled
end,
order = 11.1,
},
textVerticalOffset = {
type = 'range',
name = L["Text Vertical Offset"],
desc = L["Offset of the text from the bar vertically (negative is farther below)"],
min = -450,
max = 350,
step = 1,
get = function()
return self.moduleSettings.textVerticalOffset
end,
set = function(info, v)
self.moduleSettings.textVerticalOffset = v
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 11.2,
},
textHorizontalOffset = {
type = 'range',
name = L["Text Horizontal Offset"],
desc = L["Offset of the text from the bar horizontally"],
min = -350,
max = 350,
step = 1,
get = function()
return self.moduleSettings.textHorizontalOffset
end,
set = function(info, v)
self.moduleSettings.textHorizontalOffset = v
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 11.3,
},
textVerticalGap = {
type = 'range',
name = L["Text Vertical Gap"],
desc = L["Gap between Upper and Lower text vertically"],
min = 0,
max = 10,
step = 1,
get = function()
return self.moduleSettings.textVerticalGap
end,
set = function(info, v)
self.moduleSettings.textVerticalGap = v
self:Redraw()
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 11.4,
},
textHeader = {
type = 'header',
name = L["Upper Text"],
order = 12,
},
textHeader2 = {
type = 'header',
name = L["Lower Text"],
order = 13.999,
},
}
}
if not self.moduleSettings.bHideMarkerSettings then
opts["markerSettings"] =
{
type = 'group',
name = "|c"..self.configColor..L["Marker Settings"].."|r",
desc = L["Create or remove markers at various points along the bar here"],
order = 32,
args = {
markerPos = {
type = "range",
min = 0,
max = 100,
step = 1,
name = L["Position (percent)"],
desc = L["This specifies at what point along the bar this marker should be displayed. Remember to press ENTER when you are done typing.\n\nExample: if you wanted a marker at 40 energy and you have 100 total energy, then this would be 40. If you want it at 40 energy and you have 120 total energy, then this would be 33."],
get = function()
return lastMarkerPosConfig
end,
set = function(info, v)
lastMarkerPosConfig = math.floor(v)
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 20,
},
markerColor = {
type = "color",
name = L["Color"],
desc = L["The color this marker should be."],
width = "half",
get = function()
return lastMarkerColorConfig.r, lastMarkerColorConfig.g, lastMarkerColorConfig.b, lastMarkerColorConfig.a
end,
set = function(info, r, g, b, a)
lastMarkerColorConfig = {r=r, g=g, b=b, a=a}
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 30,
},
markerHeight = {
type = "range",
min = 1,
step = 1,
max = self.settings.barHeight,
name = L["Height"],
desc = L["The height of the marker on the bar."],
get = function()
return lastMarkerHeightConfig
end,
set = function(info, v)
lastMarkerHeightConfig = v
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 40,
},
createMarker = {
type = "execute",
name = L["Create marker"],
desc = L["Creates a new marker with the chosen settings."],
width = "full",
func = function()
self:AddNewMarker(lastMarkerPosConfig / 100, lastMarkerColorConfig, lastMarkerHeightConfig)
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 10,
},
listMarkers = {
type = "select",
name = L["Edit Marker"],
desc = L["Choose a marker to edit. This will place the marker's settings in the fields above here."],
values = function()
local retval = {}
if self.moduleSettings.markers then
for i=1, #self.moduleSettings.markers do
retval[i] = ((self.moduleSettings.markers[i].position) * 100) .. "%"
end
end
return retval
end,
get = function(info)
return lastEditMarkerConfig
end,
set = function(info, v)
lastEditMarkerConfig = v
lastMarkerPosConfig = (self.moduleSettings.markers[v].position) * 100
local color = self.moduleSettings.markers[v].color
lastMarkerColorConfig = {r=color.r, g=color.g, b=color.b, a=color.a}
lastMarkerHeightConfig = self.moduleSettings.markers[v].height
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 50,
},
editMarker = {
type = "execute",
name = L["Update"],
desc = L["This will update the marker selected in the 'edit marker' box with the values specified."],
func = function()
if self.moduleSettings.markers and lastEditMarkerConfig <= #self.moduleSettings.markers then
self:EditMarker(lastEditMarkerConfig, lastMarkerPosConfig / 100, lastMarkerColorConfig, lastMarkerHeightConfig)
end
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 60,
},
deleteMarker = {
type = "execute",
name = L["Remove"],
desc = L["This will remove the marker selected in the 'edit marker' box. This action is irreversible."],
func = function()
if self.moduleSettings.markers and lastEditMarkerConfig <= #self.moduleSettings.markers then
self:RemoveMarker(lastEditMarkerConfig)
end
end,
disabled = function()
return not self.moduleSettings.enabled
end,
order = 70,
},
}
}
end
return opts
end
end
function IceBarElement.prototype:SetBarVisibility(visible)
if visible then
self.barFrame:Show()
else
self.barFrame:Hide()
end
end
function IceBarElement.prototype:SetBarFramePoints(frame, offset_x, offset_y)
local anchor
frame:ClearAllPoints()
if self.moduleSettings.inverse == "INVERSE" then
anchor = "TOPLEFT"
elseif self.moduleSettings.inverse == "EXPAND" then
anchor = "LEFT"
else
anchor = "BOTTOMLEFT"
end
if self.moduleSettings.rotateBar then
frame:SetPoint(anchor, self.frame, anchor, offset_y, offset_x)
else
frame:SetPoint(anchor, self.frame, anchor, offset_x, offset_y)
end
end
-- OVERRIDE
function IceBarElement.prototype:Redraw()
IceBarElement.super.prototype.Redraw(self)
if (not self.moduleSettings.enabled) then
return
end
self.alpha = self.settings.alphaooc
self:CreateFrame()
self.frame:SetAlpha(self.alpha)
self:RepositionMarkers()
end
function IceBarElement.prototype:SetPosition(side, offset)
IceBarElement.prototype.side = side
IceBarElement.prototype.offset = offset
end
-- 'Protected' methods --------------------------------------------------------
-- OVERRIDE
function IceBarElement.prototype:CreateFrame()
-- don't call overridden method
self.alpha = self.settings.alphaooc
self:CreateBackground()
self:CreateBar()
self:CreateTexts()
if #self.Markers == 0 then
self:LoadMarkers()
else
for i=1, #self.Markers do
self:UpdateMarker(i)
end
end
self.masterFrame:SetScale(self.moduleSettings.scale)
if self.moduleSettings.rotateBar then
self:RotateHorizontal()
else
self:ResetRotation()
end
end
function IceBarElement.prototype:ConditionalSetupUpdate()
if not self.MyOnUpdateFunc then
self.MyOnUpdateFunc = function() self:MyOnUpdate() end
end
if IceHUD.IceCore:IsUpdateSubscribed(self) then
return
end
if not self.moduleSettings.enabled then
return
end
if not string.find(self.elementName, "MirrorBar") and not string.find(self.elementName, "PlayerMana") then
IceHUD.IceCore:RequestUpdates(self, self.MyOnUpdateFunc)
end
end
-- Creates background for the bar
function IceBarElement.prototype:CreateBackground()
if not (self.frame) then
self.frame = CreateFrame("Frame", "IceHUD_"..self.elementName, self.masterFrame)
end
self.frame:SetFrameStrata(IceHUD.IceCore:DetermineStrata("BACKGROUND"))
self.frame:SetWidth(self.settings.barWidth + (self.moduleSettings.widthModifier or 0))