diff ObjectiveCore.lua @ 21:d5ee940de273

use hardcoded aesthetic manipulations over loadstring cramming
author Nenue
date Fri, 08 Apr 2016 06:12:05 -0400
parents 6bd2102d340b
children 9b3fa734abff
line wrap: on
line diff
--- a/ObjectiveCore.lua	Wed Apr 06 07:54:19 2016 -0400
+++ b/ObjectiveCore.lua	Fri Apr 08 06:12:05 2016 -0400
@@ -58,7 +58,7 @@
 
 local OBJECTIVE_TRACKER_UPDATE_REASON = OBJECTIVE_TRACKER_UPDATE_ALL -- default
 --- Used to determine which trackers are listening for money events
-mod.MoneyReasons = 0
+mod.watchMoneyReasons = 0
 
 --- Baseline defaults table; values defined in the files that they pertain to
 mod.defaults = {}
@@ -87,10 +87,15 @@
   OffsetY = WRAPPER_OFFSET_Y,
   Height = WRAPPER_MAX_HEIGHT,
   Width = WRAPPER_WIDTH,
-  HeaderHeight = WRAPPER_HEADER_HEIGHT
+  HeaderHeight = WRAPPER_HEADER_HEIGHT,
+  TextSpacing = 3,
+  TitleSpacing = 3,
 }
+
+
+
 --- Tracker module definitions begin here; innards dealing with data retreival and output are defined further in
-mod.DefaultTracker = {
+mod.DefaultHandler = {
   previousHeight = 0,
 
   name = "temp",
@@ -150,8 +155,7 @@
 local Tracker_call = function (self, reason)
   self:Update(reason)
 end
-
-local Tracker_Initialize = function (self, name, index)
+local Handler_Initialize = function (self, name, index)
   print('Initializing |cFF00FFFF'..name..'|r module...')
 
   local handler = setmetatable(mod[name] or {}, {
@@ -195,6 +199,7 @@
   mod.SetBlockStyle(frame, 'Tracker', 'Normal')
   handler.frame = frame
   handler.trackerName = trackerName
+  handler.lines = {}
   mod.orderedTrackers[index] = frame
   mod.namedTrackers[name] = frame
   mod.indexedTrackers[handler] = frame
@@ -204,14 +209,17 @@
   return true
 end
 
+
 function mod:OnEvent (event, ...)
   local isHandled
-  print('|cFF00FF00'.. event ..'|r', ...)
+  print('OnEvent(|cFF00FF00'.. event ..'|r):', ...)
   if ( event == "QUEST_LOG_UPDATE" ) then
-    mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST);
+    mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST);
+
   elseif ( event == "TRACKED_ACHIEVEMENT_UPDATE" ) then
     --AchievementObjectiveTracker_OnAchievementUpdate(...);
     mod.Cheevs:Update(OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT)
+
   elseif ( event == "QUEST_ACCEPTED" ) then
     local questLogIndex, questID = ...;
     if ( IsQuestTask(questID) ) then
@@ -221,7 +229,9 @@
         AddQuestWatch(questLogIndex);
         SetSuperTrackedQuestID(questID);
       end
+      mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST)
     end
+
   elseif ( event == "TRACKED_ACHIEVEMENT_LIST_CHANGED" ) then
     local achievementID, added = ...;
     if ( added ) then
@@ -229,27 +239,29 @@
     else
       mod:Update(OBJECTIVE_TRACKER_UPDATE_ACHIEVEMENT);
     end
+
   elseif ( event == "QUEST_WATCH_LIST_CHANGED" ) then
     local questID, added = ...;
     if ( added ) then
       if ( not IsQuestTask(questID) ) then
-        mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED, questID);
+        mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST_ADDED, questID, added);
       end
     else
-      mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST);
+      mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST, questID, added);
     end
+
   elseif ( event == "QUEST_POI_UPDATE" ) then
     QuestPOIUpdateIcons();
     if ( GetCVar("trackQuestSorting") == "proximity" ) then
       SortQuestWatches();
     end
 
-    mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST);
+    mod:Update(OBJECTIVE_TRACKER_UPDATE_ALL);
 
   elseif ( event == "SCENARIO_CRITERIA_UPDATE" ) then
     mod:Update(OBJECTIVE_TRACKER_UPDATE_SCENARIO);
   elseif ( event == "SUPER_TRACKED_QUEST_CHANGED" ) then
-    mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST)
+    --mod:Update(OBJECTIVE_TRACKER_UPDATE_QUEST)
   elseif ( event == "ZONE_CHANGED" ) then
     local inMicroDungeon = IsPlayerInMicroDungeon();
     if ( inMicroDungeon ~= self.inMicroDungeon ) then
