diff --git a/src/MarbleWorld.hx b/src/MarbleWorld.hx index dbfa18c3..ff595664 100644 --- a/src/MarbleWorld.hx +++ b/src/MarbleWorld.hx @@ -593,19 +593,23 @@ class MarbleWorld extends Scheduler { return; // We will update state manually if (this.timeState.currentAttemptTime < 0.5) { this.playGui.setCenterText('none'); + this.marble.mode = Start; } if ((this.timeState.currentAttemptTime >= 0.5) && (this.timeState.currentAttemptTime < 2)) { this.playGui.setCenterText('ready'); + this.marble.mode = Start; } if ((this.timeState.currentAttemptTime >= 2) && (this.timeState.currentAttemptTime < 3.5)) { this.playGui.setCenterText('set'); + this.marble.mode = Start; } if ((this.timeState.currentAttemptTime >= 3.5) && (this.timeState.currentAttemptTime < 5.5)) { this.playGui.setCenterText('go'); this.marble.mode = Play; } - if (this.timeState.currentAttemptTime >= 5.5) { + if (this.timeState.currentAttemptTime >= 5.5 && this.finishTime == null) { this.playGui.setCenterText('none'); + this.marble.mode = Play; } } @@ -991,12 +995,12 @@ class MarbleWorld extends Scheduler { if (Key.isDown(Settings.controlsSettings.rewind) && Settings.optionsSettings.rewindEnabled && !this.isWatching) { this.rewinding = true; } else { - this.rewinding = false; - if (Key.isReleased(Settings.controlsSettings.rewind)) { + if (Key.isReleased(Settings.controlsSettings.rewind) && this.rewinding) { if (this.isRecording) { this.replay.spliceReplay(timeState.currentAttemptTime); } } + this.rewinding = false; } if (!this.isWatching) { diff --git a/src/gui/ConsoleDlg.hx b/src/gui/ConsoleDlg.hx index b3bb3d77..1b882ef1 100644 --- a/src/gui/ConsoleDlg.hx +++ b/src/gui/ConsoleDlg.hx @@ -84,7 +84,7 @@ class ConsoleDlg extends GuiControl { bord.position = new Vector(0, 350); bord.extent = new Vector(640, 18); bord.horizSizing = Width; - consoleContent.addChild(bord); + this.addChild(bord); consoleInput = new GuiTextInput(arial14); consoleInput.position = new Vector(1, 351); @@ -96,7 +96,7 @@ class ConsoleDlg extends GuiControl { consoleInput.text.selectionColor.set(1, 1, 1); consoleInput.text.selectionTile = h2d.Tile.fromColor(0x808080, 0, hxd.Math.ceil(consoleInput.text.font.lineHeight)); - consoleContent.addChild(consoleInput); + this.addChild(consoleInput); onConsoleEntry = (e) -> { var txt = '[${e.time}] ${StringTools.htmlEscape(e.text)}
'; diff --git a/src/gui/GuiConsoleScrollCtrl.hx b/src/gui/GuiConsoleScrollCtrl.hx index 614fed10..91f2dbb1 100644 --- a/src/gui/GuiConsoleScrollCtrl.hx +++ b/src/gui/GuiConsoleScrollCtrl.hx @@ -17,7 +17,7 @@ class GuiConsoleScrollCtrl extends GuiControl { var maxScrollY:Float; var scrollBarY:h2d.Object; - var scrollTrack:Bitmap; + var scrollTrack:GuiImage; var scrollTopTile:Tile; var scrollBottomTile:Tile; @@ -57,6 +57,10 @@ class GuiConsoleScrollCtrl extends GuiControl { var scrollDownPressedTile = scrollBar.sub(19, 19, 18, 17); var scrollUpDisabledTile = scrollBar.sub(38, 1, 18, 17); var scrollDownDisabledTile = scrollBar.sub(38, 19, 18, 17); + this._manualScroll = true; + + this.scrollTrack = new GuiImage(scrollTrackTile); + this.addChild(this.scrollTrack); scrollUpButton = new GuiButton([scrollUpTile, scrollUpTile, scrollUpPressedTile, scrollUpDisabledTile]); scrollUpButton.position = new Vector(0, 0); @@ -117,7 +121,6 @@ class GuiConsoleScrollCtrl extends GuiControl { }); } }; - this.scrollTrack = new Bitmap(scrollTrackTile); } public function setScrollMax(max:Float) { @@ -132,26 +135,25 @@ class GuiConsoleScrollCtrl extends GuiControl { public override function getRenderRectangle():Rect { var rrec = super.getRenderRectangle(); - rrec.scroll.y = scrollY * this.maxScrollY / (rrec.extent.y - 34 * Settings.uiScale); + // rrec.scroll.y = scrollY * this.maxScrollY / (rrec.extent.y - 34 * Settings.uiScale); return rrec; } public override function render(scene2d:Scene) { this.dirty = true; + this.scrollTrack.position = new Vector(extent.x - 18 * Settings.uiScale, 0); + this.scrollTrack.extent = new Vector(18, this.extent.y); + scrollUpButton.position = new Vector(this.extent.x - 18, 0); scrollDownButton.position = new Vector(this.extent.x - 18, this.extent.y - 17); - if (scene2d.contains(scrollTrack)) - scene2d.removeChild(scrollTrack); - if (scene2d.contains(scrollBarY)) scene2d.removeChild(scrollBarY); if (scene2d.contains(clickInteractive)) scene2d.removeChild(clickInteractive); - scene2d.addChild(scrollTrack); scene2d.addChild(scrollBarY); scene2d.addChild(clickInteractive); @@ -169,13 +171,13 @@ class GuiConsoleScrollCtrl extends GuiControl { } scrollBarY.visible = true; - this.scrollTrack.setPosition(renderRect.position.x + renderRect.extent.x - 18 * Settings.uiScale, renderRect.position.y); + // this.scrollTrack.setPosition(renderRect.position.x + renderRect.extent.x - 18 * Settings.uiScale, renderRect.position.y); var scrollExtentY = renderRect.extent.y - 34 * Settings.uiScale; var scrollBarYSize = (scrollExtentY * scrollExtentY / (maxScrollY * Settings.uiScale - 34 * Settings.uiScale)); - this.scrollTrack.scaleY = renderRect.extent.y; + this.scrollTrack.bmp.scaleY = renderRect.extent.y; this.scrollY = Util.clamp(scrollY, 0, scrollExtentY - scrollBarYSize * Settings.uiScale); @@ -222,6 +224,8 @@ class GuiConsoleScrollCtrl extends GuiControl { } for (c in this.children) { + if (c == this.scrollTrack || c == this.scrollUpButton || c == this.scrollDownButton) + continue; c.onScroll(0, scrollY * (this.maxScrollY - 34 * Settings.uiScale) / scrollExtentY); } } @@ -229,7 +233,6 @@ class GuiConsoleScrollCtrl extends GuiControl { public override function dispose() { super.dispose(); this.scrollBarY.remove(); - this.scrollTrack.remove(); this.clickInteractive.remove(); } @@ -244,9 +247,6 @@ class GuiConsoleScrollCtrl extends GuiControl { public override function onRemove() { super.onRemove(); - if (MarbleGame.canvas.scene2d.contains(scrollTrack)) { - MarbleGame.canvas.scene2d.removeChild(scrollTrack); // Refresh "layer" - } if (MarbleGame.canvas.scene2d.contains(scrollBarY)) { MarbleGame.canvas.scene2d.removeChild(scrollBarY); // Refresh "layer" } diff --git a/src/rewind/RewindFrame.hx b/src/rewind/RewindFrame.hx index 9edf4215..1c34888d 100644 --- a/src/rewind/RewindFrame.hx +++ b/src/rewind/RewindFrame.hx @@ -100,7 +100,7 @@ class RewindFrame { c.blastAmt = blastAmt; c.oobState = { oob: oobState.oob, - timeState: oobState.timeState.clone() + timeState: oobState.timeState != null ? oobState.timeState.clone() : null }; c.checkpointState = { currentCheckpoint: checkpointState.currentCheckpoint != null ? { @@ -113,5 +113,6 @@ class RewindFrame { checkpointUp: checkpointState.checkpointUp != null ? checkpointState.checkpointUp.clone() : null, checkpointBlast: checkpointState.checkpointBlast, }; + return c; } } diff --git a/src/rewind/RewindManager.hx b/src/rewind/RewindManager.hx index 14d5663d..145a0666 100644 --- a/src/rewind/RewindManager.hx +++ b/src/rewind/RewindManager.hx @@ -239,6 +239,9 @@ class RewindManager { var topFrame = frames[frames.length - 1]; while (topFrame.timeState.currentAttemptTime > absTime) { + if (frames.length == 1) { + return frames[0]; + } frames.pop(); if (frames.length == 0) return null;