diff WorldPlan.lua @ 7:34d9fbf7af20

beginning of reflecting code path isolation in file structure
author Nenue
date Sat, 22 Oct 2016 15:36:25 -0400
parents 232617b8bcd5
children 802abb8a10ea
line wrap: on
line diff
--- a/WorldPlan.lua	Fri Oct 21 18:10:53 2016 -0400
+++ b/WorldPlan.lua	Sat Oct 22 15:36:25 2016 -0400
@@ -23,6 +23,9 @@
 local WP_VERSION = "1.0"
 
 local print = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end
+local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end
+local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or function() end
+
 local wipe, tremove, tinsert, pairs, floor, tContains = table.wipe, table.remove, table.insert, pairs, floor, tContains
 local TQ_GetQuestInfoByQuestID = C_TaskQuest.GetQuestInfoByQuestID -- Return the name of a quest with a given ID
 local TQ_GetQuestsForPlayerByMapID = C_TaskQuest.GetQuestsForPlayerByMapID -- This function is not yet documented
@@ -45,8 +48,6 @@
 local GetCurrentMapAreaID, GetMapNameByID, GetSuperTrackedQuestID = GetCurrentMapAreaID, GetMapNameByID, GetSuperTrackedQuestID
 local MC_GetNumZones, MC_GetZoneInfo = C_MapCanvas.GetNumZones, C_MapCanvas.GetZoneInfo
 
-local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end
-local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or function() end
 
 local SearchFaction
 local PinBaseIndex = 1600
@@ -177,25 +178,6 @@
   { filterKey= 'worldQuestType', filterValue = LE_QUEST_TAG_TYPE_DUNGEON, label = 'Dungeon', texture = "Interface\\LFGFRAME\\UI-LFR-PORTRAIT", },
 }
 
-local PIN_TIME_CONTEXT = {
-  {max = 60,
-    r=1, g=0.25, b =0, format = function (minutes) return '|cFFFF4400'.. minutes .. 'm' end,
-    continentAlpha = 1, swipeTime = 1440,
-  },
-  {max = 240,
-    r=1, g=.5, b=0, format = function(minutes) return '|cFFFF4400'.. floor(minutes/60) .. 'h' end,
-    continentAlpha = 1, swipeTime = 1440,
-  },
-  {max = 1440,
-    r=1, g=1, b=0, format = function(minutes) return '|cFFFFFF00'.. floor(minutes/60) .. 'h' end,
-    continentAlpha = .55, swipeTime = 1440
-  },
-  {max = 10081,
-    r=0, g=1, b=0,
-    continentAlpha = .3,
-  }, -- 7 days + 1 minute
-}
-
 local numPins = 0
 local QuestsByZone = {}
 local QuestsByFaction = {}
@@ -499,13 +481,6 @@
       --print('|cFF00FF00Creating', name)
       pin = CreateFrame('Frame', name, WorldMapPOIFrame, 'WorldPlanQuestPin')
       pin:SetFrameStrata('HIGH')
-      pin:SetScript('OnEnter', function(self)
-        TaskPOI_OnEnter(self)
-      end)
-      pin:SetScript('OnLeave', function(self)
-        TaskPOI_OnLeave(self)
-      end)
-      pin:SetScript('OnMouseDown', TaskPOI_OnClick)
 
       NumPinFrames = NumPinFrames + 1
 
@@ -519,6 +494,10 @@
     -- used by TaskPOI_x scripts
     pin.questID = questID
     pin.worldQuest = true
+
+    pin.Reset = function(self)
+      WorldQuests:GetPinByQuestID(questID)
+    end
   else
     --print('|cFF00FF00Using', pin:GetName())
   end
@@ -883,96 +862,9 @@
 local tooltipLine3 = _G['VeneerWorldQuestsScannerTextLeft3']
 local GetTime, mod = GetTime, mod
 
-function QuestPOI:OnLoad()
-  self:RegisterEvent('SUPER_TRACKED_QUEST_CHANGED')
-end
 
