Skip to content

Commit 19863d5

Browse files
committed
#1806 Experimental Flight Keybinding bar
1 parent 3201155 commit 19863d5

2 files changed

Lines changed: 176 additions & 0 deletions

File tree

GSE/Localization/ModL_enUS.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,3 +809,8 @@ L[
809809
"GSE Sequences are converted to a button that responds to 'Clicks' or Keyboard keypresses (WoW calls these Hardware Events). \n\nWhen you use a KeyBind with a sequence, WoW sends two hardware events each time. With this setting on, GSE then interprets these two clicks as one and advances your sequence one step. With this off it would advance two steps. \n\nIn comparison Actionbar Overrides and '/click SEQUENCE' macros only sends one hardware Event. If you primarily use Keybinds over Actionbar Overrides over Keybinds you want this set to false."
810810
] = true
811811
L["Button Settings"] = true
812+
813+
-- #1806
814+
L["Skyriding / Vehicle Keybinds"] = true
815+
L["Override bindings for Skyriding, Vehicle, Possess and Override Bars"] = true
816+
L["Skyriding Button"] = true

GSE_QoL/QoL.lua

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,3 +633,174 @@ function GSE.CreateIconControl(action, version, keyPath, sequence, frame)
633633
)
634634
return lbl
635635
end
636+
637+
-- Skyriding Bind Bar for Retail
638+
if GSE.GameMode >= 11 then
639+
local config = LibStub("AceConfig-3.0")
640+
local dialog = LibStub("AceConfigDialog-3.0")
641+
local addonName = "|cFFFFFFFFGS|r|cFF00FFFFE|r"
642+
local OptionsTable = {
643+
type = "group",
644+
args = {
645+
title = {
646+
name = L["Skyriding / Vehicle Keybinds"],
647+
desc = L["Override bindings for Skyriding, Vehicle, Possess and Override Bars"],
648+
order = 1,
649+
type = "header"
650+
}
651+
}
652+
}
653+
654+
for i = 1, 12 do
655+
OptionsTable.args["Skyriding" .. tostring(i)] = {
656+
name = L["Skyriding Button"] .. " " .. tostring(i),
657+
type = "keybinding",
658+
set = function(info, val)
659+
if GSE.isEmpty(GSEOptions.SkyRidingBinds) then
660+
GSEOptions.SkyRidingBinds = {}
661+
end
662+
GSEOptions.SkyRidingBinds[tostring(i)] = val
663+
GSE.UpdateVehicleBar()
664+
end,
665+
get = function(info)
666+
return GSEOptions.SkyRidingBinds and GSEOptions.SkyRidingBinds[tostring(i)] and
667+
GSEOptions.SkyRidingBinds[tostring(i)] or
668+
""
669+
end,
670+
order = i + 1
671+
}
672+
end
673+
config:RegisterOptionsTable(addonName .. "-Skyriding", OptionsTable)
674+
dialog:AddToBlizOptions(addonName .. "-Skyriding", OptionsTable.args.title.name, addonName) -- 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
675+
----------------------------------------------------------------------------------------------------------
676+
677+
-- Pet battle buttons
678+
local PetBattleButton = {}
679+
for i = 1, 6 do
680+
PetBattleButton[i] = CreateFrame("Button", "GSE_PetBattleButton" .. i, nil, "SecureActionButtonTemplate")
681+
PetBattleButton[i]:RegisterForClicks("AnyDown")
682+
PetBattleButton[i]:SetAttribute("type", "macro")
683+
if i <= 3 then
684+
PetBattleButton[i]:SetAttribute(
685+
"macrotext",
686+
"/run PetBattleFrame.BottomFrame.abilityButtons[" .. i .. "]:Click()"
687+
)
688+
end
689+
end
690+
691+
PetBattleButton[4]:SetAttribute("macrotext", "/run PetBattleFrame.BottomFrame.SwitchPetButton:Click()")
692+
PetBattleButton[5]:SetAttribute("macrotext", "/run PetBattleFrame.BottomFrame.CatchButton:Click()")
693+
PetBattleButton[6]:SetAttribute("macrotext", "/run PetBattleFrame.BottomFrame.ForfeitButton:Click()") -- 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
694+
-------------------------------------------------------------------------------------------------------
695+
696+
-- Vehicle/Skyriding bar
697+
local VehicleBar = CreateFrame("Frame", nil, nil, "SecureHandlerAttributeTemplate")
698+
VehicleBar:SetAttribute("actionpage", 1)
699+
VehicleBar:Hide()
700+
701+
-- Creating buttons
702+
local VehicleButton = {}
703+
for i = 1, 12 do
704+
VehicleButton[i] = CreateFrame("Button", "GSE_VehicleButton" .. i, VehicleBar, "SecureActionButtonTemplate")
705+
local B = VehicleButton[i]
706+
B:Hide()
707+
B:SetID(i)
708+
B:SetAttribute("type", "action")
709+
B:SetAttribute("action", i)
710+
B:SetAttribute("useparent-actionpage", true)
711+
B:RegisterForClicks("AnyDown")
712+
end
713+
714+
-- Table that will store the keybinds for vehicles desired by the user
715+
716+
function GSE.UpdateVehicleBar()
717+
local tableval = {}
718+
for k, v in pairs(GSEOptions.SkyRidingBinds) do
719+
table.insert(tableval, k .. "\001" .. v)
720+
end
721+
722+
local executionString =
723+
"VehicleKeybindTable = newtable([=======[" ..
724+
string.join("]=======],[=======[", unpack(tableval)) ..
725+
"]=======])" ..
726+
[[
727+
VehicleKeybind = newtable()
728+
for _,v in ipairs(VehicleKeybindTable) do
729+
local x, y = strsplit("\001",v)
730+
VehicleKeybind[tonumber(x)] = y
731+
end
732+
733+
]]
734+
VehicleBar:Execute(executionString) -- Key: Button index / Value: Keybind
735+
end
736+
737+
GSE.UpdateVehicleBar()
738+
-- Triggers
739+
VehicleBar:SetAttribute(
740+
"_onattributechanged",
741+
[[
742+
-- Actionpage update
743+
if name == "page" then
744+
if HasVehicleActionBar() then self:SetAttribute("actionpage", GetVehicleBarIndex())
745+
elseif HasOverrideActionBar() then self:SetAttribute("actionpage", GetOverrideBarIndex())
746+
elseif HasBonusActionBar() then self:SetAttribute("actionpage", GetBonusBarIndex())
747+
else self:SetAttribute("actionpage", GetActionBarPage()) end
748+
749+
-- Settings binds of higher priority than the normal ones when the player enters a vehicle, to be able to use it
750+
elseif name == "vehicletype" then
751+
if value == "vehicle" then -- Vehicles/Skyriding
752+
for i = 1, 12 do
753+
if VehicleKeybind[i] then self:SetBindingClick(true, VehicleKeybind[i], "GSE_VehicleButton"..i) end
754+
end
755+
756+
elseif value == "petbattle" then -- Pet battle
757+
for i = 1, 6 do
758+
if VehicleKeybind[i] then self:SetBindingClick(true, VehicleKeybind[i], "GSE_PetBattleButton"..i) end
759+
end
760+
761+
elseif value == "none" then -- No vehicle, deleting vehicle binds
762+
self:ClearBindings()
763+
end
764+
end
765+
]]
766+
)
767+
768+
-- Actionpage trigger
769+
RegisterAttributeDriver(
770+
VehicleBar,
771+
"page",
772+
"[vehicleui] A;" ..
773+
"[possessbar] B;" ..
774+
"[overridebar] C;" ..
775+
"[bonusbar:5] D;" .. -- Skyriding
776+
"E"
777+
)
778+
779+
-- Vehicle trigger
780+
RegisterAttributeDriver(
781+
VehicleBar,
782+
"vehicletype",
783+
"[vehicleui][possessbar][overridebar][bonusbar:5] vehicle;" .. "[petbattle] petbattle;" .. "none"
784+
) -- 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.
785+
----------------------------------------------------------------------------------------------------------------------
786+
787+
--[[ Events ]]
788+
function GSE:PET_BATTLE_OPENING_START()
789+
VehicleBar:Execute(
790+
[[
791+
for i = 1, 6 do
792+
if VehicleKeybind[i] then self:SetBindingClick(true, VehicleKeybind[i], "GSE_PetBattleButton"..i) end
793+
end
794+
]]
795+
)
796+
end
797+
798+
-- Event PET_BATTLE_CLOSE
799+
-- Triggers when a pet battle starts. Used only in MoP because it doesn't have the [petbattle]
800+
-- macro condition to detect pet battles from the Restricted Environment like post-MoP expansions.
801+
function GSE:PET_BATTLE_CLOSE()
802+
VehicleBar:Execute([[ self:ClearBindings() ]])
803+
end
804+
GSE:RegisterEvent("PET_BATTLE_OPENING_START")
805+
GSE:RegisterEvent("PET_BATTLE_CLOSE")
806+
end

0 commit comments

Comments
 (0)