From b6b7590cf413f048bfce06f4078c1163ed649c43 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Fri, 27 Jan 2017 19:36:17 +0100 Subject: [PATCH] Add fully-functional pause menu, move skin creation --- android/assets/ui/home.png | Bin 0 -> 1150 bytes android/assets/ui/replay.png | Bin 0 -> 2284 bytes android/assets/ui/share.png | Bin 0 -> 1826 bytes .../io/github/lonamiwebs/klooni/Klooni.java | 25 ++- .../lonamiwebs/klooni/screens/GameScreen.java | 23 ++- .../klooni/screens/MainMenuScreen.java | 37 ++--- .../klooni/screens/PauseMenuStage.java | 150 ++++++++++++++++++ 7 files changed, 200 insertions(+), 35 deletions(-) create mode 100644 android/assets/ui/home.png create mode 100644 android/assets/ui/replay.png create mode 100644 android/assets/ui/share.png create mode 100644 core/src/io/github/lonamiwebs/klooni/screens/PauseMenuStage.java diff --git a/android/assets/ui/home.png b/android/assets/ui/home.png new file mode 100644 index 0000000000000000000000000000000000000000..04fc056f2e7c563c726c815a24488ac5a196c4ac GIT binary patch literal 1150 zcmV-^1cCdBP)X^D;S^lQ4n@YPH&?APDxG**!oCeBzut8iwIFMY~9m zZ#FkKHy#AR5n%f=-3FW*8XDR^Iy!oxD5pXKFf&orz0SE8&1`gq;fa|&Q!bZ}iHPOx zmU{s8di`26n>4d~*Esb9=iFmq7+%apY@S>LP}RGDw}9$8OI#F@N1`Y?lc81{F0aB# zk~|KaVf~8-xW>#rQq_YQX)Pi1E5OV)BuVlLush?@C!#3YCnA4lS+r{as=5W(1B@){ zYM9yaN~Q8uTVtcKF-_BV&FqdWCI7=&U`M%J{w=G59RrBt_$uez&s}!yq}gm%$HvC$ z0IGU3a2mKiE4dE*BqH0QDEcmoVjcGYGrM7hudHZfWMmu`HoMQsfAIh}n%Nggl5EYQ zSkIfFs%{gJkAbT*@L4ToGy5<}l81XO)N24w0B^72<|Yq@&FsxMjvwu%NKXNn**+lX zrACijAtIA;96!0<0=eA>6o`n(ORD<9dM5Wn0GBzasz=s3shIH0OW*D|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jF= z=iD&K9g;rR(_qMP0Nbs#clS8{1*4~&pmS~w$<^Nb6#!T$6pnlEk6LSA?IocZ$MMHW zejC8XUNlMmvQ#SF(2ulPUrS@oxnTfzp@(k-lKYY*xoW23NSf$-d3+-0cn!%PpnI9@ zfVFlb$u~L$)oQhsjYeY?$>jj#y+2+o7LQtMPjnm4qU{ejcI?xwHapoX^l^IJN zZ!{Wfa%TVlL{an+W6aY4N?GcV+>%QJ0Khr-WdM&L+spJoE_aFoKoA6vO8S1rG8g1_ z1pt7gfh0-BGL(2Dw<`c>eH}_V)je|Fcs(^b07*qoM6N<$g6QT_xBvhE literal 0 HcmV?d00001 diff --git a/core/src/io/github/lonamiwebs/klooni/Klooni.java b/core/src/io/github/lonamiwebs/klooni/Klooni.java index 1ee1e0a..bff9a83 100644 --- a/core/src/io/github/lonamiwebs/klooni/Klooni.java +++ b/core/src/io/github/lonamiwebs/klooni/Klooni.java @@ -1,17 +1,37 @@ package io.github.lonamiwebs.klooni; import com.badlogic.gdx.Game; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.NinePatch; import com.badlogic.gdx.scenes.scene2d.ui.Skin; import io.github.lonamiwebs.klooni.screens.MainMenuScreen; public class Klooni extends Game { - public static Skin skin; + public Skin skin; @Override public void create() { - //skin = new Skin(Gdx.files.internal("skin/craftacular-ui.json")); + // TODO Better way to have this skin somewhere + // Gotta create that darn .jsonā€¦! + skin = new Skin(Gdx.files.internal("skin/uiskin.json")); + + skin.add("button_up", new NinePatch(new Texture( + Gdx.files.internal("ui/button_up.png")), 28, 28, 28, 28)); + + skin.add("button_down", new NinePatch(new Texture( + Gdx.files.internal("ui/button_down.png")), 28, 28, 28, 28)); + + skin.add("play_texture", new Texture(Gdx.files.internal("ui/play.png"))); + skin.add("star_texture", new Texture(Gdx.files.internal("ui/star.png"))); + skin.add("stats_texture", new Texture(Gdx.files.internal("ui/stats.png"))); + skin.add("palette_texture", new Texture(Gdx.files.internal("ui/palette.png"))); + skin.add("home_texture", new Texture(Gdx.files.internal("ui/home.png"))); + skin.add("replay_texture", new Texture(Gdx.files.internal("ui/replay.png"))); + skin.add("share_texture", new Texture(Gdx.files.internal("ui/share.png"))); + setScreen(new MainMenuScreen(this)); } @@ -23,5 +43,6 @@ public class Klooni extends Game { @Override public void dispose() { super.dispose(); + skin.dispose(); } } diff --git a/core/src/io/github/lonamiwebs/klooni/screens/GameScreen.java b/core/src/io/github/lonamiwebs/klooni/screens/GameScreen.java index 2ab327c..5f5641d 100644 --- a/core/src/io/github/lonamiwebs/klooni/screens/GameScreen.java +++ b/core/src/io/github/lonamiwebs/klooni/screens/GameScreen.java @@ -1,12 +1,12 @@ package io.github.lonamiwebs.klooni.screens; import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input; import com.badlogic.gdx.InputProcessor; import com.badlogic.gdx.Screen; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.g2d.SpriteBatch; -import com.badlogic.gdx.math.MathUtils; import io.github.lonamiwebs.klooni.Klooni; import io.github.lonamiwebs.klooni.game.Board; @@ -30,22 +30,21 @@ public class GameScreen implements Screen, InputProcessor { private final Color clearColor; private int score; + private final PauseMenuStage pauseMenu; + public GameScreen(Klooni aGame) { game = aGame; score = 0; clearColor = new Color(0.9f, 0.9f, 0.7f, 1f); batch = new SpriteBatch(); + pauseMenu = new PauseMenuStage(game); + layout = new GameLayout(); scorer = new Scorer(layout, 10); board = new Board(layout, 10); holder = new PieceHolder(layout, 3); - - // Fill some random pieces - for (int i = 0; i < 10; i++) { - board.putPiece(Piece.random(), MathUtils.random(10), MathUtils.random(10)); - } } boolean isGameOver() { @@ -77,6 +76,11 @@ public class GameScreen implements Screen, InputProcessor { holder.draw(batch, board.cellPatch); batch.end(); + + if (pauseMenu.isShown() || pauseMenu.isHiding()) { + pauseMenu.act(delta); + pauseMenu.draw(); + } } @Override @@ -101,7 +105,7 @@ public class GameScreen implements Screen, InputProcessor { @Override public void dispose() { - + pauseMenu.dispose(); } //endregion @@ -115,6 +119,9 @@ public class GameScreen implements Screen, InputProcessor { @Override public boolean keyUp(int keycode) { + if (keycode == Input.Keys.P) // Pause + pauseMenu.show(); + return false; } @@ -137,7 +144,7 @@ public class GameScreen implements Screen, InputProcessor { // After the piece was put, check if it's game over if (isGameOver()) { - clearColor.set(0.4f, 0.1f, 0.1f, 1f); + pauseMenu.show(); } return true; } else { diff --git a/core/src/io/github/lonamiwebs/klooni/screens/MainMenuScreen.java b/core/src/io/github/lonamiwebs/klooni/screens/MainMenuScreen.java index 5d065d7..bdd0544 100644 --- a/core/src/io/github/lonamiwebs/klooni/screens/MainMenuScreen.java +++ b/core/src/io/github/lonamiwebs/klooni/screens/MainMenuScreen.java @@ -4,13 +4,10 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Screen; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL20; -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.NinePatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; -import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; @@ -19,7 +16,6 @@ import io.github.lonamiwebs.klooni.Klooni; public class MainMenuScreen implements Screen { private Klooni game; - Skin skin; Stage stage; SpriteBatch batch; @@ -28,27 +24,16 @@ public class MainMenuScreen implements Screen { batch = new SpriteBatch(); stage = new Stage(); - skin = new Skin(Gdx.files.internal("skin/uiskin.json")); Table table = new Table(); table.setFillParent(true); stage.addActor(table); - skin.add("button_up", new NinePatch(new Texture( - Gdx.files.internal("ui/button_up.png")), 28, 28, 28, 28)); - - skin.add("button_down", new NinePatch(new Texture( - Gdx.files.internal("ui/button_down.png")), 28, 28, 28, 28)); - - skin.add("play_texture", new Texture(Gdx.files.internal("ui/play.png"))); - skin.add("star_texture", new Texture(Gdx.files.internal("ui/star.png"))); - skin.add("stats_texture", new Texture(Gdx.files.internal("ui/stats.png"))); - skin.add("palette_texture", new Texture(Gdx.files.internal("ui/palette.png"))); - // Play button ImageButton.ImageButtonStyle playStyle = new ImageButton.ImageButtonStyle( - skin.newDrawable("button_up", Color.GREEN), skin.newDrawable("button_down", Color.GREEN), - null, skin.getDrawable("play_texture"), null, null); + game.skin.newDrawable("button_up", Color.GREEN), + game.skin.newDrawable("button_down", Color.GREEN), + null, game.skin.getDrawable("play_texture"), null, null); final ImageButton playButton = new ImageButton(playStyle); table.add(playButton).colspan(3).fill().space(16); @@ -64,24 +49,27 @@ public class MainMenuScreen implements Screen { // Star button (on GitHub) ImageButton.ImageButtonStyle starStyle = new ImageButton.ImageButtonStyle( - skin.newDrawable("button_up", Color.YELLOW), skin.newDrawable("button_down", Color.YELLOW), - null, skin.getDrawable("star_texture"), null, null); + game.skin.newDrawable("button_up", Color.YELLOW), + game.skin.newDrawable("button_down", Color.YELLOW), + null, game.skin.getDrawable("star_texture"), null, null); final ImageButton starButton = new ImageButton(starStyle); table.add(starButton).space(16); // Stats button (high scores) ImageButton.ImageButtonStyle statsStyle = new ImageButton.ImageButtonStyle( - skin.newDrawable("button_up", Color.BLUE), skin.newDrawable("button_down", Color.BLUE), - null, skin.getDrawable("stats_texture"), null, null); + game.skin.newDrawable("button_up", Color.BLUE), + game.skin.newDrawable("button_down", Color.BLUE), + null, game.skin.getDrawable("stats_texture"), null, null); final ImageButton statsButton = new ImageButton(statsStyle); table.add(statsButton).space(16); // Palette button (buy colors) ImageButton.ImageButtonStyle paletteStyle = new ImageButton.ImageButtonStyle( - skin.newDrawable("button_up", Color.FIREBRICK), skin.newDrawable("button_down", Color.FIREBRICK), - null, skin.getDrawable("palette_texture"), null, null); + game.skin.newDrawable("button_up", Color.FIREBRICK), + game.skin.newDrawable("button_down", Color.FIREBRICK), + null, game.skin.getDrawable("palette_texture"), null, null); final ImageButton paletteButton = new ImageButton(paletteStyle); table.add(paletteButton).space(16); @@ -125,6 +113,5 @@ public class MainMenuScreen implements Screen { @Override public void dispose() { stage.dispose(); - skin.dispose(); } } diff --git a/core/src/io/github/lonamiwebs/klooni/screens/PauseMenuStage.java b/core/src/io/github/lonamiwebs/klooni/screens/PauseMenuStage.java new file mode 100644 index 0000000..bf7f4cf --- /dev/null +++ b/core/src/io/github/lonamiwebs/klooni/screens/PauseMenuStage.java @@ -0,0 +1,150 @@ +package io.github.lonamiwebs.klooni.screens; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input; +import com.badlogic.gdx.InputProcessor; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; +import com.badlogic.gdx.math.Interpolation; +import com.badlogic.gdx.scenes.scene2d.Actor; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.actions.Actions; +import com.badlogic.gdx.scenes.scene2d.actions.RunnableAction; +import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; +import com.badlogic.gdx.scenes.scene2d.ui.Table; +import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; + +import io.github.lonamiwebs.klooni.Klooni; + +public class PauseMenuStage extends Stage { + + private InputProcessor lastInputProcessor; + private boolean shown; + private boolean hiding; + + public PauseMenuStage(final Klooni game) { + + Table table = new Table(); + table.setFillParent(true); + addActor(table); + + // Home screen button + ImageButton.ImageButtonStyle homeStyle = new ImageButton.ImageButtonStyle( + game.skin.newDrawable("button_up", Color.FIREBRICK), + game.skin.newDrawable("button_down", Color.FIREBRICK), + null, game.skin.getDrawable("home_texture"), null, null); + + final ImageButton homeButton = new ImageButton(homeStyle); + table.add(homeButton).space(16); + + homeButton.addListener(new ChangeListener() { + public void changed (ChangeEvent event, Actor actor) { + game.setScreen(new MainMenuScreen(game)); + dispose(); + } + }); + + // Replay button + ImageButton.ImageButtonStyle replayStyle = new ImageButton.ImageButtonStyle( + game.skin.newDrawable("button_up", Color.GREEN), + game.skin.newDrawable("button_down", Color.GREEN), + null, game.skin.getDrawable("replay_texture"), null, null); + + final ImageButton replayButton = new ImageButton(replayStyle); + table.add(replayButton).space(16); + + replayButton.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + game.setScreen(new GameScreen(game)); + dispose(); + } + }); + + table.row(); + + // Palette button (buy colors) + ImageButton.ImageButtonStyle paletteStyle = new ImageButton.ImageButtonStyle( + game.skin.newDrawable("button_up", Color.YELLOW), + game.skin.newDrawable("button_down", Color.YELLOW), + null, game.skin.getDrawable("palette_texture"), null, null); + + final ImageButton paletteButton = new ImageButton(paletteStyle); + table.add(paletteButton).space(16); + + // Continue playing OR share (if game over) button + // TODO Enable both actions for this button + ImageButton.ImageButtonStyle playStyle = new ImageButton.ImageButtonStyle( + game.skin.newDrawable("button_up", Color.BLUE), + game.skin.newDrawable("button_down", Color.BLUE), + null, game.skin.getDrawable("play_texture"), null, null); + + final ImageButton playButton = new ImageButton(playStyle); + table.add(playButton).space(16); + + playButton.addListener(new ChangeListener() { + public void changed (ChangeEvent event, Actor actor) { + hide(); + } + }); + } + + public void show() { + lastInputProcessor = Gdx.input.getInputProcessor(); + Gdx.input.setInputProcessor(this); + shown = true; + hiding = false; + + addAction(Actions.moveTo(0, Gdx.graphics.getHeight())); + addAction(Actions.moveTo(0, 0, 0.75f, Interpolation.swingOut)); + } + + public void hide() { + shown = false; + hiding = true; + Gdx.input.setInputProcessor(lastInputProcessor); + + addAction(Actions.sequence( + Actions.moveTo(0, Gdx.graphics.getHeight(), 0.5f, Interpolation.swingIn), + new RunnableAction() { + @Override + public void run() { + hiding = false; + } + } + )); + } + + public boolean isShown() { + return shown; + } + + public boolean isHiding() { + return hiding; + } + + @Override + public void draw() { + // Draw an overlay rectangle with not all the opacity + if (shown) { + ShapeRenderer shapeRenderer = new ShapeRenderer(20); + + Gdx.gl.glEnable(GL20.GL_BLEND); + shapeRenderer.begin(ShapeRenderer.ShapeType.Filled); + shapeRenderer.setColor(1f, 1f, 1f, 0.3f); + shapeRenderer.rect(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); + shapeRenderer.end(); + } + + super.draw(); + } + + @Override + public boolean keyUp(int keyCode) { + if (keyCode == Input.Keys.P) // Pause + hide(); + + return super.keyUp(keyCode); + } +}