# HG changeset patch
# User Nenue
# Date 1461521725 14400
# Node ID 03ed70f846dec65544e06a8e36241ea9011e356c
# Parent 92534dc793f2365683ce590e439474564f7d4e78
- move block accessors into a new file
- define a tMove function for reconciling the free/used tables as needed
- when retrieving an old block frame, confirm ID still matches; resolves multiple watch items on one block
- stop any animations when a block is freed; resolves stuck flare graphics
diff -r 92534dc793f2 -r 03ed70f846de ObjectiveTracker/Achievements.lua
--- a/ObjectiveTracker/Achievements.lua Thu Apr 21 16:43:37 2016 -0400
+++ b/ObjectiveTracker/Achievements.lua Sun Apr 24 14:15:25 2016 -0400
@@ -14,7 +14,78 @@
local wipe = table.wipe
local print, bprint, lprint, iprint = B.print('Tracker'), B.print('Block'), B.print('Line'), B.print('iprint')
---- Data retrieval
+--- Frame data
+Cheevs.UpdateObjectives = function(handler, block, block_schema)
+ -- if completed on another character, only show the heading for CHATLINK
+ if block.info.completed then
+ return 0, block_schema
+ end
+
+ if block.info.description then
+ handler:AddLine(block, block.info.description, nil, 'defalut')
+ end
+ local attachments = Default.UpdateObjectives(handler, block, block_schema)
+
+ return attachments, block_schema
+end
+
+Cheevs.UpdateLine = function(handler, block, data)
+ local print = lprint
+ local attachment
+ local text
+ local lineSchema = 'default'
+ print(' ', data.objectiveIndex,'|cFF'..handler.internalColor..'-|r', data.objectiveType, data.text)
+ if data.type == CRITERIA_TYPE_ACHIEVEMENT then
+ if data.value == 1 then
+ return nil, nil
+ end
+
+ text = data.text
+ lineSchema = (data.quantity == 1) and 'achievement_complete' or 'achievement'
+ elseif band(data.flags, 0x00000001) > 0 then
+ attachment = T.GetWidget(data, 'StatusBar', data.criteriaID)
+ attachment.format = "%d/%d"
+ attachment.value = data.value
+ attachment.maxValue = data.maxValue
+ attachment:SetParent(block)
+
+ print(attachment:GetNumPoints())
+ for i = 1, attachment:GetNumPoints() do
+ print(' ',attachment:GetPoint(i))
+ end
+ attachment.status:SetFormattedText("%d/%d", data.value, data.maxValue)
+ attachment:SetPoint('TOP', line, 'TOP')
+ lineSchema = 'progressbar'
+ else
+
+ text = format("%d/%d %s", data.value, data.maxValue, data.text)
+ lineSchema = 'default'
+ end
+ print(' |cFF'..handler.internalColor..'UpdateLine:|r', data.type, data.quantityString, 'qty:', data.quantity, 'assetID:', data.assetID)
+ return text, attachment, lineSchema
+end
+
+Cheevs.Select = function(self, block)
+ Cheevs.Link(self, block)
+ T:Update(self.updateReasonModule, block.info.cheevID)
+end
+
+Cheevs.Remove = function(self, block)
+
+ RemoveTrackedAchievement(block.info.cheevID)
+end
+Cheevs.OnMouseUp = function(self, button)
+
+ Default.OnMouseUp(self, button)
+end
+Cheevs.Link = function(self, block)
+ local achievementLink = GetAchievementLink(block.info.cheevID);
+ if ( achievementLink ) then
+ _G.ChatEdit_InsertLink(achievementLink);
+ end
+end
+
+--- Data accessors
Cheevs.GetNumWatched = function(self, targetID, isNew)
local trackedList = {GetTrackedAchievements() }
local numWatched, numAll = #trackedList, #self.WatchList
@@ -122,66 +193,6 @@
end
end
-Cheevs.UpdateObjectives = function(handler, block, block_schema)
- Default.UpdateObjectives(handler, block, block_schema)
- return block_schema
-end
-
---- assemble line info
-Cheevs.UpdateLine = function(handler, block, data)
- local print = lprint
- local attachment
- local text
- local lineSchema = 'default'
- print(' ', data.objectiveIndex,'|cFF'..handler.internalColor..'-|r', data.objectiveType, data.text)
- if data.type == CRITERIA_TYPE_ACHIEVEMENT then
- if data.value == 1 then
- return nil, nil
- end
-
- text = data.text
- lineSchema = (data.quantity == 1) and 'achievement_complete' or 'achievement'
- elseif band(data.flags, 0x00000001) > 0 then
- attachment = T.GetWidget(data, 'StatusBar', data.criteriaID)
- attachment.format = "%d/%d"
- attachment.value = data.value
- attachment.maxValue = data.maxValue
- attachment:SetParent(block)
-
- print(attachment:GetNumPoints())
- for i = 1, attachment:GetNumPoints() do
- print(' ',attachment:GetPoint(i))
- end
- attachment.status:SetFormattedText("%d/%d", data.value, data.maxValue)
- attachment:SetPoint('TOP', line, 'TOP')
- lineSchema = 'progressbar'
- else
- text = data.quantityString .. ' ' .. data.text
- lineSchema = 'default'
- end
- print(' |cFF'..handler.internalColor..'UpdateLine:|r', data.type, data.quantityString, 'qty:', data.quantity, 'assetID:', data.assetID)
- return text, attachment, lineSchema
-end
-
-Cheevs.Select = function(self, block)
- Cheevs.Link(self, block)
- T:Update(self.updateReasonModule, block.info.cheevID)
-end
-
-Cheevs.Remove = function(self, block)
-
- RemoveTrackedAchievement(block.info.cheevID)
-end
-Cheevs.OnMouseUp = function(self, button)
-
- Default.OnMouseUp(self, button)
-end
-Cheevs.Link = function(self, block)
- local achievementLink = GetAchievementLink(block.info.cheevID);
- if ( achievementLink ) then
- _G.ChatEdit_InsertLink(achievementLink);
- end
-end
Cheevs.Open = function(self, block)
diff -r 92534dc793f2 -r 03ed70f846de ObjectiveTracker/BonusObjectives.lua
--- a/ObjectiveTracker/BonusObjectives.lua Thu Apr 21 16:43:37 2016 -0400
+++ b/ObjectiveTracker/BonusObjectives.lua Sun Apr 24 14:15:25 2016 -0400
@@ -17,10 +17,12 @@
local GetQuestProgressBarPercent, PERCENTAGE_STRING, GetTime = GetQuestProgressBarPercent, PERCENTAGE_STRING, GetTime
local TASK_DISPLAY_TEST = 1 -- 1: normal (is nearby or on the map) 2: strict (is nearby) 3: data exists
+--- Holds data for recently completed tasks
+local completedTasks = {}
+
--- Returns a tasks table modified to include recently completed objectives
local InternalGetTasksTable = function()
local print = Bonus.print
- local savedTasks = T.Conf.TasksLog
local char = UnitName("player")
local realm = GetRealmName()
local tasks = GetTasksTable()
@@ -32,7 +34,7 @@
end
end
- for questID, data in pairs(savedTasks) do
+ for questID, data in pairs(completedTasks) do
if questID > 0 then
local found = false
for i = 1, #tasks do
@@ -55,9 +57,10 @@
end
--- Returns an entry from the composed tasks table if possible, otherwise makes an API pull
+
local InternalGetTaskInfo = function(questID)
- local completedTasks = T.Conf.TasksLog
if completedTasks[questID] then
+ -- if it's a recently completed task, use the information stored for it
return true, true, #completedTasks[questID].objectives
else
return GetTaskInfo(questID)
@@ -66,7 +69,6 @@
--- Same as above but for the objective entries
local InternalGetQuestObjectiveInfo = function(questID, objectiveIndex)
- local completedTasks = T.Conf.TasksLog
if ( completedTasks[questID] ) then
print('using internal data')
return completedTasks[questID].objectives[objectiveIndex], completedTasks[questID].objectiveType, true;
@@ -111,7 +113,8 @@
local isInArea, isOnMap, numObjectives = InternalGetTaskInfo(questID)
local existingTask = self.InfoBlock[questID]
local displayObjectiveHeader = false;
- if CanShowTask(isInArea, isOnMap, existingTask) then
+ local displayTask = CanShowTask(isInArea, isOnMap, existingTask)
+ if displayTask then
print('TaskInfo', '|cFF00FF00showable objective list', questID)
self.Info[questID] = self.Info[questID] or {}
@@ -126,7 +129,7 @@
local taskTitle
t.id = questID
t.objectives = {}
- local taskFinished = true;
+ local isComplete = true;
for objectiveIndex = 1, numObjectives do
local text, objectiveType, finished, displayAsObjective = InternalGetQuestObjectiveInfo(questID, objectiveIndex, false);
displayObjectiveHeader = displayObjectiveHeader or displayAsObjective;
@@ -147,6 +150,7 @@
o.type = objectiveType
o.finished = finished
o.displayAsObjective = displayAsObjective
+ isComplete = (isComplete and finished)
end
T.SetRewards(t, questID)
@@ -165,13 +169,15 @@
t.id = questID
t.taskIndex = i
t.title = taskTitle
+ t.isComplete = isComplete
self.WatchList[i] = t
elseif existingTask then
print('TaskInfo', '|cFFFF4400hideable task', questID)
existingTask:Hide()
end
- print ('TaskInfo', i, 'questID', questID, 'inArea', isInArea, 'onMap', isOnMap, 'existing', (existingTask and 'Y' or 'N'), (test and '|cFF00FF00show|r' or '|cFFFF0088hide|r'))
+
+ print ('TaskInfo', i, '|cFFFFFF00'.. questID..'|r', '('..(isInArea and '|cFF88FF88' or '|cFF666666') .. 'isInArea|r', 'AND', (isOnMap and '|cFF88FF88' or '|cFF666666') .. 'isOnMap|r)', 'OR', (existingTask and '|cFF88FF88' or '|cFF666666') .. 'existingTask|r', (displayTask and '|cFF00FF00show|r' or '|cFFFF4400hide|r'))
end
@@ -180,6 +186,24 @@
return self.numWatched, self.numWatched, self.WatchList
end
+Bonus.OnEvent = function(block, event, ...)
+ if event == 'QUEST_LOG_UPDATE' then
+ local info = block.info
+
+ local isInArea, isOnMap, numObjectives = InternalGetTaskInfo(info.questID)
+ if not CanShowTask(isInArea, isOnMap, block, numObjectives) then
+ block:Hide()
+ end
+ end
+end
+
+Bonus.GetBlock = function(self, index)
+ local block = Default.GetBlock(self, index)
+ block:SetScript('OnEvent', self.OnEvent)
+ block:RegisterEvent('QUEST_LOG_UPDATE')
+ return block
+end
+
--- info cleanup done when turn-ins are detected
Bonus.OnTurnIn = function(self, block, questID, xp, money)
--[=[
@@ -254,21 +278,19 @@
if data.type == 'progressbar' then
print(' |cFFFF44DDpercent='..tostring(GetQuestProgressBarPercent(info.questID)))
local percent = 100
- attachment = T.GetWidget(data, 'StatusBar', info.questID..'-'..data.index)
- attachment:SetParent(block)
-
if not data.finished then
percent = GetQuestProgressBarPercent(info.questID)
end
data.value = percent
data.maxValue = 100
+ attachment = T.GetWidget(data, 'StatusBar', info.questID..'-'..data.index)
+ attachment:SetParent(block)
print(attachment:GetNumPoints())
for i = 1, attachment:GetNumPoints() do
print(' ',attachment:GetPoint(i))
end
-
attachment.value = percent
attachment.maxValue = 100
attachment.status:SetFormattedText(PERCENTAGE_STRING, percent)
diff -r 92534dc793f2 -r 03ed70f846de ObjectiveTracker/DefaultTracker.lua
--- a/ObjectiveTracker/DefaultTracker.lua Thu Apr 21 16:43:37 2016 -0400
+++ b/ObjectiveTracker/DefaultTracker.lua Sun Apr 24 14:15:25 2016 -0400
@@ -70,12 +70,12 @@
hasStuff = true
currentPosition = currentPosition + 1
Default.AddTracker(handler, frame, currentPosition)
-
+ frame.wasEmpty = nil
else
- frame:ClearAllPoints()
- frame:SetPoint('BOTTOM', Scroll, 'BOTTOM', 0, 0)
frame.destinationOffset = 0
- frame:Hide()
+ if not frame.wasEmpty and not frame.fadeOut:IsPlaying() then
+ frame.fadeOut:Play()
+ end
frame.wasEmpty = true
end
end
@@ -92,7 +92,7 @@
local print = handler.print
local frame = handler.frame
local blockIndex = 0
- print('UpdateTracker', handler.name, reason)
+ print('MODULE:'..handler.name, 'message:', reason, 'id:', id, (isNew and '|cFF88FF88' or '|cFF555555')..'isNew|r')
handler.updateReason = reason
local numWatched, numAll, watchTable = handler:GetNumWatched(id, isNew)
@@ -120,7 +120,6 @@
end
end
-
local numBlocks = handler.numBlocks
local used = handler.usedBlocks
local free = handler.freeBlocks
@@ -146,23 +145,25 @@
block.info = info
info.blockIndex = index
+ local keyInfo
if info.id then
- print(' storing id', info.id, 'for', block:GetName())
+ keyInfo = (keyInfo and (keyInfo..', ') or '') .. 'InfoBlock[' .. info.id .. '] = *' .. block:GetName():gsub('%D', '')
handler.InfoBlock[info.id] = block
end
if info.logIndex then
- print(' storing logIndex', info.logIndex, 'for', block:GetName())
+ keyInfo = (keyInfo and (keyInfo..', ') or '') .. 'LogBlock[' .. info.logIndex .. '] = ' .. block:GetName():gsub('%D', '')
handler.LogBlock[info.logIndex] = block
end
if info.watchIndex then
- print(' storing watchIndex', info.watchIndex, 'for', block:GetName())
+ keyInfo = (keyInfo and (keyInfo..', ') or '') .. 'WatchBlock[' .. info.watchIndex .. '] = ' .. block:GetName():gsub('%D', '')
handler.WatchBlock[info.watchIndex] = block
end
+ if keyInfo then print(' assigned', keyInfo) end
handler.BlockInfo[index] = info
block.endPoint = block.titlebg
block.attachmentHeight = 0
block.currentLine = 0
- handler:UpdateObjectives(block, block.schema)
+ local attachments, override_schema = handler:UpdateObjectives(block, block.schema)
block.title:SetText(info.title)
@@ -175,28 +176,6 @@
local tagPoint, tagAnchor, tagRelative, x, y = 'TOPRIGHT', block, 'TOPRIGHT', -2, -2
- local numCurrency = 0
- for i, rewardTile in ipairs(block.rewardTile) do
- if info.rewardInfo and info.rewardInfo[i] then
- local reward = info.rewardInfo[i]
- --rewardTile:SetPoint(tagPoint, tagAnchor, tagRelative, -2, -2)
- rewardTile:SetTexture(reward.texture)
- rewardTile:Show()
-
- print('updating reward tile #'.. i, reward.type, reward.count, reward.text, reward.texture)
- if reward.count and reward.count > 1 then
- block.rewardLabel[i]:SetText(reward.count)
- block.rewardLabel[i]:Show()
- end
-
- rewardTile:ClearAllPoints()
- rewardTile:SetPoint(tagPoint, tagAnchor, tagRelative, x, y)
- tagPoint, tagAnchor, tagRelative, x, y = 'TOPRIGHT', rewardTile, 'TOPLEFT', -2, 0
- else
- rewardTile:Hide()
- block.rewardLabel[i]:Hide()
- end
- end
if info.selected then
block.SelectionOverlay:Show()
@@ -224,7 +203,7 @@
print(' |cFF00FF00default.objectives', block:GetName())
-- reset the starting positions
local text, attachment, template
-
+ local numAttachments = 0
if info.objectives and displayObjectives then
for i, data in ipairs(info.objectives) do
@@ -235,6 +214,9 @@
print(' |cFF88FF00#', i, data.type, text, attachment)
handler:AddLine(block, text, attachment, template)
end
+ if attachment then
+ numAttachments = numAttachments + 1
+ end
end
end
@@ -251,7 +233,7 @@
block.attachmentHeight = block.attachmentHeight
print(' |cFF00FF00attachment:', block.attachmentHeight)
end
- return block_schema
+ return numAttachments, block_schema
end
Default.UpdateLine = function(handler, block, data)
diff -r 92534dc793f2 -r 03ed70f846de ObjectiveTracker/Events.lua
--- a/ObjectiveTracker/Events.lua Thu Apr 21 16:43:37 2016 -0400
+++ b/ObjectiveTracker/Events.lua Sun Apr 24 14:15:25 2016 -0400
@@ -70,7 +70,7 @@
local tprint = B.print('Tracker')
T.SelectQuestLogEntry = function(logIndex)
if previousSelection and previousSelection ~= logIndex then
- tprint('swapping selection from', previousSelection, 'to', logIndex)
+ print('swapping selection from', previousSelection, 'to', logIndex)
end
previousSelection = logIndex
end
\ No newline at end of file
diff -r 92534dc793f2 -r 03ed70f846de ObjectiveTracker/Frame.lua
--- a/ObjectiveTracker/Frame.lua Thu Apr 21 16:43:37 2016 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,825 +0,0 @@
---- ${PACKAGE_NAME}
--- @file-author@
--- @project-revision@ @project-hash@
--- @file-revision@ @file-hash@
--- Created: 3/30/2016 12:49 AM
---- Everything that involves directly placing elements on the screen goes here. Sizing, spacing, tiling, etc.
-local B = select(2,...).frame
-local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
-local _G, ipairs, max, min, unpack, floor, pairs, tostring, type, band = _G, ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band
-local IsResting, UnitXP, UnitXPMax, GetXPExhaustion, tinsert, tremove = IsResting, UnitXP, UnitXPMax, GetXPExhaustion, table.insert, table.remove
-local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent
-local GetAutoQuestPopUp, GetQuestLogCompletionText = GetAutoQuestPopUp, GetQuestLogCompletionText
-local PERCENTAGE_STRING, GetQuestProgressBarPercent = PERCENTAGE_STRING, GetQuestProgressBarPercent
-local Default, AutoQuest, Quest, Bonus, Cheevs = T.DefaultHandler, T.AutoQuest, T.Quest, T.Bonus, T.Cheevs
-local InCombatLockdown, format, lshift, CreateFrame = InCombatLockdown, format, bit.lshift, CreateFrame
-local IsModifiedClick, ChatEdit_GetActiveWindow = IsModifiedClick, ChatEdit_GetActiveWindow
-local band, bor = bit.band, bit.bor
-local print = B.print('Layout')
-local oprint = B.print('Objectives')
-local bprint = B.print('Block')
-local tprint = B.print('Tracker')
-local lprint = B.print('Layout')
-local unitLevel = 1
-
-local ANIM_STATE = 'Animation: %04X'
-local INIT_STATE = 'Init: %04X'
-
---- Bitfields of import
---- control value for everything
-local OBJECTIVE_TRACKER_UPDATE_REASON = _G.OBJECTIVE_TRACKER_UPDATE_REASON
---- flags reason categories where frame layout requires initializing (starts high)
-local initReason = 0xFFFF
---- flags reason categories where frame anchor updates must be delayed because of an ongoing animation (starts low)
-local animateReason = 0x0000
-
---- FRAMES
-local Wrapper = _G.VeneerObjectiveWrapper
-local Scroller = Wrapper.scrollArea
-local Scroll = _G.VeneerObjectiveScroll
-local orderedHandlers = T.orderedHandlers
-local orderedNames = T.orderedNames
-
---- FRAME TEMP VARIABLES
-local wrapperWidth, wrapperHeight = 0, 0
-local scrollWidth, scrollHeight
-
---- SCHEMA VARIABLES
-local schemaName, lastSchema = {
- tracker = '',
- block = '',
- line = ''
-}, {}
-local trackerSchema, blockSchema, lineSchema
-
-local itemButtonSize, itemButtonSpacing = 36, 1
-local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed
-local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE'
-local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0 }
-local rewardSize = 24
-
-local headerHeight, headerColor, headerSpacing = 16, {1,.75,0,1}, 2
-local headerbg = {'VERTICAL', 1, 1, 0.5, 0.5, 1, 1, 0.5, 0}
-local headerFont, headerSize, headerOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 14, 'OUTLINE'
-
-local titlebg = {'HORIZONTAL', 1, 0, .7, 0, 1, 0, .7, .2}
-local titleFont, titleSize, titleOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'OUTLINE'
-local titleColor = {0,.7,1,1}
-
-local textbg = {'HORIZONTAL', 0, 0, 0, 0.4, 0, 0, 0, 0 }
-local textFont, textSize, textOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]], 16, 'OUTLINE'
-local textColor = {1,1,1,1 }
-
-local widgetTextFont, widgetTextSize, widgetTextOutline = [[Interface\Addons\SharedMedia_MyMedia\font\XOIREQE.TTF]], 11, 'OUTLINE'
-local widgetTextColor = {1,1,1,1 }
-local widgetHeight, widgetBorder = 17, 1
-
-
-local selectionbg = {'HORIZONTAL', 1, 1, 1, 0, 1, 1, 1, 0.225}
-local titleSpacing, textSpacing, blockSpacing = 3, 3, 1
-local titleIndent, textIndent,selectionIndent = 2, 5, 50
---- END SCHEMA
-local blockPosition
-
-
-local SetAnimate = function(reason, animate)
- print('comparing', animateReason, reason)
- if animate then
- if band(animateReason, reason) == 0 then
- animateReason = animateReason + reason
- end
- else
- if band(animateReason, reason) > 0 then
- animateReason = animateReason - reason
- end
- end
- Wrapper.AnimState:SetFormattedText(ANIM_STATE, animateReason)
-end
-
-
---- schema swapper
-T.UpdateSchema = function(layer, newSchema)
- if not (T.Conf.Schema[layer] and T.Conf.Schema[layer][newSchema]) then
- return
- elseif schemaName[layer] == newSchema then
- return
- end
- lastSchema[layer] = schemaName[layer]
- schemaName[layer] = newSchema
- local c = T.Conf.Schema[layer][newSchema]
-
- if layer == 'tracker' then
- headerHeight, headerSpacing = c.headerHeight, c.headerSpacing
- headerColor = c.headerColor
- headerbg = c.headerbg
- headerFont, headerSize, headerOutline = unpack(c.headerFont)
- trackerSchema = newSchema
- elseif layer == 'block' then
- titlebg = c.titlebg
- titleFont, titleSize, titleOutline = unpack(c.titleFont)
- selectionbg = c.selectionbg
- titleSpacing, textSpacing, blockSpacing = c.titleSpacing, c.textSpacing, c.blockSpacing
- titleIndent, textIndent,selectionIndent = c.titleIndex, c.textIndex, c.selectionIndent
- titleColor = c.titleColor
- print(unpack(c.titleColor))
- rewardSize = 24
- textFont, textSize, textOutline = unpack(c.textFont)
- textbg = c.textbg
- textIndent = c.textIndent
- rewardSize = c.rewardSize
- blockSchema = newSchema
- elseif layer == 'line' then
- textColor = c.textColor
- lineSchema = newSchema
- elseif layer == 'widget' then
- widgetTextColor = c.textSpacing
- widgetTextFont, widgetTextSize, widgetTextOutline = unpack(c.textFont)
- end
- tprint('|cFFFF0088 Schema:|r', layer, lastSchema[layer], '->', newSchema)
-end
--- todo: figure out why objectives go invisible
-local anchorPoint, anchorFrame
-local abs, GetTime = math.abs, GetTime
-Default.AddTracker = function(handler, frame, index)
- local isInitialized = true
- if initReason and (band(initReason, handler.updateReason) > 0 ) then
- isInitialized = false
- initReason = initReason - handler.updateReason
- print('|cFF00FF00%%% initialization status update:', format('%04X', initReason))
-
- frame.SlideIn:SetScript('OnPlay', function()
- SetAnimate(handler.updateReasonModule, true)
- end)
-
- frame.SlideIn:SetScript('OnFinished', function()
- SetAnimate(handler.updateReasonModule, false)
- end)
-
- if initReason == 0 then
- initReason = nil
- end
- end
-
- if index == 1 then
- print('|cFF00FF00### beginning wrapper layout -----------------')
- anchorPoint, anchorFrame = 'TOP', Scroll
- wrapperHeight = 0
- end
-
- frame.destinationOffset = -wrapperHeight
- print(frame.destinationOffset, frame.previousOffset)
- if isInitialized and (abs(frame.previousOffset - frame.destinationOffset) > 0.9) and frame:IsVisible() then
- if frame.wasEmpty then
- frame.previousOffset = -Wrapper:GetHeight()
- end
-
- local postFrame, postPoint = anchorFrame, anchorPoint
- local delta = frame.destinationOffset - frame.previousOffset
- local _, _, _, _, offset = frame:GetPoint(1)
- print(' |cFF00FFBBpushing', frame:GetName(), delta, 'pixels, from', frame.previousOffset, '(', offset, ')')
- frame.SlideIn.translation:SetTarget(frame)
- frame.SlideIn.translation:SetOffset(0, delta)
- frame.SlideIn:Play()
- --for i, b in ipairs(handler.usedBlocks) do
- --b.SlideIn.translation:SetOffset(0, delta)
- -- b.SlideIn:Play()
- --end
- local start = GetTime()
- frame.SlideIn:SetScript('OnFinished', function()
- print(' |cFF00BBFF'..frame:GetName(), 'moved', delta, 'over duration of ', GetTime()-start)
- frame:SetParent(Scroll)
- frame:SetPoint('TOP', Scroll, 'TOP', 0, frame.destinationOffset)
- frame.previousOffset = frame.destinationOffset
- frame.SlideIn:SetScript('OnFinished', nil)
- if Wrapper.destinationHeight then
- Wrapper:SetHeight(Wrapper.destinationHeight)
- Scroller:SetHeight(Wrapper.destinationHeight)
- Scroll:SetHeight(Wrapper.destinationHeight)
- Wrapper.previousHeight = Wrapper.destinationHeight
- Wrapper.destinationHeight = nil
- end
-
- end)
- else
- print(' |cFF00BBFFpinning '..handler.name..' to', anchorFrame:GetName(), anchorPoint, '|rcurrent frame height:', frame.height)
- print(' |cFFFF0088total height:', wrapperHeight)
- frame:ClearAllPoints()
- frame:SetParent(Scroll)
- frame:SetPoint('TOP', Scroll, 'TOP', 0, frame.destinationOffset)
- frame:SetPoint('LEFT', Scroll, 'LEFT')
- frame:SetPoint('RIGHT', Scroll, 'RIGHT')
- frame.previousOffset = frame.destinationOffset
- handler.initialized = true
- end
-
- frame.title:SetFont(headerFont, headerSize, headerOutline)
- frame.titlebg:SetHeight(headerHeight)
- frame.title:SetTextColor(unpack(headerColor))
-
- if frame.height ~= frame.previousHeight then
- frame:SetHeight(frame.height)
- end
-
- frame:Show()
- if frame.wasEmpty then
- frame.headerFade:Play()
- frame.wasEmpty = nil
- end
-
- wrapperHeight = wrapperHeight + frame.height
- anchorFrame = handler.frame
- anchorPoint = 'BOTTOM'
-
-end
-
-Default.AddBlock = function(self, block, blockIndex)
- local blockIndex = blockIndex or (self.currentBlock + 1)
- local print = bprint
- local tracker = self.frame
- local info = block.info
-
- block.index = blockIndex
-
- print('blockschema', blockSchema, block.schema)
- if blockSchema ~= block.schema then
- T.UpdateSchema('block', block.schema)
- print(' ### activating block schema:|cFF0088FF', block.schema)
- end
-
- block:SetWidth(T.Conf.Wrapper.Width)
- block.title:SetSpacing(titleSpacing)
- block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing)
- block.title:SetPoint('LEFT', block, 'LEFT', titleIndent, 0)
- block.title:SetTextColor(unpack(titleColor))
- block.titlebg:SetTexture(1,1,1,1)
- block.titlebg:SetGradientAlpha(unpack(titlebg))
- block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0)
- block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing)
- block.status:SetSpacing(textSpacing)
- block.status:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, -textSpacing)
- block.status:SetPoint('LEFT', block.titlebg, 'LEFT', textIndent, 0)
- block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0)
- block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0)
- block.statusbg:SetTexture(1,1,1,1)
- block.statusbg:SetGradientAlpha(unpack(textbg))
- block.SelectionOverlay:SetGradientAlpha(unpack(selectionbg))
- block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0)
- block.SelectionOverlay:SetPoint('BOTTOMRIGHT')
-
- local anchor, target, point, x, y = 'TOPRIGHT', block, 'TOPRIGHT', -2, -2
- for i, tile in ipairs(block.rewardTile) do
- --print(rewardSize)
- tile:SetSize(rewardSize, rewardSize)
- tile:ClearAllPoints()
- tile:SetPoint(anchor, target, point, x, y)
- block.rewardLabel[i]:SetPoint('TOP', tile, 'TOP', 0, 0)
- anchor, target, point, x, y = 'TOPRIGHT', tile, 'TOPLEFT', -2, 0
- end
-
-
- local titleHeight = floor(block.title:GetHeight()+.5)
- local titlebgHeight = titleHeight + titleSpacing*2
- block.titlebg:SetHeight(titlebgHeight)
-
- local statusHeight = floor(block.status:GetHeight()+.5)
- local statusbgHeight = statusHeight + textSpacing*2
- local attachmentHeight =floor(block.attachmentHeight + .5)
-
- print(' |cFF0088FFanchor to', self.currentAnchor:GetName())
- print(' |cFF00FF00attachment:|r', attachmentHeight, '|cFF00FF00title:|r', titlebgHeight, '('.. titleHeight..')')
- if attachmentHeight > 0 then
- attachmentHeight = attachmentHeight + textSpacing
- end
-
- block.height = titlebgHeight + attachmentHeight
- block:SetHeight(block.height)
-
- if block.debug then
- local func = (B.Conf.GuidesMode == true) and 'Show' or 'Hide'
- for _, region in ipairs(block.debug) do
- region[func]()
- end
- end
-
- --- Handler vars
- if blockIndex == 1 then
- tracker.previousHeight = tracker.height
- tracker.height = headerHeight
- blockPosition = -headerHeight
- tprint(' |cFF88FF00AddBlock:|r new layout: headerHeight =', headerHeight, 'previousHeight =', tracker.previousHeight)
- else
- blockPosition = blockPosition
- tprint(' |cFF8888FFAddBlock:|r advancing: height =', tracker.height)
- end
- self.currentBlock = blockIndex
- self.currentAnchor = block
-
- block:SetPoint('TOPLEFT', self.frame, 'TOPLEFT', 0, blockPosition)
- block:SetPoint('RIGHT', tracker,'RIGHT', 0, 0)
- block:Show()
- self.numBlocks = self.numBlocks + 1
- print(' |cFFFFFF00'..tracker.height..'|r', '|cFF00FF00'..block:GetName()..'|r', block.height, tracker.height)
- tracker.height = tracker.height + block.height
- blockPosition = blockPosition - block.height
-
-
-
- if Devian and Devian.InWorkspace() then
- block.DebugTab:SetParent(UIParent)
- block.DebugTab:SetPoint('TOPRIGHT', block, 'TOPLEFT', 0, 0)
- block.DebugTab.status:SetText(tostring(block.schema) .. ' @|cFF00FF00' .. tostring(block.posIndex) .. '|r #|cFFFFFF00'.. tostring(info.logIndex or info.id) .. '|r'..
- ' H|cFFFFFF00' .. tostring(block.height) .. ' L|cFF00FFFF' .. tostring(block.numLines) ..'|r')
- block.DebugTab:Show()
- end
-end
-
---- Used as an iterator of sorts for cascaded tag icon placements (the daily/faction/account icons)
-Default.AddTag = function (handler, block, tagInfo, tagPoint, tagAnchor, tagRelative)
- local print = bprint
-
- for order, tagName in ipairs(block.info.tagInfo) do
- local tag = block[tagName]
- if block.tagCoords[tagName] and tag then
- tag:SetTexCoord(unpack(block.tagCoords[tagName]))
- tag:Show()
- tag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0)
- tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', tag, 'TOPLEFT'
- else
- block[tagName]:Hide()
- end
- end
-
- return tagPoint, tagAnchor, tagRelative
-end
-
-Default.AddReward = function(handler, block, rewardInfo, tagPoint, tagAnchor, tagRelative)
- local print = bprint
-
- for order, reward in ipairs(rewardInfo) do
-
- end
-end
-
---- Adds the given line to the current content and advances the anchor pointer to that new line for the following call.
-Default.AddLine = function(handler, block, text, attachment, template)
- local print = lprint
- local lineIndex = block.currentLine + 1
- local line = handler:GetLine(block, lineIndex)
-
- line.index = lineIndex
- template = template or 'default'
- if template and lineSchema ~= template then
- print(' |cFF00FF00change schema', template)
- T.UpdateSchema('line', template)
- end
- line.status:SetSpacing(textSpacing)
- line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
- line.status:SetPoint('RIGHT', line, 'RIGHT',0, 0)
- line.status:SetTextColor(unpack(textColor))
- line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, -textSpacing)
- line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
- line:SetPoint('LEFT', block, 'LEFT')
- line:SetPoint('RIGHT', block, 'RIGHT')
- line:Show()
- line:SetScript('OnMouseUp', function(self, button)
- handler.OnMouseUp(block, button)
- end)
-
-
- tprint(' |cFF0088FFAddLine|r (|cFF00FFFF'..tostring(line.schema)..'|r):', line:GetName())
- --[[
- for i = 1, line:GetNumPoints() do
- tprint(' - ', line:GetPoint(i))
- end
- tprint(' - ', line:GetSize())
- tprint(' - ', line:GetParent(), line:GetParent():IsVisible())
- tprint(' - ', line:IsVisible())
- --]]
-
-
-
-
- -- fill in the text, then derive pixel-rounded height
- line.status:SetText(text)
- line.height = floor(line.status:GetStringHeight()+.5)
-
- -- For progressbar and timer lines, status text may be used as the title heading
- if attachment then
- attachment:SetPoint('TOP', line, 'TOP')
- attachment:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
- attachment:SetPoint('RIGHT', line, 'RIGHT')
- print(' |cFFFF0088doing things with a widget', attachment:GetSize())
- line.height = attachment:GetHeight()
- if text then
- line.height = max(line.height, line.status:GetStringHeight())
- end
- if attachment.status:GetText() then
- line.height = max(line.height, attachment.status:GetStringHeight())
- end
- attachment:Show()
- end
-
- line:SetHeight(line.height)
- block.attachmentHeight = block.attachmentHeight + line.height + textSpacing
-
- local debug_points = ''
- for i = 1, line:GetNumPoints() do
- local point, parent, anchor = line:GetPoint(i)
- debug_points = debug_points .. tostring(parent:GetName()) .. ', ' .. anchor .. ' '
- end
-
- print(' |cFF0088FFsetting line #'..lineIndex..' for|r', block.info.title, "\n |cFF0088FFsize:|r", line.height,
- "|cFF0088FFpoint:|r", debug_points, "|cFF0088FFwidget:|r", (line.widget and 'Y' or 'N'))
- block.currentLine = lineIndex
- block.endPoint = line -- edge used for the next block
-
- return lineIndex
-end
-
---- Creates or retrieves a complete line data object
-Default.GetLine = function(handler, block, lineIndex)
- local print = lprint
- local blockIndex = block.index
- local lines = block.lines
- if not lineIndex then
- lineIndex = block.currentLine + 1
- print(' |cFFFFFF00generating a frame')
- end
-
- block.numLines = max(block.numLines, lineIndex)
-
- if not lines[lineIndex] then
- print(' |cFF00FF88created line #'..lineIndex..' from for '..handler.name..' block #'..blockIndex)
- lines[lineIndex] = CreateFrame('Frame', 'Vn'..handler.name .. blockIndex..'ObjectiveLine'..lineIndex, block, 'VeneerTrackerObjective')
- local line = lines[lineIndex]
- line.index = lineIndex
- line.height = 0
- line.schema = ''
- B.SetConfigLayers(line)
-
- if debug then
- for _, region in ipairs(lines[lineIndex].debug) do
- region:Show()
- end
- end
-
- end
- return lines[lineIndex]
-end
-
-
-
---- Creates or retrieves a complete block frame object
---- todo: make it use data index to avoid re-coloring every block
-Default.GetBlock = function(handler, index)
- local print = bprint
- print('|cFF0088FFgetting a block for index', index ..',', #handler.usedBlocks,'used', #handler.freeBlocks, 'free')
- local block = handler.InfoBlock[index]
- local used = handler.usedBlocks
-
- if not block then
- if #handler.freeBlocks >= 1 then
- block = tremove(handler.freeBlocks)
- tinsert(handler.usedBlocks, block)
- block.posIndex = #handler.usedBlocks
- print(' |cFF00FF00 assigning from free heap', block:GetName())
- else
-
- local blockIndex = (#handler.usedBlocks + #handler.freeBlocks) + 1
- block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, handler.frame, 'VeneerTrackerBlock')
- --block:SetParent()
- block.schema = ''
- block.lines = {}
- block.numLines = 0
- block.currentLine = 0
- block.attachmentHeight = 0
- block.offset = 0
- B.SetConfigLayers(block)
- --- methods for event handlers
-
- block.Select = handler.Select
- block.Open = handler.Open
- block.Remove = handler.Remove
- block.Link = handler.Link
- block.clickZone:SetScript('OnMouseUp', function(self, ...) handler.OnMouseUp(block, ...) end)
- block.clickZone:SetScript('OnMouseDown', function(self, ...) handler.OnMouseDown(block, ...) end)
- block:ClearAllPoints()
- block.index = blockIndex
- print(' |cFF00FFBBcreating new|r', block:GetName())
- end
- handler.InfoBlock[index] = block
- tinsert(handler.usedBlocks, block)
- block.posIndex = #handler.usedBlocks
- else
- print(' |cFFFFFF00use existing block|r', block:GetName())
- local found = false
- for i, entry in ipairs(used) do
- if entry == block then
- found = true
- break
- end
- end
- if not found then
- tinsert(used, block)
- block.posIndex = #used
- end
- end
- return block
-end
-
-
-
-----------
---- Top level methods
-
-
-T.UpdateBlockAction = function (block, itemButton)
- local print = bprint
- print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()')
- if itemButton.questID ~= block.info.questID then
- print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID)
- -- something happened between this and last frame, go back and set new probes
- return T.UpdateActionButtons()
- end
-
- local previousItem = itemButton.previousItem
- local upper_bound = Scroller:GetTop() + Scroller.snap_upper
- local lower_bound = Scroller:GetBottom() + Scroller.snap_lower + itemButtonSize
- local point, anchor, relative
-
- if block:GetBottom() < lower_bound then
- print('** ',block:GetName() ,'|cFFFFFF00bottom =', floor(block:GetBottom()+.5), 'threschold =', floor(lower_bound+.5))
- if previousItem then
- print('adjusting', previousItem:GetName())
- previousItem:ClearAllPoints()
- previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, itemButtonSpacing)
- end
- itemButton:ClearAllPoints()
- itemButton.x = Wrapper:GetLeft() -4
- itemButton.y = Wrapper:GetBottom()
- point, anchor, relative = 'BOTTOMRIGHT', UIParent, 'BOTTOMLEFT'
- Scroller.snap_lower = Scroller.snap_lower + itemButtonSize + itemButtonSpacing
-
- elseif block:GetTop() > upper_bound then
- print('** ',block:GetName() ,'|cFFFFFF00top =', floor(block:GetTop()+.5), 'threschold =', floor(upper_bound+.5))
- itemButton:ClearAllPoints()
- if previousItem then
- print('latch onto another piece')
- point, anchor, relative ='TOP', previousItem, 'BOTTOM'
- itemButton.x = 0
- itemButton.y = -itemButtonSpacing
- else
- print('latch at corner', Scroller:GetLeft() -itemButtonSpacing, Scroller:GetTop())
- point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
- itemButton.x = Scroller:GetLeft() -4
- itemButton.y = Scroller:GetTop()
- end
- itemButton:Show()
- Scroller.snap_upper = Scroller.snap_upper - (itemButtonSize + itemButtonSpacing)
- else
- print('** ',block:GetName() ,'|cFF00FF00span =', floor(block:GetBottom()+.5), floor(block:GetTop()+.5), 'threschold =', floor(lower_bound+.5))
- itemButton:ClearAllPoints()
- itemButton.x = block:GetLeft() - itemButtonSpacing
- itemButton.y = block:GetTop()
- point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
- end
-
- itemButton:SetPoint(point, anchor, relative, itemButton.x, itemButton.y)
- itemButton:Show()
-end
-
-T.UpdateItemButtonCooldown = function(button)
-
-end
-
-function T:FinishWrapper ()
- if wrapperHeight > Wrapper.previousHeight then
- Wrapper:SetHeight(wrapperHeight)
- Scroller:SetHeight(wrapperHeight*3)
- Scroll:SetHeight(wrapperHeight)
- Wrapper.previousHeight = wrapperHeight
- Wrapper.destinationHeight = wrapperHeight
- end
- Scroller:SetVerticalScroll(B.Conf.ObjectiveScroll or 0)
- print('|cFF00FF00### end of wrapper layout', Wrapper:GetSize())
- print(' |cFF00FF00Scroller:', Scroller:GetSize())
- print(' |cFF00FF00Scroll:', Scroll:GetSize())
- for i = 1, Wrapper:GetNumPoints() do
- print('|cFF00FF00 ', Wrapper:GetPoint(i))
- end
- for i = 1, Scroller:GetNumPoints() do
- print('|cFF00FF00 ', Scroller:GetPoint(i))
- end
- for i = 1, Scroll:GetNumPoints() do
- print('|cFF00FF00 ', Scroll:GetPoint(i))
- end
-
- if Devian and Devian.InWorkspace() then
- Wrapper.AnimState:SetFormattedText(ANIM_STATE, animateReason)
- end
-
- Wrapper:Show()
- Scroller:Show()
- Scroll:Show()
-end
-
-
------------------------------------------
--- Criteria frames
-
---[[
- text = description,
- type = type,
- finished = completed,
- quantity = quantity,
- requiredQuantity = requiredQuantity,
- characterName = characterName,
- flags = flags,
- assetID = assetID,
- quantityString = quantityString,
- criteriaID = criteriaID,
-]]
-local newWidgetID = 0
-T.WidgetRegistry = {}
-local wr = T.WidgetRegistry
-
---- Get a usable widget for the given achievement criteria set.
--- Returns a frame object with dimensioning parameters needed to size the receiving tracker block
-T.GetWidget = function(data, objectiveType, objectiveKey)
- local print = B.print('ObjectiveWidgets')
- local widgetType = objectiveType
- local widget
- local isNew
- if wr[widgetType] and wr[widgetType].used[objectiveKey] then
- widget = wr[widgetType].used[objectiveKey]
- print('|cFF00FF00Updating ('..objectiveKey..')', widget)
- elseif not wr[widgetType] or #wr[widgetType].free == 0 then
- -- creating a new frame
- isNew = true
- widget = CreateFrame(widgetType, 'VeneerObjective' .. widgetType .. (wr[widgetType] and (wr[widgetType].lastn+1) or (1)), VeneerObjectiveScroll, 'VeneerObjectiveCriteria' .. widgetType)
- print('|cFFFF0088Creating `'..widget:GetName()..'` id', wr[widgetType].lastn)
- T.UpdateSchema(widgetType, data.schema or 'default')
- else
- -- recycling for a different criteria set
- isNew = true
- widget = tremove(wr[widgetType].free)
- print('|cFFFFFF00Acquiring released widget', widget:GetName())
- end
-
-
- wr[widgetType].used[objectiveKey] = widget
- widget.objective = data
- widget.key = objectiveKey
- T.InitializeWidget(widget, isNew)
- return widget
-end
-
---- WidgetTemplate 'OnLoad'
-T.RegisterWidget = function(frame)
- local print = B.print('ObjectiveWidgets')
- local widgetType = frame.widgetType
- if not wr[frame.widgetType] then
- print('|cFFFF4400[[WidgetTemplate]]|r', widgetType)
- wr[widgetType] = { lastn = 1, free = {}, used = {}, usedIndex = {}, freeIndex = {} }
- else
- print('|cFF0088FF+ [[WidgetTemplate]]r', widgetType, wr[widgetType].lastn)
- wr[widgetType].lastn = wr[widgetType].lastn + 1
- end
-end
---- WidgetTemplate 'OnShow'
-local wrapperWidth, textIndent
-T.InitializeWidget = setmetatable({}, {
- __call = function(t, frame, isNew, ...)
- -- todo: config pull
- if not wrapperWidth then
- wrapperWidth = T.Conf.Wrapper.Width
- textIndent = T.Conf.Wrapper.TextIndent
- end
-
- tprint('Initialize', frame:GetName(), isNew, ...)
- frame:SetWidth(wrapperWidth - textIndent * 2)
- frame:SetScript('OnEvent', T.UpdateWidget[frame.widgetType])
- frame:RegisterEvent('QUEST_LOG_UPDATE')
- frame:RegisterEvent('TRACKED_ACHIEVEMENT_UPDATE')
- frame:RegisterEvent('TRACKED_ACHIEVEMENT_LIST_CHANGED')
- frame:RegisterEvent('CRITERIA_UPDATE')
- frame:RegisterEvent('CRITERIA_COMPLETE')
- frame:RegisterEvent('CRITERIA_EARNED')
- t[frame.widgetType](frame, isNew)
- T.UpdateWidget[frame.widgetType](frame, isNew)
- end,
-})
-
---- WidgetTemplate 'OnEvent'
-T.UpdateWidget = setmetatable({}, {
- __call = function(t, frame, isNew, ...)
- tprint('Update', frame:GetName(), isNew, ...)
- if not frame.widgetType then
- return
- end
-
- return t[frame.widgetType](frame, isNew)
- end
-})
-
-
-local progressHeight = 17
-local progressBorder = 1
-local progressFont = _G.VeneerCriteriaFontNormal
-
-local lprint = B.print('Line')
-T.InitializeWidget.StatusBar = function(self, isNew)
- local print = lprint
- local c = T.Conf.Wrapper
-
- tprint(self:GetName(), isNew)
- if isNew then
- self.maxValue = self.maxValue or 1
- self:SetMinMaxValues(0, self.maxValue)
-
- self:SetHeight(widgetHeight)
- self.height = widgetHeight
-
- self.status:SetFont(widgetTextFont, widgetTextSize, widgetTextOutline)
- self.status:SetTextColor(unpack(widgetTextColor))
- end
- self.value = self.value or 1
- self:SetValue(self.value)
-
- self.status:SetText(self.objective.quantityString)
-end
-
-T.UpdateWidget.StatusBar = function (self)
- local value, maxValue = self.value, self.maxValue
- print('update vals:')
- for k,v in pairs(self) do
- print(k, v)
- end
- self.width = self.width or self:GetWidth()
- self:SetValue(self.value)
- local format = self.format or '%d/%d'
- self.status:SetFormattedText(format, value, maxValue)
- local progress = (value / maxValue)
- if progress > 0 then
- print('color:', 1-progress*2 , progress*2 - 1,0,1)
- print('width:', (self.width -progressBorder * 2) * progress)
- self:SetStatusBarColor(1-progress*2 , progress*2,0,1)
- end
-end
-
-
-T.InitializeWidget.Hidden = function (self)
- self.height = 0
-end
-T.UpdateWidget.Hidden = function (self)
- self.height= 0
-end
-
-
---- Queue any active item buttons for update for that frame
-local iprint = B.print('ItemButton')
-local Quest = T.Quest
-local IsQuestWatched, InCombatLockdown = IsQuestWatched, InCombatLockdown
-T.UpdateActionButtons = function(updateReason)
- local print = iprint
- Scroller.snap_upper = 0
- Scroller.snap_lower = 0
- local print = B.print('ItemButton')
- if updateReason then
- print = B.print('IB_'..updateReason)
- end
-
- local previousItem
- for questID, itemButton in pairs(Quest.itemButtons) do
- local info= T.Quest.Info[questID]
-
- print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName())
- local block = T.Quest.QuestBlock[questID]
- if block then
- -- Dispatch the probe
- if IsQuestWatched(info.logIndex) then
- itemButton.previousItem = previousItem
- print(' |cFFFFFF00probing', block:GetName())
- block:SetScript('OnUpdate', function()
- if block:GetBottom() and not InCombatLockdown() then
- print(' '..block:GetName()..' |cFF00FF00probe hit!')
- T.UpdateBlockAction(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope
- block:SetScript('OnUpdate', nil)
-
- end
- end)
- previousItem = itemButton
- else
- print('hidden block or unwatched quest')
- itemButton.previousItem = nil
- itemButton:Hide()
- end
- elseif itemButton:IsVisible() then
- print(' |cFFFF0088hiding unwatched quest button', itemButton:GetName())
- itemButton.previousItem = nil
- itemButton:Hide()
- else
- print(' |cFFBBBBBBignoring hidden log quest button', itemButton:GetName())
- end
- end
-end
\ No newline at end of file
diff -r 92534dc793f2 -r 03ed70f846de ObjectiveTracker/ObjectiveTracker.lua
--- a/ObjectiveTracker/ObjectiveTracker.lua Thu Apr 21 16:43:37 2016 -0400
+++ b/ObjectiveTracker/ObjectiveTracker.lua Sun Apr 24 14:15:25 2016 -0400
@@ -461,7 +461,7 @@
local tprint = B.print('Tracker')
T.OnHookedFunc = function(name, ...)
- tprint('|cFFFF8800securehook:|r', name, '|cFF00FFFFargs:|r', ...)
+ print('|cFFFF8800securehook:|r', name, '|cFF00FFFFargs:|r', ...)
local updateReason, arg1, arg2, arg3 = T[name](...)
if updateReason then
print('|cFF00FFFFupdate reason:|r', updateReason, arg1, arg2, arg3)
@@ -488,9 +488,9 @@
tprint('OnEvent(|cFF00FF00'.. event ..'|r):', ...)
T:Update(reason, arg1, arg2, arg3)
else
- tprint('OnEvent(|cFFFF4400'.. event ..'|r):', ...)
- tprint('no detected reason')
- Play([[Interface\Addons\SharedMedia_MyMedia\sound\Quack.ogg]])
+ print('OnEvent(|cFFFF4400'.. event ..'|r):', ...)
+ print('no detected reason')
+ --Play([[Interface\Addons\SharedMedia_MyMedia\sound\Quack.ogg]])
end
local args = (reason or '0')
if arg1 then args = args .. ', ' .. tostring(arg1) end
@@ -519,7 +519,7 @@
end
end
- T.Conf.TasksLog = T.Conf.TasksLog or {}
+
ObjectiveTrackerFrame:UnregisterAllEvents()
ObjectiveTrackerFrame:Hide()
diff -r 92534dc793f2 -r 03ed70f846de ObjectiveTracker/ObjectiveTracker.xml
--- a/ObjectiveTracker/ObjectiveTracker.xml Thu Apr 21 16:43:37 2016 -0400
+++ b/ObjectiveTracker/ObjectiveTracker.xml Sun Apr 24 14:15:25 2016 -0400
@@ -4,6 +4,7 @@
+
@@ -12,6 +13,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -257,6 +285,22 @@
+
+
+ self:GetParent().fadeOut:Stop()
+
+
+
+
+
+
+
+ self:GetParent().headerFade:Stop()
+
+
+ self:GetParent():Hide()
+
+
@@ -321,21 +365,27 @@
+ Veneer.print('Frame')(self:GetName(), '|cFF00FF00SHOW|r', debugstack(1,3,1))
if(self.DebugTab:IsShown()) then
- self.DebugTab:Show()
+ self.DebugTab:Show()
end
+ self.blockFadeOut:Stop()
+ Veneer.print('Frame')(self:GetName(), '|cFF00FF00HIDE|r', debugstack(1,3,1))
if(self.DebugTab:IsShown()) then
- self.DebugTab:Hide()
+ self.DebugTab:Hide()
end
+ -- make sure neither of these execute their onFinished upon re-show
+ self.blockFadeOut:Stop()
+ self.questFadeIn:Stop()
-
+
-
+
@@ -352,14 +402,10 @@
-
-
- self.animating = true
-
-
- self.animating = nil
-
-
+
+
+
+
@@ -469,9 +515,9 @@
-
-
-
+
+
+
@@ -674,7 +720,9 @@
-
+
+
+
diff -r 92534dc793f2 -r 03ed70f846de ObjectiveTracker/Quests.lua
--- a/ObjectiveTracker/Quests.lua Thu Apr 21 16:43:37 2016 -0400
+++ b/ObjectiveTracker/Quests.lua Sun Apr 24 14:15:25 2016 -0400
@@ -13,7 +13,7 @@
local wipeall = B.wipeall
local lprint, iprint, tprint = B.print('Line'), B.print('Info'), B.print('Tracker')
local print = tprint
-
+local fprint = B.print('Frame')
local superTrackQuestID, playerMoney, inScenario, showPOIs
@@ -71,7 +71,7 @@
end
Default.UpdateObjectives(self, block, block_schema, displayObjectives)
- return block_schema
+ return 0, block_schema
end
Quest.UpdateLine = function(handler, block, data)
@@ -86,45 +86,6 @@
Quest.QuestBlock = {}
Quest.LogBlock = {}
Quest.LogInfo = {}
-function Quest:FreeBlock (block)
- local used = Quest.usedBlocks
- local free = Quest.freeBlocks
- local reason = ''
- local doRelease = false
- local info = block.info
- local questID = info.questID
- local logIndex = info.logIndex
-
- if info.posIndex then
- if used[info.posIndex] == block then
- doRelease = true
- reason = 'posIndex mismatch'
- end
- elseif logIndex then
- if not IsQuestWatched(logIndex) then
- reason = 'not being watched'
- elseif not self.LogBlock[logIndex] then
- doRelease = true
- reason = 'missing logBlock entry'
- elseif (self.LogBlock[logIndex] ~= block) then
- doRelease = true
- reason = 'different block using index'
- end
- elseif info.questID then
- if not GetQuestLogIndexByID(info.questID) then
- doRelease = true
- reason = 'no identifiable quest log entry'
- end
- end
-
-
- if doRelease then
- print(' |cFF00FF00FreeBlock (' .. block:GetName() .. '):', reason)
- block:Hide()
- tremove(used, info.posIndex)
- tinsert(free, block)
- end
-end
Quest.OnRemoved = function(block)
@@ -139,12 +100,14 @@
local watchesChecked = {}
local infosChecked = {}
-local blocksChecked = {}
local GetQuestWatchIndex = GetQuestWatchIndex
--- Get a total of things to show, and straighten out the index while we're at it
--- Return the number shown, total in log, and the info table to parse
+local blocksChecked = {}
Quest.GetNumWatched = function (self, id, added)
local print = self.print
+ B.print('Block')('########')
+ B.print('Block')('########')
superTrackQuestID = GetSuperTrackedQuestID()
playerMoney = GetMoney();
inScenario = C_Scenario.IsInScenario();
@@ -155,19 +118,20 @@
print('GetNumWatched', self.name, numWatched, 'of', numAll)
local start, limit = 1, numAll
- --- start a list of blocks affected by this function
- wipe(blocksChecked)
if id and not added then
+ -- if a particular id is supplied, add to checklist
if self.InfoBlock[id] then
- tinsert(blocksChecked, self.InfoBlock[id])
+ blocksChecked[self.InfoBlock[id]] = self.InfoBlock[id]
end
end
+ --- Start complicated frame-recycling bullshit
for logIndex = start, limit do
local reason1, reason2 = '', ''
local title, level, suggestedGroup, isHeader, isCollapsed, isComplete, frequency, questID, startEvent, displayQuestID, isOnMap, hasLocalPOI, isTask, isStory = GetQuestLogTitle(logIndex)
local watchIndex = GetQuestWatchIndex(logIndex)
+ -- check if: the watch data pointers don't match
if watchIndex and watchIndex >= bottomIndex then
local watchInfo = self.WatchInfo[watchIndex]
local watchBlock = self.WatchBlock[watchIndex]
@@ -178,34 +142,39 @@
if watchBlock and watchBlock.info.questID ~= questID then
print('GetNumWatched', 'trimming WatchBlock ['..watchIndex..'] =/=', watchBlock:GetName())
self.WatchBlock[watchIndex] = nil
- tinsert(blocksChecked, watchBlock)
+ blocksChecked[watchBlock] = watchBlock
end
end
+ -- check if: the logIndex pointer doesn't match
local logBlock = self.LogBlock[logIndex]
if logBlock and logBlock.info.questID ~= questID then
- --print(' |cFFBBFF00GetNumWatched: trimming LogBlock ['..logIndex..'] =/=', logBlock:GetName())
+ print('GetQuests', 'replace info', logBlock.info.questID, '->', questID)
self.LogBlock[logIndex] = nil
- tinsert(blocksChecked, logBlock)
+ blocksChecked[logBlock] = logBlock
end
+ -- add to watch index if: the questID is non-zero
if questID ~= 0 then
self.Info[questID] = self:GetInfo(logIndex, watchIndex)
- --print(' |cFF44BBFFGetNumWatched:|r map', questID, 'to', logIndex, (watchIndex and ('('..watchIndex..')') or ''))
+ print('GetQuests', format('request info |cFF00FF00%2d|r |cFFFFFF00%6d|r |cFFFF4400%3s|r', logIndex, questID, tostring(watchIndex or '')))
end
end
- --- remove any orphaned blocks from view and, if possible, free it for re-use
- for i, block in ipairs(blocksChecked) do
- if not GetQuestLogIndexByID(block.info.questID, 'player') then
- print('GetNumWatched', 'iterating a block without an index |cFFBBFF00'.. block:GetName()..'|r')
- block:Hide()
- self:FreeBlock(block)
+ --- After GetInfo pass, look for any non-conformant blocks and deal with them
+ for _, block in pairs(blocksChecked) do
+ local logIndex = GetQuestLogIndexByID(block.info.questID, 'player')
+ -- free if: logIndex doesn't resolve
+ if not logIndex then
+ B.print('Block')('GetNumWatched', '|cFFBBFF00block has no index '.. block:GetName()..'|r')
+ self:ClearBlock(block)
+ -- hide if: logIndex isn't being watched
+ elseif not IsQuestWatched(block.info.logIndex) then
+ B.print('Block')('GetNumWatched', '|cFFBBFF00fade from list '.. block:GetName()..'|r')
+ -- todo: figure out why animation gets clobbered
+ self:ClearBlock(block)
end
- if not IsQuestWatched(block.info.logIndex) then
- print('GetNumWatched', 'hiding untracked quest |cFFBBFF00'.. block:GetName()..'|r')
- block:Hide()
- end
+ blocksChecked[block] = nil
end
self.numWatched = numWatched
diff -r 92534dc793f2 -r 03ed70f846de ObjectiveTracker/RewardFrame.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ObjectiveTracker/RewardFrame.lua Sun Apr 24 14:15:25 2016 -0400
@@ -0,0 +1,51 @@
+--- ${PACKAGE_NAME}
+-- @file-author@
+-- @project-revision@ @project-hash@
+-- @file-revision@ @file-hash@
+-- Created: 4/22/2016 5:38 PM
+local B = select(2,...).frame
+local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
+local ipairs = ipairs
+local bprint = B.print('Block')
+local Default, AutoQuest, Quest, Bonus, Cheevs = T.DefaultHandler, T.AutoQuest, T.Quest, T.Bonus, T.Cheevs
+--- displays a reward popout and starts its animation chain
+local tagPoint, tagAnchor, tagRelative, x, y
+local REWARD_POPUP_FRAME = _G.VeneerRewardsPopOut
+
+function REWARD_POPUP_FRAME:StartRewards()
+ tagPoint, tagAnchor, tagRelative, x, y = 'TOPLEFT', self, 'TOPLEFT', 0, 0
+
+end
+function REWARD_POPUP_FRAME:AddReward(handler, rewardInfo, id)
+ local totalHeight = 0
+ REWARD_POPUP_FRAME:SetID(id)
+ REWARD_POPUP_FRAME.handler = handler
+
+ for i, rewardTile in ipairs(REWARD_POPUP_FRAME.rewardTile) do
+ if rewardInfo[i] then
+ local reward = rewardInfo[i]
+ rewardTile:SetPoint(tagPoint, tagAnchor, tagRelative, -2, -2)
+ rewardTile:SetTexture(reward.texture)
+ rewardTile:Show()
+ if reward.count and reward.count > 1 then
+ self.rewardLabel[i]:SetText(reward.count)
+ self.rewardLabel[i]:Show()
+ end
+
+ rewardTile:ClearAllPoints()
+ rewardTile:SetPoint(tagPoint, tagAnchor, tagRelative, x, y)
+ tagPoint, tagAnchor, tagRelative, x, y = 'TOPRIGHT', rewardTile, 'TOPLEFT', -2, 0
+
+ totalHeight = totalHeight + rewardTile:GetHeight()
+ else
+ rewardTile:Hide()
+ self.rewardLabel[i]:Hide()
+ end
+ end
+
+ REWARD_POPUP_FRAME.rewardsFadeIn:Play()
+end
+
+function REWARD_POPUP_FRAME:OnFinished ()
+end
+
diff -r 92534dc793f2 -r 03ed70f846de ObjectiveTracker/TrackerBlock.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ObjectiveTracker/TrackerBlock.lua Sun Apr 24 14:15:25 2016 -0400
@@ -0,0 +1,226 @@
+--- ${PACKAGE_NAME}
+-- @file-author@
+-- @project-revision@ @project-hash@
+-- @file-revision@ @file-hash@
+-- Created: 4/24/2016 11:30 AM
+--- These functions deal with propagating and managing block/line templates
+local B = select(2,...).frame
+local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
+local _G, ipairs, max, tostring = _G, ipairs, max, tostring
+local tinsert, tremove, tContains = table.insert, table.remove, tContains
+local Default = T.DefaultHandler
+local CreateFrame = CreateFrame
+local print = B.print('Layout')
+local bprint = B.print('Block')
+local lprint = B.print('Layout')
+local fprint = B.print('Frame')
+local used, free
+
+local blockFadeOut_OnPlay = function(self)
+ fprint(self:GetName(), '|cFF00FF00PLAY|r', debugstack(1,3,1))
+end
+local blockFadeOut_OnFinished = function(self)
+ fprint(self:GetName(), '|cFF00FF00FINISHED|r', debugstack(1,3, 1))
+end
+
+local tMove = function(source, dest, frame)
+ -- if it's already in the stack, sanity check source stack
+ local removed
+ if tContains(dest, frame) then
+ for i, entry in ipairs(source) do
+ if entry == frame then
+ removed = i
+ tremove(source, i)
+ break
+ end
+ end
+ -- still need to resolve position
+ for i, entry in ipairs(dest) do
+ if entry == frame then
+ bprint('tMove result:', (removed and ('|cFFFF4400a|r['..removed .. '] is now ') or '') .. '|cFF00FF00b|r[' .. i..']')
+ return i
+ end
+ end
+ else
+ -- if it's not, then pull from source stack
+ for i, entry in ipairs(source) do
+ if entry == frame then
+ removed = i
+ tremove(source, i)
+ break
+ end
+ end
+ tinsert(dest, frame)
+ bprint('tMove result:', (removed and ('|cFFFF4400a|r['..removed .. '] is now ') or '') .. '|cFF00FF00b|r[' .. #dest..']')
+ return #dest
+ end
+end
+
+
+--- Creates or retrieves a complete line data object
+Default.GetLine = function(handler, block, lineIndex)
+ local print = lprint
+ local blockIndex = block.index
+ local lines = block.lines
+ if not lineIndex then
+ lineIndex = block.currentLine + 1
+ print(' |cFFFFFF00generating a frame')
+ end
+
+ block.numLines = max(block.numLines, lineIndex)
+
+ if not lines[lineIndex] then
+ print(' |cFF00FF88created line #'..lineIndex..' from for '..handler.name..' block #'..blockIndex)
+ lines[lineIndex] = CreateFrame('Frame', 'Vn'..handler.name .. blockIndex..'ObjectiveLine'..lineIndex, block, 'VeneerTrackerObjective')
+ local line = lines[lineIndex]
+ line.index = lineIndex
+ line.height = 0
+ line.schema = ''
+ B.SetConfigLayers(line)
+
+ if debug then
+ for _, region in ipairs(lines[lineIndex].debug) do
+ region:Show()
+ end
+ end
+
+ end
+ return lines[lineIndex]
+end
+
+
+
+--- Creates or retrieves a complete block frame object
+--- todo: make it use data index to avoid re-coloring every block
+Default.GetBlock = function(handler, index)
+ local print = bprint
+ print('|cFF0088FF'..handler.name..':GetBlock', index)
+ local block = handler.InfoBlock[index]
+ local used = handler.usedBlocks
+ local free = handler.freeBlocks
+
+ if block then
+ print(block.info.id, index)
+ end
+
+ -- if the frame entry is still good, sort heaps
+ if block and block.info.id == index then
+ block.posIndex = tMove(free, used, block)
+ print(' |cFFFFFF00using '..handler.name..'|r.|cFF00FFBBusedBlocks['..tostring(block.posIndex)..'] ('.. block:GetName()..', "'..tostring(block.info.title)..'")')
+ else
+ local source = 'cache'
+ if #handler.freeBlocks >= 1 then
+ block = tremove(handler.freeBlocks)
+ print(' |cFF00FF00 assigning from free heap', block:GetName())
+ else
+
+ local blockIndex = (#handler.usedBlocks + #handler.freeBlocks) + 1
+ block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, handler.frame, 'VeneerTrackerBlock')
+ --block:SetParent()
+ block.schema = ''
+ block.lines = {}
+ block.numLines = 0
+ block.currentLine = 0
+ block.attachmentHeight = 0
+ block.offset = 0
+ B.SetConfigLayers(block)
+ --- methods for event handlers
+
+ block.Select = handler.Select
+ block.Open = handler.Open
+ block.Remove = handler.Remove
+ block.Link = handler.Link
+ block.clickZone:SetScript('OnMouseUp', function(self, ...) handler.OnMouseUp(block, ...) end)
+ block.clickZone:SetScript('OnMouseDown', function(self, ...) handler.OnMouseDown(block, ...) end)
+ block:ClearAllPoints()
+ block.index = blockIndex
+
+ block.blockFadeOut:SetScript('OnPlay', blockFadeOut_OnPlay)
+
+ source = 'new'
+ end
+ handler.InfoBlock[index] = block
+ block.posIndex = tMove(free, used, block)
+ print(' |cFF00FF00('..source..')|r |cFF0088FF'..handler.name..'|r.|cFF00FFBBusedBlocks['..block.posIndex..'] =|r', block:GetName())
+ end
+ block.blockFadeOut:SetScript('OnFinished', blockFadeOut_OnFinished)
+ block:SetScript('OnHide', function(self)
+ self.blockFadeOut:SetScript('OnFinished', blockFadeOut_OnFinished)
+ end)
+ print(' used/free: |cFFFFFF00' .. #handler.usedBlocks .. '|r/|cFF00FFFF'..#handler.freeBlocks ..'|r')
+ return block
+end
+
+--- begins a blockFadeOut animation and fires FreeBlock when that's done
+Default.ClearBlock = function(handler, block)
+ if block.isAnimating then
+ return
+ end
+
+ block.isAnimating = true
+ block.blockFadeOut:SetScript('OnFinished', nil)
+ block.blockFadeOut:SetScript('OnFinished', function(self)
+ fprint(self:GetName(), '|cFFFFFF00FINISHED|r', debugstack())
+ handler:FreeBlock(block)
+ self:SetScript('OnFinished', blockFadeOut_OnFinished)
+ block.isAnimating = nil
+ end)
+ block.blockFadeOut:Play()
+end
+
+--- remove a block from visible existence; not called directly
+Default.FreeBlock = function(handler, block)
+ bprint('|cFFFF4400FreeBlock|r', block:GetName())
+ local used = handler.usedBlocks
+ local free = handler.freeBlocks
+ tMove(used, free, block)
+
+ bprint(' |cFFFF4444used/free:|r |cFFFFFF00' .. #used .. '|r/|cFF00FFFF'..#free ..'|r')
+
+ block:Hide()
+ local animations = {block:GetAnimationGroups() }
+ for i, animGroup in ipairs(animations) do
+ bprint(' animGroup', i, animGroup:GetName())
+ animGroup:Stop()
+ end
+end
+
+
+
+--- Get a usable widget for the given achievement criteria set.
+-- Returns a frame object with dimensioning parameters needed to size the receiving tracker block
+local wr = T.WidgetRegistry
+T.GetWidget = function(data, objectiveType, objectiveKey)
+ local print = B.print('ObjectiveWidgets')
+ local widgetType = objectiveType
+ local widget
+ local isNew
+ if wr[widgetType] and wr[widgetType].used[objectiveKey] then
+ widget = wr[widgetType].used[objectiveKey]
+ print('|cFF00FF00Updating ('..objectiveKey..')', widget)
+ elseif not wr[widgetType] or #wr[widgetType].free == 0 then
+ -- creating a new frame
+ isNew = true
+ widget = CreateFrame(widgetType, 'VeneerObjective' .. widgetType .. (wr[widgetType] and (wr[widgetType].lastn+1) or (1)), VeneerObjectiveScroll, 'VeneerObjectiveCriteria' .. widgetType)
+ print('|cFFFF0088Creating `'..widget:GetName()..'` id', wr[widgetType].lastn)
+ T.UpdateSchema(widgetType, data.schema or 'default')
+ else
+ -- recycling for a different criteria set
+ isNew = true
+ widget = tremove(wr[widgetType].free)
+ print('|cFFFFFF00Acquiring released widget', widget:GetName())
+ end
+
+ for k,v in pairs(data) do
+ if not widget[k] then
+ widget[k] = v
+ tprint('widget', widget:GetName(), k, v)
+ end
+ end
+
+ wr[widgetType].used[objectiveKey] = widget
+ widget.objective = data
+ widget.key = objectiveKey
+ T.InitializeWidget(widget, isNew)
+ return widget
+end
\ No newline at end of file
diff -r 92534dc793f2 -r 03ed70f846de ObjectiveTracker/TrackerFrame.lua
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ObjectiveTracker/TrackerFrame.lua Sun Apr 24 14:15:25 2016 -0400
@@ -0,0 +1,698 @@
+--- ${PACKAGE_NAME}
+-- @file-author@
+-- @project-revision@ @project-hash@
+-- @file-revision@ @file-hash@
+-- Created: 3/30/2016 12:49 AM
+--- Everything that involves directly placing elements on the screen goes here. Sizing, spacing, tiling, etc.
+local B = select(2,...).frame
+local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame')
+local _G, ipairs, max, min, unpack, floor, pairs, tostring, type, band = _G, ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band
+local IsResting, UnitXP, UnitXPMax, GetXPExhaustion, tinsert, tremove = IsResting, UnitXP, UnitXPMax, GetXPExhaustion, table.insert, table.remove
+local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent
+local GetAutoQuestPopUp, GetQuestLogCompletionText = GetAutoQuestPopUp, GetQuestLogCompletionText
+local PERCENTAGE_STRING, GetQuestProgressBarPercent = PERCENTAGE_STRING, GetQuestProgressBarPercent
+local Default, AutoQuest, Quest, Bonus, Cheevs = T.DefaultHandler, T.AutoQuest, T.Quest, T.Bonus, T.Cheevs
+local InCombatLockdown, format, lshift, CreateFrame = InCombatLockdown, format, bit.lshift, CreateFrame
+local IsModifiedClick, ChatEdit_GetActiveWindow = IsModifiedClick, ChatEdit_GetActiveWindow
+local band, bor = bit.band, bit.bor
+local print = B.print('Layout')
+local oprint = B.print('Objectives')
+local bprint = B.print('Block')
+local tprint = B.print('Tracker')
+local lprint = B.print('Layout')
+local unitLevel = 1
+
+local REWARD_POPUP = _G.VeneerRewardsPopOut
+local ANIM_STATE = 'Animation: %04X'
+local INIT_STATE = 'Init: %04X'
+
+--- Bitfields of import
+--- control value for everything
+local OBJECTIVE_TRACKER_UPDATE_REASON = _G.OBJECTIVE_TRACKER_UPDATE_REASON
+--- flags reason categories where frame layout requires initializing (starts high)
+local initReason = 0xFFFF
+--- flags reason categories where frame anchor updates must be delayed because of an ongoing animation (starts low)
+local animateReason = 0x0000
+
+--- FRAMES
+local Wrapper = _G.VeneerObjectiveWrapper
+local Scroller = Wrapper.scrollArea
+local Scroll = _G.VeneerObjectiveScroll
+local orderedHandlers = T.orderedHandlers
+local orderedNames = T.orderedNames
+
+--- FRAME TEMP VARIABLES
+local wrapperWidth, wrapperHeight = 0, 0
+local scrollWidth, scrollHeight
+
+--- SCHEMA VARIABLES
+local schemaName, lastSchema = {
+ tracker = '',
+ block = '',
+ line = ''
+}, {}
+local trackerSchema, blockSchema, lineSchema
+
+local itemButtonSize, itemButtonSpacing = 36, 1
+local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed
+local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE'
+local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0 }
+local rewardSize = 24
+
+local headerHeight, headerColor, headerSpacing = 16, {1,.75,0,1}, 2
+local headerbg = {'VERTICAL', 1, 1, 0.5, 0.5, 1, 1, 0.5, 0}
+local headerFont, headerSize, headerOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 14, 'OUTLINE'
+
+local titlebg = {'HORIZONTAL', 1, 0, .7, 0, 1, 0, .7, .2}
+local titleFont, titleSize, titleOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'OUTLINE'
+local titleColor = {0,.7,1,1}
+
+local textbg = {'HORIZONTAL', 0, 0, 0, 0.4, 0, 0, 0, 0 }
+local textFont, textSize, textOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Regular.ttf]], 16, 'OUTLINE'
+local textColor = {1,1,1,1 }
+
+local widgetTextFont, widgetTextSize, widgetTextOutline = [[Interface\Addons\SharedMedia_MyMedia\font\XOIREQE.TTF]], 11, 'OUTLINE'
+local widgetTextColor = {1,1,1,1 }
+local widgetHeight, widgetBorder = 17, 1
+
+
+local selectionbg = {'HORIZONTAL', 1, 1, 1, 0, 1, 1, 1, 0.225}
+local titleSpacing, textSpacing, blockSpacing = 3, 3, 1
+local titleIndent, textIndent,selectionIndent = 2, 5, 50
+--- END SCHEMA
+local blockPosition
+
+
+local SetAnimate = function(reason, animate)
+ print('comparing', animateReason, reason)
+ if animate then
+ if band(animateReason, reason) == 0 then
+ animateReason = animateReason + reason
+ end
+ else
+ if band(animateReason, reason) > 0 then
+ animateReason = animateReason - reason
+ end
+ end
+ Wrapper.AnimState:SetFormattedText(ANIM_STATE, animateReason)
+end
+
+
+--- schema swapper
+T.UpdateSchema = function(layer, newSchema)
+ if not (T.Conf.Schema[layer] and T.Conf.Schema[layer][newSchema]) then
+ return
+ elseif schemaName[layer] == newSchema then
+ return
+ end
+ lastSchema[layer] = schemaName[layer]
+ schemaName[layer] = newSchema
+ local c = T.Conf.Schema[layer][newSchema]
+
+ if layer == 'tracker' then
+ headerHeight, headerSpacing = c.headerHeight, c.headerSpacing
+ headerColor = c.headerColor
+ headerbg = c.headerbg
+ headerFont, headerSize, headerOutline = unpack(c.headerFont)
+ trackerSchema = newSchema
+ elseif layer == 'block' then
+ titlebg = c.titlebg
+ titleFont, titleSize, titleOutline = unpack(c.titleFont)
+ selectionbg = c.selectionbg
+ titleSpacing, textSpacing, blockSpacing = c.titleSpacing, c.textSpacing, c.blockSpacing
+ titleIndent, textIndent,selectionIndent = c.titleIndex, c.textIndex, c.selectionIndent
+ titleColor = c.titleColor
+ print(unpack(c.titleColor))
+ rewardSize = 24
+ textFont, textSize, textOutline = unpack(c.textFont)
+ textbg = c.textbg
+ textIndent = c.textIndent
+ rewardSize = c.rewardSize
+ blockSchema = newSchema
+ elseif layer == 'line' then
+ textColor = c.textColor
+ lineSchema = newSchema
+ elseif layer == 'widget' then
+ widgetTextColor = c.textSpacing
+ widgetTextFont, widgetTextSize, widgetTextOutline = unpack(c.textFont)
+ end
+ tprint('|cFFFF0088 Schema:|r', layer, lastSchema[layer], '->', newSchema)
+end
+-- todo: figure out why objectives go invisible
+local anchorPoint, anchorFrame
+local abs, GetTime = math.abs, GetTime
+Default.AddTracker = function(handler, frame, index)
+ local isInitialized = true
+ if initReason and (band(initReason, handler.updateReason) > 0 ) then
+ isInitialized = false
+ initReason = initReason - handler.updateReason
+ print('|cFF00FF00%%% initialization status update:', format('%04X', initReason))
+
+ frame.SlideIn:SetScript('OnPlay', function()
+ SetAnimate(handler.updateReasonModule, true)
+ end)
+
+ frame.SlideIn:SetScript('OnFinished', function()
+ SetAnimate(handler.updateReasonModule, false)
+ end)
+
+ if initReason == 0 then
+ initReason = nil
+ end
+ end
+
+ if index == 1 then
+ print('|cFF00FF00### beginning wrapper layout -----------------')
+ anchorPoint, anchorFrame = 'TOP', Scroll
+ wrapperHeight = 18
+ end
+
+ frame.destinationOffset = -wrapperHeight
+ print(frame.destinationOffset, frame.previousOffset)
+ if isInitialized and (abs(frame.previousOffset - frame.destinationOffset) > 0.9) and frame:IsVisible() then
+ if frame.wasEmpty then
+ frame.previousOffset = -Wrapper:GetHeight()
+ end
+
+ local postFrame, postPoint = anchorFrame, anchorPoint
+ local delta = frame.destinationOffset - frame.previousOffset
+ local _, _, _, _, offset = frame:GetPoint(1)
+ print(' |cFF00FFBBpushing', frame:GetName(), delta, 'pixels, from', frame.previousOffset, '(', offset, ')')
+ frame.SlideIn.translation:SetTarget(frame)
+ frame.SlideIn.translation:SetOffset(0, delta)
+ frame.SlideIn:Play()
+ --for i, b in ipairs(handler.usedBlocks) do
+ --b.SlideIn.translation:SetOffset(0, delta)
+ -- b.SlideIn:Play()
+ --end
+ local start = GetTime()
+ frame.SlideIn:SetScript('OnFinished', function()
+ print(' |cFF00BBFF'..frame:GetName(), 'moved', delta, 'over duration of ', GetTime()-start)
+ frame:SetParent(Scroll)
+ frame:SetPoint('TOP', Scroll, 'TOP', 0, frame.destinationOffset)
+ frame.previousOffset = frame.destinationOffset
+ frame.SlideIn:SetScript('OnFinished', nil)
+ if Wrapper.destinationHeight then
+ Wrapper:SetHeight(Wrapper.destinationHeight)
+ Scroller:SetHeight(Wrapper.destinationHeight)
+ Scroll:SetHeight(Wrapper.destinationHeight)
+ Wrapper.previousHeight = Wrapper.destinationHeight
+ Wrapper.destinationHeight = nil
+ end
+
+ end)
+ else
+ print(' |cFF00BBFFpinning '..handler.name..' to', anchorFrame:GetName(), anchorPoint, '|rcurrent frame height:', frame.height)
+ print(' |cFFFF0088total height:', wrapperHeight)
+ frame:ClearAllPoints()
+ frame:Show()
+ frame:SetParent(Scroll)
+ frame:SetPoint('TOP', Scroll, 'TOP', 0, frame.destinationOffset)
+ frame:SetPoint('LEFT', Scroll, 'LEFT')
+ frame:SetPoint('RIGHT', Scroll, 'RIGHT')
+ frame.previousOffset = frame.destinationOffset
+ handler.initialized = true
+ end
+
+ frame.title:SetFont(headerFont, headerSize, headerOutline)
+ frame.titlebg:SetHeight(headerHeight)
+ frame.title:SetTextColor(unpack(headerColor))
+
+ if frame.height ~= frame.previousHeight then
+ frame:SetHeight(frame.height)
+ end
+
+ if frame.wasEmpty then
+ frame.headerFade:Play()
+ frame.wasEmpty = nil
+ end
+
+ wrapperHeight = wrapperHeight + frame.height
+ anchorFrame = handler.frame
+ anchorPoint = 'BOTTOM'
+
+end
+
+Default.AddBlock = function(self, block, blockIndex)
+ local blockIndex = blockIndex or (self.currentBlock + 1)
+ local print = bprint
+ local tracker = self.frame
+ local info = block.info
+
+ block.index = blockIndex
+
+ print('blockschema', blockSchema, block.schema)
+ if blockSchema ~= block.schema then
+ T.UpdateSchema('block', block.schema)
+ print(' ### activating block schema:|cFF0088FF', block.schema)
+ end
+
+ block:SetWidth(T.Conf.Wrapper.Width)
+ block.title:SetSpacing(titleSpacing)
+ block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing)
+ block.title:SetPoint('LEFT', block, 'LEFT', titleIndent, 0)
+ block.title:SetTextColor(unpack(titleColor))
+ block.titlebg:SetTexture(1,1,1,1)
+ block.titlebg:SetGradientAlpha(unpack(titlebg))
+ block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0)
+ block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing)
+ block.status:SetSpacing(textSpacing)
+ block.status:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, -textSpacing)
+ block.status:SetPoint('LEFT', block.titlebg, 'LEFT', textIndent, 0)
+ block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0)
+ block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0)
+ block.statusbg:SetTexture(1,1,1,1)
+ block.statusbg:SetGradientAlpha(unpack(textbg))
+ block.SelectionOverlay:SetGradientAlpha(unpack(selectionbg))
+ block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0)
+ block.SelectionOverlay:SetPoint('BOTTOMRIGHT')
+
+ local anchor, target, point, x, y = 'TOPRIGHT', block, 'TOPRIGHT', -2, -2
+ for i, tile in ipairs(block.rewardTile) do
+ --print(rewardSize)
+ tile:SetSize(rewardSize, rewardSize)
+ tile:ClearAllPoints()
+ tile:SetPoint(anchor, target, point, x, y)
+ block.rewardLabel[i]:SetPoint('TOP', tile, 'TOP', 0, 0)
+ anchor, target, point, x, y = 'TOPRIGHT', tile, 'TOPLEFT', -2, 0
+ end
+
+
+ local titleHeight = floor(block.title:GetHeight()+.5)
+ local titlebgHeight = titleHeight + titleSpacing*2
+ block.titlebg:SetHeight(titlebgHeight)
+
+ local statusHeight = floor(block.status:GetHeight()+.5)
+ local statusbgHeight = statusHeight + textSpacing*2
+ local attachmentHeight =floor(block.attachmentHeight + .5)
+
+ self.print('AddBlock', 'anchor to|cFF0088FF', self.currentAnchor:GetName())
+ self.print('AddBlock', 'attachment:|cFF00FF00', attachmentHeight, '|rtitle:|cFF00FF00', titlebgHeight, '|r('.. titleHeight..')')
+ if attachmentHeight > 0 then
+ attachmentHeight = attachmentHeight + textSpacing
+ end
+
+ block.height = titlebgHeight + attachmentHeight
+ block:SetHeight(block.height)
+
+ if block.debug then
+ local func = (B.Conf.GuidesMode == true) and 'Show' or 'Hide'
+ for _, region in ipairs(block.debug) do
+ region[func]()
+ end
+ end
+
+ --- Handler vars
+ if blockIndex == 1 then
+ tracker.previousHeight = tracker.height
+ tracker.height = headerHeight
+ blockPosition = -headerHeight
+ self.print('AddBlock', 'new layout: headerHeight:|cFF00FF00', headerHeight, '|rpreviousHeight:|cFF00FF00', tracker.previousHeight)
+ else
+ blockPosition = blockPosition
+ self.print('AddBlock', 'advancing: height:|cFF8888FF', tracker.height)
+ end
+ self.currentBlock = blockIndex
+ self.currentAnchor = block
+
+ block:SetPoint('TOPLEFT', self.frame, 'TOPLEFT', 0, blockPosition)
+ block:SetPoint('RIGHT', tracker,'RIGHT', 0, 0)
+ self.numBlocks = self.numBlocks + 1
+ print(' |cFFFFFF00'..tracker.height..'|r', '|cFF00FF00'..block:GetName()..'|r', block.height, tracker.height)
+ tracker.height = tracker.height + block.height
+ blockPosition = blockPosition - block.height
+
+ block:Show()
+
+
+ if Devian and Devian.InWorkspace() then
+ block.DebugTab:SetParent(UIParent)
+ block.DebugTab:SetPoint('TOPRIGHT', block, 'TOPLEFT', 0, 0)
+ block.DebugTab.status:SetText(tostring(block.schema) .. ' @|cFF00FF00' .. tostring(block.posIndex) .. '|r #|cFFFFFF00'.. tostring(info.logIndex or info.id) .. '|r'..
+ ' H|cFFFFFF00' .. tostring(block.height) .. ' L|cFF00FFFF' .. tostring(block.numLines) ..'|r')
+ block.DebugTab:Show()
+ end
+end
+
+--- Used as an iterator of sorts for cascaded tag icon placements (the daily/faction/account icons)
+Default.AddTag = function (handler, block, tagInfo, tagPoint, tagAnchor, tagRelative)
+ local print = bprint
+
+ for order, tagName in ipairs(block.info.tagInfo) do
+ local tag = block[tagName]
+ if block.tagCoords[tagName] and tag then
+ tag:SetTexCoord(unpack(block.tagCoords[tagName]))
+ tag:Show()
+ tag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0)
+ tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', tag, 'TOPLEFT'
+ else
+ block[tagName]:Hide()
+ end
+ end
+
+ return tagPoint, tagAnchor, tagRelative
+end
+
+
+--- Adds the given line to the current content and advances the anchor pointer to that new line for the following call.
+Default.AddLine = function(handler, block, text, attachment, template)
+ local print = lprint
+ local lineIndex = block.currentLine + 1
+ local line = handler:GetLine(block, lineIndex)
+
+ line.index = lineIndex
+ template = template or 'default'
+ if template and lineSchema ~= template then
+ print(' |cFF00FF00change schema', template)
+ T.UpdateSchema('line', template)
+ end
+ line.status:SetSpacing(textSpacing)
+ line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
+ line.status:SetPoint('RIGHT', line, 'RIGHT',0, 0)
+ line.status:SetTextColor(unpack(textColor))
+ line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, -textSpacing)
+ line.status:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
+ line:SetPoint('LEFT', block, 'LEFT')
+ line:SetPoint('RIGHT', block, 'RIGHT')
+ line:Show()
+ line:SetScript('OnMouseUp', function(self, button)
+ handler.OnMouseUp(block, button)
+ end)
+
+
+ handler.print('AddLine', '|cFF00FFFF'..tostring(line.schema)..'|r', line:GetName())
+ --[[
+ for i = 1, line:GetNumPoints() do
+ tprint(' - ', line:GetPoint(i))
+ end
+ tprint(' - ', line:GetSize())
+ tprint(' - ', line:GetParent(), line:GetParent():IsVisible())
+ tprint(' - ', line:IsVisible())
+ --]]
+
+
+
+
+ -- fill in the text, then derive pixel-rounded height
+ line.status:SetText(text)
+ line.height = floor(line.status:GetStringHeight()+.5)
+
+ -- For progressbar and timer lines, status text may be used as the title heading
+ if attachment then
+ attachment:SetPoint('TOP', line, 'TOP')
+ attachment:SetPoint('LEFT', line, 'LEFT', textIndent, 0)
+ attachment:SetPoint('RIGHT', line, 'RIGHT')
+ print(' |cFFFF0088doing things with a widget', attachment:GetSize())
+ line.height = attachment:GetHeight()
+ if text then
+ line.height = max(line.height, line.status:GetStringHeight())
+ end
+ if attachment.status:GetText() then
+ line.height = max(line.height, attachment.status:GetStringHeight())
+ end
+ attachment:Show()
+ end
+
+ line:SetHeight(line.height)
+ block.attachmentHeight = block.attachmentHeight + line.height + textSpacing
+
+ local debug_points = ''
+ for i = 1, line:GetNumPoints() do
+ local point, parent, anchor = line:GetPoint(i)
+ debug_points = debug_points .. tostring(parent:GetName()) .. ', ' .. anchor .. ' '
+ end
+
+ print(' |cFF0088FFsetting line #'..lineIndex..' for|r', block.info.title, "\n |cFF0088FFsize:|r", line.height,
+ "|cFF0088FFpoint:|r", debug_points, "|cFF0088FFwidget:|r", (line.widget and 'Y' or 'N'))
+ block.currentLine = lineIndex
+ block.endPoint = line -- edge used for the next block
+
+ return lineIndex
+end
+
+
+
+----------
+--- Top level methods
+
+
+T.UpdateItemButtonAnchor = function (block, itemButton)
+ local print = bprint
+ print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()')
+ if itemButton.questID ~= block.info.questID then
+ print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID)
+ -- something happened between this and last frame, go back and set new probes
+ return T.UpdateActionButtons()
+ end
+
+ local previousItem = itemButton.previousItem
+ local upper_bound = Scroller:GetTop() + Scroller.snap_upper
+ local lower_bound = Scroller:GetBottom() + Scroller.snap_lower + itemButtonSize
+ local point, anchor, relative
+
+ if block:GetBottom() < lower_bound then
+ print('** ',block:GetName() ,'|cFFFFFF00bottom =', floor(block:GetBottom()+.5), 'threschold =', floor(lower_bound+.5))
+ if previousItem then
+ print('adjusting', previousItem:GetName())
+ previousItem:ClearAllPoints()
+ previousItem:SetPoint('BOTTOM', itemButton, 'TOP', 0, itemButtonSpacing)
+ end
+ itemButton:ClearAllPoints()
+ itemButton.x = Wrapper:GetLeft() -4
+ itemButton.y = Wrapper:GetBottom()
+ point, anchor, relative = 'BOTTOMRIGHT', UIParent, 'BOTTOMLEFT'
+ Scroller.snap_lower = Scroller.snap_lower + itemButtonSize + itemButtonSpacing
+
+ elseif block:GetTop() > upper_bound then
+ print('** ',block:GetName() ,'|cFFFFFF00top =', floor(block:GetTop()+.5), 'threschold =', floor(upper_bound+.5))
+ itemButton:ClearAllPoints()
+ if previousItem then
+ print('latch onto another piece')
+ point, anchor, relative ='TOP', previousItem, 'BOTTOM'
+ itemButton.x = 0
+ itemButton.y = -itemButtonSpacing
+ else
+ print('latch at corner', Scroller:GetLeft() -itemButtonSpacing, Scroller:GetTop())
+ point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
+ itemButton.x = Scroller:GetLeft() -4
+ itemButton.y = Scroller:GetTop()
+ end
+ itemButton:Show()
+ Scroller.snap_upper = Scroller.snap_upper - (itemButtonSize + itemButtonSpacing)
+ else
+ print('** ',block:GetName() ,'|cFF00FF00span =', floor(block:GetBottom()+.5), floor(block:GetTop()+.5), 'threschold =', floor(lower_bound+.5))
+ itemButton:ClearAllPoints()
+ itemButton.x = block:GetLeft() - itemButtonSpacing
+ itemButton.y = block:GetTop()
+ point, anchor, relative = 'TOPRIGHT', UIParent, 'BOTTOMLEFT'
+ end
+
+ itemButton:SetPoint(point, anchor, relative, itemButton.x, itemButton.y)
+ itemButton:Show()
+end
+
+T.UpdateItemButtonCooldown = function(button)
+
+end
+
+function T:FinishWrapper ()
+ if wrapperHeight > Wrapper.previousHeight then
+ Wrapper:SetHeight(wrapperHeight)
+ Scroller:SetHeight(wrapperHeight*3)
+ Scroll:SetHeight(wrapperHeight)
+ Wrapper.previousHeight = wrapperHeight
+ Wrapper.destinationHeight = wrapperHeight
+ end
+ Scroller:SetVerticalScroll(B.Conf.ObjectiveScroll or 0)
+ print('|cFF00FF00### end of wrapper layout', Wrapper:GetSize())
+ print(' |cFF00FF00Scroller:', Scroller:GetSize())
+ print(' |cFF00FF00Scroll:', Scroll:GetSize())
+ for i = 1, Wrapper:GetNumPoints() do
+ print('|cFF00FF00 ', Wrapper:GetPoint(i))
+ end
+ for i = 1, Scroller:GetNumPoints() do
+ print('|cFF00FF00 ', Scroller:GetPoint(i))
+ end
+ for i = 1, Scroll:GetNumPoints() do
+ print('|cFF00FF00 ', Scroll:GetPoint(i))
+ end
+
+ if Devian and Devian.InWorkspace() then
+ Wrapper.AnimState:SetFormattedText(ANIM_STATE, animateReason)
+ end
+
+ Wrapper:Show()
+ Scroller:Show()
+ Scroll:Show()
+end
+
+
+-----------------------------------------
+-- Criteria frames
+
+--[[
+ text = description,
+ type = type,
+ finished = completed,
+ quantity = quantity,
+ requiredQuantity = requiredQuantity,
+ characterName = characterName,
+ flags = flags,
+ assetID = assetID,
+ quantityString = quantityString,
+ criteriaID = criteriaID,
+]]
+T.WidgetRegistry = {}
+local wr = T.WidgetRegistry
+
+--- WidgetTemplate 'OnLoad'
+T.RegisterWidget = function(frame)
+ local print = B.print('ObjectiveWidgets')
+ local widgetType = frame.widgetType
+ if not wr[frame.widgetType] then
+ print('|cFFFF4400[[WidgetTemplate]]|r', widgetType)
+ wr[widgetType] = { lastn = 1, free = {}, used = {}, usedIndex = {}, freeIndex = {} }
+ else
+ print('|cFF0088FF+ [[WidgetTemplate]]r', widgetType, wr[widgetType].lastn)
+ wr[widgetType].lastn = wr[widgetType].lastn + 1
+ end
+end
+--- WidgetTemplate 'OnShow'
+local wrapperWidth, textIndent
+T.InitializeWidget = setmetatable({}, {
+ __call = function(t, frame, isNew, ...)
+ -- todo: config pull
+ if not wrapperWidth then
+ wrapperWidth = T.Conf.Wrapper.Width
+ textIndent = T.Conf.Wrapper.TextIndent
+ end
+
+ tprint('Initialize', frame:GetName(), isNew, ...)
+ frame:SetWidth(wrapperWidth - textIndent * 2)
+ frame:SetScript('OnEvent', T.UpdateWidget[frame.widgetType])
+ frame:RegisterEvent('QUEST_LOG_UPDATE')
+ frame:RegisterEvent('TRACKED_ACHIEVEMENT_UPDATE')
+ frame:RegisterEvent('TRACKED_ACHIEVEMENT_LIST_CHANGED')
+ frame:RegisterEvent('CRITERIA_UPDATE')
+ frame:RegisterEvent('CRITERIA_COMPLETE')
+ frame:RegisterEvent('CRITERIA_EARNED')
+ t[frame.widgetType](frame, isNew)
+ T.UpdateWidget[frame.widgetType](frame, isNew)
+ end,
+})
+
+--- WidgetTemplate 'OnEvent'
+T.UpdateWidget = setmetatable({}, {
+ __call = function(t, frame, isNew, ...)
+ tprint('Update', frame:GetName(), isNew, ...)
+ if not frame.widgetType then
+ return
+ end
+
+ return t[frame.widgetType](frame, isNew)
+ end
+})
+
+
+local progressHeight = 17
+local progressBorder = 1
+local progressFont = _G.VeneerCriteriaFontNormal
+
+local lprint = B.print('Line')
+T.InitializeWidget.StatusBar = function(self, isNew)
+ local print = lprint
+ local c = T.Conf.Wrapper
+
+ tprint(self:GetName(), isNew)
+ if isNew then
+ self:SetMinMaxValues(0, self.maxValue)
+
+ self:SetHeight(widgetHeight)
+ self.height = widgetHeight
+
+ self.status:SetFont(widgetTextFont, widgetTextSize, widgetTextOutline)
+ self.status:SetTextColor(unpack(widgetTextColor))
+ end
+ self:SetValue(self.value)
+
+ self.status:SetText(self.objective.quantityString)
+end
+
+T.UpdateWidget.StatusBar = function (self)
+ local value, maxValue = self.value, self.maxValue
+ print('update vals:')
+ for k,v in pairs(self) do
+ print(k, v)
+ end
+ self.width = self.width or self:GetWidth()
+ self:SetValue(self.value)
+ local format = self.format or '%d/%d'
+ self.status:SetFormattedText(format, value, maxValue)
+ local progress = (value / maxValue)
+ if progress > 0 then
+ print('color:', 1-progress*2 , progress*2 - 1,0,1)
+ print('width:', (self.width -progressBorder * 2) * progress)
+ self:SetStatusBarColor(1-progress*2 , progress*2,0,1)
+ end
+end
+
+
+T.InitializeWidget.Hidden = function (self)
+ self.height = 0
+end
+T.UpdateWidget.Hidden = function (self)
+ self.height= 0
+end
+
+
+--- Queue any active item buttons for update for that frame
+local iprint = B.print('ItemButton')
+local Quest = T.Quest
+local IsQuestWatched, InCombatLockdown = IsQuestWatched, InCombatLockdown
+T.UpdateActionButtons = function(updateReason)
+ local print = iprint
+ Scroller.snap_upper = 0
+ Scroller.snap_lower = 0
+ local print = B.print('ItemButton')
+ if updateReason then
+ print = B.print('IB_'..updateReason)
+ end
+
+ local previousItem
+ for questID, itemButton in pairs(Quest.itemButtons) do
+ local info= T.Quest.Info[questID]
+
+ print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName())
+ local block = T.Quest.QuestBlock[questID]
+ if block then
+ -- Dispatch the probe
+ if IsQuestWatched(info.logIndex) then
+ itemButton.previousItem = previousItem
+ print(' |cFFFFFF00probing', block:GetName())
+ block:SetScript('OnUpdate', function()
+ if block:GetBottom() and not InCombatLockdown() then
+ print(' '..block:GetName()..' |cFF00FF00probe hit!')
+ T.UpdateItemButtonAnchor(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope
+ block:SetScript('OnUpdate', nil)
+
+ end
+ end)
+ previousItem = itemButton
+ else
+ print('hidden block or unwatched quest')
+ itemButton.previousItem = nil
+ itemButton:Hide()
+ end
+ elseif itemButton:IsVisible() then
+ print(' |cFFFF0088hiding unwatched quest button', itemButton:GetName())
+ itemButton.previousItem = nil
+ itemButton:Hide()
+ else
+ print(' |cFFBBBBBBignoring hidden log quest button', itemButton:GetName())
+ end
+ end
+end
+
+Default.FadeOutBlock = function (handler, blockIndex)
+
+end
\ No newline at end of file
diff -r 92534dc793f2 -r 03ed70f846de ObjectiveTracker/Widgets.xml
--- a/ObjectiveTracker/Widgets.xml Thu Apr 21 16:43:37 2016 -0400
+++ b/ObjectiveTracker/Widgets.xml Sun Apr 24 14:15:25 2016 -0400
@@ -11,9 +11,6 @@
Veneer.ObjectiveTracker.InitializeWidget(self)
-
- Veneer.ObjectiveTracker.ReleaseWidget(self)
-
@@ -66,9 +63,6 @@
Veneer.ObjectiveTracker.InitializeWidget(self)
-
- Veneer.ObjectiveTracker.ReleaseWidget(self)
-
@@ -90,9 +84,6 @@
Veneer.ObjectiveTracker.InitializeWidget(self)
-
- Veneer.ObjectiveTracker.ReleaseWidget(self)
-