-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathCore.lua
73 lines (59 loc) · 2.11 KB
/
Core.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
---@class DragonflightUI : AceAddon-3.0, AceConsole-3.0, AceComm-3.0, AceHook-3.0
---@diagnostic disable-next-line: assign-type-mismatch
local DF = LibStub('AceAddon-3.0'):NewAddon('DragonflightUI', 'AceConsole-3.0', 'AceComm-3.0', 'AceHook-3.0',
'AceSerializer-3.0')
local db
DF.InterfaceVersion = select(4, GetBuildInfo())
DF.Cata = (DF.InterfaceVersion >= 40000)
DF.Wrath = (DF.InterfaceVersion >= 30400)
DF.Era = DF.InterfaceVersion <= 20000
DF.EraLater = DF.Era and DF.InterfaceVersion >= 11503
local defaults = {profile = {bestnumber = 42}}
function DF:OnInitialize()
-- Called when the addon is loaded
self.db = LibStub('AceDB-3.0'):New('DragonflightUIDB', defaults, true)
db = self.db.profile
self:SetupOptions()
self:RegisterSlashCommands()
self:InitVersionCheck()
end
function DF:OnEnable()
-- Called when the addon is enabled
-- self:Print('DragonflightUI enabled!')
self:ShowStartMessage()
end
function DF:OnDisable()
-- Called when the addon is disabled
end
local name, realm = UnitName('player')
local showDebug = name == 'Zimtdev'
DF.ShowDebug = showDebug;
function DF:Debug(m, ...)
if showDebug then m:Print(...) end
end
function DF:Dump(value)
if showDebug then DevTools_Dump(value) end
end
function DF:ShowStartMessage()
local version = C_AddOns.GetAddOnMetadata('DragonflightUI', 'Version')
self:Print(version .. " loaded! Type '/dragonflight' or '/df' to open the options menu.")
end
-- BLIZZ:
local function GetClassColor(classFilename)
local classColors = CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS -- change for 'WeWantBlueShamans'
local color = classColors[classFilename];
if color then return color.r, color.g, color.b, color.colorStr; end
return 1, 1, 1, "ffffffff";
end
function DF:GetClassColor(class, alpha)
local r, g, b, hex = GetClassColor(class)
if alpha then
return r, g, b, alpha, hex
else
return r, g, b, 1, hex
end
end
function DF:GetClassColoredText(str, class)
local r, g, b, a, hex = DF:GetClassColor(class)
return "|r|c" .. hex .. str .. "|r"
end