-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathutil.lua
More file actions
executable file
·77 lines (70 loc) · 2.4 KB
/
Copy pathutil.lua
File metadata and controls
executable file
·77 lines (70 loc) · 2.4 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
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 DecodeHTMLEntities(str)
if type(str) ~= "string" then return str end
-- named entities
str = str:gsub("&", "&")
str = str:gsub("<", "<")
str = str:gsub(">", ">")
str = str:gsub(""", '"')
str = str:gsub("'", "'")
str = str:gsub("'", "'")
str = str:gsub(" ", " ")
str = str:gsub("–", "–")
str = str:gsub("—", "—")
-- decimal numeric entities {
str = str:gsub("&#(%d+);", function(n)
return string.char(tonumber(n))
end)
-- hex numeric entities 
str = str:gsub("&#x(%x+);", function(h)
return string.char(tonumber(h, 16))
end)
return str
end
WOWUP.DecodeHTMLEntities = DecodeHTMLEntities
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