remove old keyBound code
This commit is contained in:
@@ -1,422 +0,0 @@
|
||||
--[[
|
||||
KeyBound
|
||||
An intuitive keybindings sytem
|
||||
Based off of ClickBinder by Gello and TrinityBinder by Maul
|
||||
|
||||
Functions needed to implement
|
||||
button:GetHotkey() - returns the current hotkey assigned to the given button
|
||||
|
||||
Functions to implemnt if using a custom keybindings system:
|
||||
button:SetKey(key) - binds the given key to the given button
|
||||
button:FreeKey(key) - unbinds the given key from all other buttons
|
||||
button:ClearBindings() - removes all keys bound to the given button
|
||||
button:GetBindings() - returns a string listing all bindings of the given button
|
||||
button:GetActionName() - what we're binding to, used for printing
|
||||
--]]
|
||||
|
||||
|
||||
KeyBound = LibStub('AceAddon-3.0'):NewAddon('KeyBound', 'AceEvent-3.0')
|
||||
local L = LibStub('AceLocale-3.0'):GetLocale('KeyBound')
|
||||
local Binder = {}
|
||||
|
||||
--[[ KeyBound ]]--
|
||||
|
||||
--events
|
||||
function KeyBound:OnEnable()
|
||||
do
|
||||
local f = CreateFrame('Frame', 'KeyboundDialog', UIParent)
|
||||
f:SetFrameStrata('DIALOG')
|
||||
f:SetToplevel(true); f:EnableMouse(true)
|
||||
f:SetWidth(320); f:SetHeight(96)
|
||||
f:SetBackdrop{
|
||||
bgFile='Interface\\DialogFrame\\UI-DialogBox-Background' ,
|
||||
edgeFile='Interface\\DialogFrame\\UI-DialogBox-Border',
|
||||
tile = true,
|
||||
insets = {left = 11, right = 12, top = 12, bottom = 11},
|
||||
tileSize = 32,
|
||||
edgeSize = 32,
|
||||
}
|
||||
f:SetPoint('TOP', 0, -24)
|
||||
f:Hide()
|
||||
|
||||
local tr = f:CreateTitleRegion()
|
||||
tr:SetAllPoints(f)
|
||||
f:SetClampedToScreen(true)
|
||||
|
||||
local text = f:CreateFontString('ARTWORK')
|
||||
text:SetFontObject('GameFontHighlight')
|
||||
text:SetPoint('TOP', 0, -16)
|
||||
text:SetWidth(252); text:SetHeight(0)
|
||||
text:SetText(format(L.BindingsHelp, GetBindingText('ESCAPE','KEY_')))
|
||||
|
||||
local close = CreateFrame('Button', f:GetName() .. 'Close', f, 'UIPanelCloseButton')
|
||||
close:SetPoint('TOPRIGHT', -3, -3)
|
||||
|
||||
-- per character bindings checkbox
|
||||
local perChar = CreateFrame('CheckButton', 'KeyboundDialogCheck', f, 'OptionsCheckButtonTemplate')
|
||||
getglobal(perChar:GetName() .. 'Text'):SetText(CHARACTER_SPECIFIC_KEYBINDINGS)
|
||||
perChar:SetPoint('BOTTOMLEFT', 12, 8)
|
||||
|
||||
perChar:SetScript('OnShow', function(self)
|
||||
self.current = GetCurrentBindingSet()
|
||||
self:SetChecked(GetCurrentBindingSet() == 2)
|
||||
end)
|
||||
|
||||
perChar:SetScript('OnHide', function(self)
|
||||
KeyBound:Deactivate()
|
||||
|
||||
if InCombatLockdown() then
|
||||
self:RegisterEvent('PLAYER_REGEN_ENABLED')
|
||||
else
|
||||
SaveBindings(self.current)
|
||||
end
|
||||
end)
|
||||
|
||||
perChar:SetScript('OnEvent', function(self, event)
|
||||
SaveBindings(self.current)
|
||||
self:UnregisterEvent(event)
|
||||
end)
|
||||
|
||||
perChar:SetScript('OnClick', function(self)
|
||||
self.current = (self:GetChecked() and 2) or 1
|
||||
LoadBindings(self.current)
|
||||
end)
|
||||
|
||||
self.dialog = f
|
||||
end
|
||||
|
||||
SlashCmdList['KeyBoundSlashCOMMAND'] = function() self:Toggle() end
|
||||
SLASH_KeyBoundSlashCOMMAND1 = '/keybound'
|
||||
SLASH_KeyBoundSlashCOMMAND2 = '/kb'
|
||||
|
||||
self:RegisterEvent('PLAYER_REGEN_ENABLED')
|
||||
self:RegisterEvent('PLAYER_REGEN_DISABLED')
|
||||
end
|
||||
|
||||
function KeyBound:PLAYER_REGEN_ENABLED()
|
||||
if self.enabled then
|
||||
UIErrorsFrame:AddMessage(L.CombatBindingsEnabled, 1, 0.3, 0.3, 1, UIERRORS_HOLD_TIME)
|
||||
self.dialog:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function KeyBound:PLAYER_REGEN_DISABLED()
|
||||
if self.enabled then
|
||||
self:Set(nil)
|
||||
UIErrorsFrame:AddMessage(L.CombatBindingsDisabled, 1, 0.3, 0.3, 1, UIERRORS_HOLD_TIME)
|
||||
self.dialog:Show()
|
||||
end
|
||||
end
|
||||
|
||||
function KeyBound:Toggle()
|
||||
if self:IsShown() then
|
||||
self:Deactivate()
|
||||
else
|
||||
self:Activate()
|
||||
end
|
||||
end
|
||||
|
||||
function KeyBound:Activate()
|
||||
if not self:IsShown() then
|
||||
if InCombatLockdown() then
|
||||
UIErrorsFrame:AddMessage(L.CannotBindInCombat, 1, 0.3, 0.3, 1, UIERRORS_HOLD_TIME)
|
||||
else
|
||||
self.enabled = true
|
||||
if not self.frame then
|
||||
self.frame = Binder:Create()
|
||||
end
|
||||
self:Set(nil)
|
||||
self.dialog:Show()
|
||||
self:SendMessage('KEYBOUND_ENABLED')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function KeyBound:Deactivate()
|
||||
if self:IsShown() then
|
||||
self.enabled = nil
|
||||
self:Set(nil)
|
||||
self.dialog:Hide()
|
||||
|
||||
self:SendMessage('KEYBOUND_DISABLED')
|
||||
end
|
||||
end
|
||||
|
||||
function KeyBound:IsShown()
|
||||
return self.enabled
|
||||
end
|
||||
|
||||
function KeyBound:Set(button)
|
||||
local bindFrame = self.frame
|
||||
|
||||
if button and self:IsShown() and not InCombatLockdown() then
|
||||
bindFrame.button = button
|
||||
bindFrame:SetAllPoints(button)
|
||||
|
||||
bindFrame.text:SetFontObject('GameFontNormalLarge')
|
||||
bindFrame.text:SetText(button:GetHotkey())
|
||||
if bindFrame.text:GetStringWidth() > bindFrame:GetWidth() then
|
||||
bindFrame.text:SetFontObject('GameFontNormal')
|
||||
end
|
||||
bindFrame:Show()
|
||||
bindFrame:OnEnter()
|
||||
elseif bindFrame then
|
||||
bindFrame.button = nil
|
||||
bindFrame:ClearAllPoints()
|
||||
bindFrame:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function KeyBound:ToShortKey(key)
|
||||
if key then
|
||||
key = key:upper()
|
||||
key = key:gsub(' ', '')
|
||||
key = key:gsub('ALT%-', 'A')
|
||||
key = key:gsub('CTRL%-', 'C')
|
||||
key = key:gsub('SHIFT%-', 'S')
|
||||
|
||||
key = key:gsub('NUMPAD', 'N')
|
||||
|
||||
key = key:gsub('BACKSPACE', 'BS')
|
||||
key = key:gsub('PLUS', '%+')
|
||||
key = key:gsub('MINUS', '%-')
|
||||
key = key:gsub('MULTIPLY', '%*')
|
||||
key = key:gsub('DIVIDE', '%/')
|
||||
key = key:gsub('HOME', 'HN')
|
||||
key = key:gsub('INSERT', 'Ins')
|
||||
key = key:gsub('DELETE', 'Del')
|
||||
key = key:gsub('BUTTON3', 'M3')
|
||||
key = key:gsub('BUTTON4', 'M4')
|
||||
key = key:gsub('BUTTON5', 'M5')
|
||||
key = key:gsub('MOUSEWHEELDOWN', 'WD')
|
||||
key = key:gsub('MOUSEWHEELUP', 'WU')
|
||||
key = key:gsub('PAGEDOWN', 'PD')
|
||||
key = key:gsub('PAGEUP', 'PU')
|
||||
|
||||
return key
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--[[ Binder Widget ]]--
|
||||
|
||||
function Binder:Create()
|
||||
local binder = CreateFrame('Button')
|
||||
binder:RegisterForClicks('anyUp')
|
||||
binder:SetFrameStrata('DIALOG')
|
||||
binder:EnableKeyboard(true)
|
||||
binder:EnableMouseWheel(true)
|
||||
|
||||
for k,v in pairs(self) do
|
||||
binder[k] = v
|
||||
end
|
||||
|
||||
local bg = binder:CreateTexture()
|
||||
bg:SetTexture(0, 0, 0, 0.5)
|
||||
bg:SetAllPoints(binder)
|
||||
|
||||
local text = binder:CreateFontString('OVERLAY')
|
||||
text:SetFontObject('GameFontNormalLarge')
|
||||
text:SetTextColor(0, 1, 0)
|
||||
text:SetAllPoints(binder)
|
||||
binder.text = text
|
||||
|
||||
binder:SetScript('OnClick', self.OnKeyDown)
|
||||
binder:SetScript('OnKeyDown', self.OnKeyDown)
|
||||
binder:SetScript('OnMouseWheel', self.OnMouseWheel)
|
||||
binder:SetScript('OnEnter', self.OnEnter)
|
||||
binder:SetScript('OnLeave', self.OnLeave)
|
||||
binder:SetScript('OnHide', self.OnHide)
|
||||
binder:Hide()
|
||||
|
||||
return binder
|
||||
end
|
||||
|
||||
function Binder:OnHide()
|
||||
KeyBound:Set(nil)
|
||||
end
|
||||
|
||||
function Binder:OnKeyDown(key)
|
||||
local button = self.button
|
||||
if not button then return end
|
||||
|
||||
if (key == 'UNKNOWN' or key == 'LSHIFT' or key == 'RSHIFT' or
|
||||
key == 'LCTRL' or key == 'RCTRL' or key == 'LALT' or key == 'RALT' or
|
||||
key == 'LeftButton' or key == 'RightButton') then
|
||||
return
|
||||
end
|
||||
|
||||
local screenshotKey = GetBindingKey('SCREENSHOT')
|
||||
if screenshotKey and key == screenshotKey then
|
||||
Screenshot()
|
||||
return
|
||||
end
|
||||
|
||||
local openChatKey = GetBindingKey('OPENCHAT')
|
||||
if openChatKey and key == openChatKey then
|
||||
ChatFrameEditBox:Show()
|
||||
return
|
||||
end
|
||||
|
||||
if key == 'MiddleButton' then
|
||||
key = 'BUTTON3'
|
||||
elseif key == 'Button4' then
|
||||
key = 'BUTTON4'
|
||||
elseif key == 'Button5' then
|
||||
key = 'BUTTON5'
|
||||
end
|
||||
|
||||
if key == 'ESCAPE' then
|
||||
self:ClearBindings(button)
|
||||
KeyBound:Set(button)
|
||||
return
|
||||
end
|
||||
|
||||
if IsShiftKeyDown() then
|
||||
key = 'SHIFT-' .. key
|
||||
end
|
||||
if IsControlKeyDown() then
|
||||
key = 'CTRL-' .. key
|
||||
end
|
||||
if IsAltKeyDown() then
|
||||
key = 'ALT-' .. key
|
||||
end
|
||||
|
||||
if MouseIsOver(button) then
|
||||
self:SetKey(button, key)
|
||||
KeyBound:Set(button)
|
||||
end
|
||||
end
|
||||
|
||||
function Binder:OnMouseWheel(arg1)
|
||||
if arg1 > 0 then
|
||||
self:OnKeyDown('MOUSEWHEELUP')
|
||||
else
|
||||
self:OnKeyDown('MOUSEWHEELDOWN')
|
||||
end
|
||||
end
|
||||
|
||||
function Binder:OnEnter()
|
||||
local button = self.button
|
||||
if button and not InCombatLockdown() then
|
||||
if self:GetRight() >= (GetScreenWidth() / 2) then
|
||||
GameTooltip:SetOwner(self, 'ANCHOR_LEFT')
|
||||
else
|
||||
GameTooltip:SetOwner(self, 'ANCHOR_RIGHT')
|
||||
end
|
||||
|
||||
if button.GetActionName then
|
||||
GameTooltip:SetText(button:GetActionName(), 1, 1, 1)
|
||||
else
|
||||
GameTooltip:SetText(button:GetName(), 1, 1, 1)
|
||||
end
|
||||
|
||||
local bindings = self:GetBindings(button)
|
||||
if bindings then
|
||||
GameTooltip:AddLine(bindings, 0, 1, 0)
|
||||
GameTooltip:AddLine(L.ClearTip)
|
||||
else
|
||||
GameTooltip:AddLine(L.NoKeysBoundTip, 0, 1, 0)
|
||||
end
|
||||
GameTooltip:Show()
|
||||
else
|
||||
GameTooltip:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
function Binder:OnLeave()
|
||||
KeyBound:Set(nil)
|
||||
GameTooltip:Hide()
|
||||
end
|
||||
|
||||
|
||||
--[[ Update Functions ]]--
|
||||
|
||||
function Binder:ToBinding(button)
|
||||
return format('CLICK %s:LeftButton', button:GetName())
|
||||
end
|
||||
|
||||
function Binder:FreeKey(button, key)
|
||||
local msg
|
||||
if button.FreeKey then
|
||||
local action = button:FreeKey(key)
|
||||
if button:FreeKey(key) then
|
||||
msg = format(L.UnboundKey, GetBindingText(key, 'KEY_'), action)
|
||||
end
|
||||
else
|
||||
local action = GetBindingAction(key)
|
||||
if action and action ~= '' and action ~= self:ToBinding(button) then
|
||||
msg = format(L.UnboundKey, GetBindingText(key, 'KEY_'), action)
|
||||
end
|
||||
end
|
||||
|
||||
if msg then
|
||||
UIErrorsFrame:AddMessage(msg, 1, 0.82, 0, 1, UIERRORS_HOLD_TIME)
|
||||
end
|
||||
end
|
||||
|
||||
function Binder:SetKey(button, key)
|
||||
if InCombatLockdown() then
|
||||
UIErrorsFrame:AddMessage(L.CannotBindInCombat, 1, 0.3, 0.3, 1, UIERRORS_HOLD_TIME)
|
||||
else
|
||||
self:FreeKey(button, key)
|
||||
|
||||
if button.SetKey then
|
||||
button:SetKey(key)
|
||||
else
|
||||
SetBindingClick(key, button:GetName(), 'LeftButton')
|
||||
end
|
||||
|
||||
local msg
|
||||
if button.GetActionName then
|
||||
msg = format(L.BoundKey, GetBindingText(key, 'KEY_'), button:GetActionName())
|
||||
else
|
||||
msg = format(L.BoundKey, GetBindingText(key, 'KEY_'), button:GetName())
|
||||
end
|
||||
SaveBindings(GetCurrentBindingSet())
|
||||
UIErrorsFrame:AddMessage(msg, 1, 1, 1, 1, UIERRORS_HOLD_TIME)
|
||||
end
|
||||
end
|
||||
|
||||
function Binder:ClearBindings(button)
|
||||
if InCombatLockdown() then
|
||||
UIErrorsFrame:AddMessage(L.CannotBindInCombat, 1, 0.3, 0.3, 1, UIERRORS_HOLD_TIME)
|
||||
else
|
||||
if button.ClearBindings then
|
||||
button:ClearBindings()
|
||||
else
|
||||
local binding = self:ToBinding(button)
|
||||
while GetBindingKey(binding) do
|
||||
SetBinding(GetBindingKey(binding), nil)
|
||||
end
|
||||
end
|
||||
|
||||
local msg
|
||||
if button.GetActionName then
|
||||
msg = format(L.ClearedBindings, button:GetActionName())
|
||||
else
|
||||
msg = format(L.ClearedBindings, button:GetName())
|
||||
end
|
||||
SaveBindings(GetCurrentBindingSet())
|
||||
UIErrorsFrame:AddMessage(msg, 1, 1, 1, 1, UIERRORS_HOLD_TIME)
|
||||
end
|
||||
end
|
||||
|
||||
function Binder:GetBindings(button)
|
||||
if button.GetBindings then
|
||||
return button:GetBindings()
|
||||
end
|
||||
|
||||
local keys
|
||||
local binding = self:ToBinding(button)
|
||||
for i = 1, select('#', GetBindingKey(binding)) do
|
||||
local hotKey = select(i, GetBindingKey(binding))
|
||||
if keys then
|
||||
keys = keys .. ', ' .. GetBindingText(hotKey,'KEY_')
|
||||
else
|
||||
keys = GetBindingText(hotKey,'KEY_')
|
||||
end
|
||||
end
|
||||
|
||||
return keys
|
||||
end
|
||||
@@ -1,10 +0,0 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/">
|
||||
<Script file="localization\localization.lua"/>
|
||||
<Script file="localization\localization.cn.lua"/>
|
||||
<Script file="localization\localization.fr.lua"/>
|
||||
<Script file="localization\localization.kr.lua"/>
|
||||
<Script file="localization\localization.tw.lua"/>
|
||||
<Script file="keyBound.lua"/>
|
||||
<Script file="spell.lua"/>
|
||||
<Script file="macro.lua"/>
|
||||
</Ui>
|
||||
@@ -1,19 +0,0 @@
|
||||
--[[
|
||||
KeyBound localization file
|
||||
Chinese Simplified by ondh
|
||||
http://www.ondh.cn
|
||||
--]]
|
||||
|
||||
local L = LibStub('AceLocale-3.0'):NewLocale('KeyBound', 'zhCN')
|
||||
if not L then return end
|
||||
|
||||
L.Enabled = "按键绑定模式已启用"
|
||||
L.Disabled = "按键绑定模式已禁用"
|
||||
L.ClearTip = format("按 %s 清除所有绑定", GetBindingText("ESCAPE", "KEY_"))
|
||||
L.NoKeysBoundTip = "当前没有绑定按键"
|
||||
L.ClearedBindings = "从 %s 移除按键绑定"
|
||||
L.BoundKey = "设置 %s 到 %s"
|
||||
L.UnboundKey = "取消绑定 %s 从 %s"
|
||||
L.CannotBindInCombat = "不能在战斗状态绑定按键"
|
||||
L.CombatBindingsEnabled = "离开战斗状态, 按键绑定模式已启用"
|
||||
L.CombatBindingsDisabled = "进入战斗状态, 按键绑定模式已禁用"
|
||||
@@ -1,18 +0,0 @@
|
||||
--[[
|
||||
KeyBound localization file
|
||||
French
|
||||
--]]
|
||||
|
||||
local L = LibStub('AceLocale-3.0'):NewLocale('KeyBound', 'frFR')
|
||||
if not L then return end
|
||||
|
||||
L.Enabled = "Bindings mode enabled"
|
||||
L.Disabled = "Bindings mode disabled"
|
||||
L.ClearTip = format("Appuyer sur %s pour effacer tous les bindings", GetBindingText("ESCAPE", "KEY_"))
|
||||
L.NoKeysBoundTip = "No current bindings"
|
||||
L.ClearedBindings = "Suppression de tous les binding de %s"
|
||||
L.BoundKey = "Définir %s à %s"
|
||||
L.UnboundKey = "Unbound %s depuis %s"
|
||||
L.CannotBindInCombat = "Cannot bind keys in combat"
|
||||
L.CombatBindingsEnabled = "Sortie de combat, keybinding mode activé"
|
||||
L.CombatBindingsDisabled = "Entrée en combat, keybinding mode désactivé"
|
||||
@@ -1,20 +0,0 @@
|
||||
--[[
|
||||
KeyBound localization file
|
||||
Korean by damjau
|
||||
|
||||
--]]
|
||||
|
||||
local L = LibStub('AceLocale-3.0'):NewLocale('KeyBound', 'koKR')
|
||||
if not L then return end
|
||||
|
||||
L.Enabled = '단축키 설정 기능 사용 가능'
|
||||
L.Disabled = '단축키 설정 기능 사용 불가'
|
||||
L.ClearTip = format('%s키를 누르면 모든 단축키가 초기화됩니다', GetBindingText('ESCAPE', 'KEY_'))
|
||||
L.NoKeysBoundTip = '현재 단축키 없음'
|
||||
L.ClearedBindings = '%s의 모든 단축키가 초기화 되었습니다'
|
||||
L.BoundKey = '%2$s의 단축키로 %1$s|1을;를; 설정합니다.'
|
||||
L.UnboundKey = '%2$s에서 %1$s의 단축키가 삭제되었습니다'
|
||||
L.CannotBindInCombat = '전투 중에는 단축키를 지정할 수 없습니다'
|
||||
L.CombatBindingsEnabled = '전투 종료. 단축키 설정이 가능해집니다'
|
||||
L.CombatBindingsDisabled = '전투 시작. 단축키 설정이 불가능합니다'
|
||||
L.BindingsHelp = "버튼 위에 마우스를 올려 놓고 지정할 키를 누르세요. 버튼의 현재 단축키를 삭제하시려면 %s|1을;를; 누르세요."
|
||||
@@ -1,18 +0,0 @@
|
||||
--[[
|
||||
KeyBound localization file
|
||||
English (default)
|
||||
--]]
|
||||
|
||||
local L = LibStub('AceLocale-3.0'):NewLocale('KeyBound', 'enUS', true)
|
||||
|
||||
L.Enabled = 'Bindings mode enabled'
|
||||
L.Disabled = 'Bindings mode disabled'
|
||||
L.ClearTip = format('Press %s to clear all bindings', GetBindingText('ESCAPE', 'KEY_'))
|
||||
L.NoKeysBoundTip = 'No current bindings'
|
||||
L.ClearedBindings = 'Removed all bindings from %s'
|
||||
L.BoundKey = 'Set %s to %s'
|
||||
L.UnboundKey = 'Unbound %s from %s'
|
||||
L.CannotBindInCombat = 'Cannot bind keys in combat'
|
||||
L.CombatBindingsEnabled = 'Exiting combat, keybinding mode enabled'
|
||||
L.CombatBindingsDisabled = 'Entering combat, keybinding mode disabled'
|
||||
L.BindingsHelp = "Hover over a button, then press a key to set its binding. To clear a button's current keybinding, press %s."
|
||||
@@ -1,18 +0,0 @@
|
||||
--[[
|
||||
KeyBound localization file
|
||||
Traditional Chinese
|
||||
--]]
|
||||
|
||||
local L = LibStub('AceLocale-3.0'):NewLocale('KeyBound', 'zhTW')
|
||||
if not L then return end
|
||||
|
||||
L.Enabled = "按鍵綁定模式已啟用"
|
||||
L.Disabled = "按鍵綁定模式已禁用"
|
||||
L.ClearTip = format("按 %s 清除所有綁定", GetBindingText("ESCAPE", "KEY_"))
|
||||
L.NoKeysBoundTip = "目前没有綁定按鍵"
|
||||
L.ClearedBindings = "從 %s 移除按鍵綁定"
|
||||
L.BoundKey = "設置 %s 到 %s"
|
||||
L.UnboundKey = "取消綁定 %s 从 %s"
|
||||
L.CannotBindInCombat = "不能在戰鬥狀態綁定按鍵"
|
||||
L.CombatBindingsEnabled = "離開戰鬥狀態, 按鍵綁定模式已啟用"
|
||||
L.CombatBindingsDisabled = "進入戰鬥狀態, 按鍵綁定模式已禁用"
|
||||
@@ -1,79 +0,0 @@
|
||||
local MacroButton = CreateFrame('Frame')
|
||||
|
||||
function MacroButton:Load()
|
||||
local i = 1
|
||||
local button
|
||||
repeat
|
||||
button = getglobal(format('MacroButton%d', i))
|
||||
if button then
|
||||
local OnEnter = button:GetScript('OnEnter')
|
||||
button:SetScript('OnEnter', function(self)
|
||||
KeyBound:Set(self)
|
||||
return OnEnter and OnEnter(self)
|
||||
end)
|
||||
|
||||
button.GetBindAction = self.GetBindAction
|
||||
button.GetActionName = self.GetActionName
|
||||
button.SetKey = self.SetKey
|
||||
button.GetHotkey = self.GetHotkey
|
||||
button.ClearBindings = self.ClearBindings
|
||||
button.GetBindings = self.GetBindings
|
||||
i = i + 1
|
||||
end
|
||||
until not button
|
||||
end
|
||||
|
||||
function MacroButton:OnEnter()
|
||||
KeyBound:Set(self)
|
||||
end
|
||||
|
||||
function MacroButton:GetActionName()
|
||||
return GetMacroInfo(MacroFrame.macroBase + self:GetID())
|
||||
end
|
||||
|
||||
-- returns the keybind action of the given button
|
||||
function MacroButton:GetBindAction()
|
||||
return format('MACRO %d', MacroFrame.macroBase + self:GetID())
|
||||
end
|
||||
|
||||
-- binds the given key to the given button
|
||||
function MacroButton:SetKey(key)
|
||||
SetBindingMacro(key, MacroFrame.macroBase + self:GetID())
|
||||
end
|
||||
|
||||
-- removes all keys bound to the given button
|
||||
function MacroButton:ClearBindings()
|
||||
local binding = self:GetBindAction()
|
||||
while GetBindingKey(binding) do
|
||||
SetBinding(GetBindingKey(binding), nil)
|
||||
end
|
||||
end
|
||||
|
||||
-- returns a string listing all bindings of the given button
|
||||
function MacroButton:GetBindings()
|
||||
local keys
|
||||
local binding = self:GetBindAction()
|
||||
for i = 1, select('#', GetBindingKey(binding)) do
|
||||
local hotKey = select(i, GetBindingKey(binding))
|
||||
if keys then
|
||||
keys = keys .. ', ' .. GetBindingText(hotKey, 'KEY_')
|
||||
else
|
||||
keys = GetBindingText(hotKey, 'KEY_')
|
||||
end
|
||||
end
|
||||
return keys
|
||||
end
|
||||
|
||||
function MacroButton:GetHotkey()
|
||||
return KeyBound:ToShortKey(GetBindingKey(self:GetBindAction()))
|
||||
end
|
||||
|
||||
do
|
||||
MacroButton:SetScript('OnEvent', function(self, event, addon)
|
||||
if addon == 'Blizzard_MacroUI' then
|
||||
self:UnregisterAllEvents()
|
||||
self:Load()
|
||||
end
|
||||
end)
|
||||
MacroButton:RegisterEvent('ADDON_LOADED')
|
||||
end
|
||||
@@ -1,76 +0,0 @@
|
||||
local CastButton = {}
|
||||
|
||||
function CastButton:Load()
|
||||
local i = 1
|
||||
local button
|
||||
repeat
|
||||
button = getglobal('SpellButton' .. i)
|
||||
if button then
|
||||
button:HookScript('OnEnter', self.OnEnter)
|
||||
|
||||
button.GetBindAction = self.GetBindAction
|
||||
button.GetActionName = self.GetActionName
|
||||
button.SetKey = self.SetKey
|
||||
button.GetHotkey = self.GetHotkey
|
||||
button.ClearBindings = self.ClearBindings
|
||||
button.GetBindings = self.GetBindings
|
||||
i = i + 1
|
||||
end
|
||||
until not button
|
||||
end
|
||||
|
||||
function CastButton:OnEnter()
|
||||
local id = SpellBook_GetSpellID(self:GetID())
|
||||
local bookType = SpellBookFrame.bookType
|
||||
|
||||
if not(bookType == BOOKTYPE_PET or IsPassiveSpell(id, bookType)) then
|
||||
KeyBound:Set(self)
|
||||
end
|
||||
end
|
||||
|
||||
function CastButton:GetActionName()
|
||||
local name, subName = GetSpellName(SpellBook_GetSpellID(self:GetID()), SpellBookFrame.bookType)
|
||||
if(subName and subName ~= '') then
|
||||
return format('%s(%s)', name, subName)
|
||||
end
|
||||
return name
|
||||
end
|
||||
|
||||
-- returns the keybind action of the given button
|
||||
function CastButton:GetBindAction()
|
||||
return format('SPELL %s', self:GetActionName())
|
||||
end
|
||||
|
||||
-- binds the given key to the given button
|
||||
function CastButton:SetKey(key)
|
||||
SetBindingSpell(key, self:GetActionName())
|
||||
end
|
||||
|
||||
-- removes all keys bound to the given button
|
||||
function CastButton:ClearBindings()
|
||||
local binding = self:GetBindAction()
|
||||
while GetBindingKey(binding) do
|
||||
SetBinding(GetBindingKey(binding), nil)
|
||||
end
|
||||
end
|
||||
|
||||
-- returns a string listing all bindings of the given button
|
||||
function CastButton:GetBindings()
|
||||
local keys
|
||||
local binding = self:GetBindAction()
|
||||
for i = 1, select('#', GetBindingKey(binding)) do
|
||||
local hotKey = select(i, GetBindingKey(binding))
|
||||
if keys then
|
||||
keys = keys .. ', ' .. GetBindingText(hotKey, 'KEY_')
|
||||
else
|
||||
keys = GetBindingText(hotKey, 'KEY_')
|
||||
end
|
||||
end
|
||||
return keys
|
||||
end
|
||||
|
||||
function CastButton:GetHotkey()
|
||||
return KeyBound:ToShortKey(GetBindingKey(self:GetBindAction()))
|
||||
end
|
||||
|
||||
CastButton:Load()
|
||||
Reference in New Issue
Block a user