Files
OpenSpace/data/assets/util/default_keybindings.asset
T
Alexander Bock 8b74493d96 Removing the asset_helper file (#1868)
- Remove the asset_helper file and call the onInitialize and onDeinitialize functions directly
 - Small compile fix on Windows
 - Removes the need for the registerIdentifierWithMeta function by automatically doing that for all asset.export statements
 - Allow the passing of either identifiers (as before) or entire tables to the removeSceneGraphNode, removeScreenSpaceRenderable, deleteLayer, removeAction, and export methods. In that case, the Identifier key from the table is extracted and used instead
2022-02-01 23:44:36 +01:00

214 lines
6.9 KiB
Lua

local propertyHelper = asset.require("./property_helper")
local toggle_native_ui = {
Identifier = "os_default.toggle_native_ui",
Name = "Show Native GUI",
Command = propertyHelper.invert("Modules.ImGUI.Main.Enabled"),
Documentation = "Shows or hides the native UI",
GuiPath = "/Native GUI",
IsLocal = true,
Key = "F1"
}
local toggle_shutdown = {
Identifier = "os_default.toggle_shutdown",
Name = "Toggle Shutdown",
Command = "openspace.toggleShutdown()",
Documentation = "Toggles the shutdown that will stop OpenSpace after a grace period. Press again to cancel the shutdown during this period.",
IsLocal = true,
Key = "ESC"
}
local take_screenshot = {
Identifier = "os_default.take_screenshot",
Name = "Take Screenshot",
Command = "openspace.takeScreenshot()",
Documentation = "Saves the contents of the screen to a file in the ${SCREENSHOTS} directory.",
GuiPath = "/Rendering",
IsLocal = true,
Key = "F12"
}
local toggle_pause_interpolated = {
Identifier = "os_default.toggle_pause_interpolated",
Name = "Toggle Pause (Interpolated)",
Command = "openspace.time.pauseToggleViaKeyboard()",
Documentation = "Smoothly starts and stops the simulation time.",
GuiPath = "/Simulation Speed",
IsLocal = true,
Key = "SPACE"
}
local toggle_pause_immediate = {
Identifier = "os_default.toggle_pause_immediate",
Name = "Toggle Pause (Immediate)",
Command = "openspace.time.togglePause()",
Documentation = "Immediately starts and stops the simulation time.",
GuiPath = "/Simulation Speed",
IsLocal = true,
Key = "Shift+SPACE"
}
local toggle_rotation_friction = {
Identifier = "os_default.toggle_rotation_friction",
Name = "Toggle Rotation friction",
Command = propertyHelper.invert("NavigationHandler.OrbitalNavigator.Friction.RotationalFriction"),
Documentation = "Toggles the rotational friction of the camera. If it is disabled, the camera rotates around the focus object indefinitely.",
GuiPath = "/Navigation",
IsLocal = false,
Key = "f"
}
local toggle_zoom_friction = {
Identifier = "os_default.toggle_zoom_friction",
Name = "Toggle Zoom Friction",
Command = propertyHelper.invert("NavigationHandler.OrbitalNavigator.Friction.ZoomFriction"),
Documentation = "Toggles the zoom friction of the camera. If it is disabled, the camera rises up from or closes in towards the focus object indefinitely.",
GuiPath = "/Navigation",
IsLocal = false,
Key = "Shift+f"
}
local toggle_roll_friction = {
Identifier = "os_default.toggle_roll_friction",
Name = "Toggle Roll Friction",
Command = propertyHelper.invert("NavigationHandler.OrbitalNavigator.Friction.RollFriction"),
Documentation = "Toggles the roll friction of the camera. If it is disabled, the camera rolls around its own axis indefinitely.",
GuiPath = "/Navigation",
IsLocal = false,
Key = "Ctrl+f"
}
local fade_to_black = {
Identifier = "os_default.fade_to_black",
Name = "Fade to/from black",
Command = [[
if openspace.getPropertyValue("RenderEngine.BlackoutFactor") > 0.5 then
openspace.setPropertyValueSingle("RenderEngine.BlackoutFactor", 0.0, 3)
else
openspace.setPropertyValueSingle("RenderEngine.BlackoutFactor", 1.0, 3)
end
]],
Documentation = "Toggles the fade to black within 3 seconds or shows the rendering after 3 seconds.",
GuiPath = "/Rendering",
IsLocal = false,
Key = "w"
}
local toggle_main_gui = {
Identifier = "os_default.toggle_main_gui",
Name = "Toggle main GUI",
Command = propertyHelper.invert("Modules.CefWebGui.Visible"),
Documentation = "Toggles the main GUI",
GuiPath = "/GUI",
IsLocal = true,
Key = "Tab"
}
local toggle_overlays = {
Identifier = "os_default.toggle_overlays",
Name = "Toggle dashboard and overlays",
Command =
[[local isEnabled = openspace.getPropertyValue("Dashboard.IsEnabled");
openspace.setPropertyValueSingle("Dashboard.IsEnabled", not isEnabled);
openspace.setPropertyValueSingle("RenderEngine.ShowLog", not isEnabled);
openspace.setPropertyValueSingle("RenderEngine.ShowVersion", not isEnabled);
openspace.setPropertyValueSingle("RenderEngine.ShowCamera", not isEnabled)]],
Documentation = "Toggles the dashboard and overlays",
GuiPath = "/GUI",
IsLocal = true,
Key = "Shift+Tab"
}
local toggle_master_rendering = {
Identifier = "os_default.toggle_master_rendering",
Name = "Toggle rendering on master",
Command = propertyHelper.invert("RenderEngine.DisableMasterRendering"),
Documentation = "Toggles the rendering on master",
GuiPath = "/Rendering",
IsLocal = true,
Key = "Alt+R"
}
local next_delta_step_interpolate = {
Identifier = "os_default.next_delta_step_interpolate",
Name = "Next Delta Time Step (Interpolate)",
Command = "openspace.time.interpolateNextDeltaTimeStep()",
Documentation = "Smoothly interpolates the simulation speed to the next delta time step, if one exists.",
GuiPath = "/Simulation Speed",
IsLocal = true,
Key = "Right"
}
local next_delta_step_immediate = {
Identifier = "os_default.next_delta_step_immediate",
Name = "Next Delta Time Step (Immediate)",
Command = "openspace.time.setNextDeltaTimeStep()",
Documentation = "Immediately set the simulation speed to the next delta time step, if one exists.",
GuiPath = "/Simulation Speed",
IsLocal = true,
Key = "Shift+Right"
}
local previous_delta_step_interpolate = {
Identifier = "os_default.previous_delta_step_interpolate",
Name = "Previous Delta Time Step (Interpolate)",
Command = "openspace.time.interpolatePreviousDeltaTimeStep()",
Documentation = "Smoothly interpolates the simulation speed to the previous delta time step, if one exists.",
GuiPath = "/Simulation Speed",
IsLocal = true,
Key = "Left"
}
local previous_delta_step_immediate = {
Identifier = "os_default.previous_delta_step_immediate",
Name = "Previous Delta Time Step (Immediate)",
Command = "openspace.time.setPreviousDeltaTimeStep()",
Documentation = "Immediately set the simulation speed to the previous delta time step, if one exists.",
GuiPath = "/Simulation Speed",
IsLocal = true,
Key = "Shift+Left"
}
local Actions = {
toggle_native_ui,toggle_shutdown,take_screenshot,toggle_pause_interpolated,toggle_pause_immediate,
toggle_rotation_friction,toggle_zoom_friction,toggle_roll_friction,fade_to_black,
toggle_main_gui,toggle_overlays,toggle_master_rendering,next_delta_step_interpolate,
next_delta_step_immediate,previous_delta_step_interpolate,previous_delta_step_immediate
}
asset.onInitialize(function()
for _, action in ipairs(Actions) do
openspace.action.registerAction(action)
openspace.bindKey(action.Key, action.Identifier)
end
-- The take screenshot function is a bit special since we want to bind two keys to that action
openspace.bindKey("PRINT_SCREEN", take_screenshot.Identifier)
end)
asset.onDeinitialize(function ()
openspace.clearKey("PRINT_SCREEN")
for _, action in ipairs(Actions) do
openspace.action.removeAction(action)
openspace.clearKey(action.Key)
end
end)