diff --git a/src/MarbleGame.hx b/src/MarbleGame.hx index 10ba709a..5fbabd58 100644 --- a/src/MarbleGame.hx +++ b/src/MarbleGame.hx @@ -219,6 +219,7 @@ class MarbleGame { if (paused && world._ready) { Console.log("Game paused"); world.setCursorLock(false); + @:privateAccess world.playGui.setGuiVisibility(false); exitGameDlg = new ExitGameDlg((sender) -> { canvas.popDialog(exitGameDlg); if (world.isRecording) { @@ -229,10 +230,12 @@ class MarbleGame { quitMission(); } }, (sender) -> { + @:privateAccess world.playGui.setGuiVisibility(true); canvas.popDialog(exitGameDlg); paused = !paused; world.setCursorLock(true); }, (sender) -> { + @:privateAccess world.playGui.setGuiVisibility(true); canvas.popDialog(exitGameDlg); world.restart(true); // world.setCursorLock(true); @@ -242,8 +245,10 @@ class MarbleGame { } else { if (world._ready) { Console.log("Game unpaused"); - if (exitGameDlg != null) + if (exitGameDlg != null) { canvas.popDialog(exitGameDlg); + @:privateAccess world.playGui.setGuiVisibility(true); + } world.setCursorLock(true); } } diff --git a/src/MarbleWorld.hx b/src/MarbleWorld.hx index 52499911..8d9d93dd 100644 --- a/src/MarbleWorld.hx +++ b/src/MarbleWorld.hx @@ -472,6 +472,9 @@ class MarbleWorld extends Scheduler { } } + this.cancel(this.oobSchedule); + this.cancel(this.oobSchedule2); + var startquat = this.getStartPositionAndOrientation(); this.marble.setMarblePosition(startquat.position.x, startquat.position.y, startquat.position.z + 0.727843); diff --git a/src/gui/ExitGameDlg.hx b/src/gui/ExitGameDlg.hx index d75b2389..dea0af32 100644 --- a/src/gui/ExitGameDlg.hx +++ b/src/gui/ExitGameDlg.hx @@ -1,14 +1,18 @@ package gui; +import src.AudioManager; import src.MarbleGame; import hxd.res.BitmapFont; import h3d.Vector; import src.ResourceLoader; import src.Settings; -class ExitGameDlg extends GuiControl { +class ExitGameDlg extends GuiImage { public function new(yesFunc:GuiControl->Void, noFunc:GuiControl->Void, restartFunc:GuiControl->Void) { - super(); + var res = ResourceLoader.getImage("data/ui/xbox/BG_fadeOutSoftEdge.png").resource.toTile(); + super(res); + + AudioManager.playSound(ResourceLoader.getResource('data/sound/level_text.wav', ResourceLoader.getAudio, this.soundResources)); this.horizSizing = Width; this.vertSizing = Height; @@ -22,10 +26,46 @@ class ExitGameDlg extends GuiControl { return [normal, hover, pressed]; } + var innerCtrl = new GuiControl(); + innerCtrl.position = new Vector(320, 180); + innerCtrl.extent = new Vector(1280, 720); + + var scene2d = MarbleGame.canvas.scene2d; + + // var subX = 640 - (scene2d.width - 145 * 2) * 640 g/ scene2d.width; + // var subY = 480 - (scene2d.height - 82 * 2) * 480 / scene2d.height; + + // innerCtrl.extent = new Vector(640 - subX, 480 - subY); + innerCtrl.horizSizing = Width; + innerCtrl.vertSizing = Height; + this.addChild(innerCtrl); + + var coliseumfontdata = ResourceLoader.getFileEntry("data/font/ColiseumRR.fnt"); + var coliseumb = new BitmapFont(coliseumfontdata.entry); + @:privateAccess coliseumb.loader = ResourceLoader.loader; + var coliseum = coliseumb.toSdfFont(cast 44 * Settings.uiScale, MultiChannel); + + var rootTitle = new GuiText(coliseum); + rootTitle.position = new Vector(100, 30); + rootTitle.extent = new Vector(1120, 80); + rootTitle.text.textColor = 0xFFFFFF; + rootTitle.text.text = "Paused"; + rootTitle.text.alpha = 0.5; + innerCtrl.addChild(rootTitle); + + var levelTitle = new GuiText(coliseum); + levelTitle.position = new Vector(100, 75); + levelTitle.extent = new Vector(1120, 80); + levelTitle.text.textColor = 0xFFFFFF; + levelTitle.text.alpha = 0.5; + levelTitle.text.text = 'Level ${MarbleGame.instance.world.mission.index + 1}'; + innerCtrl.addChild(levelTitle); + var dialogImg = new GuiImage(ResourceLoader.getResource("data/ui/common/dialog.png", ResourceLoader.getImage, this.imageResources).toTile()); dialogImg.horizSizing = Center; dialogImg.vertSizing = Center; dialogImg.position = new Vector(162, 160); + dialogImg.extent = new Vector(315, 160); var overlay = new GuiImage(ResourceLoader.getResource("data/ui/common/quitfromthislvl_overlay.png", ResourceLoader.getImage, this.imageResources) diff --git a/src/gui/PlayGui.hx b/src/gui/PlayGui.hx index ed2feb51..02c4bc21 100644 --- a/src/gui/PlayGui.hx +++ b/src/gui/PlayGui.hx @@ -726,4 +726,22 @@ class PlayGui { this.middleMessages.push({ctrl: middleMsg, age: 0}); } + + var pgoChildren = []; + + public function setGuiVisibility(show:Bool) { + if (show) { + if (pgoChildren.length != 0) { + for (ch in pgoChildren) { + playGuiCtrlOuter.addChild(ch); + } + playGuiCtrlOuter.render(MarbleGame.canvas.scene2d); + pgoChildren = []; + } + } else { + pgoChildren = playGuiCtrlOuter.children.copy(); + playGuiCtrlOuter.removeChildren(); + playGuiCtrlOuter.render(MarbleGame.canvas.scene2d); + } + } }