
[ENH] Add Flight Keybinding Settings to Options
TimothyLuke opened this issue ยท 1 comments
๐ข How does GSE currently work
GSE uses SetKeyBindClick to allow people to keybind a GSE Sequence. This has the limitation that if you use a key that is normally mapped to an action bar you then loose the mapping to default things like SkyRiding and VehicleUI or PossessBar.
๐ข Describe the solution you'd like
Using SetOverrideClick will allow setting an alternative bind for those keys that when those bars are in effect will pass that key through to their normal destination.
๐ข Additional context
Access to this feature would be via the Interface Options and look something like
Sypro from BindPanel gave me the following code as proof of concept:
--[[ Pet battle buttons ]]----------------------------------------------------------------------------------------------------------
-- Hidden macro buttons that execute pet battle abilities, to click on them when the player
-- enters a pet battle, with the binds assigned by the user in the vehicle binds panel
local PetBattleButton = {}
for i = 1, 6 do
PetBattleButton[i] = CreateFrame("Button", "GSE_PetBattleButton"..i, nil, "SecureActionButtonTemplate")
PetBattleButton[i]:RegisterForClicks("AnyDown")
PetBattleButton[i]:SetAttribute("type", "macro")
if i <= 3 then PetBattleButton[i]:SetAttribute("macrotext", "/run PetBattleFrame.BottomFrame.abilityButtons["..i.."]:Click()") end
end
PetBattleButton[4]:SetAttribute("macrotext", "/run PetBattleFrame.BottomFrame.SwitchPetButton:Click()")
PetBattleButton[5]:SetAttribute("macrotext", "/run PetBattleFrame.BottomFrame.CatchButton:Click()")
PetBattleButton[6]:SetAttribute("macrotext", "/run PetBattleFrame.BottomFrame.ForfeitButton:Click()")
--[[ Vehicle/Skyriding bar ]]-------------------------------------------------------------------------------------------------------
-- Hidden action bar to click on its buttons when the player enters a vehicle or
-- skyriding mount, with the binds assigned by the user in the vehicle binds panel
local VehicleBar = CreateFrame("Frame", nil, nil, "SecureHandlerAttributeTemplate")
VehicleBar:SetAttribute("actionpage", 1)
VehicleBar:Hide()
-- Creating buttons
local VehicleButton = {}
for i = 1, 12 do
VehicleButton[i] = CreateFrame("Button", "GSE_VehicleButton"..i, VehicleBar, "SecureActionButtonTemplate")
local B = VehicleButton[i]
B:Hide()
B:SetID(i)
B:SetAttribute("type", "action")
B:SetAttribute("action", i)
B:SetAttribute("useparent-actionpage", true)
B:RegisterForClicks("AnyDown")
end
-- Table that will store the keybinds for vehicles desired by the user
VehicleBar:Execute([[ VehicleKeybind = newtable() ]]) -- Key: Button index / Value: Keybind
-- Triggers
VehicleBar:SetAttribute("_onattributechanged", [[
-- Actionpage update
if name == "page" then
if HasVehicleActionBar() then self:SetAttribute("actionpage", GetVehicleBarIndex())
elseif HasOverrideActionBar() then self:SetAttribute("actionpage", GetOverrideBarIndex())
elseif HasBonusActionBar() then self:SetAttribute("actionpage", GetBonusBarIndex())
else self:SetAttribute("actionpage", GetActionBarPage()) end
-- Settings binds of higher priority than the normal ones when the player enters a vehicle, to be able to use it
elseif name == "vehicletype" then
if value == "vehicle" then -- Vehicles/Skyriding
for i = 1, 12 do
if VehicleKeybind[i] then self:SetBindingClick(true, VehicleKeybind[i], "GSE_VehicleButton"..i) end
end
elseif value == "petbattle" then -- Pet battle
for i = 1, 6 do
if VehicleKeybind[i] then self:SetBindingClick(true, VehicleKeybind[i], "GSE_PetBattleButton"..i) end
end
elseif value == "none" then -- No vehicle, deleting vehicle binds
self:ClearBindings()
end
end
]])
-- Actionpage trigger
RegisterAttributeDriver(VehicleBar, "page",
"[vehicleui] A;" ..
"[possessbar] B;" ..
"[overridebar] C;"..
"[bonusbar:5] D;" .. -- Skyriding
"E"
)
-- Vehicle trigger
RegisterAttributeDriver(VehicleBar, "vehicletype",
"[vehicleui][possessbar][overridebar][bonusbar:5] vehicle;"..
"[petbattle] petbattle;"..
"none"
)
--[[ Events ]]----------------------------------------------------------------------------------------------------------------------
-- Event PET_BATTLE_OPENING_START
-- Triggers when a pet battle starts. Used only in MoP because it doesn't have the [petbattle]
-- macro condition to detect pet battles from the Restricted Environment like post-MoP expansions.
function Event:PET_BATTLE_OPENING_START()
VehicleBar:Execute([[
for i = 1, 6 do
if VehicleKeybind[i] then self:SetBindingClick(true, VehicleKeybind[i], "GSE_PetBattleButton"..i) end
end
]])
end
-- Event PET_BATTLE_CLOSE
-- Triggers when a pet battle starts. Used only in MoP because it doesn't have the [petbattle]
-- macro condition to detect pet battles from the Restricted Environment like post-MoP expansions.
function Event:PET_BATTLE_CLOSE()
VehicleBar:Execute([[ self:ClearBindings() ]])
end