Mercurial > wow > buffalo2
comparison ObjectiveTracker/Frame.lua @ 30:7583684becf4
- implement procedural block contents generation
- redo anchor calculations to allow for transitional animation
- attempt to sort out event handling quirks related to autopopup quest completion and turn-in
- revise the data structures created by the different GetInfo's
- start on trimming out redundant variables
| author | Nenue |
|---|---|
| date | Thu, 14 Apr 2016 17:11:13 -0400 |
| parents | adcd7c328d07 |
| children | 48b3e3959a0a |
comparison
equal
deleted
inserted
replaced
| 29:adcd7c328d07 | 30:7583684becf4 |
|---|---|
| 2 -- @file-author@ | 2 -- @file-author@ |
| 3 -- @project-revision@ @project-hash@ | 3 -- @project-revision@ @project-hash@ |
| 4 -- @file-revision@ @file-hash@ | 4 -- @file-revision@ @file-hash@ |
| 5 -- Created: 3/30/2016 12:49 AM | 5 -- Created: 3/30/2016 12:49 AM |
| 6 local B = select(2,...).frame | 6 local B = select(2,...).frame |
| 7 local T = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') | 7 local Module = B:RegisterModule("ObjectiveTracker", _G.VeneerObjectiveWrapper, 'BuffFrame') |
| 8 local _G, ipairs, max, min, unpack, floor, pairs, tostring, type, band = _G, ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band | 8 local _G, ipairs, max, min, unpack, floor, pairs, tostring, type, band = _G, ipairs, max, min, unpack, floor, pairs, tostring, type, bit.band |
| 9 local IsResting, UnitXP, UnitXPMax, GetXPExhaustion = IsResting, UnitXP, UnitXPMax, GetXPExhaustion | 9 local IsResting, UnitXP, UnitXPMax, GetXPExhaustion = IsResting, UnitXP, UnitXPMax, GetXPExhaustion |
| 10 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent | 10 local UnitLevel, IsQuestWatched, UIParent = UnitLevel, IsQuestWatched, UIParent |
| 11 local GetAutoQuestPopUp, GetQuestLogCompletionText = GetAutoQuestPopUp, GetQuestLogCompletionText | 11 local GetAutoQuestPopUp, GetQuestLogCompletionText = GetAutoQuestPopUp, GetQuestLogCompletionText |
| 12 local PERCENTAGE_STRING, GetQuestProgressBarPercent = PERCENTAGE_STRING, GetQuestProgressBarPercent | 12 local PERCENTAGE_STRING, GetQuestProgressBarPercent = PERCENTAGE_STRING, GetQuestProgressBarPercent |
| 13 local Default, AutoQuest, Quest, Bonus, Cheevs = T.DefaultHandler, T.AutoQuest, T.Quest, T.Bonus, T.Cheevs | 13 local Default, AutoQuest, Quest, Bonus, Cheevs = Module.DefaultHandler, Module.AutoQuest, Module.Quest, Module.Bonus, Module.Cheevs |
| 14 local InCombatLockdown, format, lshift, CreateFrame = InCombatLockdown, format, bit.lshift, CreateFrame | 14 local InCombatLockdown, format, lshift, CreateFrame = InCombatLockdown, format, bit.lshift, CreateFrame |
| 15 local IsModifiedClick, ChatEdit_GetActiveWindow = IsModifiedClick, ChatEdit_GetActiveWindow | 15 local IsModifiedClick, ChatEdit_GetActiveWindow = IsModifiedClick, ChatEdit_GetActiveWindow |
| 16 local print = B.print('Tracker') | 16 local print = B.print('Tracker') |
| 17 local unitLevel = 1 | 17 local unitLevel = 1 |
| 18 local OBJECTIVE_TRACKER_UPDATE_REASON = OBJECTIVE_TRACKER_UPDATE_REASON | 18 local OBJECTIVE_TRACKER_UPDATE_REASON = OBJECTIVE_TRACKER_UPDATE_REASON |
| 19 local debug = false | 19 local debug = false |
| 20 -------------------------------------------------------------------- | |
| 21 --- Global frame layout | |
| 22 -------------------------------------------------------------------- | |
| 23 | 20 |
| 24 --- Upvalues | 21 --- Upvalues |
| 25 local Wrapper = _G.VeneerObjectiveWrapper | 22 local Wrapper = _G.VeneerObjectiveWrapper |
| 26 local Scroller = Wrapper.scrollArea | 23 local Scroller = Wrapper.scrollArea |
| 27 local Scroll = _G.VeneerObjectiveScroll | 24 local Scroll = _G.VeneerObjectiveScroll |
| 28 local orderedHandlers = T.orderedHandlers | 25 local orderedHandlers = Module.orderedHandlers |
| 29 local orderedNames = T.orderedNames | 26 local orderedNames = Module.orderedNames |
| 30 | 27 |
| 31 --- Temp values set during updates | 28 --- Temp values set during updates |
| 32 local wrapperWidth, wrapperHeight | 29 local wrapperWidth, wrapperHeight |
| 33 local scrollWidth, scrollHeight | 30 local scrollWidth, scrollHeight |
| 34 local previousBlock | 31 local previousBlock |
| 35 local currentBlock | 32 local currentBlock |
| 36 --- todo: source these from config | 33 --- todo: source these from config |
| 37 local itemButtonSize, itemButtonSpacing = 36, 1 | 34 local itemButtonSize, itemButtonSpacing = 36, 1 |
| 38 | 35 |
| 39 local headerHeight, headerColor, headerSpacing = 16, {1,1,1,1}, 2 | 36 local headerHeight, headerColor, headerSpacing = 16, {1,.75,0,1}, 2 |
| 40 local headerbg = {'VERTICAL', 1, 1, 0.5, 0.5, 1, 1, 0.5, 0} | 37 local headerbg = {'VERTICAL', 1, 1, 0.5, 0.5, 1, 1, 0.5, 0} |
| 41 local headerFont, headerSize, headerOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 14, 'OUTLINE' | 38 local headerFont, headerSize, headerOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 14, 'OUTLINE' |
| 42 | 39 |
| 43 local titlebg = {'HORIZONTAL', 1, 0, .7, .25, 1, 0, .7, .125} | 40 local titlebg = {'HORIZONTAL', 1, 0, .7, .25, 1, 0, .7, .125} |
| 44 local titlebg_daily = {'HORIZONTAL', 0, .7, 1, .25, 0, 1, .7, .125 } | 41 local titlebg_daily = {'HORIZONTAL', 0, .7, 1, .25, 0, 1, .7, .125 } |
| 52 | 49 |
| 53 | 50 |
| 54 local selectionbg = {'HORIZONTAL', 1, 1, 1, 0, 1, 1, 1, 0.225} | 51 local selectionbg = {'HORIZONTAL', 1, 1, 1, 0, 1, 1, 1, 0.225} |
| 55 local titleSpacing, textSpacing, blockSpacing = 3, 3, 1 | 52 local titleSpacing, textSpacing, blockSpacing = 3, 3, 1 |
| 56 local titleIndent, textIndent,selectionIndent = 2, 5, 50 | 53 local titleIndent, textIndent,selectionIndent = 2, 5, 50 |
| 54 | |
| 55 local lineColors = { | |
| 56 text = {.5,.75,1}, | |
| 57 } | |
| 57 | 58 |
| 58 local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed | 59 local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed |
| 59 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE' | 60 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE' |
| 60 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0 } | 61 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0 } |
| 61 local rewardSize = 32 | 62 local rewardSize = 32 |
| 62 local oprint = B.print('Objectives') | 63 local oprint = B.print('Objectives') |
| 63 local bprint = B.print('Block') | 64 local bprint = B.print('Block') |
| 64 local tprint = B.print('Tracker') | 65 local tprint = B.print('Tracker') |
| 65 local lprint = B.print('Line') | 66 local lprint = B.print('Line') |
| 66 | 67 |
| 67 local currentPosition, anchorFrame, anchorPoint | 68 Default.AddBlock = function(self, block, blockIndex) |
| 68 | 69 local blockIndex = blockIndex or (self.currentBlock + 1) |
| 69 --- Positioning and stuff | |
| 70 local tick = 0 | |
| 71 function T:Update (reason, ...) | |
| 72 tick = tick + 1 | |
| 73 local print = tprint | |
| 74 reason = reason or OBJECTIVE_TRACKER_UPDATE_REASON | |
| 75 local updateWrapper = 0 | |
| 76 local hasStuff | |
| 77 local insertingStuff | |
| 78 | |
| 79 print(format('%d |cFFFF%04X Update()', tick, lshift(reason, 4)), reason, ...) | |
| 80 currentPosition = 0 | |
| 81 anchorPoint = 'TOP' | |
| 82 anchorFrame = Scroll | |
| 83 | |
| 84 local wrapperHeight = 0 | |
| 85 for id, handler in pairs(T.orderedHandlers) do | |
| 86 local frame = handler.frame | |
| 87 | |
| 88 print(format('|cFF00FFFF%s and(%04X vs %04x+%04x) = %04X|r', handler.name, reason, handler.updateReasonModule, handler.updateReasonEvents, band(reason, handler.updateReasonModule + handler.updateReasonEvents))) | |
| 89 if band(reason, handler.updateReasonModule + handler.updateReasonEvents) > 0 then | |
| 90 handler:Update(reason, ...) | |
| 91 print(' |cFF00FF00'..id..'|r', handler.displayName, 'count:', handler.numWatched) | |
| 92 insertingStuff = true | |
| 93 else | |
| 94 print(' |cFFFF0088'..id..'|r', 'no reason to update') | |
| 95 end | |
| 96 | |
| 97 if handler.numWatched >= 1 then | |
| 98 hasStuff = true | |
| 99 currentPosition = currentPosition + 1 | |
| 100 frame:SetParent(Scroll) | |
| 101 frame:SetPoint('TOP', anchorFrame, anchorPoint, 0, 0) | |
| 102 print(' |cFF00BBFFpinning to', anchorFrame:GetName(), anchorPoint) | |
| 103 anchorFrame = handler.frame | |
| 104 anchorPoint = 'BOTTOM' | |
| 105 | |
| 106 print('current frame height:', frame.height) | |
| 107 wrapperHeight = wrapperHeight + frame.height | |
| 108 print('|cFFFF0088total height:', wrapperHeight) | |
| 109 else | |
| 110 handler.frame:Hide() | |
| 111 end | |
| 112 end | |
| 113 | |
| 114 | |
| 115 if hasStuff or insertingStuff then | |
| 116 print('updating height to', wrapperHeight) | |
| 117 Wrapper:SetHeight(wrapperHeight) | |
| 118 Scroller:SetHeight(wrapperHeight) | |
| 119 Scroll:SetHeight(wrapperHeight) | |
| 120 Scroller:SetVerticalScroll(B.Conf.ObjectiveScroll or 0) | |
| 121 print('|cFFFF8800Wrapper:', Wrapper:GetSize()) | |
| 122 for i = 1, Wrapper:GetNumPoints() do | |
| 123 print(' ', Wrapper:GetPoint(i)) | |
| 124 end | |
| 125 print(' |cFF00FFFFScroller:', Scroller:GetSize()) | |
| 126 for i = 1, Scroller:GetNumPoints() do | |
| 127 print(' ', Scroller:GetPoint(i)) | |
| 128 end | |
| 129 print(' |cFF00FFFFScroll:', Scroll:GetSize()) | |
| 130 for i = 1, Scroll:GetNumPoints() do | |
| 131 print(' ', Scroll:GetPoint(i)) | |
| 132 end | |
| 133 | |
| 134 Wrapper:Show() | |
| 135 Scroller:Show() | |
| 136 Scroll:Show() | |
| 137 end | |
| 138 Quest.GetClosest() | |
| 139 --T.UpdateActionButtons(reason) | |
| 140 end | |
| 141 | |
| 142 T.AddBlock = function(self, block) | |
| 143 local print = bprint | 70 local print = bprint |
| 144 local tracker = self.frame | 71 local tracker = self.frame |
| 145 local info = block.info | 72 local info = block.info |
| 146 block:SetPoint('TOPLEFT', self.currentAnchor, 'BOTTOMLEFT', 0, 0) | 73 |
| 74 block.index = blockIndex | |
| 75 block:SetPoint('TOPLEFT', self.frame, 'TOPLEFT', 0, block.offset) | |
| 147 block:SetPoint('RIGHT', tracker,'RIGHT', 0, 0) | 76 block:SetPoint('RIGHT', tracker,'RIGHT', 0, 0) |
| 77 self.currentBlock = blockIndex | |
| 148 self.currentAnchor = block | 78 self.currentAnchor = block |
| 149 print(' |cFFFFFF00'..tracker.height..'|r', '|cFF00FF00'..block:GetName()..'|r', block.height, tracker.height) | 79 print(' |cFFFFFF00'..tracker.height..'|r', '|cFF00FF00'..block:GetName()..'|r', block.height, tracker.height) |
| 150 tracker.height = tracker.height + block.height | 80 tracker.height = tracker.height + block.height |
| 151 self.numBlocks = max(self.numBlocks, info.blockIndex) | 81 self.numBlocks = max(self.numBlocks, blockIndex) |
| 152 self.actualBlocks = self.actualBlocks + 1 | 82 self.actualBlocks = self.actualBlocks + 1 |
| 153 end | 83 end |
| 154 | 84 |
| 155 --- Used as an iterator of sorts for cascaded tag icon placements (the daily/faction/account icons) | 85 --- Used as an iterator of sorts for cascaded tag icon placements (the daily/faction/account icons) |
| 156 T.AddTag = function (block, tagName, tagPoint, tagAnchor, tagRelative) | 86 Default.AddTag = function (handler, block, tagInfo, tagPoint, tagAnchor, tagRelative) |
| 157 local print = bprint | 87 local print = bprint |
| 158 local tag = block[tagName] | 88 |
| 159 if block.info[tagName] and tag then | 89 for order, tagName in ipairs(block.info.tagInfo) do |
| 160 tag:SetTexCoord(unpack(block.info[tagName])) | 90 local tag = block[tagName] |
| 161 tag:Show() | 91 if block.tagCoords[tagName] and tag then |
| 162 tag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) | 92 tag:SetTexCoord(unpack(block.tagCoords[tagName])) |
| 163 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', tag, 'TOPLEFT' | 93 tag:Show() |
| 164 else | 94 tag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) |
| 165 block[tagName]:Hide() | 95 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', tag, 'TOPLEFT' |
| 166 end | 96 else |
| 97 block[tagName]:Hide() | |
| 98 end | |
| 99 end | |
| 100 | |
| 167 return tagPoint, tagAnchor, tagRelative | 101 return tagPoint, tagAnchor, tagRelative |
| 168 end | 102 end |
| 169 | 103 |
| 170 --- Adds the given line to the current content and advances the anchor pointer to that new line for the following call. | 104 --- Adds the given line to the current content and advances the anchor pointer to that new line for the following call. |
| 171 T.AddLine = function(block, line) | 105 Default.AddLine = function(handler, block, text, attachment, template) |
| 172 local print = lprint | 106 local print = lprint |
| 107 local lineIndex = block.currentLine + 1 | |
| 108 local line = handler:GetLine(block) | |
| 173 line:ClearAllPoints() | 109 line:ClearAllPoints() |
| 174 line:SetPoint('LEFT', block, 'LEFT', 0, 0) | 110 line:SetPoint('LEFT', block, 'LEFT', 0, 0) |
| 175 line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, -textSpacing) | 111 line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, -textSpacing) |
| 176 line:SetPoint('RIGHT', block, 'RIGHT', 0, 0) | 112 line:SetPoint('RIGHT', block, 'RIGHT', 0, 0) |
| 113 line:Show() | |
| 114 | |
| 115 local r, g, b, a = 1, 1, 1, 1 | |
| 116 if lineColors[template] then | |
| 117 r, g, b = unpack(lineColors[template]) | |
| 118 end | |
| 119 | |
| 120 line.status:SetText(text) | |
| 121 line.height = floor(line.status:GetStringHeight()+.5) + textSpacing | |
| 177 line:SetHeight(line.height) | 122 line:SetHeight(line.height) |
| 178 line:Show() | 123 line.status:SetTextColor(r, g, b, a) |
| 124 | |
| 125 -- For progressbar and timer lines, status text may be used as the title heading | |
| 126 if attachment then | |
| 127 local widgetPosition = 0 | |
| 128 attachment:SetPoint('TOP', line, 'TOP', 0, -block.attachmentHeight) | |
| 129 attachment:Show() | |
| 130 if text and #text >= 1 then | |
| 131 widgetPosition = line.status:GetHeight() + textSpacing | |
| 132 line.status:SetText(text) | |
| 133 line.height = floor(line.status:GetStringHeight()+.5) + textSpacing + attachment.height | |
| 134 print(' - progressbar has text, adjust') | |
| 135 end | |
| 136 else | |
| 137 print(' |cFFFF0088no attachments') | |
| 138 end | |
| 179 | 139 |
| 180 block.endIndex = line.index | 140 block.endIndex = line.index |
| 181 block.numLines = block.numLines + 1 | |
| 182 block.attachmentHeight = block.attachmentHeight + (line.height + textSpacing) | 141 block.attachmentHeight = block.attachmentHeight + (line.height + textSpacing) |
| 183 print(' |cFF0088FFsetting line #'..block.numLines..' for|r', block.info.title, "\n |cFF0088FFsize:|r", line.height, | 142 print(' |cFF0088FFsetting line #'..lineIndex..' for|r', block.info.title, "\n |cFF0088FFsize:|r", line.height, |
| 184 "|cFF0088FFpoint:|r", line:GetPoint(1), "|cFF0088FFwidget:|r", (line.widget and 'Y' or 'N')) | 143 "|cFF0088FFpoint:|r", line:GetPoint(1), "|cFF0088FFwidget:|r", (line.widget and 'Y' or 'N')) |
| 144 block.currentLine = lineIndex | |
| 185 block.endPoint = line | 145 block.endPoint = line |
| 186 end | 146 end |
| 187 | 147 |
| 188 --- Creates or retrieves a complete line data object | 148 --- Creates or retrieves a complete line data object |
| 189 T.GetLine = function(handler, block, lineIndex) | 149 Default.GetLine = function(handler, block, lineIndex) |
| 190 local print = lprint | 150 local print = lprint |
| 191 local blockIndex = block.index | 151 local blockIndex = block.index |
| 192 if not block.lines then | |
| 193 block.lines = {} | |
| 194 end | |
| 195 local lines = block.lines | 152 local lines = block.lines |
| 153 if not lineIndex then | |
| 154 lineIndex = block.currentLine + 1 | |
| 155 print('fetching the "next" line:', lineIndex) | |
| 156 else | |
| 157 print('fetching explicit offset:', lineIndex) | |
| 158 end | |
| 159 | |
| 160 block.numLines = max(block.numLines, lineIndex) | |
| 161 print('|cFF00FFFFnumLines:|r', block.numLines, '|cFF00FFFFcurrentLine:|r', block.currentLine) | |
| 162 | |
| 196 if not lines[lineIndex] then | 163 if not lines[lineIndex] then |
| 197 print(' |cFF00FF88created line #'..lineIndex..' from for '..handler.name..' block #'..blockIndex) | 164 print(' |cFF00FF88created line #'..lineIndex..' from for '..handler.name..' block #'..blockIndex) |
| 198 lines[lineIndex] = CreateFrame('Frame', 'Vn'..handler.name .. blockIndex..'ObjectiveLine'..lineIndex, block, 'VeneerTrackerObjective') | 165 lines[lineIndex] = CreateFrame('Frame', 'Vn'..handler.name .. blockIndex..'ObjectiveLine'..lineIndex, block, 'VeneerTrackerObjective') |
| 199 local line = lines[lineIndex] | 166 local line = lines[lineIndex] |
| 200 line.index = lineIndex | 167 line.index = lineIndex |
| 218 end | 185 end |
| 219 | 186 |
| 220 | 187 |
| 221 | 188 |
| 222 --- Creates or retrieves a complete block frame object | 189 --- Creates or retrieves a complete block frame object |
| 223 T.GetBlock = function(handler, blockIndex) | 190 Default.GetBlock = function(handler, blockIndex) |
| 224 local print = bprint | 191 local print = bprint |
| 225 local block = handler.usedBlocks[blockIndex] | 192 local block = handler.usedBlocks[blockIndex] |
| 226 | 193 |
| 227 if not handler.usedBlocks[blockIndex] then | 194 if not handler.usedBlocks[blockIndex] then |
| 228 if #handler.freeBlocks >= 1 then | 195 if #handler.freeBlocks >= 1 then |
| 229 block = handler.freeBlocks[#handler.freeBlocks] | 196 block = handler.freeBlocks[#handler.freeBlocks] |
| 230 handler.freeBlocks[#handler.freeBlocks] = nil | 197 handler.freeBlocks[#handler.freeBlocks] = nil |
| 231 else | 198 else |
| 232 block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, Scroll, 'VeneerTrackerBlock') | 199 block = CreateFrame('Frame', 'Veneer'..tostring(handler)..'Block'..blockIndex, handler.frame, 'VeneerTrackerBlock') |
| 233 | 200 |
| 234 | 201 local c = Module.Conf.Wrapper |
| 235 | |
| 236 local c = T.Conf.Wrapper | |
| 237 block.index = blockIndex | 202 block.index = blockIndex |
| 203 block.lines = {} | |
| 204 block.numLines = 0 | |
| 205 block.currentLine = 0 | |
| 238 block:SetWidth(c.Width) | 206 block:SetWidth(c.Width) |
| 239 | 207 |
| 240 block.title:SetSpacing(c.TitleSpacing) | 208 block.title:SetSpacing(c.TitleSpacing) |
| 241 block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing) | 209 block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing) |
| 242 | 210 |
| 243 block.titlebg:SetTexture(1,1,1,1) | 211 block.titlebg:SetTexture(1,1,1,1) |
| 244 block.titlebg:SetGradientAlpha(unpack(T.colors.default.titlebg)) | 212 block.titlebg:SetGradientAlpha(unpack(Module.colors.default.titlebg)) |
| 245 block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0) | 213 block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0) |
| 246 block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing) | 214 block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing) |
| 247 | 215 |
| 248 block.status:SetSpacing(c.TextSpacing) | 216 block.status:SetSpacing(c.TextSpacing) |
| 249 block.status:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, -textSpacing) | 217 block.status:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, -textSpacing) |
| 250 block.status:SetPoint('LEFT', block.titlebg, 'LEFT', textIndent, 0) | 218 block.status:SetPoint('LEFT', block.titlebg, 'LEFT', textIndent, 0) |
| 251 | 219 |
| 252 block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0) | 220 block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0) |
| 253 block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0) | 221 block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0) |
| 254 block.statusbg:SetTexture(1,1,1,1) | 222 block.statusbg:SetTexture(1,1,1,1) |
| 255 block.statusbg:SetGradientAlpha(unpack(T.colors.default.textbg)) | 223 block.statusbg:SetGradientAlpha(unpack(Module.colors.default.textbg)) |
| 256 | 224 |
| 257 block.SelectionOverlay:SetGradientAlpha(unpack(T.colors.default.selectionbg)) | 225 block.SelectionOverlay:SetGradientAlpha(unpack(Module.colors.default.selectionbg)) |
| 258 block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0) | 226 block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0) |
| 259 block.SelectionOverlay:SetPoint('BOTTOMRIGHT') | 227 block.SelectionOverlay:SetPoint('BOTTOMRIGHT') |
| 260 | 228 |
| 261 block.icon:SetSize(rewardSize, rewardSize) | 229 block.icon:SetSize(rewardSize, rewardSize) |
| 262 block.icon:SetPoint('TOPRIGHT', block, 'TOPRIGHT', -2, -2) | 230 block.icon:SetPoint('TOPRIGHT', block, 'TOPRIGHT', -2, -2) |
| 284 handler.usedBlocks[blockIndex] = block | 252 handler.usedBlocks[blockIndex] = block |
| 285 end | 253 end |
| 286 return handler.usedBlocks[blockIndex] | 254 return handler.usedBlocks[blockIndex] |
| 287 end | 255 end |
| 288 | 256 |
| 257 local currentPosition, anchorFrame, anchorPoint | |
| 258 --- Positioning and stuff | |
| 259 local tick = 0 | |
| 260 local maxReason = 0 | |
| 261 function Module:Update (reason, ...) | |
| 262 tick = tick + 1 | |
| 263 -- is this the first time updating? | |
| 264 if maxReason == 0 then | |
| 265 reason = OBJECTIVE_TRACKER_UPDATE_ALL | |
| 266 elseif not reason then | |
| 267 reason = OBJECTIVE_TRACKER_UPDATE_REASON | |
| 268 end | |
| 269 | |
| 270 local print = tprint | |
| 271 local updateWrapper = 0 | |
| 272 local hasStuff | |
| 273 local insertingStuff | |
| 274 | |
| 275 print(format('%d |cFFFF%04X Update()', tick, lshift(reason, 4)), reason, ...) | |
| 276 currentPosition = 0 | |
| 277 anchorPoint = 'TOP' | |
| 278 anchorFrame = Scroll | |
| 279 | |
| 280 local wrapperHeight = 0 | |
| 281 for id, handler in pairs(Module.orderedHandlers) do | |
| 282 local frame = handler.frame | |
| 283 | |
| 284 print(format('|cFF00FFFF%s and(%04X vs %04x+%04x) = %04X|r', handler.name, reason, handler.updateReasonModule, handler.updateReasonEvents, band(reason, handler.updateReasonModule + handler.updateReasonEvents))) | |
| 285 if band(reason, handler.updateReasonModule + handler.updateReasonEvents) > 0 then | |
| 286 handler:UpdateTracker(reason, ...) | |
| 287 print(' |cFF00FF00'..id..'|r', handler.displayName, 'count:', handler.numWatched) | |
| 288 insertingStuff = true | |
| 289 else | |
| 290 print(' |cFFFF0088'..id..'|r', 'no reason to update') | |
| 291 end | |
| 292 | |
| 293 if handler.numWatched >= 1 then | |
| 294 hasStuff = true | |
| 295 currentPosition = currentPosition + 1 | |
| 296 frame.destinationOffset = -wrapperHeight | |
| 297 if frame.previousOffset ~= wrapperHeight and frame:IsVisible() then | |
| 298 print(frame.SlideIn.translation) | |
| 299 local postFrame, postPoint = anchorFrame, anchorPoint | |
| 300 local delta = frame.destinationOffset - frame.previousOffset | |
| 301 local _, _, _, _, offset = frame:GetPoint(1) | |
| 302 print(' |cFF00BBFFstart slide for', delta, 'pixels, from', frame.previousOffset, '(', offset, ')') | |
| 303 frame.SlideIn.translation:SetTarget(frame) | |
| 304 frame.SlideIn.translation:SetOffset(0, delta) | |
| 305 frame.SlideIn:Play() | |
| 306 for i, b in ipairs(handler.usedBlocks) do | |
| 307 b.SlideIn.translation:SetOffset(0, delta) | |
| 308 b.SlideIn:Play() | |
| 309 end | |
| 310 frame.SlideIn:SetScript('OnFinished', function() | |
| 311 print(' |cFF00BBFFsliding finished:', delta, 'pixels covered') | |
| 312 frame:SetParent(Scroll) | |
| 313 frame:SetPoint('TOP', Scroll, 'TOP', 0, frame.destinationOffset) | |
| 314 frame.previousOffset = frame.destinationOffset | |
| 315 frame.SlideIn:SetScript('OnFinished', nil) | |
| 316 if Wrapper.destinationHeight then | |
| 317 Wrapper:SetHeight(Wrapper.destinationHeight) | |
| 318 Scroller:SetHeight(Wrapper.destinationHeight) | |
| 319 Scroll:SetHeight(Wrapper.destinationHeight) | |
| 320 Wrapper.previousHeight = Wrapper.destinationHeight | |
| 321 Wrapper.destinationHeight = nil | |
| 322 end | |
| 323 | |
| 324 end) | |
| 325 else | |
| 326 print(' |cFF00BBFFpinning to', anchorFrame:GetName(), anchorPoint) | |
| 327 frame:SetParent(Scroll) | |
| 328 frame:SetPoint('TOP', Scroll, 'TOP', 0, frame.destinationOffset) | |
| 329 end | |
| 330 | |
| 331 frame:Show() | |
| 332 anchorFrame = handler.frame | |
| 333 anchorPoint = 'BOTTOM' | |
| 334 | |
| 335 print('current frame height:', frame.height) | |
| 336 wrapperHeight = wrapperHeight + frame.height | |
| 337 print('|cFFFF0088total height:', wrapperHeight) | |
| 338 else | |
| 339 frame:SetPoint('TOP', Scroll, 'TOP', 0, 0) | |
| 340 frame.destinationOffset = 0 | |
| 341 frame.previousOffset = 0 | |
| 342 handler.frame:Hide() | |
| 343 end | |
| 344 end | |
| 345 | |
| 346 | |
| 347 if hasStuff or insertingStuff then | |
| 348 print('updating height to', wrapperHeight) | |
| 349 if wrapperHeight > Wrapper.previousHeight then | |
| 350 Wrapper:SetHeight(wrapperHeight) | |
| 351 Scroller:SetHeight(wrapperHeight) | |
| 352 Scroll:SetHeight(wrapperHeight) | |
| 353 Wrapper.previousHeight = wrapperHeight | |
| 354 Wrapper.destinationHeight = wrapperHeight | |
| 355 end | |
| 356 Scroller:SetVerticalScroll(B.Conf.ObjectiveScroll or 0) | |
| 357 print('|cFFFF8800Wrapper:', Wrapper:GetSize()) | |
| 358 for i = 1, Wrapper:GetNumPoints() do | |
| 359 print(' ', Wrapper:GetPoint(i)) | |
| 360 end | |
| 361 print(' |cFF00FFFFScroller:', Scroller:GetSize()) | |
| 362 for i = 1, Scroller:GetNumPoints() do | |
| 363 print(' ', Scroller:GetPoint(i)) | |
| 364 end | |
| 365 print(' |cFF00FFFFScroll:', Scroll:GetSize()) | |
| 366 for i = 1, Scroll:GetNumPoints() do | |
| 367 print(' ', Scroll:GetPoint(i)) | |
| 368 end | |
| 369 | |
| 370 Wrapper:Show() | |
| 371 Scroller:Show() | |
| 372 Scroll:Show() | |
| 373 end | |
| 374 Quest.GetClosest() | |
| 375 --Module.UpdateActionButtons(reason) | |
| 376 end | |
| 377 | |
| 289 --- Content generator base | 378 --- Content generator base |
| 290 Default.Update = function (self, reason, ...) | 379 Default.UpdateTracker = function (handler, reason, id, isNew) |
| 291 local print = tprint | 380 local print = tprint |
| 292 local tracker = self.frame | 381 local tracker = handler.frame |
| 293 local blockIndex = 0 | 382 local blockIndex = 0 |
| 294 tracker.previousHeight = tracker.height | 383 tracker.previousHeight = tracker.height |
| 295 tracker.height = 0 | 384 tracker.height = 0 |
| 296 | 385 |
| 297 tracker.title:SetFont(headerFont, headerSize, headerOutline) | 386 tracker.title:SetFont(headerFont, headerSize, headerOutline) |
| 298 tracker.titlebg:SetHeight(headerHeight) | 387 tracker.titlebg:SetHeight(headerHeight) |
| 299 tracker.title:SetTextColor(unpack(headerColor)) | 388 tracker.title:SetTextColor(unpack(headerColor)) |
| 300 | 389 |
| 301 self.currentAnchor = tracker.titlebg | 390 handler.updateReason = reason |
| 302 self.numWatched = self:GetNumWatched() | 391 handler.numWatched = handler:GetNumWatched() |
| 303 self.actualBlocks = 0 | 392 handler.currentBlock = 0 |
| 304 for watchIndex = 1, 25 do | 393 handler.currentAnchor = tracker.titlebg |
| 305 blockIndex = blockIndex + 1 | 394 local blockPosition = -headerHeight |
| 306 if watchIndex <= self.numWatched then | 395 for blockIndex = 1, handler.numWatched do |
| 307 local info = self:GetInfo(watchIndex) | 396 local currentBlock = handler:UpdateBlock(blockIndex, id, isNew) |
| 308 if info then | 397 if currentBlock then |
| 309 local currentBlock = self:UpdateBlock(blockIndex, info) | 398 currentBlock.offset = blockPosition |
| 310 T.AddBlock(self, currentBlock) | 399 handler:AddBlock(currentBlock) |
| 311 else | 400 blockPosition = blockPosition - currentBlock.height |
| 312 print(' |cFFFF0000bad GetInfo data for #'..watchIndex) | |
| 313 end | |
| 314 elseif watchIndex <= self.actualBlocks then | |
| 315 local used = self.usedBlocks | |
| 316 local free = self.freeBlocks | |
| 317 print('clean up dead quest block') | |
| 318 if used[blockIndex] then | |
| 319 used[blockIndex]:Hide() | |
| 320 used[blockIndex]:ClearAllPoints() | |
| 321 free[#free+1]= used[blockIndex] | |
| 322 used[blockIndex] = nil | |
| 323 end | |
| 324 else | 401 else |
| 325 print(' |cFFFF9900END|r @', blockIndex) | 402 print(' |cFFFF9900END|r @', blockIndex) |
| 326 break -- done with quest stuff | 403 break -- done with quest stuff |
| 327 end | 404 end |
| 328 end | 405 end |
| 329 | 406 |
| 330 | 407 for i = handler.currentBlock+1, handler.numBlocks do |
| 331 if self.actualBlocks >= 1 then | 408 local used = handler.usedBlocks |
| 409 local free = handler.freeBlocks | |
| 410 print('clean up dead quest block') | |
| 411 if used[i] then | |
| 412 used[i]:Hide() | |
| 413 used[i]:ClearAllPoints() | |
| 414 free[#free+1]= used[blockIndex] | |
| 415 used[i] = nil | |
| 416 end | |
| 417 end | |
| 418 | |
| 419 | |
| 420 if handler.currentBlock >= 1 then | |
| 332 tracker.height = tracker.height + headerHeight | 421 tracker.height = tracker.height + headerHeight |
| 333 tracker:Show() | 422 tracker:Show() |
| 334 | 423 |
| 335 if tracker.wasEmpty then | 424 if tracker.wasEmpty then |
| 336 tracker.headerFade:Play() | 425 tracker.headerFade:Play() |
| 351 --- Updates the selected block frame to display the given info batch | 440 --- Updates the selected block frame to display the given info batch |
| 352 -- If `previousBlock` is set, it will attempt to anchor to that | 441 -- If `previousBlock` is set, it will attempt to anchor to that |
| 353 -- @param blockNum the ordered block to be updated, not a watchIndex value | 442 -- @param blockNum the ordered block to be updated, not a watchIndex value |
| 354 -- @param info the reference returned by the GetXInfo functions | 443 -- @param info the reference returned by the GetXInfo functions |
| 355 -- REMEMBER: t.info and questData[questID] are the same table | 444 -- REMEMBER: t.info and questData[questID] are the same table |
| 356 Default.UpdateBlock = function (handler, blockIndex, info) | 445 Default.UpdateBlock = function (handler, blockIndex, id, added) |
| 357 local print = bprint | 446 local print = bprint |
| 358 print(' Read list item |cFF00FFFF'..blockIndex..'|r') | 447 print(' Updating |cFF00FF00'..handler.displayName..'|r|cFF00FFFF'..blockIndex..'|r') |
| 359 if not blockIndex or not info then | 448 if not blockIndex then |
| 360 return | 449 return |
| 361 end | 450 end |
| 451 local info = handler:GetInfo(blockIndex) -- should match up with whatever the internal watch list has | |
| 452 if not info then | |
| 453 return | |
| 454 end | |
| 362 local frame = handler.frame | 455 local frame = handler.frame |
| 363 local block = T.GetBlock(handler, blockIndex) | 456 local block = handler:GetBlock(blockIndex) |
| 457 | |
| 458 block.questID = info.questID | |
| 459 if id == info.questID then | |
| 460 --block.questFadeIn:Play() | |
| 461 end | |
| 462 | |
| 364 block.handler = handler | 463 block.handler = handler |
| 365 block.info = info | 464 block.info = info |
| 366 block.mainStyle = info.mainStyle or 'Normal' | 465 block.mainStyle = info.mainStyle or 'Normal' |
| 367 block.subStyle = info.subStyle | 466 block.subStyle = info.subStyle |
| 368 | 467 |
| 369 info.blockIndex = blockIndex | 468 info.blockIndex = blockIndex |
| 370 if info.questID then handler.QuestBlock[info.questID] = block end | 469 if info.questID then handler.QuestBlock[info.questID] = block end |
| 371 if info.questLogIndex then handler.LogBlock[info.questLogIndex] = block end | 470 if info.questLogIndex then handler.LogBlock[info.questLogIndex] = block end |
| 372 if info.watchIndex then handler.WatchBlock[info.watchIndex] = block end | 471 if info.watchIndex then handler.WatchBlock[info.watchIndex] = block end |
| 373 handler.BlockInfo[blockIndex] = info | 472 handler.BlockInfo[blockIndex] = info |
| 374 | |
| 375 block.endPoint = block.titlebg | |
| 376 block.attachmentHeight = 0 | |
| 377 handler:UpdateObjectives(block) | 473 handler:UpdateObjectives(block) |
| 378 | 474 |
| 379 block.title:SetText(info.title) | 475 block.title:SetText(info.title) |
| 380 local titleHeight = floor(block.title:GetHeight()+.5) | 476 local titleHeight = floor(block.title:GetHeight()+.5) |
| 477 local titlebgHeight = titleHeight + titleSpacing*2 | |
| 478 block.titlebg:SetHeight(titlebgHeight) | |
| 479 | |
| 381 local statusHeight = floor(block.status:GetHeight()+.5) | 480 local statusHeight = floor(block.status:GetHeight()+.5) |
| 481 local statusbgHeight = statusHeight + textSpacing*2 | |
| 382 local attachmentHeight =floor(block.attachmentHeight + .5) | 482 local attachmentHeight =floor(block.attachmentHeight + .5) |
| 383 local titlebgHeight = titleHeight + titleSpacing*2 | |
| 384 local statusbgHeight = statusHeight + textSpacing*2 | |
| 385 | |
| 386 block.titlebg:SetHeight(titlebgHeight) | |
| 387 | |
| 388 | 483 |
| 389 print(' |cFF0088FFanchor to', handler.currentAnchor:GetName()) | 484 print(' |cFF0088FFanchor to', handler.currentAnchor:GetName()) |
| 390 | 485 print(' |cFF00FF00attachment:|r', attachmentHeight, '|cFF00FF00title:|r', titlebgHeight, '('.. titleHeight..')') |
| 391 print(' |cFF00FF00total sizes:') | 486 --block.titlebg:SetHeight(block.title:GetHeight() + Module.Conf.Wrapper.TitleSpacing) |
| 392 print(' attachment:', attachmentHeight) | |
| 393 print(' title:', titlebgHeight, '('.. titleHeight..')') | |
| 394 --block.titlebg:SetHeight(block.title:GetHeight() + T.Conf.Wrapper.TitleSpacing) | |
| 395 block.height = titlebgHeight + attachmentHeight | 487 block.height = titlebgHeight + attachmentHeight |
| 488 | |
| 396 if statusHeight > 1 then | 489 if statusHeight > 1 then |
| 397 block.height = block.height + statusbgHeight | 490 block.height = block.height + statusbgHeight |
| 398 print(' status:', statusbgHeight, '('.. statusHeight..')') | 491 print(' status:', statusbgHeight, '('.. statusHeight..')') |
| 399 else | 492 else |
| 400 print(' |cFFFF0088 skipped') | 493 print(' |cFFFF0088 skipped') |
| 406 | 499 |
| 407 block:Show() | 500 block:Show() |
| 408 | 501 |
| 409 if info.specialItem and not info.itemButton then | 502 if info.specialItem and not info.itemButton then |
| 410 print(' - |cFF00FFFFgenerating item button for info set') | 503 print(' - |cFF00FFFFgenerating item button for info set') |
| 411 info.itemButton = T.SetItemButton(block, info) | 504 info.itemButton = Module.SetItemButton(block, info) |
| 412 else | 505 else |
| 413 --info.itemButton = nil | 506 --info.itemButton = nil |
| 414 end | 507 end |
| 415 | 508 |
| 416 local tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', block, 'TOPRIGHT' | 509 local tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', block, 'TOPRIGHT' |
| 435 end | 528 end |
| 436 -- workaround for scrollchild issue where layers fall out of sync: in this case, it's by 1 vertical pixel | 529 -- workaround for scrollchild issue where layers fall out of sync: in this case, it's by 1 vertical pixel |
| 437 --block.highlight:SetPoint('TOPLEFT', block, 'TOPLEFT', 0, 1) | 530 --block.highlight:SetPoint('TOPLEFT', block, 'TOPLEFT', 0, 1) |
| 438 --block.lowlight:SetPoint('BOTTOMLEFT', block, 'BOTTOMLEFT', 0, 1) | 531 --block.lowlight:SetPoint('BOTTOMLEFT', block, 'BOTTOMLEFT', 0, 1) |
| 439 | 532 |
| 440 tagPoint, tagAnchor, tagRelative = T.AddTag(block, 'frequencyTag', tagPoint, tagAnchor, tagRelative) | 533 tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'frequencyTag', tagPoint, tagAnchor, tagRelative) |
| 441 tagPoint, tagAnchor, tagRelative = T.AddTag(block, 'typeTag', tagPoint, tagAnchor, tagRelative) | 534 tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'typeTag', tagPoint, tagAnchor, tagRelative) |
| 442 tagPoint, tagAnchor, tagRelative = T.AddTag(block, 'completionTag', tagPoint, tagAnchor, tagRelative) | 535 tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'completionTag', tagPoint, tagAnchor, tagRelative) |
| 443 | 536 |
| 444 return block | 537 return block |
| 445 end | 538 end |
| 446 | 539 |
| 447 | 540 |
| 451 -- Hooked by corresponding handler functions where additional details need to be sorted. | 544 -- Hooked by corresponding handler functions where additional details need to be sorted. |
| 452 Default.UpdateObjectives = function(handler, block) | 545 Default.UpdateObjectives = function(handler, block) |
| 453 local print = lprint | 546 local print = lprint |
| 454 local info = block.info | 547 local info = block.info |
| 455 print(' |cFF00FF00default objectives routine', block:GetName()) | 548 print(' |cFF00FF00default objectives routine', block:GetName()) |
| 549 block.endPoint = block.titlebg | |
| 550 block.attachmentHeight = 0 | |
| 551 block.currentLine = 0 | |
| 456 | 552 |
| 457 -- reset the starting positions | 553 -- reset the starting positions |
| 458 block.attachmentHeight = 0 | 554 block.attachmentHeight = 0 |
| 459 block.endPoint = block.titlebg | 555 block.endPoint = block.titlebg |
| 460 local completionScore, completionMax = 0, 0 | 556 local completionScore, completionMax = 0, 0 |
| 461 local displayObjectiveHeader = false | 557 local displayObjectiveHeader = false |
| 462 | 558 |
| 463 | 559 |
| 464 --- The first line is going to be used no matter what, so it is hard-pulled. | 560 --- The first line is going to be used no matter what, so it is hard-pulled. |
| 465 -- It also ensures that we're in the right position for cleaning up the leftover lines. | 561 -- It also ensures that we're in the right position for cleaning up the leftover lines. |
| 466 local lineIndex = 1 | 562 |
| 467 local line = T.GetLine(handler, block, lineIndex) | |
| 468 | |
| 469 block.numLines = 0 | |
| 470 block.attachmentHeight = 0 | 563 block.attachmentHeight = 0 |
| 471 | 564 |
| 565 local text, attachment | |
| 472 if info.description and #info.description >= 1 then | 566 if info.description and #info.description >= 1 then |
| 473 print(' |cFF00FFFF header line:|r', info.description) | 567 print(' |cFF00FFFF header line:|r', info.description) |
| 474 line.status:SetText(info.description) | 568 text = info.description |
| 475 line.height = floor(line.status:GetStringHeight()+.5) + textSpacing | 569 handler:AddLine(block, text, nil) |
| 476 if line.widget then | |
| 477 line.widget:Hide() | |
| 478 end | |
| 479 T.AddLine(block, line) | |
| 480 | |
| 481 lineIndex = lineIndex + 1 | |
| 482 line = T.GetLine(handler, block, lineIndex) | |
| 483 end | 570 end |
| 484 | 571 |
| 485 if (info.isComplete or info.numObjectives == 0) and info.completionText then | 572 if (info.isComplete or info.numObjectives == 0) and info.completionText then |
| 486 print(' overriding line #1 for completion text:', info.completionText) | 573 print(' overriding line #1 for completion text:', info.completionText) |
| 487 line.status:SetText(info.completionText) | 574 text = info.completionText |
| 488 line.height = floor(line.status:GetStringHeight()+.5) + textSpacing | 575 Module.AddLine(block, text, nil) |
| 489 if line.widget then | |
| 490 line.widget:Hide() | |
| 491 end | |
| 492 T.AddLine(block, line) | |
| 493 else | 576 else |
| 494 if info.objectives then | 577 if info.objectives then |
| 495 for i, data in ipairs(info.objectives) do | 578 for i, data in ipairs(info.objectives) do |
| 496 print(' |cFF88FF00#', i, data.type, data.text) | 579 local line = handler:GetLine(block) |
| 497 displayObjectiveHeader = true | 580 displayObjectiveHeader = true |
| 498 line.height = 0 | 581 line.height = 0 |
| 499 handler:UpdateLine(block, line, data) | 582 text, attachment = handler:UpdateLine(block, line, data) |
| 500 | 583 print(' |cFF88FF00#', i, data.type, text) |
| 501 -- For progressbar and timer lines, status text may be used as the title heading | 584 handler:AddLine(block, text, attachment) |
| 502 if line.widget then | 585 |
| 503 local widgetPosition = 0 | |
| 504 --- WIDGET POSITION ------------------------------------------------- | |
| 505 line.widget:SetPoint('TOP', line, 'TOP', 0, -widgetPosition) | |
| 506 line.widget:Show() | |
| 507 line.height = line.widget:GetHeight() + textSpacing | |
| 508 --------------------------------------------------------------------- | |
| 509 if line.displayText and #line.displayText >= 1 then | |
| 510 widgetPosition = line.status:GetHeight() + textSpacing | |
| 511 line.status:SetText(line.displayText) | |
| 512 line.height = floor(line.status:GetStringHeight()+.5) + textSpacing + line.widget.height | |
| 513 print(' - progressbar has text, adjust') | |
| 514 end | |
| 515 elseif line.displayText then | |
| 516 line.status:SetText(line.displayText) | |
| 517 line.height = floor(line.status:GetStringHeight()+.5) | |
| 518 end | |
| 519 | |
| 520 T.AddLine(block, line) | |
| 521 | |
| 522 --print(' sz', line:GetWidth(), line:GetHeight(), 'pt', line:GetPoint(1)) | |
| 523 --print(' |cFF44BBFF#', i, 'anchoring line, size:', line.height, 'current endpoint:', line.statusbg) | |
| 524 | |
| 525 lineIndex = lineIndex + 1 | |
| 526 line = T.GetLine(handler, block, lineIndex) | |
| 527 end | 586 end |
| 528 end | 587 end |
| 529 end | 588 end |
| 530 | 589 |
| 531 while (block.lines[lineIndex+1]) do | 590 for i = block.currentLine + 1, block.numLines do |
| 532 print(' - hide |cFFFF0088'..lineIndex..'|r') | 591 print(i, block.numLines) |
| 533 block.lines[lineIndex]:Hide() | 592 print(' - hide |cFFFF0088'..i..'|r', block.lines[i]) |
| 534 lineIndex = lineIndex +1 | 593 block.lines[i]:ClearAllPoints() |
| 535 end | 594 block.lines[i]:Hide() |
| 536 | 595 end |
| 537 | 596 |
| 538 | 597 if block.currentLine > 0 then |
| 539 if lineIndex > 0 then | |
| 540 block.attachmentHeight = block.attachmentHeight + textSpacing * 2 | 598 block.attachmentHeight = block.attachmentHeight + textSpacing * 2 |
| 541 print(' |cFF00FF00attachment:', block.attachmentHeight) | 599 print(' |cFF00FF00attachment:', block.attachmentHeight) |
| 542 end | 600 end |
| 543 | |
| 544 | |
| 545 --[[ | |
| 546 local lines = handler.lines[block.index] | |
| 547 if lines and #lines > block.numLines then | |
| 548 print(' |cFFFF008' .. (#lines - block.numLines) .. ' extra lines to hide.') | |
| 549 for i = block.numLines + 1, #lines do | |
| 550 print(' hide', i, lines[i]:GetName()) | |
| 551 lines[i]:Hide() | |
| 552 end | |
| 553 end | |
| 554 ]] | |
| 555 | 601 |
| 556 | 602 |
| 557 if debug then | 603 if debug then |
| 558 for i, region in ipairs(block.debug) do | 604 for i, region in ipairs(block.debug) do |
| 559 for j = 1, region:GetNumPoints() do | 605 for j = 1, region:GetNumPoints() do |
| 583 elseif line.quantity > 0 then | 629 elseif line.quantity > 0 then |
| 584 line.progress = 1 | 630 line.progress = 1 |
| 585 else | 631 else |
| 586 line.progress = 0 | 632 line.progress = 0 |
| 587 end | 633 end |
| 588 return line | 634 return line.displayText, line.widget |
| 589 end | 635 end |
| 590 ---------- | 636 ---------- |
| 591 --- Top level methods | 637 --- Top level methods |
| 592 | 638 |
| 593 --- Queue any active item buttons for update for that frame | 639 --- Queue any active item buttons for update for that frame |
| 594 local iprint = B.print('ItemButton') | 640 local iprint = B.print('ItemButton') |
| 595 T.UpdateActionButtons = function(updateReason) | 641 Module.UpdateActionButtons = function(updateReason) |
| 596 local print = iprint | 642 local print = iprint |
| 597 Scroller.snap_upper = 0 | 643 Scroller.snap_upper = 0 |
| 598 Scroller.snap_lower = 0 | 644 Scroller.snap_lower = 0 |
| 599 local print = B.print('ItemButton') | 645 local print = B.print('ItemButton') |
| 600 if updateReason then | 646 if updateReason then |
| 601 print = B.print('IB_'..updateReason) | 647 print = B.print('IB_'..updateReason) |
| 602 end | 648 end |
| 603 | 649 |
| 604 local previousItem | 650 local previousItem |
| 605 for questID, itemButton in pairs(Quest.itemButtons) do | 651 for questID, itemButton in pairs(Quest.itemButtons) do |
| 606 local info= T.Quest.Info[questID] | 652 local info= Module.Quest.Info[questID] |
| 607 | 653 |
| 608 print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName()) | 654 print('|cFF00FFFF'.. questID .. '|r', itemButton:GetName()) |
| 609 local block = T.Quest.QuestBlock[questID] | 655 local block = Module.Quest.QuestBlock[questID] |
| 610 if block then | 656 if block then |
| 611 -- Dispatch the probe | 657 -- Dispatch the probe |
| 612 if IsQuestWatched(info.questLogIndex) then | 658 if IsQuestWatched(info.questLogIndex) then |
| 613 itemButton.previousItem = previousItem | 659 itemButton.previousItem = previousItem |
| 614 print(' |cFFFFFF00probing', block:GetName()) | 660 print(' |cFFFFFF00probing', block:GetName()) |
| 615 block:SetScript('OnUpdate', function() | 661 block:SetScript('OnUpdate', function() |
| 616 if block:GetBottom() and not InCombatLockdown() then | 662 if block:GetBottom() and not InCombatLockdown() then |
| 617 print(' '..block:GetName()..' |cFF00FF00probe hit!') | 663 print(' '..block:GetName()..' |cFF00FF00probe hit!') |
| 618 T.UpdateBlockAction(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope | 664 Module.UpdateBlockAction(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope |
| 619 block:SetScript('OnUpdate', nil) | 665 block:SetScript('OnUpdate', nil) |
| 620 | 666 |
| 621 end | 667 end |
| 622 end) | 668 end) |
| 623 previousItem = itemButton | 669 previousItem = itemButton |
| 634 print(' |cFFBBBBBBignoring hidden log quest button', itemButton:GetName()) | 680 print(' |cFFBBBBBBignoring hidden log quest button', itemButton:GetName()) |
| 635 end | 681 end |
| 636 end | 682 end |
| 637 end | 683 end |
| 638 | 684 |
| 639 T.UpdateBlockAction = function (block, itemButton) | 685 Module.UpdateBlockAction = function (block, itemButton) |
| 640 local print = iprint | 686 local print = iprint |
| 641 print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()') | 687 print('**|cFF0088FF'..itemButton:GetName(), '|r:Update()') |
| 642 if itemButton.questID ~= block.info.questID then | 688 if itemButton.questID ~= block.info.questID then |
| 643 print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID) | 689 print('** |cFFFF0088mismatched block assignment', itemButton.questID,'<~>', block.info.questID) |
| 644 -- something happened between this and last frame, go back and set new probes | 690 -- something happened between this and last frame, go back and set new probes |
| 645 return T.UpdateActionButtons() | 691 return Module.UpdateActionButtons() |
| 646 end | 692 end |
| 647 | 693 |
| 648 local previousItem = itemButton.previousItem | 694 local previousItem = itemButton.previousItem |
| 649 local upper_bound = Scroller:GetTop() + Scroller.snap_upper | 695 local upper_bound = Scroller:GetTop() + Scroller.snap_upper |
| 650 local lower_bound = Scroller:GetBottom() + Scroller.snap_lower + itemButtonSize | 696 local lower_bound = Scroller:GetBottom() + Scroller.snap_lower + itemButtonSize |
| 689 | 735 |
| 690 itemButton:SetPoint(point, anchor, relative, itemButton.x, itemButton.y) | 736 itemButton:SetPoint(point, anchor, relative, itemButton.x, itemButton.y) |
| 691 itemButton:Show() | 737 itemButton:Show() |
| 692 end | 738 end |
| 693 | 739 |
| 694 T.UpdateItemButtonCooldown = function(button) | 740 Module.UpdateItemButtonCooldown = function(button) |
| 695 | 741 |
| 696 end | 742 end |
| 697 | 743 |
| 698 Default.Select = function(handler, block) | 744 Default.Select = function(handler, block) |
| 699 T:Update(handler.watchReasonModule) | 745 Module:Update(handler.watchReasonModule) |
| 700 end | 746 end |
| 701 Default.Open = function(handler, block) | 747 Default.Open = function(handler, block) |
| 702 T:Update(handler.watchReasonModule) | 748 Module:Update(handler.watchReasonModule) |
| 703 end | 749 end |
| 704 Default.Remove = function(handler, block) | 750 Default.Remove = function(handler, block) |
| 705 T:Update(handler.watchReasonModule) | 751 Module:Update(handler.watchReasonModule) |
| 706 end | 752 end |
| 707 Default.Report = function(handler, block) | 753 Default.Report = function(handler, block) |
| 708 print('Stats:', handler.numWatched,'items tracked,', handler.numBlocks,'blocks assigned.') | 754 print('Stats:', handler.numWatched,'items tracked,', handler.numBlocks,'blocks assigned.') |
| 709 end | 755 end |
| 710 | 756 |
| 722 self.Open(self.handler, self) | 768 self.Open(self.handler, self) |
| 723 end | 769 end |
| 724 self.initialButton = nil | 770 self.initialButton = nil |
| 725 self.modChatLink = nil | 771 self.modChatLink = nil |
| 726 self.modQuestWatch = nil | 772 self.modQuestWatch = nil |
| 727 T:Update(self.handler.updateReasonModule) | 773 Module:Update(self.handler.updateReasonModule) |
| 728 print('|cFFFF8800'..tostring(self:GetName())..':MouseUp()|r') | 774 print('|cFFFF8800'..tostring(self:GetName())..':MouseUp()|r') |
| 729 end | 775 end |
| 730 Default.OnMouseDown = function(self, button) | 776 Default.OnMouseDown = function(self, button) |
| 731 print(self.info.title) | 777 print(self.info.title) |
| 732 end | 778 end |
