changeset 125:3f4794dca91b

template load order and Script handlers linkage
author Nenue
date Sun, 15 Oct 2017 16:47:22 -0400
parents 07fe8fae8ca8
children 3de635cda288
files Init.lua Modules/ArtifactPower.lua Modules/ArtifactPower.xml Modules/Bank.lua Modules/Currency.lua Modules/Currency.xml Modules/WorldState.lua Templates.lua Templates.xml Veneer.lua Veneer.toc Veneer.xml
diffstat 12 files changed, 164 insertions(+), 92 deletions(-) [+]
line wrap: on
line diff
--- a/Init.lua	Tue Sep 05 02:57:08 2017 -0400
+++ b/Init.lua	Sun Oct 15 16:47:22 2017 -0400
@@ -1,3 +1,5 @@
 -- things to override for sanity
+local _, addon = ...
 SLASH_RELOADUI1 = "/rl"
-SlashCmdList["RELOADUI"] = ReloadUI
\ No newline at end of file
+SlashCmdList["RELOADUI"] = ReloadUI
+addon.ConfigMode = false
\ No newline at end of file
--- a/Modules/ArtifactPower.lua	Tue Sep 05 02:57:08 2017 -0400
+++ b/Modules/ArtifactPower.lua	Sun Oct 15 16:47:22 2017 -0400
@@ -315,11 +315,11 @@
 
 function Module:TryToShow()
 
-  print('|cFFFFFF00TryToShow()')
+  --print('|cFFFFFF00TryToShow()')
 
   if not InCombatLockdown() then
     for _, name in ipairs(FRAME_LIST) do
-      print('test:', name, (_G[name] and _G[name]:IsShown()))
+      --print('test:', name, (_G[name] and _G[name]:IsShown()))
       if _G[name] and _G[name]:IsVisible() then
         if self:IsShown() then
           self:Update()
@@ -331,13 +331,13 @@
     end
   end
 
-  print('failed tests')
+  --print('failed tests')
   self:Hide()
 end
 
 
 function Module:OnEvent(event, ...)
-  print('|cFF00FF88OnEvent()', event, ...)
+  --print('|cFF00FF88OnEvent()', event, ...)
   if event == 'PLAYER_ENTERING_WORLD' then
     self:TryToShow()
   elseif event == 'BAG_UPDATE' then
@@ -376,10 +376,12 @@
       self:UpdateArtifact(itemID, name, texture, currentXP, pointsSpent)
       --self:ScanAllBags(self.bankAccess)
     end
+    self:UpdateArtifactButtons()
   elseif event == 'ARTIFACT_XP_UPDATE' then
     local itemID, _, name, texture, currentXP, pointsSpent = C_ArtifactUI:GetEquippedArtifactInfo()
     self:UpdateArtifact(itemID, name, texture, currentXP, pointsSpent)
     --self:ScanAllBags(self.bankAccess)
+    self:UpdateArtifactButtons()
   elseif event == 'PLAYER_REGEN_ENABLED' then
 
     if self.queuedScan then
@@ -559,8 +561,10 @@
     numButtons = numButtons + 1
     button = self.Artifact[numButtons]
     button.relativeFrame = self
+    button:SetItem(self.equippedID, equipped, numButtons, true, nil)
+
     if self.equippedID ~= button.itemID then
-      button:SetItem(self.equippedID, equipped, numButtons, true, nil)
+
       hasArtifacts = true
     end
     lastFrame = button
@@ -589,9 +593,7 @@
           numButtons = numButtons + 1
           button = self.Artifact[numButtons]
           button.relativeFrame = lastFrame
-          if button.itemID ~= itemID then
-            button:SetItem(itemID, artifact, numButtons, (self.equippedID == itemID), nil)
-          end
+          button:SetItem(itemID, artifact, numButtons, (self.equippedID == itemID), nil)
           lastFrame = button
           buttonsWidth = buttonsWidth + lastFrame:GetWidth() + FRAME_PADDING
         end
@@ -791,7 +793,6 @@
   local artifacts = self.profile.artifacts
 
   if itemID then
