-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUI.lua
More file actions
626 lines (541 loc) · 22 KB
/
Copy pathUI.lua
File metadata and controls
626 lines (541 loc) · 22 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
local _, VoxGM = ...
local UI = VoxGM.UI
local C = nil
---------------------------------------------------------------------
-- Widget Helpers
---------------------------------------------------------------------
function UI:CreateLabel(parent, text, size, anchorPoint, relTo, relPoint, x, y)
local label = parent:CreateFontString(nil, "OVERLAY", "GameFontNormal")
label:SetText(text)
if size then
local fontPath, _, flags = label:GetFont()
if fontPath then label:SetFont(fontPath, size, flags or "") end
end
if anchorPoint then
label:SetPoint(anchorPoint, relTo or parent, relPoint or anchorPoint, x or 0, y or 0)
end
return label
end
function UI:CreateButton(parent, text, width, height, onClick, tooltip)
local btn = CreateFrame("Button", nil, parent, "UIPanelButtonTemplate")
btn:SetSize(width or 100, height or 24)
btn:SetText(text)
if onClick then btn:SetScript("OnClick", onClick) end
if tooltip then
btn:HookScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_TOP")
GameTooltip:SetText(text, 1, 1, 1)
GameTooltip:AddLine(tooltip, 0.7, 0.7, 0.7, true)
GameTooltip:Show()
end)
btn:HookScript("OnLeave", function() GameTooltip:Hide() end)
end
return btn
end
function UI:CreateEditBox(parent, width, height, placeholder)
local box = CreateFrame("EditBox", nil, parent, "InputBoxTemplate")
box:SetSize(width or 120, height or 22)
box:SetAutoFocus(false)
box:SetFontObject(ChatFontNormal)
if placeholder then
box.placeholder = box:CreateFontString(nil, "ARTWORK", "GameFontDisableSmall")
box.placeholder:SetPoint("LEFT", 5, 0)
box.placeholder:SetText(placeholder)
box:SetScript("OnTextChanged", function(self)
if self.placeholder then
self.placeholder:SetShown(self:GetText() == "")
end
end)
box:SetScript("OnEditFocusGained", function(self)
if self.placeholder then self.placeholder:Hide() end
end)
box:SetScript("OnEditFocusLost", function(self)
if self.placeholder and self:GetText() == "" then self.placeholder:Show() end
end)
end
box:SetScript("OnEscapePressed", function(self) self:ClearFocus() end)
box:SetScript("OnEnterPressed", function(self)
self:ClearFocus()
if self.onEnter then self:onEnter() end
end)
return box
end
function UI:CreateSlider(parent, label, min, max, step, default, width)
local container = CreateFrame("Frame", nil, parent)
container:SetSize(width or 200, 40)
local text = container:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
text:SetPoint("TOPLEFT", 0, 0)
text:SetText(label)
local slider = CreateFrame("Slider", nil, container)
slider:SetSize((width or 200) - 50, 16)
slider:SetPoint("TOPLEFT", 0, -16)
slider:SetOrientation("HORIZONTAL")
slider:SetMinMaxValues(min, max)
slider:SetValueStep(step or 1)
slider:SetObeyStepOnDrag(true)
slider:SetValue(default or min)
local bg = slider:CreateTexture(nil, "BACKGROUND")
bg:SetAllPoints()
bg:SetColorTexture(0.15, 0.15, 0.2, 1)
local thumb = slider:CreateTexture(nil, "ARTWORK")
thumb:SetSize(12, 20)
thumb:SetColorTexture(0.6, 0.6, 0.7, 1)
slider:SetThumbTexture(thumb)
local lowText = slider:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
lowText:SetPoint("TOPLEFT", slider, "BOTTOMLEFT", 0, -2)
lowText:SetText(tostring(min))
local highText = slider:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
highText:SetPoint("TOPRIGHT", slider, "BOTTOMRIGHT", 0, -2)
highText:SetText(tostring(max))
local valText = container:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
valText:SetPoint("LEFT", slider, "RIGHT", 8, 0)
valText:SetText(tostring(default or min))
slider:SetScript("OnValueChanged", function(self, value)
value = math.floor(value + 0.5)
valText:SetText(tostring(value))
if container.onValueChanged then container.onValueChanged(value) end
end)
container.slider = slider
container.valText = valText
container.label = text
return container
end
function UI:CreateToggleButton(parent, labelOn, labelOff, width, height, onClick)
local btn = CreateFrame("Button", nil, parent)
btn:SetSize(width or 100, height or 24)
btn.labelOn = labelOn or "ON"
btn.labelOff = labelOff or "OFF"
btn.isOn = false
local bg = btn:CreateTexture(nil, "BACKGROUND")
bg:SetAllPoints()
btn.bg = bg
local inner = btn:CreateTexture(nil, "BORDER")
inner:SetPoint("TOPLEFT", 1, -1)
inner:SetPoint("BOTTOMRIGHT", -1, 1)
inner:SetColorTexture(0, 0, 0, 1)
local text = btn:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
text:SetPoint("CENTER", 0, 0)
btn.text = text
local highlight = btn:CreateTexture(nil, "HIGHLIGHT")
highlight:SetAllPoints()
highlight:SetColorTexture(1, 1, 1, 0.08)
function btn:SetState(on)
self.isOn = on
self.text:SetText(on and self.labelOn or self.labelOff)
if on then
self.bg:SetColorTexture(0.1, 0.5, 0.1, 1)
self.text:SetTextColor(0.3, 1, 0.3)
else
self.bg:SetColorTexture(0.4, 0.08, 0.08, 1)
self.text:SetTextColor(1, 0.5, 0.5)
end
end
btn:SetState(false)
btn:SetScript("OnClick", function(self)
if onClick then onClick(self, not self.isOn) end
end)
return btn
end
function UI:CreateDropdown(parent, label, items, width, onSelect)
local container = CreateFrame("Frame", nil, parent)
container:SetSize(width or 180, 40)
-- Track for cleanup when main frame hides
if not self._dropdowns then self._dropdowns = {} end
table.insert(self._dropdowns, container)
if label then
local text = container:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
text:SetPoint("TOPLEFT", 0, 0)
text:SetText(label)
end
local btn = CreateFrame("Button", nil, container)
btn:SetSize((width or 180), 22)
btn:SetPoint("TOPLEFT", 0, label and -14 or 0)
btn:SetNormalTexture("Interface\\Buttons\\UI-Quickslot-Depress")
btn:GetNormalTexture():SetVertexColor(0.2, 0.2, 0.25)
local selectedText = btn:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
selectedText:SetPoint("LEFT", 8, 0)
selectedText:SetText(items[1] and items[1].label or "Select...")
btn.selectedText = selectedText
local arrow = btn:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
arrow:SetPoint("RIGHT", -6, 0)
arrow:SetText("v")
btn:SetScript("OnClick", function(self)
-- Toggle popup menu
if container.popup and container.popup:IsShown() then
container.popup:Hide()
return
end
if not container.popup then
-- Click-catcher: invisible full-screen frame to dismiss on outside click
local catcher = CreateFrame("Button", nil, UIParent)
catcher:SetAllPoints()
catcher:SetFrameStrata("DIALOG")
catcher:SetFrameLevel(0)
catcher:Hide()
container.catcher = catcher
local popup = CreateFrame("Frame", nil, UIParent, "BackdropTemplate")
popup:SetFrameStrata("DIALOG")
popup:SetFrameLevel(10)
popup:SetBackdrop({
bgFile = "Interface\\Buttons\\WHITE8x8",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
edgeSize = 10,
insets = { left = 2, right = 2, top = 2, bottom = 2 },
})
popup:SetBackdropColor(0.1, 0.1, 0.15, 0.95)
popup:SetBackdropBorderColor(0.4, 0.4, 0.5, 1)
local itemHeight = 20
local maxVisibleItems = 15
local visibleCount = math.min(#items, maxVisibleItems)
local popupHeight = visibleCount * itemHeight + 8
local popupWidth = width or 180
popup:SetSize(popupWidth, popupHeight)
-- Decide direction: if too close to bottom, open upward
popup:SetScript("OnShow", function(pf)
local _, btnBottom = self:GetCenter()
if btnBottom and btnBottom < popupHeight + 40 then
pf:ClearAllPoints()
pf:SetPoint("BOTTOMLEFT", self, "TOPLEFT", 0, 2)
else
pf:ClearAllPoints()
pf:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -2)
end
container.catcher:Show()
end)
popup:SetScript("OnHide", function()
container.catcher:Hide()
end)
catcher:SetScript("OnClick", function()
popup:Hide()
end)
-- If more items than max, add a scrollable area
local host
if #items > maxVisibleItems then
local scroll = CreateFrame("ScrollFrame", nil, popup)
scroll:SetPoint("TOPLEFT", 4, -4)
scroll:SetPoint("BOTTOMRIGHT", -4, 4)
local child = CreateFrame("Frame", nil, scroll)
child:SetSize(popupWidth - 8, #items * itemHeight)
scroll:SetScrollChild(child)
scroll:EnableMouseWheel(true)
scroll:SetScript("OnMouseWheel", function(sf, delta)
local current = sf:GetVerticalScroll()
local maxScroll = (#items * itemHeight) - (visibleCount * itemHeight)
local newScroll = math.max(0, math.min(maxScroll, current - delta * itemHeight * 3))
sf:SetVerticalScroll(newScroll)
end)
host = child
else
host = popup
end
for idx, item in ipairs(items) do
local row = CreateFrame("Button", nil, host)
row:SetSize(popupWidth - (host == popup and 8 or 4), itemHeight)
row:SetPoint("TOPLEFT", host == popup and 4 or 0, -((host == popup and 4 or 0) + (idx - 1) * itemHeight))
local rowText = row:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
rowText:SetPoint("LEFT", 4, 0)
rowText:SetText(item.label)
local rowBg = row:CreateTexture(nil, "BACKGROUND")
rowBg:SetAllPoints()
rowBg:SetColorTexture(0, 0, 0, 0)
row:SetScript("OnEnter", function()
rowBg:SetColorTexture(0.3, 0.3, 0.5, 0.5)
end)
row:SetScript("OnLeave", function()
rowBg:SetColorTexture(0, 0, 0, 0)
end)
row:SetScript("OnClick", function()
selectedText:SetText(item.label)
container.selectedValue = item.value or item.id or item.label
if onSelect then onSelect(container.selectedValue, item) end
popup:Hide()
end)
end
container.popup = popup
end
container.popup:Show()
end)
container.button = btn
container.selectedValue = items[1] and (items[1].value or items[1].id or items[1].label) or nil
return container
end
function UI:CreateSectionHeader(parent, text, y)
local header = parent:CreateFontString(nil, "OVERLAY", "GameFontNormal")
header:SetPoint("TOPLEFT", 10, y or 0)
header:SetTextColor(C.COLOR_GOLD.r, C.COLOR_GOLD.g, C.COLOR_GOLD.b)
header:SetText(text)
return header
end
function UI:ShowConfirm(text, onAccept)
StaticPopupDialogs["VOXGM_CONFIRM"] = {
text = text,
button1 = "Yes",
button2 = "Cancel",
OnAccept = onAccept,
timeout = 0,
whileDead = true,
hideOnEscape = true,
preferredIndex = 3,
}
StaticPopup_Show("VOXGM_CONFIRM")
end
---------------------------------------------------------------------
-- Main Frame
---------------------------------------------------------------------
function UI:Init()
C = VoxGM.C
if self.mainFrame then return end
VoxGM.Events:RegisterDefaultParsers()
local f = CreateFrame("Frame", "VoxGMFrame", UIParent, "BackdropTemplate")
f:SetSize(C.WINDOW_WIDTH, C.WINDOW_HEIGHT)
f:SetFrameStrata("HIGH")
f:SetClampedToScreen(true)
f:SetMovable(true)
f:EnableMouse(true)
f:SetBackdrop({
bgFile = "Interface\\Buttons\\WHITE8x8",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
edgeSize = 14,
insets = { left = 3, right = 3, top = 3, bottom = 3 },
})
f:SetBackdropColor(C.COLOR_BG.r, C.COLOR_BG.g, C.COLOR_BG.b, C.COLOR_BG.a)
f:SetBackdropBorderColor(0.3, 0.3, 0.4, 0.8)
self.mainFrame = f
-- Restore position
local savedX = VoxGM.State:GetUI("x")
local savedY = VoxGM.State:GetUI("y")
if savedX and savedY then
f:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", savedX, savedY)
else
f:SetPoint("CENTER")
end
-- Title bar
local titleBar = CreateFrame("Frame", nil, f)
titleBar:SetHeight(28)
titleBar:SetPoint("TOPLEFT", 4, -4)
titleBar:SetPoint("TOPRIGHT", -4, -4)
titleBar:EnableMouse(true)
titleBar:RegisterForDrag("LeftButton")
titleBar:SetScript("OnDragStart", function() f:StartMoving() end)
titleBar:SetScript("OnDragStop", function()
f:StopMovingOrSizing()
local x, y = f:GetLeft(), f:GetTop()
VoxGM.State:SetUI("x", x)
VoxGM.State:SetUI("y", y)
end)
local title = titleBar:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
title:SetPoint("LEFT", 8, 0)
title:SetText("|cff00ccffVoxGM|r")
local verText = titleBar:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall")
verText:SetPoint("LEFT", title, "RIGHT", 6, -1)
verText:SetText("v" .. VoxGM.version)
-- Close button
local close = CreateFrame("Button", nil, f, "UIPanelCloseButton")
close:SetPoint("TOPRIGHT", -2, -2)
close:SetScript("OnClick", function() UI:Hide() end)
-- Tab strip
self:CreateTabStrip(f)
-- Content host
local content = CreateFrame("Frame", nil, f)
content:SetPoint("TOPLEFT", 6, -(34 + C.TAB_HEIGHT + 4))
content:SetPoint("BOTTOMRIGHT", -6, C.STATUS_HEIGHT + 8)
self.contentHost = content
-- Status bar
local statusBg = CreateFrame("Frame", nil, f, "BackdropTemplate")
statusBg:SetHeight(C.STATUS_HEIGHT)
statusBg:SetPoint("BOTTOMLEFT", 4, 4)
statusBg:SetPoint("BOTTOMRIGHT", -4, 4)
statusBg:SetBackdrop({
bgFile = "Interface\\Buttons\\WHITE8x8",
})
statusBg:SetBackdropColor(0, 0, 0, 0.4)
local statusText = statusBg:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall")
statusText:SetPoint("LEFT", 6, 0)
statusText:SetText("Ready")
f.statusText = statusText
-- Create tab containers
self:CreateTabContainers()
-- Select saved tab
local savedTab = VoxGM.State:GetUI("selectedTab") or "GM"
self:SelectTab(savedTab)
-- Close any open dropdown popups when the main frame hides
f:HookScript("OnHide", function()
if self._dropdowns then
for _, dd in ipairs(self._dropdowns) do
if dd.popup and dd.popup:IsShown() then dd.popup:Hide() end
end
end
end)
f:Hide()
table.insert(UISpecialFrames, "VoxGMFrame")
end
function UI:CreateTabStrip(parent)
self.tabButtons = {}
local tabs = C.TABS
local tabWidth = (C.WINDOW_WIDTH - 12) / #tabs
for i, tabDef in ipairs(tabs) do
local btn = CreateFrame("Button", nil, parent)
btn:SetSize(tabWidth, C.TAB_HEIGHT)
btn:SetPoint("TOPLEFT", 6 + (i - 1) * tabWidth, -32)
local bg = btn:CreateTexture(nil, "BACKGROUND")
bg:SetAllPoints()
bg:SetColorTexture(C.COLOR_TAB_INACTIVE.r, C.COLOR_TAB_INACTIVE.g, C.COLOR_TAB_INACTIVE.b, C.COLOR_TAB_INACTIVE.a)
btn.bg = bg
local text = btn:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
text:SetPoint("CENTER", 0, 0)
text:SetText(tabDef.label)
btn.label = text
btn.tabId = tabDef.id
btn:SetScript("OnClick", function()
UI:SelectTab(tabDef.id)
end)
btn:SetScript("OnEnter", function(self)
if self.tabId ~= UI.activeTabId then
bg:SetColorTexture(0.12, 0.12, 0.18, 1)
end
end)
btn:SetScript("OnLeave", function(self)
if self.tabId ~= UI.activeTabId then
bg:SetColorTexture(C.COLOR_TAB_INACTIVE.r, C.COLOR_TAB_INACTIVE.g, C.COLOR_TAB_INACTIVE.b, C.COLOR_TAB_INACTIVE.a)
end
end)
self.tabButtons[tabDef.id] = btn
end
end
function UI:CreateTabContainers()
self.tabContainers = {}
self.tabScrollFrames = {}
for _, tabDef in ipairs(C.TABS) do
-- ScrollFrame wrapper for each tab
local scroll = CreateFrame("ScrollFrame", nil, self.contentHost)
scroll:SetAllPoints(self.contentHost)
scroll:EnableMouseWheel(true)
-- Scroll indicator (thin bar on right edge)
local indicator = scroll:CreateTexture(nil, "OVERLAY")
indicator:SetWidth(3)
indicator:SetColorTexture(1, 1, 1, 0.2)
indicator:Hide()
scroll._indicator = indicator
scroll:SetScript("OnMouseWheel", function(sf, delta)
local current = sf:GetVerticalScroll()
local child = sf:GetScrollChild()
if not child then return end
local maxScroll = math.max(0, child:GetHeight() - sf:GetHeight())
local step = 30
local newScroll = math.max(0, math.min(maxScroll, current - delta * step))
sf:SetVerticalScroll(newScroll)
-- Update scroll indicator
if maxScroll > 0 and sf._indicator then
local viewH = sf:GetHeight()
local thumbH = math.max(20, viewH * (viewH / child:GetHeight()))
local thumbY = (newScroll / maxScroll) * (viewH - thumbH)
sf._indicator:ClearAllPoints()
sf._indicator:SetPoint("TOPRIGHT", sf, "TOPRIGHT", -1, -thumbY)
sf._indicator:SetHeight(thumbH)
sf._indicator:Show()
elseif sf._indicator then
sf._indicator:Hide()
end
end)
scroll:Hide()
local container = CreateFrame("Frame", nil, scroll)
container:SetWidth(C.WINDOW_WIDTH - 12)
container:SetHeight(1) -- placeholder; measured after tab creates its content
scroll:SetScrollChild(container)
self.tabContainers[tabDef.id] = container
self.tabScrollFrames[tabDef.id] = scroll
-- Initialize tab module if it exists
local tabModule = VoxGM.Tabs[tabDef.id]
if tabModule and tabModule.Create then
tabModule:Create(container)
end
-- Measure actual content height from the lowest child region
self:FitScrollChild(container)
end
end
function UI:FitScrollChild(container)
-- Walk all regions and children, compute bottom edge relative to container top.
-- Handles both direct TOPLEFT offsets and elements anchored to siblings.
local lowest = 0
local function measureBottom(obj)
local numPoints = obj.GetNumPoints and obj:GetNumPoints() or 0
if numPoints == 0 then return end
-- Use GetBottom/GetTop relative to container
local objBottom = obj.GetBottom and obj:GetBottom()
local contTop = container:GetTop()
if objBottom and contTop then
local distance = contTop - objBottom
if distance > lowest then lowest = distance end
end
end
for _, region in pairs({ container:GetRegions() }) do
measureBottom(region)
end
for _, child in pairs({ container:GetChildren() }) do
measureBottom(child)
end
-- Fallback: if frames aren't laid out yet, use offset heuristic
if lowest < 1 then
for _, child in pairs({ container:GetRegions() }) do
local _, _, _, _, offY = child:GetPoint()
if offY then
lowest = math.max(lowest, math.abs(offY) + (child.GetHeight and child:GetHeight() or 0))
end
end
for _, child in pairs({ container:GetChildren() }) do
local _, _, _, _, offY = child:GetPoint()
if offY then
lowest = math.max(lowest, math.abs(offY) + child:GetHeight())
end
end
end
-- Add padding and enforce a minimum so short tabs don't look broken
container:SetHeight(math.max(lowest + 20, 200))
end
function UI:SelectTab(tabId)
self.activeTabId = tabId
VoxGM.State:SetUI("selectedTab", tabId)
-- Close any open dropdown popups on tab switch
if self._dropdowns then
for _, dd in ipairs(self._dropdowns) do
if dd.popup and dd.popup:IsShown() then dd.popup:Hide() end
end
end
for id, scroll in pairs(self.tabScrollFrames or {}) do
scroll:SetShown(id == tabId)
if id == tabId then scroll:SetVerticalScroll(0) end
end
for id, btn in pairs(self.tabButtons or {}) do
if id == tabId then
btn.bg:SetColorTexture(C.COLOR_TAB_ACTIVE.r, C.COLOR_TAB_ACTIVE.g, C.COLOR_TAB_ACTIVE.b, C.COLOR_TAB_ACTIVE.a)
btn.label:SetTextColor(C.COLOR_GOLD.r, C.COLOR_GOLD.g, C.COLOR_GOLD.b)
else
btn.bg:SetColorTexture(C.COLOR_TAB_INACTIVE.r, C.COLOR_TAB_INACTIVE.g, C.COLOR_TAB_INACTIVE.b, C.COLOR_TAB_INACTIVE.a)
btn.label:SetTextColor(1, 1, 1)
end
end
-- Notify tab module
local tabModule = VoxGM.Tabs[tabId]
if tabModule and tabModule.OnShow then
tabModule:OnShow()
end
end
function UI:RefreshActiveTab()
if self.activeTabId then
local tabModule = VoxGM.Tabs[self.activeTabId]
if tabModule and tabModule.OnShow then
tabModule:OnShow()
end
end
end
function UI:Toggle()
if self.mainFrame then
self.mainFrame:SetShown(not self.mainFrame:IsShown())
end
end
function UI:Show()
if self.mainFrame then self.mainFrame:Show() end
end
function UI:Hide()
if self.mainFrame then self.mainFrame:Hide() end
end