-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathConfigUI.lua
2035 lines (1741 loc) · 79 KB
/
ConfigUI.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 ADDON, addon = ...
local LibDD = LibStub:GetLibrary("LibUIDropDownMenu-4.0")
local config = addon.Config
local GamePadButtonList = addon.GamePadButtonList
local GamePadBindingList = {
"PAD1",
"PAD2",
"PAD3",
"PAD4",
"PAD5",
"PAD6",
"PADDRIGHT",
"PADDUP",
"PADDDOWN",
"PADDLEFT",
"PADLSTICK",
"PADRSTICK",
"PADLSHOULDER",
"PADRSHOULDER",
"PADLTRIGGER",
"PADRTRIGGER",
"PADFORWARD",
"PADBACK",
"PADSYSTEM",
"PADSOCIAL",
"PADPADDLE1",
"PADPADDLE2",
"PADPADDLE3",
"PADPADDLE4",
"1",
"2",
"3",
"4" ,
"5",
"6",
"7",
"8",
"9",
"0",
"-",
"=",
"[",
"]",
"\\",
"'",
",",
".",
"'",
"/",
"`"
}
local GamePadActionMap = {
FACER=addon.GamePadActions,
FACEU=addon.GamePadActions,
FACED=addon.GamePadActions,
FACEL=addon.GamePadActions,
DPADR=addon.GamePadActions,
DPADU=addon.GamePadActions,
DPADD=addon.GamePadActions,
DPADL=addon.GamePadActions,
STCKL=addon.GamePadActions,
STCKR=addon.GamePadActions,
SPADL=addon.GamePadModifiers,
SPADR=addon.GamePadModifiers,
TRIGL=addon.GamePadModifiers,
TRIGR=addon.GamePadModifiers,
PPADL=addon.GamePadModifiers,
PPADR=addon.GamePadModifiers,
TPADL=addon.GamePadActions,
TPADR=addon.GamePadActions,
SOCIA=addon.GamePadActions,
OPTIO=addon.GamePadActions,
SYSTM=addon.GamePadActions
}
local GamePadModifierActionMap = {
FACER=addon.GamePadModifierActions,
FACEU=addon.GamePadModifierActions,
FACED=addon.GamePadModifierActions,
FACEL=addon.GamePadModifierActions,
DPADR=addon.GamePadModifierActions,
DPADU=addon.GamePadModifierActions,
DPADD=addon.GamePadModifierActions,
DPADL=addon.GamePadModifierActions,
STCKL=addon.GamePadModifierActions,
STCKR=addon.GamePadModifierActions,
SPADL=addon.GamePadModifierActions,
SPADR=addon.GamePadModifierActions,
TRIGL=addon.GamePadModifierActions,
TRIGR=addon.GamePadModifierActions,
PPADL=addon.GamePadModifierActions,
PPADR=addon.GamePadModifierActions,
TPADL=addon.GamePadModifierActions,
TPADR=addon.GamePadModifierActions,
SOCIA=addon.GamePadModifierActions,
OPTIO=addon.GamePadModifierActions,
SYSTM=addon.GamePadModifierActions,
}
local GamePadHotbarMap = {
FACER=addon.HotbarActions,
FACEU=addon.HotbarActions,
FACED=addon.HotbarActions,
FACEL=addon.HotbarActions,
DPADR=addon.HotbarActions,
DPADU=addon.HotbarActions,
DPADD=addon.HotbarActions,
DPADL=addon.HotbarActions,
STCKL=addon.GamePadModifierActions,
STCKR=addon.GamePadModifierActions,
SPADL=addon.GamePadModifierActions,
SPADR=addon.GamePadModifierActions,
TRIGL=addon.GamePadModifierActions,
TRIGR=addon.GamePadModifierActions,
PPADL=addon.GamePadModifierActions,
PPADR=addon.GamePadModifierActions,
TPADL=addon.GamePadModifierActions,
TPADR=addon.GamePadModifierActions,
SOCIA=addon.GamePadModifierActions,
OPTIO=addon.GamePadModifierActions,
SYSTM=addon.GamePadModifierActions,
}
StaticPopupDialogs["CROSSHOTBAR_ENABLEGAMEPAD"] = {
text = [[This config requires GamePad mode enabled.
CVar GamePadEnable is 0.
Click "Enable" to enable or use the Console command:
"/console GamePadEnable 1"]],
button1 = "Enable",
button2 = "Cancel",
OnAccept = function()
print("Enabled")
end,
timeout = 0,
whileDead = true,
hideOnEscape = true,
preferredIndex = 3
}
local Locale = {
bindingToolTip = "Button bindings used to assign buttons to actions. The bindings can be either controller or keyboards bindings. The bindings are for the Cross hotbar only, the controller needs to be configured seperately.",
actionToolTip = "Actions assigned when hobars are not active. Available actions are dependant on the button type. Some buttons can be assigned to modifiers such as LEFTHOTBAR or LEFTSHOULDER which can remap other buttons.",
hotbaractionToolTip = "Hotbar buttons or actions assigned with a hotbar is active. The hotbar buttons are index relative to the active hotbar.",
defaultTabToolTip = "Default actions for controller buttons and hotbar button assignments.",
spadlTabToolTip = "Actions and hotbar assignments when under the LEFTSHOULDER modifier. An unassigned button will recieve the DEFAULT actions. Modifiers are exclusive and only modify the DEFAULT tab.",
spadrTabToolTip = "Actions and hotbar assignments when under the RIGHTSHOULDER modifier. An unassigned button will recieve the DEFAULT actions. Modifiers are exclusive and only modify the DEFAULT tab.",
ppadlTabToolTip = "Actions and hotbar assignments when under the LEFTPADDLE modifier. An unassigned button will recieve the DEFAULT actions. Modifiers are exclusive and only modify the DEFAULT tab.",
ppadrTabToolTip = "Actions and hotbar assignments when under the RIGHTPADDLE modifier. An unassigned button will recieve the DEFAULT actions. Modifiers are exclusive and only modify the DEFAULT tab.",
hotbarTypeToolTip = "Hotbars can be created with LibActionButton or reuse the existing Blizzard Actionbars. When using Blizzard Actiobars Edit Mode can change the hotbar positions. Interacting with the Crosshotbar will restore the positions if moved.",
hotkeyTypeToolTip = "Button icons used in the gui and hotkeys can be set to shapes or letters.",
expandedTypeToolTip = "When either LEFTHOTBAR or RIGHTHOTBAR are double clicked HOTBARBTN[9-12] are mapped to HOTBARBTN[1-4]. This setting controls the visual cue of their activation.",
dadaTypeToolTip = "The Cross hotbar can have two layouts. One with each bar on a given side or another that interleaves the hotbars.",
pageIndexToolTip = "The default page displayed by the hotbar.",
pagePrefixToolTip = "The prefix macro conditional to control paging under certain conditionals. Default page should not be included in this string.",
enabeGamePadToolTip = "Toggle global GamePad mode.",
enabeCVarToolTip = "Toggle CVar settings and hooks used by Crosshotbar. Disabling requires reloading.",
gamepadLookToolTip = "Toggle CrossHotbar camera look handling and mouse mode for GamePad controls.",
mouseLookToolTip = "Toggle mouse look handling. Enabling allows camera look control for keyboard binding setup.",
deviceToolTip = "The DeviceId of the gamepad.",
leftclickToolTip = "Left click binding for mouse mode.",
rightclickToolTip = "Right click binding for mouse mode."
}
local ConfigUI = {
preset = 0,
Inset = 16,
ConfigSpacing = 20,
TextHeight = 20,
SymbolHeight = 32,
SymbolWidth = 32,
ButtonWidth = 80,
ButtonHeight = 24,
TabWidth = 64,
TabHeight = 32,
DropDownSpacing = 60,
EditBoxHeight = 30,
EditBoxSpacing = 30,
InterfaceFrame = nil,
RefreshCallbacks = {}
}
local function BindingDropDownDemo_OnClick(self, arg1, arg2, checked)
local newaction = self:GetText()
local currentaction = config.PadActions[arg1].BIND
if currentaction ~= newaction then
if newaction ~= "NONE" then
for button, attributes in pairs(config.PadActions) do
if button ~= arg1 then
if attributes.BIND == newaction then
config.PadActions[button].BIND = "NONE"
break
end
end
end
end
config.PadActions[arg1].BIND = newaction
end
ConfigUI:Refresh(true)
end
local function ActionDropDownDemo_OnClick(self, arg1, arg2, checked)
local newaction = self:GetText()
local currentaction = config.PadActions[arg1][arg2]
if currentaction ~= newaction then
if newaction ~= "NONE" then
for button, attributes in pairs(config.PadActions) do
if button ~= arg1 then
if attributes[arg2] == newaction then
config.PadActions[button][arg2] = "NONE"
break
end
end
end
end
config.PadActions[arg1][arg2] = newaction
end
ConfigUI:Refresh(true)
end
local function HotbarBtnDropDownDemo_OnClick(self, arg1, arg2, checked)
local newaction = self:GetText()
local currentaction = config.PadActions[arg1][arg2]
if currentaction ~= newaction then
if newaction ~= "NONE" then
for button, attributes in pairs(config.PadActions) do
if button ~= arg1 then
if attributes[arg2] == newaction then
config.PadActions[button][arg2] = "NONE"
break
end
end
end
end
config.PadActions[arg1][arg2] = newaction
end
ConfigUI:Refresh(true)
end
local function FilterDropDownText(name)
if name == "NONE" then
return ""
else
return name
end
end
local function ActionsAvailable(button, prefix, ActionType)
if prefix .. ActionType ~= "ACTION" then
if prefix == button then
return false
end
if config.PadActions[button]["ACTION"] == "LEFTHOTBAR" or
config.PadActions[button]["ACTION"] == "RIGHTHOTBAR" then
return false
end
end
return true
end
function ConfigUI:AddToolTip(frame, text, wrap)
frame:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_TOP")
GameTooltip:ClearLines()
GameTooltip:SetText(text, 1, 1, 1, 1, wrap)
end)
frame:SetScript("OnLeave", function(self)
GameTooltip:SetOwner(WorldFrame, "ANCHOR_LEFT")
GameTooltip:ClearLines()
end)
end
function ConfigUI:Refresh(updated)
if self.InterfaceFrame:IsVisible() or
self.PresetFrame:IsVisible() or
self.ActionFrame:IsVisible() or
self.HotbarFrame:IsVisible() or
self.GamePadFrame:IsVisible() then
for i,callback in ipairs(self.RefreshCallbacks) do
callback()
end
addon:ApplyConfig(updated)
end
end
function ConfigUI:OnConfigInit()
ConfigUI.preset = CrossHotbar_DB.ActivePreset
end
function ConfigUI:CreateFrame()
self.InterfaceFrame = CreateFrame("Frame", ADDON .. "ConfigFrame", InterfaceOptionsFramePanelContainer)
self.InterfaceFrame.name = ADDON
self.InterfaceFrame:Hide()
addon:AddInitCallback(GenerateClosure(self.OnConfigInit, self))
self.InterfaceFrame:SetScript("OnShow", function(InterfaceFrame)
local title = InterfaceFrame:CreateFontString(nil, "ARTWORK", "GameFontHighlightHuge")
title:SetPoint("TOPLEFT", self.Inset, -self.Inset)
title:SetText("CrossHotbar")
local authortitle = InterfaceFrame:CreateFontString(nil, "ARTWORK", "GameFontNormal")
authortitle:SetPoint("TOPLEFT", title, "TOPLEFT", 0, -2 * self.ConfigSpacing)
authortitle:SetText("Author")
local author = InterfaceFrame:CreateFontString(nil, "ARTWORK", "GameFontNormal")
author:SetPoint("TOPLEFT", authortitle, "TOPLEFT", self.Inset, -self.TextHeight)
author:SetWidth(InterfaceFrame:GetWidth() - 4 * self.Inset)
author:SetJustifyH("LEFT")
author:SetText("ChainStratagem (phodoe)")
author:SetTextColor(1,1,1,1)
local descripttitle = InterfaceFrame:CreateFontString(nil, "ARTWORK", "GameFontNormal")
descripttitle:SetPoint("TOPLEFT", author, "TOPLEFT", -self.Inset, -self.ConfigSpacing)
descripttitle:SetText("Description")
local descript = InterfaceFrame:CreateFontString(nil, "ARTWORK", "GameFontNormal")
descript:SetPoint("TOPLEFT", descripttitle, "TOPLEFT", self.Inset, -self.TextHeight)
descript:SetWidth(InterfaceFrame:GetWidth() - 4 * self.Inset)
descript:SetJustifyH("LEFT")
descript:SetText([[
Addon to reconfigure default Actionbars into the WXHB Crosshotbar found in FFXIV.
Features:
-Left and right hotbar selection with extended right-left and left-right back hotbars.
-Double click expands hotbar and maps actions buttons[9-12] onto face buttons.
-Reconfigurable modifier buttons to override default action settings.
-Target traversal with trigger shoulder pad combinations.
-Unit raid and party navigation actions for dpad party traversal.
-Cursor and camera look support through bindable actions.
-Actions to execute user macros named CH_MACRO_[1-4]
-Drag bar activated by clicking on the hotbar seperator line.
Settings:
Presets: Load and Save controler settings, bindings, and actions.
Actions: Set button bindings and action assignments.
Hotbars: Hotbar specific settings controlling paging and display.
GamePad: Gamepad settings with camera and cursor controls.
]])
descript:SetTextColor(1,1,1,1)
InterfaceFrame:SetScript("OnShow", function(frame) ConfigUI:Refresh() end)
ConfigUI:Refresh()
end)
local category, layout = Settings.RegisterCanvasLayoutCategory(self.InterfaceFrame,
self.InterfaceFrame.name)
Settings.RegisterAddOnCategory(category)
self.PresetFrame = CreateFrame("Frame", ADDON .. "PresetsSettings", self.InterfaceFrame)
self.PresetFrame.name = "Presets"
self.PresetFrame.parent = self.InterfaceFrame.name
self.PresetFrame:Hide()
self.PresetFrame:SetScript("OnShow", function(PresetFrame)
local title = PresetFrame:CreateFontString(nil, "ARTWORK", "GameFontHighlightHuge")
title:SetPoint("TOPLEFT", self.Inset, -self.Inset)
title:SetText("Presets")
local anchor = title
anchor = ConfigUI:CreatePresets(PresetFrame, anchor)
PresetFrame:SetScript("OnShow", function(frame) ConfigUI:Refresh() end)
ConfigUI:Refresh()
end)
Settings.RegisterCanvasLayoutSubcategory(category,
self.PresetFrame,
self.PresetFrame.name)
self.ActionFrame = CreateFrame("Frame", ADDON .. "ActionsSettings", self.InterfaceFrame)
self.ActionFrame.name = "Actions"
self.ActionFrame.parent = self.InterfaceFrame.name
self.ActionFrame:Hide()
self.ActionFrame:SetScript("OnShow", function(ActionFrame)
local scrollFrame = CreateFrame("ScrollFrame", nil, ActionFrame, "UIPanelScrollFrameTemplate")
scrollFrame:SetPoint("TOPLEFT", 3, -4)
scrollFrame:SetPoint("BOTTOMRIGHT", -27, 4)
local scrollChild = CreateFrame("Frame")
scrollFrame:SetScrollChild(scrollChild)
scrollChild:SetWidth(ActionFrame:GetWidth()-self.Inset)
scrollChild:SetHeight(1)
local title = scrollChild:CreateFontString(nil, "ARTWORK", "GameFontHighlightHuge")
title:SetPoint("TOPLEFT", self.Inset, -self.Inset)
title:SetText("Actions Settings")
local anchor = title
anchor = ConfigUI:CreatePadBindings(scrollChild, anchor)
anchor, tab1, tab2, tab3, tab4, tab5 =
ConfigUI:CreateTabFrame(scrollChild, anchor)
ConfigUI:CreatePadActions(tab1, tab1, "", GamePadActionMap, GamePadHotbarMap)
ConfigUI:CreatePadActions(tab2, tab2, "SPADL", GamePadModifierActionMap, GamePadHotbarMap)
ConfigUI:CreatePadActions(tab3, tab3, "SPADR", GamePadModifierActionMap, GamePadHotbarMap)
ConfigUI:CreatePadActions(tab4, tab4, "PPADL", GamePadModifierActionMap, GamePadHotbarMap)
ConfigUI:CreatePadActions(tab5, tab5, "PPADR", GamePadModifierActionMap, GamePadHotbarMap)
table.insert(self.RefreshCallbacks, function()
local spadlactive = false
local spadractive = false
local ppadlactive = false
local ppadractive = false
for i,button in ipairs(GamePadButtonList) do
if config.PadActions[button].ACTION == "LEFTSHOULDER" then spadlactive = true end
if config.PadActions[button].ACTION == "RIGHTSHOULDER" then spadractive = true end
if config.PadActions[button].ACTION == "LEFTPADDLE" then ppadlactive = true end
if config.PadActions[button].ACTION == "RIGHTPADDLE" then ppadractive = true end
end
PanelTemplates_SetTabEnabled(anchor, 2, spadlactive)
PanelTemplates_SetTabEnabled(anchor, 3, spadractive)
PanelTemplates_SetTabEnabled(anchor, 4, ppadlactive)
PanelTemplates_SetTabEnabled(anchor, 5, ppadractive)
end)
ActionFrame:SetScript("OnShow", function(frame) ConfigUI:Refresh() end)
ConfigUI:Refresh()
end)
Settings.RegisterCanvasLayoutSubcategory(category,
self.ActionFrame,
self.ActionFrame.name)
self.HotbarFrame = CreateFrame("Frame", ADDON .. "HotbarsSettings", self.InterfaceFrame)
self.HotbarFrame.name = "Hotbars"
self.HotbarFrame.parent = self.InterfaceFrame.name
self.HotbarFrame:Hide()
self.HotbarFrame:SetScript("OnShow", function(HotbarFrame)
local scrollFrame = CreateFrame("ScrollFrame", nil, HotbarFrame, "UIPanelScrollFrameTemplate")
scrollFrame:SetPoint("TOPLEFT", 3, -4)
scrollFrame:SetPoint("BOTTOMRIGHT", -27, 4)
local scrollChild = CreateFrame("Frame")
scrollFrame:SetScrollChild(scrollChild)
scrollChild:SetWidth(HotbarFrame:GetWidth()-self.Inset)
scrollChild:SetHeight(1)
local title = scrollChild:CreateFontString(nil, "ARTWORK", "GameFontHighlightHuge")
title:SetPoint("TOPLEFT", self.Inset, -self.Inset)
title:SetText("Hotbar Settings")
local anchor = title
anchor = ConfigUI:CreateHotbarSettings(scrollChild, anchor)
HotbarFrame:SetScript("OnShow", function(frame) ConfigUI:Refresh() end)
ConfigUI:Refresh()
end)
Settings.RegisterCanvasLayoutSubcategory(category,
self.HotbarFrame,
self.HotbarFrame.name)
self.GamePadFrame = CreateFrame("Frame", ADDON .. "GamePadSettings", self.InterfaceFrame)
self.GamePadFrame.name = "GamePad"
self.GamePadFrame.parent = self.InterfaceFrame.name
self.GamePadFrame:Hide()
self.GamePadFrame:SetScript("OnShow", function(GamePadFrame)
local title = GamePadFrame:CreateFontString(nil, "ARTWORK", "GameFontHighlightHuge")
title:SetPoint("TOPLEFT", self.Inset, -self.Inset)
title:SetText("GamePad Settings")
local anchor = title
anchor = ConfigUI:CreateGamePadSettings(GamePadFrame, anchor)
GamePadFrame:SetScript("OnShow", function(frame) ConfigUI:Refresh() end)
ConfigUI:Refresh()
end)
Settings.RegisterCanvasLayoutSubcategory(category,
self.GamePadFrame,
self.GamePadFrame.name)
SLASH_WXHBCROSSHOTBAR1, SLASH_WXHBCROSSHOTBAR2 = '/chb', '/wxhb';
local function slashcmd(msg, editBox)
Settings.OpenToCategory(category.ID)
end
SlashCmdList["WXHBCROSSHOTBAR"] = slashcmd;
end
function ConfigUI:CreateTabFrame(configFrame, anchorFrame)
local DropDownWidth = (configFrame:GetWidth() - self.SymbolWidth - 4*self.Inset)/3
local tabframe = CreateFrame("Frame", ADDON .. "ActionTabFrame", configFrame, "BackdropTemplate")
tabframe:EnableMouse(true)
tabframe:SetHeight(anchorFrame:GetHeight())
tabframe:SetWidth(2*DropDownWidth)
tabframe:SetBackdropColor(0, 0, 1, .5)
tabframe:SetPoint("TOPLEFT", anchorFrame, "TOPRIGHT", 0, 0)
tabframe:SetBackdrop({
bgFile="Interface/DialogFrame/UI-DialogBox-Background",
edgeFile="Interface/DialogFrame/UI-DialogBox-Border",
tile = false,
tileEdge = false,
tileSize = 0,
edgeSize = 16,
insets = { left = 0, right = 0, top = 0, bottom = 0 }
})
local tab1frame = CreateFrame("Frame", tabframe:GetName() .. "Page1", tabframe)
tab1frame:SetPoint("TOPLEFT", tabframe, "TOPLEFT", 0, 0)
tab1frame:SetHeight(tabframe:GetHeight())
tab1frame:SetWidth(tabframe:GetWidth())
local tab2frame = CreateFrame("Frame", tabframe:GetName() .. "Page2", tabframe)
tab2frame:SetPoint("TOPLEFT", tabframe, "TOPLEFT", 0, 0)
tab2frame:SetHeight(tabframe:GetHeight())
tab2frame:SetWidth(tabframe:GetWidth())
local tab3frame = CreateFrame("Frame", tabframe:GetName() .. "Page3", tabframe)
tab3frame:SetPoint("TOPLEFT", tabframe, "TOPLEFT", 0, 0)
tab3frame:SetHeight(tabframe:GetHeight())
tab3frame:SetWidth(tabframe:GetWidth())
local tab4frame = CreateFrame("Frame", tabframe:GetName() .. "Page4", tabframe)
tab4frame:SetPoint("TOPLEFT", tabframe, "TOPLEFT", 0, 0)
tab4frame:SetHeight(tabframe:GetHeight())
tab4frame:SetWidth(tabframe:GetWidth())
local tab5frame = CreateFrame("Frame", tabframe:GetName() .. "Page5", tabframe)
tab5frame:SetPoint("TOPLEFT", tabframe, "TOPLEFT", 0, 0)
tab5frame:SetHeight(tabframe:GetHeight())
tab5frame:SetWidth(tabframe:GetWidth())
--[[
Tab Default
--]]
local tab1button = CreateFrame("Button", tabframe:GetName() .. "Tab1", tabframe, "PanelTopTabButtonTemplate")
tab1button:SetPoint("BOTTOMLEFT", tabframe, "TOPLEFT", 0, 0)
tab1button:SetHeight(self.TabHeight)
tab1button:SetWidth(self.TabWidth)
tab1button:SetText("DEFAULT")
tab1button:SetID(1)
ConfigUI:AddToolTip(tab1button, Locale.defaultTabToolTip, true)
tab1button:SetScript("OnClick", function(self)
PanelTemplates_SetTab(tabframe, 1)
tab1frame:Show()
tab2frame:Hide()
tab3frame:Hide()
tab4frame:Hide()
tab5frame:Hide()
end)
--[[
Tab Left Shoulder
--]]
local tab2button = CreateFrame("Button", tabframe:GetName() .. "Tab2", tabframe, "PanelTopTabButtonTemplate")
tab2button:SetPoint("TOPLEFT", tab1button, "TOPRIGHT", 0, 0)
tab2button:SetHeight(self.TabHeight)
tab2button:SetWidth(self.TabWidth)
tab2button:SetText("SPADL")
tab2button:SetID(2)
ConfigUI:AddToolTip(tab2button, Locale.spadlTabToolTip, true)
tab2button:SetScript("OnClick", function(self)
PanelTemplates_SetTab(tabframe, 2)
tab1frame:Hide()
tab2frame:Show()
tab3frame:Hide()
tab4frame:Hide()
tab5frame:Hide()
end)
--[[
Tab Right Shoulder
--]]
local tab3button = CreateFrame("Button", tabframe:GetName() .. "Tab3", tabframe, "PanelTopTabButtonTemplate")
tab3button:SetPoint("TOPLEFT", tab2button, "TOPRIGHT", 0, 0)
tab3button:SetHeight(self.TabHeight)
tab3button:SetWidth(self.TabWidth)
tab3button:SetText("SPADR")
tab3button:SetID(3)
ConfigUI:AddToolTip(tab3button, Locale.spadrTabToolTip, true)
tab3button:SetScript("OnClick", function(self)
PanelTemplates_SetTab(tabframe, 3)
tab1frame:Hide()
tab2frame:Hide()
tab3frame:Show()
tab4frame:Hide()
tab5frame:Hide()
end)
--[[
Tab Left Paddle
--]]
local tab4button = CreateFrame("Button", tabframe:GetName() .. "Tab4", tabframe, "PanelTopTabButtonTemplate")
tab4button:SetPoint("TOPLEFT", tab3button, "TOPRIGHT", 0, 0)
tab4button:SetHeight(self.TabHeight)
tab4button:SetWidth(self.TabWidth)
tab4button:SetText("PPADL")
tab4button:SetID(4)
ConfigUI:AddToolTip(tab4button, Locale.ppadlTabToolTip, true)
tab4button:SetScript("OnClick", function(self)
PanelTemplates_SetTab(tabframe, 4)
tab1frame:Hide()
tab2frame:Hide()
tab3frame:Hide()
tab4frame:Show()
tab5frame:Hide()
end)
--[[
Tab Right Paddle
--]]
local tab5button = CreateFrame("Button", tabframe:GetName() .. "Tab5", tabframe, "PanelTopTabButtonTemplate")
tab5button:SetPoint("TOPLEFT", tab4button, "TOPRIGHT", 0, 0)
tab5button:SetHeight(self.TabHeight)
tab5button:SetWidth(self.TabWidth)
tab5button:SetText("PPADR")
tab5button:SetID(5)
ConfigUI:AddToolTip(tab5button, Locale.ppadrTabToolTip, true)
tab5button:SetScript("OnClick", function(self)
PanelTemplates_SetTab(tabframe, 5)
tab1frame:Hide()
tab2frame:Hide()
tab3frame:Hide()
tab4frame:Hide()
tab5frame:Show()
end)
tabframe:SetScript("OnShow", function(self)
PanelTemplates_SetTab(tabframe, 1)
tab1frame:Show()
tab2frame:Hide()
tab3frame:Hide()
tab4frame:Hide()
tab5frame:Hide()
end)
PanelTemplates_SetNumTabs(tabframe, 5)
PanelTemplates_SetTab(tabframe, 1)
tab1frame:Show()
tab2frame:Hide()
tab3frame:Hide()
tab4frame:Hide()
tab5frame:Hide()
return tabframe, tab1frame, tab2frame, tab3frame, tab4frame, tab5frame
end
--[[
Presets
--]]
function ConfigUI:CreatePresets(configFrame, anchorFrame)
local DropDownWidth = configFrame:GetWidth()/2 - 2*self.Inset
local presetsubtitle = configFrame:CreateFontString(nil, "ARTWORK", "GameFontNormal")
presetsubtitle:SetHeight(self.TextHeight)
presetsubtitle:SetWidth(DropDownWidth)
presetsubtitle:SetPoint("TOPLEFT", anchorFrame, "BOTTOMLEFT", 0, -self.ConfigSpacing)
presetsubtitle:SetNonSpaceWrap(true)
presetsubtitle:SetJustifyH("CENTER")
presetsubtitle:SetJustifyV("TOP")
presetsubtitle:SetText("Presets")
local PresetsDropDown = LibDD:Create_UIDropDownMenu(nil, configFrame)
PresetsDropDown:SetPoint("TOPLEFT", presetsubtitle, "BOTTOMLEFT", 0, 0)
LibDD:UIDropDownMenu_SetWidth(PresetsDropDown, DropDownWidth-self.DropDownSpacing)
LibDD:UIDropDownMenu_SetText(PresetsDropDown, "Presets")
LibDD:UIDropDownMenu_JustifyText(PresetsDropDown, "LEFT")
local function PresetDropDownDemo_OnClick(self, arg1, arg2, checked)
if ConfigUI.preset ~= arg1 then
ConfigUI.preset = arg1
LibDD:UIDropDownMenu_SetText(arg2, self:GetText())
ConfigUI:Refresh(true)
end
end
LibDD:UIDropDownMenu_Initialize(PresetsDropDown, function(self, level, menuList)
local info = LibDD:UIDropDownMenu_CreateInfo()
LibDD:UIDropDownMenu_SetText(self, "")
if (level or 1) == 1 then
local presets = CrossHotbar_DB.Presets
for i,p in ipairs(presets) do
info.text, info.checked = p.Name, ConfigUI.preset == i
info.menuList, info.hasArrow = i, false
info.arg1 = i
info.arg2 = self
info.func = PresetDropDownDemo_OnClick
LibDD:UIDropDownMenu_AddButton(info)
if ConfigUI.preset == i then
LibDD:UIDropDownMenu_SetText(self, CrossHotbar_DB.Presets[ConfigUI.preset].Name)
end
end
end
end)
local presetloadbutton = CreateFrame("Button", nil, configFrame, "UIPanelButtonTemplate")
presetloadbutton:SetPoint("TOPLEFT", PresetsDropDown, "TOPRIGHT", 0, 0)
presetloadbutton:SetHeight(self.ButtonHeight)
presetloadbutton:SetWidth(self.ButtonWidth)
presetloadbutton:SetText("Load")
presetloadbutton:SetScript("OnClick", function(self, button, down)
CrossHotbar_DB.ActivePreset = ConfigUI.preset
config:StorePreset(config, CrossHotbar_DB.Presets[ConfigUI.preset])
ConfigUI:Refresh(true)
end)
local presetdeletebutton = CreateFrame("Button", nil, configFrame, "UIPanelButtonTemplate")
presetdeletebutton:SetPoint("TOPLEFT", presetloadbutton, "TOPRIGHT", 0, 0)
presetdeletebutton:SetHeight(self.ButtonHeight)
presetdeletebutton:SetWidth(self.ButtonWidth)
presetdeletebutton:SetEnabled(false)
presetdeletebutton:SetText("Delete")
presetdeletebutton:SetScript("OnClick", function(self, button, down)
if CrossHotbar_DB.Presets[ConfigUI.preset].Mutable then
table.remove(CrossHotbar_DB.Presets, ConfigUI.preset)
ConfigUI.preset = ConfigUI.preset + 1
if ConfigUI.preset > #CrossHotbar_DB.Presets then
ConfigUI.preset = #CrossHotbar_DB.Presets
end
CrossHotbar_DB.ActivePreset = ConfigUI.preset
end
config.Name = "Custom"
config:StorePreset(config, CrossHotbar_DB.Presets[ConfigUI.preset])
LibDD:UIDropDownMenu_SetText(PresetsDropDown, CrossHotbar_DB.Presets[ConfigUI.preset].Name)
--ConfigUI:Refresh(true)
end)
local filesubtitle = configFrame:CreateFontString(nil, "ARTWORK", "GameFontNormal")
filesubtitle:SetHeight(self.TextHeight)
filesubtitle:SetWidth(DropDownWidth)
filesubtitle:SetPoint("TOPLEFT", PresetsDropDown, "BOTTOMLEFT", 0, -self.ConfigSpacing)
filesubtitle:SetNonSpaceWrap(true)
filesubtitle:SetJustifyH("CENTER")
filesubtitle:SetJustifyV("TOP")
filesubtitle:SetText("Name")
local presetfileeditbox = CreateFrame("EditBox", nil, configFrame, "InputBoxTemplate")
presetfileeditbox:SetPoint("TOPLEFT", filesubtitle, "BOTTOMLEFT", 24, 0)
presetfileeditbox:SetWidth(DropDownWidth-self.DropDownSpacing)
presetfileeditbox:SetHeight(self.EditBoxHeight)
presetfileeditbox:SetMovable(false)
presetfileeditbox:SetAutoFocus(false)
presetfileeditbox:EnableMouse(true)
presetfileeditbox:SetText(config.Name)
local presetsavebutton = CreateFrame("Button", nil, configFrame, "UIPanelButtonTemplate")
presetsavebutton:SetPoint("LEFT", presetfileeditbox, "RIGHT", 24, 0)
presetsavebutton:SetHeight(self.ButtonHeight)
presetsavebutton:SetWidth(self.ButtonWidth)
presetsavebutton:SetText("Save")
presetsavebutton:SetScript("OnClick", function(self, button, down)
if presetfileeditbox:GetText() ~= "" then
local foundpreset = 0
for i,p in ipairs(CrossHotbar_DB.Presets) do
if p.Name == presetfileeditbox:GetText() then
foundpreset = i
end
end
if foundpreset == 0 then
config.Name = presetfileeditbox:GetText()
local newpreset = {
Mutable = true
}
config:StorePreset(newpreset, config)
table.insert(CrossHotbar_DB.Presets, newpreset)
ConfigUI.preset = #CrossHotbar_DB.Presets
CrossHotbar_DB.ActivePreset = ConfigUI.preset
elseif CrossHotbar_DB.Presets[foundpreset].Mutable then
ConfigUI.preset = foundpreset
CrossHotbar_DB.ActivePreset = ConfigUI.preset
config:StorePreset(CrossHotbar_DB.Presets[ConfigUI.preset], config)
end
end
ConfigUI:Refresh(true)
end)
local descripttitle = configFrame:CreateFontString(nil, "ARTWORK", "GameFontNormal")
descripttitle:SetPoint("TOPLEFT", presetfileeditbox, "BOTTOMLEFT", 0, -4*self.ConfigSpacing)
descripttitle:SetWidth(2*DropDownWidth-self.DropDownSpacing)
descripttitle:SetNonSpaceWrap(true)
descripttitle:SetJustifyH("CENTER")
descripttitle:SetJustifyV("TOP")
descripttitle:SetText("Description")
local backdropframe = CreateFrame("Frame", nil, configFrame, "BackdropTemplate")
backdropframe:SetBackdrop({
bgFile="Interface/DialogFrame/UI-DialogBox-Background",
edgeFile="Interface/DialogFrame/UI-DialogBox-Border",
tile = false,
tileEdge = false,
tileSize = 0,
edgeSize = 8,
insets = { left = 0, right = 0, top = 0, bottom = 0 }
})
backdropframe:SetPoint("TOPLEFT", descripttitle, "BOTTOMLEFT", 0, -self.ConfigSpacing)
backdropframe:SetSize(2*DropDownWidth-self.DropDownSpacing, 200)
local scrollFrame = CreateFrame("ScrollFrame", nil, backdropframe, "UIPanelScrollFrameTemplate, BackdropTemplate")
scrollFrame:SetSize(backdropframe:GetWidth()-40, backdropframe:GetHeight()-20)
scrollFrame:SetPoint("TOPLEFT", backdropframe, "TOPLEFT", 10, -10)
local descriptfileeditbox = CreateFrame("EditBox", nil, scrollFrame)
descriptfileeditbox:SetMultiLine(true)
descriptfileeditbox:SetMovable(false)
descriptfileeditbox:SetAutoFocus(false)
descriptfileeditbox:EnableMouse(true)
descriptfileeditbox:SetFontObject(ChatFontNormal)
descriptfileeditbox:SetSize(backdropframe:GetWidth()-40,
backdropframe:GetHeight()-20)
descriptfileeditbox:SetText(config.Description)
scrollFrame:SetScrollChild(descriptfileeditbox)
table.insert(self.RefreshCallbacks, function()
presetdeletebutton:SetEnabled(CrossHotbar_DB.Presets[ConfigUI.preset].Mutable)
presetfileeditbox:SetText(config.Name)
LibDD:UIDropDownMenu_SetText(PresetsDropDown, CrossHotbar_DB.Presets[ConfigUI.preset].Name)
descriptfileeditbox:SetText(config.Description)
end)
return PresetsDropDown
end
--[[
Pad bindings.
--]]
function ConfigUI:CreatePadBindings(configFrame, anchorFrame)
local DropDownWidth = (configFrame:GetWidth() - self.SymbolWidth - 4*self.Inset)/3
local bindingframe = CreateFrame("Frame", nil, configFrame, "BackdropTemplate")
bindingframe:EnableMouse(true)
bindingframe:SetHeight(#GamePadButtonList * 32 + 2*self.TextHeight + self.ConfigSpacing)
bindingframe:SetWidth(self.SymbolWidth + 100 + DropDownWidth - self.DropDownSpacing - self.Inset)
bindingframe:SetBackdropColor(0, 0, 1, .5)
bindingframe:SetPoint("TOPLEFT", anchorFrame, "BOTTOMLEFT", 0, -self.ConfigSpacing -anchorFrame:GetHeight())
bindingframe:SetBackdrop({
bgFile="Interface/DialogFrame/UI-DialogBox-Background",
edgeFile="Interface/DialogFrame/UI-DialogBox-Border",
tile = false,
tileEdge = false,
tileSize = 0,
edgeSize = 16,
insets = { left = 0, right = 0, top = 0, bottom = 0 }
})
local buttonsubtitle = bindingframe:CreateFontString(nil, "ARTWORK", "GameFontNormal")
buttonsubtitle:SetHeight(self.TextHeight)
buttonsubtitle:SetWidth(self.SymbolWidth+self.Inset)
buttonsubtitle:SetPoint("TOPLEFT", bindingframe, "TOPLEFT", self.Inset, -self.ConfigSpacing)
buttonsubtitle:SetNonSpaceWrap(true)
buttonsubtitle:SetJustifyH("CENTER")
buttonsubtitle:SetJustifyV("TOP")
buttonsubtitle:SetText("Button")
local bindingsubtitle = bindingframe:CreateFontString(nil, "ARTWORK", "GameFontNormal")
bindingsubtitle:SetHeight(self.TextHeight)
bindingsubtitle:SetWidth(DropDownWidth)
bindingsubtitle:SetPoint("TOPLEFT", buttonsubtitle, "TOPRIGHT", 0, 0)
bindingsubtitle:SetNonSpaceWrap(true)
bindingsubtitle:SetJustifyH("CENTER")
bindingsubtitle:SetJustifyV("TOP")
bindingsubtitle:SetText("Binding")
local buttoninset = self.Inset
local buttonanchor = buttonsubtitle
local bindinganchor = bindingsubtitle
for i,button in ipairs(GamePadButtonList) do
if config.PadActions[button] then
local attributes = config.PadActions[button]
local buttonsubtitle = bindingframe:CreateFontString(nil, "ARTWORK", "GameFontNormal")
buttonsubtitle:SetHeight(32)
buttonsubtitle:SetWidth(self.SymbolWidth)
buttonsubtitle:SetPoint("TOPLEFT", buttonanchor, "BOTTOMLEFT", 0.5*buttoninset, 0)
buttonsubtitle:SetNonSpaceWrap(true)
buttonsubtitle:SetJustifyH("CENTER")
buttonsubtitle:SetJustifyV("TOP")
buttonsubtitle:SetText(addon:GetButtonIcon(button))
buttonsubtitle:SetScript("OnShow", function(frame) buttonsubtitle:SetText(addon:GetButtonIcon(button)) end)
local bindingframe = LibDD:Create_UIDropDownMenu(nil, bindingframe)
bindingframe:SetPoint("TOPLEFT", bindinganchor, "BOTTOMLEFT", 0, 0)
LibDD:UIDropDownMenu_SetWidth(bindingframe, DropDownWidth-self.DropDownSpacing)
LibDD:UIDropDownMenu_SetText(bindingframe, "NONE")
LibDD:UIDropDownMenu_JustifyText(bindingframe, "LEFT")
LibDD:UIDropDownMenu_Initialize(bindingframe, function(self, level, menuList)
local info = LibDD:UIDropDownMenu_CreateInfo()
LibDD:UIDropDownMenu_SetText(self, "")
if (level or 1) == 1 then
local a = config.PadActions
for _,binding in ipairs(GamePadBindingList) do
info.text, info.checked = binding, (a[button].BIND == binding)
info.menuList, info.hasArrow = i, false
info.arg1, info.arg2 = button, ConfigUI
info.func = BindingDropDownDemo_OnClick
LibDD:UIDropDownMenu_AddButton(info)
if (a[button].BIND == binding) then
LibDD:UIDropDownMenu_SetText(self, binding)
end
end
end
end)
ConfigUI:AddToolTip(bindingframe, Locale.bindingToolTip, true)
table.insert(self.RefreshCallbacks, function()
LibDD:UIDropDownMenu_SetText(bindingframe, config.PadActions[button].BIND)
end)
buttoninset = 0
buttonanchor = buttonsubtitle
bindinganchor = bindingframe
end
end
return bindingframe
end
--[[
Pad actions.
--]]
function ConfigUI:CreatePadActions(configFrame, anchorFrame, prefix, ActionMap, HotbarMap)
local DropDownWidth = (configFrame:GetWidth() - self.Inset)/2
local actionsubtitle = configFrame:CreateFontString(nil, "ARTWORK", "GameFontNormal")
actionsubtitle:SetHeight(self.TextHeight)
actionsubtitle:SetWidth(DropDownWidth)
actionsubtitle:SetPoint("TOPLEFT", anchorFrame, "TOPLEFT", self.Inset, -self.ConfigSpacing)
actionsubtitle:SetNonSpaceWrap(true)
actionsubtitle:SetJustifyH("CENTER")
actionsubtitle:SetJustifyV("TOP")
actionsubtitle:SetText("Action")
local hotbarsubtitle = configFrame:CreateFontString(nil, "ARTWORK", "GameFontNormal")
hotbarsubtitle:SetHeight(self.TextHeight)
hotbarsubtitle:SetWidth(DropDownWidth)
hotbarsubtitle:SetPoint("TOPLEFT", actionsubtitle, "TOPRIGHT", 0, 0)
hotbarsubtitle:SetNonSpaceWrap(true)
hotbarsubtitle:SetJustifyH("CENTER")
hotbarsubtitle:SetJustifyV("TOP")
hotbarsubtitle:SetText("Hotbar Action")
local actionanchor = actionsubtitle
local hotbaranchor = hotbarsubtitle
for i,button in ipairs(GamePadButtonList) do
if config.PadActions[button] then
local attributes = config.PadActions[button]
local actionframe = LibDD:Create_UIDropDownMenu(nil, configFrame)
actionframe:SetPoint("TOPLEFT", actionanchor, "BOTTOMLEFT", 0, 0)
LibDD:UIDropDownMenu_SetWidth(actionframe, DropDownWidth-self.DropDownSpacing)
LibDD:UIDropDownMenu_SetText(actionframe, "NONE")
LibDD:UIDropDownMenu_JustifyText(actionframe, "LEFT")
LibDD:UIDropDownMenu_Initialize(actionframe, function(self, level, menuList)
local info = LibDD:UIDropDownMenu_CreateInfo()
LibDD:UIDropDownMenu_SetText(self, "")
if (level or 1) == 1 then
local a = config.PadActions
local actions = {"NONE"}
if ActionsAvailable(button, prefix, "ACTION") then
actions = ActionMap[button]
end
for _,action in ipairs(actions) do
info.text, info.checked = action, (a[button][prefix .. "ACTION"] == action)
info.menuList, info.hasArrow = i, false
info.arg1, info.arg2 = button, prefix .. "ACTION"
info.func = ActionDropDownDemo_OnClick
LibDD:UIDropDownMenu_AddButton(info)
if (a[button][prefix .. "ACTION"] == action) then
LibDD:UIDropDownMenu_SetText(self, FilterDropDownText(action))