mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 03:00:58 -06:00
@@ -1,18 +1,23 @@
|
||||
local bindKeys = function(t)
|
||||
for i, k in ipairs(t) do
|
||||
local bindFunction
|
||||
local bindKeys = function(t, ignoreWarning)
|
||||
ignoreWarning = ignoreWarning or false
|
||||
for _, k in ipairs(t) do
|
||||
assert(k.Key, 'No key provided')
|
||||
assert(k.Command, 'No command provided for key ' .. k.Key)
|
||||
|
||||
k.Name = k.Name or k.Key
|
||||
k.GuiPath = k.GuiPath or ''
|
||||
|
||||
local currentKey = openspace.getKeyBinding(k.Key)
|
||||
if (next(currentKey) ~= nil) and (not ignoreWarning) then
|
||||
|
||||
openspace.printWarning('New keybind for "' .. k.Key .. '" is added, but a previous keybind already existed. If you want to silence this warning, pass "true", to this call to bindKeys')
|
||||
end
|
||||
|
||||
if k.Local then
|
||||
bindFunction = openspace.bindKeyLocal
|
||||
openspace.bindKeyLocal(k.Key, k.Command, k.Documentation, k.Name, k.GuiPath)
|
||||
else
|
||||
bindFunction = openspace.bindKey
|
||||
openspace.bindKey(k.Key, k.Command, k.Documentation, k.Name, k.GuiPath)
|
||||
end
|
||||
if k.Name == nil then
|
||||
k.Name = k.Key
|
||||
end
|
||||
if k.GuiPath == nil then
|
||||
k.GuiPath = ""
|
||||
end
|
||||
bindFunction(k.Key, k.Command, k.Documentation, k.Name, k.GuiPath)
|
||||
end
|
||||
end
|
||||
asset.export("bindKeys", bindKeys)
|
||||
@@ -21,12 +26,8 @@ local unbindKeys = function(keys)
|
||||
-- We check against k and k.Key to provide compatability
|
||||
-- for both calls with the same table that goes to bindKeys
|
||||
-- as well as the return values from setDeltaTimeKeys
|
||||
for i, k in ipairs(keys) do
|
||||
if k.Key then
|
||||
openspace.clearKey(k.Key)
|
||||
else
|
||||
openspace.clearKey(k)
|
||||
end
|
||||
for _, k in ipairs(keys) do
|
||||
openspace.clearKey(k.Key or k)
|
||||
end
|
||||
end
|
||||
asset.export("unbindKeys", unbindKeys)
|
||||
|
||||
Submodule ext/ghoul updated: 810483aa96...629a0c09be
@@ -186,7 +186,7 @@ scripting::LuaLibrary KeybindingManager::luaLibrary() {
|
||||
"bindKey",
|
||||
&luascriptfunctions::bindKey,
|
||||
{},
|
||||
"string, string [,string]",
|
||||
"string, string [, string]",
|
||||
"Binds a key by name to a lua string command to execute both locally "
|
||||
"and to broadcast to clients if this is the host of a parallel session. "
|
||||
"The first argument is the key, the second argument is the Lua command "
|
||||
@@ -197,7 +197,7 @@ scripting::LuaLibrary KeybindingManager::luaLibrary() {
|
||||
"bindKeyLocal",
|
||||
&luascriptfunctions::bindKeyLocal,
|
||||
{},
|
||||
"string, string [,string]",
|
||||
"string, string [, string]",
|
||||
"Binds a key by name to a lua string command to execute only locally. "
|
||||
"The first argument is the key, the second argument is the Lua command "
|
||||
"that is to be executed, and the optional third argument is a human "
|
||||
@@ -211,7 +211,6 @@ scripting::LuaLibrary KeybindingManager::luaLibrary() {
|
||||
"Returns a list of information about the keybindings for the provided "
|
||||
"key. Each element in the list is a table describing the 'Command' that "
|
||||
"was bound and whether it was a 'Remote' script or not."
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user