-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathutil.lua
More file actions
executable file
·53 lines (47 loc) · 1.66 KB
/
util.lua
File metadata and controls
executable file
·53 lines (47 loc) · 1.66 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
local _, WOWUP = ...
WOWUP.L = LibStub("AceLocale-3.0"):GetLocale("WOWUP")
local L = WOWUP.L
WOWUP_DATA = WOWUP_DATA or {}
-- functions
local function newCheckbox(optionName, label, description, onClick, parent)
local check = CreateFrame("CheckButton", "WowUpAddon" .. optionName, parent, "InterfaceOptionsCheckButtonTemplate")
check:SetScript("OnClick", function(self)
local tick = self:GetChecked()
onClick(self, tick and true or false)
if tick then
PlaySound(856) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
else
PlaySound(857) -- SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF
end
end)
check.label = _G[check:GetName() .. "Text"]
check.label:SetText(label)
check.tooltipText = label
check.tooltipRequirement = description
return check
end
WOWUP.newCheckbox = newCheckbox
local function CreateRGBToHexHeader(r, g, b)
r = r <= 1 and r >= 0 and r or 1
g = g <= 1 and g >= 0 and g or 1
b = b <= 1 and b >= 0 and b or 1
return format("%s%02x%02x%02x%s %s|r", "|cff", r * 255, g * 255, b * 255, WOWUP_DATA and WOWUP_DATA.addonManagerName or "WowUp", L["Notification"])
end
WOWUP.CreateRGBToHexHeader = CreateRGBToHexHeader
local function CreateRGBToHex(r, g, b)
r = r <= 1 and r >= 0 and r or 1
g = g <= 1 and g >= 0 and g or 1
b = b <= 1 and b >= 0 and b or 1
return format("%s%02x%02x%02x", "|cff", r * 255, g * 255, b * 255)
end
WOWUP.CreateRGBToHex = CreateRGBToHex
local function CountTable(T)
local c = 0
if T ~= nil and type(T) == "table" then
for _ in pairs(T) do
c = c + 1
end
end
return c
end
WOWUP.CountTable = CountTable