mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-12-23 16:32:49 +00:00
Make MBP replay saving system more natural
This commit is contained in:
parent
e6605efaa6
commit
73b70ab6ab
4 changed files with 69 additions and 29 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package src;
|
||||
|
||||
import gui.ReplayNameDlg;
|
||||
import gui.ConsoleDlg;
|
||||
import src.Replay;
|
||||
import touch.TouchInput;
|
||||
|
|
@ -218,7 +219,11 @@ class MarbleGame {
|
|||
world.setCursorLock(false);
|
||||
exitGameDlg = new ExitGameDlg((sender) -> {
|
||||
canvas.popDialog(exitGameDlg);
|
||||
quitMission();
|
||||
if (world.isRecording) {
|
||||
MarbleGame.canvas.pushDialog(new ReplayNameDlg(() -> {quitMission();}));
|
||||
} else {
|
||||
quitMission();
|
||||
}
|
||||
}, (sender) -> {
|
||||
canvas.popDialog(exitGameDlg);
|
||||
paused = !paused;
|
||||
|
|
@ -247,9 +252,6 @@ class MarbleGame {
|
|||
var pmg = new PlayMissionGui();
|
||||
PlayMissionGui.currentSelectionStatic = world.mission.index;
|
||||
PlayMissionGui.currentGameStatic = world.mission.game;
|
||||
if (world.isRecording) {
|
||||
world.saveReplay();
|
||||
}
|
||||
world.dispose();
|
||||
world = null;
|
||||
canvas.setContent(pmg);
|
||||
|
|
@ -263,7 +265,6 @@ class MarbleGame {
|
|||
world.dispose();
|
||||
}
|
||||
world = new MarbleWorld(scene, scene2d, mission, toRecord);
|
||||
toRecord = false;
|
||||
world.init();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package src;
|
||||
|
||||
import gui.ReplayNameDlg;
|
||||
import collision.Collision;
|
||||
import shapes.MegaMarble;
|
||||
import shapes.Blast;
|
||||
|
|
@ -1636,7 +1637,8 @@ class MarbleWorld extends Scheduler {
|
|||
this.finishYaw = this.marble.camera.CameraYaw;
|
||||
this.finishPitch = this.marble.camera.CameraPitch;
|
||||
displayAlert("Congratulations! You've finished!");
|
||||
this.schedule(this.timeState.currentAttemptTime + 2, () -> cast showFinishScreen());
|
||||
if (!this.isWatching)
|
||||
this.schedule(this.timeState.currentAttemptTime + 2, () -> cast showFinishScreen());
|
||||
// Stop the ongoing sounds
|
||||
if (timeTravelSound != null) {
|
||||
timeTravelSound.stop();
|
||||
|
|
@ -1650,16 +1652,17 @@ class MarbleWorld extends Scheduler {
|
|||
}
|
||||
|
||||
function showFinishScreen() {
|
||||
if (this.isWatching)
|
||||
return 0;
|
||||
Console.log("State End");
|
||||
var egg:EndGameGui = null;
|
||||
#if js
|
||||
var pointercontainer = js.Browser.document.querySelector("#pointercontainer");
|
||||
pointercontainer.hidden = false;
|
||||
#end
|
||||
if (this.isRecording) {
|
||||
this.schedule(this.timeState.currentAttemptTime + 3, () -> {
|
||||
this.isRecording = false; // Stop recording here
|
||||
this.saveReplay();
|
||||
}
|
||||
}, "stopRecordingTimeout");
|
||||
if (Util.isTouchDevice()) {
|
||||
MarbleGame.instance.touchInput.setControlsEnabled(false);
|
||||
}
|
||||
|
|
@ -1667,24 +1670,48 @@ class MarbleWorld extends Scheduler {
|
|||
if (Util.isTouchDevice()) {
|
||||
MarbleGame.instance.touchInput.hideControls(@:privateAccess this.playGui.playGuiCtrl);
|
||||
}
|
||||
this.dispose();
|
||||
var pmg = new PlayMissionGui();
|
||||
PlayMissionGui.currentSelectionStatic = mission.index + 1;
|
||||
MarbleGame.canvas.setContent(pmg);
|
||||
#if js
|
||||
pointercontainer.hidden = false;
|
||||
#end
|
||||
}, (sender) -> {
|
||||
MarbleGame.canvas.popDialog(egg);
|
||||
this.setCursorLock(true);
|
||||
this.restart(true);
|
||||
#if js
|
||||
pointercontainer.hidden = true;
|
||||
#end
|
||||
if (Util.isTouchDevice()) {
|
||||
MarbleGame.instance.touchInput.setControlsEnabled(true);
|
||||
if (this.isRecording) {
|
||||
this.isRecording = false; // Stop recording here if we haven't already
|
||||
this.clearScheduleId("stopRecordingTimeout");
|
||||
}
|
||||
var endGameCode = () -> {
|
||||
this.dispose();
|
||||
var pmg = new PlayMissionGui();
|
||||
PlayMissionGui.currentSelectionStatic = mission.index + 1;
|
||||
MarbleGame.canvas.setContent(pmg);
|
||||
#if js
|
||||
pointercontainer.hidden = false;
|
||||
#end
|
||||
}
|
||||
if (MarbleGame.instance.toRecord) {
|
||||
MarbleGame.canvas.pushDialog(new ReplayNameDlg(endGameCode));
|
||||
} else {
|
||||
endGameCode();
|
||||
}
|
||||
}, (sender) -> {
|
||||
var restartGameCode = () -> {
|
||||
MarbleGame.canvas.popDialog(egg);
|
||||
this.setCursorLock(true);
|
||||
this.restart(true);
|
||||
#if js
|
||||
pointercontainer.hidden = true;
|
||||
#end
|
||||
if (Util.isTouchDevice()) {
|
||||
MarbleGame.instance.touchInput.setControlsEnabled(true);
|
||||
}
|
||||
// @:privateAccess playGui.playGuiCtrl.render(scene2d);
|
||||
}
|
||||
if (this.isRecording) {
|
||||
this.clearScheduleId("stopRecordingTimeout");
|
||||
}
|
||||
if (MarbleGame.instance.toRecord) {
|
||||
MarbleGame.canvas.pushDialog(new ReplayNameDlg(() -> {
|
||||
this.isRecording = true;
|
||||
restartGameCode();
|
||||
}));
|
||||
} else {
|
||||
restartGameCode();
|
||||
}
|
||||
// @:privateAccess playGui.playGuiCtrl.render(scene2d);
|
||||
}, mission, finishTime);
|
||||
MarbleGame.canvas.pushDialog(egg);
|
||||
this.setCursorLock(false);
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ class PlayMissionGui extends GuiImage {
|
|||
currentCategory = PlayMissionGui.currentCategoryStatic;
|
||||
currentGame = PlayMissionGui.currentGameStatic;
|
||||
|
||||
MarbleGame.instance.toRecord = false;
|
||||
|
||||
function chooseBg() {
|
||||
if (currentGame == "gold")
|
||||
return ResourceLoader.getImage('data/ui/backgrounds/gold/${cast (Math.floor(Util.lerp(1, 12, Math.random())), Int)}.jpg');
|
||||
|
|
@ -667,7 +669,8 @@ class PlayMissionGui extends GuiImage {
|
|||
pmRecord.position = new Vector(247, 46);
|
||||
pmRecord.extent = new Vector(43, 43);
|
||||
pmRecord.pressedAction = (sender) -> {
|
||||
cast(this.parent, Canvas).pushDialog(new ReplayNameDlg());
|
||||
MarbleGame.instance.toRecord = true;
|
||||
MarbleGame.canvas.pushDialog(new MessageBoxOkDlg("The next mission you play will be recorded."));
|
||||
};
|
||||
pmMorePopDlg.addChild(pmRecord);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import src.ResourceLoader;
|
|||
import src.Settings;
|
||||
|
||||
class ReplayNameDlg extends GuiControl {
|
||||
public function new() {
|
||||
public function new(callback:Void->Void) {
|
||||
super();
|
||||
var text = "Enter a name for the recording";
|
||||
this.horizSizing = Width;
|
||||
|
|
@ -59,6 +59,13 @@ class ReplayNameDlg extends GuiControl {
|
|||
textInput.text.selectionTile = h2d.Tile.fromColor(0x808080, 0, hxd.Math.ceil(textInput.text.font.lineHeight));
|
||||
textFrame.addChild(textInput);
|
||||
|
||||
textInput.text.text = MarbleGame.instance.world.mission.title;
|
||||
if (MarbleGame.instance.world.finishTime == null) {
|
||||
textInput.text.text += " Unfinished Run";
|
||||
} else {
|
||||
textInput.text.text += " " + MarbleGame.instance.world.finishTime.gameplayClock;
|
||||
}
|
||||
|
||||
var yesButton = new GuiButton(loadButtonImages("data/ui/common/ok"));
|
||||
yesButton.position = new Vector(171, 124);
|
||||
yesButton.extent = new Vector(95, 45);
|
||||
|
|
@ -66,9 +73,10 @@ class ReplayNameDlg extends GuiControl {
|
|||
yesButton.accelerator = hxd.Key.ENTER;
|
||||
yesButton.pressedAction = (sender) -> {
|
||||
if (StringTools.trim(textInput.text.text) != "") {
|
||||
MarbleGame.instance.toRecord = true;
|
||||
MarbleGame.instance.recordingName = textInput.text.text;
|
||||
MarbleGame.canvas.popDialog(this);
|
||||
MarbleGame.instance.world.saveReplay();
|
||||
callback();
|
||||
}
|
||||
}
|
||||
yesNoFrame.addChild(yesButton);
|
||||
|
|
@ -80,6 +88,7 @@ class ReplayNameDlg extends GuiControl {
|
|||
noButton.accelerator = hxd.Key.ESCAPE;
|
||||
noButton.pressedAction = (sender) -> {
|
||||
MarbleGame.canvas.popDialog(this);
|
||||
callback();
|
||||
}
|
||||
yesNoFrame.addChild(noButton);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue