Mercurial > wow > buffalo2
comparison ObjectiveTracker/DefaultTracker.lua @ 40:03ed70f846de
- 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
| author | Nenue |
|---|---|
| date | Sun, 24 Apr 2016 14:15:25 -0400 |
| parents | 92534dc793f2 |
| children |
comparison
equal
deleted
inserted
replaced
| 39:92534dc793f2 | 40:03ed70f846de |
|---|---|
| 68 | 68 |
| 69 if handler.numWatched >= 1 then | 69 if handler.numWatched >= 1 then |
| 70 hasStuff = true | 70 hasStuff = true |
| 71 currentPosition = currentPosition + 1 | 71 currentPosition = currentPosition + 1 |
| 72 Default.AddTracker(handler, frame, currentPosition) | 72 Default.AddTracker(handler, frame, currentPosition) |
| 73 | 73 frame.wasEmpty = nil |
| 74 else | 74 else |
| 75 frame:ClearAllPoints() | |
| 76 frame:SetPoint('BOTTOM', Scroll, 'BOTTOM', 0, 0) | |
| 77 frame.destinationOffset = 0 | 75 frame.destinationOffset = 0 |
| 78 frame:Hide() | 76 if not frame.wasEmpty and not frame.fadeOut:IsPlaying() then |
| 77 frame.fadeOut:Play() | |
| 78 end | |
| 79 frame.wasEmpty = true | 79 frame.wasEmpty = true |
| 80 end | 80 end |
| 81 end | 81 end |
| 82 | 82 |
| 83 -- do these whenever there is content or content is being added | 83 -- do these whenever there is content or content is being added |
| 90 | 90 |
| 91 Default.UpdateTracker = function (handler, reason, id, isNew) | 91 Default.UpdateTracker = function (handler, reason, id, isNew) |
| 92 local print = handler.print | 92 local print = handler.print |
| 93 local frame = handler.frame | 93 local frame = handler.frame |
| 94 local blockIndex = 0 | 94 local blockIndex = 0 |
| 95 print('UpdateTracker', handler.name, reason) | 95 print('MODULE:'..handler.name, 'message:', reason, 'id:', id, (isNew and '|cFF88FF88' or '|cFF555555')..'isNew|r') |
| 96 handler.updateReason = reason | 96 handler.updateReason = reason |
| 97 local numWatched, numAll, watchTable = handler:GetNumWatched(id, isNew) | 97 local numWatched, numAll, watchTable = handler:GetNumWatched(id, isNew) |
| 98 | 98 |
| 99 if numWatched >= 1 then | 99 if numWatched >= 1 then |
| 100 if watchTable then | 100 if watchTable then |
| 118 print(' |cFF'..handler.internalColor..'finished|r @', blockIndex) | 118 print(' |cFF'..handler.internalColor..'finished|r @', blockIndex) |
| 119 break -- done with quest stuff | 119 break -- done with quest stuff |
| 120 end | 120 end |
| 121 end | 121 end |
| 122 | 122 |
| 123 | |
| 124 local numBlocks = handler.numBlocks | 123 local numBlocks = handler.numBlocks |
| 125 local used = handler.usedBlocks | 124 local used = handler.usedBlocks |
| 126 local free = handler.freeBlocks | 125 local free = handler.freeBlocks |
| 127 print(format('#### %s ## |cFFFF8800%04X|r --- blocks |cFFFF8800%d|r, (used/free: |cFFFF8800%d|r/|cFFFF8800%d|r)', handler.name, band(reason, handler.updateReasonModule + handler.updateReasonEvents, reason), numBlocks, #used, #free)) | 126 print(format('#### %s ## |cFFFF8800%04X|r --- blocks |cFFFF8800%d|r, (used/free: |cFFFF8800%d|r/|cFFFF8800%d|r)', handler.name, band(reason, handler.updateReasonModule + handler.updateReasonEvents, reason), numBlocks, #used, #free)) |
| 128 | 127 |
| 144 | 143 |
| 145 block.handler = handler | 144 block.handler = handler |
| 146 block.info = info | 145 block.info = info |
| 147 | 146 |
| 148 info.blockIndex = index | 147 info.blockIndex = index |
| 148 local keyInfo | |
| 149 if info.id then | 149 if info.id then |
| 150 print(' storing id', info.id, 'for', block:GetName()) | 150 keyInfo = (keyInfo and (keyInfo..', ') or '') .. 'InfoBlock[' .. info.id .. '] = *' .. block:GetName():gsub('%D', '') |
| 151 handler.InfoBlock[info.id] = block | 151 handler.InfoBlock[info.id] = block |
| 152 end | 152 end |
| 153 if info.logIndex then | 153 if info.logIndex then |
| 154 print(' storing logIndex', info.logIndex, 'for', block:GetName()) | 154 keyInfo = (keyInfo and (keyInfo..', ') or '') .. 'LogBlock[' .. info.logIndex .. '] = ' .. block:GetName():gsub('%D', '') |
| 155 handler.LogBlock[info.logIndex] = block | 155 handler.LogBlock[info.logIndex] = block |
| 156 end | 156 end |
| 157 if info.watchIndex then | 157 if info.watchIndex then |
| 158 print(' storing watchIndex', info.watchIndex, 'for', block:GetName()) | 158 keyInfo = (keyInfo and (keyInfo..', ') or '') .. 'WatchBlock[' .. info.watchIndex .. '] = ' .. block:GetName():gsub('%D', '') |
| 159 handler.WatchBlock[info.watchIndex] = block | 159 handler.WatchBlock[info.watchIndex] = block |
| 160 end | 160 end |
| 161 if keyInfo then print(' assigned', keyInfo) end | |
| 161 handler.BlockInfo[index] = info | 162 handler.BlockInfo[index] = info |
| 162 block.endPoint = block.titlebg | 163 block.endPoint = block.titlebg |
| 163 block.attachmentHeight = 0 | 164 block.attachmentHeight = 0 |
| 164 block.currentLine = 0 | 165 block.currentLine = 0 |
| 165 handler:UpdateObjectives(block, block.schema) | 166 local attachments, override_schema = handler:UpdateObjectives(block, block.schema) |
| 166 | 167 |
| 167 block.title:SetText(info.title) | 168 block.title:SetText(info.title) |
| 168 | 169 |
| 169 if info.specialItem and not info.itemButton then | 170 if info.specialItem and not info.itemButton then |
| 170 print(' - |cFF00FFFFgenerating item button for info set') | 171 print(' - |cFF00FFFFgenerating item button for info set') |
| 173 --info.itemButton = nil | 174 --info.itemButton = nil |
| 174 end | 175 end |
| 175 | 176 |
| 176 local tagPoint, tagAnchor, tagRelative, x, y = 'TOPRIGHT', block, 'TOPRIGHT', -2, -2 | 177 local tagPoint, tagAnchor, tagRelative, x, y = 'TOPRIGHT', block, 'TOPRIGHT', -2, -2 |
| 177 | 178 |
| 178 local numCurrency = 0 | |
| 179 for i, rewardTile in ipairs(block.rewardTile) do | |
| 180 if info.rewardInfo and info.rewardInfo[i] then | |
| 181 local reward = info.rewardInfo[i] | |
| 182 --rewardTile:SetPoint(tagPoint, tagAnchor, tagRelative, -2, -2) | |
| 183 rewardTile:SetTexture(reward.texture) | |
| 184 rewardTile:Show() | |
| 185 | |
| 186 print('updating reward tile #'.. i, reward.type, reward.count, reward.text, reward.texture) | |
| 187 if reward.count and reward.count > 1 then | |
| 188 block.rewardLabel[i]:SetText(reward.count) | |
| 189 block.rewardLabel[i]:Show() | |
| 190 end | |
| 191 | |
| 192 rewardTile:ClearAllPoints() | |
| 193 rewardTile:SetPoint(tagPoint, tagAnchor, tagRelative, x, y) | |
| 194 tagPoint, tagAnchor, tagRelative, x, y = 'TOPRIGHT', rewardTile, 'TOPLEFT', -2, 0 | |
| 195 else | |
| 196 rewardTile:Hide() | |
| 197 block.rewardLabel[i]:Hide() | |
| 198 end | |
| 199 end | |
| 200 | 179 |
| 201 if info.selected then | 180 if info.selected then |
| 202 block.SelectionOverlay:Show() | 181 block.SelectionOverlay:Show() |
| 203 else | 182 else |
| 204 block.SelectionOverlay:Hide() | 183 block.SelectionOverlay:Hide() |
| 222 block_schema = block_schema or block.schema | 201 block_schema = block_schema or block.schema |
| 223 local info = block.info | 202 local info = block.info |
| 224 print(' |cFF00FF00default.objectives', block:GetName()) | 203 print(' |cFF00FF00default.objectives', block:GetName()) |
| 225 -- reset the starting positions | 204 -- reset the starting positions |
| 226 local text, attachment, template | 205 local text, attachment, template |
| 227 | 206 local numAttachments = 0 |
| 228 | 207 |
| 229 if info.objectives and displayObjectives then | 208 if info.objectives and displayObjectives then |
| 230 for i, data in ipairs(info.objectives) do | 209 for i, data in ipairs(info.objectives) do |
| 231 text, attachment, template = handler:UpdateLine(block, data) | 210 text, attachment, template = handler:UpdateLine(block, data) |
| 232 if text or attachment then | 211 if text or attachment then |
| 233 local line = handler:GetLine(block) | 212 local line = handler:GetLine(block) |
| 234 line.height = 0 | 213 line.height = 0 |
| 235 print(' |cFF88FF00#', i, data.type, text, attachment) | 214 print(' |cFF88FF00#', i, data.type, text, attachment) |
| 236 handler:AddLine(block, text, attachment, template) | 215 handler:AddLine(block, text, attachment, template) |
| 237 end | 216 end |
| 217 if attachment then | |
| 218 numAttachments = numAttachments + 1 | |
| 219 end | |
| 238 end | 220 end |
| 239 end | 221 end |
| 240 | 222 |
| 241 if block.currentLine < block.numLines then | 223 if block.currentLine < block.numLines then |
| 242 print(' - cull', block.currentLine, block.numLines) | 224 print(' - cull', block.currentLine, block.numLines) |
| 249 | 231 |
| 250 if block.currentLine > 0 then | 232 if block.currentLine > 0 then |
| 251 block.attachmentHeight = block.attachmentHeight | 233 block.attachmentHeight = block.attachmentHeight |
| 252 print(' |cFF00FF00attachment:', block.attachmentHeight) | 234 print(' |cFF00FF00attachment:', block.attachmentHeight) |
| 253 end | 235 end |
| 254 return block_schema | 236 return numAttachments, block_schema |
| 255 end | 237 end |
| 256 | 238 |
| 257 Default.UpdateLine = function(handler, block, data) | 239 Default.UpdateLine = function(handler, block, data) |
| 258 return block.info.description, nil, 'default' | 240 return block.info.description, nil, 'default' |
| 259 end | 241 end |
