# HG changeset patch # User Nenue # Date 1459423925 14400 # Node ID 3397aae1f44d9da197064aed9f81786778eebd2d # Parent a2396b03ce633a6962cf09ad47ffcb9e14f43a50 - use the correct key value when searching for action buttons - handle pre-built frames from XML diff -r a2396b03ce63 -r 3397aae1f44d Core.xml --- a/Core.xml Thu Mar 31 01:38:47 2016 -0400 +++ b/Core.xml Thu Mar 31 07:32:05 2016 -0400 @@ -393,7 +393,7 @@ - + diff -r a2396b03ce63 -r 3397aae1f44d Init.lua --- a/Init.lua Thu Mar 31 01:38:47 2016 -0400 +++ b/Init.lua Thu Mar 31 07:32:05 2016 -0400 @@ -6,7 +6,7 @@ local ADDON, A = ... Veneer = Veneer or CreateFrame('Frame', 'Veneer', UIParent) local B = Veneer -local wipe, min, max, random, tinsert = table.wipe, math.min, math.max, math.random, table.insert +local wipe, min, max, random, tinsert, tremove = table.wipe, math.min, math.max, math.random, table.insert, table.remove local pairs, ipairs, select, unpack, _G = pairs, ipairs, select, unpack, _G local type, tostring, format = type, tostring, string.format A.frame = B @@ -15,6 +15,7 @@ local initOnced local modules = {} local queuedModules = {} +local checkForConfig = {} local moduleStack = { } @@ -247,6 +248,16 @@ --@end-non-debug@]===] end end + + + if #checkForConfig >= 1 then + local queuedFrame = tremove(checkForConfig) + while queuedFrame do + B.SetConfigLayers(queuedFrame) + B.InitXMLFrame(queuedFrame) + queuedFrame = tremove(checkForConfig) + end + end -- remove from existing end @@ -296,6 +307,7 @@ module = CreateFrame('Frame', 'Veneer' .. tostring(name) .. 'Handler', B, 'VeneerHandlerTemplate') end modules[name] = module + B[name] = module if select('#', ...) >= 1 then local numDeps = select('#', ...) print(' '..numDeps..' deps detected') @@ -331,6 +343,7 @@ end B.RemoveConfigLayers = function(frame) + local print = B.fprint() print('|cFFFF0000RemoveConfigLayers', frame:GetName()) for i, subframe in pairs(layers) do @@ -368,4 +381,45 @@ end print('['..func..'] updated', #layers, 'regions,', numAnchors, 'frames') +end + +--- Generic handlers for keeping track of XML-defined frames +B.OnLoad = function(self) + tinsert(checkForConfig, self) +end + +B.InitXMLFrame = function(self) + print('|cFF00FF00hello from '..self:GetName()) + + self:RegisterForDrag('LeftButton') + if not B.Conf.FramePosition then + B.Conf.FramePosition = {} + end + if B.Conf.FramePosition[self:GetName()] then + print('restoring frame position', unpack(B.Conf.FramePosition[self:GetName()])) + self:ClearAllPoints() + local anchorTo, relativePoint, x, y = unpack(B.Conf.FramePosition[self:GetName()]) + self:SetPoint(anchorTo, UIParent, relativePoint, x, y) + end +end + +B.OnDragStart = function(self) + self.xA = self:GetLeft() + self.yA = self:GetBottom() + self.anchorTo, self.relativeTo, self.relativePoint, self.x, self.y = self:GetPoint(1) + print('acquire anchor', self:GetPoint(1)) + print(self:GetName(), 'start moving ('..self.x..', '..self.y..')') + self:StartMoving() +end + +B.OnDragStop = function(self) + print(self:GetName(), 'stop moving ('..self:GetLeft()..', '..self:GetBottom()..')') + local xB = self:GetLeft() - self.xA + local yB = self:GetBottom() - self.yA + print('storing anchor point', self.anchorTo, self.relativePoint, self.x + xB, self.y + yB) + + self:StopMovingOrSizing() + B.Conf.FramePosition[self:GetName()] = {self.anchorTo, self.relativePoint, self.x + xB, self.y + yB} + B.InitXMLFrame(self) + end \ No newline at end of file diff -r a2396b03ce63 -r 3397aae1f44d ObjectiveFrame.lua --- a/ObjectiveFrame.lua Thu Mar 31 01:38:47 2016 -0400 +++ b/ObjectiveFrame.lua Thu Mar 31 07:32:05 2016 -0400 @@ -54,7 +54,7 @@ }, ObjectiveHeaderStyle = { Normal = { - Gradient = {MinColor = {0,0,0,0.5}, MaxColor = {0,0,0,1}}, + Gradient = {MinColor = {0,0,0,0.5}, MaxColor = {0,0,0,.25}}, Font = {headerFont, headerSize, headerOutline}, Spacing = headerSpacing, } }, @@ -109,6 +109,13 @@ } } +local FontBank = { + ['Normal'] = VeneerCriteriaFontNormal, + ['Progress'] = VeneerCriteriaFontProgress, + ['Complete'] = VeneerCriteriaFontComplete, + ['Failed'] = VeneerCriteriaFontFailed, +} + local Scroller_OnShow = function() Wrapper.watchMoneyReasons = 0; mod.UpdateWrapper() @@ -227,16 +234,17 @@ if rest then XPBar.rested:ClearAllPoints() if xp == 0 then - XPBar.rested:SetPoint('LEFT', XPBar, 'LEFT', 0, 0) + XPBar.rested:SetPoint('TOPLEFT', XPBar, 'TOPLEFT', 0, 0) else - XPBar.rested:SetPoint('LEFT', XPBar.fg, 'RIGHT', 0, 0) + XPBar.rested:SetPoint('TOPLEFT', XPBar.fg, 'TOPRIGHT', 0, 0) end if (xp + rest) > xpmax then - XPBar.rested:SetPoint('RIGHT', XPBar, 'RIGHT', 0, 0) + XPBar.rested:SetPoint('BOTTOMRIGHT', XPBar, 'BOTTOMRIGHT', 0, 0) else - XPBar.rested:SetWidth((xp/xpmax) * XPBar:GetWidth()) + XPBar.rested:SetWidth((rest/xpmax) * XPBar:GetWidth()) end + XPBar.rested:SetPoint('BOTTOM', XPBar, 'BOTTOM') XPBar.rested:Show() else XPBar.rested:Hide() @@ -367,19 +375,56 @@ elseif info.numObjectives >= 1 then t.objectives:Show() print(' - objective lines:', info.numObjectives, 'can wrap:', t.objectives:CanWordWrap()) + local text = '' + if info.description then + print(' -- has description text:', select('#', info.description), info.description) + text = info.description + end + + --- todo: implement objective displays + -- in an accumulator loop, call upon handler for the appropriate display frame, each defining: + -- * height of whatever display widget is involved in conveying the task + -- * number of non-wrapped text lines to account for line space; may be discarded depending on things + -- * boolean that determines listening for money events or not + t.attachmentHeight = 0 for o, obj in ipairs(t.info.objectives) do - local line = obj.text - if obj.type == 'monster' then - line = '|cFFFFFF00' .. line .. '|r' - elseif obj.type == 'item' then - line = '|cFF44BBFF' .. line .. '|r' - elseif obj.type == 'object' then - line = '|cFFFFFFFF' .. line .. '|r' + --- achievement criteria + if obj.flags then + + if bit.band(obj.flags, 0x00000001) > 0 then + obj.type = 'ProgressBar' + obj.widget = mod.SetWidget(obj, info) + elseif bit.band(obj.flags, 0x00000002) then + obj.type = 'Hidden' + obj.widget = nil + else + obj.type = 'Text' + obj.widget = nil + text = text .. ((text == '') and "" or "\n") .. obj.text + end + + print(obj.type, obj.text, obj.quantityString) + --- none of the above (most quests) + else + local line = obj.text + if obj.type == 'monster' then + line = '|cFFFFFF00' .. line .. '|r' + elseif obj.type == 'item' then + line = '|cFF44BBFF' .. line .. '|r' + elseif obj.type == 'object' then + line = '|cFFFFFFFF' .. line .. '|r' + end + text = text .. ((text == '') and "" or "\n") .. line end - text = text .. ((text == '') and "" or "\n") .. line + + if obj.widget then + t.attachmentHeight = t.attachmentHeight + obj.widget.height + end + end t.objectives:SetText(text) + t.objectives:SetWordWrap(true) -- todo: set up a SecureActionButton template @@ -402,12 +447,11 @@ style = 'Super' end + --- metrics are calculated in SetStyle t:SetStyle(style) + t:Show() - - local fullheight = t:GetHeight() - t:Show() - print(' |cFF00FFFF)|r -> ', t, t:GetHeight(), fullheight) + print(' |cFF00FFFF)|r -> ', t, t:GetHeight()) return t end @@ -558,8 +602,8 @@ local previousItem for questID, itemButton in pairs(usedButtons) do local questIndex = mod.Quest.Info[questID].questLogIndex - print('|cFF00FFFF', questIndex, itemButton:GetName()) - local block = mod.Quest.LogBlock[questIndex] + print('|cFF00FFFF', questID, itemButton:GetName()) + local block = mod.Quest.LogBlock[questID] print(block:GetTop()) if block then if IsQuestWatched(questIndex) then diff -r a2396b03ce63 -r 3397aae1f44d ObjectiveInfo.lua --- a/ObjectiveInfo.lua Thu Mar 31 01:38:47 2016 -0400 +++ b/ObjectiveInfo.lua Thu Mar 31 07:32:05 2016 -0400 @@ -128,7 +128,6 @@ local cheevID = Cheevs.trackedCheevs[index] local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy = GetAchievementInfo(cheevID) - print('|cFF00FF00', GetAchievementNumCriteria(cheevID)) self.Info[cheevID] = {} local c = self.Info[cheevID] c.type = 'Cheevs' @@ -154,6 +153,7 @@ criteriaID = criteriaID, } end + print('Cheevs.|cFF0088FFGetInfo|r('..index..')', 'obj:', GetAchievementNumCriteria(cheevID), name, description) self.WatchInfo[index] = c return self.Info[cheevID] diff -r a2396b03ce63 -r 3397aae1f44d ObjectiveTracker.lua --- a/ObjectiveTracker.lua Thu Mar 31 01:38:47 2016 -0400 +++ b/ObjectiveTracker.lua Thu Mar 31 07:32:05 2016 -0400 @@ -202,11 +202,6 @@ if not isHandled then print('|cFFFF4400'..event..'|r', ...) end - --@debug@ - if Devian and Devian.InWorkspace() then - frame_guide_init(Scroller) - frame_guide(Scroller, Scroller) - end end mod.SetEvents = function() @@ -223,7 +218,7 @@ function mod:OnInitialize() self.InitializeTrackers() - + self.InitializeXPTracker() mod.SetEvents() ObjectiveTrackerFrame:UnregisterAllEvents() ObjectiveTrackerFrame:Hide() diff -r a2396b03ce63 -r 3397aae1f44d ObjectiveTracker.xml --- a/ObjectiveTracker.xml Thu Mar 31 01:38:47 2016 -0400 +++ b/ObjectiveTracker.xml Thu Mar 31 07:32:05 2016 -0400 @@ -5,19 +5,35 @@ + + + + + + + + + + + + + + self.toggle = true - self:RegisterForDrag('LeftButton') + self.drag = true + Veneer.OnLoad(self) - self:StartMoving() + Veneer.OnDragStart(self) - self:StopMovingOrSizing() + Veneer.OnDragStop(self) + Veneer.ObjectiveTracker.UpdateActionButtons() @@ -28,7 +44,6 @@ - + + + + + + + + self.widgetType = 'ProgressBar' + Veneer.ObjectiveTracker.RegisterWidget(self) + + + Veneer.ObjectiveTracker.InitializeWidget(self) + + + Veneer.ObjectiveTracker.ReleaseWidget(self) + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file