Mercurial > wow > ouroloot
comparison gui.lua @ 78:f8118aa5fbb8
Manually inserting loot entries now (1) uses autocomplete dropdowns for the recipient name (raid members if in a raid, online guild members otherwise), and (2) adds a rebroadcasting hyperlink to the text response. Clicking the link rebroadcasts just like the context menu.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Tue, 12 Jun 2012 03:46:00 +0000 |
parents | a07c9dd79f3a |
children | 0235a1695b83 |
comparison
equal
deleted
inserted
replaced
77:a07c9dd79f3a | 78:f8118aa5fbb8 |
---|---|
64 local pairs, ipairs, tinsert, tremove, tostring, tonumber = | 64 local pairs, ipairs, tinsert, tremove, tostring, tonumber = |
65 pairs, ipairs, table.insert, table.remove, tostring, tonumber | 65 pairs, ipairs, table.insert, table.remove, tostring, tonumber |
66 | 66 |
67 local pprint, tabledump = addon.pprint, flib.tabledump | 67 local pprint, tabledump = addon.pprint, flib.tabledump |
68 local GetItemInfo, ITEM_QUALITY_COLORS = GetItemInfo, ITEM_QUALITY_COLORS | 68 local GetItemInfo, ITEM_QUALITY_COLORS = GetItemInfo, ITEM_QUALITY_COLORS |
69 local GetNumRaidMembers = GetNumRaidMembers | |
69 | 70 |
70 -- En masse forward decls of symbols defined inside local blocks | 71 -- En masse forward decls of symbols defined inside local blocks |
71 local _generate_text, _populate_text_specials | 72 local _generate_text, _populate_text_specials |
72 local _tabtexts, _taborder -- filled out in gui block scope | 73 local eoi_dropdownfuncs, _tabtexts, _taborder -- filled out in gui block scope |
73 local _do_debugging_tooltip, _hide_debugging_tooltip, _build_debugging_tooltip | 74 local _do_debugging_tooltip, _hide_debugging_tooltip, _build_debugging_tooltip |
75 local _new_rebroadcast_hyperlink | |
74 | 76 |
75 --[[ | 77 --[[ |
76 This is a table of callback functions, each responsible for drawing a tab | 78 This is a table of callback functions, each responsible for drawing a tab |
77 into the container passed in the first argument. Special-purpose buttons | 79 into the container passed in the first argument. Special-purpose buttons |
78 can optionally be created (mkbutton) and added to the container in the second | 80 can optionally be created (mkbutton) and added to the container in the second |
598 end | 600 end |
599 debug_tt:Show() | 601 debug_tt:Show() |
600 end | 602 end |
601 end | 603 end |
602 | 604 |
605 do | |
606 local rebroadcast_map -- XXX weaken this somehow? | |
607 | |
608 local function onclick (self, ident) | |
609 local data = assert(rebroadcast_map[ident]) | |
610 eoi_dropdownfuncs["Rebroadcast this loot entry"](data.rowindex) | |
611 -- XXX delete the entry maybe? | |
612 end | |
613 | |
614 function _new_rebroadcast_hyperlink (data) | |
615 rebroadcast_map = rebroadcast_map or flib.new() | |
616 local clicky, ident = addon.format_hypertext( | |
617 -- same color sequence as what DBM uses to announce pizza timers, | |
618 -- which looks reasonably pleasing | |
619 [[Broadcast this entry]], "|cff3588ff", onclick) | |
620 rebroadcast_map[ident] = data | |
621 return clicky | |
622 end | |
623 end | |
624 | |
603 | 625 |
604 ------ Main GUI Window | 626 ------ Main GUI Window |
605 local _d -- display when it's open, eoiST when it's not | 627 local _d -- display when it's open, eoiST when it's not |
606 local function setstatus(txt) _d:SetStatusText(txt) end | 628 local function setstatus(txt) _d:SetStatusText(txt) end |
607 local function statusy_OnLeave() setstatus("") end | 629 local function statusy_OnLeave() setstatus("") end |
744 local dropdownmenuframe = CreateFrame("Frame", "OuroLootDropDownMenu", nil, "UIDropDownMenuTemplate") | 766 local dropdownmenuframe = CreateFrame("Frame", "OuroLootDropDownMenu", nil, "UIDropDownMenuTemplate") |
745 | 767 |
746 | 768 |
747 -- Tab 1: Events Of Interest | 769 -- Tab 1: Events Of Interest |
748 -- This actually takes up quite a bit of the file. | 770 -- This actually takes up quite a bit of the file. |
749 local eoi_dropdownfuncs | |
750 eoi_dropdownfuncs = dropdownfuncs{ | 771 eoi_dropdownfuncs = dropdownfuncs{ |
751 df_INSERT = function(rowi,text) | 772 df_INSERT = function(rowi,text) |
752 local which = (text == 'loot') and "OUROL_EOI_INSERT_LOOT" or "OUROL_EOI_INSERT" | 773 local which = (text == 'loot') and "OUROL_EOI_INSERT_LOOT" or "OUROL_EOI_INSERT" |
753 local dialog = StaticPopup_Show(which,text) | 774 local dialog = StaticPopup_Show(which,text) |
754 dialog.editBox:SetScript("OnTextChanged",StaticPopup_EditBoxOnTextChanged) | 775 dialog.editBox:SetScript("OnTextChanged",StaticPopup_EditBoxOnTextChanged) |
2718 local entry = tremove(g_loot,boss_index) | 2739 local entry = tremove(g_loot,boss_index) |
2719 tinsert(g_loot,data.rowindex,entry) | 2740 tinsert(g_loot,data.rowindex,entry) |
2720 addon:_mark_boss_kill(data.rowindex) | 2741 addon:_mark_boss_kill(data.rowindex) |
2721 data.display:GetUserData("eoiST"):OuroLoot_Refresh(data.rowindex) | 2742 data.display:GetUserData("eoiST"):OuroLoot_Refresh(data.rowindex) |
2722 dialog.data = nil -- free up memory | 2743 dialog.data = nil -- free up memory |
2723 addon:Print("Inserted %s %s (entry %d).", data.kind, data.name, data.rowindex) | 2744 addon:Print("Inserted %s %s at entry %d.", data.kind, data.name, data.rowindex) |
2724 return | 2745 return |
2725 end | 2746 end |
2726 | 2747 |
2727 -- third click | 2748 -- third click |
2728 if data.name and data.instance then | 2749 if data.name and data.instance then |
2762 end | 2783 end |
2763 end | 2784 end |
2764 | 2785 |
2765 local function eoi_st_insert_OnAccept_loot (dialog, data) | 2786 local function eoi_st_insert_OnAccept_loot (dialog, data) |
2766 if data.all_done then | 2787 if data.all_done then |
2767 --local real_rebroadcast, real_enabled = addon.rebroadcast, addon.enabled | |
2768 --g_rebroadcast, g_enabled = false, true | |
2769 data.display:Hide() | 2788 data.display:Hide() |
2770 local loot_index = assert(addon:CHAT_MSG_LOOT ("manual", data.recipient, data.name, data.notes)) | 2789 local loot_index = assert(addon:CHAT_MSG_LOOT ("manual", data.recipient, data.name, data.notes)) |
2771 --g_rebroadcast, g_enabled = real_g_rebroadcast, real_g_enabled | |
2772 local entry = tremove(g_loot,loot_index) | 2790 local entry = tremove(g_loot,loot_index) |
2773 tinsert(g_loot,data.rowindex,entry) | 2791 tinsert(g_loot,data.rowindex,entry) |
2774 --data.display:GetUserData("eoiST"):OuroLoot_Refresh(data.rowindex) | |
2775 addon:_fill_out_eoi_data(data.rowindex) | 2792 addon:_fill_out_eoi_data(data.rowindex) |
2776 addon:BuildMainDisplay() | 2793 addon:BuildMainDisplay() |
2794 local clicky = _new_rebroadcast_hyperlink (data) | |
2777 dialog.data = nil | 2795 dialog.data = nil |
2778 addon:Print("Inserted %s %s (entry %d).", data.kind, data.name, data.rowindex) | 2796 addon:Print ("Inserted %s %s at entry %d. %s", |
2797 data.kind, data.name, data.rowindex, tostring(clicky)) | |
2779 return | 2798 return |
2780 end | 2799 end |
2781 | 2800 |
2782 local text = dialog.editBox:GetText():trim() | 2801 local text = dialog.editBox:GetText():trim() |
2783 | 2802 |
2800 | 2819 |
2801 -- first click | 2820 -- first click |
2802 if text then | 2821 if text then |
2803 data.name = text | 2822 data.name = text |
2804 dialog:Hide() -- technically a "different" one about to be shown | 2823 dialog:Hide() -- technically a "different" one about to be shown |
2824 StaticPopupDialogs["OUROL_EOI_INSERT"].autoCompleteParams = | |
2825 AUTOCOMPLETE_LIST_TEMPLATES[GetNumRaidMembers() > 0 and "IN_GROUP" or "IN_GUILD"] | |
2805 local getrecipient = StaticPopup_Show("OUROL_EOI_INSERT","recipient") | 2826 local getrecipient = StaticPopup_Show("OUROL_EOI_INSERT","recipient") |
2827 StaticPopupDialogs["OUROL_EOI_INSERT"].autoCompleteParams = nil | |
2806 getrecipient.data = data | 2828 getrecipient.data = data |
2807 getrecipient.editBox:SetText("") | 2829 getrecipient.editBox:SetText("") |
2808 return true | 2830 return true |
2809 end | 2831 end |
2810 end | 2832 end |
2826 button2 = CANCEL, | 2848 button2 = CANCEL, |
2827 hasEditBox = true, | 2849 hasEditBox = true, |
2828 editBoxWidth = 350, | 2850 editBoxWidth = 350, |
2829 maxLetters = 50, | 2851 maxLetters = 50, |
2830 noCancelOnReuse = true, | 2852 noCancelOnReuse = true, |
2831 --[[ XXX still needed? | |
2832 OnShow = function(dialog) | |
2833 dialog.wideEditBox:SetText("") | |
2834 dialog.wideEditBox:SetFocus() | |
2835 end,]] | |
2836 } | 2853 } |
2837 t.EditBoxOnEnterPressed = function(editbox) | 2854 t.EditBoxOnEnterPressed = function(editbox) |
2838 if editbox:GetText() == "" then return end | 2855 if editbox:GetText() == "" then return end |
2839 local dialog = editbox:GetParent() | 2856 local dialog = editbox:GetParent() |
2840 if not eoi_st_insert_OnAccept (dialog, dialog.data) then | 2857 if not eoi_st_insert_OnAccept (dialog, dialog.data) then |