-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClassResourceBarSwitch.lua
104 lines (83 loc) · 3.07 KB
/
ClassResourceBarSwitch.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
local addOnName = ...
local data = {
{ 2, Enum.PowerType.HolyPower, PaladinPowerBarFrame, ClassNameplateBarPaladinFrame },
{ 4, Enum.PowerType.ComboPoints, RogueComboPointBarFrame, ClassNameplateBarRogueFrame },
{ 6, Enum.PowerType.Runes, RuneFrame, DeathKnightResourceOverlayFrame },
{ 8, Enum.PowerType.ArcaneCharges, MageArcaneChargesFrame, ClassNameplateBarMageFrame },
{ 9, Enum.PowerType.SoulShards, WarlockPowerFrame, ClassNameplateBarWarlockFrame },
{ 10, Enum.PowerType.Chi, MonkHarmonyBarFrame, ClassNameplateBarWindwalkerMonkFrame },
{ 11, Enum.PowerType.ComboPoints, DruidComboPointBarFrame, ClassNameplateBarFeralDruidFrame },
{ 13, Enum.PowerType.Essence, EssencePlayerFrame, ClassNameplateBarDracthyrFrame },
}
local function makeDBKey(d)
local class, powerType = unpack(d)
return class .. "-" .. powerType
end
local showOptions = {
unitFrameBar = 1,
nameplateBar = 2,
both = 3,
none = 4,
}
local db
local function prepare()
for _, f in ipairs { RuneFrame, DeathKnightResourceOverlayFrame } do
f.SetTooltip = ClassPowerBar.SetTooltip
f.tooltip1 = f.tooltipTitle
f.tooltip2 = f.tooltip
end
end
local function setup()
if not db then return end
for _, d in ipairs(data) do
local _, _, unitFrameBar, nameplateBar = unpack(d)
local show = db[makeDBKey(d)].show
if show == showOptions.unitFrameBar or show == showOptions.both then
unitFrameBar.showTooltip = true
unitFrameBar:SetTooltip(unitFrameBar.tooltip1, unitFrameBar.tooltip2)
unitFrameBar:SetAlpha(1)
else
unitFrameBar.showTooltip = false
unitFrameBar:SetTooltip(nil, nil)
unitFrameBar:SetAlpha(0)
end
if show == showOptions.nameplateBar or show == showOptions.both then
nameplateBar:SetAlpha(1)
else
nameplateBar:SetAlpha(0)
end
end
end
local f = CreateFrame("Frame")
f:RegisterEvent("ADDON_LOADED")
f:SetScript("OnEvent", function(_, event, ...)
if event == "ADDON_LOADED" and addOnName == ... then
f:UnregisterEvent("ADDON_LOADED")
ClassResourceBarSwitchDB = ClassResourceBarSwitchDB or {}
db = ClassResourceBarSwitchDB
prepare()
local category = Settings.RegisterVerticalLayoutCategory(addOnName)
for _, d in ipairs(data) do
local k = makeDBKey(d)
db[k] = db[k] or {}
local class, _, unitFrameBar = unpack(d)
local variable = addOnName .. "_" .. k
local setting = Settings.RegisterAddOnSetting(
category, variable, "show", db[k], Settings.VarType.Number,
GetClassInfo(class) .. " - " .. unitFrameBar.tooltip1,
showOptions.both)
setting:SetValueChangedCallback(setup)
local function getOptions()
local options = Settings.CreateControlTextContainer()
options:Add(showOptions.both, STATUS_TEXT_BOTH)
options:Add(showOptions.unitFrameBar, UNITFRAME_LABEL)
options:Add(showOptions.nameplateBar, NAMEPLATES_LABEL)
options:Add(showOptions.none, NONE)
return options:GetData()
end
Settings.CreateDropdown(category, setting, getOptions, unitFrameBar.tooltip2)
end
Settings.RegisterAddOnCategory(category)
setup()
end
end)