Mercurial > wow > buffalo2
comparison ObjectiveFrame.lua @ 22:9b3fa734abff
ObjectiveFrame
- polish quest rewards display
- implement money objectives
- set line metrics in UpdateLine
- set block metrics in UpdateBlock (sum of line metrics)
author | Nenue |
---|---|
date | Sat, 09 Apr 2016 07:32:45 -0400 |
parents | d5ee940de273 |
children |
comparison
equal
deleted
inserted
replaced
21:d5ee940de273 | 22:9b3fa734abff |
---|---|
41 local blockSpacing = 1 | 41 local blockSpacing = 1 |
42 local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed | 42 local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed |
43 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE' | 43 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE' |
44 local headerFont, headerSize, headerHeight = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 18, 24 | 44 local headerFont, headerSize, headerHeight = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 18, 24 |
45 local headerOutline, headerColor, headerSpacing = 'OUTLINE', {1,1,1,1}, 2 | 45 local headerOutline, headerColor, headerSpacing = 'OUTLINE', {1,1,1,1}, 2 |
46 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0} | 46 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0 } |
47 local rewardSize = 32 | |
47 local oprint = B.print('Objectives') | 48 local oprint = B.print('Objectives') |
48 local bprint = B.print('Block') | 49 local bprint = B.print('Block') |
49 local tprint = B.print('Tracker') | 50 local tprint = B.print('Tracker') |
50 local lprint = B.print('Line') | 51 local lprint = B.print('Line') |
51 | 52 |
120 block.statusbg:SetGradientAlpha(unpack(textbg)) | 121 block.statusbg:SetGradientAlpha(unpack(textbg)) |
121 | 122 |
122 block.SelectionOverlay:SetPoint('TOPLEFT') | 123 block.SelectionOverlay:SetPoint('TOPLEFT') |
123 block.SelectionOverlay:SetPoint('BOTTOMRIGHT') | 124 block.SelectionOverlay:SetPoint('BOTTOMRIGHT') |
124 | 125 |
126 block.icon:SetSize(rewardSize, rewardSize) | |
127 block.icon:SetPoint('TOPRIGHT', block, 'TOPRIGHT', -2, -2) | |
125 | 128 |
126 | 129 |
127 --- methods for event handlers | 130 --- methods for event handlers |
128 | 131 |
129 block.Select = handler.Select | 132 block.Select = handler.Select |
179 displayObjectiveHeader = true | 182 displayObjectiveHeader = true |
180 end | 183 end |
181 | 184 |
182 local attachmentHeight = 0 | 185 local attachmentHeight = 0 |
183 if info.objectives then | 186 if info.objectives then |
187 attachmentHeight = textSpacing * 2 | |
184 for i, data in ipairs(info.objectives) do | 188 for i, data in ipairs(info.objectives) do |
185 print(' |cFF88FF00#', i, data.type, data.text) | 189 print(' |cFF88FF00#', i, data.type, data.text) |
186 displayObjectiveHeader = true | 190 displayObjectiveHeader = true |
187 local line = block:GetLine(i) | 191 local line = block:GetLine(i) |
188 line.height = 0 | 192 line.height = 0 |
189 block:UpdateLine(line, data) | 193 block:UpdateLine(line, data) |
190 | 194 |
191 line:ClearAllPoints() | 195 line:ClearAllPoints() |
192 if line.displayText then | 196 if line.widget then |
197 local widgetPosition = 0 | |
198 line.widget:SetPoint('TOP', line, 'TOP', 0, -widgetPosition) | |
199 line.widget:Show() | |
200 line.height = line.widget:GetHeight() + textSpacing | |
201 | |
202 if line.displayText and #line.displayText >= 1 then | |
203 widgetPosition = line.status:GetHeight() + textSpacing | |
204 line.status:SetText(line.displayText) | |
205 line.height = floor(line.status:GetStringHeight()+.5) + textSpacing + line.widget.height | |
206 print(' - progressbar has text, adjust') | |
207 end | |
208 elseif line.displayText then | |
193 line.status:SetText(line.displayText) | 209 line.status:SetText(line.displayText) |
194 line.height = floor(line.status:GetStringHeight()+.5) | 210 line.height = floor(line.status:GetStringHeight()+.5) + textSpacing |
211 | |
195 end | 212 end |
196 | 213 attachmentHeight = attachmentHeight + line.height |
197 if line.widget then | |
198 line.widget:SetPoint('TOP', line, 'TOP', 0, 0) | |
199 line.widget:Show() | |
200 end | |
201 | |
202 | 214 |
203 line:Show() | 215 line:Show() |
204 | 216 |
205 line:SetPoint('LEFT', block, 'LEFT', 0, 0) | 217 line:SetPoint('LEFT', block, 'LEFT', 0, 0) |
206 line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, 0) | 218 line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, 0) |
207 line:SetPoint('RIGHT', block, 'RIGHT', 0, 0) | 219 line:SetPoint('RIGHT', block, 'RIGHT', 0, 0) |
208 line:SetHeight(line.height) | 220 line:SetHeight(line.height) |
209 | 221 |
210 attachmentHeight = attachmentHeight + line.height | 222 |
211 print(' sz', line:GetSize()) | 223 print(' sz', line:GetSize()) |
212 print(' pt', line:GetPoint(1)) | 224 print(' pt', line:GetPoint(1)) |
213 print(' |cFF44BBFF#', i, 'anchoring line, size:', line.height, 'current endpoint:', line.statusbg) | 225 print(' |cFF44BBFF#', i, 'anchoring line, size:', line.height, 'current endpoint:', line.statusbg) |
214 | 226 |
215 block.endPoint = line | 227 block.endPoint = line |
216 end | 228 end |
217 | 229 |
218 if attachmentHeight > 0 then | 230 if attachmentHeight > 0 then |
219 block.attachmentHeight = attachmentHeight + textSpacing * 2 | 231 block.attachmentHeight = attachmentHeight |
220 print(' |cFF00FF00attachment:', block.attachmentHeight) | 232 print(' |cFF00FF00attachment:', block.attachmentHeight) |
221 end | 233 end |
222 | 234 |
223 local lines = handler.lines[block.blockIndex] | 235 local lines = handler.lines[block.blockIndex] |
224 local numObjectives = info.numObjectives | 236 local numObjectives = #info.objectives |
225 local numLines = #lines | 237 local numLines = #lines |
226 if numLines > numObjectives then | 238 if lines and numLines > numObjectives then |
227 print(' has extra lines, need to clean up;', numLines, numObjectives) | 239 print(' has extra lines, need to clean up;', numLines, numObjectives) |
228 for i = numObjectives+1, numLines do | 240 for i = numObjectives+1, numLines do |
229 print(' hide', i, lines[i]:GetName()) | 241 print(' hide', i, lines[i]:GetName()) |
230 lines[i]:Hide() | 242 lines[i]:Hide() |
231 end | 243 end |
268 end | 280 end |
269 | 281 |
270 Quest.UpdateObjectives = function(handler, block) | 282 Quest.UpdateObjectives = function(handler, block) |
271 local print = lprint | 283 local print = lprint |
272 print('|cFF00FFFFUpdateObjectives()') | 284 print('|cFF00FFFFUpdateObjectives()') |
273 Default.UpdateObjectives(handler, block) | |
274 local info = block.info | 285 local info = block.info |
275 local completionText | 286 local completionText |
276 if info.isAutoComplete then | 287 if info.isAutoComplete then |
277 local questID, popupType = GetAutoQuestPopUp(info.questLogIndex) | 288 local questID, popupType = GetAutoQuestPopUp(info.questLogIndex) |
278 if popupType == 'COMPLETE' then | 289 if popupType == 'COMPLETE' then |
279 completionText = CLICK_TO_COMPLETE | 290 completionText = CLICK_TO_COMPLETE |
280 end | 291 end |
281 end | 292 end |
282 if not completionText then | 293 if info.isComplete then |
283 completionText = GetQuestLogCompletionText(info.questLogIndex) | 294 if not completionText then |
284 end | 295 completionText = GetQuestLogCompletionText(info.questLogIndex) |
285 | 296 end |
286 block.status:SetText() | 297 else |
298 Default.UpdateObjectives(handler, block) | |
299 end | |
287 end | 300 end |
288 | 301 |
289 --- Module-specific display variables | 302 --- Module-specific display variables |
290 -- * height - height of whatever display widget is involved in conveying the task | 303 -- * height - height of whatever display widget is involved in conveying the task |
291 -- * money - boolean that determines listening for money events or not | 304 -- * money - boolean that determines listening for money events or not |
311 end | 324 end |
312 | 325 |
313 line.displayColor = {r, g, b, a} | 326 line.displayColor = {r, g, b, a} |
314 line.status:SetTextColor(r, g, b, a) | 327 line.status:SetTextColor(r, g, b, a) |
315 line.displayText = data.text | 328 line.displayText = data.text |
329 | |
316 return line | 330 return line |
317 end | 331 end |
318 | 332 |
319 Bonus.UpdateLine = function(handler, block, line, data) | 333 Bonus.UpdateLine = function(handler, block, line, data) |
320 local info = block.info | 334 local info = block.info |
321 local print = lprint | 335 local print = lprint |
322 | 336 |
323 | 337 |
324 line.displayColor = 'FFFFFF' | 338 line.displayColor = 'FFFFFF' |
325 if data.text and not info.title then | 339 line.displayText = data.text |
326 print('using first text item as title') | |
327 info.title = data.text | |
328 else | |
329 line.displayText = data.text | |
330 end | |
331 | |
332 line.progress = 0 | 340 line.progress = 0 |
333 print(' ', data.objectiveIndex,'|cFFFF0088-|r', data.objectiveType, data.text) | 341 print(' ', data.objectiveIndex,'|cFFFF0088-|r', data.objectiveType, data.text) |
334 if data.objectiveType == 'progressbar' then | 342 if data.objectiveType == 'progressbar' then |
335 line.widgetType = 'ProgressBar' | 343 line.widgetType = 'ProgressBar' |
336 print(' |cFFFF44DDpercent='..tostring(GetQuestProgressBarPercent(info.questID))) | 344 print(' |cFFFF44DDpercent='..tostring(GetQuestProgressBarPercent(info.questID))) |
342 line.progress = 2 | 350 line.progress = 2 |
343 end | 351 end |
344 line.format = PERCENTAGE_STRING | 352 line.format = PERCENTAGE_STRING |
345 local widget = mod.SetWidget(line, data, 'ProgressBar', info.questID..'-'..data.objectiveIndex) | 353 local widget = mod.SetWidget(line, data, 'ProgressBar', info.questID..'-'..data.objectiveIndex) |
346 print(' |cFFFF0022** text:|r', data.text, '|cFFFF0022value:|r', data.value, '|cFFFF0022max:|r', data.maxValue) | 354 print(' |cFFFF0022** text:|r', data.text, '|cFFFF0022value:|r', data.value, '|cFFFF0022max:|r', data.maxValue) |
347 widget:SetPoint('CENTER', line, 'CENTER', 0, 0) | 355 widget:SetPoint('TOP', line, 'TOP', 0, 0) |
348 | 356 |
349 line.widget = widget | 357 line.widget = widget |
350 line.height = widget.height | 358 line.height = widget.height |
351 else | 359 else |
352 line.displayText = data.text | 360 line.displayText = data.text |
478 | 486 |
479 | 487 |
480 Default.Update = function (self, reason, ...) | 488 Default.Update = function (self, reason, ...) |
481 local print = tprint | 489 local print = tprint |
482 local tracker = self.frame | 490 local tracker = self.frame |
483 print('|cFFFF4400'..tracker:GetName().. '|r:Update()', reason, ...) | |
484 local blockIndex = 0 | 491 local blockIndex = 0 |
485 local trackerHeight = floor(tracker.titlebg:GetHeight()+.5) | 492 local trackerHeight = floor(tracker.titlebg:GetHeight()+.5) |
486 | 493 |
487 self.currentAnchor = tracker.titlebg | 494 self.currentAnchor = tracker.titlebg |
488 local numWatched = self:GetNumWatched() | 495 local numWatched = self:GetNumWatched() |
492 blockIndex = blockIndex + 1 | 499 blockIndex = blockIndex + 1 |
493 if watchIndex <= numWatched then | 500 if watchIndex <= numWatched then |
494 local info = self:GetInfo(watchIndex) | 501 local info = self:GetInfo(watchIndex) |
495 if info then | 502 if info then |
496 local currentBlock = self:UpdateBlock(blockIndex, info) | 503 local currentBlock = self:UpdateBlock(blockIndex, info) |
497 currentBlock:SetPoint('TOPLEFT', self.currentAnchor, 'BOTTOMLEFT', 0, -1) | 504 currentBlock:SetPoint('TOPLEFT', self.currentAnchor, 'BOTTOMLEFT', 0, 0) |
498 currentBlock:SetPoint('RIGHT', tracker,'RIGHT', 0, 0) | 505 currentBlock:SetPoint('RIGHT', tracker,'RIGHT', 0, 0) |
499 self.currentAnchor = currentBlock | 506 self.currentAnchor = currentBlock |
500 print(' |cFFFFFF00'..watchIndex..'|r', '|cFF00FF00'..currentBlock:GetName()..'|r', currentBlock.height) | 507 print(' |cFFFFFF00'..watchIndex..'|r', '|cFF00FF00'..currentBlock:GetName()..'|r', currentBlock.height, trackerHeight) |
501 trackerHeight = trackerHeight + currentBlock.height | 508 trackerHeight = trackerHeight + currentBlock.height |
502 numBlocks = max(numBlocks, watchIndex) | 509 numBlocks = max(numBlocks, watchIndex) |
503 actualBlocks = actualBlocks + 1 | 510 actualBlocks = actualBlocks + 1 |
504 else | 511 else |
505 print(' |cFFFF0000bad GetInfo data for #'..watchIndex) | 512 print(' |cFFFF0000bad GetInfo data for #'..watchIndex) |
526 | 533 |
527 tracker.previousHeight = tracker.height | 534 tracker.previousHeight = tracker.height |
528 if numBlocks >= 1 then | 535 if numBlocks >= 1 then |
529 previousBlock = nil | 536 previousBlock = nil |
530 | 537 |
531 tracker.height = trackerHeight + tracker.titlebg:GetHeight() | 538 tracker.height = trackerHeight |
532 tracker:SetHeight(tracker.height) | 539 tracker:SetHeight(tracker.height) |
533 tracker:Show() | 540 tracker:Show() |
534 | 541 |
535 | 542 |
536 else | 543 else |
611 if info.rewardInfo then | 618 if info.rewardInfo then |
612 print('has immediate reward') | 619 print('has immediate reward') |
613 if info.rewardInfo[1].type == 'currency' or info.rewardInfo[1].type == 'item' then | 620 if info.rewardInfo[1].type == 'currency' or info.rewardInfo[1].type == 'item' then |
614 block.icon:Show() | 621 block.icon:Show() |
615 block.iconLabel:SetText(info.rewardInfo[1].count) | 622 block.iconLabel:SetText(info.rewardInfo[1].count) |
616 block.icon:SetSize(block.height, block.height) | 623 block.icon:SetPoint(tagPoint, tagAnchor, tagRelative, -2, -2) |
617 block.icon:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) | |
618 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', block.icon, 'TOPLEFT' | 624 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', block.icon, 'TOPLEFT' |
619 block.icon:SetTexture(info.rewardInfo[1].texture) | 625 block.icon:SetTexture(info.rewardInfo[1].texture) |
620 end | 626 end |
621 else | 627 else |
622 block.icon:Hide() | 628 block.icon:Hide() |
657 | 663 |
658 local wrapperHeight = 0 | 664 local wrapperHeight = 0 |
659 for id, handler in pairs(mod.orderedHandlers) do | 665 for id, handler in pairs(mod.orderedHandlers) do |
660 local frame = handler.frame | 666 local frame = handler.frame |
661 | 667 |
662 print(format(' |cFF00FFFFbitcheck (%04X vs %04x+%04x):|r', reason, handler.updateReasonModule, handler.updateReasonEvents), band(reason, handler.updateReasonModule + handler.updateReasonEvents)) | 668 print(format('|cFF00FFFF%s and(%04X vs %04x+%04x) = %04X|r', handler.name, reason, handler.updateReasonModule, handler.updateReasonEvents, band(reason, handler.updateReasonModule + handler.updateReasonEvents))) |
663 if band(reason, handler.updateReasonModule + handler.updateReasonEvents) > 0 then | 669 if band(reason, handler.updateReasonModule + handler.updateReasonEvents) > 0 then |
664 handler:Update(reason, ...) | 670 handler:Update(reason, ...) |
665 print(' |cFF00FF00'..id..'|r', handler.displayName, 'count:', handler.numWatched) | 671 print(' |cFF00FF00'..id..'|r', handler.displayName, 'count:', handler.numWatched) |
666 insertingStuff = true | 672 insertingStuff = true |
667 else | 673 else |
735 block:SetScript('OnUpdate', function() | 741 block:SetScript('OnUpdate', function() |
736 if block:GetBottom() and not InCombatLockdown() then | 742 if block:GetBottom() and not InCombatLockdown() then |
737 print(' '..block:GetName()..' |cFF00FF00probe hit!') | 743 print(' '..block:GetName()..' |cFF00FF00probe hit!') |
738 mod.UpdateBlockAction(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope | 744 mod.UpdateBlockAction(block, itemButton, itemButton.previousItem) -- needs to be previousItem from this scope |
739 block:SetScript('OnUpdate', nil) | 745 block:SetScript('OnUpdate', nil) |
746 | |
740 end | 747 end |
741 end) | 748 end) |
742 previousItem = itemButton | 749 previousItem = itemButton |
743 else | 750 else |
744 print('hidden block or unwatched quest') | 751 print('hidden block or unwatched quest') |