@@ -262,7 +274,7 @@
   elseif ( event == "QUEST_AUTOCOMPLETE" ) then
     local questId = ...;
     AddAutoQuestPopUp(questId, "COMPLETE");
-    mod:Update(OBJECTIVE_TRACKER_UPDATE_STATIC)
+    mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST)
   elseif ( event == "SCENARIO_UPDATE" ) then
     local newStage = ...;
     if ( newStage ) then
@@ -275,12 +287,20 @@
       SetMapToCurrentZone();			-- update the zone to get the right POI numbers for the tracker
     end
     SortQuestWatches();
+    mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE)
+  elseif (event == 'CRITERIA_COMPLETE') then
+    mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE)
+
   elseif ( event == "QUEST_TURNED_IN" ) then
     local questID, xp, money = ...;
     if ( IsQuestTask(questID) ) then
       mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_BONUS_OBJECTIVE)
+    else
+
+      mod:Update(OBJECTIVE_TRACKER_UPDATE_MODULE_QUEST)
     end
   elseif ( event == "PLAYER_MONEY" and self.watchMoneyReasons > 0 ) then
+    -- only update trackers that have money counters
     mod:Update(self.watchMoneyReasons);
   end
 end
@@ -317,31 +337,44 @@
   end
   Scroller:SetScrollChild(Scroll)
   Scroller:SetWidth(c.Width)
-  Scroll:SetPoint('TOPLEFT', Scroller, 'TOPLEFT')
   Scroll:SetWidth(c.Width)
+  Scroll:ClearAllPoints()
+  Scroll:SetPoint('TOP', Scroller, 'TOP')
   ObjectiveTrackerFrame:UnregisterAllEvents()
   ObjectiveTrackerFrame:Hide()
 end
 
 --- Done any time the the minimize button is toggled up
 
+
 function mod:OnEnable()
   for id, name in ipairs(mod.orderedNames) do
     if not mod.orderedHandlers[id] then
-      Tracker_Initialize(mod.DefaultTracker, name, id)
+      Handler_Initialize(mod.DefaultHandler, name, id)
     end
   end
 
-  for event, func in pairs(mod) do
-    if type(func) == 'function' and event:match('^[A-Z_]+$') then
-      print('|cFFFF44FFlistening to', event)
-      Wrapper:RegisterEvent(event)
-    end
-  end
+  Wrapper:RegisterEvent("CRITERIA_COMPLETE");
+  Wrapper:RegisterEvent("SCENARIO_UPDATE");
+  Wrapper:RegisterEvent("SCENARIO_CRITERIA_UPDATE");
+  Wrapper:RegisterEvent("PLAYER_MONEY");
+  Wrapper:RegisterEvent("QUEST_ACCEPTED");
+  Wrapper:RegisterEvent("QUEST_AUTOCOMPLETE");
+  Wrapper:RegisterEvent("QUEST_LOG_UPDATE");
+  Wrapper:RegisterEvent("QUEST_POI_UPDATE");
+  Wrapper:RegisterEvent("QUEST_TURNED_IN");
+  Wrapper:RegisterEvent("QUEST_WATCH_LIST_CHANGED");
+  Wrapper:RegisterEvent("SUPER_TRACKED_QUEST_CHANGED");
+  Wrapper:RegisterEvent("TRACKED_ACHIEVEMENT_LIST_CHANGED");
+  Wrapper:RegisterEvent("TRACKED_ACHIEVEMENT_UPDATE");
+  Wrapper:RegisterEvent("VARIABLES_LOADED");
+  Wrapper:RegisterEvent("ZONE_CHANGED_NEW_AREA");
+  Wrapper:RegisterEvent("ZONE_CHANGED");
+  Wrapper:SetScript('OnEvent', mod.OnEvent)
 
   local c = mod.Conf.Wrapper
-  Wrapper:SetPoint(c.AnchorPoint, UIParent, c.AnchorPoint, c.OffsetX, c.OffsetY)
-  B.Conf.FramePosition[Wrapper:GetName()] = {c.AnchorPoint, c.AnchorPoint, c.OffsetX, c.OffsetY}
+  --Wrapper:SetPoint(c.AnchorPoint, UIParent, c.AnchorPoint, c.OffsetX, c.OffsetY)
+  --B.Conf.FramePosition[Wrapper:GetName()] = {c.AnchorPoint, c.AnchorPoint, c.OffsetX, c.OffsetY}
   Wrapper:SetWidth(c.Width)