-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCore.lua
More file actions
executable file
·78 lines (70 loc) · 2.32 KB
/
Core.lua
File metadata and controls
executable file
·78 lines (70 loc) · 2.32 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
local addonName, addonTable = ...
addonTable.addon = LibStub("AceAddon-3.0"):NewAddon(addonName, "AceConsole-3.0", "AceSerializer-3.0", "AceEvent-3.0")
local addon = addonTable.addon
addon:SetDefaultModuleState(false)
addon:SetDefaultModuleLibraries("AceEvent-3.0")
local ACD = LibStub("AceConfigDialog-3.0")
local AC = LibStub("AceConfig-3.0")
--local L = LibStub("AceLocale-3.0"):GetLocale(addonName)
--local LDBI = LibStub("LibDBIcon-1.0")
function addon:OnInitialize()
--The order is important: UpdateAddonColors needs the db values, CreateAllUnits calls Update on the hbc_unit which expects the colours to be initialised.
self:LoadDataBase()
self:UpdateAddonColors()
self:CreateAllUnits()
--options
local colorsTabOptions = self:GetColorsTabOptions()
AC:RegisterOptionsTable("HealthBarColor_Colors_Tab", colorsTabOptions)
local healthBarsTabOptions = self:GetHealthBarsTabOptions()
AC:RegisterOptionsTable("HealthBarColor_HealthBars_Tab", healthBarsTabOptions)
local modulesTabOptions = self:GetModulesTabOptions()
AC:RegisterOptionsTable("HealthBarColor_Modules_Tab", modulesTabOptions)
local fontsTabOptions = self:GetFontsTabOptions()
AC:RegisterOptionsTable("HealthBarColor_Fonts_Tab", fontsTabOptions)
local profilesTabOptions = self:GetProfilesTabOptions()
AC:RegisterOptionsTable("HealthBarColor_Profiles_Tab", profilesTabOptions)
self:RegisterChatCommand("hbc", "SlashCommand")
end
function addon:SlashCommand()
if InCombatLockdown() then
return
end
local frame = addon:GetOptionsFrame()
if not frame:IsShown() then
frame:Show()
else
frame:Hide()
end
end
function addon:OnEnable()
for name, module in self:IterateModules() do
if self.db.profile[name].enabled then
module:Enable()
end
end
end
function addon:OnDisable()
for name, module in self:IterateModules() do
module:Disable()
end
end
function addon:ReloadConfig()
self:UpdateAddonColors()
self:Disable()
self:Enable()
local hbc_units = self:GetAllUnits()
for _, hbc_unit in pairs(hbc_units) do
hbc_unit:FullUpdate()
end
self:UpdateOptionsFrame()
end
function addon:IsModuleEnabled(name)
return self.db.profile[name].enabled
end
function addon:ReloadModule(name)
self:DisableModule(name)
self:EnableModule(name)
end
function HealthBarColor_OnAddonCompartmentClick()
addon:SlashCommand()
end