changeset 54:ed74c5cabe98

Core - updated comment notes Objectives - force hide blocks when their tracker is hidden Clock - convert clock into its own module - display zone coordinates alongside time
author Nenue
date Wed, 01 Jun 2016 20:48:14 -0400
parents 5cedcb683eda
children dd9b5f59632c
files ObjectiveTracker/Layout.lua ObjectiveTracker/ObjectiveTracker.lua ObjectiveTracker/ObjectiveTracker.xml TimeManager/TimeManager.lua TimeManager/TimeManager.xml Veneer.lua
diffstat 6 files changed, 162 insertions(+), 128 deletions(-) [+]
line wrap: on
line diff
--- a/ObjectiveTracker/Layout.lua	Fri Apr 29 17:06:48 2016 -0400
+++ b/ObjectiveTracker/Layout.lua	Wed Jun 01 20:48:14 2016 -0400
@@ -439,7 +439,12 @@
   return lineIndex
 end
 
-
+-- Resets blocks to hidden if the tracker framescript gets disrupted
+Default.OnHide = function(self)
+  for i, block in pairs(self.handler.usedBlocks) do
+    block:Hide()
+  end
+end
 
 ----------
 --- Top level methods
--- a/ObjectiveTracker/ObjectiveTracker.lua	Fri Apr 29 17:06:48 2016 -0400
+++ b/ObjectiveTracker/ObjectiveTracker.lua	Wed Jun 01 20:48:14 2016 -0400
@@ -245,6 +245,8 @@
   frame.title:SetText(handler.displayName)
   frame:SetWidth(c.Width)
   frame.previousOffset = 0
+  frame:SetScript('OnHide', T.DefaultHandler.OnHide)
+  frame.handler = handler
 
   handler.frame = frame
   handler.numBlocks = 0
@@ -499,7 +501,7 @@
 function T:OnInitialize()
   local c = T.Conf.Wrapper
   VeneerData = _G.VeneerData
-  VeneerData.CallLog = VeneerData.CallLog or {}
+  --VeneerData.CallLog = VeneerData.CallLog or {}
   if not T.isHooked then
     T.isHooked = true
     for _, func in ipairs(BlizzHooks) do
--- a/ObjectiveTracker/ObjectiveTracker.xml	Fri Apr 29 17:06:48 2016 -0400
+++ b/ObjectiveTracker/ObjectiveTracker.xml	Wed Jun 01 20:48:14 2016 -0400
@@ -158,37 +158,6 @@
       </Button>
 
 
-      <Frame name="VeneerClock" parentKey="Clock" hidden="false">
-        <Scripts>
-          <OnLoad>
-            self.toggle = true
-            Veneer.RegisterModuleFrame(self, 'Clock')
-          </OnLoad>
-        </Scripts>
-        <Anchors>
-          <Anchor point="TOPRIGHT" relativePoint="TOPLEFT" relativeKey="$parent.QuestMapButton" />
-        </Anchors>
-        <Size x="280" y="16" />
-        <Layers>
-          <Layer level="OVERLAY">
-            <FontString font="Interface\Addons\SharedMedia_MyMedia\font\XOIREQE.TTF" parentKey="time" text="GAME_TIME" outline="NORMAL">
-              <FontHeight>
-                <AbsValue val="14" />
-              </FontHeight>
-
-              <Anchors>
-                <Anchor point="RIGHT" />
-              </Anchors>
-              <Color r="1" g="1" b="1" a="1" />
-            </FontString>
-          </Layer>
-        </Layers>
-        <Scripts>
-          <OnUpdate>
-          </OnUpdate>
-        </Scripts>
-      </Frame>
-
 
       <Frame name="$parentQuestDetailsPane" parentKey="QuestDetails" hidden="true">
         <Anchors>
--- a/TimeManager/TimeManager.lua	Fri Apr 29 17:06:48 2016 -0400
+++ b/TimeManager/TimeManager.lua	Wed Jun 01 20:48:14 2016 -0400
@@ -1,26 +1,39 @@
 --------------------------------------------
 -- Veneer
