changeset 104:04198c8d0717

Don't set a default keybinding, but rather change the associated option to not be clunky and gross.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Sun, 05 Aug 2012 16:53:07 +0000
parents dc8a23a47b03
children 646c9b41aaed
files core.lua gui.lua options.lua
diffstat 3 files changed, 37 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/core.lua	Sun Aug 05 07:26:06 2012 +0000
+++ b/core.lua	Sun Aug 05 16:53:07 2012 +0000
@@ -121,7 +121,7 @@
 	['snarky_boss'] = true,
 	['keybinding'] = false,
 	['bossmod'] = "DBM",
-	['keybinding_text'] = 'CTRL-SHIFT-O',
+	['keybinding_text'] = '',  --'CTRL-SHIFT-O',
 	['forum'] = {
 		['[url] Wowhead'] = '[url=http://www.wowhead.com/?item=$I]$N[/url]$X - $T',
 		['[url] MMO/Wowstead'] = '[http://db.mmo-champion.com/i/$I]$X - $T',
--- a/gui.lua	Sun Aug 05 07:26:06 2012 +0000
+++ b/gui.lua	Sun Aug 05 16:53:07 2012 +0000
@@ -117,7 +117,7 @@
 		        :gsub("([^\n])\n([^\n])", "%1 %2")
 		        :gsub("|r\n\n", "|r\n")
 	end
-	gui.markup = markup  -- too useful to keep local
+	gui.markup = _markup  -- too useful to keep local
 end
 
 -- Working around this bug:
@@ -752,6 +752,7 @@
 local function setstatus(txt) _d:SetStatusText(txt) end
 local function statusy_OnLeave() setstatus("") end
 local tabgroup_tabs
+gui.setstatus = setstatus
 
 --[[
 Controls for the tabs on the left side of the main display.
--- a/options.lua	Sun Aug 05 07:26:06 2012 +0000
+++ b/options.lua	Sun Aug 05 16:53:07 2012 +0000
@@ -183,8 +183,9 @@
 		local pair = AceGUI:Create("InlineGroup")
 		pair:SetLayout("List")
 		pair:SetRelativeWidth(0.49)
-		pair:SetTitle("Keybinding for '/ouroloot'")
-		local editbox, checkbox
+		pair:SetTitle('Keybinding for "/ouroloot toggle"')
+		local checkbox, button
+		--[=[
 		editbox = mkbutton("EditBox", nil, opts.keybinding_text,
 			[[Keybinding text format is fragile!  (All caps, ALT then CTRL then SHIFT.)  Relog to take effect.]])
 		editbox:SetFullWidth(true)
@@ -193,15 +194,42 @@
 			opts.keybinding_text = value
 		end)
 		editbox:SetDisabled(not opts.keybinding)
+		]=]
 		checkbox = mktoggle('keybinding', "Register keybinding", 1,
-			[[Register a keybinding to toggle the loot display.  Relog to take effect.]],
+			[[Whether to register a keybinding to toggle the loot display.  Relog to take effect.]],
 			function (_w,_,value)
 				opts.keybinding = value
-				editbox:SetDisabled(not opts.keybinding)
+				--editbox:SetDisabled(not opts.keybinding)
+				button:SetDisabled(not opts.keybinding)
 			end)
 		checkbox:SetFullWidth(true)
-		pair:AddChild(checkbox)
-		pair:AddChild(editbox)
+		button = mkbutton("Keybinding", nil, "",
+			-- This wording is not quite accurate, but auto-l10n is nice.
+			_G.BIND_KEY_TO_COMMAND:format([['/ouroloot toggle']]))
+		button:SetFullWidth(true)
+		--button:SetLabel("this is label text")
+		button:SetKey(opts.keybinding_text)
+		button.msgframe:SetToplevel(true) -- XXX ace3 ticket #305
+		button:SetCallback("OnKeyChanged", function(_b,event,value)
+			local possible_prev = opts.keybinding_text
+			opts.keybinding_text = value
+			-- If they were already binding something at login, try updating.
+			if not _G.OuroLootBindingOpen then return end
+			if possible_prev and #possible_prev > 0 then
+				addon:Print("Trying to unbind previous %s key.", possible_prev)
+				SetBinding (possible_prev, nil)
+			end
+			if value and #value > 0 then
+				addon:Print("Trying to bind new %s key.", value)
+				if SetBindingClick (value, "OuroLootBindingOpen") then
+					local c = GetCurrentBindingSet()
+					if c == ACCOUNT_BINDINGS or c == CHARACTER_BINDINGS then
+						SaveBindings(c)
+					end
+				end
+			end
+		end)
+		pair:AddChildren (checkbox, button)--, editbox)
 		container:AddChild(pair)
 	end