diff --git a/android/assets/ui/back.png b/android/assets/ui/back.png new file mode 100644 index 0000000..36a54c3 Binary files /dev/null and b/android/assets/ui/back.png differ diff --git a/android/assets/ui/credits.png b/android/assets/ui/credits.png new file mode 100644 index 0000000..64734ad Binary files /dev/null and b/android/assets/ui/credits.png differ diff --git a/android/assets/ui/issues.png b/android/assets/ui/issues.png new file mode 100644 index 0000000..4aba784 Binary files /dev/null and b/android/assets/ui/issues.png differ diff --git a/android/assets/ui/sound_off.png b/android/assets/ui/sound_off.png new file mode 100644 index 0000000..297dad6 Binary files /dev/null and b/android/assets/ui/sound_off.png differ diff --git a/android/assets/ui/sound_on.png b/android/assets/ui/sound_on.png new file mode 100644 index 0000000..7ec6e5e Binary files /dev/null and b/android/assets/ui/sound_on.png differ diff --git a/android/assets/ui/web.png b/android/assets/ui/web.png new file mode 100644 index 0000000..3b19744 Binary files /dev/null and b/android/assets/ui/web.png differ diff --git a/core/src/io/github/lonamiwebs/klooni/Klooni.java b/core/src/io/github/lonamiwebs/klooni/Klooni.java index 9b36467..5e46390 100644 --- a/core/src/io/github/lonamiwebs/klooni/Klooni.java +++ b/core/src/io/github/lonamiwebs/klooni/Klooni.java @@ -34,6 +34,12 @@ public class Klooni extends Game { 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"))); + skin.add("sound_on_texture", new Texture(Gdx.files.internal("ui/sound_on.png"))); + skin.add("sound_off_texture", new Texture(Gdx.files.internal("ui/sound_off.png"))); + skin.add("issues_texture", new Texture(Gdx.files.internal("ui/issues.png"))); + skin.add("credits_texture", new Texture(Gdx.files.internal("ui/credits.png"))); + skin.add("web_texture", new Texture(Gdx.files.internal("ui/web.png"))); + skin.add("back_texture", new Texture(Gdx.files.internal("ui/back.png"))); Gdx.input.setCatchBackKey(true); // To show the pause menu setScreen(new MainMenuScreen(this)); @@ -66,5 +72,9 @@ public class Klooni extends Game { return !prefs.getBoolean("muteSound", false); } + public static void toggleSound() { + prefs.putBoolean("muteSound", soundsEnabled()).flush(); + } + //endregion } diff --git a/core/src/io/github/lonamiwebs/klooni/screens/CustomizeScreen.java b/core/src/io/github/lonamiwebs/klooni/screens/CustomizeScreen.java new file mode 100644 index 0000000..7f91c34 --- /dev/null +++ b/core/src/io/github/lonamiwebs/klooni/screens/CustomizeScreen.java @@ -0,0 +1,156 @@ +package io.github.lonamiwebs.klooni.screens; + + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input; +import com.badlogic.gdx.Screen; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.scenes.scene2d.Actor; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup; +import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; +import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane; +import com.badlogic.gdx.scenes.scene2d.ui.Table; +import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup; +import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; +import com.badlogic.gdx.scenes.scene2d.utils.Drawable; + +import io.github.lonamiwebs.klooni.Klooni; + +public class CustomizeScreen implements Screen { + private Klooni game; + + private Stage stage; + + public CustomizeScreen(Klooni aGame, final Screen lastScreen) { + game = aGame; + stage = new Stage(); + + Table table = new Table(); + table.setFillParent(true); + stage.addActor(table); + + HorizontalGroup optionsGroup = new HorizontalGroup(); + optionsGroup.space(12); + + // Back to the previous screen + ImageButton.ImageButtonStyle backStyle = new ImageButton.ImageButtonStyle( + game.skin.newDrawable("button_up", Color.GOLD), + game.skin.newDrawable("button_down", Color.GOLD), + null, game.skin.getDrawable("back_texture"), null, null); + + final ImageButton backButton = new ImageButton(backStyle); + optionsGroup.addActor(backButton); + backButton.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + game.setScreen(lastScreen); + dispose(); + } + }); + + // Turn sound on/off + Drawable soundDrawable = game.skin.getDrawable( + Klooni.soundsEnabled() ? "sound_on_texture" : "sound_off_texture"); + + ImageButton.ImageButtonStyle soundStyle = new ImageButton.ImageButtonStyle( + game.skin.newDrawable("button_up", Color.LIME), + game.skin.newDrawable("button_down", Color.LIME), + null, soundDrawable, null, null); + + final ImageButton soundButton = new ImageButton(soundStyle); + optionsGroup.addActor(soundButton); + soundButton.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + Klooni.toggleSound(); + soundButton.getStyle().imageUp = game.skin.getDrawable( + Klooni.soundsEnabled() ? "sound_on_texture" : "sound_off_texture"); + } + }); + + // Issues + ImageButton.ImageButtonStyle issuesStyle = new ImageButton.ImageButtonStyle( + game.skin.newDrawable("button_up", Color.FIREBRICK), + game.skin.newDrawable("button_down", Color.FIREBRICK), + null, game.skin.getDrawable("issues_texture"), null, null); + + final ImageButton issuesButton = new ImageButton(issuesStyle); + optionsGroup.addActor(issuesButton); + issuesButton.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + Gdx.net.openURI("https://github.com/LonamiWeb/Klooni1010/issues"); + } + }); + + // Website + ImageButton.ImageButtonStyle webStyle = new ImageButton.ImageButtonStyle( + game.skin.newDrawable("button_up", new Color(0x6E99FFFF)), + game.skin.newDrawable("button_down", new Color(0x6E99FFFF)), + null, game.skin.getDrawable("web_texture"), null, null); + + final ImageButton webButton = new ImageButton(webStyle); + optionsGroup.addActor(webButton); + webButton.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + Gdx.net.openURI("https://lonamiwebs.github.io"); + } + }); + + table.add(new ScrollPane(optionsGroup)).pad(20, 4, 12, 4); + table.row(); + + VerticalGroup themesGroup = new VerticalGroup(); + themesGroup.space(8); + + table.add(themesGroup).expandY(); + } + + @Override + public void show() { + Gdx.input.setInputProcessor(stage); + } + + private static final float minDelta = 1/30f; + + @Override + public void render(float delta) { + Gdx.gl.glClearColor(0.7f, 0.9f, 0.9f, 1); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + stage.act(Math.min(Gdx.graphics.getDeltaTime(), minDelta)); + stage.draw(); + + if (Gdx.input.isKeyJustPressed(Input.Keys.BACK)) { + game.setScreen(new MainMenuScreen(game)); + dispose(); + } + } + + @Override + public void resize(int width, int height) { + stage.getViewport().update(width, height, true); + } + + @Override + public void pause() { + + } + + @Override + public void resume() { + + } + + @Override + public void hide() { + + } + + @Override + public void dispose() { + stage.dispose(); + } +} diff --git a/core/src/io/github/lonamiwebs/klooni/screens/GameScreen.java b/core/src/io/github/lonamiwebs/klooni/screens/GameScreen.java index 298d80a..9b087da 100644 --- a/core/src/io/github/lonamiwebs/klooni/screens/GameScreen.java +++ b/core/src/io/github/lonamiwebs/klooni/screens/GameScreen.java @@ -54,7 +54,10 @@ public class GameScreen implements Screen, InputProcessor { @Override public void show() { - Gdx.input.setInputProcessor(this); + if (pauseMenu.isShown()) // Will happen if we go to the customize menu + Gdx.input.setInputProcessor(pauseMenu); + else + Gdx.input.setInputProcessor(this); } @Override diff --git a/core/src/io/github/lonamiwebs/klooni/screens/MainMenuScreen.java b/core/src/io/github/lonamiwebs/klooni/screens/MainMenuScreen.java index 301fd17..877b515 100644 --- a/core/src/io/github/lonamiwebs/klooni/screens/MainMenuScreen.java +++ b/core/src/io/github/lonamiwebs/klooni/screens/MainMenuScreen.java @@ -75,6 +75,13 @@ public class MainMenuScreen extends InputListener implements Screen { final ImageButton paletteButton = new ImageButton(paletteStyle); table.add(paletteButton).space(16); + + paletteButton.addListener(new ChangeListener() { + public void changed (ChangeEvent event, Actor actor) { + game.setScreen(new CustomizeScreen(game, game.getScreen())); + // Don't dispose because then it needs to take us to the previous screen + } + }); } @Override diff --git a/core/src/io/github/lonamiwebs/klooni/screens/PauseMenuStage.java b/core/src/io/github/lonamiwebs/klooni/screens/PauseMenuStage.java index c64b840..4a23f97 100644 --- a/core/src/io/github/lonamiwebs/klooni/screens/PauseMenuStage.java +++ b/core/src/io/github/lonamiwebs/klooni/screens/PauseMenuStage.java @@ -85,6 +85,14 @@ public class PauseMenuStage extends Stage { final ImageButton paletteButton = new ImageButton(paletteStyle); table.add(paletteButton).space(16); + paletteButton.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + game.setScreen(new CustomizeScreen(game, game.getScreen())); + // Don't dispose because then it needs to take us to the previous screen + } + }); + // Continue playing OR share (if game over) button // TODO Enable both actions for this button ImageButton.ImageButtonStyle playStyle = new ImageButton.ImageButtonStyle(