Mercurial > wow > buffalo2
comparison ObjectiveTracker/Frame.lua @ 31:48b3e3959a0a
- clean up method arguments
author | Nenue |
---|---|
date | Thu, 14 Apr 2016 19:39:05 -0400 |
parents | 7583684becf4 |
children | a3afe6c3771e |
comparison
equal
deleted
inserted
replaced
30:7583684becf4 | 31:48b3e3959a0a |
---|---|
35 | 35 |
36 local headerHeight, headerColor, headerSpacing = 16, {1,.75,0,1}, 2 | 36 local headerHeight, headerColor, headerSpacing = 16, {1,.75,0,1}, 2 |
37 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} |
38 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' |
39 | 39 |
40 local titlebg = {'HORIZONTAL', 1, 0, .7, .25, 1, 0, .7, .125} | 40 local titlebg = {'HORIZONTAL', 1, 0, .7, 0, 1, 0, .7, .2} |
41 local titlebg_daily = {'HORIZONTAL', 0, .7, 1, .25, 0, 1, .7, .125 } | 41 local titlebg_daily = {'HORIZONTAL', 0, .7, 1, 0, 0, 1, .7, .2 } |
42 local titlebg_account = {'HORIZONTAL', 0, .45, 1, .25, 0, .45, 1, .125} | 42 local titlebg_account = {'HORIZONTAL', 0, .45, 1, 0, 0, .45, 1, .2} |
43 local titleFont, titleSize, titleOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'OUTLINE' | 43 local titleFont, titleSize, titleOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'OUTLINE' |
44 | 44 |
45 local textbg = {'HORIZONTAL', 0, 0, 0, 0.4, 0, 0, 0, 0 } | 45 local textbg = {'HORIZONTAL', 0, 0, 0, 0.4, 0, 0, 0, 0 } |
46 local textbg_daily = {'HORIZONTAL', 0, .7, 1, .1, 0, 1, .7, .075 } | 46 local textbg_daily = {'HORIZONTAL', 0, .7, 1, .1, 0, 1, .7, .075 } |
47 local textbg_account = {'HORIZONTAL', 0, .45, 1, 0.4, 0, .41, 1, .085 } | 47 local textbg_account = {'HORIZONTAL', 0, .45, 1, 0.4, 0, .41, 1, .085 } |
51 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} |
52 local titleSpacing, textSpacing, blockSpacing = 3, 3, 1 | 52 local titleSpacing, textSpacing, blockSpacing = 3, 3, 1 |
53 local titleIndent, textIndent,selectionIndent = 2, 5, 50 | 53 local titleIndent, textIndent,selectionIndent = 2, 5, 50 |
54 | 54 |
55 local lineColors = { | 55 local lineColors = { |
56 text = {.5,.75,1}, | 56 normal = { |
57 text = {.5,.75,1}, | |
58 }, | |
59 completed = { | |
60 text = {1,0,.1} | |
61 }, | |
62 failed = { | |
63 text = {1,0,0 } | |
64 }, | |
65 autocomplete = { | |
66 text = {0,1,0 } | |
67 }, | |
68 object = { | |
69 text = {0,1,1} | |
70 }, | |
71 monster = { | |
72 text = {1,1,0} | |
73 }, | |
74 item = { | |
75 text = {1,.25,.5} | |
76 } | |
57 } | 77 } |
58 | 78 |
59 local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed | 79 local wrapperMaxWidth, wrapperMaxHeight = 270, 490 -- these are the hard bounds, actual *Height variables are changed |
60 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE' | 80 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE' |
61 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0 } | 81 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0 } |
104 --- Adds the given line to the current content and advances the anchor pointer to that new line for the following call. | 124 --- Adds the given line to the current content and advances the anchor pointer to that new line for the following call. |
105 Default.AddLine = function(handler, block, text, attachment, template) | 125 Default.AddLine = function(handler, block, text, attachment, template) |
106 local print = lprint | 126 local print = lprint |
107 local lineIndex = block.currentLine + 1 | 127 local lineIndex = block.currentLine + 1 |
108 local line = handler:GetLine(block) | 128 local line = handler:GetLine(block) |
129 line.index = lineIndex | |
109 line:ClearAllPoints() | 130 line:ClearAllPoints() |
110 line:SetPoint('LEFT', block, 'LEFT', 0, 0) | 131 line:SetPoint('LEFT', block, 'LEFT', 0, 0) |
111 line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, -textSpacing) | 132 line:SetPoint('TOP', block.endPoint, 'BOTTOM', 0, 0) |
112 line:SetPoint('RIGHT', block, 'RIGHT', 0, 0) | 133 line:SetPoint('RIGHT', block, 'RIGHT', 0, 0) |
113 line:Show() | 134 line:Show() |
114 | 135 |
115 local r, g, b, a = 1, 1, 1, 1 | 136 print(' |cFF0088FFAddLine >>|r', block, '::', block.endPoint:GetName(),'"'.. text .. '"', attachment, template) |
116 if lineColors[template] then | |
117 r, g, b = unpack(lineColors[template]) | |
118 end | |
119 | |
120 line.status:SetText(text) | 137 line.status:SetText(text) |
121 line.height = floor(line.status:GetStringHeight()+.5) + textSpacing | 138 line.height = floor(line.status:GetStringHeight()+.5) + textSpacing |
122 line:SetHeight(line.height) | 139 line:SetHeight(line.height) |
140 | |
141 local r, g, b, a = 1, 1, 1, 1 | |
142 if lineColors[template] then | |
143 r, g, b = unpack(lineColors[template].text) | |
144 end | |
123 line.status:SetTextColor(r, g, b, a) | 145 line.status:SetTextColor(r, g, b, a) |
124 | 146 |
125 -- For progressbar and timer lines, status text may be used as the title heading | 147 -- For progressbar and timer lines, status text may be used as the title heading |
126 if attachment then | 148 if attachment then |
127 local widgetPosition = 0 | 149 local widgetOffset = 0 |
128 attachment:SetPoint('TOP', line, 'TOP', 0, -block.attachmentHeight) | 150 if text and #text >= 1 then |
151 widgetOffset = line.status:GetHeight() + textSpacing | |
152 line.height = floor(line.status:GetStringHeight()+.5) + textSpacing + attachment.height | |
153 print(' |cFFFF0088doing things with captioned widget') | |
154 else | |
155 print(' |cFFFF0088doing things with a widget') | |
156 end | |
157 attachment:SetPoint('TOP', line, 'TOP', 0, -widgetOffset) | |
129 attachment:Show() | 158 attachment:Show() |
130 if text and #text >= 1 then | 159 end |
131 widgetPosition = line.status:GetHeight() + textSpacing | 160 |
132 line.status:SetText(text) | 161 block.attachmentHeight = block.attachmentHeight + line.height |
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 | |
139 | |
140 block.endIndex = line.index | |
141 block.attachmentHeight = block.attachmentHeight + (line.height + textSpacing) | |
142 print(' |cFF0088FFsetting line #'..lineIndex..' for|r', block.info.title, "\n |cFF0088FFsize:|r", line.height, | 162 print(' |cFF0088FFsetting line #'..lineIndex..' for|r', block.info.title, "\n |cFF0088FFsize:|r", line.height, |
143 "|cFF0088FFpoint:|r", line:GetPoint(1), "|cFF0088FFwidget:|r", (line.widget and 'Y' or 'N')) | 163 "|cFF0088FFpoint:|r", line:GetPoint(1), "|cFF0088FFwidget:|r", (line.widget and 'Y' or 'N')) |
144 block.currentLine = lineIndex | 164 block.currentLine = lineIndex |
145 block.endPoint = line | 165 block.endPoint = line.statusbg -- edge used for the next block |
166 | |
167 return lineIndex | |
146 end | 168 end |
147 | 169 |
148 --- Creates or retrieves a complete line data object | 170 --- Creates or retrieves a complete line data object |
149 Default.GetLine = function(handler, block, lineIndex) | 171 Default.GetLine = function(handler, block, lineIndex) |
150 local print = lprint | 172 local print = lprint |
151 local blockIndex = block.index | 173 local blockIndex = block.index |
152 local lines = block.lines | 174 local lines = block.lines |
153 if not lineIndex then | 175 if not lineIndex then |
154 lineIndex = block.currentLine + 1 | 176 lineIndex = block.currentLine + 1 |
155 print('fetching the "next" line:', lineIndex) | 177 print(' fetching the "next" line:', lineIndex) |
156 else | 178 else |
157 print('fetching explicit offset:', lineIndex) | 179 print(' fetching explicit offset:', lineIndex) |
158 end | 180 end |
159 | 181 |
160 block.numLines = max(block.numLines, lineIndex) | 182 block.numLines = max(block.numLines, lineIndex) |
161 print('|cFF00FFFFnumLines:|r', block.numLines, '|cFF00FFFFcurrentLine:|r', block.currentLine) | 183 print(' |cFF00FFFFposition|r', block.currentLine, '|cFF00FFFFof|r|cFFFFFF00' , block.numLines) |
162 | 184 |
163 if not lines[lineIndex] then | 185 if not lines[lineIndex] then |
164 print(' |cFF00FF88created line #'..lineIndex..' from for '..handler.name..' block #'..blockIndex) | 186 print(' |cFF00FF88created line #'..lineIndex..' from for '..handler.name..' block #'..blockIndex) |
165 lines[lineIndex] = CreateFrame('Frame', 'Vn'..handler.name .. blockIndex..'ObjectiveLine'..lineIndex, block, 'VeneerTrackerObjective') | 187 lines[lineIndex] = CreateFrame('Frame', 'Vn'..handler.name .. blockIndex..'ObjectiveLine'..lineIndex, block, 'VeneerTrackerObjective') |
166 local line = lines[lineIndex] | 188 local line = lines[lineIndex] |
207 | 229 |
208 block.title:SetSpacing(c.TitleSpacing) | 230 block.title:SetSpacing(c.TitleSpacing) |
209 block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing) | 231 block.title:SetPoint('TOP', block, 'TOP', 0, -titleSpacing) |
210 | 232 |
211 block.titlebg:SetTexture(1,1,1,1) | 233 block.titlebg:SetTexture(1,1,1,1) |
212 block.titlebg:SetGradientAlpha(unpack(Module.colors.default.titlebg)) | 234 block.titlebg:SetGradientAlpha(unpack(titlebg)) |
213 block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0) | 235 block.titlebg:SetPoint('TOP', block, 'TOP', 0, 0) |
214 block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing) | 236 block.titlebg:SetPoint('BOTTOM', block.title, 'BOTTOM', 0, -titleSpacing) |
215 | 237 |
216 block.status:SetSpacing(c.TextSpacing) | 238 block.status:SetSpacing(c.TextSpacing) |
217 block.status:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, -textSpacing) | 239 block.status:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, -textSpacing) |
218 block.status:SetPoint('LEFT', block.titlebg, 'LEFT', textIndent, 0) | 240 block.status:SetPoint('LEFT', block.titlebg, 'LEFT', textIndent, 0) |
219 | 241 |
220 block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0) | 242 block.statusbg:SetPoint('TOP', block.titlebg, 'BOTTOM', 0, 0) |
221 block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0) | 243 block.statusbg:SetPoint('BOTTOM', block, 'BOTTOM', 0, 0) |
222 block.statusbg:SetTexture(1,1,1,1) | 244 block.statusbg:SetTexture(1,1,1,1) |
223 block.statusbg:SetGradientAlpha(unpack(Module.colors.default.textbg)) | 245 block.statusbg:SetGradientAlpha(unpack(textbg)) |
224 | 246 |
225 block.SelectionOverlay:SetGradientAlpha(unpack(Module.colors.default.selectionbg)) | 247 block.SelectionOverlay:SetGradientAlpha(unpack(Module.colors.default.selectionbg)) |
226 block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0) | 248 block.SelectionOverlay:SetPoint('TOPLEFT', selectionIndent, 0) |
227 block.SelectionOverlay:SetPoint('BOTTOMRIGHT') | 249 block.SelectionOverlay:SetPoint('BOTTOMRIGHT') |
228 | 250 |
528 end | 550 end |
529 -- workaround for scrollchild issue where layers fall out of sync: in this case, it's by 1 vertical pixel | 551 -- workaround for scrollchild issue where layers fall out of sync: in this case, it's by 1 vertical pixel |
530 --block.highlight:SetPoint('TOPLEFT', block, 'TOPLEFT', 0, 1) | 552 --block.highlight:SetPoint('TOPLEFT', block, 'TOPLEFT', 0, 1) |
531 --block.lowlight:SetPoint('BOTTOMLEFT', block, 'BOTTOMLEFT', 0, 1) | 553 --block.lowlight:SetPoint('BOTTOMLEFT', block, 'BOTTOMLEFT', 0, 1) |
532 | 554 |
533 tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'frequencyTag', tagPoint, tagAnchor, tagRelative) | 555 if info.tagInfo then |
534 tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'typeTag', tagPoint, tagAnchor, tagRelative) | 556 tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'frequencyTag', tagPoint, tagAnchor, tagRelative) |
535 tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'completionTag', tagPoint, tagAnchor, tagRelative) | 557 tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'typeTag', tagPoint, tagAnchor, tagRelative) |
536 | 558 tagPoint, tagAnchor, tagRelative = handler:AddTag(block, 'completionTag', tagPoint, tagAnchor, tagRelative) |
559 end | |
537 return block | 560 return block |
538 end | 561 end |
539 | 562 |
540 | 563 |
541 | 564 |
543 --- Does the main iterations for populating block content. | 566 --- Does the main iterations for populating block content. |
544 -- Hooked by corresponding handler functions where additional details need to be sorted. | 567 -- Hooked by corresponding handler functions where additional details need to be sorted. |
545 Default.UpdateObjectives = function(handler, block) | 568 Default.UpdateObjectives = function(handler, block) |
546 local print = lprint | 569 local print = lprint |
547 local info = block.info | 570 local info = block.info |
548 print(' |cFF00FF00default objectives routine', block:GetName()) | 571 print('|cFF00FF00default.objectives', block:GetName()) |
572 -- reset the starting positions | |
549 block.endPoint = block.titlebg | 573 block.endPoint = block.titlebg |
550 block.attachmentHeight = 0 | 574 block.attachmentHeight = 0 |
551 block.currentLine = 0 | 575 block.currentLine = 0 |
552 | 576 |
553 -- reset the starting positions | 577 local displayObjectiveHeader = false |
578 | |
554 block.attachmentHeight = 0 | 579 block.attachmentHeight = 0 |
555 block.endPoint = block.titlebg | 580 local text, attachment, template |
556 local completionScore, completionMax = 0, 0 | 581 if info.statusKey and (Devian and Devian.InWorkspace()) then |
557 local displayObjectiveHeader = false | 582 handler:AddLine(block, info.statusKey, nil) |
558 | 583 end |
559 | 584 |
560 --- The first line is going to be used no matter what, so it is hard-pulled. | 585 |
561 -- It also ensures that we're in the right position for cleaning up the leftover lines. | |
562 | |
563 block.attachmentHeight = 0 | |
564 | |
565 local text, attachment | |
566 if info.description and #info.description >= 1 then | 586 if info.description and #info.description >= 1 then |
567 print(' |cFF00FFFF header line:|r', info.description) | 587 print(' |cFF00FFFF header line:|r', info.description) |
568 text = info.description | 588 text = info.description |
569 handler:AddLine(block, text, nil) | 589 handler:AddLine(block, text, nil) |
570 end | 590 end |
571 | 591 |
572 if (info.isComplete or info.numObjectives == 0) and info.completionText then | 592 if (info.isComplete or info.numObjectives == 0) and info.completionText then |
573 print(' overriding line #1 for completion text:', info.completionText) | 593 print(' overriding line #1 for completion text:', info.completionText) |
574 text = info.completionText | 594 text = info.completionText |
575 Module.AddLine(block, text, nil) | 595 handler:AddLine(block, text, nil) |
576 else | 596 else |
577 if info.objectives then | 597 if info.objectives then |
578 for i, data in ipairs(info.objectives) do | 598 for i, data in ipairs(info.objectives) do |
579 local line = handler:GetLine(block) | 599 local line = handler:GetLine(block) |
580 displayObjectiveHeader = true | 600 displayObjectiveHeader = true |
581 line.height = 0 | 601 line.height = 0 |
582 text, attachment = handler:UpdateLine(block, line, data) | 602 text, attachment, template = handler:UpdateLine(block, line, data) |
583 print(' |cFF88FF00#', i, data.type, text) | 603 print(' |cFF88FF00#', i, data.type, text) |
584 handler:AddLine(block, text, attachment) | 604 handler:AddLine(block, text, attachment, template) |
585 | 605 |
586 end | 606 end |
587 end | 607 end |
588 end | 608 end |
589 | 609 |
593 block.lines[i]:ClearAllPoints() | 613 block.lines[i]:ClearAllPoints() |
594 block.lines[i]:Hide() | 614 block.lines[i]:Hide() |
595 end | 615 end |
596 | 616 |
597 if block.currentLine > 0 then | 617 if block.currentLine > 0 then |
598 block.attachmentHeight = block.attachmentHeight + textSpacing * 2 | 618 block.attachmentHeight = block.attachmentHeight + textSpacing |
599 print(' |cFF00FF00attachment:', block.attachmentHeight) | 619 print(' |cFF00FF00attachment:', block.attachmentHeight) |
600 end | 620 end |
601 | |
602 | |
603 if debug then | |
604 for i, region in ipairs(block.debug) do | |
605 for j = 1, region:GetNumPoints() do | |
606 local _, target = region:GetPoint(j) | |
607 if target:IsVisible() then | |
608 region:Hide() | |
609 else | |
610 region:Show() | |
611 end | |
612 end | |
613 end | |
614 end | |
615 | |
616 block.completionScore = completionScore / completionMax | |
617 end | 621 end |
618 | 622 |
619 | 623 |
620 --- Module-specific display variables | 624 --- Module-specific display variables |
621 -- * height - height of whatever display widget is involved in conveying the task | 625 -- * height - height of whatever display widget is involved in conveying the task |
622 -- * money - boolean that determines listening for money events or not | 626 -- * money - boolean that determines listening for money events or not |
623 -- * progress - number ranging 0 to 2 indicating none/partial/full completion respectively | 627 -- * progress - number ranging 0 to 2 indicating none/partial/full completion respectively |
624 | 628 |
625 | 629 |
626 Default.UpdateLine = function(block, line) | 630 Default.UpdateLine = function(handler, block, line, data) |
627 if line.finished then | 631 if line.finished then |
628 line.progress = 2 | 632 line.progress = 2 |
629 elseif line.quantity > 0 then | 633 elseif line.quantity > 0 then |
630 line.progress = 1 | 634 line.progress = 1 |
631 else | 635 else |
632 line.progress = 0 | 636 line.progress = 0 |
633 end | 637 end |
634 return line.displayText, line.widget | 638 return data.text, line.widget, 'normal' |
635 end | 639 end |
636 ---------- | 640 ---------- |
637 --- Top level methods | 641 --- Top level methods |
638 | 642 |
639 --- Queue any active item buttons for update for that frame | 643 --- Queue any active item buttons for update for that frame |