diff gui.lua @ 76:124da015c4a2

- Some more debugging aids (logging error/assert, auto-enable of testing panel, reminder of GOP history mode) - Move (finally!) hypertext handling code out to each call site. - Fix some bugs in previous alpha code. - Initial-but-mostly-tested code to handle items that have a "unique" field which are in fact always the same (for example, elementium gem cluster). Still need to test the case in which a remote tracker sees them first. - The rest of the variable-cutoff history cleanup.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Fri, 08 Jun 2012 08:05:37 +0000
parents 676fb79a4ae2
children a07c9dd79f3a
line wrap: on
line diff
--- a/gui.lua	Fri Jun 01 02:17:57 2012 +0000
+++ b/gui.lua	Fri Jun 08 08:05:37 2012 +0000
@@ -58,6 +58,9 @@
 local window_title		= "Ouro Loot"
 local dirty_tabs		= nil
 
+local error				= addon.error
+local assert			= addon.assert
+
 local pairs, ipairs, tinsert, tremove, tostring, tonumber =
 	pairs, ipairs, table.insert, table.remove, tostring, tonumber
 
@@ -164,13 +167,14 @@
 		g_loot[text_type] = g_loot[text_type] or ""
 
 		if g_loot.printed[text_type] >= #g_loot then return false end
-		assert(addon.loot_clean == #g_loot, tostring(addon.loot_clean) .. " ~= " .. #g_loot)
+		assert (addon.loot_clean == #g_loot,
+			tostring(addon.loot_clean) .. " ~= " .. #g_loot)
 		-- if glc is nil, #==0 test already returned
 
 		local ok,ret = pcall (f, text_type, g_loot, g_loot.printed[text_type], g_generated, accumulator)
 		if not ok then
 			error(("ERROR:  text generator '%s' failed:  %s"):format(text_type, ret))
-			return false
+			return false  -- why is this here again?
 		end
 		if ret then
 			g_loot.printed[text_type] = #g_loot
@@ -1888,30 +1892,35 @@
 		container:SetScroll(1000)  -- scrollframe's max value
 	end
 
-	-- Initial lower panel function
-	local function adv_lower (container, specials)
-		local spacer = GUI:Create("Spacer")
-		spacer:SetFullWidth(true)
-		spacer:SetHeight(5)
-		container:AddChild(spacer)
-		local speedbump = GUI:Create("InteractiveLabel")
-		speedbump:SetFullWidth(true)
-		speedbump:SetFontObject(GameFontHighlightLarge)
-		speedbump:SetImage("Interface\\DialogFrame\\DialogAlertIcon")
-		speedbump:SetImageSize(50,50)
-		speedbump:SetText("The debugging/testing settings on the rest of this panel can"
-			.." seriously bork up the addon if you make a mistake.  If you're okay"
-			.." with the possibility of losing data, click this warning to load the panel.")
-		speedbump:SetCallback("OnClick", function (_sb)
-			adv_lower = adv_real
-			return addon:redisplay()
-			--return tabs_OnGroupSelected_func(container.parent,"OnGroupSelected","opt")
-		end)
-		container:AddChild(speedbump)
-		spacer = GUI:Create("Spacer")
-		spacer:SetFullWidth(true)
-		spacer:SetHeight(5)
-		container:AddChild(spacer)
+	-- Initial lower panel function (unless debug mode is on during load, which
+	-- means it was almost certainly hardcoded that way, which means it's
+	-- probably me testing).
+	local adv_lower
+	if addon.DEBUG_PRINT then
+		adv_lower = adv_real
+	else
+		function adv_lower (container, specials)
+			local spacer = GUI:Create("Spacer")
+			spacer:SetFullWidth(true)
+			spacer:SetHeight(5)
+			container:AddChild(spacer)
+			local speedbump = GUI:Create("InteractiveLabel")
+			speedbump:SetFullWidth(true)
+			speedbump:SetFontObject(GameFontHighlightLarge)
+			speedbump:SetImage("Interface\\DialogFrame\\DialogAlertIcon")
+			speedbump:SetImageSize(50,50)
+			speedbump:SetText("The debugging/testing settings on the rest of this panel can seriously bork up the addon if you make a mistake.  If you're okay with the possibility of losing data, click this warning to load the panel.")
+			speedbump:SetCallback("OnClick", function (_sb)
+				adv_lower = adv_real
+				return addon:redisplay()
+				--return tabs_OnGroupSelected_func(container.parent,"OnGroupSelected","opt")
+			end)
+			container:AddChild(speedbump)
+			spacer = GUI:Create("Spacer")
+			spacer:SetFullWidth(true)
+			spacer:SetHeight(5)
+			container:AddChild(spacer)
+		end
 	end
 
 	tabs_OnGroupSelected["opt"] = function(container,specials)
@@ -2233,6 +2242,15 @@
 	h:SetFullWidth(true)
 	h:SetText(_tabtexts[group].title)
 	spec:AddChild(h)
+	do
+		addon.sender_list.sort()
+		local fmt = "Received broadcast data from %d |4player:players;."
+		if addon.history_suppress then
+			-- this is the druid class color reworked into hex
+			fmt = fmt .. "  |cffff7d0aHistory recording suppressed.|r"
+		end
+		tabs.titletext:SetFormattedText (fmt, addon.sender_list.activeI)
+	end
 	return tabs_OnGroupSelected[group](tabs,spec,group)
 	--[====[
 	Unfortunately, :GetHeight() called on anything useful out of a TabGroup
@@ -2478,11 +2496,6 @@
 	tabs:SetCallback("OnRelease", function(_tabs)
 		tabs.titletext:SetFontObject(titletext_orig_fo)
 	end)
-	do
-		self.sender_list.sort()
-		tabs.titletext:SetFormattedText("Received broadcast data from %d |4player:players;.",
-			self.sender_list.activeI)
-	end
 	tabs:SetRelativeWidth(0.99-rhs_width)
 	tabs:SetFullHeight(true)
 	tabs:SetTabs(tabgroup_tabs)
@@ -2492,7 +2505,8 @@
 	end)
 	tabs:SetCallback("OnTabLeave", statusy_OnLeave)
 	tabs:SetUserData("special buttons group",tab_specials)
-	tabs:SelectTab(opt_tabselect or "eoi")
+	tabs:SelectTab((opt_tabselect and #opt_tabselect>0)
+		and opt_tabselect or "eoi")
 
 	display:AddChildren (tabs, control)
 	display:ApplyStatus()