Mercurial > wow > ouroloot
comparison gui.lua @ 72:bb19899c65a7
Add a tooltip for debugging g_loot contents; toggle from the advanced debug options. (Font is ginormous, why?)
| author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
|---|---|
| date | Sat, 12 May 2012 11:08:23 +0000 |
| parents | fb330a1fb6e9 |
| children | 32eb24fb2ebf |
comparison
equal
deleted
inserted
replaced
| 71:fb330a1fb6e9 | 72:bb19899c65a7 |
|---|---|
| 55 local GetItemInfo, ITEM_QUALITY_COLORS = GetItemInfo, ITEM_QUALITY_COLORS | 55 local GetItemInfo, ITEM_QUALITY_COLORS = GetItemInfo, ITEM_QUALITY_COLORS |
| 56 | 56 |
| 57 -- En masse forward decls of symbols defined inside local blocks | 57 -- En masse forward decls of symbols defined inside local blocks |
| 58 local _generate_text, _populate_text_specials | 58 local _generate_text, _populate_text_specials |
| 59 local _tabtexts, _taborder -- filled out in gui block scope | 59 local _tabtexts, _taborder -- filled out in gui block scope |
| 60 local _do_debugging_tooltip, _hide_debugging_tooltip, _build_debugging_tooltip | |
| 60 | 61 |
| 61 --[[ | 62 --[[ |
| 62 This is a table of callback functions, each responsible for drawing a tab | 63 This is a table of callback functions, each responsible for drawing a tab |
| 63 into the container passed in the first argument. Special-purpose buttons | 64 into the container passed in the first argument. Special-purpose buttons |
| 64 can optionally be created (mkbutton) and added to the container in the second | 65 can optionally be created (mkbutton) and added to the container in the second |
| 395 end | 396 end |
| 396 | 397 |
| 397 --print("finished history loop, #st ==", #st) | 398 --print("finished history loop, #st ==", #st) |
| 398 self.hist_clean = cache_okay and #self.history or nil | 399 self.hist_clean = cache_okay and #self.history or nil |
| 399 end | 400 end |
| 400 | 401 end |
| 401 | 402 |
| 403 -- Debugging tooltip | |
| 404 do | |
| 405 -- Fields to put in the tooltip (maybe move these into the options window | |
| 406 -- if I spend too much time fiddling). | |
| 407 local loot = {'person', 'id', 'unique', 'disposition', 'count', 'variant'} | |
| 408 local boss = {'bossname', 'reason', 'instance', 'maxsize', 'duration', 'raidersnap'} | |
| 409 | |
| 410 -- Now here's a thing unheard-of. A tooltip not inheriting from the big | |
| 411 -- memory-wasteful template, but also not intended merely for scanning | |
| 412 -- invisible tooltips. | |
| 413 -- (If this ever grows beyond a text dump, then replace it with libqtip.) | |
| 414 local tt | |
| 415 local function _create_tooltip() | |
| 416 tt = CreateFrame("GameTooltip") | |
| 417 | |
| 418 tt:SetBackdrop{ | |
| 419 bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], | |
| 420 edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]], | |
| 421 tile = true, | |
| 422 tileSize = 8, | |
| 423 edgeSize = 12, | |
| 424 insets = { left = 2, right = 2, top = 2, bottom = 2 } | |
| 425 } | |
| 426 tt:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, | |
| 427 TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b) | |
| 428 tt:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, | |
| 429 TOOLTIP_DEFAULT_COLOR.b) | |
| 430 tt:SetMovable(false) | |
| 431 tt:EnableMouse(false) | |
| 432 tt:SetFrameStrata("TOOLTIP") | |
| 433 tt:SetToplevel(true) | |
| 434 tt:SetClampedToScreen(true) | |
| 435 | |
| 436 local font = GameTooltipTextSmall | |
| 437 local left, right, prevleft | |
| 438 -- Only create as many lines as we might need (the auto growth | |
| 439 -- by Add*Line does odd things sometimes). | |
| 440 for i = 1, math.max(#loot,#boss)+2 do | |
| 441 prevleft = left | |
| 442 left = tt:CreateFontString(nil,"ARTWORK") | |
| 443 right = tt:CreateFontString(nil,"ARTWORK") | |
| 444 left:SetFontObject(font) | |
| 445 right:SetFontObject(font) | |
| 446 tt:AddFontStrings(left,right) | |
| 447 if prevleft then | |
| 448 left:SetPoint("TOPLEFT",prevleft,"BOTTOMLEFT",0,-2) | |
| 449 else | |
| 450 left:SetPoint("TOPLEFT",10,-10) -- top line | |
| 451 end | |
| 452 right:SetPoint("RIGHT",left,"LEFT") | |
| 453 end | |
| 454 | |
| 455 _create_tooltip = nil | |
| 456 end | |
| 457 | |
| 458 function _build_debugging_tooltip (parent, index) | |
| 459 local e = g_loot[index]; assert(type(e)=='table') | |
| 460 if not tt then _create_tooltip() end | |
| 461 tt:SetOwner (parent, "ANCHOR_LEFT", -15, -5) | |
| 462 tt:ClearLines() | |
| 463 | |
| 464 -- change these, change the +2 above | |
| 465 tt:AddDoubleLine (tostring(index), tostring(e), 1,1,1) | |
| 466 tt:AddDoubleLine ('kind', e.kind, 1,1,1) | |
| 467 | |
| 468 local source = (e.kind == 'loot' and loot) or (e.kind == 'boss' and boss) | |
| 469 if source then | |
| 470 for _,field in ipairs(source) do | |
| 471 tt:AddDoubleLine (field, tostring(e[field]), 1,1,1, 0,156/255,1) | |
| 472 end | |
| 473 end | |
| 474 tt:Show() | |
| 475 end | |
| 476 function _hide_debugging_tooltip() | |
| 477 if tt then tt:Hide() end | |
| 478 end | |
| 402 end | 479 end |
| 403 | 480 |
| 404 | 481 |
| 405 ------ Main GUI Window | 482 ------ Main GUI Window |
| 406 local _d -- display when it's open, eoiST when it's not | 483 local _d -- display when it's open, eoiST when it's not |
| 458 next_insertion_position = next_insertion_position + saved_offset | 535 next_insertion_position = next_insertion_position + saved_offset |
| 459 removed, saved_offset = nil, nil | 536 removed, saved_offset = nil, nil |
| 460 return count | 537 return count |
| 461 end | 538 end |
| 462 end | 539 end |
| 463 | |
| 464 | 540 |
| 465 -- Done at startup, and whenever we've changed the population of tabs. | 541 -- Done at startup, and whenever we've changed the population of tabs. |
| 466 function addon:gui_init (loot_pointer) | 542 function addon:gui_init (loot_pointer) |
| 467 g_loot = assert(loot_pointer, "something went wrong at startup") | 543 g_loot = assert(loot_pointer, "something went wrong at startup") |
| 468 g_generated = nil | 544 g_generated = nil |
| 734 ]] | 810 ]] |
| 735 local function eoi_st_OnEnter (rowFrame, cellFrame, data, cols, row, realrow, column, table, button, ...) | 811 local function eoi_st_OnEnter (rowFrame, cellFrame, data, cols, row, realrow, column, table, button, ...) |
| 736 if (row == nil) or (realrow == nil) then return end -- mouseover column header | 812 if (row == nil) or (realrow == nil) then return end -- mouseover column header |
| 737 local e = data[realrow] | 813 local e = data[realrow] |
| 738 local kind = e.kind | 814 local kind = e.kind |
| 739 | 815 local tt = GameTooltip -- can this be hoisted? does GT ever get securely replaced? |
| 816 | |
| 817 if _do_debugging_tooltip and column == 1 and kind~='history' then -- FIXME history | |
| 818 _build_debugging_tooltip (cellFrame, realrow) | |
| 819 end | |
| 740 if (kind == 'loot' and column == 1) or (kind == 'history' and column == 2) then | 820 if (kind == 'loot' and column == 1) or (kind == 'history' and column == 2) then |
| 741 GameTooltip:SetOwner (cellFrame, "ANCHOR_RIGHT", -20, 0) | 821 tt:SetOwner (cellFrame, "ANCHOR_RIGHT", -20, 0) |
| 742 if e.cache_miss then | 822 if e.cache_miss then |
| 743 GameTooltip:ClearLines() | 823 tt:ClearLines() |
| 744 GameTooltip:AddLine("Missing Cache Data") | 824 tt:AddLine("Missing Cache Data") |
| 745 GameTooltip:AddLine([[Wait a few seconds, then type]], 0.8, 0.8, 0.8, 1) | 825 tt:AddLine([[Wait a few seconds, then type]], 0.8, 0.8, 0.8, 1) |
| 746 GameTooltip:AddLine([[/ouroloot fixcache]], 0, 1, 64/255, nil) | 826 tt:AddLine([[/ouroloot fixcache]], 0, 1, 64/255, nil) |
| 747 GameTooltip:AddLine([[and redisplay this window.]], 0.8, 0.8, 0.8, 1) | 827 tt:AddLine([[and redisplay this window.]], 0.8, 0.8, 0.8, 1) |
| 748 GameTooltip:Show() | 828 tt:Show() |
| 749 elseif e.itemlink then | 829 elseif e.itemlink then |
| 750 GameTooltip:SetHyperlink (e.itemlink) | 830 tt:SetHyperlink (e.itemlink) |
| 751 end | 831 end |
| 752 | 832 |
| 753 elseif kind == 'loot' and column == 2 then | 833 elseif kind == 'loot' and column == 2 then |
| 754 GameTooltip:SetOwner (cellFrame, "ANCHOR_BOTTOMRIGHT", -50, 5) | 834 tt:SetOwner (cellFrame, "ANCHOR_BOTTOMRIGHT", -50, 5) |
| 755 GameTooltip:ClearLines() | 835 tt:ClearLines() |
| 756 GameTooltip:AddLine(e.person.." Loot:") | 836 tt:AddLine(e.person.." Loot:") |
| 757 local counter = 0 | 837 local counter = 0 |
| 758 for i,e2 in ipairs(data) do | 838 for i,e2 in ipairs(data) do |
| 759 if e2.person == e.person then -- would be awesome to test for alts | 839 if e2.person == e.person then -- would be awesome to test for alts |
| 760 if counter > 10 then | 840 if counter > 10 then |
| 761 GameTooltip:AddLine("...") | 841 tt:AddLine("...") |
| 762 break | 842 break |
| 763 else | 843 else |
| 764 -- textures screw up too badly, strip them | 844 -- textures screw up too badly, strip them |
| 765 local textured = e2.cols[1].value | 845 local textured = e2.cols[1].value |
| 766 local space = textured:find(" ") | 846 local space = textured:find(" ") |
| 767 GameTooltip:AddLine(textured:sub(space+1)) | 847 tt:AddLine(textured:sub(space+1)) |
| 768 counter = counter + 1 | 848 counter = counter + 1 |
| 769 end | 849 end |
| 770 end | 850 end |
| 771 end | 851 end |
| 772 GameTooltip:Show() | 852 tt:Show() |
| 773 | 853 |
| 774 elseif kind == 'loot' and column == 3 then | 854 elseif kind == 'loot' and column == 3 then |
| 775 setstatus(e.cols[column].value) | 855 setstatus(e.cols[column].value) |
| 776 | 856 |
| 777 end | 857 end |
| 778 | 858 |
| 779 return false -- continue with default highlighting behavior | 859 return false -- continue with default highlighting behavior |
| 780 end | 860 end |
| 781 local function eoi_st_OnLeave (rowFrame, cellFrame, data, cols, row, realrow, column, table, button, ...) | 861 local function eoi_st_OnLeave (rowFrame, cellFrame, data, cols, row, realrow, column, table, button, ...) |
| 782 GameTooltip:Hide() | 862 GameTooltip:Hide() |
| 863 _hide_debugging_tooltip() | |
| 783 if row and realrow and data[realrow].kind ~= 'loot' then | 864 if row and realrow and data[realrow].kind ~= 'loot' then |
| 784 table:SetHighLightColor (rowFrame, eoi_st_otherrow_bgcolortable[data[realrow].reason or data[realrow].kind]) | 865 table:SetHighLightColor (rowFrame, eoi_st_otherrow_bgcolortable[data[realrow].reason or data[realrow].kind]) |
| 785 return true -- do not do anything further | 866 return true -- do not do anything further |
| 786 else | 867 else |
| 787 --setstatus("") | 868 --setstatus("") |
| 1603 w = GUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(1) grp:AddChild(w) | 1684 w = GUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(1) grp:AddChild(w) |
| 1604 | 1685 |
| 1605 local simple = GUI:Create("SimpleGroup") | 1686 local simple = GUI:Create("SimpleGroup") |
| 1606 simple:SetLayout("List") | 1687 simple:SetLayout("List") |
| 1607 simple:SetRelativeWidth(0.3) | 1688 simple:SetRelativeWidth(0.3) |
| 1689 w = GUI:Create("CheckBoxSmallLabel") | |
| 1690 w:SetFullWidth(true) | |
| 1691 w:SetType("checkbox") | |
| 1692 w:SetLabel("loot debugging tooltip") | |
| 1693 w:SetValue(_do_debugging_tooltip) | |
| 1694 w:SetCallback("OnValueChanged", function(_w,event,value) | |
| 1695 _do_debugging_tooltip = value | |
| 1696 end) | |
| 1697 simple:AddChild(w) | |
| 1608 w = GUI:Create("CheckBoxSmallLabel") | 1698 w = GUI:Create("CheckBoxSmallLabel") |
| 1609 w:SetFullWidth(true) | 1699 w:SetFullWidth(true) |
| 1610 w:SetType("checkbox") | 1700 w:SetType("checkbox") |
| 1611 w:SetLabel("debug toggle") | 1701 w:SetLabel("debug toggle") |
| 1612 w:SetValue(addon.DEBUG_PRINT) | 1702 w:SetValue(addon.DEBUG_PRINT) |
