Slight refactoring and moved camera hotkeys to a separate subrouting

This commit is contained in:
Imbus 2023-10-29 11:37:41 +01:00
parent 243e1e83e8
commit ded727b9d7

View file

@ -8,10 +8,6 @@ local myBinds = {
["F1"] = "TOGGLEBACKPACK", ["F1"] = "TOGGLEBACKPACK",
["F2"] = "TOGGLECHARACTER0", ["F2"] = "TOGGLECHARACTER0",
-- Remove zoom from mousewheel
["-"] = "CAMERAZOOMOUT",
["+"] = "CAMERAZOOMIN",
-- Action Bar 1 -- Action Bar 1
["1"] = "ACTIONBUTTON1", ["1"] = "ACTIONBUTTON1",
["2"] = "ACTIONBUTTON2", ["2"] = "ACTIONBUTTON2",
@ -83,6 +79,13 @@ local myBinds = {
["CTRL-6"] = "MULTIACTIONBAR4BUTTON12", ["CTRL-6"] = "MULTIACTIONBAR4BUTTON12",
} }
local cameraBinds = {
-- Remove zoom from mousewheel
["-"] = "CAMERAZOOMOUT",
["+"] = "CAMERAZOOMIN",
}
-- Unsets a binding, if it exists
local function unsetBinding(action) local function unsetBinding(action)
local key1, key2 = GetBindingKey(action); local key1, key2 = GetBindingKey(action);
if key1 then if key1 then
@ -93,6 +96,7 @@ local function unsetBinding(action)
end end
end end
-- Same as SetBinding, but removes the old binding first
local function setBindingRM(key, action) local function setBindingRM(key, action)
unsetBinding(action); unsetBinding(action);
if SetBinding(key, action) then if SetBinding(key, action) then
@ -102,12 +106,11 @@ local function setBindingRM(key, action)
end end
end end
local function applyBindingSet(set)
local function setAllBinds() for key, action in pairs(set) do
for key, action in pairs(myBinds) do
setBindingRM(key, action) setBindingRM(key, action)
end end
print("Bindings set. Run /binds permanent to save them permanently.") print("Bindings set. Dont forget to reload your UI.")
end end
local function enableBars() local function enableBars()
@ -122,22 +125,18 @@ local function enableBars()
SetCVar("countdownForCooldowns", 1); SetCVar("countdownForCooldowns", 1);
SetCVar("autoLootDefault", 1); SetCVar("autoLootDefault", 1);
SetCVar("cameraDistanceMaxZoomFactor", 2); SetCVar("cameraDistanceMaxZoomFactor", 2);
SetCVar("instantQuestText", 1);
end end
local function BindsHandler(msg, editbox) local function BindsHandler(msg, editbox)
if msg == "reset" then
for key, action in pairs(myBinds) do
unsetBinding(action)
end
print("Bindings reset. Run /binds to set them again.")
return
end
if msg == "" then if msg == "" then
setAllBinds() applyBindingSet(myBinds)
enableBars() enableBars()
SaveBindings(1)
return
end end
if msg == "camera" then
applyBindingSet(cameraBinds)
end
SaveBindings(1)
end end
-- Register the /hello command -- Register the /hello command