+-- Clock/Coordinate multi-tool
+-- mouseover reveals coordinates by map yards, right-click toggles display
 -- Krakyn
 -- @project-revision@ @project-hash@
 -- @file-revision@ @file-hash@
 -- Created: 4/27/2016 1:02 AM
 --------------------------------------------
 
-local B, _G = select(2,...).frame, _G
-local clock = B:RegisterModule("Clock", VeneerClock)
+local B = select(2,...).frame
+local _G = _G
+local clock = B:RegisterModule("Clock", _G.VeneerClock)
+local print = B.print('XML') -- debug hook
+-- weekday abbreviations used in display
 local weekDays = {'Su', 'M', 'T', 'W', 'R' ,'F', 'Sa' }
 
-local print = B.print('XML')
-
+-- runs when visible
 clock.OnUpdate = function(self)
-  local weekday, month, day, year = CalendarGetDate()
-  local hour, min = GetGameTime()
+  local weekday, month, day, year = _G.CalendarGetDate()
+  local hour, min = _G.GetGameTime()
   if hour > 12 then
     hour = hour - 12
   end
-  self.time:SetFormattedText("|cAAFFFFFF%s|r |cFF44FFFF%s|r|c88FFFFFF/|r|cFF44FFFF%s|r %d:%02d", weekDays[weekday], month, day, hour, min)
+  local posFunc, posF = _G.GetPlayerMapPosition, 100
+  local posFormat = "|cFF00FFFF%0.1f %0.1f|r"
+  if self:IsMouseOver() then
+    posFunc = _G.UnitPosition
+    posFormat = "|cFFFFFF00%d %d|r"
+    posF = 1
+  end
+  local posX, posY = posFunc('player')
+  self.time:SetFormattedText(posFormat.. " |cAAFFFFFF%s|r |cFF44FFFF%s|r|c88FFFFFF/|r|cFF44FFFF%s|r %d:%02d", posX * posF, posY * posF, weekDays[weekday], month, day, hour, min)
 end
 
+-- hide/show toggler
 clock.OnMouseUp = function(self, button)
   if button == 'RightButton' then
     if self:IsVisible() then
@@ -31,7 +44,17 @@
   end
 end
 
+-- runs once per login
 function clock:OnInitialize()
   print('clock thing')
   self:Show()
+end
+
+-- runs once per ui load
+clock.OnEnable = function(self)
+  self:SetParent(_G.UIParent)
+  self:SetPoint('TOPRIGHT', _G.UIParent, 'TOPRIGHT', -100, -2)
+  self:SetScript('OnUpdate', clock.OnUpdate)
+  self:Show()
+  self.time:SetText('Clock stuff')
 end
\ No newline at end of file
--- a/TimeManager/TimeManager.xml	Fri Apr 29 17:06:48 2016 -0400
+++ b/TimeManager/TimeManager.xml	Wed Jun 01 20:48:14 2016 -0400
@@ -1,4 +1,35 @@
 <Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
 ..\FrameXML\UI.xsd">
 
+
+  <Frame name="VeneerClock" parent="UIParent" hidden="false">
+    <Scripts>
+      <OnLoad>
+        self.toggle = true
+        Veneer.RegisterModuleFrame(self, 'Clock')
+      </OnLoad>
+    </Scripts>
+    <Size x="280" y="16" />
+    <Layers>
+      <Layer level="OVERLAY">
+        <FontString font="Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf" parentKey="time" text="GAME_TIME" outline="NORMAL">
+          <FontHeight>
+            <AbsValue val="14" />
+          </FontHeight>
+
+          <Anchors>
+            <Anchor point="RIGHT" />
+          </Anchors>
+          <Color r="1" g="1" b="1" a="1" />
+        </FontString>
+      </Layer>
+    </Layers>
+    <Scripts>
+      <OnUpdate>
+      </OnUpdate>
+    </Scripts>
+  </Frame>
+
+  <Script file="TimeManager.lua" />
+
   </Ui>
