Quantcast

Fixing issues with an updated version of Grid.

Tirds [08-08-12 - 01:23]
Fixing issues with an updated version of Grid.
Filename
GridStatusSmartHealing.lua
GridStatusSmartHealing.toc
status/chainheal.lua
status/playersinarea.lua
diff --git a/GridStatusSmartHealing.lua b/GridStatusSmartHealing.lua
index fdb2af5..f732fe3 100644
--- a/GridStatusSmartHealing.lua
+++ b/GridStatusSmartHealing.lua
@@ -5,11 +5,9 @@ local GridFrame = Grid:GetModule("GridFrame");
 local MapData = LibStub("LibMapData-1.0");

 local APP = "GridStatusSmartHealing";
-GridStatusSmartHealing = GridStatus:NewModule(APP);
+GridStatusSmartHealing = Grid:NewStatusModule(APP);
 GridStatusSmartHealing.menuName = "Smart Healing - by Tirds";

--- Settings var from self.db.profile;
-local Settings;
 -- Timer used to measure time between updates
 local Timer = 0;
 -- Blank frame used to run OnUpdate
@@ -56,31 +54,22 @@ GridStatusSmartHealing.extraOptions =
             return false;
         end,
         set = function()
-            local asdf = GridStatus.options.args;
-            print(asdf);
-            for key, value in pairs(asdf) do
+            print(GridStatusSmartHealing.statusModules);
+            for key, value in pairs(GridStatusSmartHealing.statusModules) do
                 print(key, " = ", value);
-                if (key == APP) then
-                    print("-------");
-                    for key2, value2 in pairs(value) do
-                        print(key2, " = ", value2);
-                    end
-                    print("-------");
-                end
             end
         end
     }
-    ]]--;
+    ]]
 }
 GridStatusSmartHealing.statusModules = {};

 -- module stuff
 GridStatusSmartHealing.modulePrototype = GridStatus.modulePrototype;
-GridStatusSmartHealing.core = GridStatusSmartHealing;
-
-function GridStatusSmartHealing.modulePrototype:RegisterStatus(status, desc, options, inMainMenu, order)
-    GridStatus:RegisterStatus(status, desc, self.moduleName or true);
+GridStatusSmartHealing:SetDefaultModulePrototype(GridStatusSmartHealing.modulePrototype);

