changeset 94:db1d5d09e5f5

Do not register '/loot' as a synonym any longer, as it becomes a builtin command in MoP.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Tue, 24 Jul 2012 23:04:51 +0000
parents ea20a28327b5
children 3546c7b55986
files core.lua gui.lua
diffstat 2 files changed, 55 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/core.lua	Wed Jul 18 07:42:16 2012 +0000
+++ b/core.lua	Tue Jul 24 23:04:51 2012 +0000
@@ -115,7 +115,8 @@
 local option_defaults = {
 	['datarev'] = 20,    -- cheating, this isn't actually an option
 	['popup_on_join'] = true,
-	['register_slashloot'] = true,
+	['register_slash_synonyms'] = false,
+	['slash_synonyms'] = '/ol,/oloot',
 	['scroll_to_bottom'] = true,
 	['gui_noob'] = true,
 	['chatty_on_kill'] = false,
@@ -744,6 +745,10 @@
 			opts['forum_current'] = '[url] Wowhead'
 		end
 	end
+	if opts['register_slashloot'] then
+		self:Print[[The "/loot" command is no longer available, because it is used by Blizzard in MoP.  You can toggle on other synonyms for "/ouroloot" in the Options tab.]]
+	end
+	opts['register_slashloot'] = nil
 	option_defaults = nil
 	if OuroLootSV then  -- may not be the same as testing g_restore_p soon
 		if OuroLootSV.saved then
@@ -768,10 +773,13 @@
 	self.default_itemvault = nil
 
 	self:RegisterChatCommand("ouroloot", "OnSlash")
-	if opts.register_slashloot then
-		-- NOTA BENE:  do not use /loot in the LoadOn list, ChatTypeInfo gets confused
-		-- maybe try to detect if this command is already in use...
-		_G.SLASH_ACECONSOLE_OUROLOOT2 = "/loot"
+	if opts.register_slash_synonyms then
+		-- Maybe use %w here for non-English locales?
+		local n = 2
+		for s in opts.slash_synonyms:gmatch("/%a+") do
+			_G['SLASH_ACECONSOLE_OUROLOOT'..n] = s
+			n = n + 1
+		end
 	end
 
 	self.history_all = self.history_all or _G.OuroLootSV_hist or {}
--- a/gui.lua	Wed Jul 18 07:42:16 2012 +0000
+++ b/gui.lua	Tue Jul 24 23:04:51 2012 +0000
@@ -2126,7 +2126,6 @@
 		w = mkoption('gui_noob', [[Show UI Tips]], 0.85,
 			[[Toggles display of the "helpful tips" box on the right side.  Useful if you've just installed/upgraded.]])
 		grp:AddChild(w)
-		w = GUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(10) grp:AddChild(w)
 
 		-- reminder popup
 		w = mkoption ('popup_on_join', "Show reminder popup on new raid", 0.49,
@@ -2138,11 +2137,6 @@
 			[[Scroll to the bottom of the loot window (most recent entries) when displaying the GUI.]])
 		grp:AddChild(w)
 
-		-- /loot option
-		w = mkoption('register_slashloot', "Register /loot slash command on login", 0.49,
-			[[Register "/loot" as a slash command in addition to the normal "/ouroloot".  Relog to take effect.]])
-		grp:AddChild(w)
-
 		-- chatty boss mode
 		w = mkoption('chatty_on_kill', "Be chatty on boss kill", 0.49,
 			[[Print something to chat output when the boss mod tells Ouro Loot about a successful boss kill.]])
@@ -2177,7 +2171,7 @@
 			[[See description under +Help -- Handy Tips -- Prescanning> for instructions.]])
 		grp:AddChild(w)
 
-		w = GUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(1) grp:AddChild(w)
+		w = GUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(5) grp:AddChild(w)
 
 		-- possible keybindings
 		do
@@ -2206,6 +2200,45 @@
 			grp:AddChild(pair)
 		end
 
+		-- replacement for slashloot
+		do
+			local pair = GUI:Create("InlineGroup")
+			pair:SetLayout("List")
+			pair:SetRelativeWidth(0.49)
+			pair:SetTitle('Synonyms for "/ouroloot"')
+			local editbox, checkbox
+			editbox = mkbutton("EditBox", nil, opts.slash_synonyms,
+				[[Separate multiple synonyms with a comma.  Relog to take effect.]])
+			editbox:SetFullWidth(true)
+			editbox:SetLabel("Slash commands")
+			editbox:SetCallback("OnEnterPressed", function(_e,event,value)
+				-- Do the sanity checking here rather than at each login.
+				-- This is not foolproof.  That's okay.
+				local t = { strsplit(',', tostring(value)) }
+				for k,v in ipairs(t) do
+					v = v:trim()
+					if v:sub(1,1) ~= "/" then
+						v = "/" .. v
+					end
+					t[k] = v
+				end
+				value = table.concat(t,',')
+				_e:SetText(value)
+				opts.slash_synonyms = value
+			end)
+			editbox:SetDisabled(not opts.register_slash_synonyms)
+			checkbox = mkoption('register_slash_synonyms', "Register slash commands", 1,
+				[[Register these slash commands as synonyms for "/ouroloot".  Relog to take effect.]],
+				function (_w,_,value)
+					opts.register_slash_synonyms = value
+					editbox:SetDisabled(not opts.register_slash_synonyms)
+				end)
+			checkbox:SetFullWidth(true)
+			pair:AddChild(checkbox)
+			pair:AddChild(editbox)
+			grp:AddChild(pair)
+		end
+
 		-- chatty disposition/assignment changes
 		do
 			local chatgroup = GUI:Create("InlineGroup")
@@ -2259,10 +2292,7 @@
 		end
 
 		-- boss mod selection
-		w = GUI:Create("Spacer")
-		w:SetFullWidth(true)
-		w:SetHeight(2)
-		grp:AddChild(w)
+		w = GUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(2) grp:AddChild(w)
 		do
 			local list = {}
 			local current
@@ -2284,10 +2314,7 @@
 		end
 
 		-- item filters
-		w = GUI:Create("Spacer")
-		w:SetFullWidth(true)
-		w:SetHeight(2)
-		grp:AddChild(w)
+		w = GUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(2) grp:AddChild(w)
 		do
 			local warntext = "At least one of the items in the filter list was not in your game client's cache.  This is okay.  Just wait a few seconds, display some other Ouro Loot tab, and then display Options again."
 			local cache_warn, cache_warned = false, false