rewind controller support

This commit is contained in:
RandomityGuy 2023-05-14 19:03:27 +05:30
parent 581e5de970
commit 1e6141cdff
2 changed files with 12 additions and 3 deletions

View file

@ -992,12 +992,16 @@ class MarbleWorld extends Scheduler {
var realDt = dt; var realDt = dt;
if ((Key.isDown(Settings.controlsSettings.rewind) || MarbleGame.instance.touchInput.rewindButton.pressed) if ((Key.isDown(Settings.controlsSettings.rewind)
|| MarbleGame.instance.touchInput.rewindButton.pressed
|| Gamepad.isDown(Settings.gamepadSettings.rewind))
&& Settings.optionsSettings.rewindEnabled && Settings.optionsSettings.rewindEnabled
&& !this.isWatching) { && !this.isWatching) {
this.rewinding = true; this.rewinding = true;
} else { } else {
if ((Key.isReleased(Settings.controlsSettings.rewind) || !MarbleGame.instance.touchInput.rewindButton.pressed) if ((Key.isReleased(Settings.controlsSettings.rewind)
|| !MarbleGame.instance.touchInput.rewindButton.pressed
|| Gamepad.isReleased(Settings.gamepadSettings.rewind))
&& this.rewinding) { && this.rewinding) {
if (this.isRecording) { if (this.isRecording) {
this.replay.spliceReplay(timeState.currentAttemptTime); this.replay.spliceReplay(timeState.currentAttemptTime);

View file

@ -93,6 +93,7 @@ typedef GamepadSettings = {
var axisDeadzone:Float; var axisDeadzone:Float;
var respawn:Array<String>; var respawn:Array<String>;
var blast:Array<String>; var blast:Array<String>;
var rewind:Array<String>;
} }
typedef PlayStatistics = { typedef PlayStatistics = {
@ -178,7 +179,8 @@ class Settings {
invertYAxis: false, invertYAxis: false,
axisDeadzone: 0.15, axisDeadzone: 0.15,
respawn: ["back"], respawn: ["back"],
blast: ["X", "LB", "RB"] blast: ["X", "LB", "RB"],
rewind: ["Y"],
} }
public static var playStatistics:PlayStatistics = { public static var playStatistics:PlayStatistics = {
@ -389,6 +391,9 @@ class Settings {
if (json.gamepad != null) { if (json.gamepad != null) {
gamepadSettings = json.gamepad; gamepadSettings = json.gamepad;
} }
if (gamepadSettings.rewind == null) {
gamepadSettings.rewind = ["Y"];
}
if (json.stats != null) { if (json.stats != null) {
playStatistics = json.stats; playStatistics = json.stats;
} }