-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptions.lua
More file actions
3950 lines (3784 loc) · 224 KB
/
Copy pathOptions.lua
File metadata and controls
3950 lines (3784 loc) · 224 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
local ADDON, ns = ...
local C = ns.COLORS
local BASE_ACCENT = { C.accent[1], C.accent[2], C.accent[3], C.accent[4] }
local BASE_BLUE = { C.blue[1], C.blue[2], C.blue[3], C.blue[4] }
local BASE_BORDER = { C.border[1], C.border[2], C.border[3], C.border[4] }
local BASE_TEAL = { C.teal[1], C.teal[2], C.teal[3], C.teal[4] }
local function PlayerClassFile()
local ok, _, classFile = pcall(UnitClass, "player")
if not ok or classFile == nil or (issecretvalue and issecretvalue(classFile)) then return nil end
return classFile
end
-- Cinematic normally owns the warm orange identity used by the original
-- editor. Druids already use an orange class accent, so violet preserves the
-- same strong mode change without looking like the normal Druid theme.
local CINEMATIC_IS_DRUID = PlayerClassFile() == "DRUID"
local CINEMATIC_ACCENT = CINEMATIC_IS_DRUID and { 0.69, 0.47, 1, 1 }
or C.cinematic or { 0.90, 0.52, 0.24, 1 }
local CINEMATIC_BORDER = CINEMATIC_IS_DRUID and { 0.39, 0.26, 0.61, 0.88 }
or { 0.52, 0.29, 0.13, 0.88 }
local CINEMATIC_BUTTON = CINEMATIC_IS_DRUID and { 0.09, 0.06, 0.16, 1 }
or { 0.14, 0.085, 0.045, 1 }
local REMOVE_RED = { 0.88, 0.31, 0.34, 1 }
local NORMAL_HEADER = { 0.043, 0.051, 0.067, 1 }
local BUTTON_HOVER = { 0.095, 0.108, 0.129, 1 }
local themeObjects = setmetatable({}, { __mode = "k" })
local euiSkin
local euiObjects = {
shell = {}, panel = {}, button = {}, font = {}, close = {}, edit = {},
}
local euiSeen = setmetatable({}, { __mode = "k" })
local euiOwned = setmetatable({}, { __mode = "k" })
local function EUIOwnsVisual(object)
return object and (euiOwned[object] or object._frameGambitEUI) or false
end
local function SetFallbackBackdrop(frame, color, border)
if not frame or EUIOwnsVisual(frame) then return end
if color and frame.SetBackdropColor then frame:SetBackdropColor(unpack(color)) end
if border and frame.SetBackdropBorderColor then frame:SetBackdropBorderColor(unpack(border)) end
end
local SELECTED_FILL_TEXT = { 0.02, 0.06, 0.07, 1 }
local function SelectedButtonText(button, selected, unselected, euiUnselected)
if not selected then
if EUIOwnsVisual(button) then return euiUnselected or C.text end
return unselected or C.accent
end
-- Standalone buttons use a bright accent fill and therefore need dark
-- text. EUI buttons deliberately stay neutral, so their active state must
-- be communicated with the same bright live accent used by BindCards.
return EUIOwnsVisual(button) and C.accent or SELECTED_FILL_TEXT
end
local function ClearShellBackdrop(frame)
if not frame or not frame.SetBackdropColor then return end
-- S.Shell owns the visible atlas/AdventureMap border. The fallback
-- Backdrop must become transparent or it will cover that shell.
frame:SetBackdropColor(0, 0, 0, 0)
frame:SetBackdropBorderColor(0, 0, 0, 0)
end
local function ApplyEUIObject(kind, object, opts, record)
if not object then return end
local list = euiObjects[kind]
if record ~= false and list and not euiSeen[object] then
list[#list + 1] = { object = object, opts = opts }
euiSeen[object] = kind
end
opts = opts or object._frameGambitEUIKeepKeys
local skin = euiSkin
local fn = skin and skin[kind == "shell" and "Shell" or kind == "panel" and "Panel" or
kind == "button" and "Button" or kind == "font" and "Font" or
kind == "close" and "CloseButton" or kind == "edit" and "EditBox"]
if fn then
local ok = pcall(fn, object, opts)
if ok then
euiOwned[object] = kind
if kind == "button" or kind == "close" then object._frameGambitEUI = true end
if kind == "shell" then ClearShellBackdrop(object) end
end
if kind == "button" and skin.WhiteButtonLabel then
pcall(skin.WhiteButtonLabel, object)
end
end
end
function ns:TrackEUIObject(kind, object, opts)
ApplyEUIObject(kind, object, opts)
end
local function UpdateEUIAccent()
if not euiSkin or not euiSkin.GetAccentColor then return end
local ok, r, g, b = pcall(euiSkin.GetAccentColor)
if not ok or type(r) ~= "number" or type(g) ~= "number" or type(b) ~= "number" then return end
-- BindCards treats the EUI accent as the live accent for both normal
-- actions and active-state marks. Keep the mutable bases in sync so a
-- later ApplyEditorTheme call cannot restore stale fallback colors.
for index, value in ipairs({ r, g, b }) do
BASE_ACCENT[index], BASE_BLUE[index], BASE_TEAL[index] = value, value, value
C.accent[index], C.blue[index], C.teal[index] = value, value, value
end
ns:ApplyEditorTheme()
end
function ns:SetEUITheme(skin)
euiSkin = skin
self.euiSkin = skin
if not skin then return end
for kind, list in pairs(euiObjects) do
for _, entry in ipairs(list) do ApplyEUIObject(kind, entry.object, entry.opts, false) end
end
UpdateEUIAccent()
if skin.OnLooksChanged then pcall(skin.OnLooksChanged, UpdateEUIAccent) end
end
local function TrackTheme(object, role)
if not object then return end
local roles = themeObjects[object] or {}
roles[role] = true
themeObjects[object] = roles
end
local function SetTealTexture(texture)
TrackTheme(texture, "tealTexture")
texture:SetColorTexture(unpack(C.teal))
end
local function Backdrop(frame, color, border)
local actualColor, actualBorder = color or C.card, border or C.border
if actualColor == C.accent then TrackTheme(frame, "background") end
if actualColor == C.teal then TrackTheme(frame, "tealBackground") end
if actualBorder == C.accent then TrackTheme(frame, "accentBorder") end
if actualBorder == C.teal then TrackTheme(frame, "tealBorder") end
if actualBorder == C.border then TrackTheme(frame, "border") end
frame:SetBackdrop({ bgFile = "Interface\\Buttons\\WHITE8X8", edgeFile = "Interface\\Buttons\\WHITE8X8", edgeSize = 1 })
frame:SetBackdropColor(unpack(actualColor))
frame:SetBackdropBorderColor(unpack(actualBorder))
end
-- BindCards-style scrollbars: a quiet inset rail with a slim, draggable
-- teal thumb. The stock template's oversized arrows are hidden, and the
-- replacement lives in the gutter already reserved inside each card so it
-- never paints across the card border.
local function SkinScrollFrame(scroll)
if not scroll or scroll._frameGambitScrollBar then return end
local stock = scroll.ScrollBar or scroll.scrollBar
if not stock and scroll.GetName and scroll:GetName() then
stock = _G[scroll:GetName() .. "ScrollBar"]
end
if stock then
stock:SetAlpha(0)
stock:EnableMouse(false)
stock:Hide()
end
scroll:EnableMouseWheel(true)
if scroll.SetClipsChildren then scroll:SetClipsChildren(true) end
local track = CreateFrame("Button", nil, scroll:GetParent(), "BackdropTemplate")
track:SetPoint("TOPLEFT", scroll, "TOPRIGHT", 4, 0)
track:SetPoint("BOTTOMLEFT", scroll, "BOTTOMRIGHT", 4, 0)
track:SetWidth(8)
track:SetFrameLevel(scroll:GetFrameLevel() + 8)
track:EnableMouse(true)
Backdrop(track, C.panel, C.border)
local rail = track:CreateTexture(nil, "BACKGROUND")
rail:SetTexture("Interface\\Buttons\\WHITE8X8")
rail:SetVertexColor(C.border[1], C.border[2], C.border[3], 0.44)
rail:SetPoint("TOP", 0, -3)
rail:SetPoint("BOTTOM", 0, 3)
rail:SetWidth(2)
local thumb = CreateFrame("Button", nil, track, "BackdropTemplate")
thumb:SetSize(6, 28)
thumb:SetPoint("TOP", track, "TOP", 0, -2)
thumb:SetFrameLevel(track:GetFrameLevel() + 1)
thumb:EnableMouse(true)
thumb:RegisterForDrag("LeftButton")
Backdrop(thumb, { C.teal[1], C.teal[2], C.teal[3], 0.88 }, C.teal)
local dragging, dragStartY, dragStartScroll
local function Range()
return math.max(0, tonumber(scroll:GetVerticalScrollRange()) or 0)
end
local function UpdateThumb()
local maxScroll = Range()
local trackHeight = math.max(1, track:GetHeight() - 4)
if maxScroll <= 0 or trackHeight <= 1 then
track:Hide()
return
end
track:Show()
local visibleHeight = math.max(1, scroll:GetHeight())
local thumbHeight = math.min(trackHeight, math.max(28, trackHeight * visibleHeight / (visibleHeight + maxScroll)))
local travel = math.max(0, trackHeight - thumbHeight)
local ratio = math.max(0, math.min(1, (tonumber(scroll:GetVerticalScroll()) or 0) / maxScroll))
thumb:SetHeight(thumbHeight)
thumb:ClearAllPoints()
thumb:SetPoint("TOP", track, "TOP", 0, -2 - ratio * travel)
end
local function StopDrag()
if not dragging then return end
dragging = false
thumb:SetScript("OnUpdate", nil)
thumb:SetBackdropColor(C.teal[1], C.teal[2], C.teal[3], 0.88)
thumb:SetBackdropBorderColor(unpack(C.teal))
end
local function BeginDrag()
local _, cursorY = GetCursorPosition()
local scale = math.max(0.001, scroll:GetEffectiveScale())
dragging = true
dragStartY = cursorY / scale
dragStartScroll = tonumber(scroll:GetVerticalScroll()) or 0
thumb:SetBackdropColor(unpack(C.teal))
thumb:SetBackdropBorderColor(unpack(C.teal))
thumb:SetScript("OnUpdate", function()
if not IsMouseButtonDown("LeftButton") then StopDrag(); return end
local _, currentY = GetCursorPosition()
local travel = math.max(1, track:GetHeight() - 4 - thumb:GetHeight())
local delta = dragStartY - currentY / math.max(0.001, scroll:GetEffectiveScale())
scroll:SetVerticalScroll(math.max(0, math.min(Range(), dragStartScroll + delta / travel * Range())))
UpdateThumb()
end)
end
thumb:SetScript("OnEnter", function(self)
if not dragging then
self:SetBackdropColor(C.teal[1], C.teal[2], C.teal[3], 0.88)
self:SetBackdropBorderColor(unpack(C.teal))
end
end)
thumb:SetScript("OnLeave", function(self)
if not dragging then
self:SetBackdropColor(C.teal[1], C.teal[2], C.teal[3], 0.88)
self:SetBackdropBorderColor(unpack(C.teal))
end
end)
thumb:SetScript("OnDragStart", BeginDrag)
thumb:SetScript("OnDragStop", StopDrag)
thumb:SetScript("OnMouseDown", function(_, button) if button == "LeftButton" then BeginDrag() end end)
thumb:SetScript("OnMouseUp", StopDrag)
track:SetScript("OnMouseDown", function(_, button)
if button ~= "LeftButton" then return end
local _, cursorY = GetCursorPosition()
local scale = math.max(0.001, track:GetEffectiveScale())
local offset = (track:GetTop() or 0) - cursorY / scale - thumb:GetHeight() * 0.5
local travel = math.max(1, track:GetHeight() - 4 - thumb:GetHeight())
scroll:SetVerticalScroll(math.max(0, math.min(Range(), offset / travel * Range())))
UpdateThumb()
BeginDrag()
end)
track:SetScript("OnMouseUp", StopDrag)
scroll:SetScript("OnMouseWheel", function(self, delta)
local nextScroll = (tonumber(self:GetVerticalScroll()) or 0) - delta * 50
self:SetVerticalScroll(math.max(0, math.min(Range(), nextScroll)))
UpdateThumb()
end)
scroll:HookScript("OnVerticalScroll", UpdateThumb)
scroll:HookScript("OnScrollRangeChanged", UpdateThumb)
scroll:HookScript("OnSizeChanged", UpdateThumb)
scroll:HookScript("OnShow", function() C_Timer.After(0, UpdateThumb) end)
scroll._frameGambitScrollBar = track
scroll._frameGambitUpdateScrollBar = UpdateThumb
C_Timer.After(0, UpdateThumb)
end
local function Text(parent, template, value, color)
local label = parent:CreateFontString(nil, "ARTWORK", template or "GameFontHighlightSmall")
label:SetText(value or "")
local actualColor = color or C.muted
if actualColor == C.accent then TrackTheme(label, "text") end
if actualColor == C.teal then TrackTheme(label, "tealText") end
label:SetTextColor(unpack(actualColor))
ApplyEUIObject("font", label)
return label
end
local SetTooltip
local REQUIREMENT_BUTTON_SIZE = 22
local REQUIREMENT_BUTTON_GAP = REQUIREMENT_BUTTON_SIZE
local function StyleRequirementButton(button, hovered)
if EUIOwnsVisual(button) then return end
local strength = hovered and 0.24 or 0.15
button:SetBackdropColor(C.accent[1] * strength, C.accent[2] * strength, C.accent[3] * strength, 1)
button:SetBackdropBorderColor(C.accent[1], C.accent[2], C.accent[3], hovered and 1 or 0.72)
end
local function SetRequirementButtonLabel(control, label)
local text = control.GetFontString and control:GetFontString() or control.text
local bareAdd = not label or label == "+"
if not control.addStrokes then
control.addStrokes = {}
for index = 1, 2 do
local stroke = control:CreateTexture(nil, "OVERLAY")
stroke:SetTexture("Interface\\Buttons\\WHITE8X8")
stroke:SetPoint("CENTER")
stroke:SetSize(index == 1 and 12 or 2, index == 1 and 2 or 12)
stroke:SetVertexColor(unpack(C.accent))
TrackTheme(stroke, "accentTexture")
control.addStrokes[index] = stroke
end
control.AddStrokeHorizontal = control.addStrokes[1]
control.AddStrokeVertical = control.addStrokes[2]
control._frameGambitEUIKeepKeys = { "AddStrokeHorizontal", "AddStrokeVertical" }
end
if text then
text:SetText(bareAdd and "" or label)
text:SetShown(not bareAdd)
end
for _, stroke in ipairs(control.addStrokes) do
stroke:SetAlpha(1)
stroke:SetVertexColor(unpack(C.accent))
stroke:SetShown(bareAdd)
end
end
local function Button(parent, label, width, callback, primary)
local button = CreateFrame("Button", nil, parent, "BackdropTemplate")
button._primary = primary
button:SetSize(width or 92, 24)
Backdrop(button, primary and C.blueSoft or C.raised, C.border)
local text = Text(button, "GameFontNormalSmall", label, C.text)
text:SetPoint("CENTER")
button:SetFontString(text)
ApplyEUIObject("button", button)
button:SetScript("OnEnter", function(self)
if not self._frameGambitEUI then
if self._selected and self._selectedColor then
self:SetBackdropColor(unpack(self._selectedColor))
else
self:SetBackdropColor(unpack(BUTTON_HOVER))
end
self:SetBackdropBorderColor(unpack((self._selected and self._selectedColor) and C.teal or C.blue))
end
if self._tooltipTitle then
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText(self._tooltipTitle, unpack(C.accent))
if self._tooltipBody then GameTooltip:AddLine(self._tooltipBody, C.muted[1], C.muted[2], C.muted[3], true) end
if self._tooltipLines then
for _, line in ipairs(self._tooltipLines) do
GameTooltip:AddLine("- " .. line, C.muted[1], C.muted[2], C.muted[3], true)
end
end
GameTooltip:Show()
end
end)
button:SetScript("OnLeave", function(self)
if not self._frameGambitEUI then
local fill = C.raised
if self._primary then
fill = C.blueSoft
elseif self._selected then
fill = self._selectedColor or C.teal
end
self:SetBackdropColor(unpack(fill))
self:SetBackdropBorderColor(unpack(C.border))
end
if self._tooltipTitle then GameTooltip_Hide() end
end)
button:SetScript("OnClick", callback)
return button
end
-- The compact suite font does not contain reliable arrow glyphs on every
-- Retail client. Every direction uses this one canonical mark; reversing the
-- segment positions is an exact 180-degree rotation with identical thickness.
local TRIANGLE_SEGMENTS = {
{ span = 10, offset = -3 },
{ span = 6, offset = 0 },
{ span = 2, offset = 3 },
}
local function DrawTriangle(control, direction)
if control.GetFontString and control:GetFontString() then control:GetFontString():SetText("") end
if control.text then control.text:SetText("") end
control.arrowLines = control.arrowLines or {}
local horizontal = direction == "left" or direction == "right"
local rotation = (direction == "down" or direction == "left") and -1 or 1
for index, segment in ipairs(TRIANGLE_SEGMENTS) do
local line = control.arrowLines[index]
if not line then
line = control:CreateTexture(nil, "OVERLAY")
control.arrowLines[index] = line
TrackTheme(line, "accentTexture")
end
line:ClearAllPoints()
if horizontal then
line:SetSize(1, segment.span)
line:SetPoint("CENTER", segment.offset * rotation, 0)
else
line:SetSize(segment.span, 1)
line:SetPoint("CENTER", 0, segment.offset * rotation)
end
line:SetColorTexture(unpack(C.accent)); line:Show()
end
end
local function DrawRemoveMark(control)
if control.GetFontString and control:GetFontString() then control:GetFontString():SetText(""); control:GetFontString():Hide() end
if control.text then control.text:SetText(""); control.text:Hide() end
control.removeStrokes = control.removeStrokes or {}
for index, angle in ipairs({ math.pi / 4, -math.pi / 4 }) do
local stroke = control.removeStrokes[index]
if not stroke then
stroke = control:CreateTexture(nil, "OVERLAY")
stroke:SetTexture("Interface\\Buttons\\WHITE8X8")
stroke:SetSize(2, 11); stroke:SetPoint("CENTER"); stroke:SetRotation(angle)
control.removeStrokes[index] = stroke
end
stroke:SetVertexColor(unpack(REMOVE_RED)); stroke:Show()
end
end
local function DrawInspectorIcon(parent, kind)
local icon = CreateFrame("Frame", nil, parent)
icon:SetSize(42, 42); icon:EnableMouse(false)
local index = ({ transition = 0, eye = 1, group = 2, link = 3, visibility = 4 })[kind] or 0
local texture = icon:CreateTexture(nil, "OVERLAY")
texture:SetAllPoints(); texture:SetTexture("Interface\\AddOns\\FrameGambit\\Assets\\InspectorIcons")
texture:SetTexCoord(index / 5, (index + 1) / 5, 0, 1)
return icon
end
local function InspectorSwitch(parent, enabled)
local toggle = CreateFrame("Frame", nil, parent, "BackdropTemplate")
toggle:SetSize(42, 20); Backdrop(toggle, enabled and { 0.03, 0.18, 0.17, 1 } or C.cardAlt, enabled and C.teal or C.border)
toggle.thumb = toggle:CreateTexture(nil, "OVERLAY"); toggle.thumb:SetSize(14, 14); toggle.thumb:SetColorTexture(unpack(enabled and C.teal or C.muted))
toggle.thumb:SetPoint(enabled and "RIGHT" or "LEFT", enabled and -3 or 3, 0)
return toggle
end
local function InspectorActionCard(parent, anchor, iconKind, title, enabled, callback)
local card = Button(parent, "", 206, callback)
card:SetHeight(70); card:GetFontString():Hide(); card:SetPoint("TOPLEFT", anchor, "BOTTOMLEFT", 0, -7)
card.icon = DrawInspectorIcon(card, iconKind); card.icon:SetSize(34, 34); card.icon:SetPoint("LEFT", 8, 0)
card.title = Text(card, "GameFontNormal", title, C.accent)
card.title:SetPoint("TOPLEFT", 52, -12); card.title:SetPoint("RIGHT", -24, 0)
card.title:SetJustifyH("LEFT"); card.title:SetWordWrap(false)
card.state = Text(card, "GameFontHighlightSmall", enabled and "On" or "Off", enabled and C.teal or C.muted)
card.state:SetPoint("TOPLEFT", 52, -39); card.state:SetWidth(20); card.state:SetJustifyH("LEFT")
card.switch = InspectorSwitch(card, enabled); card.switch:SetPoint("LEFT", 78, -12)
card.arrow = CreateFrame("Frame", nil, card); card.arrow:SetSize(12, 12); card.arrow:SetPoint("RIGHT", -10, 0); DrawTriangle(card.arrow, "right")
return card
end
-- The first configurable-card Boolean. Keep the interaction explicit rather
-- than making players infer a value from a cycling button: the current answer
-- is filled, the other answer remains visible, and later picker cards can use
-- this exact Yes/No segment without inventing another toggle treatment.
local function BooleanChoice(parent)
local choice = CreateFrame("Frame", nil, parent)
choice:SetSize(70, 22)
choice.yes = Button(choice, "Yes", 34, function()
if choice._onChange then choice._onChange(true) end
end)
choice.yes:SetPoint("LEFT")
choice.no = Button(choice, "No", 34, function()
if choice._onChange then choice._onChange(false) end
end)
choice.no:SetPoint("RIGHT")
function choice:SetValue(value)
self.value = value == true
for selected, button in pairs({ [self.value] = self.yes, [not self.value] = self.no }) do
button._selected, button._selectedColor = selected, C.teal
SetFallbackBackdrop(button, selected and C.teal or C.cardAlt)
button:GetFontString():SetTextColor(unpack(SelectedButtonText(button, selected, C.muted, C.muted)))
end
end
function choice:SetCallback(callback) self._onChange = callback end
return choice
end
local function CloseButton(parent, callback)
local button = CreateFrame("Button", nil, parent, "BackdropTemplate")
button:SetSize(26, 26)
-- Match Resonance: the close control is a raised corner element, not part
-- of the panel border. The extra level keeps thick Cinematic borders and
-- nested header cards from painting over it.
button:SetFrameLevel(parent:GetFrameLevel() + 20)
Backdrop(button, C.cardAlt, C.border)
local strokes = {}
for index, angle in ipairs({ math.pi / 4, -math.pi / 4 }) do
local stroke = button:CreateTexture(nil, "ARTWORK")
stroke:SetTexture("Interface\\Buttons\\WHITE8X8")
stroke:SetSize(2, 13)
stroke:SetPoint("CENTER")
stroke:SetRotation(angle)
stroke:SetVertexColor(unpack(C.text))
strokes[index] = stroke
end
local function Tint(color)
for _, stroke in ipairs(strokes) do stroke:SetVertexColor(unpack(color)) end
end
button:SetScript("OnEnter", function(self)
if not self._frameGambitEUI then
self:SetBackdropColor(C.teal[1] * 0.17, C.teal[2] * 0.20, C.teal[3] * 0.20, 1)
self:SetBackdropBorderColor(unpack(C.teal))
Tint(C.teal)
end
end)
button:SetScript("OnLeave", function(self)
if not self._frameGambitEUI then
self:SetBackdropColor(unpack(C.cardAlt))
self:SetBackdropBorderColor(unpack(C.border))
Tint(C.text)
end
end)
button:SetScript("OnClick", callback or function() parent:Hide() end)
SetTooltip(button, "Close", "Close this window.")
ApplyEUIObject("close", button)
return button
end
function ns:IsCinematicEditorTheme()
local panel = self.Options
return panel and self:IsCinematicActive() or false
end
function ns:ApplyEditorTheme(force)
local cinematic = force
if cinematic == nil then cinematic = self:IsCinematicEditorTheme() end
-- Cinematic replaces the character-class accent throughout the editor so
-- the profile cannot be mistaken for a normal profile at a glance.
for index = 1, 4 do
C.accent[index], C.blue[index], C.border[index], C.teal[index] =
BASE_ACCENT[index], BASE_BLUE[index], BASE_BORDER[index], BASE_TEAL[index]
if cinematic then
C.accent[index], C.blue[index], C.teal[index] =
CINEMATIC_ACCENT[index], CINEMATIC_ACCENT[index], CINEMATIC_ACCENT[index]
end
end
for object, roles in pairs(themeObjects) do
if roles.text and object.SetTextColor then pcall(object.SetTextColor, object, unpack(C.accent)) end
if roles.tealText and object.SetTextColor then pcall(object.SetTextColor, object, unpack(C.teal)) end
if not EUIOwnsVisual(object) and roles.background and object.SetBackdropColor then pcall(object.SetBackdropColor, object, unpack(C.accent)) end
if not EUIOwnsVisual(object) and roles.tealBackground and object.SetBackdropColor then pcall(object.SetBackdropColor, object, unpack(C.teal)) end
if not EUIOwnsVisual(object) and roles.accentBorder and object.SetBackdropBorderColor then pcall(object.SetBackdropBorderColor, object, unpack(C.accent)) end
if not EUIOwnsVisual(object) and roles.tealBorder and object.SetBackdropBorderColor then pcall(object.SetBackdropBorderColor, object, unpack(C.teal)) end
if roles.accentTexture and object.SetColorTexture then pcall(object.SetColorTexture, object, unpack(C.accent)) end
if roles.tealTexture and object.SetColorTexture then pcall(object.SetColorTexture, object, unpack(C.teal)) end
if not EUIOwnsVisual(object) and roles.border and object.SetBackdropBorderColor then pcall(object.SetBackdropBorderColor, object, unpack(C.border)) end
if not EUIOwnsVisual(object) and roles.requirementButton then StyleRequirementButton(object, false) end
end
local panel = self.Options
if panel then
-- The outer boundary is the persistent Cinematic editing cue. Give it
-- enough weight to read at a glance without recoloring every control.
if euiSkin then
-- The EUI shell owns both the backdrop texture and its atlas
-- border. Replacing its Backdrop descriptor here would erase the
-- modern_blizz/AdventureMap treatment on every refresh.
ClearShellBackdrop(panel)
else
panel:SetBackdrop({
bgFile = "Interface\\Buttons\\WHITE8X8",
edgeFile = "Interface\\Buttons\\WHITE8X8",
edgeSize = cinematic and 4 or 1,
})
panel:SetBackdropColor(unpack(C.window))
panel:SetBackdropBorderColor(unpack(cinematic and CINEMATIC_BORDER or BASE_BORDER))
end
end
if panel and panel.header and not EUIOwnsVisual(panel.header) then
panel.header:SetBackdropColor(unpack(NORMAL_HEADER))
end
if panel and panel.cinematic then
-- Off-state: this is a normal editor action with an amber name, not a
-- second amber panel. Active-state: it becomes the clear Cinematic
-- editing identity marker while the scene controls live below.
panel.cinematic._selected = cinematic
panel.cinematic._selectedColor = cinematic and CINEMATIC_BUTTON or nil
SetFallbackBackdrop(panel.cinematic, cinematic and CINEMATIC_BUTTON or C.cardAlt,
cinematic and CINEMATIC_ACCENT or C.border)
panel.cinematic:GetFontString():SetText(cinematic and "Exit Cinematic" or "Edit Cinematic")
panel.cinematic:GetFontString():SetTextColor(unpack(CINEMATIC_ACCENT))
end
if panel and panel.subtitle then
panel.subtitle:SetText(cinematic and "Editing the Cinematic profile. Changes apply live." or "Choose a frame and set when it should appear.")
panel.subtitle:SetTextColor(unpack(cinematic and CINEMATIC_ACCENT or C.muted))
end
end
local NORMAL_LIVE_STATE_FILL = { 0.05, 0.18, 0.17, 1 }
local function LiveStateFill()
return ns:IsCinematicEditorTheme() and CINEMATIC_BUTTON or NORMAL_LIVE_STATE_FILL
end
local function LocalActiveReactionIndex(state)
if not state or not state.reaction or state.inheritedFrom or not state.index or state.index < 1 then return nil end
return state.index
end
local function SetReactionRowLiveState(row, isActive, isEnabled)
row:SetAlpha(isEnabled and 1 or 0.42)
row.handle.label:SetTextColor(unpack(isActive and C.teal or C.muted))
row:SetBackdropColor(unpack(isActive and LiveStateFill() or C.cardAlt))
-- Every configured, enabled Gambit reads as an active card in the same
-- way a BindCards card does. The currently matching row still receives its
-- stronger live fill; disabled rows alone recede to the neutral border.
row:SetBackdropBorderColor(unpack(isEnabled and C.accent or C.border))
row.label:SetTextColor(unpack(isActive and C.teal or C.accent))
end
local function ClearChildren(frame)
if not frame._rows then return end
for _, child in ipairs(frame._rows) do child:Hide() end
wipe(frame._rows)
end
local function Percent(value)
return ("%d%%"):format(math.floor((value or 0) * 100 + 0.5))
end
local function Seconds(value)
value = math.floor((tonumber(value) or 0) * 100 + 0.5) / 100
if value % 1 == 0 then return string.format("%ds", value) end
if (value * 10) % 1 == 0 then return string.format("%.1fs", value) end
return string.format("%.2fs", value)
end
local function ShortText(value, limit)
value = tostring(value or "")
if #value <= limit then return value end
return value:sub(1, math.max(1, limit - 3)) .. "..."
end
local function NormalizedDuration(value)
value = math.max(0.5, math.min(30, tonumber(value) or 3))
return math.floor(value * 4 + 0.5) / 4
end
-- Reaction rows are edited frequently. Keep a small reusable set rather
-- than creating a new frame tree every time a value is nudged or reordered.
local function NewReactionRow(parent)
local row = CreateFrame("Frame", nil, parent, "BackdropTemplate")
row:SetSize(10, 39); Backdrop(row, C.cardAlt)
row.handle = CreateFrame("Button", nil, row)
row.handle:SetSize(24, 39); row.handle:SetPoint("LEFT", 0, 0); row.handle:RegisterForDrag("LeftButton")
row.handle.label = Text(row.handle, "GameFontNormal", "::", C.muted); row.handle.label:SetPoint("CENTER")
row.handle:SetScript("OnDragStart", function(self)
if self._targetID and self._reaction and self._row then ns:StartReactionDrag(self._targetID, self._reaction, self._row) end
end)
row.handle:SetScript("OnDragStop", function() ns:FinishReactionDrag() end)
row.handle:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText("Reorder reaction", unpack(C.accent))
GameTooltip:AddLine("Drag to change priority. The first matching reaction wins.", C.muted[1], C.muted[2], C.muted[3], true)
GameTooltip:Show()
end)
row.handle:SetScript("OnLeave", GameTooltip_Hide)
row.label = Text(row, "GameFontHighlight", "", C.accent); row.label:SetPoint("LEFT", 65, 0)
row.formPicker = Button(row, "", 132, nil); row.formPicker:SetPoint("LEFT", 65, 0); row.formPicker:Hide()
row.formExpected = BooleanChoice(row); row.formExpected:SetPoint("LEFT", row.formPicker, "RIGHT", 5, 0); row.formExpected:Hide()
SetTooltip(row.formPicker, "Form", "Choose which form this reaction checks. Unavailable forms stay saved but are skipped.")
SetTooltip(row.formExpected.yes, "Form is active", "This row matches while the chosen form is active.")
SetTooltip(row.formExpected.no, "Form is inactive", "This row matches while the chosen form is available but inactive.")
row.opacity = Button(row, "", 54, nil)
row.opacity:RegisterForClicks("LeftButtonUp", "RightButtonUp"); row.opacity:SetPoint("RIGHT", -87, 0)
SetTooltip(row.opacity, "Opacity", "Choose a preset or drag for a precise value.")
row.requirements = Button(row, "+", REQUIREMENT_BUTTON_SIZE, nil)
row.requirements:SetPoint("RIGHT", row.opacity, "LEFT", -REQUIREMENT_BUTTON_GAP, 0)
TrackTheme(row.requirements, "requirementButton")
StyleRequirementButton(row.requirements)
row.requirements:HookScript("OnEnter", function(self) StyleRequirementButton(self, true) end)
row.requirements:HookScript("OnLeave", function(self) StyleRequirementButton(self, false) end)
SetRequirementButtonLabel(row.requirements, "+")
SetTooltip(row.requirements, "Requirements", "Add conditions that must all be true.")
-- Enable/disable is a row-level control, so it lives beside the drag
-- handle rather than among the condition's value controls.
row.enabled = Button(row, "On", 30, nil); row.enabled:SetPoint("LEFT", row.handle, "RIGHT", 5, 0)
SetTooltip(row.enabled, "Reaction enabled", "Turn this reaction off without deleting it.")
row.duration = Button(row, "", 40, nil); row.duration:SetPoint("RIGHT", row.requirements, "LEFT", -5); row.duration:Hide()
SetTooltip(row.duration, "Reaction duration", "Choose how long this event reaction stays active.")
row.up = Button(row, "", 22, nil); row.up:SetPoint("RIGHT", -60, 0); DrawTriangle(row.up, "up")
row.down = Button(row, "", 22, nil); row.down:SetPoint("RIGHT", -34, 0); DrawTriangle(row.down, "down")
row.remove = Button(row, "x", 22, nil); row.remove:SetPoint("RIGHT", -8, 0)
DrawRemoveMark(row.remove); SetFallbackBackdrop(row.remove, nil, REMOVE_RED)
return row
end
SetTooltip = function(frame, title, body)
frame._tooltipTitle, frame._tooltipBody = title, body
end
local function ConditionLabel(condition)
return (ns.CONDITION_INFO[condition] and ns.CONDITION_INFO[condition].label) or condition
end
local function ReactionLabel(reaction)
if reaction and reaction.condition == "form" then
local option = ns.FORM_BY_ID and ns.FORM_BY_ID[reaction.formKey]
return "Form: " .. (option and option.label or "Choose a form")
end
if reaction and reaction.condition == "spec" then
local option = ns.SPEC_BY_ID and ns.SPEC_BY_ID[reaction.specID]
return "Spec: " .. (option and option.label or "Choose a spec")
end
return ConditionLabel(reaction and reaction.condition or "")
end
local function RequirementIndex(reaction, condition)
for index, existing in ipairs(reaction.requirements or {}) do
if existing == condition then return index end
end
end
function ns:CreateOptions()
if self.Options then return end
local panel = CreateFrame("Frame", "FrameGambitOptions", UIParent, "BackdropTemplate")
-- The editor is deliberately spacious: choosing a target, ordering its
-- rules, and defining its relationships are three different jobs.
panel:SetSize(math.min(1180, UIParent:GetWidth() - 40), math.min(680, UIParent:GetHeight() - 40))
panel:SetPoint("CENTER")
panel:SetFrameStrata("FULLSCREEN_DIALOG")
panel:SetFrameLevel(500)
panel:SetToplevel(true)
panel:SetMovable(true)
panel:SetResizable(true)
panel:SetClampedToScreen(true)
panel:EnableMouse(true)
if panel.SetResizeBounds then panel:SetResizeBounds(math.min(900, UIParent:GetWidth() - 20), math.min(560, UIParent:GetHeight() - 20), UIParent:GetWidth() - 20, UIParent:GetHeight() - 20) end
Backdrop(panel, C.window, C.border)
ApplyEUIObject("shell", panel, { bottomBar = 24 })
panel:Hide()
self.Options = panel
-- Keep the frame being edited visible in context without changing its
-- alpha, mouse handling, or ownership. FULLSCREEN stays below this
-- FULLSCREEN_DIALOG options panel, so the marker never paints over the UI.
local selectionOutline = CreateFrame("Frame", "FrameGambitSelectionOutline", UIParent, "BackdropTemplate")
selectionOutline:SetFrameStrata("FULLSCREEN"); selectionOutline:SetFrameLevel(850)
selectionOutline:EnableMouse(false); selectionOutline:Hide()
Backdrop(selectionOutline, { 0, 0, 0, 0 }, C.teal)
selectionOutline.elapsed = 0
selectionOutline._ticker = function(self, elapsed)
self.elapsed = self.elapsed + elapsed
if self.elapsed >= 0.10 then self.elapsed = 0; ns:RefreshSelectionOutline() end
end
self.SelectionOutline = selectionOutline
panel.selectionOutlineEnabled = true
local peekBar = CreateFrame("Button", "FrameGambitPeekBar", UIParent, "BackdropTemplate")
peekBar:SetSize(360, 38); peekBar:SetPoint("TOP", UIParent, "TOP", 0, -22)
peekBar:SetFrameStrata("FULLSCREEN_DIALOG"); peekBar:SetFrameLevel(520)
peekBar:EnableMouse(true); peekBar:RegisterForClicks("LeftButtonUp"); peekBar:Hide()
Backdrop(peekBar, C.panel, C.teal)
ApplyEUIObject("panel", peekBar)
peekBar.label = Text(peekBar, "GameFontHighlightSmall", "", C.teal)
peekBar.label:SetPoint("LEFT", 12, 0); peekBar.label:SetPoint("RIGHT", -112, 0)
peekBar.label:SetJustifyH("LEFT"); peekBar.label:SetWordWrap(false)
peekBar.returnText = Text(peekBar, "GameFontNormal", "Return to editor", C.accent)
peekBar.returnText:SetPoint("RIGHT", -12, 0)
peekBar:SetScript("OnEnter", function()
if not EUIOwnsVisual(peekBar) then peekBar:SetBackdropBorderColor(unpack(C.accent)) end
end)
peekBar:SetScript("OnLeave", function()
if not EUIOwnsVisual(peekBar) then peekBar:SetBackdropBorderColor(unpack(C.teal)) end
end)
peekBar:SetScript("OnClick", function() ns:ExitEditorPeek() end)
self.PeekBar = peekBar
local header = CreateFrame("Frame", nil, panel, "BackdropTemplate")
header:SetPoint("TOPLEFT", 12, -12); header:SetPoint("TOPRIGHT", -12, -12); header:SetHeight(74)
Backdrop(header, NORMAL_HEADER, C.accent); panel.header = header
ApplyEUIObject("panel", header)
header:EnableMouse(true); header:RegisterForDrag("LeftButton")
header:SetScript("OnDragStart", function() panel:StartMoving() end)
header:SetScript("OnDragStop", function() panel:StopMovingOrSizing() end)
local icon = header:CreateTexture(nil, "ARTWORK")
icon:SetSize(42, 42); icon:SetPoint("TOPLEFT", 13, -14); icon:SetTexture(self.ICON_TEXTURE)
local title = Text(header, "GameFontNormalLarge", "Frame Gambit", C.accent)
title:SetPoint("TOPLEFT", icon, "TOPRIGHT", 10, -1)
local subtitle = Text(header, "GameFontHighlightSmall", "Choose a frame and set when it should appear.", C.muted)
subtitle:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -4)
panel.subtitle = subtitle
local version = Text(header, "GameFontHighlightSmall", "v" .. self.VERSION .. " | Retail 12.1", C.teal)
version:SetPoint("BOTTOMRIGHT", header, "BOTTOMRIGHT", -10, 9)
panel.version = version
local creator = Text(header, "GameFontHighlightSmall", "by Mimezu", C.muted)
creator:Hide()
local profile = Button(header, "Profile: Default", 150, function()
ns:OpenProfilePicker()
end)
profile:SetPoint("TOPRIGHT", header, "TOPRIGHT", -154, -18); profile:GetFontString():SetText(""); profile:GetFontString():Hide()
profile.arrow = CreateFrame("Frame", nil, profile)
profile.arrow:SetSize(14, 10); profile.arrow:SetPoint("RIGHT", -8, 0); profile.arrow:EnableMouse(false)
DrawTriangle(profile.arrow, "down")
profile.label = Text(profile, "GameFontNormalSmall", "Profile: Default", C.accent)
profile.label:SetPoint("LEFT", 8, 0); profile.label:SetPoint("RIGHT", profile.arrow, "LEFT", -2, 0); profile.label:SetJustifyH("CENTER"); profile.label:SetWordWrap(false)
panel.profile = profile
local cinematic = Button(header, "Edit Cinematic", 144, function()
local ok, reason = ns:ToggleCinematic(true)
if not ok then ns:ShowEditorNotice(reason or "Cinematic Mode could not be toggled.", "amber") end
ns:RenderOptions()
end)
cinematic:SetPoint("TOPRIGHT", header, "TOPRIGHT", -58, -18); panel.cinematic = cinematic
SetTooltip(cinematic, "Edit Cinematic", "Open the separate Cinematic profile. Amber means it is active.")
local peek = Button(header, "Preview", 76, function() ns:EnterEditorPeek() end)
peek:SetPoint("RIGHT", profile, "LEFT", -7, 0)
SetTooltip(peek, "Preview", "Hide the editor except for the frame list. Hover a frame name to move the outline; click to select.")
panel.peek = peek
local helpButton = Button(header, "? Help", 72, function()
if ns.ToggleHelp then ns:ToggleHelp() elseif ns.OpenHelp then ns:OpenHelp() end
end)
helpButton:SetPoint("RIGHT", peek, "LEFT", -7, 0)
SetTooltip(helpButton, "Help & tutorial", "Read the guide or start the tutorial.")
panel.helpButton = helpButton
subtitle:SetPoint("RIGHT", helpButton, "LEFT", -10, 0)
subtitle:SetWordWrap(false)
if subtitle.SetMaxLines then subtitle:SetMaxLines(1) end
local function UpdateHeaderComposition()
-- At the narrow resize breakpoint the descriptive sentence becomes a
-- weak, floating fifth column. The identity and action cluster are
-- clearer without it; the sentence returns automatically when space
-- is available again.
subtitle:SetShown(panel:GetWidth() >= 1080)
end
panel:HookScript("OnSizeChanged", UpdateHeaderComposition)
C_Timer.After(0, UpdateHeaderComposition)
local helpDot = helpButton:CreateTexture(nil, "OVERLAY")
helpDot:SetSize(5, 5); helpDot:SetPoint("TOPRIGHT", -3, -3); SetTealTexture(helpDot); helpDot:Hide()
helpButton.helpDot = helpDot
if self.HasUnreadHelp then helpDot:SetShown(self:HasUnreadHelp()) end
local cinematicControls = CreateFrame("Frame", nil, header, "BackdropTemplate")
-- Two compact rows keep the camera composition readable without turning
-- the editor header into a second settings page.
cinematicControls:SetPoint("BOTTOMLEFT", 8, 8); cinematicControls:SetPoint("BOTTOMRIGHT", -8, 8); cinematicControls:SetHeight(64)
Backdrop(cinematicControls, C.cardAlt, CINEMATIC_BORDER); cinematicControls:Hide(); panel.cinematicControls = cinematicControls
ApplyEUIObject("panel", cinematicControls, { inset = true })
cinematicControls.fovGroup = CreateFrame("Frame", nil, cinematicControls)
cinematicControls.fovGroup:SetPoint("TOPLEFT", 8, -5); cinematicControls.fovGroup:SetPoint("RIGHT", cinematicControls, "CENTER", -6, 0); cinematicControls.fovGroup:SetHeight(24)
cinematicControls.fovLabel = Text(cinematicControls.fovGroup, "GameFontHighlightSmall", "FOV 90°", C.muted)
cinematicControls.fovLabel:SetPoint("LEFT", 0, 0); cinematicControls.fovLabel:SetWidth(68); cinematicControls.fovLabel:SetJustifyH("LEFT"); cinematicControls.fovLabel:SetWordWrap(false)
cinematicControls.fovSlider = CreateFrame("Slider", nil, cinematicControls.fovGroup, "BackdropTemplate")
cinematicControls.fovSlider:SetPoint("LEFT", cinematicControls.fovLabel, "RIGHT", 8, 0); cinematicControls.fovSlider:SetPoint("RIGHT", -2, 0)
cinematicControls.fovSlider:SetHeight(9); cinematicControls.fovSlider:SetOrientation("HORIZONTAL")
cinematicControls.fovSlider:SetMinMaxValues(40, 100); cinematicControls.fovSlider:SetValueStep(1); cinematicControls.fovSlider:SetObeyStepOnDrag(true)
Backdrop(cinematicControls.fovSlider, C.card, C.border)
local fovThumb = cinematicControls.fovSlider:CreateTexture(nil, "OVERLAY")
fovThumb:SetSize(8, 15); fovThumb:SetColorTexture(unpack(CINEMATIC_ACCENT)); cinematicControls.fovSlider:SetThumbTexture(fovThumb)
cinematicControls.fovSlider:SetScript("OnValueChanged", function(_, value)
value = math.floor(value + 0.5)
cinematicControls.fovLabel:SetText("FOV " .. value .. "°")
if not cinematicControls.fovApplying then
local ok, actual = ns:SetCinematicFOV(value)
if ok and actual and actual ~= value then
cinematicControls.fovApplying = true
cinematicControls.fovSlider:SetValue(actual)
cinematicControls.fovApplying = nil
cinematicControls.fovLabel:SetText("FOV " .. actual .. "°")
end
end
end)
SetTooltip(cinematicControls.fovSlider, "Cinematic FOV", "Set the field of view used while Cinematic Mode is active. Your previous FOV returns when it ends.")
cinematicControls.letterboxGroup = CreateFrame("Frame", nil, cinematicControls)
cinematicControls.letterboxGroup:SetPoint("TOPLEFT", cinematicControls, "TOP", 6, -5); cinematicControls.letterboxGroup:SetPoint("TOPRIGHT", -8, -5); cinematicControls.letterboxGroup:SetHeight(24)
cinematicControls.letterboxLabel = Text(cinematicControls.letterboxGroup, "GameFontHighlightSmall", "Bars 4%", C.muted)
cinematicControls.letterboxLabel:SetPoint("LEFT", 0, 0); cinematicControls.letterboxLabel:SetWidth(76)
cinematicControls.letterboxLabel:SetJustifyH("LEFT"); cinematicControls.letterboxLabel:SetWordWrap(false)
cinematicControls.letterboxToggle = Button(cinematicControls.letterboxGroup, "Off", 48, function()
local enabled = ns:GetCinematicLetterboxSettings()
ns:SetCinematicLetterboxEnabled(not enabled)
ns:RenderOptions()
end)
cinematicControls.letterboxToggle:SetPoint("RIGHT", 0, 0)
SetTooltip(cinematicControls.letterboxToggle, "Cinematic black bars", "Add mouse-transparent letterbox bars at the top and bottom of the screen.")
cinematicControls.letterboxSlider = CreateFrame("Slider", nil, cinematicControls.letterboxGroup, "BackdropTemplate")
cinematicControls.letterboxSlider:SetPoint("LEFT", cinematicControls.letterboxLabel, "RIGHT", 8, 0)
cinematicControls.letterboxSlider:SetPoint("RIGHT", cinematicControls.letterboxToggle, "LEFT", -8, 0)
cinematicControls.letterboxSlider:SetHeight(9); cinematicControls.letterboxSlider:SetOrientation("HORIZONTAL")
cinematicControls.letterboxSlider:SetMinMaxValues(0, 0.25); cinematicControls.letterboxSlider:SetValueStep(0.01); cinematicControls.letterboxSlider:SetObeyStepOnDrag(true)
Backdrop(cinematicControls.letterboxSlider, C.card, C.border)
local letterboxThumb = cinematicControls.letterboxSlider:CreateTexture(nil, "OVERLAY")
letterboxThumb:SetSize(8, 15); letterboxThumb:SetColorTexture(unpack(CINEMATIC_ACCENT)); cinematicControls.letterboxSlider:SetThumbTexture(letterboxThumb)
cinematicControls.letterboxSlider:SetScript("OnValueChanged", function(_, value)
value = math.floor(value * 100 + 0.5) / 100
cinematicControls.letterboxLabel:SetText("Bars " .. math.floor(value * 100 + 0.5) .. "%")
if not cinematicControls.letterboxApplying then ns:SetCinematicLetterboxHeight(value) end
end)
cinematicControls.actionsGroup = CreateFrame("Frame", nil, cinematicControls)
cinematicControls.actionsGroup:SetPoint("BOTTOMLEFT", 8, 5); cinematicControls.actionsGroup:SetPoint("BOTTOMRIGHT", -8, 5); cinematicControls.actionsGroup:SetHeight(24)
cinematicControls.cameraDefaultGroup = CreateFrame("Frame", nil, cinematicControls.actionsGroup)
cinematicControls.cameraDefaultGroup:SetPoint("LEFT", 0, 0); cinematicControls.cameraDefaultGroup:SetSize(190, 24)
cinematicControls.cameraDefaultLabel = Text(cinematicControls.cameraDefaultGroup, "GameFontHighlightSmall", "Left on entry", C.muted)
cinematicControls.cameraDefaultLabel:SetPoint("LEFT", 0, 0)
cinematicControls.cameraDefaultToggle = Button(cinematicControls.cameraDefaultGroup, "Off", 58, function()
local _, enabled = ns:GetCinematicCameraSettings()
ns:SetCinematicCameraOffsetDefault(not enabled)
ns:RenderOptions()
end)
cinematicControls.cameraDefaultToggle:SetPoint("RIGHT", 0, 0)
SetTooltip(cinematicControls.cameraDefaultToggle, "Left camera on entry", "Choose whether Cinematic Mode starts with your character composed on the left. The camera shortcut can still change it live.")
cinematicControls.modeShortcutGroup = CreateFrame("Frame", nil, cinematicControls.actionsGroup)
cinematicControls.modeShortcutGroup:SetPoint("LEFT", cinematicControls.cameraDefaultGroup, "RIGHT", 12, 0); cinematicControls.modeShortcutGroup:SetPoint("RIGHT", cinematicControls.actionsGroup, "CENTER", -4, 0); cinematicControls.modeShortcutGroup:SetHeight(24)
cinematicControls.shortcut = Button(cinematicControls.modeShortcutGroup, "Mode: Set", 180, function() ns:OpenCinematicKeyCapture() end)
cinematicControls.shortcut:SetPoint("LEFT", 0, 0); cinematicControls.shortcut:SetPoint("RIGHT", -50, 0)
SetTooltip(cinematicControls.shortcut, "Cinematic shortcut", "Choose a shortcut for toggling Cinematic Mode outside combat.")
cinematicControls.clear = Button(cinematicControls.modeShortcutGroup, "Clear", 43, function()
local ok, reason = ns:SetCinematicBinding(nil)
if not ok then ns:ShowEditorNotice(reason or "Cinematic shortcut could not be cleared.", "amber") end
ns:RenderOptions()
end)
cinematicControls.clear:SetPoint("RIGHT", 0, 0)
cinematicControls.cameraShortcutGroup = CreateFrame("Frame", nil, cinematicControls.actionsGroup)
cinematicControls.cameraShortcutGroup:SetPoint("LEFT", cinematicControls.actionsGroup, "CENTER", 4, 0); cinematicControls.cameraShortcutGroup:SetPoint("RIGHT", 0, 0); cinematicControls.cameraShortcutGroup:SetHeight(24)
cinematicControls.cameraShortcut = Button(cinematicControls.cameraShortcutGroup, "Camera: Set", 180, function() ns:OpenCinematicCameraKeyCapture() end)
cinematicControls.cameraShortcut:SetPoint("LEFT", 0, 0); cinematicControls.cameraShortcut:SetPoint("RIGHT", -50, 0)
SetTooltip(cinematicControls.cameraShortcut, "Camera shortcut", "Choose a separate shortcut for switching between the left camera and centered camera while Cinematic is active.")
cinematicControls.cameraClear = Button(cinematicControls.cameraShortcutGroup, "Clear", 43, function()
local ok, reason = ns:SetCinematicCameraBinding(nil)
if not ok then ns:ShowEditorNotice(reason or "Camera shortcut could not be cleared.", "amber") end
ns:RenderOptions()
end)
cinematicControls.cameraClear:SetPoint("RIGHT", 0, 0)
local close = CloseButton(panel)
close:SetPoint("TOPRIGHT", -4, -4)
local resizer = CreateFrame("Button", nil, panel)
resizer:SetSize(22, 22); resizer:SetPoint("BOTTOMRIGHT", -3, 3)
resizer:SetFrameLevel(panel:GetFrameLevel() + 20)
local resizeTexture = resizer:CreateTexture(nil, "ARTWORK")
resizeTexture:SetAllPoints(); resizeTexture:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
resizer:SetHighlightTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
resizer:SetPushedTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
resizer:SetScript("OnMouseDown", function(_, button) if button == "LeftButton" then panel:StartSizing("BOTTOMRIGHT") end end)
resizer:SetScript("OnMouseUp", function() panel:StopMovingOrSizing() end)
SetTooltip(resizer, "Resize", "Drag to resize the Frame Gambit editor.")
local targets = CreateFrame("Frame", nil, panel, "BackdropTemplate")
targets:SetPoint("TOPLEFT", header, "BOTTOMLEFT", 0, -12); targets:SetPoint("BOTTOMLEFT", panel, "BOTTOMLEFT", 12, 58); targets:SetWidth(230)
Backdrop(targets, C.card)
ApplyEUIObject("panel", targets, { inset = true })
panel.targets = targets; targets._rows = {}
local targetsTitle = Text(targets, "GameFontNormal", "Frames", C.teal); targetsTitle:SetPoint("TOPLEFT", 12, -11)
local add = Button(targets, "Pick on screen", 96, function() ns:StartPicker() end)
add:SetPoint("TOPLEFT", 12, -36)
panel.pickButton = add
local scan = Button(targets, "Discover visible UI", 102, function()
if InCombatLockdown() then
panel.active:SetText("Leave combat to discover frames."); panel.active:SetTextColor(unpack(C.amber))
return
end
local added, firstID = ns:DiscoverVisibleFrameRoots()
if firstID then panel.selected = firstID end
panel.active:SetText(added > 0 and (added .. " frame" .. (added == 1 and " added." or "s added.")) or "All visible frames are already listed.")
panel.active:SetTextColor(unpack(added > 0 and C.teal or C.muted))
ns:RenderOptions()
end)
scan:SetPoint("TOPLEFT", add, "TOPRIGHT", 8, 0)
panel.discoverButton = scan
local filter = CreateFrame("EditBox", nil, targets, "BackdropTemplate")
filter:SetSize(206, 22); filter:SetPoint("TOPLEFT", 12, -66); filter:SetAutoFocus(false); filter:SetFontObject(GameFontHighlightSmall)
filter:SetTextInsets(28, 8, 0, 0); filter:SetTextColor(unpack(C.accent)); TrackTheme(filter, "text"); Backdrop(filter, C.cardAlt, C.border)
ApplyEUIObject("edit", filter)
filter.searchIcon = filter:CreateTexture(nil, "ARTWORK")
filter.searchIcon:SetTexture("Interface\\COMMON\\UI-Searchbox-Icon")
filter.searchIcon:SetSize(14, 14); filter.searchIcon:SetPoint("LEFT", 8, 0); filter.searchIcon:SetVertexColor(unpack(C.muted))
local filterHint = Text(filter, "GameFontHighlightSmall", "Search frames...", C.muted)
filterHint:SetPoint("LEFT", 28, 0); filter.hint = filterHint
filter:SetScript("OnEditFocusGained", function() filterHint:Hide() end)
filter:SetScript("OnEditFocusLost", function() if filter:GetText() == "" then filterHint:Show() end end)
filter:SetScript("OnTextChanged", function(self)
if self:GetText() == "" and not self:HasFocus() then filterHint:Show() else filterHint:Hide() end
panel.targetQuery = self:GetText():lower()
ns:RenderTargetRail()
end)
panel.targetFilter = filter
local targetScroll = CreateFrame("ScrollFrame", nil, targets, "UIPanelScrollFrameTemplate")
targetScroll:SetPoint("TOPLEFT", 8, -97); targetScroll:SetPoint("BOTTOMRIGHT", -26, 8); panel.targetScroll = targetScroll
local targetContent = CreateFrame("Frame", nil, targetScroll)
targetContent:SetSize(1, 1); targetScroll:SetScrollChild(targetContent)
local function FitTargetContent()
-- Cards belong to the viewport, not beneath the separate scrollbar
-- gutter. Keeping the scroll child exactly as wide as the viewport
-- preserves every right-hand card border at every panel/UI scale.
targetContent:SetWidth(math.max(1, targetScroll:GetWidth()))
end
targetScroll:HookScript("OnSizeChanged", FitTargetContent)
C_Timer.After(0, FitTargetContent)
targetScroll:EnableMouseWheel(true)
targetScroll:SetScript("OnMouseWheel", function(self, delta)
self:SetVerticalScroll(math.max(0, math.min(self:GetVerticalScrollRange(), self:GetVerticalScroll() - delta * 45)))
end)
SkinScrollFrame(targetScroll)
targetContent._rows = {}; panel.targetContent = targetContent