Mercurial > wow > buffalo2
changeset 113:2105b6e5095f
- Added Blood of Sargeras to currency list
- Fixed panel ordering issues when a module is loaded on the fly.
author | Nick@Zahhak |
---|---|
date | Sun, 26 Mar 2017 06:25:18 -0400 |
parents | 7c77fde36287 |
children | 6748c98a6c6c |
files | Modules/Currency.lua Modules/Currency.xml Modules/WorldState.lua Modules/WorldState.xml Veneer.lua Veneer.toc |
diffstat | 6 files changed, 331 insertions(+), 398 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/Currency.lua Sun Mar 26 06:25:18 2017 -0400 @@ -0,0 +1,196 @@ +-- +-- Created by IntelliJ IDEA. +-- User: Nick +-- Date: 3/25/2017 +-- Time: 7:07 PM +-- To change this template use File | Settings | File Templates. +-- + +local print = DEVIAN_WORKSPACE and function(...) print('VnWorldState', ...) end or nop + +local zoneEvents = { + "ZONE_CHANGED_NEW_AREA", "ZONE_CHANGED_INDOORS", "ZONE_CHANGED" +} +local currencyEvents = { + 'CURRENCY_DISPLAY_UPDATE', 'CHAT_MSG_CURRENCY' +} +local itemEvents = { + 'CHAT_MSG_LOOT', 'BAG_UPDATE' +} + +local blocks = { + ["Ancient Mana"] = { + currencyID = 1155, + zones = { + ['Suramar'] = true, + ["Sashj'tar Ruins"] = true, + ["Faronaar Ruins"] = true + } + }, + ["Blood of Sargeras"] = { + itemID = 124124, + } +} +local items = {} + + +VeneerWorldStateCurrencyMixin = { Blocks = {} } +VeneerWorldStateCurrencyBlockMixin = {} +local module = VeneerWorldStateCurrencyMixin +local block = VeneerWorldStateCurrencyBlockMixin + + + +local function RegisterEvents (frame, events) + for _, event in ipairs(events) do + print('|cFFFF0088'..(frame.name or frame:GetName())..'|r', 'listening to', event) + frame:RegisterEvent(event) + end +end + +function module:OnLoad () + self:RegisterEvent("PLAYER_ENTERING_WORLD"); + self:RegisterEvent('PLAYER_REGEN_ENABLED') + self:RegisterEvent('PLAYER_REGEN_DISABLED') + + for name, info in pairs(blocks) do + local frame = CreateFrame('Frame', nil, self, 'VeneerCurrencyTemplate') + frame.name = name + for k,v in pairs(info) do + print(name, k, '=', v) + frame[k] = v + end + + local debug = function(...) + print('|cFF0088FF<'..frame.name..'>|r', ...) + end + + if info.itemID then + local itemID = info.itemID + items[itemID] = { + count = 0, + frame = frame + } + frame.Update = function(block) + debug('Update [Item]') + if items[itemID].count >= 1 then + block.Icon:SetTexture(GetItemIcon(itemID)) + block.Label:SetFormattedText("%d", items[itemID].count) + return true + end + end + RegisterEvents(self, itemEvents) + elseif info.currencyID then + local currencyID = info.currencyID + frame.Update = function (block) + debug('Update [Currency]') + local name, earned, texture, earnedThisWeek, weeklyMax, totalMax = GetCurrencyInfo(currencyID) + block.Icon:SetTexture(texture) + block.Label:SetFormattedText("%d / %d", earned, totalMax) + block:SetWidth(block.Icon:GetWidth() + block.Label:GetStringWidth() + 6) + return true + end + + RegisterEvents(frame, currencyEvents) + end + if info.zones then + RegisterEvents(frame, zoneEvents) + local zones = info.zones + local of = frame.Update + frame.Update = function(block) + debug('Update [Zone]') + local zone = self.zoneText + local canShow = (zone and block.zones[zone]) and true or false + if of then + canShow = canShow and of(frame) + end + return canShow + end + end + end +end + +function module:OnEvent (event, arg) + print(self:GetName(), 'OnEvent', event, arg) + self:Update() +end +local toUpdate = {} +local wipe = table.wipe +function module:Update(isBatchUpdate) + print(self:GetName(), 'Update()') + if InCombatLockdown() then + self:SetShown(false) + return + end + + + for itemID in pairs(items) do + items[itemID].count = 0 + end + self.zoneText = GetRealZoneText() + local canShow = false + + for i = 0, NUM_BAG_SLOTS do + local numSlots = GetContainerNumSlots(i) + for j = 1, numSlots do + local itemID = GetContainerItemID(i, j) + local texture, count = GetContainerItemInfo(i,j) + if items[itemID] then + items[itemID].count = items[itemID].count + (count or 1) + items[itemID].texture = texture + print('tracked currency tally', items[itemID].count, '|T'..texture..':16:16|t') + items[itemID].frame.Icon:SetTexture(texture) + end + end + end + + for itemID, info in pairs(items) do + end + + local lastBlock + local totalWidth = 0 + for _, block in ipairs(self.Blocks) do + local blockIsShown = block:Update() or false + block:SetShown(blockIsShown) + canShow = canShow or blockIsShown + + + if block:IsShown() then + block:ClearAllPoints() + if lastBlock then + block:SetPoint('TOPLEFT', lastBlock, 'TOPRIGHT') + else + block:SetPoint('TOPLEFT', self, 'TOPLEFT') + end + lastBlock = block + + block:SetHeight(24) + block:SetWidth(block.Icon:GetWidth() + block.Label:GetWidth()+4) + totalWidth = totalWidth + block:GetWidth() + end + print(block:IsShown(), '|cFF0088FF'..block.name..'|r', block:GetSize()) + + end + + self:SetWidth(totalWidth) + + self.needsUpdate = nil + print(self:IsShown(), '|cFF00FF88'..self:GetName()..'|r', self:GetSize()) + self:SetShown(canShow) + VeneerWorldState:Reanchor(true) +end + +function module:OnUpdate() + if self.needsUpdate then + self:Update() + end +end + +function block:OnEvent(event, ...) + print('|cFF0088FF<'..self.name..'>|r', 'OnEvent', event, ...) + self:Update() +end + +function block:Setup() + +end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/Currency.xml Sun Mar 26 06:25:18 2017 -0400 @@ -0,0 +1,39 @@ +<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"> + + <Script file="Currency.lua" /> + <Frame virtual="true" name="VeneerCurrencyTemplate" parentArray="Blocks" mixin="VeneerWorldStateCurrencyBlockMixin" hidden="true"> + <Scripts> + <OnLoad method="OnLoad" /> + <OnEvent method="OnEvent" /> + <OnShow method="OnShow" /> + <OnHide method="OnHide" /> + </Scripts> + <Layers> + <Layer level="ARTWORK"> + <Texture parentKey="Icon" > + <Size x="16" y="16" /> + <Anchors> + <Anchor point="LEFT" /> + </Anchors> + </Texture> + </Layer> + <Layer level="OVERLAY"> + <FontString parentKey="Label" inherits="VeneerNumberFont"> + <Anchors> + <Anchor point="LEFT" relativePoint="RIGHT" relativeKey="$parent.Icon" x="2" y="0" /> + </Anchors> + </FontString> + </Layer> + </Layers> + </Frame> + + <Frame parent="VeneerWorldState" name="$parentZoneCurrency" parentArray="modules" mixin="VeneerWorldStateCurrencyMixin" hidden="true" inherits="VeneerMixinScripts, VeneerAnimations"> + <Size x="240" y="24" /> + <Anchors> + <Anchor point="TOP" /> + </Anchors> + </Frame> + + +</Ui> \ No newline at end of file
--- a/Modules/WorldState.lua Thu Mar 23 05:29:03 2017 -0400 +++ b/Modules/WorldState.lua Sun Mar 26 06:25:18 2017 -0400 @@ -2,31 +2,25 @@ -- WorldState.lua -- Created: 10/7/2016 10:55 PM -- %file-revision% --- +-- An extensible panel group for HUD values local print = DEVIAN_WORKSPACE and function(...) print('VnWorldState', ...) end or nop local WorldStateBlockMixin = {} VeneerOrderHallMixin = { anchorPoint = 'TOP', anchorFrom = 'TOP', + anchorPriority = 1, anchorX = 0, anchorY = 0, addonTrigger = 'Blizzard_OrderHallUI', addonFrame = 'OrderHallCommandBar', } -VeneerWorldStateHeadsUpMixin = { -} - -VeneerWorldStateCurrencyMixin = { -} -VeneerWorldStateProgressMixin = { - keepOpen = true, -} VeneerWorldStateMixin = { maxHeight = 0, detectedFrames = {}, anchorPoint = 'TOP', + modules = {} } function VeneerWorldStateMixin:Reset() @@ -42,7 +36,6 @@ --DEFAULT_CHAT_FRAME:AddMessage('Loaded') print('|cFFFFFF00'..self:GetName()..'|r:Setup()') - self.modules = self.modules or {self:GetChildren()} for i, frame in ipairs(self.modules) do print('--'.. frame:GetName()..' exists') if frame.Setup then @@ -75,7 +68,7 @@ self:RegisterEvent('PLAYER_ENTERING_WORLD') self:RegisterEvent('PLAYER_REGEN_ENABLED') self:RegisterEvent('PLAYER_REGEN_DISABLED') - Veneer:AddHandler(self, self.anchorPoint, 2) + Veneer:AddHandler(self, self.anchorPoint, self.anchorPriority) SLASH_VENEERWORLDSTATE1 = "/vws" SLASH_VENEERWORLDSTATE2 = "/worldstate" SlashCmdList.VENEERWORLDSTATE = function() @@ -157,14 +150,17 @@ function VeneerOrderHallMixin:Setup() print('|cFFFFFF00'..self:GetName()..':Setup()') self:SetParent(OrderHallCommandBar) - self:RegisterEvent("ZONE_CHANGED"); - self:RegisterEvent("ZONE_CHANGED_INDOORS"); - self:RegisterEvent("ZONE_CHANGED_NEW_AREA"); + self:RegisterEvent("UNIT_AURA"); + self:RegisterEvent("GARRISON_FOLLOWER_CATEGORIES_UPDATED") + self:RegisterEvent("GARRISON_FOLLOWER_ADDED") + self:RegisterEvent("GARRISON_FOLLOWER_REMOVED") + self:SetShown(true) end function VeneerOrderHallMixin:OnLoad() Veneer:AddHandler(self, 'TOP', 1) + self:EnableMouse(false) end function VeneerOrderHallMixin:OnEvent(event, ...) @@ -189,7 +185,6 @@ end function VeneerOrderHallMixin:Update() - if not OrderHallCommandBar then print('|cFFFF4400'..self:GetName()..' updater called without target') return @@ -201,7 +196,17 @@ OrderHallCommandBar.Background:SetColorTexture(0,0,0,0.5) OrderHallCommandBar.WorldMapButton:Hide() OrderHallCommandBar:EnableMouse(false) - self:SetSize(700, 24) + self:SetSize(700, 22) + + local troops = OrderHallCommandBar.TroopSummary + if troops then + for _, category in ipairs(troops) do + category.Count:SetFontObject(VeneerNumberFont) + category.Count:ClearAllPoints() + category.Count:SetPoint('BOTTOMRIGHT', category.Icon, 'BOTTOMRIGHT', -1, 1) + end + end + print('|cFF00AAFF'..self:GetName()..'|r:Update()', OrderHallCommandBar:IsVisible(), self:IsShown()) @@ -209,308 +214,7 @@ Veneer:DynamicReanchor() end -function VeneerWorldStateCurrencyMixin:OnLoad () - self:RegisterEvent("PLAYER_ENTERING_WORLD"); - self:RegisterEvent("ZONE_CHANGED"); - self:RegisterEvent("ZONE_CHANGED_INDOORS"); - self:RegisterEvent("ZONE_CHANGED_NEW_AREA"); - self:RegisterEvent('CURRENCY_DISPLAY_UPDATE') - self:RegisterEvent('CHAT_MSG_CURRENCY') -end -function VeneerWorldStateCurrencyMixin:OnEvent (event, arg) - self:Update() -end -local zoneCurrency = { - ['Suramar'] = 1155, - ["Sashj'tar Ruins"] = 1155, - ["Faronaar Ruins"] = 1155 -} -local zoneBountyInfo = { - ['Suramar'] = 1859, - ["Sashj'tar Ruins"] = 1859, - ["Faronaar Ruins"] = 1859, - - ['Azsuna'] = 1900, -} -local globalBountyInfo = { -} -function VeneerWorldStateCurrencyMixin:Update(isBatchUpdate) - local zoneText = GetRealZoneText() - local canShow = false - if zoneText then - local currency = zoneCurrency[zoneText] - if currency then - local name, earned, texture, earnedThisWeek, weeklyMax, totalMax = GetCurrencyInfo(zoneCurrency[zoneText]) - self.Icon:SetTexture(texture) - self.Label:SetFormattedText("%d / %d", earned, totalMax) - self:SetWidth(self.Icon:GetWidth() + self.Label:GetStringWidth() + 6) - canShow = true - end - else - end - self:SetShown(canShow) - VeneerWorldState:Reanchor(true) -end - -function VeneerWorldStateProgressMixin:OnUpdate(sinceLast) - self.timeLived = (self.timeLived or 0) + sinceLast - if self.keepOpen then - return - end - if self.timeLived >= 3 and not self.TimedFadeOut:IsPlaying() then - self.TimedFadeOut:Play() - end -end - -function VeneerWorldStateProgressMixin:OnLoad() - self:RegisterEvent('PLAYER_EQUIPMENT_CHANGED') - - self:RegisterEvent("PLAYER_XP_UPDATE"); - self:RegisterEvent("UPDATE_EXHAUSTION"); - self:RegisterEvent("PLAYER_LEVEL_UP"); - self:RegisterEvent("PLAYER_UPDATE_RESTING"); - - self:RegisterEvent("ARTIFACT_UPDATE"); - self:RegisterEvent("ARTIFACT_XP_UPDATE"); - self:RegisterEvent("ARTIFACT_CLOSE"); - self:RegisterEvent("ARTIFACT_MAX_RANKS_UPDATE"); - - self.progressPercent = 0 - self.progressAmount = 0 - self.progressMax = 1 - self.progressOverflow = 0 - -end - -function VeneerWorldStateProgressMixin:Setup() - self:UpdateXPGain() - if self.canGainXP then - self.mode = 'xp' - else - self.mode = 'artifact' - end - print('setup mode:', self.mode) -end - -function VeneerWorldStateProgressMixin:OnEvent(event, ...) - local lastMode = self.mode - if event == 'PLAYER_LEVEL_UP' or event == 'ENABLE_XP_GAIN' or event == 'DISABLE_XP_GAIN' then - self:UpdateXPGain() - elseif event == 'ARTIFACT_XP_UPDATE' or event == 'ARTIFACT_UPDATE' then - self.mode = 'artifact' - - elseif event == 'PLAYER_EQUIPMENT_CHANGED' then - local slot, hasEquip = ... - if slot == 16 then - self.mode = 'artifact' - lastMode = nil - end - elseif event == 'PLAYER_XP_UPDATE' or event == 'PLAYER_LEVEL_UP' then - print('forcing to XP mode') - self.mode = 'xp' - end - self.modeChanged = (lastMode ~= self.mode) - if self.modeChanged and self:IsVisible() then - print('|cFF88FF00'..self:GetName()..'.TransitionFadeOut:Play()', event, ...) - self:AnimateMode() - else - print('|cFFFFFF00'..self:GetName()..':Update()', event, ...) - self:Update() - end -end -function VeneerWorldStateProgressMixin:UpdateXPGain() - self.canGainXP = (UnitLevel('player') < GetMaxPlayerLevel()) and (not IsXPUserDisabled()) - if not self.canGainXP then - self.ProgressBar:SetColorTexture(0.75,0.75,0.75) - end -end - -local GetEquippedArtifactInfo = _G.C_ArtifactUI.GetEquippedArtifactInfo -local GetCostForPointAtRank = _G.C_ArtifactUI.GetCostForPointAtRank - - -local progressHandlers = { - xp = function(self) - local hasNewInfo, showChange = false, false - local xp = UnitXP('player') - local xpMax = UnitXPMax('player') - local bonusXP = GetXPExhaustion() - if xp then - self.progressPercent = xp / xpMax - end - self.progressText = '|cFFFFCC00' .. UnitLevel('player') .. '|r ' .. xp .. '/' .. xpMax - if bonusXP then - self.progressOverflow = min(1,(bonusXP / xpMax)) - self.OverflowBar:SetColorTexture(0.5, 0.5,0.5, 0.25) - self.OverflowBar:SetPoint('LEFT', self.ProgressBar, 'LEFT') - else - self.progressOverflow = nil - end - self.ProgressBar:SetColorTexture(0, 0.5,1,1) - self.OverflowAnchor = self.ProgressBar - self.hasNewInfo = (self.progressAmount ~= xp) - showChange = (hasNewInfo and not self.modeChanged) and ((xp - self.progressAmount) / xpMax) - - self.progressAmount = xp - self.progressMax = xpMax - return hasNewInfo, showChange - end, - artifact = function(self) - local hasNewInfo, showChange = false, false - local itemID, altItemID, name, icon, totalXP, pointsSpent = GetEquippedArtifactInfo() - if itemID then - local nextRankCost = GetCostForPointAtRank(pointsSpent) or 0 - print(' API:', itemID, name, 'XP:', totalXP, 'Points:', pointsSpent, 'Next:', nextRankCost) - hasNewInfo = (self.progressAmount ~= totalXP) - showChange = (hasNewInfo and not self.modeChanged) and (((totalXP - self.progressAmount) / nextRankCost)) - - if totalXP > nextRankCost then - self.progressPercent = 1 - else - self.progressPercent = totalXP / nextRankCost - end - - self.progressText = name .. ' ('..pointsSpent .. '): '.. totalXP .. ' / ' .. nextRankCost - - self.ProgressBar:SetColorTexture(1,0.5,0,1) - self.OverflowBar:Hide() - - if totalXP > nextRankCost then - self.progressText = self.progressText .. ' Level Up!' - self.progressOverflow = (totalXP - nextRankCost) / nextRankCost - self.OverflowBar:SetPoint('LEFT', self.ProgressBG, 'LEFT') - self.OverflowAnchor = self.OverflawBar - else - self.progressOverflow = nil - self.OverflowAnchor = self.ProgressBar - end - - self.progressAmount = totalXP - self.progressMax = nextRankCost - else - self.progressOverflow = nil - self.progressAmount = 0 - self.progressMax = 1 - self.progressText = '' - end - return hasNewInfo, showChange - end -} - -function VeneerWorldStateProgressMixin:Update(isBatchUpdate) - - local progressChange = false - print(' current mode:', self.mode, 'vis:', self:IsVisible()) - if (not self.mode) or (not progressHandlers[self.mode]) then - self:HidePanel() - return - end - - local hasNewInfo, showProgress = progressHandlers[self.mode](self) - self:SetSize(600,16) - if hasNewInfo then - self.timeOut = nil - self.timeLived = 0 - end - - - if not self:IsVisible() then - self.TransitionFadeIn:Play() - else - self:ShowPanel() - end - - print(' Percent:', floor(self.progressPercent*100)/100, 'BarLength:', floor(self:GetWidth()* self.progressPercent), 'new:', hasNewInfo, 'shown:', self:IsShown()) - print(' Metrics:', self:IsVisible(), self:GetWidth(), self.ProgressBG:GetWidth()) - if self.progressPercent > 0 then - self.ProgressBar:Show() - self.ProgressBar:SetPoint('TOPRIGHT', self.ProgressBG, 'TOPLEFT', self:GetWidth()* self.progressPercent , 0) - self.Label:SetText(self.progressText) - - self.ProgressSpark:ClearAllPoints() - if self.progressOverflow then - print(' Overflow:', self.progressOverflow) - self.OverflowBar:Show() - self.OverflowBar:SetWidth(self.progressOverflow * self:GetWidth(), 0) - else - self.OverflowBar:Hide() - end - self.ProgressSpark:SetPoint('CENTER', self.OverflowAnchor, 'RIGHT', 0, 0) - - else - self.ProgressBar:Hide() - end - - if self.progressOverflow and (self.progressOverflow >= self.progressPercent) then - self.OverflowBar:SetDrawLayer('ARTWORK', 1) - self.ProgressBar:SetDrawLayer('ARTWORK', 2) - else - self.OverflowBar:SetDrawLayer('ARTWORK', 2) - self.ProgressBar:SetDrawLayer('ARTWORK', 1) - end - - if progressChange then - self:AnimateProgress(progressChange) - end - - self.modeChanged = nil -end - - -function VeneerWorldStateProgressMixin:AnimateProgress(progressChange) - - - local changeAnchor = (self.progressOverflow and self.OverflowBar) or self.ProgressBar - local progressWidth = self:GetWidth() * min(progressChange, changeAnchor:GetWidth()) - - self.ProgressAdded:Show() - self.ProgressAdded:ClearAllPoints() - self.ProgressAdded:SetPoint('TOPRIGHT', changeAnchor, 'TOPRIGHT', 0, 0) - self.ProgressAdded:SetPoint('BOTTOMLEFT', changeAnchor, 'BOTTOMRIGHT', - (progressWidth), 0) - - print(' Render change:', progressWidth, changeAnchor) - self.ProgressFlash.translation:SetOffset(progressWidth, 0) - self.ProgressFlash:Play() -end - -function VeneerWorldStateProgressMixin:OnMouseDown(button) - if button == 'RightButton' then - if self.keepOpen then - self.keepOpen = nil - self.timeLived = 1000 - else - self.keepOpen = true - - self.modeChanged = true - end - print('keepOpen =', self.keepOpen) - self:Update() - else - - if self.mode == 'xp' then - self.mode = 'artifact' - else - if not self.canGainXP then - return - end - self.mode = 'xp' - end - print('|cFFFF4400Change mode:', self.mode) - - - self:AnimateMode() - end - -end - -function VeneerWorldStateProgressMixin:AnimateMode() - - self.TransitionFadeIn:Stop() - print('|cFF88FF00'..self:GetName()..'.TransitionFadeOut:Play()') - self.modeChanged = true - self.TransitionFadeOut:Play() -end do function WorldStateBlockMixin:ShowPanel() @@ -555,3 +259,4 @@ end end +
--- a/Modules/WorldState.xml Thu Mar 23 05:29:03 2017 -0400 +++ b/Modules/WorldState.xml Sun Mar 26 06:25:18 2017 -0400 @@ -9,29 +9,6 @@ <Anchor point="TOP" /> </Anchors> <Frames> - <Frame name="$parentZoneCurrency" mixin="VeneerWorldStateCurrencyMixin" hidden="true" inherits="VeneerMixinScripts, VeneerAnimations"> - <Size x="240" y="24" /> - <Anchors> - <Anchor point="TOP" /> - </Anchors> - <Layers> - <Layer level="ARTWORK"> - <Texture parentKey="Icon" > - <Size x="16" y="16" /> - <Anchors> - <Anchor point="LEFT" /> - </Anchors> - </Texture> - </Layer> - <Layer level="OVERLAY"> - <FontString parentKey="Label" inherits="VeneerNumberFont"> - <Anchors> - <Anchor point="LEFT" relativePoint="RIGHT" relativeKey="$parent.Icon" x="2" y="0" /> - </Anchors> - </FontString> - </Layer> - </Layers> - </Frame> </Frames> </Frame> <Frame name="VeneerOrderHallHandler" hidden="true" parent="UIParent" mixin="VeneerOrderHallMixin" inherits="VeneerMixinScripts" />
--- a/Veneer.lua Thu Mar 23 05:29:03 2017 -0400 +++ b/Veneer.lua Sun Mar 26 06:25:18 2017 -0400 @@ -10,6 +10,7 @@ local type, strrep, ipairs, tinsert, tostring, select = type, string.rep, ipairs, tinsert, tostring, select local pairs, tremove = pairs, tremove local print = DEVIAN_WORKSPACE and function(...) _G.print('Veneer', ...) end or nop +local eprint = DEVIAN_WORKSPACE and function(...) _G.print('VeneerEvent', ...) end or nop local wipe = table.wipe SLASH_VENEER1 = "/veneer" @@ -103,6 +104,7 @@ local select, IsAddOnLoaded, IsLoggedIn = select, IsAddOnLoaded, IsLoggedIn function Veneer:OnEvent(event, ...) + local print = eprint print('|cFFFF0088OnEvent()|r',event, ...) if (event == 'PLAYER_LOGIN') or (event == 'ADDON_LOADED') then print(IsLoggedIn(), self.initialized) @@ -205,57 +207,6 @@ function Veneer:GetClusterFromArgs (...) - local primaryAnchor - local insertPosition - local insertPriority - - - local clusterTable = self.FrameClusters - for i = 1, select('#', ...) do - local arg = select(i, ...) - local argType = type(arg) - if argType == 'string' then - if not primaryAnchor then - primaryAnchor = arg - end - clusterTable[arg] = clusterTable[arg] or {} - clusterTable = clusterTable[arg] - print(strrep(' ', i)..'anchor cluster', i, arg) - elseif argType == 'boolean' then - if arg == true then - print('force top position') - insertPosition = 1 - insertPriority = nil - end - elseif argType == 'number' then - insertPriority = arg - end - end - - if insertPriority then - for i = 1, #clusterTable do - if clusterTable[i].anchorPriority and (clusterTable[i].anchorPriority > insertPriority) then - print('prioritized insert position:', insertPriority, insertPosition) - break - else - print('passing lower priority frame:', clusterTable[i]:GetName()) - end - insertPosition = i - end - end - - - if not primaryAnchor then - primaryAnchor = 'CENTER' - clusterTable[primaryAnchor] = clusterTable[primaryAnchor] or {} - clusterTable = clusterTable[primaryAnchor] - print('using default anchor') - end - - if not insertPosition then - insertPosition = #clusterTable + 1 - print('using default position') - end return primaryAnchor, clusterTable, insertPosition end @@ -272,14 +223,71 @@ end if not handler.anchorFrame then - local anchorGroup, clusterTable, clusterIndex, clusterPriority = self:GetClusterFromArgs(...) - if clusterIndex == 1 then - for i, frame in ipairs(clusterTable) do - frame.clusterIndex = i + 1 + + local primaryAnchor + local clusterIndex + local clusterPriority = handler.anchorPriority + local clusterDepth = 0 + + local clusterTable = self.FrameClusters + for i = 1, select('#', ...) do + local arg = select(i, ...) + local argType = type(arg) + if argType == 'string' then + + if not primaryAnchor then + primaryAnchor = arg + end + clusterDepth = clusterDepth + 1 + clusterTable[arg] = clusterTable[arg] or {} + clusterTable = clusterTable[arg] + print('clusterGroup =', clusterDepth ..'.'.. arg) + elseif argType == 'boolean' then + if arg == true then + print('anchorFirst =', arg) + clusterPriority = nil + end + elseif argType == 'number' then + if arg ~= clusterPriority then + print('anchorPriority =', arg) + clusterPriority = arg + end + end end + + if clusterPriority then + for i = 1, #clusterTable do + clusterIndex = i + if clusterTable[i].anchorPriority and (clusterTable[i].anchorPriority > clusterPriority) then + print('|cFF00BB00insert position:', clusterPriority, clusterIndex) + break + else + print('passing lower priority frame:', clusterTable[i]:GetName()) + end + end + else + print('|cFF00BB00inserting at front') + clusterIndex = 1 + end + + + if not primaryAnchor then + primaryAnchor = 'CENTER' + clusterTable[primaryAnchor] = clusterTable[primaryAnchor] or {} + clusterTable = clusterTable[primaryAnchor] + end + + if not clusterPriority then + clusterIndex = #clusterTable + 1 + end + if not clusterIndex then + clusterIndex = #clusterTable + 1 + end + + tinsert(clusterTable, clusterIndex, handler) - print(' cluster', anchorGroup, 'table', clusterTable, 'position', clusterIndex) + print(' cluster', primaryAnchor, 'table', clusterTable, 'priority', clusterPriority, 'position', clusterIndex) handler.anchorCluster = clusterTable handler.anchorIndex = clusterIndex @@ -334,10 +342,10 @@ end --- Evaluates frames visibility and chains them accordingly - -function Veneer:DynamicReanchor(parent) +-- Recursives updates frame group anchors +function Veneer:EvaluateAnchors(parent) parent = parent or self + local print = eprint print('|cFF88FF00DynamicReanchor()') for anchorPoint, cluster in pairs(parent.FrameClusters) do if anchorPoint ~= LE_FREE_FRAMES_GROUP then @@ -372,8 +380,11 @@ end end +Veneer.DynamicReanchor = Veneer.EvaluateAnchors + -- Evaluates the current visibility state and re-anchors adjacent blocks accordingly function Veneer:InternalReanchor(handler, printFunc) + local print = eprint print('|cFF00FFFFVeneer:InternalReanchor('..handler:GetName()..')') if handler.anchorFrame then handler:SetPoint(handler.anchorPoint, handler.anchorFrame, handler.anchorFrom, handler.anchorX, handler.anchorY) @@ -423,6 +434,7 @@ end function Veneer:SlideBlock(frame, ...) + local print = eprint local aX, aY = frame:GetLeft(), frame:GetTop() frame:SetPoint('TOPLEFT', frame, 'BOTTOMLEFT', aX, aY) @@ -440,6 +452,7 @@ function Veneer:ExecuteOnClusters(layer, method) + local print = eprint self.parserDepth = self.parserDepth + 1 if not layer then if self.parserDepth > 1 then @@ -480,6 +493,7 @@ -- Takes frame handle and assigns a block to it function Veneer:Acquire (frame, template) + local print = eprint if not frame then print('|cFFFF4400Unable to acquire frame...|r') return