Mercurial > wow > buffalo2
comparison ObjectiveFrame.lua @ 18:d1812fb10ae6
ObjectiveStyle
- move tag/template logic into the corresponding GetInfo
| author | Nenue |
|---|---|
| date | Tue, 05 Apr 2016 02:38:01 -0400 |
| parents | 880828018bf4 |
| children | 605e8f0e46db |
comparison
equal
deleted
inserted
replaced
| 17:c33497b116d6 | 18:d1812fb10ae6 |
|---|---|
| 39 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE' | 39 local wrapperHeadFont, wrapperHeadSize, wrapperHeadOutline = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 16, 'NONE' |
| 40 local headerFont, headerSize, headerHeight = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 18, 24 | 40 local headerFont, headerSize, headerHeight = [[Interface\Addons\SharedMedia_MyMedia\font\ArchivoNarrow-Bold.ttf]], 18, 24 |
| 41 local headerOutline, headerColor, headerSpacing = 'OUTLINE', {1,1,1,1}, 2 | 41 local headerOutline, headerColor, headerSpacing = 'OUTLINE', {1,1,1,1}, 2 |
| 42 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0} | 42 local wrapperPosition = {'RIGHT', UIParent, 'RIGHT', -84, 0} |
| 43 | 43 |
| 44 | |
| 45 mod.InitializeWrapper = function() | 44 mod.InitializeWrapper = function() |
| 46 | 45 |
| 47 mod.SetBlockStyle(Scroller, 'Scroller', 'Normal') | 46 mod.SetBlockStyle(Scroller, 'Scroller', 'Normal') |
| 48 mod.SetBlockStyle(Scroller, 'Scroll', 'Normal') | 47 mod.SetBlockStyle(Scroller, 'Scroll', 'Normal') |
| 49 mod.SetBlockStyle(Wrapper, 'Wrapper', 'Normal') | 48 mod.SetBlockStyle(Wrapper, 'Wrapper', 'Normal') |
| 157 | 156 |
| 158 mod.UpdateTracker = function(handler) | 157 mod.UpdateTracker = function(handler) |
| 159 local tracker = handler.Tracker | 158 local tracker = handler.Tracker |
| 160 print('|cFFFF4400'..tracker:GetName().. '|r:Update()') | 159 print('|cFFFF4400'..tracker:GetName().. '|r:Update()') |
| 161 local blockIndex = 0 | 160 local blockIndex = 0 |
| 162 local trackerHeight = headerHeight | 161 local trackerHeight = tracker.titleHeight |
| 163 | 162 |
| 164 | 163 |
| 165 previousBlock = tracker.title | 164 previousBlock = tracker.title |
| 166 local numWatched = handler.GetNumWatched() | 165 local numWatched = handler.GetNumWatched() |
| 167 local numBlocks = handler.numBlocks | 166 local numBlocks = handler.numBlocks |
| 224 end | 223 end |
| 225 local tracker = handler.Tracker | 224 local tracker = handler.Tracker |
| 226 local t = handler:GetBlock(blockIndex) | 225 local t = handler:GetBlock(blockIndex) |
| 227 t.handler = handler | 226 t.handler = handler |
| 228 t.info = info | 227 t.info = info |
| 229 t.mainStyle = 'Normal' | 228 t.mainStyle = info.mainStyle or 'Normal' |
| 230 t.subStyle = nil | 229 t.subStyle = info.subStyle |
| 231 | 230 |
| 232 info.blockIndex = blockIndex | 231 info.blockIndex = blockIndex |
| 233 if info.questID then handler.QuestBlock[info.questID] = t end | 232 if info.questID then handler.QuestBlock[info.questID] = t end |
| 234 if info.questLogIndex then handler.LogBlock[info.questLogIndex] = t end | 233 if info.questLogIndex then handler.LogBlock[info.questLogIndex] = t end |
| 235 if info.watchIndex then handler.WatchBlock[info.watchIndex] = t end | 234 if info.watchIndex then handler.WatchBlock[info.watchIndex] = t end |
| 236 handler.BlockInfo[blockIndex] = info | 235 handler.BlockInfo[blockIndex] = info |
| 237 | 236 |
| 238 | 237 |
| 239 t.attachmentHeight = 0 | 238 t.attachmentHeight = 0 |
| 240 --if info.isComplete then | 239 |
| 241 --t.status:Show() | 240 |
| 242 --t.status:SetText(info.completionText) | 241 |
| 243 --end | 242 |
| 244 | 243 |
| 245 if info.numObjectives >= 1 then | 244 if info.isComplete == 1 then |
| 245 if info.popupInfo then | |
| 246 t.status:SetText('(Click to Complete)') | |
| 247 else | |
| 248 t.status:SetText('Ready to turn in') | |
| 249 end | |
| 250 elseif info.completed then | |
| 251 t.status:SetText(nil) | |
| 252 elseif info.numObjectives >= 1 then | |
| 246 t.attachmentHeight = 0 | 253 t.attachmentHeight = 0 |
| 247 t.status:Show() | 254 t.status:Show() |
| 248 print(' lines to build:', info.numObjectives) | 255 print(' lines to build:', info.numObjectives) |
| 249 | |
| 250 local text = '' | 256 local text = '' |
| 251 | 257 |
| 252 mod.UpdateObjectives(t, info, text) | 258 mod.UpdateObjectives(t, info, text) |
| 253 elseif info.description then | 259 elseif info.description then |
| 254 t.status:SetText(info.description) | 260 t.status:SetText(info.description) |
| 263 print(' - |cFF00FFFFgenerating item button for info set') | 269 print(' - |cFF00FFFFgenerating item button for info set') |
| 264 info.itemButton = mod.SetItemButton(t, info) | 270 info.itemButton = mod.SetItemButton(t, info) |
| 265 else | 271 else |
| 266 --info.itemButton = nil | 272 --info.itemButton = nil |
| 267 end | 273 end |
| 268 | |
| 269 handler.SetBlockTags(t, info) | |
| 270 | 274 |
| 271 if previousBlock then | 275 if previousBlock then |
| 272 t:SetPoint('TOPLEFT', previousBlock, 'BOTTOMLEFT', 0, 0) | 276 t:SetPoint('TOPLEFT', previousBlock, 'BOTTOMLEFT', 0, 0) |
| 273 t:SetPoint('RIGHT', tracker,'RIGHT', 0, 0) | 277 t:SetPoint('RIGHT', tracker,'RIGHT', 0, 0) |
| 274 print(' anchor to|cFF0088FF', previousBlock:GetName()) | 278 print(' anchor to|cFF0088FF', previousBlock:GetName()) |
| 279 t:SetStyle('TrackerBlock', handler.name, t.mainStyle, t.subStyle) | 283 t:SetStyle('TrackerBlock', handler.name, t.mainStyle, t.subStyle) |
| 280 t:Show() | 284 t:Show() |
| 281 | 285 |
| 282 print(' |cFF00FFFF)|r -> ', t, t:GetHeight()) | 286 print(' |cFF00FFFF)|r -> ', t, t:GetHeight()) |
| 283 | 287 |
| 288 local tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t, 'TOPRIGHT' | |
| 284 if info.rewardInfo then | 289 if info.rewardInfo then |
| 285 print('has immediate reward') | 290 print('has immediate reward') |
| 286 if info.rewardInfo[1].type == 'currency' or info.rewardInfo[1].type == 'item' then | 291 if info.rewardInfo[1].type == 'currency' or info.rewardInfo[1].type == 'item' then |
| 287 t.icon:Show() | 292 t.icon:Show() |
| 288 t.iconLabel:SetText(info.rewardInfo[1].count) | 293 t.iconLabel:SetText(info.rewardInfo[1].count) |
| 289 t.icon:SetSize(t.height, t.height) | 294 t.icon:SetSize(t.height, t.height) |
| 295 t.icon:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) | |
| 296 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t.icon, 'TOPLEFT' | |
| 290 t.icon:SetTexture(info.rewardInfo[1].texture) | 297 t.icon:SetTexture(info.rewardInfo[1].texture) |
| 291 end | 298 end |
| 292 | |
| 293 else | 299 else |
| 294 t.icon:Hide() | 300 t.icon:Hide() |
| 295 end | 301 end |
| 296 | 302 |
| 297 if Devian and Devian.InWorkspace() then | 303 if info.selected then |
| 304 t.SelectionOverlay:Show() | |
| 305 else | |
| 306 t.SelectionOverlay:Hide() | |
| 307 end | |
| 308 | |
| 309 if info.frequencyTag then | |
| 310 t.FrequencyTag:SetTexCoord(unpack(info.frequencyTag)) | |
| 311 t.FrequencyTag:Show() | |
| 312 t.FrequencyTag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) | |
| 313 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t.FrequencyTag, 'TOPLEFT' | |
| 314 else | |
| 315 t.FrequencyTag:Hide() | |
| 316 end | |
| 317 if info.typeTag then | |
| 318 t.TypeTag:SetTexCoord(unpack(info.typeTag)) | |
| 319 t.TypeTag:Show() | |
| 320 t.TypeTag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) | |
| 321 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t.TypeTag, 'TOPLEFT' | |
| 322 else | |
| 323 t.TypeTag:Hide() | |
| 324 end | |
| 325 if info.completionTag then | |
| 326 t.CompletionTag:SetTexCoord(unpack(info.completionTag)) | |
| 327 t.CompletionTag:Show() | |
| 328 t.CompletionTag:SetPoint(tagPoint, tagAnchor, tagRelative, 0, 0) | |
| 329 tagPoint, tagAnchor, tagRelative = 'TOPRIGHT', t.CompletionTag, 'TOPLEFT' | |
| 330 else | |
| 331 t.CompletionTag:Hide() | |
| 332 end | |
| 333 | |
| 334 --[[if Devian and Devian.InWorkspace() then | |
| 298 t.debugText:Show() | 335 t.debugText:Show() |
| 299 t.debugText:SetText(tostring(blockIndex) .. '\n' .. tostring(info.itemButton and info.itemButton:GetName()) .. "\n" .. (tostring(t.mainStyle) .. '/' .. tostring(t.subStyle))) | 336 t.debugText:SetText(tostring(blockIndex) .. '\n' .. tostring(info.itemButton and info.itemButton:GetName()) .. "\n" .. (tostring(t.mainStyle) .. '/' .. tostring(t.subStyle))) |
| 300 end | 337 end]] |
| 301 return t | 338 return t |
| 302 end | 339 end |
| 303 | 340 |
| 304 mod.UpdateObjectives = function(block, info, text) | 341 mod.UpdateObjectives = function(block, info, text) |
| 305 local print = B.print('BlockLine') | 342 local print = B.print('BlockLine') |
| 306 print(' |cFF00FF00objective updates for', block:GetName()) | 343 print(' |cFF00FF00objective updates for', block:GetName()) |
| 307 | 344 |
| 308 local attachmentHeight = block.attachmentHeight | 345 local attachmentHeight = block.attachmentHeight |
| 309 if info.description then | 346 if info.description and not(info.earnedBy or info.isComplete) then |
| 310 print(' -- has description text:', select('#', info.description), info.description) | 347 print(' -- has description text:', select('#', info.description), info.description) |
| 311 text = info.description | 348 text = info.description |
| 312 end | 349 end |
| 313 local completionScore, completionMax = 0, 0 | 350 local completionScore, completionMax = 0, 0 |
| 314 | 351 |
| 318 | 355 |
| 319 if line.title then | 356 if line.title then |
| 320 info.title = line.title | 357 info.title = line.title |
| 321 line.title = nil | 358 line.title = nil |
| 322 end | 359 end |
| 323 | |
| 324 | 360 |
| 325 if line.widget then | 361 if line.widget then |
| 326 if attachmentHeight == 0 then | 362 if attachmentHeight == 0 then |
| 327 attachmentHeight = block.status.spacing | 363 attachmentHeight = block.status.spacing |
| 328 end | 364 end |
| 329 | |
| 330 line.widget:Show() | 365 line.widget:Show() |
| 331 line.widget:SetParent(block) | 366 line.widget:SetParent(block) |
| 332 line.widget:SetPoint('TOPLEFT', block.status, 'BOTTOMLEFT', 0, -attachmentHeight ) | 367 line.widget:SetPoint('TOPLEFT', block.status, 'BOTTOMLEFT', 0, -attachmentHeight ) |
| 333 print(' has a widget, height is', line.widget.height) | 368 print(' has a widget, height is', line.widget.height) |
| 334 attachmentHeight = attachmentHeight + line.widget.height | 369 attachmentHeight = attachmentHeight + line.widget.height |
| 338 | 373 |
| 339 if line.displayText then | 374 if line.displayText then |
| 340 print(' has text') | 375 print(' has text') |
| 341 text = text .. ((text == '') and "" or "\n") .. '|cFF'..line.displayColor.. line.displayText .. '|r' | 376 text = text .. ((text == '') and "" or "\n") .. '|cFF'..line.displayColor.. line.displayText .. '|r' |
| 342 end | 377 end |
| 343 | |
| 344 end | 378 end |
| 345 | 379 |
| 346 block.completionScore = completionScore / completionMax | 380 block.completionScore = completionScore / completionMax |
| 347 block.attachmentHeight = attachmentHeight | 381 block.attachmentHeight = attachmentHeight |
| 348 | 382 |
| 349 block.status:SetText(text) | 383 if #text >= 1 then |
| 350 block.status:SetWordWrap(true) | 384 block.status:SetText(text) |
| 385 block.status:SetWordWrap(true) | |
| 386 else | |
| 387 block.status:SetText(nil) | |
| 388 block.status:Hide() | |
| 389 end | |
| 390 | |
| 351 end | 391 end |
| 352 | 392 |
| 353 --- Objective parsers | 393 --- Objective parsers |
| 354 -- defines the following variables | 394 -- defines the following variables |
| 355 -- * height - height of whatever display widget is involved in conveying the task | 395 -- * height - height of whatever display widget is involved in conveying the task |
| 515 print('|cFF00FF00'..Scroll:GetName()..'|r:', Scroll:GetWidth(), Scroll:GetHeight(), | 555 print('|cFF00FF00'..Scroll:GetName()..'|r:', Scroll:GetWidth(), Scroll:GetHeight(), |
| 516 '|cFF00FF00'..Scroller:GetName()..'|r:', Scroller:GetWidth(), Scroller:GetHeight(), | 556 '|cFF00FF00'..Scroller:GetName()..'|r:', Scroller:GetWidth(), Scroller:GetHeight(), |
| 517 '|cFF00FF00'..Wrapper:GetName()..'|r:', Wrapper:GetWidth(), Wrapper:GetHeight(), | 557 '|cFF00FF00'..Wrapper:GetName()..'|r:', Wrapper:GetWidth(), Wrapper:GetHeight(), |
| 518 '|cFF0088FFvScrollRange|r:', floor(Scroller:GetVerticalScrollRange()+.5) | 558 '|cFF0088FFvScrollRange|r:', floor(Scroller:GetVerticalScrollRange()+.5) |
| 519 ) | 559 ) |
| 560 --]] | |
| 520 mod.UpdateActionButtons() | 561 mod.UpdateActionButtons() |
| 521 --]] | |
| 522 | 562 |
| 523 end | 563 end |
| 524 | 564 |
| 525 --- Queue any active item buttons for update for that frame | 565 --- Queue any active item buttons for update for that frame |
| 526 mod.UpdateActionButtons = function(updateReason) | 566 mod.UpdateActionButtons = function(updateReason) |
| 620 end | 660 end |
| 621 | 661 |
| 622 mod.UpdateItemButtonCooldown = function(button) | 662 mod.UpdateItemButtonCooldown = function(button) |
| 623 | 663 |
| 624 end | 664 end |
| 665 | |
| 666 local unitLevel = UnitLevel('player') | |
| 667 | |
| 668 |
