From 41b90f331142701523bc9efbac5c8d7f08639b9d Mon Sep 17 00:00:00 2001 From: Recrown Date: Fri, 18 Aug 2017 03:03:18 -0500 Subject: [PATCH] added quit button to pause menu --- .../rhythmbullet/screens/PreGameScreen.java | 2 +- .../rhythmbullet/ui/stages/GameHUD.java | 18 +++++++++++++++--- .../rhythmbullet/ui/windows/PauseMenu.java | 12 ++++++++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/core/src/zero1hd/rhythmbullet/screens/PreGameScreen.java b/core/src/zero1hd/rhythmbullet/screens/PreGameScreen.java index 3451983..adfcb51 100755 --- a/core/src/zero1hd/rhythmbullet/screens/PreGameScreen.java +++ b/core/src/zero1hd/rhythmbullet/screens/PreGameScreen.java @@ -21,7 +21,7 @@ public class PreGameScreen extends ScreenAdapter implements TransitionAdapter, M Stage stage; MusicSelectionPage ms; - AnalyzePage ap; + public AnalyzePage ap; private Vector3 cameraPos; private RhythmBullet core; diff --git a/core/src/zero1hd/rhythmbullet/ui/stages/GameHUD.java b/core/src/zero1hd/rhythmbullet/ui/stages/GameHUD.java index 4ec306a..e00943f 100755 --- a/core/src/zero1hd/rhythmbullet/ui/stages/GameHUD.java +++ b/core/src/zero1hd/rhythmbullet/ui/stages/GameHUD.java @@ -17,12 +17,16 @@ import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; +import zero1hd.rhythmbullet.RhythmBullet; +import zero1hd.rhythmbullet.screens.PreGameScreen; import zero1hd.rhythmbullet.ui.builders.HealthBar; import zero1hd.rhythmbullet.ui.windows.FPSWindow; import zero1hd.rhythmbullet.ui.windows.PauseMenu; +import zero1hd.rhythmbullet.util.MiniEvents; import zero1hd.rhythmbullet.util.ScoreManager; public class GameHUD extends Stage { + private PreGameScreen pgs; private Label scoreLabel; private ImageButton pause; private boolean paused; @@ -39,14 +43,15 @@ public class GameHUD extends Stage { private ScoreManager sm; private Color original, bass, um; - public GameHUD(Skin skin, float maxHealth, GamePlayArea gpa) { + public GameHUD(Skin skin, float maxHealth, GamePlayArea gpa, PreGameScreen preGS, final RhythmBullet core) { super(); scoreLabel = new Label("Score: 0", skin, "default-font", Color.WHITE); scoreLabel.setPosition(10f, Gdx.graphics.getHeight()-scoreLabel.getHeight() - 10f); addActor(scoreLabel); this.sm = gpa.score; this.gpa = gpa; - + this.pgs = preGS; + pause = new ImageButton(skin.getDrawable("pause"), skin.getDrawable("pause-down")); pause.setPosition(Gdx.graphics.getWidth() - pause.getWidth() - 15f, @@ -69,6 +74,14 @@ public class GameHUD extends Stage { setPaused(false); } }); + + pauseMenu.getQuitButton().addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + pgs.ap.miniSender.send(MiniEvents.BACK); + core.setScreen(pgs); + } + }); pauseMenu.setPosition((Gdx.graphics.getWidth()-pauseMenu.getWidth())/2f, (Gdx.graphics.getHeight()-pauseMenu.getHeight())/2f); healthBar = new HealthBar(skin, maxHealth); @@ -77,7 +90,6 @@ public class GameHUD extends Stage { healthBar.setPosition(Gdx.graphics.getWidth() -(gpa.getViewport().getRightGutterWidth()/4f), (Gdx.graphics.getHeight()-healthBar.getHeight())/2f); addActor(healthBar); healthBar.setPolyjetEntity(gpa.getPolyjetEntity()); - pixmap = new Pixmap(3, 3, Format.RGBA8888); int excess = 2*gpa.getViewport().getLeftGutterWidth()/pixmap.getWidth(); Gdx.app.debug("GHUD", "offset on size: " + excess); diff --git a/core/src/zero1hd/rhythmbullet/ui/windows/PauseMenu.java b/core/src/zero1hd/rhythmbullet/ui/windows/PauseMenu.java index 1a3089f..0f83f6e 100755 --- a/core/src/zero1hd/rhythmbullet/ui/windows/PauseMenu.java +++ b/core/src/zero1hd/rhythmbullet/ui/windows/PauseMenu.java @@ -8,7 +8,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Window; public class PauseMenu extends Window { private Label label; private TextButton resumeButton; - + private TextButton quit; public PauseMenu(Skin skin) { super("Paused", skin, "tinted"); defaults().pad(25f); @@ -16,9 +16,10 @@ public class PauseMenu extends Window { add(label).spaceBottom(15f); row(); - resumeButton = new TextButton("Resume", skin); - add(resumeButton); - + resumeButton = new TextButton("Resume", skin, "sub"); + add(resumeButton).spaceBottom(8f); + quit = new TextButton("Quit", skin, "sub"); + add(quit); pack(); setModal(true); @@ -28,4 +29,7 @@ public class PauseMenu extends Window { public TextButton getResumeButton() { return resumeButton; } + public TextButton getQuitButton() { + return quit; + } }