Mercurial > wow > ouroloot
comparison gui.lua @ 74:5edaac60449b
Replace kludgey debug tooltip toggle with a dropdown, workable at runtime.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Thu, 31 May 2012 00:06:20 +0000 |
parents | 32eb24fb2ebf |
children | 676fb79a4ae2 |
comparison
equal
deleted
inserted
replaced
73:32eb24fb2ebf | 74:5edaac60449b |
---|---|
430 --print("finished history loop, #st ==", #st) | 430 --print("finished history loop, #st ==", #st) |
431 self.hist_clean = cache_okay and #self.history or nil | 431 self.hist_clean = cache_okay and #self.history or nil |
432 end | 432 end |
433 end | 433 end |
434 | 434 |
435 -- Debugging tooltip | 435 -- Debugging tooltip (unfortunately managed by global and semi-global state |
436 if true then | 436 -- rather than passing around stack parameters) |
437 local tt | 437 do |
438 local debug_tt | |
439 | |
440 local _creators, _builders = {}, {} | |
438 local function _create_tooltip() | 441 local function _create_tooltip() |
439 tt = CreateFrame("GameTooltip") | 442 local which = assert(tonumber(_do_debugging_tooltip)) |
443 if type(_creators[which]) == 'function' then | |
444 _creators[which]() | |
445 end | |
446 debug_tt = _creators[which] | |
447 end | |
448 function _build_debugging_tooltip (parent, index) | |
449 local which = assert(tonumber(_do_debugging_tooltip)) | |
450 if type(_builders[which]) == 'function' then | |
451 _builders[which](parent,index) | |
452 end | |
453 end | |
454 function _hide_debugging_tooltip() | |
455 if debug_tt then debug_tt:Hide() end | |
456 end | |
457 | |
458 -- 2 == /dump | |
459 _creators[2] = function() | |
460 local tt = CreateFrame("GameTooltip") | |
440 UIParentLoadAddOn("Blizzard_DebugTools") | 461 UIParentLoadAddOn("Blizzard_DebugTools") |
441 | 462 |
442 tt:SetBackdrop{ | 463 tt:SetBackdrop{ |
443 bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], | 464 bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], |
444 edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], | 465 edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], |
482 end | 503 end |
483 right:SetPoint("RIGHT",left,"LEFT") | 504 right:SetPoint("RIGHT",left,"LEFT") |
484 end | 505 end |
485 tt.AddMessage = tt.AddLine | 506 tt.AddMessage = tt.AddLine |
486 | 507 |
487 _create_tooltip = nil | 508 _creators[2] = tt |
488 end | 509 end |
489 | 510 |
490 function _build_debugging_tooltip (parent, index) | 511 _builders[2] = function (parent, index) |
491 local e = g_loot[index]; assert(type(e)=='table') | 512 local e = g_loot[index]; assert(type(e)=='table') |
492 if not tt then _create_tooltip() end | 513 _create_tooltip() |
493 tt:SetOwner (parent, "ANCHOR_LEFT", -15, -5) | 514 debug_tt:SetOwner (parent, "ANCHOR_LEFT", -15, -5) |
494 tt:ClearLines() | 515 debug_tt:ClearLines() |
495 | 516 |
496 local real = DEFAULT_CHAT_FRAME | 517 local real = DEFAULT_CHAT_FRAME |
497 DEFAULT_CHAT_FRAME = tt | 518 DEFAULT_CHAT_FRAME = debug_tt |
498 DevTools_Dump{ [index] = e } | 519 DevTools_Dump{ [index] = e } |
499 DEFAULT_CHAT_FRAME = real | 520 DEFAULT_CHAT_FRAME = real |
500 | 521 |
501 tt:Show() | 522 debug_tt:Show() |
502 end | 523 end |
503 | |
504 function _hide_debugging_tooltip() | |
505 if tt then tt:Hide() end | |
506 end | |
507 else | |
508 -- Fields to put in the tooltip (maybe move these into the options window | |
509 -- if I spend too much time fiddling). | |
510 local loot = {'person', 'id', 'unique', 'disposition', 'count', 'variant'} | |
511 local boss = {'bossname', 'reason', 'instance', 'maxsize', 'duration', 'raidersnap'} | |
512 | 524 |
513 -- Now here's a thing unheard-of. A tooltip not inheriting from the big | 525 -- Now here's a thing unheard-of. A tooltip not inheriting from the big |
514 -- memory-wasteful template, but also not intended merely for scanning | 526 -- memory-wasteful template, but also not intended merely for scanning |
515 -- invisible tooltips. | 527 -- invisible tooltips. |
516 -- (If this ever grows beyond a text dump, then replace it with libqtip.) | 528 -- (If this ever grows beyond a text dump, then replace it with libqtip.) |
517 local tt | 529 -- |
518 local function _create_tooltip() | 530 -- Fields to put in the fixed-fields tooltip (maybe move these into the |
519 tt = CreateFrame("GameTooltip") | 531 -- options window if I spend too much time fiddling). |
532 local loot = {'person', 'id', 'unique', 'disposition', 'count', 'variant'} | |
533 local boss = {'bossname', 'reason', 'instance', 'maxsize', 'duration', 'raidersnap'} | |
534 | |
535 -- 3 == fixed fields | |
536 _creators[3] = function() | |
537 local tt = CreateFrame("GameTooltip") | |
520 | 538 |
521 tt:SetBackdrop{ | 539 tt:SetBackdrop{ |
522 bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], | 540 bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], |
523 edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], | 541 edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], |
524 tile = true, | 542 tile = true, |
553 left:SetPoint("TOPLEFT",10,-10) -- top line | 571 left:SetPoint("TOPLEFT",10,-10) -- top line |
554 end | 572 end |
555 right:SetPoint("RIGHT",left,"LEFT") | 573 right:SetPoint("RIGHT",left,"LEFT") |
556 end | 574 end |
557 | 575 |
558 _create_tooltip = nil | 576 _creators[3] = tt |
559 end | 577 end |
560 | 578 |
561 function _build_debugging_tooltip (parent, index) | 579 _builders[3] = function (parent, index) |
562 local e = g_loot[index]; assert(type(e)=='table') | 580 local e = g_loot[index]; assert(type(e)=='table') |
563 if not tt then _create_tooltip() end | 581 _create_tooltip() |
564 tt:SetOwner (parent, "ANCHOR_LEFT", -15, -5) | 582 debug_tt:SetOwner (parent, "ANCHOR_LEFT", -15, -5) |
565 tt:ClearLines() | 583 debug_tt:ClearLines() |
566 | 584 |
567 -- change these, change the +2 above | 585 -- change these, change the +2 above |
568 tt:AddDoubleLine (tostring(index), tostring(e), 1,1,1) | 586 debug_tt:AddDoubleLine (tostring(index), tostring(e), 1,1,1) |
569 tt:AddDoubleLine ('kind', e.kind, 1,1,1) | 587 debug_tt:AddDoubleLine ('kind', e.kind, 1,1,1) |
570 | 588 |
571 local source = (e.kind == 'loot' and loot) or (e.kind == 'boss' and boss) | 589 local source = (e.kind == 'loot' and loot) or (e.kind == 'boss' and boss) |
572 if source then | 590 if source then |
573 for _,field in ipairs(source) do | 591 for _,field in ipairs(source) do |
574 tt:AddDoubleLine (field, tostring(e[field]), 1,1,1, 0,156/255,1) | 592 debug_tt:AddDoubleLine (field, tostring(e[field]), 1,1,1, 0,156/255,1) |
575 end | 593 end |
576 end | 594 end |
577 tt:Show() | 595 debug_tt:Show() |
578 end | |
579 function _hide_debugging_tooltip() | |
580 if tt then tt:Hide() end | |
581 end | 596 end |
582 end | 597 end |
583 | 598 |
584 | 599 |
585 ------ Main GUI Window | 600 ------ Main GUI Window |
1784 w = GUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(1) grp:AddChild(w) | 1799 w = GUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(1) grp:AddChild(w) |
1785 | 1800 |
1786 local simple = GUI:Create("SimpleGroup") | 1801 local simple = GUI:Create("SimpleGroup") |
1787 simple:SetLayout("List") | 1802 simple:SetLayout("List") |
1788 simple:SetRelativeWidth(0.3) | 1803 simple:SetRelativeWidth(0.3) |
1804 w = mkbutton("Dropdown", nil, "", [[hovering over Item column only]]) | |
1805 w:SetFullWidth(true) | |
1806 w:SetLabel("loot debugging tooltip") | |
1807 w:SetList{ | |
1808 [1] = "Off", | |
1809 [2] = "/dump into tooltip", | |
1810 [3] = "small fixed fields", | |
1811 } | |
1812 w:SetValue(_do_debugging_tooltip or 1) | |
1813 w:SetCallback("OnValueChanged", function(_w,event,choice) | |
1814 _do_debugging_tooltip = choice > 1 and choice or nil | |
1815 end) | |
1816 simple:AddChild(w) | |
1817 | |
1818 w = GUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(10) simple:AddChild(w) | |
1819 | |
1789 w = GUI:Create("CheckBoxSmallLabel") | 1820 w = GUI:Create("CheckBoxSmallLabel") |
1790 w:SetFullWidth(true) | 1821 w:SetFullWidth(true) |
1791 w:SetType("checkbox") | 1822 w:SetType("checkbox") |
1792 w:SetLabel("loot debugging tooltip") | 1823 w:SetLabel("debug toggle --->") |
1793 w:SetValue(_do_debugging_tooltip) | |
1794 w:SetCallback("OnValueChanged", function(_w,event,value) | |
1795 _do_debugging_tooltip = value | |
1796 end) | |
1797 simple:AddChild(w) | |
1798 w = GUI:Create("CheckBoxSmallLabel") | |
1799 w:SetFullWidth(true) | |
1800 w:SetType("checkbox") | |
1801 w:SetLabel("debug toggle") | |
1802 w:SetValue(addon.DEBUG_PRINT) | 1824 w:SetValue(addon.DEBUG_PRINT) |
1803 w:SetCallback("OnValueChanged", function(_w,event,value) | 1825 w:SetCallback("OnValueChanged", function(_w,event,value) |
1804 addon.DEBUG_PRINT = value | 1826 addon.DEBUG_PRINT = value |
1805 addon:redisplay() | 1827 addon:redisplay() |
1806 end) | 1828 end) |