changeset 101:060f5d0f7a35 v1.0beta10

Manage correctly the Campfire button
author contrebasse
date Fri, 20 May 2011 22:14:31 +0200
parents 0fd1fd1ba2d9
children e74ed53097d7
files CampFireButton.lua ReagentMaker.lua
diffstat 2 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/CampFireButton.lua	Fri May 20 19:29:13 2011 +0200
+++ b/CampFireButton.lua	Fri May 20 22:14:31 2011 +0200
@@ -34,14 +34,14 @@
 
 	-- Save info
 	cookingName = GetSpellInfo(COOKING_ID)
-	
+
 	-- Show if needed
 	A.ManageCampFireBtn()
 end
 
 -- Hide button
 function A.HideCampFireBtn()
-	btn:Hide()
+	if btn then btn:Hide() end
 end
 
 -- Show button if applicable
--- a/ReagentMaker.lua	Fri May 20 19:29:13 2011 +0200
+++ b/ReagentMaker.lua	Fri May 20 22:14:31 2011 +0200
@@ -56,10 +56,15 @@
 	end
 end
 A.EventsFrame:SetScript("OnEvent", function(self, event)
-	A.ManageCampFireBtn()
 	if event == "TRADE_SKILL_UPDATE" then
 		t_throttle = SCAN_DELAY
 		self:SetScript("OnUpdate", throttleScan)
+		A.ManageCampFireBtn()
+
+	elseif event == "PLAYER_REGEN_DISABLED" then
+		A.HideCampFireBtn()
+	elseif event == "PLAYER_REGEN_ENABLED" then
+		A.ManageCampFireBtn()
 
 	elseif event == "TRADE_SKILL_SHOW" then
 		A:Initialize()
@@ -104,10 +109,10 @@
 	A.tooltipRecipe = CreateFrame("GameTooltip", "ReagentMaker_tooltipRecipe",UIParent, "GameTooltipTemplate")
 	A.tooltipRecipe:SetFrameStrata("TOOLTIP")
 	A.tooltipRecipe:Hide()
-	
+
 	-- Button for enchanting directy on a scroll
 	A.LoadEnchantOnScroll()
-	
+
 	-- Button to cast a campfire
 	A.InitialiseCampFireBtn()
 end -- function
@@ -194,7 +199,7 @@
 	-- use the mean between min and max, but make at least one...
 	local minMade, maxMade = GetTradeSkillNumMade(reagentIndex)
 	numToMake = math.max(math.floor(2*numToMake/(maxMade+minMade)),1)
-	
+
 	-- Choose number or craft directly
 	if chooseNumber then
 		-- the dialog window is linked to the reagent button