+function GridStatusSmartHealing:RegisterStatus(module, status, desc, options, inMainMenu, order)
+    GridStatus:RegisterStatus(status, desc, module.moduleName or true);

     options["enabled"] =
     {
@@ -90,17 +79,17 @@ function GridStatusSmartHealing.modulePrototype:RegisterStatus(status, desc, opt
         width = "full",
         type = "toggle",
         get = function()
-            return self.db.profile.enable;
+            return module.db.profile.enable;
         end,
         set = function(info, v)
-            self.db.profile.enable = v;
+            module.db.profile.enable = v;
             if (v) then
-                if (self["OnStatusEnable"]) then
-                    self:OnStatusEnable(status);
+                if (module["OnStatusEnable"]) then
+                    module:OnStatusEnable(status);
                 end
             else
-                if (self["OnStatusDisable"]) then
-                    self:OnStatusDisable(status);
+                if (module["OnStatusDisable"]) then
+                    module:OnStatusDisable(status);
                 end
             end
         end
@@ -113,15 +102,15 @@ function GridStatusSmartHealing.modulePrototype:RegisterStatus(status, desc, opt
         type = "color",
         hasAlpha = true,
         get = function()
-            local color = self.db.profile.color
-            return color.r, color.g, color.b, color.a
+            local color = module.db.profile.color;
+            return color.r, color.g, color.b, color.a;
         end,
         set = function(_, r, g, b, a)
-            local color = self.db.profile.color
-            color.r = r
-            color.g = g
-            color.b = b
-            color.a = a or 1
+            local color = module.db.profile.color;
+            color.r = r;
+            color.g = g;
+            color.b = b;
+            color.a = a or 1;
         end,
     };
     options["priority"] =
@@ -131,10 +120,10 @@ function GridStatusSmartHealing.modulePrototype:RegisterStatus(status, desc, opt
         order = 30,
         type = "range", max = 99, min = 0, step = 1,
         get = function()
-            return self.db.profile.priority
+            return module.db.profile.priority
         end,
         set = function(_, v)
-            self.db.profile.priority = v
+            module.db.profile.priority = v
         end,
     };

@@ -142,27 +131,16 @@ function GridStatusSmartHealing.modulePrototype:RegisterStatus(status, desc, opt
     {
         type = "group",
         name = desc,
-        desc = "Options for " .. desc,
+        desc = string.format(L("Options for %s"), desc),
         args = options,
     };
 end

-function GridStatusSmartHealing:OnModuleCreated(statusModule)
-    statusModule.super = self.modulePrototype;
-
-    GridStatusSmartHealing.statusModules[statusModule.name] = statusModule;
-end
-
-GridStatusSmartHealing:SetDefaultModulePrototype(GridStatusSmartHealing.modulePrototype);
-
-function GridStatusSmartHealing:OnInitialize()
-    self.super.OnInitialize(self);
-    self.roster = {};------------------------
+function GridStatusSmartHealing:PostInitialize()
+    self.roster = {};

     -- Do now so modulePrototype can register Options for modules
     self:InitializeOptions();
-
-    Settings = self.db.profile;
 end

 function GridStatusSmartHealing:PostEnable()
@@ -187,7 +165,7 @@ function GridStatusSmartHealing:DoEnable(force)
         NumEnabled = NumEnabled + 1;
         return;
     end
-    GridStatus:Debug("Enabling", self.moduleName);
+    self:Debug("Enabling", self.moduleName);
     self:UpdateRoster();

     self:RegisterEvent("PLAYER_MEMBERS_CHANGED", "UpdateRoster");
@@ -197,6 +175,7 @@ function GridStatusSmartHealing:DoEnable(force)
         return self:OnUpdate(timer);
     end);

+    -- todo loop modules and check enabled
     if (not force) then
         NumEnabled = 1;
     end
@@ -220,7 +199,7 @@ function GridStatusSmartHealing:DoDisable()
     NumEnabled = NumEnabled - 1;

     if (NumEnabled == 0) then
-        GridStatus:Debug("Disabling", self.moduleName);
+        self:Debug("Disabling", self.moduleName);
         BlankFrame:SetScript("OnUpdate", nil);
         self:UnregisterEvent("PLAYER_MEMBERS_CHANGED");
         self:UnregisterEvent("RAID_ROSTER_UPDATE");
@@ -247,16 +226,18 @@ function GridStatusSmartHealing:OnUpdate(elapsed)
     Timer = Timer + elapsed;

     if (NumEnabled == 0) then
+        self:Debug("Nothing is Enabled to Update");
         return;
     end

-    if (Timer >= Settings.cycle) then
+    if (Timer >= self.db.profile.cycle) then
         Timer = 0;
         --self:UpdateRoster();
         if (self:UpdateMap()) then
             self:UpdateData();
             self:UpdateAll();
         else
+            self:Debug("Update Map Failed");
             self:ClearAll();
         end
     end
@@ -362,3 +343,9 @@ function GridStatusSmartHealing:IsValidHealTarget(unitId)
         UnitIsVisible(unitId) and
         not (UnitIsCharmed(unitId) and UnitIsEnemy("player", unitId));
 end
+
+function GridStatusSmartHealing:NewModule(name)
+    local statusModule = Grid:NewStatusModule(name);
+    GridStatusSmartHealing.statusModules[statusModule.name] = statusModule;
+    return statusModule;
+end
\ No newline at end of file
diff --git a/GridStatusSmartHealing.toc b/GridStatusSmartHealing.toc
index b9197fd..bec21a5 100644
--- a/GridStatusSmartHealing.toc
+++ b/GridStatusSmartHealing.toc
@@ -3,7 +3,7 @@
 ## Notes: Adds statuses to grid for best targets for smart heals.
 ## Dependencies: Grid, LibMapData-1.0
 ## Author: Tirds
-## Version: v0.2b
+## Version: v0.3b
 ## X-GridStatusModule: GridStatusSmartHealing

 GridStatusSmartHealing.lua
diff --git a/status/chainheal.lua b/status/chainheal.lua
index 40d8dff..0120d4c 100644
--- a/status/chainheal.lua
+++ b/status/chainheal.lua
@@ -103,10 +103,8 @@ local thisStatus = "alert_gssh_chainheal";

 local chainHealGlyph = 55437;

-function GridStatusSmartHealing_ChainHeal:OnInitialize()
-    self.super.OnInitialize(self);
-
-    self:RegisterStatus(thisStatus, "Smart Healing - Chain Heal", options, false);
+function GridStatusSmartHealing_ChainHeal:PostInitialize()
+    SmartHealing:RegisterStatus(self, thisStatus, "Smart Healing - Chain Heal", options, false);

     Settings = self.db.profile;
 end
diff --git a/status/playersinarea.lua b/status/playersinarea.lua
index 896259b..25b82e6 100644
--- a/status/playersinarea.lua
+++ b/status/playersinarea.lua
@@ -127,10 +127,8 @@ local options =
 local thisStatus = "alert_gssh_playersinarea";
 local Settings;

-function GridStatusSmartHealing_InArea:OnInitialize()
-    self.super.OnInitialize(self);
-
-    self:RegisterStatus(thisStatus, "Smart Healing - Players in Area", options, false);
+function GridStatusSmartHealing_InArea:PostInitialize()
+    SmartHealing:RegisterStatus(self, thisStatus, "Smart Healing - Players in Area", options, false);

     Settings = self.db.profile;
 end