\ No newline at end of file
--- a/Veneer.lua	Fri Apr 29 17:06:48 2016 -0400
+++ b/Veneer.lua	Wed Jun 01 20:48:14 2016 -0400
@@ -1,43 +1,53 @@
---- Modulizer framework
+--------------------------------------------
+-- Veneer
+-- Core
+-- author: Krakyn
+-- @project-revision@ @project-hash@
+-- @file-revision@ @file-hash@
+-- Created: 4/27/2016 1:02 AM
+--------------------------------------------
+--- Implemented methods
 -- OnInitialize
 -- OnUpdate
--- OnEnable     -- run when GetSpecialization() returns true
+-- OnEnable     -- runs as soon as GetSpecialization() returns valid data
 
 local ADDON, A = ...
-Veneer = Veneer or CreateFrame('Frame', 'Veneer', UIParent)
-local B = Veneer
 local wipe, min, max, random, tinsert, tremove = table.wipe, math.min, math.max, math.random, table.insert, table.remove
 local pairs, ipairs, select, unpack, _G = pairs, ipairs, select, unpack, _G
 local type, tostring, format = type, tostring, string.format
-A.frame = B
 
---- Cache tables
-local initOnced
-local modules = {}
-local queuedModules = {}
-local checkForConfig = {}
-local moduleStack = {
-}
+--- Establish presence
+Veneer = Veneer or CreateFrame('Frame', 'Veneer', UIParent)
+local V = Veneer
+A.frame = V
+
+--- Work variables
+local modules = {}        -- module collector
+local queuedModules = {}  -- indicates modules that were encountered out of dependency order
+local checkForConfig = {} -- indicates frames created from XML that use their own namespace for position control
+local moduleStack = {}    -- dictates the order in which module methods are fired
+local initOnced           -- internal check for doing bottom-up SV retrieval
 
 --- Utilities
-B.wipeall = function (...)
+V.wipeall = function (...)
   for i = 1, select('#', ...) do
     wipe(select(i, ...))
   end
 end
 
 --- Various region categories
-B.displays = {}
-B.configLayers = {}
-B.configLayersRef = {}
+V.displays = {}
+V.configLayers = {}
+V.configLayersRef = {}
 
 
---@debug@
---- Generates a print handler pointing to a static channel signature
--- @usage func = B.print(sig)
+--- Returns a debug hook for adding generic module information to each message
+-- @usage func = V.print(sig)
 -- @param sig channel name or number
+local debugstack = _G.debugstack
+local Devian = _G.Devian
 local printfuncs = {}
-B.print = function(pref, ...)
+V.print = function(pref, ...)
   if Devian and Devian.InWorkspace() then
       printfuncs[pref] = printfuncs[pref] or function(...) print(pref,  ...) end
 
@@ -47,6 +57,7 @@
   end
 end
 
+--@debug@
 local rgb = {}
 local getcolor = function()
   local n, p = 0, 4
@@ -63,12 +74,12 @@
 
 local color = {}
 local fprints = {}
-B.fprint = function()
+--- Attempts to generate a debug printer based on the local scope. Results vary by where the originator was invoked.
+V.fprint = function()
   if not (Devian and Devian.InWorkspace()) then
     return function() end
   end
 
-
   local sig = debugstack(2,1)
   if fprints[sig] then
     return fprints[sig]
@@ -88,14 +99,14 @@
   color[sig] = color[sig] or format('|cFF%02X%02X%02X%s|r', r, g, b, func)
 
   --print(color[func] .. ' ( ' .. table.concat(args, ', ')..' )' )
-  func = B.print(func)
+  func = V.print(func)
   fprints[sig] = func
   return func
 end
 
 --@end-debug@
 --[=[@non-debug@
-B.print = function() end
+V.print = function() end
 --@end-non-debug@]=]
 
 -- for the Mikk script
