-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.lua
More file actions
101 lines (84 loc) · 3.58 KB
/
Config.lua
File metadata and controls
101 lines (84 loc) · 3.58 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
local addOnName = ...
BTEConfig = {}
BTEConfigCheckBoxes = {}
BTEConfig.panel = CreateFrame("Frame", "BTEConfigFrame", UIParent)
BTEConfig.panel.name = "Better Twitch Emotes"
BTEConfig.panel:RegisterEvent("ADDON_LOADED")
-- Load table from SavedVariables
BTEConfig.panel:SetScript("OnEvent", function(self, event, arg1)
if event == "ADDON_LOADED" and arg1 == "TwitchEmotes" then
if BTEConfigEmotes == nil then -- set defaults
BTEConfigEmotes = {}
for k,v in pairs(BTEMOTES) do
BTEConfigEmotes[k] = true
end
else
-- set possible new emotes to true
for k,v in pairs(BTEMOTES) do
if BTEConfigEmotes[k] == nil then
BTEConfigEmotes[k] = true
end
end
-- remove emotes that no longer exist
for k,v in pairs(BTEConfigEmotes) do
if BTEMOTES[k] == nil then
BTEConfigEmotes[k] = nil
end
end
end
end
end)
-- Interface Options stuff
BTEConfig.panel:Hide()
BTEConfig.panel:SetScript("OnShow", function(frame)
-- Scroll frame stuff
BTEConfig.panel.ScrollFrame = CreateFrame("ScrollFrame", nil, BTEConfig.panel, "UIPanelScrollFrameTemplate")
BTEConfig.panel.ScrollFrame:SetPoint("TOPLEFT", BTEConfig.panel, "TOPLEFT", 4, -38)
BTEConfig.panel.ScrollFrame:SetPoint("BOTTOMRIGHT", BTEConfig.panel, "BOTTOMRIGHT", -28, 4)
local childFrame = CreateFrame("Frame", nil, BTEConfig.panel.ScrollFrame)
childFrame:SetSize(BTEConfig.panel:GetWidth(), BTEConfig.panel:GetHeight())
BTEConfig.panel.ScrollFrame:SetScrollChild(childFrame)
-- Title label at the top of options panel
local title = frame:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", 16, -16)
title:SetText("Better Twitch Emotes " .. GetAddOnMetadata(addOnName, "Version"))
-- Check box stuff
local function newCheckbox(label, description, image, onClick)
local check = CreateFrame("CheckButton", "BTECheck" .. label, childFrame, "InterfaceOptionsCheckButtonTemplate")
check:SetScript("OnClick", function(self)
local tick = self:GetChecked()
BTEConfigEmotes[label] = tick
end)
check.label = _G[check:GetName() .. "Text"]
check.label:SetText(label .. " " .. image)
check.tooltipText = label
check.tooltipRequirement = description
return check
end
-- Create sorted array of emotes
local emoteArray = {}
for k,v in pairs(BTEMOTES) do table.insert(emoteArray, k) end
table.sort(emoteArray, function(a, b) return a:upper() < b:upper() end)
-- Create checkboxes
for i,e in ipairs(emoteArray) do
if BTEConfigCheckBoxes[e] == nil then -- shitty duplication check
BTEConfigCheckBoxes[e] = newCheckbox(
e,
"Enable/Disable",
BTEMOTES[e],
function(self, value)
BTEConfigEmotes[e] = value
end
)
BTEConfigCheckBoxes[e]:SetChecked(BTEConfigEmotes[e])
BTEConfigCheckBoxes[e]:SetPoint("TOPLEFT", 16, -28 * (i - 1))
end
end
frame:SetScript("OnShow", nil)
end)
BTEConfig.panel.default = function(self)
for k,v in pairs(BTEConfigCheckBoxes) do v:SetChecked(true) end
for k,v in pairs(BTEConfigEmotes) do v = true end
end
local category = Settings.RegisterCanvasLayoutCategory(BTEConfig.panel, BTEConfig.panel.name)
Settings.RegisterAddOnCategory(category)