-
Notifications
You must be signed in to change notification settings - Fork 9
/
Options.lua
executable file
·1879 lines (1761 loc) · 49.6 KB
/
Options.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 LibStub = LibStub
local ChocolateBar = LibStub("AceAddon-3.0"):GetAddon("ChocolateBar")
local debug = ChocolateBar and ChocolateBar.Debug or function() end
local AceCfgDlg = LibStub("AceConfigDialog-3.0")
local Drag = ChocolateBar.Drag
local broker = LibStub("LibDataBroker-1.1")
local L = LibStub("AceLocale-3.0"):GetLocale("ChocolateBar")
local LSM = LibStub("LibSharedMedia-3.0")
local _G, pairs, string = _G, pairs, string
local db, moreChocolate
local index = 0
local version = C_AddOns.GetAddOnMetadata("ChocolateBar","X-Curse-Packaged-Version") or ""
local function GetStats(info)
local total = 0
local enabled = 0
local data = 0
for name, obj in broker:DataObjectIterator() do
local t = obj.type
if t == "data source" or t == "launcher" then
total = total + 1
if t == "data source" then
data = data + 1
end
local settings = db.objSettings[name]
if settings and settings.enabled then
enabled = enabled +1
end
end
end
return _G.strjoin("\n","|cffffd200"..L["Enabled"].."|r "..enabled,
"|cffffd200"..L["Disabled"].."|r "..total-enabled,
"|cffffd200"..L["Total"].."|r "..total,
"",
"|cffffd200"..L["Data Source"].."|r "..data,
"|cffffd200"..L["Launcher"].."|r "..total-data
)
end
local function EnableAll(info)
for name, obj in LibStub("LibDataBroker-1.1"):DataObjectIterator() do
ChocolateBar:EnableDataObject(name, obj)
end
end
local function DisableAll(info)
for name, obj in LibStub("LibDataBroker-1.1"):DataObjectIterator() do
ChocolateBar:DisableDataObject(name)
end
end
local function DisableLauncher(info)
for name, obj in LibStub("LibDataBroker-1.1"):DataObjectIterator() do
if obj.type ~= "data source" then
ChocolateBar:DisableDataObject(name)
end
end
end
local aceoptions = {
name = "ChocolateBar".." "..version,
handler = ChocolateBar,
type='group',
desc = "ChocolateBar",
args = {
lookAndFeel = {
name = L["Look and Feel"],
type="group",
order = 0,
args={
general = {
inline = true,
name = L["General"],
type="group",
order = 3,
args={
locked = {
type = 'toggle',
order = 1,
name = L["Lock Plugins"],
desc = L["Hold alt key to drag a plugin."],
get = function(info, value)
return db.locked
end,
set = function(info, value)
db.locked = value
end,
},
adjustBlizzardFrames = {
type = 'toggle',
order = 2,
name = L["Adjust Blizzard Frames"],
desc = L["Move Blizzard frames above/below bars"],
get = function(info, value)
return db.moveFrames
end,
set = function(info, value)
db.moveFrames = value
ChocolateBar:UpdateBarOptions("UpdateAutoHide")
end,
},
hideBarsPetBattle = {
type = 'toggle',
order = 3,
name = L["Hide Bars in Pet Battle"],
desc = L["Hide Bars during a Pet Battle."],
get = function(info, value)
return db.petBattleHideBars
end,
set = function(info, value)
db.petBattleHideBars = value
end,
},
hideOrderHallCommandBar = {
type = 'toggle',
order = 4,
name = L["Hide Order Hall Bar"],
desc = L["Hides the command bar displayed at the Class/Order Hall."],
get = function(info, value)
return db.hideOrderHallCommandBar
end,
set = function(info, value)
db.hideOrderHallCommandBar = value
ChocolateBar:ToggleOrderHallCommandBar()
end,
},
--[[
adjustCenter = {
type = 'toggle',
order = 5,
width = "double",
name = L["Update Center Position"],
desc = L["Always adjust the center group based on the current width of the plugins. Disable this to align the center group based only on the number of plugins."],
get = function(info, value)
return db.adjustCenter
end,
set = function(info, value)
db.adjustCenter = value
ChocolateBar:UpdateBarOptions("UpdateBar")
end,
},]]--
gap = {
type = 'range',
order = 10,
name = L["Gap"],
desc = L["Set the gap between the plugins."],
min = 0,
max = 50,
step = 1,
get = function(name)
return db.gap
end,
set = function(info, value)
db.gap = value
ChocolateBar.ChocolatePiece:UpdateGap(value)
ChocolateBar:UpdateChoclates("updateSettings")
end,
},
textOffset = {
type = 'range',
order = 11,
name = L["Text Offset"],
desc = L["Set the distance between the icon and the text."],
min = -5,
max = 15,
step = 1,
get = function(name)
return db.textOffset
end,
set = function(info, value)
db.textOffset = value
--ChocolateBar.ChocolatePiece:UpdateGap(value)
ChocolateBar:UpdateChoclates("updateSettings")
end,
},
size = {
type = 'range',
order = 12,
name = L["Bar Size"],
desc = L["Bar Size"],
min = 12,
max = 30,
step = 1,
get = function(name)
return db.height
end,
set = function(info, value)
db.height = value
ChocolateBar:UpdateBarOptions("UpdateHeight")
end,
},
iconSize = {
type = 'range',
order = 13,
name = L["Icon Size"],
desc = L["Icon size in relation to the bar height."],
min = 0,
max = 1,
step = 0.001,
bigStep = 0.05,
isPercent = true,
get = function(name)
return db.iconSize
end,
set = function(info, value)
if value > 1 then
value = 1
elseif value < 0.01 then
value = 0.001
end
db.iconSize = value
ChocolateBar:UpdateBarOptions("UpdateHeight")
end,
},
strata = {
type = 'select',
values = {FULLSCREEN_DIALOG="Fullscreen_Dialog",FULLSCREEN="Fullscreen",
DIALOG="Dialog",HIGH="High",MEDIUM="Medium",LOW="Low",BACKGROUND="Background"},
order = 14,
name = L["Bar Strata"],
desc = L["Bar Strata"],
get = function()
return db.strata
end,
set = function(info, value)
db.strata = value
ChocolateBar:UpdateBarOptions("UpdateStrata")
end,
},
barRightClick = {
type = 'select',
values = {NONE=L["none"],OPTIONS=L["ChocolateBar Options"],
BLIZZ=L["Blizzard Options"]},
order = 16,
name = L["Bar Right Click"],
desc = L["Select the action when right clicking on a bar."],
get = function()
return db.barRightClick
end,
set = function(info, value)
db.barRightClick = value
end,
},
--colorizedDragging = {
-- type = 'toggle',
-- order = 12,
-- name = L["Colorized Dragging"],
-- desc = L["Colorize frames during drag & drop."],
-- get = function(info, value)
-- return db.colorizedDragging
-- end,
-- set = function(info, value)
-- - db.colorizedDragging = value
-- end,
--},
},
},
defaults = {
inline = true,
name= L["Defaults"],
type="group",
order = 4,
args={
label = {
order = 0,
type = "description",
name = L["Automatically disable new plugins of type:"],
},
dataobjects = {
type = 'toggle',
order = 1,
name = L["Data Source"],
desc = L["If enabled new plugins of type data source will automatically be disabled."],
get = function()
return db.autodissource
end,
set = function(info, value)
db.autodissource = value
end,
},
launchers = {
type = 'toggle',
order = 2,
name = L["Launcher"],
desc = L["If enabled new plugins of type launcher will automatically be disabled."],
get = function()
return db.autodislauncher
end,
set = function(info, value)
db.autodislauncher = value
end,
},
},
},
combat = {
--inline = true,
name= L["In Combat"],
type="group",
order = 0,
args={
combat = {
inline = true,
name= L["In Combat"],
type="group",
order = 0,
args={
hidetooltip = {
type = 'toggle',
order = 1,
name = L["Disable Tooltips"],
desc = L["Disable Tooltips"],
get = function(info, value)
return db.combathidetip
end,
set = function(info, value)
db.combathidetip = value
end,
},
hidebars = {
type = 'toggle',
order = 2,
name = L["Hide Bars"],
desc = L["Hide Bars"],
get = function(info, value)
return db.combathidebar
end,
set = function(info, value)
db.combathidebar = value
end,
},
disablebar = {
type = 'toggle',
order = 2,
name = L["Disable Clicking"],
desc = L["Disable Clicking"],
get = function(info, value)
return db.combatdisbar
end,
set = function(info, value)
db.combatdisbar = value
end,
},
disableoptons = {
type = 'toggle',
order = 2,
name = L["Disable Options"],
desc = L["Disable options dialog on right click"],
get = function(info, value)
return db.disableoptons
end,
set = function(info, value)
db.disableoptons = value
end,
},
combatopacity = {
type = 'range',
order = 3,
name = L["Opacity"],
desc = L["Set the opacity of the bars during combat."],
min = 0,
max = 1,
step = 0.001,
bigStep = 0.05,
isPercent = true,
get = function(name)
return db.combatopacity
end,
set = function(info, value)
if value > 1 then
value = 1
elseif value < 0.01 then
value = 0.001
end
db.combatopacity = value
--ChocolateBar:UpdateBarOptions("UpdateOpacity")
for name,bar in pairs(ChocolateBar:GetBars()) do
bar.tempHide = bar:GetAlpha()
bar:SetAlpha(db.combatopacity)
end
end,
},
},
},
},
},
fontAndTextures = {
--inline = true,
name = L["Fonts and Textures"],
type = "group",
order = 4,
args = {
textures = {
inline = true,
name = L["Textures"],
type = "group",
order = 2,
args = {
colour = {
type = "color",
order = 5,
name = L["Texture Color/Alpha"],
desc = L["Texture Color/Alpha"],
hasAlpha = true,
get = function(info)
local t = db.background.color
return t.r, t.g, t.b, t.a
end,
set = function(info, r, g, b, a)
local t = db.background.color
t.r, t.g, t.b, t.a = r, g, b, a
ChocolateBar:UpdateBarOptions("UpdateColors")
end,
},
bordercolour = {
type = "color",
order = 6,
name = L["Border Color/Alpha"],
desc = L["Border Color/Alpha"],
hasAlpha = true,
get = function(info)
local t = db.background.borderColor
return t.r, t.g, t.b, t.a
end,
set = function(info, r, g, b, a)
local t = db.background.borderColor
t.r, t.g, t.b, t.a = r, g, b, a
ChocolateBar:UpdateBarOptions("UpdateColors")
end,
},
textureTile = {
type = 'toggle',
order = 3,
name = L["Tile"],
desc = L["Tile the Texture. Disable to stretch the Texture."],
get = function()
return db.background.tile
end,
set = function(info, value)
db.background.tile = value
ChocolateBar:UpdateBarOptions("UpdateTexture")
end,
},
textureTileSize = {
type = 'range',
order = 4,
name = L["Tile Size"],
desc = L["Adjust the size of the tiles."],
min = 1,
max = 256,
step = 1,
bigStep = 5,
isPercent = false,
get = function(name)
return db.background.tileSize
end,
set = function(info, value)
if value > 256 then
value = 256
elseif value < 1 then
value = 1
end
db.background.tileSize = value
ChocolateBar:UpdateBarOptions("UpdateTexture")
end,
},
},
},
font = {
inline = true,
name = L["Font"],
type = "group",
order = 1,
args ={
fontSize = {
type = 'range',
order = 2,
name = L["Font Size"],
desc = L["Font Size"],
min = 8,
max = 20,
step = .5,
get = function(name)
return db.fontSize
end,
set = function(info, value)
db.fontSize = value
ChocolateBar:UpdateChoclates("updatefont")
end,
},
textcolour = {
type = "color",
order = 3,
name = L["Text color"],
desc = L["Default text color of a plugin. This will not overwrite plugins that use own colors."],
hasAlpha = true,
get = function(info)
local t = db.textColor or {r = 1, g = 1, b = 1, a = 1}
return t.r, t.g, t.b, t.a
end,
set = function(info, r, g, b, a)
db.textColor = db.textColor or {r = 1, g = 1, b = 1, a = 1}
local t = db.textColor
t.r, t.g, t.b, t.a = r, g, b, a
ChocolateBar:UpdateChoclates("updateSettings")
end,
},
labelColor = {
type = "color",
order = 3,
name = L["Label color"],
desc = L["Default label color of a plugin."],
hasAlpha = true,
get = function(info)
local t = db.labelColor or {r=1, g=0.82, b=0, a=1}
return t.r, t.g, t.b, t.a
end,
set = function(info, r, g, b, a)
db.labelColor = db.labelColor or {r=1, g=0.82, b=0, a=1}
local t = db.labelColor
t.r, t.g, t.b, t.a = r, g, b, a
ChocolateBar:UpdateChoclates("updateSettings")
end,
},
iconcolour = {
type = "toggle",
order = 4,
name = L["Desaturated Icons"],
desc = L["Show icons in gray scale mode (This will not affect icons embedded in the text of a plugin)."],
get = function(info)
return db.desaturated
end,
set = function(info, vale)
db.desaturated = vale
for name, obj in broker:DataObjectIterator() do
if db.objSettings[name] then
if db.objSettings[name].enabled then
local choco = ChocolateBar:GetChocolate(name)
if choco then
choco:Update(choco, "iconR", nil)
end
end
end
end
end,
},
forceColor = {
type = 'toggle',
width = "double",
order = 9,
name = L["Force Text Color"],
desc = L["Remove custom colors from plugins."],
get = function(info, value)
return db.forceColor
end,
set = function(info, value)
db.forceColor = value
for name, obj in broker:DataObjectIterator() do
if db.objSettings[name] then
if db.objSettings[name].enabled then
local choco = ChocolateBar:GetChocolate(name)
if choco then
choco:Update(choco, "text", obj.text)
end
end
end
end
end,
},
},
},
},
},
--@debug@
debug = {
type = 'toggle',
--width = "half",
order = 20,
name = "Debug",
desc = "This one is for me, not for you :P",
get = function(info, value)
return ChocolateBar.db.char.debug
end,
set = function(info, value)
ChocolateBar.db.char.debug = value
end,
},
--@end-debug@
},
},
bars={
name = L["Bars"],
type ="group",
order = 20,
args ={
new = {
type = 'execute',
--width = "half",
order = 0,
name = L["Create Bar"],
desc = L["Create New Bar"],
func = function()
local name = ChocolateBar:AddBar()
ChocolateBar:AddBarOptions(name)
end,
},
},
},
moduleOptions={
name = L["Modules"],
type ="group",
order = 20,
args ={
label = {
type = 'description',
order = 1,
name = L["Modules are buildin plugins that can be enabled or disabled here. Disabled plugins will not be loaded."]
},
},
},
chocolates={
name = L["Plugins"],
type="group",
order = -1,
args={
stats = {
inline = true,
name = L["Plugin Statistics"],
type="group",
order = 1,
args={
stats = {
order = 1,
type = "description",
name = GetStats,
},
},
},
quickconfig = {
inline = true,
name = L["Quick Config"],
type = "group",
order = 2,
args ={
enableAll = {
type = 'execute',
order = 3,
name = L["Enable All"],
desc = L["Get back my plugins!"],
func = EnableAll,
},
disableAll = {
type = 'execute',
order = 4,
name = L["Disable All"],
desc = L["Eat all the chocolate at once, uff..."],
func = DisableAll,
},
disableLauncher = {
type = 'execute',
order = 5,
name = L["Disable all Launchers"],
desc = L["Disable all the bad guy's:)"],
func = DisableLauncher,
},
},
},
},
},
},
}
aceoptions.args.lookAndFeel.args.fontAndTextures.args.textures.args.textureStatusbar = {
type = 'select',
dialogControl = 'LSM30_Statusbar',
values = AceGUIWidgetLSMlists and AceGUIWidgetLSMlists.statusbar or {},
order = 1,
name = L["Background Texture"],
desc = L["Some of the textures may depend on other addons."],
get = function()
return db.background.textureName
end,
set = function(info, value)
db.background.texture = LSM:Fetch("statusbar", value)
db.background.textureName = value
db.background.tile = false
ChocolateBar:UpdateBarOptions("UpdateTexture")
end,
}
aceoptions.args.lookAndFeel.args.fontAndTextures.args.textures.args.background1 = {
inline = true,
name = L["Advanced Textures"],
type = "group",
order = 3,
args ={
textureBackground = {
type = 'select',
dialogControl = 'LSM30_Background',
values = AceGUIWidgetLSMlists and AceGUIWidgetLSMlists.background or {},
order = 2,
name = L["Background Texture"],
desc = L["Some of the textures may depend on other addons."],
get = function()
return db.background.textureName
end,
set = function(info, value)
db.background.texture = LSM:Fetch("background", value)
db.background.textureName = value
db.background.tile = true
local t = db.background.color
t.r, t.g, t.b, t.a = 1, 1, 1, 1
ChocolateBar:UpdateBarOptions("UpdateTexture")
end,
}
}
}
aceoptions.args.lookAndFeel.args.fontAndTextures.args.font.args.font = {
type = 'select',
dialogControl = 'LSM30_Font',
values = AceGUIWidgetLSMlists and AceGUIWidgetLSMlists.font or {},
order = 1,
name = L["Font"],
desc = L["Some of the fonts may depend on other addons."],
get = function()
return db.fontName
end,
set = function(info, value)
db.fontPath = LSM:Fetch("font", value)
db.fontName = value
ChocolateBar:UpdateChoclates("updatefont")
end,
}
local chocolateOptions = aceoptions.args.chocolates.args
local barOptions = aceoptions.args.bars.args
local moduleOptions = aceoptions.args.moduleOptions.args
ChocolateBar.optionsTable = aceoptions
-----
-- bar option functions
-----
function ChocolateBar:GetAceOptions()
return aceoptions
end
-- return the number of bars aligend to align (top or bottom)
function ChocolateBar:GetNumBars(align)
local i = 0
for k,v in pairs(ChocolateBar:GetBars()) do
if v.settings.align == align then
i = i + 1
end
end
return i
end
local function GetBarName(info)
local name = info[#info]
local bar = ChocolateBar:GetBar(name)
if bar and bar.settings.align == "top" then
name = name.." (top) "
elseif bar and bar.settings.align == "bottom" then
name = name.." (bottom) "
else
name = name.." (custom) "
end
return name
end
local function GetBarIndex(info)
local name = info[#info]
local bar = ChocolateBar:GetBar(name)
local index = bar.settings.index
if db.barSettings[name].align == "bottom" then
--reverse order and force below top bars
index = index *-1 + 100
end
return index
end
local function SetBarAlign(info, value)
local name = info[#info-2]
if value then
db.barSettings[name].align = value
local bar = ChocolateBar:GetBar(name)
if bar then
bar:UpdateAutoHide(db)
ChocolateBar:AnchorBars()
end
end
end
local function GetBarAlign(info, value)
local name = info[#info-2]
return db.barSettings[name].align
end
local function EatBar(info, value)
local name = info[#info-2]
ChocolateBar:RemoveBar(name)
end
local function MoveUp(info, value)
local name = info[#info-2]
local bar = ChocolateBar:GetBar(name)
local index = bar.settings.index
if bar then
if db.barSettings[name].align == "bottom" then
index = index +1.5
if index > (ChocolateBar:GetNumBars("bottom")+1) then
index = ChocolateBar:GetNumBars("top")+1
SetBarAlign(info, "top")
end
elseif db.barSettings[name].align == "top" then
index = index -1.5
else
db.barSettings[name].align = "top"
index = 0
SetBarAlign(info, "top")
end
bar.settings.index = index
ChocolateBar:AnchorBars()
end
end
local function MoveDown(info, value)
local name = info[#info-2]
local bar = ChocolateBar:GetBar(name)
local index = bar.settings.index
if bar then
if db.barSettings[name].align == "bottom" then
index = index -1.5
elseif db.barSettings[name].align == "top" then
index = index +1.5
if index > (ChocolateBar:GetNumBars("top")+1) then
index = ChocolateBar:GetNumBars("bottom")+1
SetBarAlign(info, "bottom")
end
else
db.barSettings[name].align = "top"
index = 0
SetBarAlign(info, "top")
end
bar.settings.index = index
ChocolateBar:AnchorBars()
end
end
local function getAutoHide(info, value)
local name = info[#info-2]
return db.barSettings[name].autohide
end
local function setAutoHide(info, value)
local name = info[#info-2]
db.barSettings[name].autohide = value
local bar = ChocolateBar:GetBar(name)
bar:UpdateAutoHide(db)
--ChocolateBar:UpdateBarOptions("UpdateAutoHide")
end
--hide bar during combat
local function gethideBarInCombat(info, value)
local name = info[#info-2]
return db.barSettings[name].hideBarInCombat
end
local function sethideBarInCombat(info, value)
local name = info[#info-2]
db.barSettings[name].hideBarInCombat = value
end
local function GetBarWidth(info)
local name = info[#info-2]
local maxBarWidth = _G.math.floor(_G.GetScreenWidth())
return db.barSettings[name].width
end
local function SetBarWidth(info, value)
local name = info[#info-2]
local settings = db.barSettings[name]
settings.width = value
local bar = ChocolateBar:GetBar(name)
if value > _G.GetScreenWidth() or value == 0 then
bar:SetPoint("RIGHT", "UIParent" ,"RIGHT",0, 0);
else
local relative, relativePoint
settings.barPoint ,relative ,relativePoint,settings.barOffx ,settings.barOffy = bar:GetPoint()
if settings.barOffy == 0 then settings.barOffy = 1 end
bar:ClearAllPoints()
bar:SetPoint(settings.barPoint, "UIParent",settings.barOffx,settings.barOffy)
bar:SetWidth(value)
end
end
local moveBarDummy
local function OnDragStart(self)
self:StartMoving()
self.isMoving = true
end
local function OnDragStop(self)
self:StopMovingOrSizing()
self.isMoving = false
end
local function SetLockedBar(info, value)
local name = info[#info-2]
local settings = db.barSettings[name]
local bar = ChocolateBar:GetBar(name)
bar.locked = not value
if not value then
--unlock
if not moveBarDummy then
moveBarDummy = _G.CreateFrame("Frame",bar, _G.UIParent, BackdropTemplateMixin and "BackdropTemplate")
moveBarDummy:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background",
nil,
tile = true, tileSize = 16, edgeSize = 16,
nil});
moveBarDummy:SetBackdropColor(1,0,0,1);
moveBarDummy:RegisterForDrag("LeftButton")
moveBarDummy:SetFrameStrata("FULLSCREEN_DIALOG")
moveBarDummy:SetFrameLevel(10)
moveBarDummy:SetScript("OnMouseUp", function(self, btn)
if btn == "RightButton" then
ChocolateBar:ChatCommand()
end
end)
end
moveBarDummy.bar = bar
moveBarDummy:SetAllPoints(bar)
moveBarDummy:Show()
bar:RegisterForDrag("LeftButton")
bar:EnableMouse(true)
bar:SetFrameStrata("FULLSCREEN_DIALOG")
bar:SetFrameLevel(20)
bar:SetMovable(true)
bar:SetScript("OnDragStart",OnDragStart)
bar:SetScript("OnDragStop",OnDragStop)
bar:SetClampedToScreen(true)
for k, v in pairs(bar.chocolist) do
v:Hide()
end
else
bar:SetClampedToScreen(false)
for k, v in pairs(bar.chocolist) do
v:Show()
end
bar:SetScript("OnDragStart", nil)
local relative, relativePoint
settings.barPoint, relative, relativePoint, settings.barOffx ,settings.barOffy = bar:GetPoint()
if settings.barOffy == 0 then settings.barOffy = 1 end
bar:SetPoint(settings.barPoint, "UIParent",settings.barOffx,settings.barOffy)
settings.align = "custom"
settings.width = bar:GetWidth()
bar:SetFrameStrata(db.strata)
bar:SetFrameLevel(1)
if moveBarDummy then moveBarDummy:Hide() end
end
end
local function GetFreeBar(info)
local name = info[#info-2]
return db.barSettings[name].align == "custom"
end
local function SetFreeBar(info, value)
local name = info[#info-2]
local bar = ChocolateBar:GetBar(name)
if not value then
SetLockedBar(info, true)
db.barSettings[name].align = "top"
bar:SetPoint("RIGHT", "UIParent" ,"RIGHT",0, 0);
ChocolateBar:AnchorBars()
else
db.barSettings[name].align = "custom"
end
bar:UpdateJostle(db)
end
local function GetBarOffX(info, value)
local name = info[#info-2]
return db.barSettings[name].fineX
end
local function GetBarOffY(info, value)
local name = info[#info-2]
return db.barSettings[name].fineY
end
local function SetBarOff(info, value)
local name = info[#info-2]
local offtype = info[#info]
local bar = ChocolateBar:GetBar(name)
local settings = db.barSettings[name]
bar = ChocolateBar:GetBar(name)