Mercurial > wow > buffalo2
changeset 75:d9d16e67725c
- refactor objectives plugin
author | Nenue |
---|---|
date | Sat, 27 Aug 2016 07:09:54 -0400 |
parents | cd6e78091b04 |
children | 83b3cdaae6a5 |
files | Modules/BuffFrame.lua Modules/PaperDoll.lua Options.lua Veneer.lua Veneer.toc Veneer.xml |
diffstat | 6 files changed, 229 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/Modules/BuffFrame.lua Tue Aug 23 19:50:10 2016 -0400 +++ b/Modules/BuffFrame.lua Sat Aug 27 07:09:54 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 = 4 local BUFF_BUTTON_SPACING_V = 14 @@ -21,10 +22,12 @@ local BORDER_SIZE_R = 0 local BORDER_SIZE_U = 4 local BORDER_SIZE_D = 0 +local BUFF_FRAMES_X = -230 +local BUFF_FRAMES_Y = -4 local plugin = CreateFrame('Frame', 'VeneerBuffFrame', UIParent) -local vn, print = LibStub("LibKraken").register(VeneerController, plugin) +local vn, print = LibStub("LibKraken").register(Veneer, plugin) local tprint = DEVIAN_WORKSPACE and function(...) _G.print('Timer', ...) end or function() end local _G, UIParent = _G, UIParent @@ -33,44 +36,42 @@ local UnitAura, GetTime, CreateFrame = UnitAura, GetTime, CreateFrame local hooksecurefunc = hooksecurefunc -local buttons = {} -local buffTypes = { +local aurasCache = {} +local skinnedFrames = {} +local pendingFrames = {} +local veneers = {} +local expirationCache = {} +local visibility = {} +local isHooked = {} + +plugin.options = { + nameString = 'Buff Frames', { - name = 'buff', - pattern = 'BuffButton(%d)', - filters = 'HELPFUL', + name = 'BuffButtonZoom', + type = 'slider', + min = 0, + max = 100, + fullwidth = true, }, { - name = 'debuff', - pattern = 'DebuffButton(%d)', - filters = 'HARMFUL', + name = 'BuffBorderLeft', + type = 'slider', + min = 0, + max = 16, }, { - name = 'tempenchant', - pattern = 'TempEnchant(%d)', - filters = 'TEMPENCHANT' + name = 'BuffBorderLeft', + type = 'slider', + min = 0, + max = 16, } } -local textureMapping = { - [1] = 16, --Main hand - [2] = 17, --Off-hand - [3] = 18, --Ranged -} - -local tickCounter = {} -local aurasCache = {} -local skinnedFrames = {} -local pendingFrames = {} -local anchors = {} -local expirationCache = {} -local visibility = {} - - local GetVeneer = function(frame) - local name = frame:GetName() - if not (_G[name..'Veneer']) then + + if not (veneers[frame]) then + local name = frame:GetName() print('|cFF88FF00Creating', name,'Veneer') local veneer = vn.GetVeneer(frame, 'VeneerBuffTemplate') local id = frame:GetID() @@ -80,7 +81,10 @@ veneer.progress:SetPoint('TOPRIGHT', veneer, 'BOTTOMRIGHT', 0, -1) veneer.progress:SetHeight(BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2)) - veneer.progress.fg:SetColorTexture(0,1,0,1) + veneer.progress.bg:SetColorTexture(0,0,0,1) + + veneer.progress.fg:SetColorTexture(1,1,1,1) + veneer.progress.fg:ClearAllPoints() veneer.progress.fg:SetPoint('BOTTOMLEFT', BUFF_PROGRESS_INSET,BUFF_PROGRESS_INSET) veneer.progress.fg:SetPoint('TOP', 0, -BUFF_PROGRESS_INSET) @@ -100,10 +104,11 @@ veneer.border:Show() + veneers[frame] = veneer end - return _G[name..'Veneer'] + return veneers[frame] end @@ -141,7 +146,7 @@ end veneer.progress.fg:SetColorTexture(color.r,color.g,color.b) - veneer.border:SetColorTexture(color.r,color.g,color.b) + veneer.border:SetColorTexture(0,0,0,1) end if duration then duration:ClearAllPoints() @@ -205,12 +210,8 @@ veneer.underlay:Show() end) - anchors[frame] = veneer end -local Aura_SetBorderColor = function(self, r,g,b,a) end -local Aura_OnShow = function(self) end -local Aura_OnHide = function(self) end --- Set widgets to reflect the passed parameters local UpdateVeneer = function (frame, duration, expires) @@ -294,7 +295,6 @@ local bName = name..index local frame = _G[bName] if frame and frame:IsVisible() then - tickCounter[frame] = (tickCounter[frame] or 0) + 1 local cacheDiff = CacheCheck(frame, UnitAura(frame.unit, frame:GetID(), frame.filter)) -- if the name or expirationTime changed if (cacheDiff >= 1) then @@ -338,9 +338,9 @@ if buff then numBuffs = numBuffs + 1 buff:ClearAllPoints() - if mod(numBuffs,12) == 1 then + if mod(numBuffs,BUFFS_PER_ROW) == 1 then if numBuffs == 1 then - buff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', -120, -6) + buff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', BUFF_FRAMES_X, BUFF_FRAMES_Y) plugin.currentTop = buff:GetTop() else buff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -BUFF_BUTTON_SPACING_V) @@ -365,7 +365,7 @@ debuff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', -120, -6) end topBuff = debuff - elseif mod(numBuffs, 12) == 1 then + elseif mod(numBuffs, BUFFS_PER_ROW) == 1 then debuff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -BUFF_BUTTON_SPACING_V) topBuff = debuff else @@ -398,7 +398,7 @@ if not veneer.duration.getHuge then veneer.duration.getHuge = true veneer.duration:SetFontObject(VeneerNumberFontLarge) - veneer.duration:SetTextColor(1,0,0,1) + veneer.duration:SetTextColor(1,1,0,1) end else if veneer.duration.getHuge then
--- a/Modules/PaperDoll.lua Tue Aug 23 19:50:10 2016 -0400 +++ b/Modules/PaperDoll.lua Sat Aug 27 07:09:54 2016 -0400 @@ -6,7 +6,7 @@ -- Requires tooltip scraping to obtain these numbers, meaning any currently active tooltip will be cleared. local plugin = CreateFrame('Frame', 'VeneerPaper', UIParent) -local vn, print = LibStub("LibKraken").register(VeneerController, plugin) +local vn, print = LibStub("LibKraken").register(Veneer, plugin) local slot_anchors = { [1] = 'TOPLEFT',
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Options.lua Sat Aug 27 07:09:54 2016 -0400 @@ -0,0 +1,162 @@ + +local vn, print = LibStub("LibKraken").register(Veneer, "Options") +local plugin = CreateFrame('Frame', 'VeneerOptions', UIParent, 'TooltipBorderedFrameTemplate') +vn.wrap(plugin) + + +local fields = {} +local templateTypes = { + slider = 'Slider', + radio = 'Frame', + number = 'EditBox', + check = 'CheckButton' +} +local templateNames = { + slider = 'OptionsSliderTemplate', + radio = '', + number = 'NumericInputSpinnerTemplate', + check = 'UICheckButtonTemplate' +} +local OnLoad, OnUpdate, OnValueChanged = {}, {}, {} +local frameHeadings = {} + +local framePadding = 14 +local frameMaxWidth = 400 + + +local ToggleVeneerOptions = function() + + plugin:Show() + if plugin.initialized then + return + end + + local sizeChanged = false + local frameDepth = framePadding + local frameWidth = framePadding + local lineWidth = framePadding + local lineNum = 1 + local lineColumn = 1 + + for i, module in ipairs(vn.modules) do + if module.options then + if not frameHeadings[module] then + frameHeadings[module] = plugin:CreateFontString(nil, 'OVERLAY', 'VeneerNumberFontLarge') + frameHeadings[module]:SetText(module.options.nameString or module:GetName()) + frameHeadings[module].height = frameHeadings[module]:GetHeight() + + frameHeadings[module]:SetPoint('TOPLEFT', plugin, 'TOPLEFT', lineColumn, -frameDepth) + frameDepth = frameDepth + frameHeadings[module].height + end + + for index, args in ipairs(module.options) do + local fullIndex = (i*1000)+index + print('config field', fullIndex) + if not fields[fullIndex] then + fields[fullIndex] = {} + end + local opt = fields[fullIndex] + + if not opt.frame then + sizeChanged = true + + local configType = args.type + print('Creating', templateTypes[configType] or 'Frame', 'from', templateNames[configType]) + opt.frame = CreateFrame(templateTypes[configType] or 'Frame', 'VeneerOptions' .. args.name, plugin, templateNames[configType]) + + if OnLoad[configType] then + OnLoad[configType](opt.frame, args) + end + if opt.OnLoad then + opt.OnLoad(opt.frame) + end + + if args.OnUpdate then + opt.frame.Update = function(self) + OnUpdate[configType](self, args) + args.OnUpdate(self, args) + end + else + opt.frame.Update = function(self) + OnUpdate[configType](self, args) + end + end + + opt.frame:Update() + + opt.frame:SetPoint('TOPLEFT', plugin, 'TOPLEFT', lineColumn, -frameDepth) + + + opt.name = args.name + opt.line = lineNum + opt.column = lineColumn + + -- measure after initializer + frameDepth = frameDepth + opt.frame:GetHeight() + lineWidth = lineWidth + opt.frame:GetWidth() + opt.depth = frameDepth + opt.width = lineWidth + local isOverlapped = (lineWidth > frameMaxWidth) + if args.fullwidth or isOverlapped then + lineNum = lineNum + 1 + if isOverlapped then + lineWidth = framePadding + opt.frame:GetWidth() + lineColumn = 1 + else + lineWidth = framePadding + lineColumn = lineColumn + 1 + end + end + + if lineWidth > frameWidth then + sizeChanged = true + frameWidth = lineWidth + end + + + end + + + + + + + end + end + end + + if sizeChanged then + plugin:SetSize(frameWidth + framePadding, frameDepth + framePadding) + + plugin:SetPoint('CENTER') + end + +end + +OnLoad.slider = function(self, args) + print('min:', args.min, 'max:', args.max, 'steps:', args.step) + self:SetMinMaxValues(args.min or 0, args.max or 420) + self:SetValueStep(1) + self:SetStepsPerPage(5) + self:SetObeyStepOnDrag(true) +end + +OnUpdate.slider = function(self, args) + local base = args.handler or vn.db + self:SetValue(vn.db[self.name] or 1) +end + +OnValueChanged.slider = function() +end + +plugin.cmd = function(cmd) + cmd = string.lower(cmd) + if cmd:match('config') then + ToggleVeneerOptions() + return true + end +end + +plugin.init = function() + --ToggleVeneerOptions() +end
--- a/Veneer.lua Tue Aug 23 19:50:10 2016 -0400 +++ b/Veneer.lua Sat Aug 27 07:09:54 2016 -0400 @@ -1,7 +1,7 @@ -- Veneer -- Base framework for making things draggable. -local vn, print = LibStub("LibKraken").register(VeneerController) +local vn, print = LibStub("LibKraken").register(Veneer) local defaults = { @@ -178,6 +178,15 @@ SLASH_VENEER1 = "/veneer" SLASH_VENEER2 = "/vn" -SlashCmdList.VENEER = function() +SlashCmdList.VENEER = function(cmd) + for i, module in pairs(vn.modules) do + if module.cmd then + local result = module.cmd(cmd) + if result then + return + end + end + end + ToggleVeneerConfig() end \ No newline at end of file
--- a/Veneer.toc Tue Aug 23 19:50:10 2016 -0400 +++ b/Veneer.toc Sat Aug 27 07:09:54 2016 -0400 @@ -10,6 +10,7 @@ ## OptionalDeps: Devian Veneer.xml +Options.lua Modules\BuffFrame.lua Modules\PaperDoll.lua Modules\ObjectiveTracker.lua \ No newline at end of file
--- a/Veneer.xml Tue Aug 23 19:50:10 2016 -0400 +++ b/Veneer.xml Sat Aug 27 07:09:54 2016 -0400 @@ -3,12 +3,18 @@ <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="VeneerController" hidden="true" enableMouse="true" movable="true" parent="UIParent" frameStrata="DIALOG"> + <Frame name="Veneer" hidden="true" enableMouse="true" movable="true" parent="UIParent" frameStrata="DIALOG"> <Size x="400" y="400" /> <Anchors> <Anchor point="CENTER" relativePoint="CENTER" x="0" y="0" /> @@ -132,7 +138,9 @@ </Layers> </Frame> <Cooldown name="$parentCooldown" parentKey="cooldown" inherits="CooldownFrameTemplate" reverse="true" setAllPoints="true"> - + <EdgeTexture> + <Color a="0" r="0" g="0" b="0" /> + </EdgeTexture> </Cooldown> <Frame name="$parentProgress" parentKey="progress" frameStrata="MEDIUM"> <Layers> @@ -151,6 +159,9 @@ </Frames> </Frame> + + + <Script file="Veneer.lua" /> </Ui> \ No newline at end of file