diff gui.lua @ 125:a9cf9b2fbf9b

- Fix interactions with AddonLoader. - Plugins get a :Print with a clickable prefix, with overrideable behaviors. - 'Deactivate' event gets a [wrapper around] current raiders table. - Fix sorting bug in player history data. - Smarter status line text when viewing unfiltered history. - Do not disable history regeneration button when current history is empty. - :BuildMainDisplay can handle the CLI args now.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Sun, 19 Aug 2012 21:08:59 -0400
parents fb4bda3ad05c
children 9232cacc9136
line wrap: on
line diff
--- a/gui.lua	Fri Aug 17 02:48:13 2012 -0400
+++ b/gui.lua	Sun Aug 19 21:08:59 2012 -0400
@@ -458,6 +458,10 @@
 	function addon:_fill_out_hist_data (opt_starting_index)
 		local new, del = flib.new, flib.del
 
+		if not self.history.st then
+			self.history.st = {}
+			self.hist_clean = nil
+		end
 		-- Clearing history finishes this function with #hist==0 and hist_clean==0.
 		-- The next call typically detects this (#<1) and handles it.  If loot is
 		-- recorded before then, it results in hist_clean==0 and #hist==1, which
@@ -466,9 +470,6 @@
 			self.hist_clean = nil
 			opt_starting_index = nil
 		end
-		if not self.history.st then
-			self.history.st = {}
-		end
 
 		-- for now
 		if self.hist_clean == #self.history then return end
@@ -1865,12 +1866,12 @@
 		container:AddChild(st_widget)
 		-- If we're focused on one player, but have deleted all entries for
 		-- that player, don't sit there stuck on a blank grid.
-		if history_filter_who and #histST.filtered < 1 then
+		if history_filter_who and #histST.filtered > 0 then
+			setstatus(hist_name_status)
+		else
 			history_filter_who = nil
 			histST:SetFilter(history_filter_by_recent)
 			setstatus(hist_normal_status)
-		else
-			setstatus(hist_name_status)
 		end
 
 		local b
@@ -1907,7 +1908,6 @@
 		b = mkbutton("Regenerate",
 			[[Erases all history entries from the displayed realm, and regenerates it from current loot information.]])
 		b:SetFullWidth(true)
-		b:SetDisabled (#addon.history == 0)
 		b:SetCallback("OnClick", function(_b)
 			local dialog = StaticPopup_Show("OUROL_HIST_REGEN", addon.history.realm)
 			dialog.data = addon
@@ -2070,9 +2070,10 @@
 gui.mkbutton = mkbutton
 
 --[[
-Creates the main window.
+Creates the main window.  Can jump directly to a tab (and feed it CLI
+routine arguments), if given the appropriate tab code.
 ]]
-function addon:BuildMainDisplay (opt_tabselect)
+function addon:BuildMainDisplay (opt_tabselect, opt_tabselect_CLI_arg)
 	if self.display then
 		-- try to get everything to update, rebuild, refresh... ugh, no
 		self.display:Hide()
@@ -2284,26 +2285,30 @@
 	end)
 	tabs:SetCallback("OnTabLeave", statusy_OnLeave)
 	tabs:SetUserData("special buttons group",tab_specials)
-	tabs:SelectTab((opt_tabselect and #opt_tabselect>0)
-		and opt_tabselect or "eoi")
+
+	local whichtab, tabargs = "eoi"
+	if opt_tabselect and #opt_tabselect > 0 then
+		whichtab, tabargs = opt_tabselect, opt_tabselect_CLI_arg
+	end
+	tabs:SelectTab(whichtab)
 
 	display:AddChildren (tabs, control)
 	display:ApplyStatus()
+	display:Show() -- without this, only appears every *other* function call
 
-	display:Show() -- without this, only appears every *other* function call
+	if tabargs and tabs_CLI_special[whichtab] then
+		tabs_CLI_special[whichtab](tabargs)
+	end
 	return display
 end
 
--- Searches tab titles from left to right.
+-- Searches tab title texts from left to right.
 function addon:OpenMainDisplayToTab (text, opt_arg)
 	text = '^'..text:lower()
 	for _,tab in ipairs(gui.taborder) do
 		local v = gui.tabtexts[tab]
 		if v and v.title:lower():find(text) then
-			self:BuildMainDisplay(tab)
-			if opt_arg and tabs_CLI_special[tab] then
-				tabs_CLI_special[tab](opt_arg)
-			end
+			self:BuildMainDisplay (tab, opt_arg)
 			return true
 		end
 	end
@@ -2384,7 +2389,7 @@
 StaticPopupDialogs["OUROL_HIST_REGEN"] = flib.StaticPopup{
 	-- Concatenate this once at load time.  There is no ITEM_QUALITY_LEGENDARY constant.
 	text = "Erase all history entries from " .. ITEM_QUALITY_COLORS[5].hex
-		.. "%s|r, and generate it anew from current loot?",
+		.. "%s|r, and generate it anew from current loot?|n|nNote this obeys the current setting of the 'Suppress history for cross-realm players' option.",
 	button1 = YES,
 	button2 = NO,
 	OnAccept = function (dialog, addon, data2)