-    self.currentEquipped = itemID
 
     artifacts[itemID] = artifacts[itemID] or {}
     table.wipe(artifacts[itemID])
@@ -807,14 +808,10 @@
     print('tier', artifact.tier)
     local cost = C_ArtifactUI.GetCostForPointAtRank(pointsSpent, artifact.tier)
     artifact.currentCost = cost
+  end
 
-    for index, frame in pairs(self.Artifact) do
-      if frame.itemID == itemID then
-        frame:SetItem(itemID, artifact, index, (itemID == self.equippedID), (itemID == UNDERLIGHT_ANGLER_ID))
-      end
-    end
-
-  end
+  local equippedID = C_ArtifactUI:GetEquippedArtifactInfo()
+  self.currentEquipped = equippedID
 end
 
 function Module:ScanBag(id)
@@ -920,6 +917,8 @@
     end
   end
 
+
+
   self.bankAP = 0
   self.bagAP = 0
   self.fishingAP = 0
@@ -1027,7 +1026,7 @@
   self.itemID = itemID
   self.isEquipped = equipped
   self:Update()
-  self:Show()
+  self:SetShown(true)
 
   return self
 end
@@ -1095,16 +1094,6 @@
 
 function Artifact:OnLoad()
   print('|cFFFF4400OnLoad()|r', self:GetName(), self:GetID())
-  self:RegisterEvent('ARTIFACT_UPDATE')
-  self:RegisterEvent('PLAYER_LOGIN')
-end
-
-function Artifact:OnEvent(event)
-  local itemID, _, _, nextCost = C_ArtifactUI.GetEquippedArtifactInfo()
-  print(self:GetID(), '|cFFFF4400OnEvent()|r', event, itemID, '=', self.itemID, (itemID == self.itemID))
-  if itemID == self.itemID then
-    self:Update()
-  end
 end
 
 function Artifact:Update()
@@ -1112,7 +1101,7 @@
     return
   end
 
-  print(self:GetName(), '|ff00FFFFUpdate()|r')
+  print(self:GetName(), '|cff00FFFFUpdate()|r')
   local r1, g1, b1 = 1, 1, 1  -- top text
   local r2, g2, b2 = 1, 1, 0  -- bottom text
   local levelText = self.level
--- a/Modules/ArtifactPower.xml	Tue Sep 05 02:57:08 2017 -0400
+++ b/Modules/ArtifactPower.xml	Sun Oct 15 16:47:22 2017 -0400
@@ -25,6 +25,8 @@
 
   <Button name="VeneerArtifactButton" parentArray="Artifact" mixin="VeneerArtifactButtonMixin" virtual="true">
     <Scripts>
+      <OnShow method="OnShow" />
+      <OnHide method="OnHide" />
       <OnLoad method="OnLoad" />
       <OnEvent method="OnEvent" />
       <OnEnter method="OnEnter" />
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Modules/Bank.lua	Sun Oct 15 16:47:22 2017 -0400
@@ -0,0 +1,37 @@
+--
+-- Background data gathering for things that are only available from set places
+
+
+local print = DEVIAN_WORKSPACE and function(...) print('Bank', ...) end or nop
+local profileUpdate, needsUpdate
+VeneerBankDBMixin = {}
+local m = VeneerBankDBMixin
+
+function m:Setup()
+  self:RegisterEvent('BANKFRAME_OPENED')
+  self:RegisterEvent('BANKFRAME_CLOSED')
+
+  self:SetPoint('CENTER', UIParent, 'CENTER')
+  self:SetSize(100,100)
+  m.Info:SetPoint('CENTER', self, 'CENTER')
+
+  self:Show()
+  print('Setup()')
+
+
+  self.Info:SetFontObject(GameFontNormal)
+  self.Info:SetText('Setup')
+
+  for k,v in pairs(self) do
+    print(k,v)
+  end
+end
+
+function m:OnEvent(event)
+  print('OnEvent', event)
+  self.Info:SetText(event)
+end
+
+
+
+
--- a/Modules/Currency.lua	Tue Sep 05 02:57:08 2017 -0400
+++ b/Modules/Currency.lua	Sun Oct 15 16:47:22 2017 -0400
@@ -6,7 +6,7 @@
 -- To change this template use File | Settings | File Templates.
 --
 
