027048a - Split config
[wowui.git] / RaidFrameCustomization / Core.lua
1 RaidFrameCustomization = LibStub("AceAddon-3.0"):NewAddon("RaidFrameCustomization");
2
3 RaidFrameCustomization.normalBarColor = CreateColor(0.3, 0.3, 0.3);
4 RaidFrameCustomization.dispelBarColor = CreateColor(1, 0.5, 0);
5 RaidFrameCustomization.normalBackColor = {0.7, 0.7, 0.7};
6 RaidFrameCustomization.dispelBackColor = {0.5, 0.2, 0};
7
8 RaidFrameCustomization.frames = {};
9 RaidFrameCustomization.positions = {
10     "TOPLEFT", "TOPRIGHT", "CENTER", "BOTTOMLEFT", "BOTTOMRIGHT"
11 };
12
13 RaidFrameCustomization.running = false;
14
15 local defaults = {
16     profile = {
17         indicatorFont = "Arial Narrow",
18         showIcons = true,
19         enabled = true,
20         indicators = {
21             ['**'] = {
22                 textSize = 10,
23                 textColor = {1, 1, 1, 1},
24                 mine = false,
25                 stack = true,
26                 showText = true,
27                 showIcon = true,
28                 useDefaultIcon = true,
29                 iconSize = 10,
30                 iconColor = {1, 1, 1, 1},
31             },
32         },
33     }
34 };
35
36 function RaidFrameCustomization:OnInitialize()
37     self.db = LibStub("AceDB-3.0"):New("RaidFrameCustomizationDB", defaults);
38     self.db.RegisterCallback(self, "OnProfileChanged", "RefreshConfig");
39     self.db.RegisterCallback(self, "OnProfileCopied", "RefreshConfig");
40     self.db.RegisterCallback(self, "OnProfileReset", "RefreshConfig");
41     self:SetupOptions();
42 end
43
44 function RaidFrameCustomization:OnEnable()
45     self:RefreshConfig();
46 end
47
48 function RaidFrameCustomization:OnDisable()
49     self.running = false;
50     for _, frame in pairs(self.frames) do
51         for _, ind in pairs(frame) do
52             ind.text:SetText("");
53             ind.icon:SetTexture("");
54         end
55     end
56 end