comparison ObjectiveFrame.lua @ 4:18eee961038e

- more action button debug
author Nenue
date Thu, 31 Mar 2016 14:28:40 -0400
parents 3397aae1f44d
children e9b61fd5f607
comparison
equal deleted inserted replaced
3:3397aae1f44d 4:18eee961038e
385 --- todo: implement objective displays 385 --- todo: implement objective displays
386 -- in an accumulator loop, call upon handler for the appropriate display frame, each defining: 386 -- in an accumulator loop, call upon handler for the appropriate display frame, each defining:
387 -- * height of whatever display widget is involved in conveying the task 387 -- * height of whatever display widget is involved in conveying the task
388 -- * number of non-wrapped text lines to account for line space; may be discarded depending on things 388 -- * number of non-wrapped text lines to account for line space; may be discarded depending on things
389 -- * boolean that determines listening for money events or not 389 -- * boolean that determines listening for money events or not
390 t.attachmentHeight = 0 390 t.attachmentHeight, text = mod.UpdateObjectives(t, info, text)
391 for o, obj in ipairs(t.info.objectives) do 391
392 --- achievement criteria
393 if obj.flags then
394
395 if bit.band(obj.flags, 0x00000001) > 0 then
396 obj.type = 'ProgressBar'
397 obj.widget = mod.SetWidget(obj, info)
398 elseif bit.band(obj.flags, 0x00000002) then
399 obj.type = 'Hidden'
400 obj.widget = nil
401 else
402 obj.type = 'Text'
403 obj.widget = nil
404 text = text .. ((text == '') and "" or "\n") .. obj.text
405 end
406
407 print(obj.type, obj.text, obj.quantityString)
408 --- none of the above (most quests)
409 else
410 local line = obj.text
411 if obj.type == 'monster' then
412 line = '|cFFFFFF00' .. line .. '|r'
413 elseif obj.type == 'item' then
414 line = '|cFF44BBFF' .. line .. '|r'
415 elseif obj.type == 'object' then
416 line = '|cFFFFFFFF' .. line .. '|r'
417 end
418 text = text .. ((text == '') and "" or "\n") .. line
419 end
420
421 if obj.widget then
422 t.attachmentHeight = t.attachmentHeight + obj.widget.height
423 end
424
425 end
426 t.objectives:SetText(text) 392 t.objectives:SetText(text)
427 t.objectives:SetWordWrap(true) 393 t.objectives:SetWordWrap(true)
428 394
429
430 -- todo: set up a SecureActionButton template
431 if info.specialItem and not info.itemButton then
432 print(' - |cFF00FFFFupdate item button')
433 mod.SetItemButton(t, info)
434 end
435 395
436 396
437 elseif info.description then 397 elseif info.description then
438 t.objectives:SetText(info.description) 398 t.objectives:SetText(info.description)
439 t.objectives:SetWordWrap(true) 399 t.objectives:SetWordWrap(true)
445 style = 'Complete' 405 style = 'Complete'
446 elseif info.superTracked then 406 elseif info.superTracked then
447 style = 'Super' 407 style = 'Super'
448 end 408 end
449 409
410 if info.specialItem then
411 print(' - |cFF00FFFFupdate item button')
412 info.itemButton = mod.SetItemButton(t, info)
413 else
414 --info.itemButton = nil
415 end
416
450 --- metrics are calculated in SetStyle 417 --- metrics are calculated in SetStyle
451 t:SetStyle(style) 418 t:SetStyle(style)
452 t:Show() 419 t:Show()
453 420
454 print(' |cFF00FFFF)|r -> ', t, t:GetHeight()) 421 print(' |cFF00FFFF)|r -> ', t, t:GetHeight())
455 return t 422 return t
423 end
424
425 mod.UpdateObjectives = function(block, info, text)
426 local attachmentHeight = 0
427 for o, obj in ipairs(info.objectives) do
428 --- achievement criteria
429 if obj.flags then
430
431
432 if bit.band(obj.flags, 0x00000001) > 0 then
433 obj.type = 'ProgressBar'
434 obj.widget = mod.SetWidget(obj, info)
435 elseif bit.band(obj.flags, 0x00000002) then
436 obj.type = 'Hidden'
437 obj.widget = nil
438 else
439 obj.type = 'Text'
440 obj.widget = nil
441 text = text .. ((text == '') and "" or "\n") .. obj.text
442 end
443
444 print(obj.type, obj.text, obj.quantityString)
445 --- none of the above (most quests)
446 else
447 local line = obj.text
448 local color = '00FFFF'
449 if obj.finished then
450 color = 'FFFFFF'
451 elseif obj.type == 'monster' then
452 color = 'FFFF00'
453 elseif obj.type == 'item' then
454 color = '44DDFF'
455 elseif obj.type == 'object' then
456 color = 'FF44DD'
457 end
458 text = text .. ((text == '') and "" or "\n") .. '|cFF'..color.. line .. '|r'
459 end
460
461 if obj.widget then
462 attachmentHeight = attachmentHeight + obj.widget.height
463 end
464
465 end
466 return attachmentHeight, text
456 end 467 end
457 468
458 mod.UpdateTracker = function(handler) 469 mod.UpdateTracker = function(handler)
459 print('|cFF00FF88UpdateTracker(|r|cFFFF4400' .. type(handler) .. '|r :: |cFF88FFFF' .. tostring(handler) .. '|r') 470 print('|cFF00FF88UpdateTracker(|r|cFFFF4400' .. type(handler) .. '|r :: |cFF88FFFF' .. tostring(handler) .. '|r')
460 local tracker = handler.Tracker 471 local tracker = handler.Tracker
601 mod.UpdateActionButtons = function() 612 mod.UpdateActionButtons = function()
602 local previousItem 613 local previousItem
603 for questID, itemButton in pairs(usedButtons) do 614 for questID, itemButton in pairs(usedButtons) do
604 local questIndex = mod.Quest.Info[questID].questLogIndex 615 local questIndex = mod.Quest.Info[questID].questLogIndex
605 print('|cFF00FFFF', questID, itemButton:GetName()) 616 print('|cFF00FFFF', questID, itemButton:GetName())
606 local block = mod.Quest.LogBlock[questID] 617 local block = mod.Quest.LogBlock[questIndex]
607 print(block:GetTop())
608 if block then 618 if block then
619 print(block:GetTop())
609 if IsQuestWatched(questIndex) then 620 if IsQuestWatched(questIndex) then
610 -- Dispatch the probe 621 -- Dispatch the probe
611 block:SetScript('OnUpdate', function() 622 block:SetScript('OnUpdate', function()
612 print('|cFFFFFF00probing', block:GetName()) 623 print('|cFFFFFF00probing', block:GetName())
613 if block:GetBottom() then 624 if block:GetBottom() and not InCombatLockdown() then
614 print('|cFF00FF00ding ding ding!') 625 print('|cFF00FF00ding ding ding!')
615 mod.UpdateBlockAction(block, itemButton, previousItem) 626 mod.UpdateBlockAction(block, itemButton, previousItem)
616 block:SetScript('OnUpdate', nil) 627 block:SetScript('OnUpdate', nil)
617 end 628 end
618 end) 629 end)