WoWInterface SVN KeyboardAccess

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 12 to Rev 13
    Reverse comparison

Rev 12 → Rev 13

core.lua
3,35 → 3,6
##Subfile : core.lua
##Author : Hati-EK
--]]
--[[Logic Rules:
FIFO Principe
Example:
1. Ready-Check comes in.
2. Rogue wants to swap poison on MH.
3. !No Rule Conflict!
=> Rule#1:
What shows up first -> Gets handled first
 
 
informations
>>readycheck module
ReadyCheckFrameYesButton --yes
ReadyCheckFrameNoButton --no
 
 
>>npc/enchant module
StaticPopup1Button1 --yes
StaticPopup1Button2 --no
up to StaticPopup4
 
>>LFD tool (role)
LFDRoleCheckPopupAcceptButton
LFDRoleCheckPopupDeclineButton
 
>>LFD tool (join)
LFDDungeonReadyDialogEnterDungeonButton --Enter
LFDDungeonReadyDialogLeaveQueueButton --Leave
]]
KeyboardAccess = { } --just for personal debugging issues
local KA = KeyboardAccess -- 4b6579626f617264416363657373 = Hex-CODE for KeyboarAccess
KA.name = 'KeyboardAccess'
41,7 → 12,6
KA.handleT = {}
local events = {}
 
 
local function toboolean(x)
if x==1 then
return true
60,66 → 30,90
return b
end
 
function events:MODIFIER_STATE_CHANGED(modi,state) --required for still opening chat or config
if modi=='LSHIFT' or modi=='RSHIFT' then
KA.MODShift=toboolean(state)
if KA.MODShift then
KA.handler:EnableKeyboard(0)
else
if #KA.handleT>0 then
KA.handler:EnableKeyboard(1)
else
KA.handler:EnableKeyboard(0)
end
end
ReadyCheckFrame.button1 = ReadyCheckFrameYesButton
ReadyCheckFrame.button2 = ReadyCheckFrameNoButton
 
local allowedPopups = {
--Invites
"ARENA_TEAM_INVITE",
"BFMGR_INVITED_TO_QUEUE",
"BFMGR_INVITED_TO_ENTER",
"PARTY_INVITE",
"GUILD_INVITE",
--talents
"CONFIRM_TALENT_WIPE",
"TALENTS_INVOLUNTARILY_RESET",
"TALENTS_INVOLUNTARILY_RESET_PET",
"CONFIRM_REMOVE_GLYPH",
"CONFIRM_GLYPH_PLACEMENT",
 
--misc
"CONFIRM_BINDER",
"CONFIRM_GUILD_PROMOTE",
}
 
 
local function ReadyCheckFrame_OnKeyDown(self,key)
if ( key=='ESCAPE' ) then
ReadyCheckFrame.button2:Click()
ReadyCheckFrame:EnableKeyboard(0)
elseif ( GetBindingFromClick(key) == "SCREENSHOT" ) then
RunBinding("SCREENSHOT");
return;
elseif key=='LSHIFT' or key=='RSHIFT' then
self:EnableKeyboard(0)
KA.MODShift=true
elseif key=='ENTER' then
ReadyCheckFrame.button1:Click()
ReadyCheckFrame:EnableKeyboard(0)
end
end
 
function events:READY_CHECK(initiator,timer) --ReadyCheck PopUp
--print(UnitName('player')==initiator)
if not (UnitName('player')==initiator) then
--print(initiator)
tinsert(KA.handleT,'ReadyCheckFrame')
KA.handler:EnableKeyboard(1)
local RCFYB_OnClick = ReadyCheckFrameYesButton:GetScript('OnClick')
ReadyCheckFrameYesButton:SetScript('OnClick',function(self, button, down)
if button=='LeftButton' and not down then
RCFYB_OnClick(button,down)
local num = inTable(KA.handleT,'ReadyCheckFrame')
--print(num)
if num then
--print('removing', 'READY_CHECK')
tremove(KA.handleT,num)
if #KA.handleT==0 then
KA.handler:EnableKeyboard(0)
end
end
end
end)
local RCFNB_OnClick = ReadyCheckFrameNoButton:GetScript('OnClick')
ReadyCheckFrameNoButton:SetScript('OnClick',function(self, button, down)
if button=='LeftButton' and not down then
RCFNB_OnClick(button,down)
local num = inTable(KA.handleT,'ReadyCheckFrame')
--print(num)
if num then
--print('removing', 'READY_CHECK')
tremove(KA.handleT,num)
if #KA.handleT==0 then
KA.handler:EnableKeyboard(0)
end
end
end
end)
local function EnableEnter()
for _,which in ipairs(allowedPopups) do
StaticPopupDialogs[which].enterClicksFirstButton = true
end
if ReadyCheckFrame:IsVisible() then
ReadyCheckFrame:EnableKeyboard(1)
ReadyCheckFrame:SetScript('OnKeyDown',ReadyCheckFrame_OnKeyDown)
end
end
local function DisableEnter()
for _,which in ipairs(allowedPopups) do
StaticPopupDialogs[which].enterClicksFirstButton = false
end
if ReadyCheckFrame:GetScript('OnKeyDown') then
ReadyCheckFrame:SetScript('OnKeyDown',nil)
end
end
 
