diff WorldPlan.lua @ 69:31de7e9e7849

stop hiding pins when the timeleft returns 0; use C_TQ.IsActive
author Nenue
date Wed, 05 Apr 2017 11:36:06 -0400
parents cce68795f955
children bb2baedae81f
line wrap: on
line diff
--- a/WorldPlan.lua	Sun Apr 02 13:51:24 2017 -0400
+++ b/WorldPlan.lua	Wed Apr 05 11:36:06 2017 -0400
@@ -11,6 +11,7 @@
 local BROKEN_ISLES_ID = 1007
 local GetCurrentMapAreaID = GetCurrentMapAreaID
 local GetTime, IsLoggedIn = GetTime, IsLoggedIn
+local DEBUG_HISTORY = {}
 
 -- Define tables here so the pointers match up
 WorldPlanCore = { defaults = {}, modules = {}, TaskQueue = {}, }
@@ -192,6 +193,50 @@
   end
 end
 
+function db.log(msg)
+  WorldPlanData.Debug = WorldPlanData.Debug or {}
+  tinsert(WorldPlanData.Debug, msg)
+  tinsert(DEBUG_HISTORY, msg)
+  if WorldPlanDebug:IsShown() then
+    WorldPlanDebug:Update()
+  end
+end
+
+WorldPlanDebugMixin = {
+  OnLoad = function(self)
+    self:SetFont("Interface\\Addons\\Devian\\font\\SourceCodePro-Regular.ttf", 13, 'NORMAL')
+    self:SetJustifyH('LEFT')
+    self:SetFading(false)
+    self:SetMaxLines(2048)
+    self.loadedMessages = 0
+  end,
+  OnShow = function(self)
+    if self.loadedMessages < #DEBUG_HISTORY then
+      self:Update()
+    end
+  end,
+  Update = function(self)
+    for i = self.loadedMessages, #DEBUG_HISTORY do
+      self:AddMessage(DEBUG_HISTORY[i])
+      self.loadedMessages = i
+    end
+  end ,
+  OnMouseWheel = function(self, delta)
+
+  local up =  delta > 0
+  if IsControlKeyDown() then
+    if up then self:ScrollToTop()
+    else self:ScrollToBottom() end
+  elseif IsShiftKeyDown() then
+    if up then self:PageUp()
+    else self:PageDown() end
+  else
+    if up then self:ScrollUp()
+    else self:ScrollDown() end
+  end
+end
+}
+
 function WorldPlanCore:OnConfigUpdate()
   for _, module in ipairs(db.OrderedModules) do
     if module.OnConfigUpdate then
@@ -389,7 +434,16 @@
   if not WorldPlanData then
     WorldPlanData = {key = 0}
   end
+
+  -- debug info
   WorldPlanData.key = (WorldPlanData.key or 0) + 1
+  WorldPlanData.Debug = WorldPlanData.Debug or {}
+  for _, msg in ipairs(WorldPlanData.Debug) do
+    tinsert(DEBUG_HISTORY, msg)
+  end
+  tinsert(DEBUG_HISTORY, '--SESSION BREAK--')
+  wipe(WorldPlanData.Debug)
+
   db.Config = WorldPlanData
   for k,v in pairs(db.DefaultConfig) do
     --[===[@non-debug@
@@ -484,6 +538,14 @@
         self:print('WorldPlanSummary:Refresh(true)')
         WorldPlanSummary:Refresh(true)
       end
+    elseif arg1 == 'log' then
+      WorldPlanDebug:SetShown(true)
+    elseif arg1 == 'debug' then
+      if WorldPlanData then
+        WorldPlanData.DebugEnabled = (not WorldPlanData.DebugEnabled)
+        self:print(WorldPlanData.DebugEnabled and "Debugger on." or "Debugger off.")
+      end
+
     else
       self:print('Refreshing data.')
       self:Refresh(true)