Add a nicer share screen
This commit is contained in:
parent
acc80677fe
commit
17f3fe40e6
2 changed files with 126 additions and 12 deletions
|
@ -1,10 +1,8 @@
|
||||||
package io.github.lonamiwebs.klooni.screens;
|
package io.github.lonamiwebs.klooni.screens;
|
||||||
|
|
||||||
import com.badlogic.gdx.Application;
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Input;
|
import com.badlogic.gdx.Input;
|
||||||
import com.badlogic.gdx.InputProcessor;
|
import com.badlogic.gdx.InputProcessor;
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||||
|
@ -16,10 +14,7 @@ import com.badlogic.gdx.scenes.scene2d.actions.RunnableAction;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import io.github.lonamiwebs.klooni.Klooni;
|
import io.github.lonamiwebs.klooni.Klooni;
|
||||||
import io.github.lonamiwebs.klooni.ShareChallenge;
|
|
||||||
import io.github.lonamiwebs.klooni.actors.Band;
|
import io.github.lonamiwebs.klooni.actors.Band;
|
||||||
import io.github.lonamiwebs.klooni.actors.SoftButton;
|
import io.github.lonamiwebs.klooni.actors.SoftButton;
|
||||||
import io.github.lonamiwebs.klooni.game.BaseScorer;
|
import io.github.lonamiwebs.klooni.game.BaseScorer;
|
||||||
|
@ -102,11 +97,7 @@ class PauseMenuStage extends Stage {
|
||||||
playButton = new SoftButton(2, "play_texture");
|
playButton = new SoftButton(2, "play_texture");
|
||||||
table.add(playButton).space(16);
|
table.add(playButton).space(16);
|
||||||
|
|
||||||
playButton.addListener(new ChangeListener() {
|
playButton.addListener(playChangeListener);
|
||||||
public void changed (ChangeEvent event, Actor actor) {
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
@ -131,6 +122,13 @@ class PauseMenuStage extends Stage {
|
||||||
scorer.resume();
|
scorer.resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final ChangeListener playChangeListener = new ChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
//region Package local methods
|
//region Package local methods
|
||||||
|
@ -152,11 +150,13 @@ class PauseMenuStage extends Stage {
|
||||||
|
|
||||||
void showGameOver(final String gameOverReason) {
|
void showGameOver(final String gameOverReason) {
|
||||||
if (game.shareChallenge != null) {
|
if (game.shareChallenge != null) {
|
||||||
|
playButton.removeListener(playChangeListener);
|
||||||
playButton.updateImage("share_texture");
|
playButton.updateImage("share_texture");
|
||||||
playButton.addListener(new ChangeListener() {
|
playButton.addListener(new ChangeListener() {
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
game.shareChallenge.shareScreenshot(
|
// Don't dispose because then it needs to take us to the previous screen
|
||||||
game.shareChallenge.saveChallengeImage(scorer.getCurrentScore()));
|
game.transitionTo(new ShareScoreScreen(
|
||||||
|
game, game.getScreen(), scorer.getCurrentScore()), false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
114
core/src/io/github/lonamiwebs/klooni/screens/ShareScoreScreen.java
Executable file
114
core/src/io/github/lonamiwebs/klooni/screens/ShareScoreScreen.java
Executable file
|
@ -0,0 +1,114 @@
|
||||||
|
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.GL20;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||||
|
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.TextureRegionDrawable;
|
||||||
|
import com.badlogic.gdx.utils.Align;
|
||||||
|
|
||||||
|
import io.github.lonamiwebs.klooni.Klooni;
|
||||||
|
import io.github.lonamiwebs.klooni.Theme;
|
||||||
|
import io.github.lonamiwebs.klooni.actors.MoneyBuyBand;
|
||||||
|
import io.github.lonamiwebs.klooni.actors.SoftButton;
|
||||||
|
import io.github.lonamiwebs.klooni.actors.ThemeCard;
|
||||||
|
import io.github.lonamiwebs.klooni.game.GameLayout;
|
||||||
|
|
||||||
|
// Screen where the user can customize the look and feel of the game
|
||||||
|
class ShareScoreScreen implements Screen {
|
||||||
|
|
||||||
|
//region Members
|
||||||
|
|
||||||
|
private Klooni game;
|
||||||
|
private final Label infoLabel;
|
||||||
|
private final SpriteBatch spriteBatch;
|
||||||
|
|
||||||
|
private final Screen lastScreen;
|
||||||
|
private final int score;
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
//region Constructor
|
||||||
|
|
||||||
|
ShareScoreScreen(final Klooni game, final Screen lastScreen, final int score) {
|
||||||
|
this.game = game;
|
||||||
|
this.lastScreen = lastScreen;
|
||||||
|
this.score = score;
|
||||||
|
|
||||||
|
final Label.LabelStyle labelStyle = new Label.LabelStyle();
|
||||||
|
labelStyle.font = game.skin.getFont("font_small");
|
||||||
|
|
||||||
|
infoLabel = new Label("Generating image...", labelStyle);
|
||||||
|
infoLabel.setColor(Klooni.theme.textColor);
|
||||||
|
infoLabel.setAlignment(Align.center);
|
||||||
|
infoLabel.layout();
|
||||||
|
infoLabel.setPosition(
|
||||||
|
(Gdx.graphics.getWidth() - infoLabel.getWidth()) * 0.5f,
|
||||||
|
(Gdx.graphics.getHeight() - infoLabel.getHeight()) * 0.5f);
|
||||||
|
|
||||||
|
spriteBatch = new SpriteBatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
//region Private methods
|
||||||
|
|
||||||
|
private void goBack() {
|
||||||
|
game.transitionTo(lastScreen);
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
//region Public methods
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show() {
|
||||||
|
final boolean ok = game.shareChallenge.saveChallengeImage(score);
|
||||||
|
game.shareChallenge.shareScreenshot(ok);
|
||||||
|
goBack();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(float delta) {
|
||||||
|
Klooni.theme.glClearBackground();
|
||||||
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
spriteBatch.begin();
|
||||||
|
infoLabel.draw(spriteBatch, 1);
|
||||||
|
spriteBatch.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
//region Empty methods
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resize(int width, int height) { }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() { }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pause() { }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resume() { }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() { }
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
}
|
Loading…
Reference in a new issue