6f9efe3 - Remove font option
[wowui.git] / OmaRF / Core.lua
1 OmaRF = LibStub("AceAddon-3.0"):NewAddon("OmaRF");
2
3 OmaRF.normalBarColor = CreateColor(0.3, 0.3, 0.3);
4 OmaRF.dispelBarColor = CreateColor(1, 0.5, 0);
5 OmaRF.normalBackColor = {0.7, 0.7, 0.7};
6 OmaRF.dispelBackColor = {0.5, 0.2, 0};
7
8 OmaRF.frames = {};
9 OmaRF.positions = {
10     "TOPLEFT", "TOPRIGHT", "CENTER", "BOTTOMLEFT", "BOTTOMRIGHT"
11 };
12
13 OmaRF.running = false;
14
15 local defaults = {
16     profile = {
17         enabled = true,
18         indicators = {
19             ['**'] = {
20                 auras = {},
21                 textSize = 10,
22                 textColor = {1, 1, 1, 1},
23                 mine = false,
24                 stack = true,
25                 showText = true,
26                 showIcon = true,
27                 useDefaultIcon = true,
28                 iconSize = 10,
29                 iconColor = {1, 1, 1, 1},
30             },
31         },
32     }
33 };
34
35 function OmaRF:OnInitialize()
36     self.db = LibStub("AceDB-3.0"):New("OmaRFDB", defaults);
37     self.db.RegisterCallback(self, "OnProfileChanged", "RefreshConfig");
38     self.db.RegisterCallback(self, "OnProfileCopied", "RefreshConfig");
39     self.db.RegisterCallback(self, "OnProfileReset", "RefreshConfig");
40 end
41
42 function OmaRF:OnEnable()
43     self:RefreshConfig();
44 end
45
46 function OmaRF:OnDisable()
47     self.running = false;
48     for _, frame in pairs(self.frames) do
49         for _, ind in pairs(frame) do
50             ind.text:SetText("");
51             ind.icon:SetTexture("");
52         end
53     end
54 end
55
56 SLASH_OMARF1 = "/omarf";
57 function SlashCmdList.OMARF(msg, editBox)
58     local loaded, finished = IsAddOnLoaded("OmaRFConfig");
59     if not loaded then
60         local loaded, reason = LoadAddOn("OmaRFConfig");
61         if not loaded then
62             if reason == "DISABLED" then
63                 print("OmaRFConfig is disabled");
64             elseif reason == "MISSING" then
65                 print("OmaRFConfig is missing");
66             elseif reason == "CORRUPT" then
67                 print("OmaRFConfig is corrupt");
68             elseif reason == "INCOMPATIBLE" then
69                 print("OmaRFConfig is incompatible");
70             elseif reason == "INTERFACE_VERSION" then
71                 print("OmaRFConfig has wrong interface version");
72             end
73             return;
74         end
75     elseif not finished then
76         -- slash command sent again when loading process is in progress
77         return;
78     end
79
80     InterfaceOptionsFrame_OpenToCategory(OmaRF.optionsFrames.Profile);
81     InterfaceOptionsFrame_OpenToCategory(OmaRF.optionsFrames.Indicators);
82 end