-local print = DEVIAN_WORKSPACE and function(...) print('VnWorldState', ...) end or nop
+local print = DEVIAN_WORKSPACE and function(...) print('Currency', ...) end or nop
 local profileUpdate, needsUpdate
 
 
@@ -30,11 +30,6 @@
     showMax = true,
     zones = {
       ['Suramar'] = true,
-      ["Sashj'tar Ruins"] = true,
-      ["Faronaar Ruins"] = true,
-      ["Halls of the Eclipse"] = true,
-      ["Shal'aran"] = true,
-      ["The Fel Breach"] = true,
     },
   },
   ["Blood of Sargeras"] = {
@@ -42,16 +37,24 @@
   },
   ["Legionfall War Supplies"] = {
     currencyID = 1342,
+    zones = {
+      ["The Broken Shore"] = true
+    }
   },
   ["Nethershard"] = {
     currencyID = 1226,
+    zones = {
+      ["The Broken Shore"] = true
+    }
   },
   ["Veiled Argunite"] = {
     currencyID = 1508,
+    zones = {
+      ["Antoran Wastes"] = true,
+      ["Krokuun"] = true,
+      ["MacAree"] = true,
+    }
   },
-  ["Argus Waystone"] = {
-    currencyID = 1506,
-  }
 }
 local items, currencies = {}, {}
 
@@ -77,49 +80,52 @@
   end
 end
 
+function module:Setup()
+  self:Update()
+end
+
 function module:OnLoad ()
   Veneer:AddHandler(self)
 
   for name, info in pairs(blocks) do
-    local frame = CreateFrame('Frame', nil, self, 'VeneerCurrencyTemplate')
-    frame.name = name
+    local block = CreateFrame('Frame', nil, self, 'VeneerCurrencyTemplate')
+    block.name = name
     for k,v in pairs(info) do
       print(name, k, '=', v)
-      frame[k] = v
+      block[k] = v
     end
 
-    frame.debug = function(...)
-      print('|cFF0088FF<'..frame.name..'>|r', ...)
+    block.debug = function(...)
+      print('|cFF0088FF<'..block.name..'>|r', ...)
     end
-    frame.id = info.itemID or info.currencyID
+    block.id = info.itemID or info.currencyID
 
 
     if info.itemID then
       local itemID = info.itemID
       items[itemID] = {
         count = 0,
-        frame = frame
+        frame = block
       }
-      frame.Update = itemBlock.Update
+      block.Update = itemBlock.Update
       RegisterEvents(self, itemEvents)
     elseif info.currencyID then
       local currencyID = info.currencyID
-      frame.Update = currencyBlock.Update
-      RegisterEvents(frame, currencyEvents)
+      block.Update = currencyBlock.Update
+      RegisterEvents(block, currencyEvents)
     end
 
 
 
     if info.zones then
-      RegisterEvents(frame, zoneEvents)
+      RegisterEvents(block, zoneEvents)
       local zones = info.zones
-      local of = frame.Update
-      frame.Update = function(block)
-        frame.debug('Update [Zone]')
-        local zone = self.zoneText
-        local canShow = (zone and block.zones[zone]) and true or false
+      local of = block.Update
+      function block:Update(zone, subZone)
+        block.debug('Update [Zone]', zone, subZone)
+        local canShow = ((zone and self.zones[zone]) or (subZone and self.zones[subZone])) and true or false
         if of then
-          canShow = canShow and of(frame)
+          canShow = canShow and of(self)
         end
         return canShow
       end
@@ -144,7 +150,8 @@
   for itemID in pairs(items) do
     items[itemID].count = 0
   end
-  self.zoneText = GetRealZoneText()
+  self.realZoneText = GetRealZoneText()
+  self.subZoneText = GetSubZoneText()
   local canShow = false
 
   for i = 0, NUM_BAG_SLOTS do
@@ -168,12 +175,12 @@
   local lastBlock
   local totalWidth = 0
   for _, block in ipairs(self.Blocks) do
