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