Files

39 lines
1.6 KiB
Lua

-- OctoTextSize: addon-local factory; Blizzard CreateFrame is unchanged.
local CreateFrame = OctoTextSize and OctoTextSize.WrapFactory(CreateFrame) or CreateFrame
-- #125: with the Modern experience preset the 70334 engine re-applies the preset's default key bindings
-- right after PLAYER_ENTERING_WORLD (one UPDATE_BINDINGS, no Lua call), on top of the bindings it has just
-- loaded from the saved cache. Every saved change to a key that has a preset default (Q, E, A, D...) is lost
-- on each login. LoadBindings(current set) rebuilds preset defaults + the saved changes, so reload once after
-- that reset.
local f = CreateFrame("Frame")
local armed = false
local function restore()
if InCombatLockdown() then
f:RegisterEvent("PLAYER_REGEN_ENABLED")
return
end
local set = GetCurrentBindingSet()
if set == 1 or set == 2 then LoadBindings(set) end
end
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:SetScript("OnEvent", function(self, event)
if event == "PLAYER_ENTERING_WORLD" then
armed = true
self:RegisterEvent("UPDATE_BINDINGS")
-- No preset reset within a few seconds (e.g. Classic preset): stop waiting.
C_Timer.After(5, function()
if armed then armed = false self:UnregisterEvent("UPDATE_BINDINGS") end
end)
elseif event == "UPDATE_BINDINGS" then
if not armed then return end
armed = false
self:UnregisterEvent("UPDATE_BINDINGS")
restore()
elseif event == "PLAYER_REGEN_ENABLED" then
self:UnregisterEvent("PLAYER_REGEN_ENABLED")
restore()
end
end)