-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptions.lua
More file actions
786 lines (722 loc) · 27.2 KB
/
Options.lua
File metadata and controls
786 lines (722 loc) · 27.2 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
local _, GB = ...
local W = GB.W
local PAD = GB.PAD
local HDR_H = GB.HDR_H
local openDropList
local blocker = CreateFrame("Frame", nil, UIParent)
blocker:SetAllPoints(UIParent)
blocker:SetFrameStrata("DIALOG")
blocker:EnableMouse(true)
blocker:Hide()
blocker:SetScript("OnMouseDown", function()
if openDropList then
openDropList:Hide()
end
openDropList = nil
blocker:Hide()
end)
local function CloseDropdown()
if openDropList then
openDropList:Hide()
end
openDropList = nil
blocker:Hide()
end
local function MakeDropList(items, onPick)
local h = 18
local list = CreateFrame("Frame", nil, UIParent, "BackdropTemplate")
list:SetBackdrop({
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tileSize = 8, edgeSize = 8,
insets = { left = 2, right = 2, top = 2, bottom = 2 },
})
list:SetBackdropColor(0.07, 0.07, 0.10, 0.97)
list:SetBackdropBorderColor(0.50, 0.44, 0.18)
list:SetFrameStrata("TOOLTIP")
list:SetWidth(214)
list:SetHeight(#items * h + 6)
for i, item in ipairs(items) do
local btn = CreateFrame("Button", nil, list)
btn:SetPoint("TOPLEFT", 4, -3 - (i - 1) * h)
btn:SetSize(206, h)
local fs = btn:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
fs:SetAllPoints()
fs:SetJustifyH("LEFT")
fs:SetText(item.label)
local function applyNormalColor()
if item.disabled then
fs:SetTextColor(0.45, 0.45, 0.48)
else
fs:SetTextColor(0.88, 0.88, 0.88)
end
end
applyNormalColor()
btn:SetScript("OnEnter", function()
if not item.disabled then
fs:SetTextColor(1, 0.88, 0.2)
end
end)
btn:SetScript("OnLeave", applyNormalColor)
btn:SetScript("OnClick", function()
if item.disabled then
return
end
onPick(item.value, item)
CloseDropdown()
end)
end
list:Hide()
return list
end
local function MakeOptRow(parent, cat, yTop, profID)
local row, db = CreateFrame("Frame", nil, parent), GB.db.categories[cat.id]
row:SetPoint("TOPLEFT", PAD, yTop)
row:SetSize(W + 20, 24)
local cb = CreateFrame("CheckButton", nil, row, "UICheckButtonTemplate")
cb:SetPoint("LEFT", 0, 0)
cb:SetChecked(GB:GetCategoryEnabled(cat.id, profID))
cb:SetScript("OnClick", function(self)
GB:SetCategoryEnabled(cat.id, self:GetChecked(), profID)
GB:Rebuild()
end)
local lbl = row:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
lbl:SetPoint("LEFT", 36, 0)
lbl:SetWidth(72)
lbl:SetJustifyH("LEFT")
lbl:SetText(cat.label .. ":")
local btn = CreateFrame("Button", nil, row, "BackdropTemplate")
btn:SetPoint("LEFT", 114, 0)
btn:SetSize(214, 18)
btn:SetBackdrop({
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tileSize = 8, edgeSize = 6,
insets = { left = 1, right = 1, top = 1, bottom = 1 },
})
btn:SetBackdropColor(0.10, 0.10, 0.14, 0.92)
btn:SetBackdropBorderColor(0.38, 0.38, 0.40)
local txt = btn:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
txt:SetPoint("LEFT", 4, 0)
txt:SetPoint("RIGHT", -12, 0)
txt:SetJustifyH("LEFT")
local arr = btn:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
arr:SetPoint("RIGHT", -3, 0)
arr:SetText("v")
local STAT_FULL = { finesse = "Finesse", perception = "Perception", deftness = "Deftness" }
local function BuffLabel(buff)
if not buff then
return "-"
end
local label = GB.GetBuffDisplayLabel(cat.id, buff, true) or "-"
if buff.stats then
local bestStat, bestVal = nil, 0
for statID, val in pairs(buff.stats) do
if statID ~= "speedPct" and val > bestVal then
bestStat, bestVal = statID, val
end
end
local hint = STAT_FULL[bestStat] or bestStat
if bestStat and not label:lower():find(hint:lower(), 1, true) then
label = label .. " (" .. hint .. ")"
end
end
return label
end
local function refresh()
txt:SetText(GB.Trunc(BuffLabel(GB:GetSelectedBuff(cat.id, profID)), 34))
end
refresh()
local items = {}
local seenKeys = {}
for _, buff in ipairs(cat.buffs) do
if GB.BuffMatchesProfession(buff, profID) then
local buffKey = GB.GetBuffKey(cat.id, buff)
if not seenKeys[buffKey] then
seenKeys[buffKey] = true
table.insert(items, { label = BuffLabel(buff), value = buffKey })
end
end
end
local list = MakeDropList(items, function(value)
GB:SetCategorySelectionKey(cat.id, value, profID)
refresh()
GB:UpdateBars()
end)
btn:SetScript("OnClick", function(self)
if openDropList == list and list:IsShown() then
CloseDropdown()
else
CloseDropdown()
list:ClearAllPoints()
list:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -1)
list:SetFrameLevel(self:GetFrameLevel() + 10)
blocker:SetFrameLevel(self:GetFrameLevel() + 9)
list:Show()
blocker:Show()
openDropList = list
end
end)
end
local function MakeProfOptRow(parent, prof, yTop)
GB.db.modules.professions[prof.id] = GB.db.modules.professions[prof.id] or {}
local db = GB.db.modules.professions[prof.id]
local row = CreateFrame("Frame", nil, parent)
row:SetPoint("TOPLEFT", PAD, yTop)
row:SetSize(W + 20, 24)
local cb = CreateFrame("CheckButton", nil, row, "UICheckButtonTemplate")
cb:SetPoint("LEFT", 0, 0)
cb:SetChecked(db.enabled ~= false)
cb:SetScript("OnClick", function(self)
GB.db.modules.professions[prof.id].enabled = self:GetChecked()
GB:Rebuild()
end)
local lbl = row:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
lbl:SetPoint("LEFT", 36, 0)
lbl:SetWidth(72)
lbl:SetJustifyH("LEFT")
lbl:SetText(prof:GetLabel() .. ":")
if not prof:SupportsDesiredStatSelection() then
return row
end
local btn = CreateFrame("Button", nil, row, "BackdropTemplate")
btn:SetPoint("LEFT", 114, 0)
btn:SetSize(214, 18)
btn:SetBackdrop({
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tileSize = 8, edgeSize = 6,
insets = { left = 1, right = 1, top = 1, bottom = 1 },
})
btn:SetBackdropColor(0.10, 0.10, 0.14, 0.92)
btn:SetBackdropBorderColor(0.38, 0.38, 0.40)
local txt = btn:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
txt:SetPoint("LEFT", 4, 0)
txt:SetPoint("RIGHT", -12, 0)
txt:SetJustifyH("LEFT")
local arr = btn:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
arr:SetPoint("RIGHT", -3, 0)
arr:SetText("v")
local function refresh()
txt:SetText(GB.GetDesiredStatLabel(GB:GetDesiredStat(prof.id)))
end
refresh()
local items = {}
for _, stat in ipairs(GATHERBUFFS_STAT_ORDER) do
if stat.id ~= "speedPct" then
table.insert(items, { label = stat.label, value = stat.id })
end
end
local list = MakeDropList(items, function(value)
GB.db.modules.professions[prof.id].desiredStat = value
refresh()
GB:UpdateBars()
end)
btn:SetScript("OnClick", function(self)
if openDropList == list and list:IsShown() then
CloseDropdown()
else
CloseDropdown()
list:ClearAllPoints()
list:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -1)
list:SetFrameLevel(self:GetFrameLevel() + 10)
blocker:SetFrameLevel(self:GetFrameLevel() + 9)
list:Show()
blocker:Show()
openDropList = list
end
end)
end
local function MakeBoolOptRow(parent, label, yTop, getter, setter)
local row = CreateFrame("Frame", nil, parent)
row:SetPoint("TOPLEFT", PAD, yTop)
row:SetSize(W + 20, 24)
local cb = CreateFrame("CheckButton", nil, row, "UICheckButtonTemplate")
cb:SetPoint("LEFT", 0, 0)
cb:SetChecked(getter())
cb:SetScript("OnClick", function(self) setter(self:GetChecked()) end)
local lbl = row:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
lbl:SetPoint("LEFT", cb, "RIGHT", 8, 0)
lbl:SetJustifyH("LEFT")
lbl:SetText(label)
lbl:SetTextColor(0.65, 0.65, 0.68)
return row
end
local function MakeChoiceOptRow(parent, label, yTop, items, getter, setter, isEnabled)
local row = CreateFrame("Frame", nil, parent)
row:SetPoint("TOPLEFT", PAD, yTop)
row:SetSize(W + 20, 24)
local lbl = row:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
lbl:SetPoint("LEFT", 36, 0)
lbl:SetWidth(98)
lbl:SetJustifyH("LEFT")
lbl:SetText(label .. ":")
lbl:SetTextColor(0.65, 0.65, 0.68)
local btn = CreateFrame("Button", nil, row, "BackdropTemplate")
btn:SetPoint("LEFT", 136, 0)
btn:SetSize(192, 18)
btn:SetBackdrop({
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tileSize = 8, edgeSize = 6,
insets = { left = 1, right = 1, top = 1, bottom = 1 },
})
btn:SetBackdropColor(0.10, 0.10, 0.14, 0.92)
btn:SetBackdropBorderColor(0.38, 0.38, 0.40)
local txt = btn:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
txt:SetPoint("LEFT", 4, 0)
txt:SetPoint("RIGHT", -12, 0)
txt:SetJustifyH("LEFT")
local arr = btn:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
arr:SetPoint("RIGHT", -3, 0)
arr:SetText("v")
local function getLabel(value)
for _, item in ipairs(items) do
if item.value == value then
return item.label
end
end
return "-"
end
local function rowEnabled()
if isEnabled == nil then
return true
end
return isEnabled()
end
local function refresh()
txt:SetText(getLabel(getter()))
if rowEnabled() then
btn:SetBackdropColor(0.10, 0.10, 0.14, 0.92)
btn:SetBackdropBorderColor(0.38, 0.38, 0.40)
txt:SetTextColor(0.88, 0.88, 0.90)
arr:SetTextColor(0.88, 0.88, 0.90)
else
btn:SetBackdropColor(0.08, 0.08, 0.10, 0.70)
btn:SetBackdropBorderColor(0.24, 0.24, 0.26)
txt:SetTextColor(0.56, 0.56, 0.58)
arr:SetTextColor(0.56, 0.56, 0.58)
end
end
local list = MakeDropList(items, function(value)
setter(value)
refresh()
end)
btn:SetScript("OnClick", function(self)
if not rowEnabled() then
return
end
if openDropList == list and list:IsShown() then
CloseDropdown()
else
CloseDropdown()
list:ClearAllPoints()
list:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -1)
list:SetFrameLevel(self:GetFrameLevel() + 10)
blocker:SetFrameLevel(self:GetFrameLevel() + 9)
list:Show()
blocker:Show()
openDropList = list
end
end)
refresh()
return row
end
local sliderCounter = 0
local function MakeSliderOptRow(parent, label, yTop, minValue, maxValue, step, getter, setter)
sliderCounter = sliderCounter + 1
local sliderName = "GBOptionsSlider" .. sliderCounter
local row = CreateFrame("Frame", nil, parent)
row:SetPoint("TOPLEFT", PAD, yTop)
row:SetSize(W + 20, 42)
local lbl = row:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
lbl:SetPoint("TOPLEFT", 0, 0)
lbl:SetText(label)
lbl:SetTextColor(0.65, 0.65, 0.68)
local val = row:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
val:SetPoint("TOPRIGHT", -8, 0)
val:SetJustifyH("RIGHT")
val:SetTextColor(0.88, 0.88, 0.90)
local slider = CreateFrame("Slider", sliderName, row, "OptionsSliderTemplate")
slider:SetPoint("TOPLEFT", 0, -14)
slider:SetWidth(220)
slider:SetMinMaxValues(minValue, maxValue)
slider:SetValueStep(step)
slider:SetObeyStepOnDrag(true)
_G[sliderName .. "Low"]:SetText("")
_G[sliderName .. "High"]:SetText("")
_G[sliderName .. "Text"]:SetText("")
local updating = false
local function refresh()
updating = true
local current = getter()
slider:SetValue(current)
val:SetText(string.format("%.2f", current))
updating = false
end
slider:SetScript("OnValueChanged", function(_, value)
if updating then
return
end
local snapped = math.floor((value / step) + 0.5) * step
snapped = math.max(minValue, math.min(maxValue, snapped))
setter(snapped)
val:SetText(string.format("%.2f", snapped))
end)
refresh()
return row
end
function GB:BuildOptions()
local PANEL_W = W + 34
local TAB_H, TAB_GAP = 22, 4
local hasGatheringProfession = self:IsProfessionAvailable("mining")
or self:IsProfessionAvailable("herbalism")
or self:IsProfessionAvailable("skinning")
or self:IsProfessionAvailable("fishing")
local f = GB.MakePanel(UIParent, "GatherBuffs - Settings")
f:SetFrameStrata("HIGH")
f:SetMovable(true)
f:EnableMouse(true)
f:SetClampedToScreen(true)
local function stopMoving(self)
self:StopMovingOrSizing()
GB.db.optX = self:GetLeft()
GB.db.optY = self:GetTop()
end
f:RegisterForDrag("LeftButton")
f:SetScript("OnDragStart", function(self) self:StartMoving() end)
f:SetScript("OnDragStop", stopMoving)
f.header:EnableMouse(true)
f.header:RegisterForDrag("LeftButton")
f.header:SetScript("OnDragStart", function() f:StartMoving() end)
f.header:SetScript("OnDragStop", function() stopMoving(f) end)
local closeBtn = CreateFrame("Button", nil, f, "UIPanelCloseButton")
closeBtn:SetPoint("TOPRIGHT", 2, 2)
closeBtn:SetScript("OnClick", function() f:Hide(); CloseDropdown() end)
local tabDefs = {
{ id = "global", label = "Global" },
{ id = "consumables", label = "Consum.", visible = hasGatheringProfession },
{ id = "currencies", label = "Currencies" },
{ id = "profit", label = "Profit" },
}
for _, prof in ipairs(GB.GetProfessionDefs()) do
if prof:HasSettingsTab() then
table.insert(tabDefs, { id = "prof_" .. prof.id, label = prof:GetLabel(), prof = prof })
end
end
local visibleTabDefs = {}
for _, td in ipairs(tabDefs) do
local tabVisible = td.visible ~= false
if tabVisible and (not td.prof or self:IsProfessionAvailable(td.prof.id)) then
visibleTabDefs[#visibleTabDefs + 1] = td
end
end
local nTabs = #visibleTabDefs
local TAB_W = math.floor((PANEL_W - PAD * 2 - TAB_GAP * (nTabs - 1)) / nTabs)
local TABS_Y = -(HDR_H + 8)
local CONTENT_Y = TABS_Y - TAB_H - 6
local contentFrames = {}
for _, td in ipairs(visibleTabDefs) do
local cf = CreateFrame("Frame", nil, f)
cf:SetPoint("TOPLEFT", f, "TOPLEFT", 0, CONTENT_Y)
cf:SetSize(PANEL_W, 400)
cf:Hide()
contentFrames[td.id] = cf
end
do
local gc = contentFrames.global
MakeBoolOptRow(gc, "Lock window", 0,
function() return GB.db.locked end,
function(value) GB.db.locked = value end)
MakeBoolOptRow(gc, "Hide in combat", -24,
function() return GB.db.hideInCombat or false end,
function(value)
GB.db.hideInCombat = value
GB:RefreshMainFrameVisibility()
end)
MakeBoolOptRow(gc, "Minimap icon", -48,
function() return GB.db.ui.showMinimapIcon ~= false end,
function(value)
GB.db.ui.showMinimapIcon = value
GB:ApplyUiSettings()
end)
MakeBoolOptRow(gc, "Loot debug (shows unknown items)", -72,
function() return GB.lootDebug or false end,
function(value) GB.lootDebug = value end)
MakeBoolOptRow(gc, "Alert when buff expires", -96,
function() return GB.db.modules.alertOnBuffExpiry == true end,
function(value) GB.db.modules.alertOnBuffExpiry = value and true or false end)
MakeSliderOptRow(gc, "Background Opacity", -130, 0.00, 1.00, 0.01,
function() return GB.db.ui.backgroundOpacity or GB.DEFAULTS.ui.backgroundOpacity end,
function(value)
GB.db.ui.backgroundOpacity = value
GB:ApplyUiSettings()
end)
MakeSliderOptRow(gc, "Bars Opacity", -174, 0.00, 1.00, 0.01,
function() return GB.db.ui.barOpacity or GB.db.ui.rowOpacity or GB.DEFAULTS.ui.barOpacity or GB.DEFAULTS.ui.rowOpacity end,
function(value)
GB.db.ui.barOpacity = value
GB.db.ui.rowOpacity = value
GB:ApplyUiSettings()
GB:UpdateBars()
end)
MakeSliderOptRow(gc, "Text Opacity", -218, 0.00, 1.00, 0.01,
function() return GB.db.ui.textOpacity or GB.DEFAULTS.ui.textOpacity end,
function(value)
GB.db.ui.textOpacity = value
GB:ApplyUiSettings()
GB:UpdateBars()
end)
MakeSliderOptRow(gc, "UI Scale", -262, 0.50, 1.50, 0.05,
function() return GB.db.ui.scale or GB.DEFAULTS.ui.scale end,
function(value)
GB.db.ui.scale = value
GB:ApplyUiSettings()
end)
end
do
local cc = contentFrames.consumables
local globalCatIDs = { "food", "phial", "steamphial", "potion" }
for i, catID in ipairs(globalCatIDs) do
local cat = GB.GetCatDef(catID)
if cat then
MakeOptRow(cc, cat, -(28 * (i - 1)))
end
end
MakeBoolOptRow(cc, "Alert when consumable runs out", -124,
function() return GB.db.modules.alertOnLowStock == true end,
function(value) GB.db.modules.alertOnLowStock = value and true or false end)
end
do
local cc = contentFrames.currencies
MakeBoolOptRow(cc, "Enable Dundun module", 0,
function()
return GB.db.currencies and GB.db.currencies.shard_of_dundun and GB.db.currencies.shard_of_dundun.enabled ~= false
end,
function(value)
GB.db.currencies = GB.db.currencies or {}
GB.db.currencies.shard_of_dundun = GB.db.currencies.shard_of_dundun or {}
GB.db.currencies.shard_of_dundun.enabled = value and true or false
GB:Rebuild()
end)
end
do
local pc = contentFrames.profit
local y = 0
for _, prof in ipairs(GB.GetProfessionDefs()) do
if prof.id ~= "fishing" and not prof:IsProfitOnly() and self:IsProfessionAvailable(prof.id) then
MakeBoolOptRow(pc, "Track " .. prof:GetLabel(), y,
function()
return GB:IsProfitProfessionTracked(prof.id)
end,
function(value)
GB.db.modules.profitTracking[prof.id] = value and true or false
GB:CheckProfession()
GB:MarkProfitUiDirty()
GB:UpdateProfit()
end)
y = y - 24
end
end
for _, prof in ipairs(GB.GetProfessionDefs()) do
if prof:IsProfitOnly() and self:IsProfessionAvailable(prof.id) then
MakeBoolOptRow(pc, prof:GetProfitToggleLabel(), y,
function()
return GB:IsProfitProfessionTracked(prof.id)
end,
function(value)
GB.db.modules.profitTracking[prof.id] = value and true or false
GB:CheckProfession()
GB:MarkProfitUiDirty()
GB:UpdateProfit()
end)
y = y - 24
end
end
MakeBoolOptRow(pc, "Include vendor loot value", y,
function()
return GB.db.modules.profitVendorLoot == true
end,
function(value)
GB.db.modules.profitVendorLoot = value and true or false
GB:MarkProfitUiDirty()
GB:UpdateProfit()
end)
y = y - 24
MakeBoolOptRow(pc, "Auto-start on first loot", y,
function()
return GB.db.modules.profitAutoStartOnLoot == true
end,
function(value)
GB.db.modules.profitAutoStartOnLoot = value and true or false
end)
y = y - 24
MakeBoolOptRow(pc, "Exclude gear from vendor loot", y,
function()
return GB.db.modules.profitVendorLootExcludeGear == true
end,
function(value)
GB.db.modules.profitVendorLootExcludeGear = value and true or false
GB:MarkProfitUiDirty()
GB:UpdateProfit()
end)
y = y - 24
MakeBoolOptRow(pc, "Auto-pause when inactive", y,
function()
return GB.db.modules.profitAutoInactivePause == true
end,
function(value)
GB.db.modules.profitAutoInactivePause = value and true or false
end)
y = y - 24
local inactiveItems = {
{ label = "2 min", value = 2 },
{ label = "5 min", value = 5 },
{ label = "10 min", value = 10 },
{ label = "15 min", value = 15 },
{ label = "30 min", value = 30 },
}
MakeChoiceOptRow(pc, "Inactivity threshold", y, inactiveItems,
function()
return GB.db.modules.profitAutoInactivePauseMinutes or 5
end,
function(value)
GB.db.modules.profitAutoInactivePauseMinutes = value
end)
y = y - 24
local modeItems = {}
for _, entry in ipairs(GB.PROFIT_PRICE_SOURCE_MODES) do
modeItems[#modeItems + 1] = { label = entry.label, value = entry.id }
end
MakeChoiceOptRow(pc, "Price mode", y - 8, modeItems,
function()
return GB.GetProfitPriceSourceMode()
end,
function(value)
GB.db.modules.profitPriceSourceMode = value
GB:MarkProfitUiDirty()
GB:UpdateProfit()
end)
local sourceItems = {}
for _, entry in ipairs(GB.PROFIT_PRICE_SOURCES) do
local available = GB.IsAhSourceAvailable(entry.id)
sourceItems[#sourceItems + 1] = {
label = available and entry.label or (entry.label .. " (unavailable)"),
value = entry.id,
disabled = not available,
}
end
MakeChoiceOptRow(pc, "Manual source", y - 36, sourceItems,
function()
if GB.GetProfitPriceSourceMode() == "auto" then
local current = GB.GetCurrentPriceSource()
return current and current:GetID() or GB.GetProfitPriceSource()
end
return GB.GetProfitPriceSource()
end,
function(value)
GB.db.modules.profitPriceSource = value
GB:MarkProfitUiDirty()
GB:UpdateProfit()
end,
function()
return GB.GetProfitPriceSourceMode() == "manual"
end)
end
for _, td in ipairs(visibleTabDefs) do
if td.prof then
local pc = contentFrames[td.id]
MakeProfOptRow(pc, td.prof, 0)
local y = -28
local catList = td.prof:GetBuffCategoryIDs()
for _, catID in ipairs(catList) do
local cat = GB.GetCatDef(catID)
if cat then
MakeOptRow(pc, cat, y, td.prof.id)
y = y - 28
end
end
if td.prof.id == "enchanting" then
MakeBoolOptRow(pc, "Warn on disenchant without Shattered Essence", y,
function()
return GB.db.modules.enchantingRequireShatteredEssence == true
end,
function(value)
GB.db.modules.enchantingRequireShatteredEssence = value and true or false
if value then
GB:MaybeWarnDisenchant()
end
end)
y = y - 24
end
if y < -260 then
pc:SetHeight(math.abs(y) + 80)
else
pc:SetHeight(400)
end
end
end
local tabBtns = {}
local function SetActiveTab(tabID)
for _, td in ipairs(visibleTabDefs) do
local btn = tabBtns[td.id]
local cf = contentFrames[td.id]
if td.id == tabID then
btn:SetBackdropColor(0.16, 0.18, 0.26, 0.95)
btn:SetBackdropBorderColor(0.50, 0.46, 0.22)
btn.txt:SetTextColor(1, 0.90, 0.50)
cf:Show()
else
btn:SetBackdropColor(0.08, 0.08, 0.12, 0.92)
btn:SetBackdropBorderColor(0.26, 0.26, 0.30)
btn.txt:SetTextColor(0.56, 0.56, 0.60)
cf:Hide()
end
end
end
local tabX = PAD
for _, td in ipairs(visibleTabDefs) do
local btn = CreateFrame("Button", nil, f, "BackdropTemplate")
btn:SetPoint("TOPLEFT", f, "TOPLEFT", tabX, TABS_Y)
btn:SetSize(TAB_W, TAB_H)
btn:SetBackdrop({
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true, tileSize = 8, edgeSize = 6,
insets = { left = 1, right = 1, top = 1, bottom = 1 },
})
local btnTxt = btn:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
btnTxt:SetAllPoints()
btnTxt:SetJustifyH("CENTER")
btnTxt:SetText(td.label)
btn.txt = btnTxt
tabBtns[td.id] = btn
local capturedID = td.id
btn:SetScript("OnClick", function() SetActiveTab(capturedID) end)
tabX = tabX + TAB_W + TAB_GAP
end
SetActiveTab("global")
local contentH = math.max(288, 28) + PAD
f:SetSize(PANEL_W, HDR_H + 8 + TAB_H + 6 + contentH + PAD * 2)
f:ClearAllPoints()
if self.db.optX and self.db.optY then
f:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", self.db.optX, self.db.optY)
else
f:SetPoint("CENTER", UIParent, "CENTER", 220, 0)
end
self.optFrame = f
self:ApplyUiSettings()
f:Hide()
return f
end
function GB:ToggleOptions()
if self.optFrame and self.optFrame:IsShown() then
self.optFrame:Hide()
CloseDropdown()
else
if not self.optFrame then
self.optFrame = self:BuildOptions()
end
self.optFrame:Show()
end
end