Quantcast

Fix bug that reset enable state when zoning.

Christopher Rosell [03-22-12 - 12:57]
Fix bug that reset enable state when zoning.
Filename
kungaloosh.lua
diff --git a/kungaloosh.lua b/kungaloosh.lua
index 983a08e..0a255ea 100755
--- a/kungaloosh.lua
+++ b/kungaloosh.lua
@@ -12,13 +12,17 @@ function addon:OnEnable()
 			minthreat = 5000,
 			dynamic_minthreat = true,
 			enabled_in = { dungeon = true, raid = false },
-			raid_icons = { 8, 7, 1, 2 },
 			icon_recycle = true,
 			icon_recycle_time = 50
 		}
 	}
 	self.db = LibStub("AceDB-3.0"):New("KungalooshDB", defaults, true)

+	-- Work around weird AceDB behaviour..
+	if not self.db.profile.raid_icons then
+		self.db.profile.raid_icons = { 8, 7, 1, 2 }
+	end
+
 	self:CreateConfig()

 	self:UnregisterEvent"ADDON_LOADED"
@@ -162,7 +166,7 @@ function addon:GetMinThreat()
 end

 function addon:EnableIfTank()
-	if self.enabled then return end
+	if self.force_enabled then return end

 	local istank = (UnitGroupRolesAssigned("player") == "TANK") or (GetPartyAssignment("MAINTANK", "player") == 1)

@@ -192,6 +196,7 @@ function addon:Enable(msg)
 	self:RegisterEvent"UNIT_THREAT_LIST_UPDATE"
 	self:RegisterEvent"RAID_TARGET_UPDATE"
 	self:RegisterEvent"COMBAT_LOG_EVENT_UNFILTERED"
+	self.enabled = true

 	self:ResetState()

@@ -205,6 +210,7 @@ function addon:Disable(msg)
 	self:UnregisterEvent"UNIT_THREAT_LIST_UPDATE"
 	self:UnregisterEvent"RAID_TARGET_UPDATE"
 	self:UnregisterEvent"COMBAT_LOG_EVENT_UNFILTERED"
+	self.enabled = false

 	if msg then self:Print(msg) end
 end
@@ -212,10 +218,10 @@ end
 function addon:Toggle()
 	if not self.enabled then
 		self:Enable(L["is now enabled"])
-		self.enabled = true
+		self.force_enabled = true
 	else
 		self:Disable(L["is now disabled"])
-		self.enabled = false
+		self.force_enabled = false
 	end
 end