# HG changeset patch # User Flick # Date 1174426727 0 # Node ID 88df7235ad8b455fa7f0512fac078aa51f4aa64b # Parent f3a7bfebc283292276ef8d1ce1ce159398ffdbde Version 0.33, part 2 diff -r f3a7bfebc283 -r 88df7235ad8b classes/ReBound.lua --- a/classes/ReBound.lua Tue Mar 20 21:37:38 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,158 +0,0 @@ --- ReBound.lua --- - - -local AceEvent = AceLibrary("AceEvent-2.0") - -ReBound = { } - --- initial values -ReBound.active = false - -ReBound.targets = { } - -function ReBound:AddKeybindTarget( t ) - if t then - self.targets[t] = CreateFrame("Button", nil, t, "ReBoundClickBindingTemplate") - self.targets[t].keybindTarget = t:GetName() - end -end - -function ReBound:RemoveKeybindTarget( t ) - if t then - self.targets[t] = nil - end -end - -function ReBound:ShowClickBindingButtons() - AceEvent:TriggerEvent("EVENT_REBOUND_KEYBINDING_MODE", true) - for tgt, clickFrame in pairs(self.targets) do - clickFrame:Show() - end -end - -function ReBound:HideClickBindingButtons() - AceEvent:TriggerEvent("EVENT_REBOUND_KEYBINDING_MODE", false) - for tgt, clickFrame in pairs(self.targets) do - clickFrame:Hide() - end -end - -function ReBound:ClearSelectedKey() - self.selectedKey = nil - SetCursor(nil) -- reset cursor to default state -end - -function ReBound:ToggleEnabled() - if self:IsEnabled() then - self:Disable() - else - self:Enable() - end -end - -function ReBound:IsEnabled() - return ReBoundFrame:IsVisible() -end - -function ReBound:Enable() - if InCombatLockdown() then - UIErrorsFrame:AddMessage("Can't set keybindings in combat") - else - ReBoundFrame:Show() - end -end - -function ReBound:Disable() - ReBoundFrame:Hide() -end - - -local mouseButtonConvert = { - LeftButton = "BUTTON1", - RightButton = "BUTTON2", - MiddleButton = "BUTTON3", - Button4 = "BUTTON4", - Button5 = "BUTTON5" -} - -function ReBound:HandleKeyPressed( key ) - if key == nil or key == "UNKNOWN" or key == "SHIFT" or key == "CTRL" or key == "ALT" then - return - end - if IsShiftKeyDown() then - key = "SHIFT-"..key - end - if IsControlKeyDown() then - key = "CTRL-"..key - end - if IsAltKeyDown() then - key = "ALT-"..key - end - if key == "ESCAPE" or GetBindingAction(key) == "ReBound_TOGGLEBINDINGMODE" then - ReBoundFrame:Hide() - return nil, nil - end - key = mouseButtonConvert[key] or key - - self.selectedKey = key - - -- change cursor to glowing hand - SetCursor("CAST_CURSOR") - - local keyTxt = GetBindingText(key, "KEY_") - local cmd = GetBindingAction(key) - local cmdTxt - - if cmd then - cmdTxt = GetBindingText(cmd, "BINDING_NAME_") - end - - -- make click-bindings look prettier - local btnName - if cmdTxt then - btnName = string.match(cmdTxt,"CLICK (.+)\:LeftButton") - btnName = btnName or string.match(cmdTxt,"CLICK (.+)\:RightButton") - end - - return keyTxt, btnName or cmdTxt -end - --- TODO: move to override-binding model and store data in profile -function ReBound:BindSelectedKeyTo( btnName ) - if self.selectedKey and btnName then - self:ClearBinding(btnName) - SetBindingClick(self.selectedKey, btnName, "LeftButton") - SaveBindings(2) -- 2 = character-specific - ReBoundFrame.statusMsg:SetText(GetBindingText(self.selectedKey, "KEY_") .. " is now bound to " .. btnName) - ReBoundFrame.selectedKey:SetText("(none)") - ReBoundFrame.currentAction:SetText("(none)") - self:ClearSelectedKey() - end -end - - -function ReBound:ClearBinding( btnName ) - if btnName then - local current = GetBindingKey("CLICK "..btnName..":LeftButton") - if current then - SetBinding(current, nil) - ReBoundFrame.statusMsg:SetText("|cFFFF3333"..btnName .. " is now unbound|r") - end - end -end - - -function ReBound:UpdateCurrentTarget( btnName ) - local msg = "" - if btnName then - msg = btnName.." is currently " - local current = GetBindingKey("CLICK "..btnName..":LeftButton") - if current then - msg = msg .. "bound to " .. GetBindingText(current, "KEY_") - else - msg = msg .. " not bound" - end - end - ReBoundFrame.statusMsg:SetText(msg) -end diff -r f3a7bfebc283 -r 88df7235ad8b classes/ReBound.xml --- a/classes/ReBound.xml Tue Mar 20 21:37:38 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,246 +0,0 @@ - - - - - - - - - - - - - - this.selectedKey = getglobal(this:GetName().."SelectedKeyText") - this.currentAction = getglobal(this:GetName().."CurrentActionText") - this:RegisterForClicks("MiddleButtonUp","Button4Up","Button5Up") - - - local k, a = ReBound:HandleKeyPressed(arg1) - if k then - this.selectedKey:SetText(k) - this.currentAction:SetText(a or "(none)") - end - - - - - - - this.selectedKey = getglobal(this:GetName().."DialogSelectedKeyText") - this.currentAction = getglobal(this:GetName().."DialogCurrentActionText") - this.statusMsg = getglobal(this:GetName().."DialogStatusMsg") - tinsert(UISpecialFrames,this:GetName()) - this:RegisterForClicks("MiddleButtonUp","Button4Up","Button5Up") - this:RegisterEvent("PLAYER_REGEN_DISABLED") - - - this.selectedKey:SetText("(none)") - this.currentAction:SetText("(none)") - this.statusMsg:SetText("") - ReBound:ShowClickBindingButtons() - - - ReBound:HideClickBindingButtons() - ReBound:ClearSelectedKey() - - - local k, a = ReBound:HandleKeyPressed(arg1) - if k then - this.selectedKey:SetText(k) - this.currentAction:SetText(a or "(none)") - end - - - local k, a = ReBound:HandleKeyPressed(arg1) - if k then - this.selectedKey:SetText(k) - this.currentAction:SetText(a or "(none)") - end - - - this:Hide() -- only event is enter-combat - - - - -