-function QuestPOI:OnEvent(event, ...)
-  if event == 'SUPER_TRACKED_QUEST_CHANGED' then
-    if self:IsVisible() then
-      self:Refresh()
-    end
-  end
-end
 
-local PIN_UPDATE_DELAY = .016
-local TOP_PIN_ID
-function QuestPOI:OnUpdate (sinceLast)
-  -- control update check intervals
-  self.throttle = (self.throttle or PIN_UPDATE_DELAY) - sinceLast
-  if self.throttle <= 0 then
-    -- factor overtime into the throttle timer
-    self.throttle = PIN_UPDATE_DELAY - self.throttle
-  else
-    return
-  end
 
-  -- query for reward data if it wasn't found in the original scan
-  local questID = self.questID
-  if self.isPending then
-    WorldQuests:GetPinByQuestID(questID)
-    if not (self.PendingFade:IsPlaying() or self.isAnimating) then
-      self.PendingFade:Play()
-    end
-    return
-  else
-    if self.PendingFade:IsPlaying() then
-      self.PendingFade:Stop()
-    end
-  end
-
-  if self.hasUpdate then
-    self:Refresh()
-    self.hasUpdate = nil
-  end
-
-  -- update time elements
-  local tl = self.timeThreschold
-  local timeLeft = TQ_GetQuestTimeLeftMinutes(questID)
-  if timeLeft > 0 then
-    for i, context in ipairs(PIN_TIME_CONTEXT) do
-      if i > self.TimeleftStage then
-        self.timeLabel:SetText(nil)
-        break
-      end
-
-
-      if timeLeft <= context.max then
-        if tl ~= i then
-          tl = i
-        end
-
-        if context.format then
-          self.timeLabel:SetText(context.format(timeLeft))
-        else
-          self.timeLabel:SetText(nil)
-        end
-        break
-      end
-    end
-  else
-    -- remove self in a timely manner
-    if not self.isPending then
-      self:Hide()
-    end
-  end
-  self.timeThreschold = tl
-
-  if self:IsMouseOver() then
-    self.MouseGlow:Show()
-  else
-    self.MouseGlow:Hide()
-  end
-end
-
-function QuestPOI:OnShow ()
-  qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnShow()')
-  -- pop this on principle
-  self:Refresh()
-end
-function QuestPOI:OnHide()
-  --qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnHide()')
-end
 function QuestPOI:Refresh ()
   print('|cFF00FF88["'..tostring(self.title)..'"]|r:Refresh()', tostring(self.title), "|T"..tostring(self.itemTexture)..":12:12|t", tostring(self.itemName))
   qprint(self.style)
@@ -1035,28 +927,7 @@
   qprint('|cFF88FF00updated', questID, self.title, self.rewardType, (style.showNumber and self.itemNumber) or '')
 end
 
-function QuestPOI:SetAnchor(frame, mapID, mapWidth, mapHeight)
-  self:ClearAllPoints()
-  local dX, dY = TQ_GetQuestLocation(self.questID, mapID)
-  if not dX or dX == 0 then
-    local _, x, y = QuestPOIGetIconInfo(self.questID)
-    if x and floor(x) ~= 0 then
-      dX, dY = x, y
-    else
-      dX, dY = self.x, self.y
-    end
-  end
-  self.x = dX
-  self.y = dY
 
-  print('  |cFF00FF00'..self.questID..':|r', format("%0.2f %0.2f", dX, dY))
-
-  local pX = (dX * mapWidth)
-  local pY = (-dY * mapHeight)
-
-  self:SetParent(WorldMapPOIFrame)
-  self:SetPoint('CENTER', frame, 'TOPLEFT', pX, pY)
-end
 
 
 function QuestPOI:IsShowable (ignoreFilters)
@@ -1161,7 +1032,6 @@
 end
 
 
-
 function FilterBar:OnEvent(event)
   if event == 'QUEST_LOG_UPDATE' then
     self:Refresh()