-    local blockIsShown = block:Update() or false
+    local blockIsShown = block:Update(self.realZoneText, self.subZoneText) or false
     block:SetShown(blockIsShown)
     canShow = canShow or blockIsShown
 
 
-    if block:IsShown() then
+    if blockIsShown then
       block:ClearAllPoints()
       if lastBlock then
         block:SetPoint('TOPLEFT', lastBlock, 'TOPRIGHT')
@@ -212,7 +219,7 @@
 
 function module:OnUpdate()
   if needsUpdate then
-    self:Update()
+    self:Update(GetRealZoneText(), GetSubZoneText())
   elseif profileUpdate then
     self:UpdateProfile()
   end
@@ -238,23 +245,25 @@
 
 function block:OnEvent(event, ...)
   print('|cFF0088FF<'..self.name..'>|r', 'OnEvent', event, ...)
-  self:Update()
+
+  self:Update(GetRealZoneText(), GetSubZoneText())
 end
 
 function block:Setup()
 
 end
-function itemBlock:Update()
-  self.debug('Update [Item]')
+function itemBlock:Update(zone, subZone)
+  self.debug('Update [Item]', zone, subZone)
   if items[self.itemID].count >= 1 then
     self.Icon:SetTexture(GetItemIcon(self.id))
     self.Label:SetFormattedText("%d", items[self.id].count)
     return true
   end
+  return false
 end
 
-function currencyBlock:Update()
-  self.debug('Update [Currency]')
+function currencyBlock:Update(zone, subZone)
+  self.debug('Update [Currency]', zone, subZone)
   local name, earned, texture, earnedThisWeek, weeklyMax, totalMax = GetCurrencyInfo(self.id)
 
   self.Icon:SetTexture(texture)
--- a/Modules/Currency.xml	Tue Sep 05 02:57:08 2017 -0400
+++ b/Modules/Currency.xml	Sun Oct 15 16:47:22 2017 -0400
@@ -1,6 +1,23 @@
 <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 parent="UIParent" name="VeneerBankDB" parentArray="modules" mixin="VeneerBankDBMixin" hidden="false" inherits="VeneerHandlerTemplate">
+        <Size x="240" y="24" />
+        <Anchors>
+            <Anchor point="CENTER" />
+        </Anchors>
+        <Layers>
+            <Layer level="OVERLAY">
+                <FontString parentArray="ConfigLayer" parentKey="Info" inherits="GameFontNormal" hidden="true">
+                    <Anchors>
+                        <Anchor point="CENTER" />
+                    </Anchors>
+                </FontString>
+            </Layer>
+        </Layers>
+    </Frame>
+
     <Script file="Currency.lua" />
     <Frame virtual="true" name="VeneerCurrencyTemplate" parentArray="Blocks" mixin="VeneerCurrencyBlockMixin" hidden="true">
         <Scripts>
@@ -15,7 +32,7 @@
         <Layers>
             <Layer level="BACKGROUND">
                 <Texture setAllPoints="true" parentKey="Background">
-                    <Color a="0.5" r="0" g="0" b="0" />
+                    <Color a="0" r="0" g="0" b="0" />
                 </Texture>
             </Layer>
             <Layer level="ARTWORK">
--- a/Modules/WorldState.lua	Tue Sep 05 02:57:08 2017 -0400
+++ b/Modules/WorldState.lua	Sun Oct 15 16:47:22 2017 -0400
@@ -3,7 +3,8 @@
 -- Created: 10/7/2016 10:55 PM
 -- %file-revision%
 -- An extensible panel group for HUD values
