From cabb8cb55bd8d73b430fea538d7a06db4805496d Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 18 Jul 2024 11:11:26 +0200 Subject: [PATCH] Add Down and Up keybinds to set the time to realtime and "now" respectively (closes #3275) --- data/assets/default_keybindings.asset | 60 +++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/data/assets/default_keybindings.asset b/data/assets/default_keybindings.asset index 66446dfd25..f12f872467 100644 --- a/data/assets/default_keybindings.asset +++ b/data/assets/default_keybindings.asset @@ -158,6 +158,42 @@ local PreviousDeltaStepImmediate = { IsLocal = true } +local RealTimeDeltaStepInterpolate = { + Identifier = "os.RealTimeDeltaStepInterpolate", + Name = "Reset the simulation time to realtime (interpolate)", + Command = "openspace.time.interpolateDeltaTime(1)", + Documentation = "Smoothly interpolate the simulation speed to match real-time speed", + GuiPath = "/Time/Simulation Speed", + IsLocal = true +} + +local RealTimeDeltaStepImmediate = { + Identifier = "os.RealTimeDeltaStepImmediate", + Name = "Reset the simulation time to realtime (immediate)", + Command = "openspace.time.setDeltaTime(1)", + Documentation = "Immediately set the simulation speed to match real-time speed", + GuiPath = "/Time/Simulation Speed", + IsLocal = true +} + +local DateToNowInterpolate = { + Identifier = "os.DateToNowInterpolate", + Name = "Set the in-game time to now (interpolate)", + Command = "openspace.time.interpolateTime(openspace.time.currentWallTime())", + Documentation = "Immediately set the current in-game time to the 'now' time", + GuiPath = "/Time/Simulation Speed", + IsLocal = true +} + +local DateToNowImmediate = { + Identifier = "os.DateToNowImmediate", + Name = "Set the in-game time to now (immediate)", + Command = "openspace.time.setTime(openspace.time.currentWallTime())", + Documentation = "Smoothly interpolate the current in-game time to the 'now' time", + GuiPath = "/Time/Simulation Speed", + IsLocal = true +} + local ReloadGui = { Identifier = "os.ReloadGui", Name = "Reload GUI", @@ -217,6 +253,18 @@ asset.onInitialize(function() openspace.action.registerAction(PreviousDeltaStepImmediate) openspace.bindKey("Shift+Left", PreviousDeltaStepImmediate.Identifier) + openspace.action.registerAction(RealTimeDeltaStepInterpolate) + openspace.bindKey("Down", RealTimeDeltaStepInterpolate.Identifier) + + openspace.action.registerAction(RealTimeDeltaStepImmediate) + openspace.bindKey("Shift+Down", RealTimeDeltaStepImmediate.Identifier) + + openspace.action.registerAction(DateToNowInterpolate) + openspace.bindKey("Up", DateToNowInterpolate.Identifier) + + openspace.action.registerAction(DateToNowImmediate) + openspace.bindKey("Shift+Up", DateToNowImmediate.Identifier) + openspace.action.registerAction(ReloadGui) openspace.bindKey("F5", ReloadGui.Identifier) end) @@ -225,6 +273,18 @@ asset.onDeinitialize(function() openspace.clearKey("F5") openspace.action.removeAction(ReloadGui) + openspace.clearKey("Shift+Up") + openspace.actiion.removeAction(DateToNowImmediate) + + openspace.clearKey("Up") + openspace.actiion.removeAction(DateToNowInterpolate) + + openspace.clearKey("Shift+Down") + openspace.action.removeAction(RealTimeDeltaStepImmediate) + + openspace.clearKey("Down") + openspace.action.removeAction(RealTimeDeltaStepInterpolate) + openspace.clearKey("Shift+Left") openspace.action.removeAction(PreviousDeltaStepImmediate)