comparison gui.lua @ 79:0235a1695b83

Tweak the manual entry hyperlink handling to use unique tags instead.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Tue, 12 Jun 2012 17:33:38 +0000
parents f8118aa5fbb8
children 0f6355bcfe68
comparison
equal deleted inserted replaced
78:f8118aa5fbb8 79:0235a1695b83
52 ------ Globals 52 ------ Globals
53 local GUI = LibStub("AceGUI-3.0") 53 local GUI = LibStub("AceGUI-3.0")
54 local flib = LibStub("LibFarmbuyer") 54 local flib = LibStub("LibFarmbuyer")
55 55
56 local g_loot = nil 56 local g_loot = nil
57 local g_uniques = nil
57 local g_generated = nil 58 local g_generated = nil
58 local window_title = "Ouro Loot" 59 local window_title = "Ouro Loot"
59 local dirty_tabs = nil 60 local dirty_tabs = nil
60 61
61 local error = addon.error 62 local error = addon.error
604 605
605 do 606 do
606 local rebroadcast_map -- XXX weaken this somehow? 607 local rebroadcast_map -- XXX weaken this somehow?
607 608
608 local function onclick (self, ident) 609 local function onclick (self, ident)
609 local data = assert(rebroadcast_map[ident]) 610 -- Since an arbitrary number of insert/delete ops can happen between
610 eoi_dropdownfuncs["Rebroadcast this loot entry"](data.rowindex) 611 -- now and (potentially) clicking on the hyperlink, we can't depend on
611 -- XXX delete the entry maybe? 612 -- the row index. Force the uniques cache to re-search (research?) it.
612 end 613 local u = assert(rebroadcast_map[ident])
613 614 local cache = g_uniques:SEARCH(u)
614 function _new_rebroadcast_hyperlink (data) 615 -- A missing history entry isn't necessarily an error here, but we
616 -- need a loot entry to go further.
617 if cache.loot then
618 eoi_dropdownfuncs["Rebroadcast this loot entry"](cache.loot)
619 else
620 addon:Print("...guh? Entry was recorded with tag <%s> but cannot now be found!", u)
621 end
622 -- delete the entry maybe?
623 end
624
625 function _new_rebroadcast_hyperlink (u)
615 rebroadcast_map = rebroadcast_map or flib.new() 626 rebroadcast_map = rebroadcast_map or flib.new()
616 local clicky, ident = addon.format_hypertext( 627 local clicky, ident = addon.format_hypertext(
617 -- same color sequence as what DBM uses to announce pizza timers, 628 -- same color sequence as what DBM uses to announce pizza timers,
618 -- which looks reasonably pleasing 629 -- which looks reasonably pleasing
619 [[Broadcast this entry]], "|cff3588ff", onclick) 630 [[Broadcast this entry]], "|cff3588ff", onclick)
620 rebroadcast_map[ident] = data 631 rebroadcast_map[ident] = u
621 return clicky 632 return clicky
622 end 633 end
623 end 634 end
624 635
625 636
681 return count 692 return count
682 end 693 end
683 end 694 end
684 695
685 -- Done at startup, and whenever we've changed the population of tabs. 696 -- Done at startup, and whenever we've changed the population of tabs.
686 function addon:gui_init (loot_pointer) 697 function addon:gui_init (loot_pointer, uniques_pointer)
687 g_loot = assert(loot_pointer, "something went wrong at startup") 698 g_loot = assert(loot_pointer, "something went wrong at startup")
699 g_uniques = assert(uniques_pointer, "something went wrong at startup")
688 g_generated = nil 700 g_generated = nil
689 tabgroup_tabs = {} 701 tabgroup_tabs = {}
690 window_title = "Ouro Loot " .. self.revision 702 window_title = "Ouro Loot " .. self.revision
691 -- TabGroup stretches out the tabs to fill the row but only if >75% of the 703 -- TabGroup stretches out the tabs to fill the row but only if >75% of the
692 -- row is already full. It turns out that not doing this looks like ass. 704 -- row is already full. It turns out that not doing this looks like ass.
2334 -- This probably causes taint... hm. 2346 -- This probably causes taint... hm.
2335 local prev_fade_time = UIDROPDOWNMENU_SHOW_TIME 2347 local prev_fade_time = UIDROPDOWNMENU_SHOW_TIME
2336 UIDROPDOWNMENU_SHOW_TIME = 4 2348 UIDROPDOWNMENU_SHOW_TIME = 4
2337 2349
2338 if dirty_tabs then 2350 if dirty_tabs then
2339 self:gui_init(g_loot) -- pointer known to be good by now 2351 self:gui_init (g_loot, g_uniques) -- pointers known to be good by now
2340 self:zero_printed_fenceposts() 2352 self:zero_printed_fenceposts()
2341 end 2353 end
2342 2354
2343 local display = GUI:Create("Frame") 2355 local display = GUI:Create("Frame")
2344 if _d then 2356 if _d then
2345 display:SetUserData("eoiST",_d) -- warning! warning! kludge detected! 2357 display:SetUserData("eoiST",_d) -- warning! warning! kludge detected!
2346 end 2358 end
2347 _d = display 2359 _d = display
2348 self.display = display 2360 self.display = display
2349 display:SetTitle(window_title) 2361 display:SetTitle(window_title)
2350 display:SetStatusText(self.status_text) 2362 display:SetStatusText(self.status_text)
2789 local loot_index = assert(addon:CHAT_MSG_LOOT ("manual", data.recipient, data.name, data.notes)) 2801 local loot_index = assert(addon:CHAT_MSG_LOOT ("manual", data.recipient, data.name, data.notes))
2790 local entry = tremove(g_loot,loot_index) 2802 local entry = tremove(g_loot,loot_index)
2791 tinsert(g_loot,data.rowindex,entry) 2803 tinsert(g_loot,data.rowindex,entry)
2792 addon:_fill_out_eoi_data(data.rowindex) 2804 addon:_fill_out_eoi_data(data.rowindex)
2793 addon:BuildMainDisplay() 2805 addon:BuildMainDisplay()
2794 local clicky = _new_rebroadcast_hyperlink (data) 2806 local clicky = _new_rebroadcast_hyperlink (entry.unique)
2795 dialog.data = nil 2807 dialog.data = nil
2796 addon:Print ("Inserted %s %s at entry %d. %s", 2808 addon:Print ("Inserted %s %s at entry %d. %s",
2797 data.kind, data.name, data.rowindex, tostring(clicky)) 2809 data.kind, data.name, data.rowindex, tostring(clicky))
2798 return 2810 return
2799 end 2811 end