-
+local _, vn = ...
+local L = vn.L
 local print = DEVIAN_WORKSPACE and function(...) print('VnWorldState', ...) end or nop
 
 VeneerOrderHallMixin = {
@@ -84,7 +85,7 @@
 end
 
 function VeneerOrderHallMixin:Update()
-  self:SetShown(C_Garrison.IsPlayerInGarrison(LE_GARRISON_TYPE_7_0))
+  self:SetShown(C_Garrison.IsPlayerInGarrison(LE_GARRISON_TYPE_7_0) or (GetSubZoneText() == L["The Vindicaar"]))
   local lastFrame
   local categoriesWidth = 0
   local troops = OrderHallCommandBar.TroopSummary
--- a/Templates.lua	Tue Sep 05 02:57:08 2017 -0400
+++ b/Templates.lua	Sun Oct 15 16:47:22 2017 -0400
@@ -4,8 +4,8 @@
 -- %file-revision%
 --
 -- Mover Widget base
-local ADDON, Veneer = ...
-local print = DEVIAN_WORKSPACE and function(...) _G.print('Veneer', ...) end or nop
+local ADDON, addon = ...
+local print = DEVIAN_WORKSPACE and function(...) _G.print('VnTpl', ...) end or nop
 local PlaySoundKitID = DEVIAN_WORKSPACE and PlaySoundKitID or nop
 local ipairs, pairs = ipairs, pairs
 local pack, unpack = pack, unpack
@@ -18,9 +18,9 @@
 Handler.anchorPoint = 'CENTER'
 Handler.anchorPriority = 4
 Handler.data = {}
-Veneer.HandlerBase = Handler
-Veneer.ConfigLayerBase = ConfigLayer
-Veneer.AnimationBase = Animation
+addon.HandlerBase = Handler
+addon.ConfigLayerBase = ConfigLayer
+addon.AnimationBase = Animation
 
 local ANCHOR_BUTTON_TYPES = {
   'TOPLEFT', 'TOP', 'TOPRIGHT', 'RIGHT', 'LEFT', 'CENTER', 'BOTTOMLEFT', 'BOTTOM', 'BOTTOMRIGHT'
@@ -28,10 +28,10 @@
 
 function ConfigLayer:OnLoad()
   local handler = self:GetParent()
-  print(handler:GetName(), 'configLayers')
+  print(handler:GetName(), '-> ConfigLayer loaded', addon.ConfigMode)
   handler.ConfigLayers = handler.ConfigLayers or {}
   for i, region in ipairs(handler.ConfigLayers) do
-    region:SetShown(Veneer.ConfigMode)
+    region:SetShown(addon.ConfigMode)
   end
   self.handler = handler
 end
@@ -144,10 +144,19 @@
   print('|cFF00FF00Anim:OnFinish|r @', unpack(self.destPoint))
 end
 
+
+function Handler:OnLoad()
+  print(self:GetName(), 'loaded')
+  self.debug = DEVIAN_WORKSPACE and function(...) _G.print(self:GetName(), ...) end or nop
+  self.debug('OnLoad() template')
+end
+
 -- Replace if module requires anything besides fixing frame anchors
+
+
 function Handler:OnShow()
   self:Reanchor()
-  _G.Veneer:StaticReanchor(self)
+  _G.Veneer:DynamicReanchor()
 end
 function Handler:OnHide()
   _G.Veneer:DynamicReanchor()
--- a/Templates.xml	Tue Sep 05 02:57:08 2017 -0400
+++ b/Templates.xml	Sun Oct 15 16:47:22 2017 -0400
@@ -148,7 +148,7 @@
     </Layers>
   </Frame>
 
-  <Frame name="VeneerHandlerTemplate" inherits="VeneerAnimations" hidden="true" parent="UIParent" virtual="true">
+  <Frame name="VeneerHandlerTemplate" inherits="VeneerAnimations" mixin="VeneerHandlerMixin" hidden="true" parent="UIParent" virtual="true">
     <Scripts>
       <OnLoad method="OnLoad" />
       <OnEvent method="OnEvent" />
@@ -163,7 +163,7 @@
       </Layer>
     </Layers>
     <Frames>
-      <Frame name="$parentConfigHandler" setAllPoints="true" mixin="VeneerConfigLayerMixin" enableMouse="true" parentArray="ConfigLayer">
+      <Frame name="$parentConfigHandler" hidden="true" setAllPoints="true" mixin="VeneerConfigLayerMixin" enableMouse="true" parentArray="ConfigLayer">
         <Scripts>
           <OnLoad method="OnLoad" />
           <OnShow method="OnShow" />
--- a/Veneer.lua	Tue Sep 05 02:57:08 2017 -0400
+++ b/Veneer.lua	Sun Oct 15 16:47:22 2017 -0400
@@ -15,18 +15,22 @@
 VeneerCore = {}
 local Veneer = VeneerCore
 
+
 SLASH_VENEER1 = "/veneer"
 SLASH_VENEER2 = "/vn"
 SlashCmdList.VENEER = function(cmd)
-  _G.Veneer:print(_G.Veneer.ConfigMode)
-  if _G.Veneer.ConfigMode == true then
-    _G.Veneer.ConfigMode = false
+  _G.Veneer:print(addon.ConfigMode)
+  if addon.ConfigMode == true then
+    addon.ConfigMode = false
   else
-    _G.Veneer.ConfigMode = true
+    addon.ConfigMode = true
   end
   _G.Veneer:UpdateConfigLayers()
 end
 
+addon.L = setmetatable({}, {
+  __index = function(k) return k end
+})
 
 Veneer.modules = {}
 Veneer.Frames = {}
@@ -188,8 +192,8 @@
   self.data = VeneerData
   self:ExecuteOnClusters(nil, VeneerModule_Setup)
 
-  self.ConfigMode = VeneerData.ConfigMode
-  print('|cFF00FF88configMode =', self.ConfigMode)
+  addon.ConfigMode = VeneerData.ConfigMode
+  print('|cFF00FF88configMode =', addon.ConfigMode)
   self:UpdateConfigLayers()
   self:Reanchor()
   self:Update()
@@ -197,28 +201,28 @@
 
 function Veneer:UpdateConfigLayers()
   if VeneerData then
-    VeneerData.ConfigMode = self.ConfigMode
+    VeneerData.ConfigMode = addon.ConfigMode
   end
 
-  self:print('Config mode '..(self.ConfigMode and '|cFF00FF00ON|r' or '|cFFFF0000OFF|r')..'. ', tostring(self.ConfigMode))
+  self:print('Config mode '..(addon.ConfigMode and '|cFF00FF00ON|r' or '|cFFFF0000OFF|r')..'. ', tostring(addon.ConfigMode))
   self:ExecuteOnClusters(nil, function(frame)
     if frame.UpdateConfigLayers then
-      frame:UpdateConfigLayers(self.ConfigMode)
+      frame:UpdateConfigLayers(addon.ConfigMode)
     end
 
 
     if type(frame.ConfigLayer) == 'table' then
       for index, region in ipairs(frame.ConfigLayer) do
-        print('setting', frame:GetName() .. '['.. index..']', 'to', self.ConfigMode)
+        print('setting', frame:GetName() .. '['.. index..']', 'to', addon.ConfigMode)
 
-        region:SetShown(self.ConfigMode)
+        region:SetShown(addon.ConfigMode)
       end
     end
 
     self.ConfigLayers[frame] = frame:IsShown()
-    if self.ConfigMode then
+    if addon.ConfigMode then
       print(frame:GetName(), self.ConfigLayers[frame])
-      frame:SetShown(self.ConfigMode)
+      frame:SetShown(addon.ConfigMode)
     else
       frame:SetShown(self.ConfigLayers[frame])
     end
--- a/Veneer.toc	Tue Sep 05 02:57:08 2017 -0400
+++ b/Veneer.toc	Sun Oct 15 16:47:22 2017 -0400
@@ -1,8 +1,8 @@
-## Interface: 70200
+## Interface: 70300
 ## Title: Veneer
 ## Notes: Collection of interface enhancements that make life easier
 ## Author: Krakyn
-## Version: 1.0-@project-revision@
+## Version: 7.3.0
 ## SavedVariables: VeneerData
 ## X-Category: Interface Enhancements
 ## DefaultState: Enabled
@@ -13,6 +13,7 @@
 Veneer.xml
 ##Options.lua
 
+Modules\Bank.lua
 Modules\WorldState.xml
 Modules\Currency.xml
 Modules\TalkingHead.xml
--- a/Veneer.xml	Tue Sep 05 02:57:08 2017 -0400
+++ b/Veneer.xml	Sun Oct 15 16:47:22 2017 -0400
@@ -80,4 +80,5 @@
   </Frame>
 
 
+
 </Ui>
\ No newline at end of file