forked from Slothpala/RaidFrameSettings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Core.lua
executable file
·101 lines (91 loc) · 3.89 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
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
--[[Created by Slothpala]]--
local addonName, addonTable = ...
addonTable.addon = LibStub("AceAddon-3.0"):NewAddon("RaidFrameSettings", "AceConsole-3.0", "AceTimer-3.0", "AceEvent-3.0", "AceBucket-3.0", "AceSerializer-3.0")
local addon = addonTable.addon
addon:SetDefaultModuleLibraries("AceEvent-3.0")
addon:SetDefaultModuleState(false)
local AC = LibStub("AceConfig-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale(addonName)
function addon:OnInitialize()
-- Create/Load the Data Base
self:LoadDataBase()
self:CheckDatabase()
--Slash command
self:RegisterChatCommand(addonName, "SlashCommand")
self:RegisterChatCommand("rfs", "SlashCommand")
end
function addon:OnEnable()
-- Options
-- Leave this in OnEnable to update the UI on profile change.
AC:RegisterOptionsTable("RaidFrameSettings_Module_Selection_Tab", self:GetModuleSelectionOptions())
AC:RegisterOptionsTable("RaidFrameSettings_AddOn_Colors_Tab", self:GetAddOnColorOptions())
AC:RegisterOptionsTable("RaidFrameSettings_General_Options_Tab", self:GetGeneralOptions())
AC:RegisterOptionsTable("RaidFrameSettings_Font_Options_Tab", self:GetFontOptions())
AC:RegisterOptionsTable("RaidFrameSettings_Defensive_Overlay_Options_Tab", self:GetDefensiveOverlayOptions())
AC:RegisterOptionsTable("RaidFrameSettings_Buff_Frame_Options_Tab", self:GetBuffFrameOptions())
AC:RegisterOptionsTable("RaidFrameSettings_Debuff_Frame_Options_Tab", self:GetDebuffFrameOptions())
AC:RegisterOptionsTable("RaidFrameSettings_Profiles_Options_Tab", self:GetProfileTabOptions())
AC:RegisterOptionsTable("RaidFrameSettings_Aura_Group_Options_Tab", self:GetAuraGroupOptions())
AC:RegisterOptionsTable("RaidFrameSettings_Edit_Aura_Group_Options_PopUp", self:GetEditAuraGroupOptions())
AC:RegisterOptionsTable("RaidFrameSettings_Buff_Highlight_Auras_Options_PopUp", self:GetBuffHighlightAuraOptions())
AC:RegisterOptionsTable("RaidFrameSettings_Export_Profile_Options_PopUp", self:GetExportProfileOptions())
AC:RegisterOptionsTable("RaidFrameSettings_Import_Profile_Options_PopUp", self:GetImportProfileOptions())
-- Set the addon colors
self:CreateOrUpdateClassColors()
self:CreateOrUpdatePowerColors()
self:CreateOrUpdateDispelTypeColors()
-- Create or update the frame env
self:CreateOrUpdateFrameEnv()
-- GROUP_ROSTER_UPDATE gets spammed in certain scenarios (large groups with many people joining or leaving).
-- Buffering greatly reduces CPU usage spikes in these scenarios.
self:RegisterBucketEvent("GROUP_ROSTER_UPDATE", 1, "CreateOrUpdateFrameEnv")
for _, module in self:IterateModules() do
if self:IsModuleEnabled(module:GetName()) then
module:Enable()
end
end
end
function addon:OnDisable()
end
function addon:SlashCommand()
local options_frame = addon:GetOptionsFrame()
if InCombatLockdown() then
self:Print(L["option_open_after_combat_msg"])
options_frame:RegisterEvent("PLAYER_REGEN_ENABLED")
return
end
if not options_frame:IsShown() then
options_frame:Show()
else
options_frame:Hide()
end
end
function addon:ReloadConfig()
self:Disable()
self:Enable()
self:OptionsFrame_UpdateTabs()
end
-- To not have a to convoluted Set/Get section.
local module_assoiaton = {
["NameFont"] = "Font",
["StatusFont"] = "Font",
["DefensiveOverlayDurationFont"] = "DefensiveOverlay",
["DefensiveOverlayStackFont"] = "DefensiveOverlay",
["BuffFrameDurationFont"] = "BuffFrame",
["BuffFrameStackFont"] = "BuffFrame",
["DebuffFrameDurationFont"] = "DebuffFrame",
["DebuffFrameStackFont"] = "DebuffFrame",
["AuraGroupsDurationFont"] = "AuraGroups",
["AuraGroupsStackFont"] = "AuraGroups",
}
function addon:ReloadModule(name)
local module_name = module_assoiaton[name] or name
self:DisableModule(module_name)
self:EnableModule(module_name)
end
function addon:IsModuleEnabled(name)
return self.db.profile[name].enabled
end
function RaidFrameSettings_AddOnCompartmentEntry()
addon:SlashCommand()
end