c6843f3 - Refactor updateIndicators to get auras when they're applied
[wowui.git] / OmaRF / Core.lua
index e4c2d29..d39b6e6 100644 (file)
@@ -1,24 +1,35 @@
-OmaRF = LibStub("AceAddon-3.0"):NewAddon("OmaRF");
+local unpack = unpack;
+local wipe = wipe;
+local next = next;
+local pairs = pairs;
+local ipairs = ipairs;
+
+OmaRF = CreateFrame("Frame");
 
 OmaRF.normalBarColor = CreateColor(0.3, 0.3, 0.3);
 OmaRF.dispelBarColor = CreateColor(1, 0.5, 0);
 OmaRF.normalBackColor = {0.7, 0.7, 0.7};
 OmaRF.dispelBackColor = {0.5, 0.2, 0};
 
 OmaRF.normalBarColor = CreateColor(0.3, 0.3, 0.3);
 OmaRF.dispelBarColor = CreateColor(1, 0.5, 0);
 OmaRF.normalBackColor = {0.7, 0.7, 0.7};
 OmaRF.dispelBackColor = {0.5, 0.2, 0};
-
 OmaRF.frames = {};
 OmaRF.frames = {};
+OmaRF.majorFrames = {};
 OmaRF.positions = {
     "TOPLEFT", "TOPRIGHT", "CENTER", "BOTTOMLEFT", "BOTTOMRIGHT"
 };
 OmaRF.positions = {
     "TOPLEFT", "TOPRIGHT", "CENTER", "BOTTOMLEFT", "BOTTOMRIGHT"
 };
-
 OmaRF.running = false;
 OmaRF.running = false;
+OmaRF.ooc_queue = {};
 
 local defaults = {
     profile = {
 
 local defaults = {
     profile = {
-        indicatorFont = "Arial Narrow",
-        showIcons = true,
         enabled = true,
         enabled = true,
+        majorAuras = {
+            auras = {"Aqua Bomb"},
+            max = 3;
+            iconSize = 24,
+            textSize = 10,
+        },
         indicators = {
             ['**'] = {
         indicators = {
             ['**'] = {
+                auras = {},
                 textSize = 10,
                 textColor = {1, 1, 1, 1},
                 mine = false,
                 textSize = 10,
                 textColor = {1, 1, 1, 1},
                 mine = false,
@@ -46,19 +57,39 @@ end
 
 function OmaRF:OnDisable()
     self.running = false;
 
 function OmaRF:OnDisable()
     self.running = false;
-    for _, frame in pairs(self.frames) do
+    for name, frame in pairs(self.frames) do
         for _, ind in pairs(frame) do
         for _, ind in pairs(frame) do
-            ind.text:SetText("");
-            ind.icon:SetTexture("");
+            ind.text:Hide();
+            ind.icon:Hide();
+        end
+        for _, ind in ipairs(self.majorFrames[name]) do
+            ind.icon:Hide();
+            ind.expireText:Hide();
+            ind.stackText:Hide();
         end
     end
 end
 
         end
     end
 end
 
+local function onEvent(self, event, ...)
+    if event == "PLAYER_REGEN_ENABLED" then
+        for _, t in pairs(self.ooc_queue) do
+            t.func(unpack(t.args));
+        end
+        if next(self.ooc_queue) ~= nil then
+            wipe(self.ooc_queue);
+        end
+    elseif event == "PLAYER_LOGIN" then
+        self:OnEnable();
+    elseif event == "ADDON_LOADED" then
+        self:OnInitialize();
+    end
+end
+
 SLASH_OMARF1 = "/omarf";
 function SlashCmdList.OMARF(msg, editBox)
 SLASH_OMARF1 = "/omarf";
 function SlashCmdList.OMARF(msg, editBox)
-    local loaded, finished = IsAddonLoaded("OmaRFConfig");
+    local loaded, finished = IsAddOnLoaded("OmaRFConfig");
     if not loaded then
     if not loaded then
-        local loaded, reason = LoadAddon("OmaRFConfig");
+        local loaded, reason = LoadAddOn("OmaRFConfig");
         if not loaded then
             if reason == "DISABLED" then
                 print("OmaRFConfig is disabled");
         if not loaded then
             if reason == "DISABLED" then
                 print("OmaRFConfig is disabled");
@@ -78,5 +109,11 @@ function SlashCmdList.OMARF(msg, editBox)
         return;
     end
 
         return;
     end
 
+    InterfaceOptionsFrame_OpenToCategory(OmaRF.optionsFrames.Profile);
     InterfaceOptionsFrame_OpenToCategory(OmaRF.optionsFrames.Indicators);
 end
     InterfaceOptionsFrame_OpenToCategory(OmaRF.optionsFrames.Indicators);
 end
+
+OmaRF:RegisterEvent("ADDON_LOADED");
+OmaRF:RegisterEvent("PLAYER_LOGIN");
+OmaRF:RegisterEvent("PLAYER_REGEN_ENABLED");
+OmaRF:SetScript("OnEvent", onEvent);