From 26503385292c310f96f1668639b9dcbbf02277dd Mon Sep 17 00:00:00 2001 From: taroeld Date: Fri, 12 Apr 2024 08:44:53 +0200 Subject: [PATCH 1/6] feat: add continuous key calls --- msu/systems/keybinds/keybind_sq.nut | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/msu/systems/keybinds/keybind_sq.nut b/msu/systems/keybinds/keybind_sq.nut index f4861ec9c..9ec1f6f2c 100644 --- a/msu/systems/keybinds/keybind_sq.nut +++ b/msu/systems/keybinds/keybind_sq.nut @@ -3,6 +3,7 @@ Function = null; State = null; KeyState = null; + CallContinuously = false; BypassInputDenied = false; constructor( _modID, _id, _keyCombinations, _state, _function, _name = null, _keyState = null) @@ -23,6 +24,12 @@ return this; } + function setCallContinuously(_bool) + { + this.CallContinuously = _bool; + return this; + } + function getState() { return this.State; @@ -35,7 +42,7 @@ function callOnKeyState( _keyState ) { - return (_keyState & this.KeyState) != 0; + return (this.CallContinuously && this.KeyState == ::MSU.Key.KeyState.Continuous && _keyState == ::MSU.Key.KeyState.Continuous) || ((_keyState & this.KeyState) != 0); } function getKeyState() From 609e9397acf749689ba41489e1ad58b11001ab4b Mon Sep 17 00:00:00 2001 From: taroeld Date: Fri, 12 Apr 2024 08:45:10 +0200 Subject: [PATCH 2/6] feat: add camera keybinds --- msu/vanilla_mod/vanilla_keybinds.nut | 127 ++++++++++++++++++++++----- 1 file changed, 104 insertions(+), 23 deletions(-) diff --git a/msu/vanilla_mod/vanilla_keybinds.nut b/msu/vanilla_mod/vanilla_keybinds.nut index c4da01083..194b70a06 100644 --- a/msu/vanilla_mod/vanilla_keybinds.nut +++ b/msu/vanilla_mod/vanilla_keybinds.nut @@ -260,29 +260,110 @@ local function isCampfireScreen() } }, "Toggle Forced Attack", ::MSU.Key.KeyState.Release | ::MSU.Key.KeyState.Press); -// World Continuous, doesn't work cuz we handle keybinds differently from vanilla ): - -// ::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_left", "left/a/q", ::MSU.Key.State.World, function() -// { -// if (::Settings.getTempGameplaySettings().CameraLocked) -// { -// this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); -// } - -// ::World.getCamera().move(-1500.0 * ::Time.getDelta() * ::Math.maxf(1.0, ::World.getCamera().Zoom * 0.66), 0); -// return true; -// }, "Move Camera Up", null, ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press); - -// ::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_right", "right/d", ::MSU.Key.State.World, function() -// { -// if (::Settings.getTempGameplaySettings().CameraLocked) -// { -// this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); -// } - -// ::World.getCamera().move(1500.0 * ::Time.getDelta() * ::Math.maxf(1.0, ::World.getCamera().Zoom * 0.66), 0); -// return true; -// }, "Move Camera Right", null, ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press); +//Camera Left + +::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_left", "left/a/q", ::MSU.Key.State.World, function() +{ + if (::Settings.getTempGameplaySettings().CameraLocked) + { + this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); + } + + ::World.getCamera().move(-1500.0 * ::Time.getDelta() * ::Math.maxf(1.0, ::World.getCamera().Zoom * 0.66), 0); + return true; +}, "Move Camera Up", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); + +//Camera Right + +::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_right", "right/d", ::MSU.Key.State.World, function() +{ + if (::Settings.getTempGameplaySettings().CameraLocked) + { + this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); + } + + ::World.getCamera().move(1500.0 * ::Time.getDelta() * ::Math.maxf(1.0, ::World.getCamera().Zoom * 0.66), 0); + return true; +}, "Move Camera Right", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); + +//Camera Up + +::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_up", "up/w/z", ::MSU.Key.State.World, function() +{ + if (::Settings.getTempGameplaySettings().CameraLocked) + { + this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); + } + + ::World.getCamera().move(0, 1500.0 * this.Time.getDelta() * this.Math.maxf(1.0, this.World.getCamera().Zoom * 0.66)); + return true; +}, "Move Camera Up", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); + +//Camera Down + +::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_down", "down/s", ::MSU.Key.State.World, function() +{ + if (::Settings.getTempGameplaySettings().CameraLocked) + { + this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); + } + + this.World.getCamera().move(0, -1500.0 * this.Time.getDelta() * this.Math.maxf(1.0, this.World.getCamera().Zoom * 0.66)); + return true; +}, "Move Camera Down", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); + +//Camera Top Left + +::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_leftup", "left+up/a+w", ::MSU.Key.State.World, function() +{ + if (::Settings.getTempGameplaySettings().CameraLocked) + { + this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); + } + + ::World.getCamera().move(-1500.0 * ::Time.getDelta() * ::Math.maxf(1.0, ::World.getCamera().Zoom * 0.66), 1500.0 * this.Time.getDelta() * this.Math.maxf(1.0, this.World.getCamera().Zoom * 0.66)); + return true; +}, "Move Camera Top Left", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); + +//Camera Bottom Left + +::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_leftdown", "left+down/a+s", ::MSU.Key.State.World, function() +{ + if (::Settings.getTempGameplaySettings().CameraLocked) + { + this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); + } + + ::World.getCamera().move(-1500.0 * ::Time.getDelta() * ::Math.maxf(1.0, ::World.getCamera().Zoom * 0.66), -1500.0 * this.Time.getDelta() * this.Math.maxf(1.0, this.World.getCamera().Zoom * 0.66)); + return true; +}, "Move Camera Bottom Left", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); + +//Camera Top Right + +::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_rightup", "right+up/d+w", ::MSU.Key.State.World, function() +{ + if (::Settings.getTempGameplaySettings().CameraLocked) + { + this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); + } + + ::World.getCamera().move(1500.0 * ::Time.getDelta() * ::Math.maxf(1.0, ::World.getCamera().Zoom * 0.66), 1500.0 * this.Time.getDelta() * this.Math.maxf(1.0, this.World.getCamera().Zoom * 0.66)); + return true; +}, "Move Camera Top Right", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); + +//Camera Bottom Right + +::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_rightdown", "right+down/d+s", ::MSU.Key.State.World, function() +{ + if (::Settings.getTempGameplaySettings().CameraLocked) + { + this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); + } + + ::World.getCamera().move(1500.0 * ::Time.getDelta() * ::Math.maxf(1.0, ::World.getCamera().Zoom * 0.66), -1500.0 * this.Time.getDelta() * this.Math.maxf(1.0, this.World.getCamera().Zoom * 0.66)); + return true; +}, "Move Camera Bottom Right", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); + //-------------------------------------------TACTICAL ONLY--------------------------------------------------------------------------------- From 45caa6f44cc0dd54d2d2e4555a74cafd124a99c3 Mon Sep 17 00:00:00 2001 From: taroeld Date: Fri, 12 Apr 2024 08:45:20 +0200 Subject: [PATCH 3/6] fix: spamming esc in tactical breaks the game --- msu/vanilla_mod/vanilla_keybinds.nut | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msu/vanilla_mod/vanilla_keybinds.nut b/msu/vanilla_mod/vanilla_keybinds.nut index 194b70a06..8487492e1 100644 --- a/msu/vanilla_mod/vanilla_keybinds.nut +++ b/msu/vanilla_mod/vanilla_keybinds.nut @@ -66,7 +66,7 @@ local function isCampfireScreen() { if (!this.m.MenuStack.hasBacksteps() || this.m.TacticalMenuScreen.isVisible()) { - if (this.toggleMenuScreen()) + if (!this.m.TacticalMenuScreen.isAnimating() && this.toggleMenuScreen()) { return true; } From 87f06c204de4add596606397c1b0e1436acbc5a0 Mon Sep 17 00:00:00 2001 From: taroeld Date: Sat, 13 Apr 2024 09:20:28 +0200 Subject: [PATCH 4/6] feat: add trigger delay to continuous keybinds --- msu/systems/keybinds/keybind_sq.nut | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/msu/systems/keybinds/keybind_sq.nut b/msu/systems/keybinds/keybind_sq.nut index 9ec1f6f2c..96377692c 100644 --- a/msu/systems/keybinds/keybind_sq.nut +++ b/msu/systems/keybinds/keybind_sq.nut @@ -4,6 +4,8 @@ State = null; KeyState = null; CallContinuously = false; + TriggerDelay = null; + NextCallTime = null; BypassInputDenied = false; constructor( _modID, _id, _keyCombinations, _state, _function, _name = null, _keyState = null) @@ -24,9 +26,10 @@ return this; } - function setCallContinuously(_bool) + function setCallContinuously(_bool, _triggerDelay = null) { this.CallContinuously = _bool; + this.TriggerDelay = _triggerDelay; return this; } @@ -40,9 +43,16 @@ return (this.State & _state) != 0; } + function checkContinuousCall(_keyState) + { + return ((this.KeyState & ::MSU.Key.KeyState.Continuous) != 0) && ((this.NextCallTime == null) || (::Time.getRealTimeF() > this.NextCallTime)); + } + function callOnKeyState( _keyState ) { - return (this.CallContinuously && this.KeyState == ::MSU.Key.KeyState.Continuous && _keyState == ::MSU.Key.KeyState.Continuous) || ((_keyState & this.KeyState) != 0); + if (this.CallContinuously && _keyState == ::MSU.Key.KeyState.Continuous) + return this.checkContinuousCall(_keyState) + return (_keyState & this.KeyState) != 0; } function getKeyState() @@ -57,7 +67,10 @@ function call( _environment ) { - return this.Function.call(_environment); + local ret = this.Function.call(_environment); + if (ret && this.CallContinuously && this.TriggerDelay != null) + this.NextCallTime = ::Time.getRealTimeF() + this.TriggerDelay; + return ret; } function tostring() From 1af15091ebaec0f5f4e7df7b0dc4f2aa661e22d0 Mon Sep 17 00:00:00 2001 From: taroeld Date: Sat, 13 Apr 2024 09:25:11 +0200 Subject: [PATCH 5/6] feat: improve world keybinds and add tactical camera keybinds --- msu/vanilla_mod/vanilla_keybinds.nut | 146 ++++++++++++++++----------- 1 file changed, 86 insertions(+), 60 deletions(-) diff --git a/msu/vanilla_mod/vanilla_keybinds.nut b/msu/vanilla_mod/vanilla_keybinds.nut index 8487492e1..561030e8c 100644 --- a/msu/vanilla_mod/vanilla_keybinds.nut +++ b/msu/vanilla_mod/vanilla_keybinds.nut @@ -260,108 +260,71 @@ local function isCampfireScreen() } }, "Toggle Forced Attack", ::MSU.Key.KeyState.Release | ::MSU.Key.KeyState.Press); -//Camera Left -::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_left", "left/a/q", ::MSU.Key.State.World, function() +local function moveCameraWorld(_x, _y) { if (::Settings.getTempGameplaySettings().CameraLocked) { this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); } - ::World.getCamera().move(-1500.0 * ::Time.getDelta() * ::Math.maxf(1.0, ::World.getCamera().Zoom * 0.66), 0); + ::World.getCamera().move(_x * ::Time.getDelta() * ::Math.maxf(1.0, ::World.getCamera().Zoom * 0.66), _y * ::Time.getDelta() * ::Math.maxf(1.0, ::World.getCamera().Zoom * 0.66)); return true; +} +//Camera Left + +::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_left", "left/a/q", ::MSU.Key.State.World, function() +{ + return moveCameraWorld(-1500, 0); }, "Move Camera Up", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); //Camera Right ::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_right", "right/d", ::MSU.Key.State.World, function() { - if (::Settings.getTempGameplaySettings().CameraLocked) - { - this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); - } - - ::World.getCamera().move(1500.0 * ::Time.getDelta() * ::Math.maxf(1.0, ::World.getCamera().Zoom * 0.66), 0); - return true; + return moveCameraWorld(1500, 0); }, "Move Camera Right", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); //Camera Up ::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_up", "up/w/z", ::MSU.Key.State.World, function() { - if (::Settings.getTempGameplaySettings().CameraLocked) - { - this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); - } - - ::World.getCamera().move(0, 1500.0 * this.Time.getDelta() * this.Math.maxf(1.0, this.World.getCamera().Zoom * 0.66)); - return true; + return moveCameraWorld(0, 1500); }, "Move Camera Up", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); //Camera Down ::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_down", "down/s", ::MSU.Key.State.World, function() { - if (::Settings.getTempGameplaySettings().CameraLocked) - { - this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); - } - - this.World.getCamera().move(0, -1500.0 * this.Time.getDelta() * this.Math.maxf(1.0, this.World.getCamera().Zoom * 0.66)); - return true; + return moveCameraWorld(0, -1500); }, "Move Camera Down", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); -//Camera Top Left +// Camera Top Left -::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_leftup", "left+up/a+w", ::MSU.Key.State.World, function() +::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_leftup", "left+up/left+w/left+z/a+up/a+w/a+z/q+up/q+w/q+z", ::MSU.Key.State.World, function() { - if (::Settings.getTempGameplaySettings().CameraLocked) - { - this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); - } - - ::World.getCamera().move(-1500.0 * ::Time.getDelta() * ::Math.maxf(1.0, ::World.getCamera().Zoom * 0.66), 1500.0 * this.Time.getDelta() * this.Math.maxf(1.0, this.World.getCamera().Zoom * 0.66)); - return true; + return moveCameraWorld(-1500.0, 1500.0); }, "Move Camera Top Left", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); //Camera Bottom Left -::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_leftdown", "left+down/a+s", ::MSU.Key.State.World, function() +::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_leftdown", "left+down/left+s/a+down/a+s/q+down/q+s", ::MSU.Key.State.World, function() { - if (::Settings.getTempGameplaySettings().CameraLocked) - { - this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); - } - - ::World.getCamera().move(-1500.0 * ::Time.getDelta() * ::Math.maxf(1.0, ::World.getCamera().Zoom * 0.66), -1500.0 * this.Time.getDelta() * this.Math.maxf(1.0, this.World.getCamera().Zoom * 0.66)); - return true; + return moveCameraWorld(-1500.0, -1500.0); }, "Move Camera Bottom Left", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); //Camera Top Right -::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_rightup", "right+up/d+w", ::MSU.Key.State.World, function() +::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_rightup", "right+up/right+w/right+z/d+up/d+w/d+z", ::MSU.Key.State.World, function() { - if (::Settings.getTempGameplaySettings().CameraLocked) - { - this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); - } - - ::World.getCamera().move(1500.0 * ::Time.getDelta() * ::Math.maxf(1.0, ::World.getCamera().Zoom * 0.66), 1500.0 * this.Time.getDelta() * this.Math.maxf(1.0, this.World.getCamera().Zoom * 0.66)); - return true; + return moveCameraWorld(1500.0, 1500.0); }, "Move Camera Top Right", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); //Camera Bottom Right -::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_rightdown", "right+down/d+s", ::MSU.Key.State.World, function() +::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_rightdown", "right+down/right+s/d+down/d+s", ::MSU.Key.State.World, function() { - if (::Settings.getTempGameplaySettings().CameraLocked) - { - this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); - } - - ::World.getCamera().move(1500.0 * ::Time.getDelta() * ::Math.maxf(1.0, ::World.getCamera().Zoom * 0.66), -1500.0 * this.Time.getDelta() * this.Math.maxf(1.0, this.World.getCamera().Zoom * 0.66)); - return true; + return moveCameraWorld(1500.0, -1500.0); }, "Move Camera Bottom Right", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); @@ -437,7 +400,70 @@ local function isCampfireScreen() return true; }, "Focus on Active Character"); +local function moveCameraTactical(_x, _y) +{ + if (this.isInputLocked() || this.isInCharacterScreen() || this.m.IsDeveloperModeEnabled || this.m.MenuStack.hasBacksteps()) + { + return false; + } + + this.Tactical.getCamera().move(_x * this.Time.getDelta(), _y * this.Time.getDelta()); + return true; +} + +//Camera Left + +::MSU.Vanilla.Keybinds.addSQKeybind("tactical_moveCamera_left", "left/a/q", ::MSU.Key.State.Tactical, function() +{ + return moveCameraTactical(-1500, 0); +}, "Move Camera Up", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); + +//Camera Right + +::MSU.Vanilla.Keybinds.addSQKeybind("tactical_moveCamera_right", "right/d", ::MSU.Key.State.Tactical, function() +{ + return moveCameraTactical(1500, 0); +}, "Move Camera Right", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); + +//Camera Up + +::MSU.Vanilla.Keybinds.addSQKeybind("tactical_moveCamera_up", "up/w/z", ::MSU.Key.State.Tactical, function() +{ + return moveCameraTactical(0, 1500); +}, "Move Camera Up", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); + +//Camera Down + +::MSU.Vanilla.Keybinds.addSQKeybind("tactical_moveCamera_down", "down/s", ::MSU.Key.State.Tactical, function() +{ + return moveCameraTactical(0, -1500); +}, "Move Camera Down", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); + +// Camera Top Left + +::MSU.Vanilla.Keybinds.addSQKeybind("tactical_moveCamera_leftup", "left+up/left+w/left+z/a+up/a+w/a+z/q+up/q+w/q+z", ::MSU.Key.State.Tactical, function() +{ + return moveCameraTactical(-1500.0, 1500.0); +}, "Move Camera Top Left", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); + +//Camera Bottom Left + +::MSU.Vanilla.Keybinds.addSQKeybind("tactical_moveCamera_leftdown", "left+down/left+s/a+down/a+s/q+down/q+s", ::MSU.Key.State.Tactical, function() +{ + return moveCameraTactical(-1500.0, -1500.0); +}, "Move Camera Bottom Left", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); + +//Camera Top Right + +::MSU.Vanilla.Keybinds.addSQKeybind("tactical_moveCamera_rightup", "right+up/right+w/right+z/d+up/d+w/d+z", ::MSU.Key.State.Tactical, function() +{ + return moveCameraTactical(1500.0, 1500.0); +}, "Move Camera Top Right", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); + +//Camera Bottom Right + +::MSU.Vanilla.Keybinds.addSQKeybind("tactical_moveCamera_rightdown", "right+down/right+s/d+down/d+s", ::MSU.Key.State.Tactical, function() +{ + return moveCameraTactical(1500.0, -1500.0); +}, "Move Camera Bottom Right", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); -// ::MSU.System.Keybinds.registerMod(::MSU.ID) -// local jskeybind = ::MSU.Class.KeybindJS(::MSU.ID, "testkb", "ctrl+s"); -// ::MSU.System.Keybinds.add(jskeybind); From 5b207ba6fa6a2240c11a419410fbe9bde06d2f15 Mon Sep 17 00:00:00 2001 From: taroeld Date: Thu, 25 Apr 2024 06:06:47 +0200 Subject: [PATCH 6/6] Revert "feat: improve world keybinds and add tactical camera keybinds" This reverts commit 1af15091ebaec0f5f4e7df7b0dc4f2aa661e22d0. --- msu/vanilla_mod/vanilla_keybinds.nut | 159 +++++---------------------- 1 file changed, 26 insertions(+), 133 deletions(-) diff --git a/msu/vanilla_mod/vanilla_keybinds.nut b/msu/vanilla_mod/vanilla_keybinds.nut index 561030e8c..37719a4a8 100644 --- a/msu/vanilla_mod/vanilla_keybinds.nut +++ b/msu/vanilla_mod/vanilla_keybinds.nut @@ -260,73 +260,29 @@ local function isCampfireScreen() } }, "Toggle Forced Attack", ::MSU.Key.KeyState.Release | ::MSU.Key.KeyState.Press); - -local function moveCameraWorld(_x, _y) -{ - if (::Settings.getTempGameplaySettings().CameraLocked) - { - this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); - } - - ::World.getCamera().move(_x * ::Time.getDelta() * ::Math.maxf(1.0, ::World.getCamera().Zoom * 0.66), _y * ::Time.getDelta() * ::Math.maxf(1.0, ::World.getCamera().Zoom * 0.66)); - return true; -} -//Camera Left - -::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_left", "left/a/q", ::MSU.Key.State.World, function() -{ - return moveCameraWorld(-1500, 0); -}, "Move Camera Up", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); - -//Camera Right - -::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_right", "right/d", ::MSU.Key.State.World, function() -{ - return moveCameraWorld(1500, 0); -}, "Move Camera Right", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); - -//Camera Up - -::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_up", "up/w/z", ::MSU.Key.State.World, function() -{ - return moveCameraWorld(0, 1500); -}, "Move Camera Up", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); - -//Camera Down - -::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_down", "down/s", ::MSU.Key.State.World, function() -{ - return moveCameraWorld(0, -1500); -}, "Move Camera Down", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); - -// Camera Top Left - -::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_leftup", "left+up/left+w/left+z/a+up/a+w/a+z/q+up/q+w/q+z", ::MSU.Key.State.World, function() -{ - return moveCameraWorld(-1500.0, 1500.0); -}, "Move Camera Top Left", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); - -//Camera Bottom Left - -::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_leftdown", "left+down/left+s/a+down/a+s/q+down/q+s", ::MSU.Key.State.World, function() -{ - return moveCameraWorld(-1500.0, -1500.0); -}, "Move Camera Bottom Left", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); - -//Camera Top Right - -::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_rightup", "right+up/right+w/right+z/d+up/d+w/d+z", ::MSU.Key.State.World, function() -{ - return moveCameraWorld(1500.0, 1500.0); -}, "Move Camera Top Right", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); - -//Camera Bottom Right - -::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_rightdown", "right+down/right+s/d+down/d+s", ::MSU.Key.State.World, function() -{ - return moveCameraWorld(1500.0, -1500.0); -}, "Move Camera Bottom Right", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); - +// World Continuous, doesn't work cuz we handle keybinds differently from vanilla ): + +// ::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_left", "left/a/q", ::MSU.Key.State.World, function() +// { +// if (::Settings.getTempGameplaySettings().CameraLocked) +// { +// this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); +// } + +// ::World.getCamera().move(-1500.0 * ::Time.getDelta() * ::Math.maxf(1.0, ::World.getCamera().Zoom * 0.66), 0); +// return true; +// }, "Move Camera Up", null, ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press); + +// ::MSU.Vanilla.Keybinds.addSQKeybind("world_moveCamera_right", "right/d", ::MSU.Key.State.World, function() +// { +// if (::Settings.getTempGameplaySettings().CameraLocked) +// { +// this.m.WorldScreen.getTopbarOptionsModule().onCameraLockButtonPressed(); +// } + +// ::World.getCamera().move(1500.0 * ::Time.getDelta() * ::Math.maxf(1.0, ::World.getCamera().Zoom * 0.66), 0); +// return true; +// }, "Move Camera Right", null, ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press); //-------------------------------------------TACTICAL ONLY--------------------------------------------------------------------------------- @@ -400,70 +356,7 @@ local function moveCameraWorld(_x, _y) return true; }, "Focus on Active Character"); -local function moveCameraTactical(_x, _y) -{ - if (this.isInputLocked() || this.isInCharacterScreen() || this.m.IsDeveloperModeEnabled || this.m.MenuStack.hasBacksteps()) - { - return false; - } - - this.Tactical.getCamera().move(_x * this.Time.getDelta(), _y * this.Time.getDelta()); - return true; -} - -//Camera Left - -::MSU.Vanilla.Keybinds.addSQKeybind("tactical_moveCamera_left", "left/a/q", ::MSU.Key.State.Tactical, function() -{ - return moveCameraTactical(-1500, 0); -}, "Move Camera Up", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); - -//Camera Right - -::MSU.Vanilla.Keybinds.addSQKeybind("tactical_moveCamera_right", "right/d", ::MSU.Key.State.Tactical, function() -{ - return moveCameraTactical(1500, 0); -}, "Move Camera Right", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); - -//Camera Up - -::MSU.Vanilla.Keybinds.addSQKeybind("tactical_moveCamera_up", "up/w/z", ::MSU.Key.State.Tactical, function() -{ - return moveCameraTactical(0, 1500); -}, "Move Camera Up", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); - -//Camera Down - -::MSU.Vanilla.Keybinds.addSQKeybind("tactical_moveCamera_down", "down/s", ::MSU.Key.State.Tactical, function() -{ - return moveCameraTactical(0, -1500); -}, "Move Camera Down", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); - -// Camera Top Left - -::MSU.Vanilla.Keybinds.addSQKeybind("tactical_moveCamera_leftup", "left+up/left+w/left+z/a+up/a+w/a+z/q+up/q+w/q+z", ::MSU.Key.State.Tactical, function() -{ - return moveCameraTactical(-1500.0, 1500.0); -}, "Move Camera Top Left", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); - -//Camera Bottom Left - -::MSU.Vanilla.Keybinds.addSQKeybind("tactical_moveCamera_leftdown", "left+down/left+s/a+down/a+s/q+down/q+s", ::MSU.Key.State.Tactical, function() -{ - return moveCameraTactical(-1500.0, -1500.0); -}, "Move Camera Bottom Left", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); - -//Camera Top Right - -::MSU.Vanilla.Keybinds.addSQKeybind("tactical_moveCamera_rightup", "right+up/right+w/right+z/d+up/d+w/d+z", ::MSU.Key.State.Tactical, function() -{ - return moveCameraTactical(1500.0, 1500.0); -}, "Move Camera Top Right", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); - -//Camera Bottom Right - -::MSU.Vanilla.Keybinds.addSQKeybind("tactical_moveCamera_rightdown", "right+down/right+s/d+down/d+s", ::MSU.Key.State.Tactical, function() -{ - return moveCameraTactical(1500.0, -1500.0); -}, "Move Camera Bottom Right", ::MSU.Key.KeyState.Continuous | ::MSU.Key.KeyState.Press).setCallContinuously(true); +// ::MSU.System.Keybinds.registerMod(::MSU.ID) +// local jskeybind = ::MSU.Class.KeybindJS(::MSU.ID, "testkb", "ctrl+s"); +// ::MSU.System.Keybinds.add(jskeybind);