@@ -105,16 +116,17 @@
 -- GLOBALS: CONSOLIDATED_BUFFS_PER_ROW, CONSOLIDATED_BUFF_ROW_HEIGHT, NUM_TEMP_ENCHANT_FRAMES
 -- GLOBALS: BUFF_BUTTON_HEIGHT, BUFF_FRAME_BASE_EXTENT, BUFF_HORIZ_SPACING
 
-local print = B.print('Bfl')
+local print = V.print('Bfl')
 
 --- Template for making perpendicular traversals of the displays structure; also makes sure the table is there
-B.Abstract = function(dest, key, table)
+local setmetatable = setmetatable
+V.Abstract = function(dest, key, table)
   if table then
     for _, v in pairs(dest) do
       v[key] = {}
     end
   end
-  B[key] = setmetatable({}, {
+  V[key] = setmetatable({}, {
     __index = function(t, k)
       return dest[k][key]
     end,
@@ -126,26 +138,21 @@
   })
 
 
-  return B[key]
+  return V[key]
 end
 
 
---- localize for speed
-
+--- internal
 local ModulesCall = function(func, flag)
-
   local n = 0
   for i = 1, #moduleStack do
     print('calling level '..i)
     local stackset = moduleStack[i]
-
     for name, module in pairs(stackset) do
       n = n + 1
-
-
       if module[func] then
         -- nil = pass
-        if not flag or module.Conf[flag] then
+        if not flag or (module.Conf and module.Conf[flag]) then
           if (flag) then
             print('  check', flag, '=', module.Conf[flag])
           end
@@ -153,7 +160,6 @@
           print(' ',n..'  '..name..'.'..func..'()')
           module[func](module, module.Conf)
         end
-
       end
     end
   end
@@ -168,7 +174,7 @@
 end
 
 
-local layers, refs, displays = B.configLayers, B.configLayersRef, B.displays
+local layers, refs, displays = V.configLayers, V.configLayersRef, V.displays
 --- Things that happen immediately upon entering world
 local InitOnce = function()
   print('entering world first time')
@@ -181,7 +187,7 @@
     end
     print('Veneer defaults being used.')
   end
-  B.Conf = setmetatable(VeneerData, {__index = function(_, k) return defaults[k] end})
+  V.Conf = setmetatable(VeneerData, {__index = function(_, k) return defaults[k] end})
 
   -- To ensure that modules are run in controlled order, walk the dependency list; if the dep shows up
   -- in the loaded manifest, remove the value. If the dep list isn't empty, move that module to the next
@@ -267,8 +273,8 @@
   if #checkForConfig >= 1 then
     local queuedFrame = tremove(checkForConfig)
     while queuedFrame do
-      B.SetConfigLayers(queuedFrame)
-      B.UpdateXMLFrame(queuedFrame)
+      V.SetConfigLayers(queuedFrame)
+      V.UpdateXMLFrame(queuedFrame)
       queuedFrame = tremove(checkForConfig)
     end
   end
@@ -276,13 +282,13 @@
 
 --- Fires an update to all modules
 local lastUpdate
-function B.UpdateAll(...)
+function V.UpdateAll(...)
   lastUpdate = GetTime()
   ModulesCall('OnUpdate')
 end
 
-B:RegisterEvent('PLAYER_ENTERING_WORLD')
-B:SetScript('OnEvent', function(self, event)
+V:RegisterEvent('PLAYER_ENTERING_WORLD')
+V:SetScript('OnEvent', function(self, event)
   if event == 'PLAYER_ENTERING_WORLD' then
     if not initOnced then
       InitOnce()
@@ -293,23 +299,23 @@
           print(GetSpecialization(), 'enabling')
 
           ModulesCall('OnEnable', 'enabled')
-          B:SetScript('OnUpdate', nil)
+          V:SetScript('OnUpdate', nil)
         end
       end)
     end
   end
 
-  B.UpdateAll()
+  V.UpdateAll()
 
   if event == 'PLAYER_ENTERING_WORLD' then
-    B.UpdateConfigLayers()
+    V.UpdateConfigLayers()
   end
 
 end)
 
 --- Modulizer method
 --
-function B:RegisterModule (name, module, ...)
+function V:RegisterModule (name, module, ...)
   if modules[name] then
     print('pulling modules[|cFFFF8800'.. tostring(name) ..'|r]')
     return modules[name]
@@ -321,10 +327,10 @@
       error("Module table for '"..tostring(name).."' already exists.")
     end
   else
-    module = CreateFrame('Frame', 'Veneer' .. tostring(name) .. 'Handler', B, 'VeneerHandlerTemplate')
+    module = CreateFrame('Frame', 'Veneer' .. tostring(name) .. 'Handler', V, 'VeneerHandlerTemplate')
   end
   modules[name] = module
-  B[name] = module
+  V[name] = module
   if select('#', ...) >= 1 then
     local numDeps = select('#', ...)
     print('  '..numDeps..' deps detected')
@@ -340,8 +346,8 @@
 end
 
 
-B.SetConfigLayers =  function(frame)
-  local print = B.fprint()
+V.SetConfigLayers =  function(frame)
+  local print = V.fprint()
   if not frame.config then
     --print(frame:GetName(), 'has no config layers')
     return
@@ -359,9 +365,9 @@
   end
 end
 
-B.RemoveConfigLayers = function(frame)
+V.RemoveConfigLayers = function(frame)
 
-  local print = B.fprint()
+  local print = V.fprint()
   print('|cFFFF0000RemoveConfigLayers', frame:GetName())
   for i, subframe in pairs(layers) do
     if subframe:GetParent() == frame then
@@ -373,9 +379,9 @@
   end
 end
 
-B.ToggleGuideLayers = function()
-  local print = B.fprint()
-  local func = B.Conf.GuidesMode and 'Show' or 'Hide'
+V.ToggleGuideLayers = function()
+  local print = V.fprint()
+  local func = V.Conf.GuidesMode and 'Show' or 'Hide'
   local numAnchors = 0
 
   for id, region in pairs(layers) do
@@ -385,17 +391,17 @@
 
   --print('['..func..'] updated', #layers, 'regions,', numAnchors, 'frames')
 end
-B.UpdateConfigLayers = function()
+V.UpdateConfigLayers = function()
   print('|cFFFF0000', debugstack())
-  B.ToggleGuideLayers()
+  V.ToggleGuideLayers()
 end
 
 local XMLFrame_Enable = function(self, value)
   local name = self:GetName()
-  local print = B.print('XML')
+  local print = V.print('XML')
 
-  if not B.Conf[name] then
-    B.Conf[name] = {
+  if not V.Conf[name] then
+    V.Conf[name] = {
       enabled = true
     }
   end
@@ -403,12 +409,12 @@
   print()
   local enabled
   if value == nil then
-    if B.Conf[name].enabled == nil then
+    if V.Conf[name].enabled == nil then
       print('toggle based on visibility')
       enabled = (not self:IsVisible()) and true or false
     else
-      print('toggle a config value =', B.Conf[name].enabled)
-      enabled = B.Conf[name].enabled
+      print('toggle a config value =', V.Conf[name].enabled)
+      enabled = V.Conf[name].enabled
     end
 
     enabled = (enabled ~= true) and true or false
@@ -417,9 +423,9 @@
       enabled = value
   end
 
-  print('arg =', value, 'conf =', B.Conf[name].enabled, 'result=', enabled)
+  print('arg =', value, 'conf =', V.Conf[name].enabled, 'result=', enabled)
 
-  B.Conf[name].enabled = enabled
+  V.Conf[name].enabled = enabled
 
   local stateFunc = enabled and 'Show' or 'Hide'
   local eventFunc = enabled and 'OnToggle' or 'OnToggle'
@@ -431,10 +437,10 @@
   end
   --- toggle action
   if self.OnToggle then
-    self:OnToggle(B.Conf[name].enabled)
+    self:OnToggle(V.Conf[name].enabled)
   end
   --- do enable
-  if B.Conf[name].enabled then
+  if V.Conf[name].enabled then
     if self.OnEnable then
       self:OnEnable()
     end
@@ -445,10 +451,9 @@
   end
 end
 --- Generic handlers for keeping track of XML-defined frames
-local print = B.print('XML')
-B.prototypes = {}
-B.prototypes.OnDragStart = function(self)
-  local print = B.print('XML')
+local print = V.print('XML')
+local prototypes = {}
+prototypes.OnDragStart = function(self)
   self.xA = self:GetLeft()
   self.yA = self:GetBottom()
   self.anchorTo, self.relativeTo, self.relativePoint, self.x, self.y = self:GetPoint(1)
@@ -457,36 +462,33 @@
   self:StartMoving()
 end
 
-B.prototypes.OnDragStop = function(self)
-  local print = B.print('XML')
+prototypes.OnDragStop = function(self)
   local name = self:GetName()
   print(name, 'stop moving ('..self:GetLeft()..', '..self:GetBottom()..')')
   local xB = self:GetLeft() - self.xA
   local yB = self:GetBottom() - self.yA
   print('storing anchor point', self.anchorTo, self.relativePoint, self.x + xB, self.y + yB)
-
   self:StopMovingOrSizing()
-  B.Conf[name].position = {self.anchorTo, self.relativePoint, self.x + xB, self.y + yB}
-  B.UpdateXMLFrame(self)
+  V.Conf[name].position = {self.anchorTo, self.relativePoint, self.x + xB, self.y + yB}
+  V.UpdateXMLFrame(self)
 end
 
 
-B.RegisterModuleFrame = function(self, moduleName)
-  local print = B.print('XML')
+V.RegisterModuleFrame = function(self, moduleName)
   local name = self:GetName()
   tinsert(checkForConfig, self)
   self.Enable = XMLFrame_Enable
   self.moduleName = moduleName
   print('|cFF00FF00XML stuff related to '.. tostring(moduleName) .. ':', self:GetName())
   ------------------------------------------------------------------------------------------
-  if not B[name] then
+  if not V[name] then
     return
   end
 
   local scriptTypes = {'OnUpdate', 'OnEvent', 'OnDragStart', 'OnDragStop'}
   for script in next(scriptTypes) do
-    if B[name][script] then
-      self:SetScript(script, B[name][script])
+    if V[name][script] then
+      self:SetScript(script, V[name][script])
     end
   end
 
@@ -494,34 +496,34 @@
 local XMLFrame_OnDragStart = function() end
 local XMLFrame_OnDragStop = function() end
 
-B.UpdateXMLFrame = function(self)
-  local print = B.print('XML')
+V.UpdateXMLFrame = function(self)
+  local print = V.print('XML')
 
   local name = self:GetName()
 
 
   if self.drag then
     self:RegisterForDrag('LeftButton')
-    self:SetScript('OnDragStart', XMLFrame_OnDragStart)
+    self:SetScript('OnDragStart', prototypes.OnDragStart)
     if self.OnDragStop then
       self:SetScript('OnDragStop', function(self, ...)
         print('|cFFFF0088end of dragging')
         self:OnDragStop(self, ...)
-        XMLFrame_OnDragStop(self, ...)
+        prototypes.OnDragStop(self, ...)
       end)
     else
-      self:SetScript('OnDragStop', XMLFrame_OnDragStop)
+      self:SetScript('OnDragStop', prototypes.OnDragStop)
     end
   else
     self:EnableMouse(false)
   end
 
-  if not B.Conf[name] then
-    B.Conf[name] = {
+  if not V.Conf[name] then
+    V.Conf[name] = {
       enabled = self.enabled,
     }
   end
-  local c = B.Conf[name]
+  local c = V.Conf[name]
 
   if not c.position then
     local anchor, _, point, x, y = self:GetPoint(1)