Mercurial > wow > buffalo2
changeset 90:6e2cb847c3c6
Implement a mixin template for the basic visual config widgets.
author | Nenue |
---|---|
date | Mon, 24 Oct 2016 18:28:40 -0400 |
parents | 74e714637d6a |
children | fe8806a7b6fc |
files | Modules/BuffFrame.lua Modules/BuffFrame.xml Modules/TalkingHead.lua Modules/TalkingHead.xml Modules/WorldState.lua Modules/WorldState.xml Templates.lua Templates.xml Veneer.lua Veneer.toc Veneer.xml |
diffstat | 11 files changed, 623 insertions(+), 390 deletions(-) [+] |
line wrap: on
line diff
--- a/Modules/BuffFrame.lua Fri Oct 21 18:03:35 2016 -0400 +++ b/Modules/BuffFrame.lua Mon Oct 24 18:28:40 2016 -0400 @@ -11,6 +11,7 @@ - BuffButtons can only be hidden/shown by blizzcode, so functions doing that have to be accounted for --]] + local BUFFS_PER_ROW = 12 local BUFF_BUTTON_SIZE = 48 local BUFF_BUTTON_SPACING_H = 5 @@ -40,10 +41,15 @@ VeneerBuffFrameMixin = { moduleName = 'Buff Frames', defaultCluster = 'TOPRIGHT', + anchorX = BUFF_FRAMES_X, + anchorY = BUFF_FRAMES_Y, + anchorPoint = 'TOPRIGHT', Buttons = {}, DetectedFrames = {}, AuraCache = {} } +VeneerBuffFrameButtonMixin = { +} local plugin = VeneerBuffFrameMixin local vn = Veneer @@ -116,7 +122,61 @@ CENTER = {0, 0}, } -function plugin:Acquire(target) +-- Associates skinning elements with said button +local surrogates = { + ['Show'] = false, + ['Hide'] = false, + ['SetText'] = false, + ['SetVertexColor'] = function(self, region, r, g, b, a) + if not self.progress then + return + end + + region:Hide() + tprint('|cFF0088FFborder:SetVertexColor|r', r,g,b,a) + self.progress.fg:SetColorTexture(r,g,b,a) + self.border:SetColorTexture(r,g,b,a) + self.border:Show() + end, +} +local DoRegionHooks = function (veneer, region) + + if region then + --print('hooking', region:GetName()) + region:ClearAllPoints() + for method, callback in pairs(surrogates) do + if type(region[method]) == 'function' then + + --print(method, type(callback)) + local func + if callback then + hooksecurefunc(region, method, function(self, ...) + --tprint('|cFF00FFFF'.. region:GetName().. ':', method) + region:ClearAllPoints() + callback(veneer, region, ...) + end) + else + hooksecurefunc(region, method, function(self,...) + tprint('|cFF0088FF'.. self:GetName().. ':', method) + self:ClearAllPoints() + veneer:Show() + veneer[method](veneer, ...) + + if self:GetName():match('Debuff.+Count') then + + print('|cFF00FFFF'.. self:GetName().. ':'.. method, '->', veneer:GetName()..':'..method..'(', ...,')') + print(veneer:IsVisible(),veneer:GetStringWidth(),veneer:GetText()) + print(veneer:GetTop(), veneer:GetLeft()) + print(veneer:GetPoint(1)) + end + + end) + end + end + end + end +end +function VeneerBuffFrameMixin:Acquire(target) local frame = self.Buttons[target] if not (self.Buttons[target]) then @@ -173,11 +233,11 @@ return frame end -function plugin:OnLoad() +function VeneerBuffFrameMixin:OnLoad() Veneer:AddHandler(self, self.defaultCluster) end -function plugin:Setup() +function VeneerBuffFrameMixin:Setup() hooksecurefunc("BuffFrame_Update", function(...) self:OnBuffFrameUpdate(...) end) @@ -190,68 +250,9 @@ _G['TempEnchant'..i..'Border']:SetVertexColor(0.5,0,1,1) end end --- Associates skinning elements with said button -local surrogates = { - ['Show'] = false, - ['Hide'] = false, - ['SetText'] = false, - ['SetVertexColor'] = function(self, region, r, g, b, a) - if not self.progress then - return - end - region:Hide() - tprint('|cFF0088FFborder:SetVertexColor|r', r,g,b,a) - self.progress.fg:SetColorTexture(r,g,b,a) - self.border:SetColorTexture(r,g,b,a) - self.border:Show() - end, -} -local DoRegionHooks = function (veneer, region) - if region then - --print('hooking', region:GetName()) - region:ClearAllPoints() - for method, callback in pairs(surrogates) do - if type(region[method]) == 'function' then - - --print(method, type(callback)) - local func - if callback then - func = function(self, ...) - --tprint('|cFF00FFFF'.. region:GetName().. ':', method) - region:ClearAllPoints() - callback(veneer, region, ...) - end - else - func = function(self,...) - tprint('|cFF0088FF'.. self:GetName().. ':', method) - self:ClearAllPoints() - veneer:Show() - veneer[method](veneer, ...) - - if self:GetName():match('Debuff.+Count') then - - print('|cFF00FFFF'.. self:GetName().. ':'.. method, '->', veneer:GetName()..':'..method..'(', ...,')') - print(veneer:IsVisible(),veneer:GetStringWidth(),veneer:GetText()) - print(veneer:GetTop(), veneer:GetLeft()) - print(veneer:GetPoint(1)) - end - - end - end - if func then - --print('hooking', region:GetName(), method) - hooksecurefunc(region, method, func) - - end - end - end - end -end - - -function plugin:SetupButton (name) +function VeneerBuffFrameMixin:SetupButton (name) local frame = _G[name ] if self.DetectedFrames[frame] then --print('|cFFFF4400Attempting to skin a frame that already went through.|r') @@ -320,7 +321,7 @@ --- Set widgets to reflect the passed parameters -function plugin:UpdateButton (frame, duration, expires) +function VeneerBuffFrameMixin:UpdateButton (frame, duration, expires) local veneer = self:Acquire(frame) -- is it a new button? if not self.DetectedFrames[frame] then @@ -374,9 +375,10 @@ veneer.cooldown:Hide() end - if count and count >= 1 then + if count and count > 1 then veneer.count:SetText(count) veneer.count:Show() + frame.count:ClearAllPoints() else veneer.count:Hide() end @@ -393,7 +395,7 @@ --- Provides the number of changed indices for use in deciding between partial and full veneer updates -function plugin:ButtonHasChanged (frame, ...) +function VeneerBuffFrameMixin:ButtonHasChanged (frame, ...) aurasCache[frame] = aurasCache[frame] or {} local hasChange = 0 local numVals = select('#',...) @@ -407,7 +409,7 @@ return hasChange end -function plugin:OnAuraButton_Update (name, index, filter) +function VeneerBuffFrameMixin:OnAuraButton_Update (name, index, filter) local bName = name..index local frame = _G[bName] if frame and frame:IsVisible() then @@ -423,7 +425,7 @@ end end -function plugin:OnUpdateAllBuffAnchors () +function VeneerBuffFrameMixin:OnUpdateAllBuffAnchors () local todo = {} if #pendingFrames >= 1 then @@ -446,6 +448,8 @@ local lastBuff, topBuff local numBuffs = 0 + local numColumns = 1 + local maxColumn = 1 for i = 1, BUFF_ACTUAL_DISPLAY do local buff = _G['BuffButton'..i] if buff then @@ -454,13 +458,19 @@ if mod(numBuffs,BUFFS_PER_ROW) == 1 then if numBuffs == 1 then buff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', BUFF_FRAMES_X, BUFF_FRAMES_Y) - plugin.currentTop = buff:GetTop() + plugin.currentTop = buff else buff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -BUFF_BUTTON_SPACING_V) end + numColumns = 1 topBuff = buff else buff:SetPoint('TOPRIGHT', lastBuff, 'TOPLEFT', -BUFF_BUTTON_SPACING_H, 0) + numColumns = numColumns + 1 + end + if numColumns > maxColumn then + maxColumn = numColumns + plugin.currentLeft = buff end lastBuff = buff end @@ -489,11 +499,18 @@ end if lastBuff then - plugin.currentBottom = lastBuff:GetBottom() + plugin.currentBottom = lastBuff end + + self.Background:ClearAllPoints() + self.Background:SetPoint('TOPRIGHT', plugin.currentTop, 'TOPRIGHT', 4, 4) + self.Background:SetPoint('BOTTOM', plugin.currentBottom, 'BOTTOM', 0, -4) + self.Background:SetPoint('LEFT', plugin.currentLeft, 'LEFT', -4, 0) end - -function plugin:OnUpdateDuration (frame, timeLeft) +function VeneerBuffFrameMixin:UpdateConfigLayers (configMode) + self:SetShown(configMode) +end +function VeneerBuffFrameMixin:OnUpdateDuration (frame, timeLeft) local veneer = self:Acquire(frame) local hours = floor(timeLeft/3600) local minutes = floor(mod(timeLeft, 3600)/60) @@ -527,7 +544,7 @@ -- Obtains the first instance of Tenchant use -function plugin:OnTemporaryEnchantFrameUpdate (...) +function VeneerBuffFrameMixin:OnTemporaryEnchantFrameUpdate (...) local numVals = select('#', ...) local numItems = numVals / 4 if numItems >= 1 then @@ -558,9 +575,24 @@ end end -function plugin:OnBuffFrameUpdate () +function VeneerBuffFrameMixin:OnBuffFrameUpdate () end +function VeneerBuffFrameButtonMixin:OnLoad() + + self.duration = self.progress.duration + self.count = self.overlay.count + self.border = self.underlay.bg + + VeneerBuffFrame.ConfigLayers = VeneerBuffFrame.ConfigLayers or {} + self.configIndex = #VeneerBuffFrame.ConfigLayers + for i, region in ipairs(self.ConfigLayers) do + tinsert(VeneerBuffFrame.ConfigLayers, region) + end + + self.configIndexEnd = #VeneerBuffFrame.ConfigLayers +end + -- The TempEnchant frames are hardcoded in the base FrameXML, so get them now
--- a/Modules/BuffFrame.xml Fri Oct 21 18:03:35 2016 -0400 +++ b/Modules/BuffFrame.xml Mon Oct 24 18:28:40 2016 -0400 @@ -2,14 +2,13 @@ ..\FrameXML\UI.xsd"> <Script file="BuffFrame.lua" /> - <Frame name="VeneerBuffFrame" mixin="VeneerBuffFrameMixin" inherits="VeneerMixinScripts" /> - <Frame name="VeneerBuffTemplate" virtual="true" inherits="VeneerTemplate" hidden="true"> + <Frame name="VeneerBuffFrame" mixin="VeneerBuffFrameMixin" inherits="VeneerHandlerTemplate" frameStrata="BACKGROUND"> + <Size x="20" y="20" /> + </Frame> + + <Frame name="VeneerBuffTemplate" virtual="true" mixin="VeneerBuffFrameButtonMixin" inherits="VeneerStatusButtonTemplate" hidden="true"> <Scripts> - <OnLoad> - self.duration = self.progress.duration - self.count = self.overlay.count - self.border = self.underlay.bg - </OnLoad> + <OnLoad method="OnLoad" /> </Scripts> <Frames> <!--
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/TalkingHead.lua Mon Oct 24 18:28:40 2016 -0400 @@ -0,0 +1,84 @@ +-- Veneer +-- TalkingHead.lua +-- Created: 10/23/2016 5:18 AM +-- %file-revision% +-- + + +local print = DEVIAN_WORKSPACE and function(...) print('VnTalkingHead', ...) end or nop + +VeneerTalkingHeadMixin = { + + anchorPoint = 'BOTTOMLEFT', + anchorFrom = 'TOPLEFT', + anchorX = -4, + anchorY = 24, + anchorFrame = 'ChatFrame1', + addonTrigger = 'Blizzard_TalkingHeadUI' + +} +function VeneerTalkingHeadMixin:OnLoad() + Veneer:AddHandler(self, self.anchorPoint) +end + + + +function VeneerTalkingHeadMixin:Setup() + print('|cFF00AAFF'..self:GetName()..'|r:Setup()', TalkingHeadFrame:IsShown(), self:IsShown()) + + self:SetSize(TalkingHeadFrame:GetSize()) + self:SetParent(TalkingHeadFrame) + TalkingHeadFrame:ClearAllPoints() + TalkingHeadFrame:SetPoint('BOTTOM', self, 'BOTTOM') + + hooksecurefunc(TalkingHeadFrame, 'SetPoint', function(...) + print('SetPoint', ...) + print(debugstack()) + end) + + self:SetShown(true) + self:ClearAnchor() +end + +function VeneerTalkingHeadMixin:ClearAnchor() + + UIPARENT_MANAGED_FRAME_POSITIONS["TalkingHeadFrame"] = nil + for i, alertSubSystem in pairs(AlertFrame.alertFrameSubSystems) do + if alertSubSystem.anchorFrame == TalkingHeadFrame then + tremove(AlertFrame.alertFrameSubSystems, i) + return + end + end +end + +function VeneerTalkingHeadMixin:OnShow() + if TalkingHeadFrame then + print('|cFF00AAFF'..self:GetName()..'|r:OnShow()', TalkingHeadFrame:IsShown(), self:IsShown()) + print(debugstack()) + self:Update() + end +end + +function VeneerTalkingHeadMixin:Reanchor() + self:ClearAllPoints() + self:SetPoint('BOTTOMLEFT', _G[self.anchorFrame], 'TOPLEFT', -4, 24) + self:SetPoint('RIGHT', _G[self.anchorFrame], 'RIGHT', 2, 0) + -- independent module, +end + +function VeneerTalkingHeadMixin:OnHide() + if TalkingHeadFrame then + print('|cFF00AAFF'..self:GetName()..'|r:OnHide()', TalkingHeadFrame:IsShown(), self:IsShown()) + end + Veneer:Reanchor() +end + +function VeneerTalkingHeadMixin:Update() + + print('|cFF00AAFF'..self:GetName()..'|r:OnShow()', TalkingHeadFrame:IsShown(), self:IsShown()) + TalkingHeadFrame:ClearAllPoints() + TalkingHeadFrame:SetAllPoints(self) + + Veneer:InternalReanchor(self) +end +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/TalkingHead.xml Mon Oct 24 18:28:40 2016 -0400 @@ -0,0 +1,8 @@ +<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="TalkingHead.lua" /> + <Frame name="VeneerTalkingHead" mixin="VeneerTalkingHeadMixin" inherits="VeneerHandlerTemplate"> + <Size x="570" y="155"/> + </Frame> + +</Ui> \ No newline at end of file
--- a/Modules/WorldState.lua Fri Oct 21 18:03:35 2016 -0400 +++ b/Modules/WorldState.lua Mon Oct 24 18:28:40 2016 -0400 @@ -7,6 +7,11 @@ local WorldStateBlockMixin = {} VeneerOrderHallMixin = { anchorPoint = 'TOP', + anchorFrom = 'TOP', + anchorX = 0, + anchorY = 0, + addonTrigger = 'Blizzard_OrderHallUI', + addonFrame = 'OrderHallCommandBar', } VeneerWorldStateCurrencyMixin = { } @@ -66,8 +71,6 @@ self:RegisterEvent('PLAYER_ENTERING_WORLD') self:RegisterEvent('PLAYER_REGEN_ENABLED') self:RegisterEvent('PLAYER_REGEN_DISABLED') - self:RegisterEvent('ZONE_CHANGED_NEW_AREA') - self:RegisterEvent('ADDON_LOADED') Veneer:AddHandler(self, self.anchorPoint, true) SLASH_VENEERWORLDSTATE1 = "/vws" SLASH_VENEERWORLDSTATE2 = "/worldstate" @@ -78,13 +81,7 @@ function VeneerWorldStateMixin:OnEvent(event, arg) print(event, arg) - if event == 'ZONE_CHANGED_NEW_AREA' or event == 'ADDON_LOADED' then - if OrderHallCommandBar then - self:UnregisterEvent('ZONE_CHANGED_NEW_AREA') - self:UnregisterEvent('ADDON_LOADED') - Veneer:AddHandler(VeneerOrderHallHandler, 'TOP', true) - end - elseif event == 'PLAYER_ENTERING_WORLD' then + if event == 'PLAYER_ENTERING_WORLD' then self:Update() elseif event == 'PLAYER_REGEN_ENABLED' then self:SetShown(true) @@ -149,6 +146,11 @@ self:SetShown(true) end +function VeneerOrderHallMixin:OnLoad() + + Veneer:AddHandler(VeneerOrderHallHandler, 'TOP', true) +end + function VeneerOrderHallMixin:OnEvent(event, ...) print('|cFF00AAFF'..self:GetName()..'|r:'.. event, ...) @@ -156,13 +158,17 @@ end function VeneerOrderHallMixin:OnShow() - print('|cFF00AAFF'..self:GetName()..'|r:OnShow()', OrderHallCommandBar:IsShown(), self:IsShown()) - self:Update() + if OrderHallCommandBar then + print('|cFF00AAFF'..self:GetName()..'|r:OnShow()', OrderHallCommandBar:IsShown(), self:IsShown()) + self:Update() + end Veneer:InternalReanchor(self) end function VeneerOrderHallMixin:OnHide() - print('|cFF00AAFF'..self:GetName()..'|r:OnHide()', OrderHallCommandBar:IsShown(), self:IsShown()) + if OrderHallCommandBar then + print('|cFF00AAFF'..self:GetName()..'|r:OnHide()', OrderHallCommandBar:IsShown(), self:IsShown()) + end Veneer:Reanchor() end
--- a/Modules/WorldState.xml Fri Oct 21 18:03:35 2016 -0400 +++ b/Modules/WorldState.xml Mon Oct 24 18:28:40 2016 -0400 @@ -22,11 +22,11 @@ self:GetParent().faded = true </OnPlay> <OnStop> - print('VnWorldState', '|cFF44FF00stopped fadeout') + --print('VnWorldState', '|cFF44FF00stopped fadeout') self:GetParent():Update() </OnStop> <OnFinished> - print('VnWorldState', '|cFFFFFF00end of fadeout') + --print('VnWorldState', '|cFFFFFF00end of fadeout') self:GetParent():Hide() self:GetParent():Update() </OnFinished> @@ -44,7 +44,7 @@ self:GetParent():Update() </OnStop> <OnFinished> - print('VnWorldState', '|cFFFFFF00end of fade IN') + --print('VnWorldState', '|cFFFFFF00end of fade IN') self:GetParent().faded = nil self:GetParent().timeLived = 0 </OnFinished>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Templates.lua Mon Oct 24 18:28:40 2016 -0400 @@ -0,0 +1,59 @@ +-- Veneer +-- Templates.lua +-- Created: 10/24/2016 9:16 AM +-- %file-revision% +-- +-- Mover Widget base +local print = DEVIAN_WORKSPACE and function(...) _G.print('VnTemplate', ...) end or nop + +VeneerConfigLayerMixin = {} +VeneerAnimationMixin = {} +VeneerHandlerMixin = { anchorPoint = 'CENTER' } + +function VeneerConfigLayerMixin:OnLoad() + local handler = self:GetParent() + print(handler:GetName(), 'configLayers') + handler.ConfigLayers = handler.ConfigLayers or {} + for i, region in ipairs(handler.ConfigLayers) do + region:SetShown(Veneer.ConfigMode) + end +end + + +function VeneerConfigLayerMixin:OnUpdate() + local handler = self:GetParent() + handler.ConfigLayers = handler.ConfigLayers or {} + + self.ConfigName:SetText(handler:GetName()) + self.ConfigID:SetText(handler:GetID()) +end + + +function VeneerHandlerMixin:OnShow() + self:Reanchor() + Veneer:StaticReanchor(self) +end +function VeneerHandlerMixin:OnHide() + Veneer:DynamicReanchor() +end +function VeneerHandlerMixin:Reanchor (anchorAll) + if not anchorAll then + Veneer:InternalReanchor(self) + end +end + +function VeneerAnimationMixin:OnPlay() + PlaySoundKitID(229) + self.animating = true + print('|cFF00FF00Anim:OnPlay|r @', unpack(self.sourcePoint)) +end +function VeneerAnimationMixin:OnStop() + PlaySoundKitID(229) + self.animating = nil + print('|cFF00FF00Anim:OnFinish|r @', unpack(self.destPoint)) +end +function VeneerAnimationMixin:OnFinished() + PlaySoundKitID(229) + self.animating = nil + print('|cFF00FF00Anim:OnFinish|r @', unpack(self.destPoint)) +end \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Templates.xml Mon Oct 24 18:28:40 2016 -0400 @@ -0,0 +1,184 @@ +<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="Templates.lua" /> + + <Font name="VeneerFont" /> + <Font name="VeneerFont_Small" font="Fonts\FRIZQT__.TTF" outline="NORMAL" height="16" /> + + <Font name="VeneerFont_Large" font="Fonts\FRIZQT__.TTF" outline="NORMAL" height="24" /> + <Font name="VeneerNumberFontSmall" font="Fonts\ARIALN.ttf" outline="NORMAL" height="12" /> + <Font name="VeneerNumberFont" font="Fonts\ARIALN.ttf" outline="NORMAL" height="14" /> + <Font name="VeneerNumberFontLarge" font="Fonts\ARIALN.ttf" outline="NORMAL" height="24" /> + <Font name="VeneerHeaderFont" font="Fonts\FRIZQT__.TTF" outline="THICK" height="14" /> + <Font name="VeneerHeader2Font" font="Fonts\FRIZQT__.TTF" outline="THICK" height="14"> + <Color a="1" r="1" g="0.4" b="0" /> + </Font> + + <!-- generic animations --> + <Frame name="VeneerAnimations" virtual="true"> + <Animations> + <AnimationGroup parentKey="BlockFade" looping="NONE" setToFinalAlpha="false"> + <Alpha parentKey="alpha" order="1" duration="1" fromAlpha="0.5" toAlpha="1" /> + <Scripts> + <OnPlay> + VeneerAnimationMixin.OnPlay(self) + </OnPlay> + </Scripts> + </AnimationGroup> + </Animations> + </Frame> + + <!-- mixin map --> + <Frame name="VeneerMixinScripts" virtual="true"> + <Scripts> + <OnLoad method="OnLoad" /> + <OnEvent method="OnEvent" /> + <OnUpdate method="OnUpdate" /> + <OnShow method="OnShow" /> + <OnHide method="OnHide" /> + <OnMouseDown method="OnMouseDown" /> + <OnSizeChanged method="OnSizeChanged" /> + </Scripts> + </Frame> + + <!-- colored-border object with minimal frame scripts --> + <Frame name="VeneerStatusButtonTemplate" virtual="true"> + <Layers> + <Layer level="BORDER"> + <Texture parentKey="bg" setAllPoints="true" parentArray="ConfigLayers" hidden="true" /> + </Layer> + <Layer level="OVERLAY"> + <FontString parentKey="label" inherits="VeneerNumberFontLarge" parentArray="ConfigLayers" hidden="true"> + <Anchors> + <Anchor point="TOPLEFT" /> + </Anchors> + </FontString> + </Layer> + </Layers> + <Frames> + <Button parentKey="resize" parentArray="ConfigLayers" hidden="true"> + <Size x="48" y="16" /> + <Anchors> + <Anchor point="BOTTOMRIGHT" /> + </Anchors> + <NormalTexture setAllPoints="true"> + <Color a="1" r="1" g="1" b="1" /> + </NormalTexture> + <PushedTexture> + <Color a="1" r="1" g="0.5" b="1" /> + </PushedTexture> + </Button> + </Frames> + </Frame> + + <!-- same as above, but with a progress bar --> + <Frame name="VeneerStatusBarTemplate" virtual="true" hidden="true" inherits="VeneerMixinScripts"> + <Scripts> + <OnShow> + if self.OnShow then self:OnShow() end + if self.Header:IsVisible() then + self.ProgressBG:ClearAllPoints() + self.ProgressBG:SetPoint('TOP', self.GlowLine, 'BOTTOM', 0, -1) + self.ProgressBG:SetPoint('LEFT') + self.ProgressBG:SetPoint('RIGHT') + self.ProgressBG:SetPoint('BOTTOM') + else + self.ProgressBG:ClearAllPoints() + self.ProgressBG:SetAllPoints(self) + end + </OnShow> + <OnSizeChanged> + </OnSizeChanged> + </Scripts> + <Layers> + <Layer level="BACKGROUND"> + <Texture parentKey="UnderLay"> + + </Texture> + </Layer> + <Layer level="BORDER"> + <Texture parentKey="ProgressBG" setAllPoints="true"> + <Color a=".7" r="0" g="0" b="0" /> + </Texture> + <Texture parentKey="GlowLine" atlas="AftLevelup-GlowLine" useAtlasSize="false"> + <Size y="3" /> + <Anchors> + <Anchor point="TOPLEFT" x="-27" y="-11" /> + <Anchor point="RIGHT" x="27" y="0" /> + </Anchors> + </Texture> + </Layer> + <Layer level="ARTWORK"> + <Texture parentKey="ProgressBar"> + <Anchors> + <Anchor point="BOTTOMLEFT" /> + </Anchors> + <Color a="1" r=".7" g=".7" b=".7" /> + </Texture> + </Layer> + <Layer level="OVERLAY" > + <FontString parentKey="Header" inherits="VeneerNumberFontSmall"> + <Anchors> + <Anchor point="TOP" /> + </Anchors> + </FontString> + <FontString parentKey="Level" inherits="GameFontNormal"> + <Anchors> + <Anchor point="TOP" x="0" y="14" /> + </Anchors> + </FontString> + <FontString parentKey="ProgressText" inherits="VeneerNumberFont"> + <Anchors> + <Anchor point="CENTER" relativeKey="$parent.ProgressBG" /> + </Anchors> + </FontString> + </Layer> + </Layers> + </Frame> + + <Frame name="VeneerHandlerTemplate" inherits="VeneerAnimations" hidden="true" parent="UIParent" virtual="true"> + <Layers> + <Layer level="BACKGROUND"> + <Texture parentKey="Background" setAllPoints="true" parentArray="ConfigLayer"> + <Color a="0.5" r="0" g="0" b="0" /> + </Texture> + </Layer> + </Layers> + <Scripts> + <OnLoad method="OnLoad" />> + <OnEvent method="OnEvent" /> + <OnShow method="OnShow" /> + <OnHide method="OnHide" /> + </Scripts> + <Frames> + <Frame name="$parentConfigHandler" setAllPoints="true" mixin="VeneerConfigLayerMixin" enableMouse="true" parentArray="ConfigLayer"> + <Scripts> + <OnLoad method="OnLoad" /> + <OnShow method="OnShow" /> + <OnDragStart method="OnDragStart" /> + <OnDragStop method="OnDragStop" /> + <OnUpdate method="OnUpdate" /> + </Scripts> + <Layers> + <Layer level="OVERLAY"> + <FontString parentKey="ConfigName" parentArray="ConfigLayer" inherits="VeneerNumberFont"> + <Anchors> + <Anchor point="TOPLEFT" /> + </Anchors> + </FontString> + <FontString parentKey="ConfigID" parentArray="ConfigLayer" inherits="VeneerNumberFont"> + <Anchors> + <Anchor point="BOTTOMLEFT" /> + </Anchors> + </FontString> + <Texture setAllPoints="true" hidden="true"> + <Color a="0.25" r="0" g="1" b="0" /> + </Texture> + </Layer> + </Layers> + </Frame> + </Frames> + </Frame> + +</Ui> \ No newline at end of file
--- a/Veneer.lua Fri Oct 21 18:03:35 2016 -0400 +++ b/Veneer.lua Mon Oct 24 18:28:40 2016 -0400 @@ -7,8 +7,16 @@ SLASH_VENEER1 = "/veneer" SLASH_VENEER2 = "/vn" +local VENEER_VERSION = 703 SlashCmdList.VENEER = function(cmd) + + if Veneer.ConfigMode then + Veneer.ConfigMode = false + else + Veneer.ConfigMode = true + end + Veneer:UpdateConfigLayers() end VeneerCore = { @@ -17,20 +25,8 @@ FrameClusters = {}, parserDepth = 0, pendingCalls = {}, + AddOnCheck = {} } -VeneerHandlerMixin = { - - anchorPoint = 'CENTER', -- indicates the initial cluster group point - --anchorPath = 'BOTTOM', -- indicates the point from which the frame is anchored in a cluster arrangement - OnHide = function() - Veneer:DynamicReanchor() - end, - OnShow = function(self) - self:Reanchor() - Veneer:StaticReanchor(self) - end -} -VeneerAnimationMixin = {} local print = DEVIAN_WORKSPACE and function(...) print('Veneer', ...) end or nop local wipe = table.wipe @@ -42,7 +38,8 @@ BuffFrame = { width = 48, height = 48, - } + }, + ConfigMode = true } local configMode @@ -109,14 +106,36 @@ end +local select, IsAddOnLoaded, IsLoggedIn = select, IsAddOnLoaded, IsLoggedIn + function VeneerCore:OnEvent(event, ...) + print(event, ...) if event == 'ADDON_LOADED' or event == 'PLAYER_LOGIN' then + print(IsLoggedIn(), self.initialized) if IsLoggedIn() and not self.intialized then self:Setup() - self:UnregisterEvent('ADDON_LOADED') - self:UnregisterEvent('PLAYER_LOGIN') - self:Reanchor() - self:Update() + self.intialized = true + print('popping init sequence', self.intialized) + end + + + if self.intialized then + local addon = ... + if self.AddOnCheck[addon] then + print(' - setting up '..addon..' dependent modules:') + local keepChecking = false + for index, handler in ipairs(self.AddOnCheck[addon]) do + print(' -', handler:GetName(), (not handler.initialized) and (handler.addonFrame and not _G[handler.addonFrame])) + if not handler.initialized then + print(' '..handler:GetName()..':Setup()') + handler:Setup() + handler.initialized = true + end + end + if not keepChecking then + self.AddOnCheck[addon] = nil + end + end end end end @@ -130,18 +149,71 @@ end function VeneerCore:Setup () - self.initialized = true - if (not VeneerData) or (not VeneerData.version) then + local resetConfig = (not VeneerData) + if (not VeneerData) then VeneerData = defaults + VeneerData.version = VENEER_VERSION + self:print('Fresh install.') + elseif (VeneerData.version and VeneerData.version < VENEER_VERSION) then + local oldVars = VeneerData + VeneerData = defaults + VeneerData.version = VENEER_VERSION + VeneerData.oldSettings = oldVars + self:print('Resetting to temp defaults. Use /vn retro to use old settings.') end self.data = VeneerData - self:ExecuteOnClusters(nil, 'Setup') + self:ExecuteOnClusters(nil, function(frame) + if (not frame.addonTrigger) or select(2,IsAddOnLoaded(frame.addonTrigger)) then + if not frame.initialized then + frame:Setup() + frame.initialized = true + end + end + end) + + self.ConfigMode = VeneerData.ConfigMode + self:UpdateConfigLayers() + self:Reanchor() + self:Update() end +function VeneerCore:UpdateConfigLayers() + if VeneerData then + + VeneerData.ConfigMode = self.ConfigMode + end + + self:print('Config mode '..(self.ConfigMode and '|cFF00FF00ON|r' or '|cFFFF0000OFF|r')..'.') + self:ExecuteOnClusters(nil, function(frame) + if frame.UpdateConfigLayers then + frame:UpdateConfigLayers(self.ConfigMode) + end + + + if type(frame.ConfigLayer) == 'table' then + for index, region in ipairs(frame.ConfigLayer) do + print('setting', frame:GetName() .. '['.. index..']', 'to', self.ConfigMode) + + region:SetShown(self.ConfigMode) + end + end + + self.ConfigLayers[frame] = frame:IsShown() + if self.ConfigMode then + print(frame:GetName(), self.ConfigLayers[frame]) + frame:SetShown(self.ConfigMode) + else + frame:SetShown(self.ConfigLayers[frame]) + end + end) +end function VeneerCore:GetClusterFromArgs (...) local primaryAnchor local insertPosition + + + local clusterTable = self.FrameClusters for i = 1, select('#', ...) do local arg = select(i, ...) @@ -169,13 +241,15 @@ function VeneerCore:AddHandler(handler, ...) print('*** Adding handler:', handler.moduleName or handler:GetName()) - local anchorGroup, clusterTable, clusterIndex = self:GetClusterFromArgs(...) - if clusterIndex == 1 then - for i, frame in ipairs(clusterTable) do - frame.clusterIndex = i + 1 + + local anchorGroup, clusterTable, clusterIndex = self:GetClusterFromArgs(...) + if clusterIndex == 1 then + for i, frame in ipairs(clusterTable) do + frame.clusterIndex = i + 1 + end end - end - tinsert(clusterTable, clusterIndex, handler) + tinsert(clusterTable, clusterIndex, handler) + print('cluster', anchorGroup, 'table', clusterTable, 'position', clusterIndex) handler.anchorCluster = clusterTable @@ -186,13 +260,28 @@ handler[k] = v end end + + if handler.addonTrigger and not IsAddOnLoaded(handler.addonTrigger) then + print('|cFFFF4400 -- dependency:', handler.addonTrigger) + self.AddOnCheck[handler.addonTrigger] = self.AddOnCheck[handler.addonTrigger] or {} + tinsert(self.AddOnCheck[handler.addonTrigger], handler) + end + if self.initialized then - print(' -- doing initialization') - if handler.Setup and not handler.initialized then - handler:Setup() - handler.initialized = true + print(' -- initialization check') + if handler.Setup then + local doInit = (not handler.initialized) + if handler.addonTrigger and not IsAddOnLoaded(handler.addonTrigger) then + doInit = false + end + -- room to add other checks + + if doInit then + handler:Setup() + handler.initialized = true + self:InternalReanchor(handler) + end end - self:InternalReanchor(handler) end end @@ -202,7 +291,11 @@ end function VeneerCore:Update() - self:ExecuteOnClusters(nil, 'Update') + self:ExecuteOnClusters(nil, function(frame) + if frame.initialized and frame.Update then + frame:Update() + end + end) self:Reanchor() end @@ -219,16 +312,24 @@ for anchorPoint, cluster in pairs(parent.FrameClusters) do local lastFrame for index, frame in ipairs(cluster) do - print(' |cFF00FF00'..index, frame:GetName(), frame:IsVisible()) + print(' |cFF00FF00'..index, frame:GetName(), frame:IsVisible(), (lastFrame and ('|cFFFFFF00'..lastFrame:GetName()..'|r') or '|cFF00FFFFUIParent')) if frame:IsVisible() then - anchorPoint = frame.anchorPoint - frame:ClearAllPoints() - if lastFrame then - frame:SetPoint(anchorPoint, lastFrame, ANCHOR_OFFSET_POINT[anchorPoint], 0, 0) + + if frame.anchorFrame then + frame:SetPoint(frame.anchorPoint, frame.anchorFrame, frame.anchorFrom, frame.anchorX, frame.anchorY) + print(frame:GetTop(), frame:GetRight()) else - frame:SetPoint(anchorPoint, UIParent, anchorPoint, 0, 0) + anchorPoint = frame.anchorPoint + frame:ClearAllPoints() + if lastFrame then + frame:SetPoint(anchorPoint, lastFrame, ANCHOR_OFFSET_POINT[anchorPoint], 0, 0) + else + frame:SetPoint(anchorPoint, UIParent, anchorPoint, frame.anchorX, frame.anchorY) + end + print(frame:GetTop(), frame:GetRight()) + lastFrame = frame end - lastFrame = frame + end end @@ -238,6 +339,12 @@ -- Evaluates the current visibility state and re-anchors adjacent blocks accordingly function VeneerCore:InternalReanchor(handler, printFunc) print('|cFF00FFFFVeneer:InternalReanchor('..handler:GetName()..')') + if handler.anchorFrame then + handler:SetPoint(handler.anchorPoint, handler.anchorFrame, handler.anchorFrom, handler.anchorX, handler.anchorY) + return + end + + local anchorPoint = handler.anchorPath or handler.anchorPoint local anchorParent, anchorTo = UIParent, anchorPoint local subPoint, subTo @@ -304,7 +411,7 @@ print('delaying walk for', method) return end - print('|cFF00FF00Veneer:ExecuteOnClusters|r('..tostring(layer)..', '..method..')') + print('|cFF00FF00Veneer:ExecuteOnClusters|r('..tostring(layer)..', '..tostring(method)..')') else print(' Level '..self.parserDepth) end @@ -313,7 +420,9 @@ for anchor, cluster in pairs(layer) do for index, frame in ipairs(cluster) do print(' '..anchor..'.'..index..' = '..frame:GetName()) - if frame[method] then + if type(method) == 'function' then + method(frame, true) + elseif frame[method] then print(' |cFF00FF00'..frame:GetName()) frame[method](frame, true) end @@ -331,102 +440,7 @@ end end -local VeneerButton_OnDragStart = function(self) - self.startingLeft = self:GetLeft() - self.startingBottom = self:GetBottom() - self.anchors = self.anchors or {} - table.wipe(self.anchors) - local frame = self:GetParent() - local n = frame:GetNumPoints() - for i = 1, n do - local anchor, parent, relative, x, y = frame:GetPoint(i) - self.anchors[i] = { - anchor = anchor, - parent = parent, - relative = relative, - x = x, - y = y - } - end - - print(self:GetName(), 'start moving', self.startingLeft, self.startingBottom) - self:StartMoving() -end - -local VeneerButton_OnDragStop = function(self) - self:StopMovingOrSizing() - if self.OnDragStop then - self.OnDragStop(self) - else - local frame = self:GetParent() - local dx = self:GetLeft() - self.startingLeft - local dy = self:GetBottom() - self.startingBottom - - frame:ClearAllPoints() - for i, point in ipairs(self.anchors) do - frame:SetPoint(point.anchor, point.parent, point.relative, point.x + dx, point.y + dy) - print('adjusting anchor', point.anchor, point.parent, point.relative, point.x + dx, point.y + dy) - end - end -end - -local Veneer_FixMovers = function() - for frame, veneer in pairs(veneers) do - if veneer:IsMoving() then - VeneerButton_OnDragStop(veneer) - end - end -end - -local VeneerButton_Update = function(self) - if configMode then - self:SetScript('OnDragStart', VeneerButton_OnDragStart) - self:SetScript('OnDragStop', VeneerButton_OnDragStop) - self:SetMovable(true) - self:EnableMouse(true) - self:RegisterForDrag('LeftButton') - - self.bg:SetColorTexture(0,1,0,0.5) - for i, region in ipairs(self.configLayers) do - region:Show() - end - self:Show() - else - - self:SetScript('OnDragStart', self.StartMoving) - self:SetScript('OnDragStop', self.StopMovingOrSizing) - self:SetMovable(false) - self:EnableMouse(false) - - self.bg:SetColorTexture(0,1,0,0) - for i, region in ipairs(self.configLayers) do - region:Hide() - end - if self.isHidden then - self:Hide() - end - - end -end - -local ToggleVeneerConfig = function() - if configMode then - configMode = false - Veneer:print('Config mode off.') - else - configMode = true - Veneer:print('Config mode on.') - end - - for frame, veneer in pairs(veneers) do - VeneerButton_Update(veneer) - end -end - -local VeneerButton_OnShow = function(self) - VeneerButton_Update(self) -end -- Takes frame handle and assigns a block to it function VeneerCore:Acquire (frame, template) @@ -437,8 +451,8 @@ local veneer = self.Frames[frame] if not veneer then local name = type(frame) == 'table' and GetTableName(frame) or GetAnonymousName() - veneer = CreateFrame('Frame', name, frame, template or 'VeneerTemplate') - print('+veneer', name) + veneer = CreateFrame('Frame', name, frame, template or 'VeneerStatusButtonTemplate') + print(self:GetName()..':Acquire()', frame:GetName(), template) veneer:SetAllPoints(frame) veneer:SetParent(frame) @@ -446,37 +460,10 @@ veneer.bg:SetColorTexture(0,0,0,0) veneer:Hide() veneer:EnableMouse(false) - - veneer:SetScript('OnShow', VeneerButton_OnShow) - -- find current X/Y veneer.currentLeft = frame:GetLeft() veneer.currentTop = frame:GetTop() self.Frames[frame] = veneer end - return veneer -end - -function VeneerHandlerMixin:Reanchor (anchorAll) - if not anchorAll then - Veneer:InternalReanchor(self) - end - -end - -function VeneerAnimationMixin:OnPlay() - PlaySoundKitID(229) - self.animating = true - print('|cFF00FF00Anim:OnPlay|r @', unpack(self.sourcePoint)) -end -function VeneerAnimationMixin:OnStop() - PlaySoundKitID(229) - self.animating = nil - print('|cFF00FF00Anim:OnFinish|r @', unpack(self.destPoint)) -end -function VeneerAnimationMixin:OnFinished() - PlaySoundKitID(229) - self.animating = nil - print('|cFF00FF00Anim:OnFinish|r @', unpack(self.destPoint)) end \ No newline at end of file
--- a/Veneer.toc Fri Oct 21 18:03:35 2016 -0400 +++ b/Veneer.toc Mon Oct 24 18:28:40 2016 -0400 @@ -13,4 +13,5 @@ ##Options.lua ##Modules\PaperDoll.lua Modules\WorldState.xml +Modules\TalkingHead.xml Modules\BuffFrame.xml \ No newline at end of file
--- a/Veneer.xml Fri Oct 21 18:03:35 2016 -0400 +++ b/Veneer.xml Mon Oct 24 18:28:40 2016 -0400 @@ -2,45 +2,13 @@ ..\FrameXML\UI.xsd"> <Script file="Veneer.lua" /> + <Include file="Templates.xml" /> - <Font name="VeneerFont" /> - <Font name="VeneerFont_Small" font="Fonts\FRIZQT__.TTF" outline="NORMAL" height="16" /> - <Font name="VeneerFont_Large" font="Fonts\FRIZQT__.TTF" outline="NORMAL" height="24" /> - <Font name="VeneerNumberFontSmall" font="Fonts\ARIALN.ttf" outline="NORMAL" height="12" /> - <Font name="VeneerNumberFont" font="Fonts\ARIALN.ttf" outline="NORMAL" height="14" /> - <Font name="VeneerNumberFontLarge" font="Fonts\ARIALN.ttf" outline="NORMAL" height="24" /> - <Font name="VeneerHeaderFont" font="Fonts\FRIZQT__.TTF" outline="THICK" height="14" /> - <Font name="VeneerHeader2Font" font="Fonts\FRIZQT__.TTF" outline="THICK" height="14"> - <Color a="1" r="1" g="0.4" b="0" /> - </Font> - <Frame name="VeneerAnimations" virtual="true"> - <Animations> - <AnimationGroup parentKey="BlockFade" looping="NONE" setToFinalAlpha="false"> - <Alpha parentKey="alpha" order="1" duration="1" fromAlpha="0.5" toAlpha="1" /> - <Scripts> - <OnPlay> - VeneerAnimationMixin.OnPlay(self) - </OnPlay> - </Scripts> - </AnimationGroup> - </Animations> - </Frame> - <Frame name="VeneerMixinScripts" virtual="true"> - <Scripts> - <OnLoad method="OnLoad" /> - <OnEvent method="OnEvent" /> - <OnUpdate method="OnUpdate" /> - <OnShow method="OnShow" /> - <OnHide method="OnHide" /> - <OnMouseDown method="OnMouseDown" /> - <OnSizeChanged method="OnSizeChanged" /> - </Scripts> - </Frame> <Frame name="Veneer" inherits="VeneerMixinScripts" mixin="VeneerCore" hidden="true" enableMouse="true" movable="true" frameStrata="DIALOG"> <Size x="400" y="400" /> @@ -111,101 +79,5 @@ </Frames> </Frame> - <Frame name="VeneerTemplate" virtual="true"> - <Layers> - <Layer level="BORDER"> - <Texture parentKey="bg" setAllPoints="true" parentArray="configLayers" /> - </Layer> - <Layer level="OVERLAY"> - <FontString parentKey="label" inherits="VeneerNumberFontLarge" parentArray="configLayers"> - <Anchors> - <Anchor point="TOPLEFT" /> - </Anchors> - </FontString> - </Layer> - </Layers> - <Frames> - <Button parentKey="resize" parentArray="configLayers"> - <Size x="48" y="16" /> - <Anchors> - <Anchor point="BOTTOMRIGHT" /> - </Anchors> - <NormalTexture setAllPoints="true"> - <Color a="1" r="1" g="1" b="1" /> - </NormalTexture> - <PushedTexture> - <Color a="1" r="1" g="0.5" b="1" /> - </PushedTexture> - </Button> - </Frames> - </Frame> - - - - <Frame name="VeneerStatusBarTemplate" virtual="true" hidden="true" inherits="VeneerMixinScripts"> - <Scripts> - <OnShow> - if self.OnShow then self:OnShow() end - if self.Header:IsVisible() then - self.ProgressBG:ClearAllPoints() - self.ProgressBG:SetPoint('TOP', self.GlowLine, 'BOTTOM', 0, -1) - self.ProgressBG:SetPoint('LEFT') - self.ProgressBG:SetPoint('RIGHT') - self.ProgressBG:SetPoint('BOTTOM') - else - self.ProgressBG:ClearAllPoints() - self.ProgressBG:SetAllPoints(self) - end - </OnShow> - <OnSizeChanged> - </OnSizeChanged> - </Scripts> - <Layers> - <Layer level="BACKGROUND"> - <Texture parentKey="UnderLay"> - - </Texture> - </Layer> - <Layer level="BORDER"> - <Texture parentKey="ProgressBG" setAllPoints="true"> - <Color a=".7" r="0" g="0" b="0" /> - </Texture> - <Texture parentKey="GlowLine" atlas="AftLevelup-GlowLine" useAtlasSize="false"> - <Size y="3" /> - <Anchors> - <Anchor point="TOPLEFT" x="-27" y="-11" /> - <Anchor point="RIGHT" x="27" y="0" /> - </Anchors> - </Texture> - </Layer> - <Layer level="ARTWORK"> - <Texture parentKey="ProgressBar"> - <Anchors> - <Anchor point="BOTTOMLEFT" /> - </Anchors> - <Color a="1" r=".7" g=".7" b=".7" /> - </Texture> - </Layer> - <Layer level="OVERLAY" > - <FontString parentKey="Header" inherits="VeneerNumberFontSmall"> - <Anchors> - <Anchor point="TOP" /> - </Anchors> - </FontString> - <FontString parentKey="Level" inherits="GameFontNormal"> - <Anchors> - <Anchor point="TOP" x="0" y="14" /> - </Anchors> - </FontString> - <FontString parentKey="ProgressText" inherits="VeneerNumberFont"> - <Anchors> - <Anchor point="CENTER" relativeKey="$parent.ProgressBG" /> - </Anchors> - </FontString> - </Layer> - </Layers> - </Frame> - - </Ui> \ No newline at end of file