function events:LFG_PROPOSAL_SHOW(...) --LFD Tool PopUp
--print('LFG_PROPOSAL_SHOW')
tinsert(KA.handleT,'LFDDungeonReadyDialog')
KA.handler:EnableKeyboard(1)
 
 
function events:READY_CHECK(initiator,timer)
if not (UnitName('player')==initiator) and not (KA.MODShift) then
ReadyCheckFrame:EnableKeyboard(1)
ReadyCheckFrame:SetScript('OnKeyDown',ReadyCheckFrame_OnKeyDown)
end
end
 
function events:READY_CHECK_FINISHED(...)
--print(...)
ReadyCheckFrame:SetScript('OnKeyDown',nil)
ReadyCheckFrame:EnableKeyboard(0)
end
 
function events:MODIFIER_STATE_CHANGED(modi,state)
print(modi,state)
if modi=='LSHIFT' or modi=='RSHIFT' then
KA.MODShift=toboolean(state)
if not KA.MODShift then
EnableEnter()
else
DisableEnter()
end
end
end
 
KA.handler = CreateFrame('Frame',KA.name.."_Handler")
KA.handler:SetScript('OnEvent',function(self,event,...)
events[event](self, ...)
129,125 → 123,5
KA.handler:RegisterEvent(k); -- Register all events for which handlers have been defined
end
 
EnableEnter()
 
--overwriting all possible frames
local popups = {
LFDRoleCheckPopup, --rolecheck
StaticPopup1, --default
StaticPopup2, --popup frames
StaticPopup3, --for enchants
StaticPopup4 --buying items
}
local buttonT = {
["LFDRoleCheckPopup"] = {
"AcceptButton",
"DeclineButton",
},
["StaticPopup1"] = {
"Button1",
"Button2",
},
["StaticPopup2"] = {
"Button1",
"Button2",
},
["StaticPopup3"] = {
"Button1",
"Button2",
},
["StaticPopup4"] = {
"Button1",
"Button2",
},
["LFDDungeonReadyDialog"] = {
"EnterDungeonButton",
"LeaveQueueButton",
},
["ReadyCheckFrame"] = {
"YesButton",
"NoButton",
}
}
KA.oldShow = { }
KA.oldClick = { }
--storing old shows & creating new ones
for _,k in ipairs(popups) do
local name = k:GetName()
KA.oldShow[name] = k:GetScript('OnShow')
KA.oldClick[name]={}
 
KA.oldClick[name][1] = _G[name..buttonT[name][1]]:GetScript('OnClick') --accept button
KA.oldClick[name][2] = _G[name..buttonT[name][2]]:GetScript('OnClick') --decline button
 
k:SetScript('OnShow',function(...)
if not ( k.which =='REPLACE_ENCHANT' or k.which=='DEATH' or k.which=='RECOVER_CORPSE_INSTANCE' or k.which=='BUYOUT_AUCTION') then
tinsert(KA.handleT,name)
KA.handler:EnableKeyboard(1)
end
KA.oldShow[name](...)
end)
_G[name..buttonT[name][1]]:SetScript('OnClick',function(self, button, down)
if button=='LeftButton' and not down then
KA.oldClick[name][1](self,button,down)
local num = inTable(KA.handleT,name)
--print(num)
if num then
--print('removing', name)
tremove(KA.handleT,num)
if #KA.handleT==0 then
KA.handler:EnableKeyboard(0)
end
end
end
end)
_G[name..buttonT[name][2]]:SetScript('OnClick',function(self, button, down)
if button=='LeftButton' and not down then
KA.oldClick[name][2](self,button,down)
local num = inTable(KA.handleT,name)
--print(num)
if num then
--print('removing', name)
--tremove(KA.handleT,num)
if #KA.handleT==0 then
KA.handler:EnableKeyboard(0)
end
end
end
end)
end
 
--fix clicking on buttons
 
--KeyPressing handling
KA.handler:SetScript('OnKeyDown',function(self,key)
if key=='LSHIFT' or key=='RSHIFT' then
self:EnableKeyboard(0)
KA.MODShift=true
end
end)
KA.handler:SetScript('OnKeyUp',function(self,key)
if key=='ENTER' then
local frame = _G[KA.handleT[1]]
if frame.which == "REPLACE_ENCHANT" or frame.which=='DEATH' or frame.which=='RECOVER_CORPSE_INSTANCE' or frame.which=='BUYOUT_AUCTION' then
tremove(KA.handleT,1)
if #KA.handleT==0 then
self:EnableKeyboard(0)
end
else
_G[KA.handleT[1]..buttonT[KA.handleT[1]][1]]:Click()
tremove(KA.handleT,1)
end
elseif key=='ESCAPE' then
_G[KA.handleT[1]..buttonT[KA.handleT[1]][2]]:Click()
tremove(KA.handleT,1)
end
if key=='LSHIFT' or key=='RSHIFT' then
self:EnableKeyboard(1)
KA.MODShift=false
end
if #KA.handleT==0 then
self:EnableKeyboard(0)
end
end)