diff ICU.lua @ 1:6af2d0a0c537

Added support for disabling certain instances (based on Zone, need testing). Cleaned up options.
author Xiiph
date Sat, 05 Feb 2011 20:27:14 +0100
parents 98c6f55e6619
children e883b490ff93
line wrap: on
line diff
--- a/ICU.lua	Sat Feb 05 16:45:02 2011 +0100
+++ b/ICU.lua	Sat Feb 05 20:27:14 2011 +0100
@@ -42,6 +42,7 @@
 		noFoodMessage = L["Well Fed reminder!"],
 		noFlaskMessage = L["Flask reminder!"],
 		lowFlaskDurationMessage = L["Your Flask runs out in less than 10 minutes!"],
+		disabledZones = {},
 	}
 }
 
@@ -61,6 +62,8 @@
 	
 	AceConfigDialog:AddToBlizOptions("ICU", nil, nil, "general")
 	AceConfigDialog:AddToBlizOptions("ICU", "Profiles","ICU","profile")
+	AceConfigDialog:AddToBlizOptions("ICU", "Whispers","ICU","messages")
+	AceConfigDialog:AddToBlizOptions("ICU", "Disabled Zones","ICU","zones")
 end
 
 function icu:refreshConfig()
@@ -183,28 +186,70 @@
 						set = function(o,v,...) self.db.profile.checkAfterFinish = v end,
 						get = function() return self.db.profile.checkAfterFinish end,
 					},
-					noFlaskMessage = {
-						type = 'input',
-						name = L["Flask reminder"],
-						desc = L["Message whispered to raiders missing a cataclysm flask"],
-						set = function(o,v,...) self.db.profile.noFlaskMessage = v end,
-						get = function() return self.db.profile.noFlaskMessage end,
+				},
+			},
+			messages = {
+				name = L["Messages"],
+				type = 'group',
+				args = {
+						noFlaskMessage = {
+							type = 'input',
+							width = 'double',
+							name = L["Flask reminder"],
+							desc = L["Message whispered to raiders missing a cataclysm flask"],
+							set = function(o,v,...) self.db.profile.noFlaskMessage = v end,
+							get = function() return self.db.profile.noFlaskMessage end,
+						},
+						lowFlaskDurationMessage = {
+							type = 'input',
+							width = 'double',
+							name = L["Flask expiration"],
+							desc = L["Message whispered to raiders with less than 10 minutes left on their flask"],
+							set = function(o,v,...) self.db.profile.lowFlaskDurationMessage = v end,
+							get = function() return self.db.profile.lowFlaskDurationMessage end,
+						},
+						noFoodMessage = {
+							type = 'input',
+							width = 'double',
+							name = L["Food reminder"],
+							desc = L["Message whispered to raiders missing the well-fed buff"],
+							set = function(o,v,...) self.db.profile.noFoodMessage = v end,
+							get = function() return self.db.profile.noFoodMessage end,
+						},
+				},
+			},
+			zones = {
+				name = L["Disabled Zones"],
+				type = 'group',
+				set = function(i,v) self.db.profile.disabledZones[i[#i]] = v end,
+				get = function(i) return self.db.profile.disabledZones[i[#i]] end,
+				args = {
+					help = {
+						type = 'description',
+						name = L['Toggle ICU automatic checking |cffcc0000off|r in the selected zones.'],
+						width = 'full',
+						order = 0,
 					},
-					lowFlaskDurationMessage = {
-						type = 'input',
-						name = L["Flask expiration"],
-						desc = L["Message whispered to raiders with less than 10 minutes left on their flask"],
-						set = function(o,v,...) self.db.profile.lowFlaskDurationMessage = v end,
-						get = function() return self.db.profile.lowFlaskDurationMessage end,
+					bwd = {
+						type = 'toggle',
+						name = L["Blackwing Descent"],
+						width = 'double',
 					},
-					noFoodMessage = {
-						type = 'input',
-						name = L["Food reminder"],
-						desc = L["Message whispered to raiders missing the well-fed buff"],
-						set = function(o,v,...) self.db.profile.noFoodMessage = v end,
-						get = function() return self.db.profile.noFoodMessage end,
+					bot = {
+						type = 'toggle',
+						name = L["Bastion of Twilight"],
+						width = 'double',
 					},
-					
+					tfw = {
+						type = 'toggle',
+						name = L["Throne of the Four Winds"],
+						width = 'double',
+					},
+					bh = {
+						type = 'toggle',
+						name = L["Baradin Hold"],
+						width = 'double',
+					},
 				}
 			},
 			profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db),
@@ -213,7 +258,16 @@
 	return options
 end
 
-function icu:inspectRaid(silent)
+function icu:inspectRaid(silent,automatic)
+	-- Check if any zones have been disabled
+	if #self.db.profile.disabledZones > 0 and automatic then
+		local currentZone = GetRealZoneText();
+		
+		for i = 1, #self.db.profile.disabledZones do
+			if currentZone == self.db.profile.disabledZones[i] then return true end
+		end	
+	end
+	
 	-- Not in a raid group
 	local icuAd = "";
 	
@@ -326,7 +380,7 @@
 	end
 	
 	if not self.db.profile.checkAfterFinish then
-		self:inspectRaid();
+		self:inspectRaid(nil,true);
 	else
 		self:ScheduleTimer("READY_CHECK_FINISHED", 30);
 		self:RegisterEvent("READY_CHECK_FINISHED");
@@ -337,13 +391,18 @@
 	--print("Ready check finish!");
 	self:UnregisterEvent("READY_CHECK_FINISHED");
 	self:CancelAllTimers();
-	self:inspectRaid();
+	self:inspectRaid(nil,true);
 end
 
-function icu:filterChat(self, event, msg)
-	if msg == self.db.profile.noFoodMessage or msg == self.db.profile.noFlaskMessage or msg == self.db.profile.lowFlaskDurationMessage or msg == L["ICU"]..": "..self.db.profile.noFoodMessage or msg == L["ICU"]..": "..self.db.profile.noFlaskMessage or msg == L["ICU"]..": "..self.db.profile.lowFlaskDurationMessage then return true end
+function icu:getDB()
+	return self.db;
 end
-ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER_ICU_INFORM", icu:filterChat)
+
+function filterChat(self, event, msg)
+	local db = icu:getDB();
+	if msg == db.profile.noFoodMessage or msg == db.profile.noFlaskMessage or msg == db.profile.lowFlaskDurationMessage or msg == L["ICU"]..": "..db.profile.noFoodMessage or msg == L["ICU"]..": "..db.profile.noFlaskMessage or msg == L["ICU"]..": "..db.profile.lowFlaskDurationMessage then return true end
+end
+ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER_ICU_INFORM", filterChat)
 
 icu:RegisterEvent("READY_CHECK");