Skip to content
Snippets Groups Projects
Commit 268f66a4 authored by Turid Cecilie Dahl's avatar Turid Cecilie Dahl
Browse files

Merge branch '50-make-it-look-pretty' into 'dev'

Resolve "Make it look pretty"

Closes #50

See merge request !66
parents e028ed95 0bb26b9d
Branches
No related tags found
1 merge request!66Resolve "Make it look pretty"
Showing
with 244 additions and 59 deletions
......@@ -5,7 +5,7 @@
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:icon="@drawable/gameware_logo"
android:isGame="true"
android:appCategory="game"
android:label="@string/app_name"
......
frontend/android/assets/bubbleWrapPhoto.png

67.5 KiB

frontend/android/assets/bubbleWrapPhotoEdit.png

69 KiB

frontend/android/assets/colorRushPhoto.png

84.8 KiB

frontend/android/assets/colorRushPhotoEdit.png

73.5 KiB

frontend/android/assets/glassy/raw/button-disabled.png

15.8 KiB

frontend/android/res/drawable-xxxhdpi/gameware_logo.png

30 KiB

......@@ -28,6 +28,7 @@ public class BubbleWrapState extends PlayStateTemplate {
public BubbleWrapState(GameStateManager gsm) {
super(gsm);
super.screenshot = new Texture(Gdx.files.internal("bubbleWrapPhotoEdit.png"));
unpopped = new Texture(Gdx.files.internal("glassy/raw/bubble_unpopped_1.png"));
popped1 = new Texture(Gdx.files.internal("glassy/raw/bubble_popped_1.png"));
......@@ -157,6 +158,7 @@ public class BubbleWrapState extends PlayStateTemplate {
this.popped2.dispose();
this.popped3.dispose();
this.pauseButton.dispose();
background.dispose();
}
@Override
......
......@@ -30,11 +30,11 @@ public class ColorRushState extends PlayStateTemplate {
private boolean buttonsEnabled = true;
private boolean disposeTargetLeft = true;
private PauseButton pauseButton;
public ColorRushState(GameStateManager gsm){
super(gsm);
super.screenshot = new Texture(Gdx.files.internal("colorRushPhotoEdit.png"));
// Creates the background
this.background = new Texture(Gdx.files.internal("glassy/raw/ColorRushBackground.jpg"));
......
package com.gameware.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
......@@ -52,7 +53,7 @@ public class CreateJoinTournamentState extends State {
private List<Tournament> tournaments = new ArrayList<>();
private Tournament tournamentTryingToLeave = null;
private int padding = 50;
private String includeFinTournamentsLabelText = "Include finished \n tournaments?";
private String includeFinTournamentsLabelText = "Include finished?";
private boolean includeFinishedTournaments = false;
......@@ -135,11 +136,10 @@ public class CreateJoinTournamentState extends State {
btnTable.row();
btnTable.add(makeCreateBtn()).size(buttonWidth, buttonHeight).spaceBottom(spacingOnBottomInputFIeld).spaceRight(spacingOnBottom);
btnTable.add(makeJoinBtn()).size(buttonWidth, buttonHeight).spaceBottom(spacingOnBottomInputFIeld);
btnTable.row();
btnTable.add(makeBackBtn());
outerTable.add(btnTable);
stage.addActor(outerTable);
stage.addActor(makeBackBtn());
makeDialog();
}
......@@ -252,6 +252,7 @@ public class CreateJoinTournamentState extends State {
handleBackBtnClick();
}
});
backBtn.setPosition(backBtnPlacementX, backBtnPlacementY);
return backBtn;
}
......@@ -272,11 +273,17 @@ public class CreateJoinTournamentState extends State {
}
@Override
protected void handleInput() { }
protected void handleInput() {
if (Gdx.input.isKeyJustPressed(Input.Keys.BACK)){
handleBackBtnClick();
}
}
@Override
public void update(float dt) {
Gdx.input.setInputProcessor(stage);
Gdx.input.setCatchBackKey(true);
handleInput();
stage.act(dt);
}
......@@ -320,7 +327,7 @@ public class CreateJoinTournamentState extends State {
}
private void handleLeaveBtnClick(Tournament t){
dialog.text("Do you want do leave\n"+t.getName()+"?").pad(padding);
dialog.text("Do you want to leave\n"+t.getName()+"?").pad(padding);
dialog.show(stage);
tournamentTryingToLeave = t;
}
......
package com.gameware.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox;
......@@ -161,11 +162,16 @@ public class CreateNewTournamentState extends State {
@Override
protected void handleInput() {
if (Gdx.input.isKeyJustPressed(Input.Keys.BACK)){
handleCancelBtnClick();
}
}
@Override
public void update(float dt) {
Gdx.input.setInputProcessor(stage);
Gdx.input.setCatchBackKey(true);
handleInput();
stage.act(dt);
}
......
package com.gameware.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
......@@ -127,7 +128,7 @@ public class FinishedTournamentState extends State {
}
};
dialog.text("Do you want do leave\n"+tournament.getName()+"?").pad(padding);
dialog.text("Do you want to leave\n"+tournament.getName()+"?").pad(padding);
dialog.button("Yes", true).pad(padding); //sends "true" as the result
dialog.button("No", false).pad(padding); //sends "false" as the result
}
......@@ -144,11 +145,17 @@ public class FinishedTournamentState extends State {
}
@Override
protected void handleInput() { }
protected void handleInput() {
if (Gdx.input.isKeyJustPressed(Input.Keys.BACK)){
handleBackBtnClick();
}
}
@Override
public void update(float dt) {
Gdx.input.setInputProcessor(stage);
Gdx.input.setCatchBackKey(true);
handleInput();
stage.act(dt);
}
......
package com.gameware.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
......@@ -22,8 +20,8 @@ public class LoginState extends State {
private Table table;
private Label gameNameText = new Label("GameWare", skin, "big");
private Label stateTitleText = new Label("Log in / Create User", skin, "big");
private Label stateNameLabel = new Label("GameWare", skin, "big");
private Label secondStateNameLabel = new Label("Log in / Create User", skin, "big");
private String usernameInputText = "Username";
private TextField usernameInputField;
......@@ -105,11 +103,12 @@ public class LoginState extends State {
table = new Table();
table.setFillParent(true);
table.setBackground(background);
gameNameText.setFontScale(titleFontBigScale);
table.add(gameNameText).spaceBottom(spacingOnBottomInputFIeld);
stateNameLabel.setFontScale(titleFontBigScale);
table.add(stateNameLabel).spaceBottom(spacingOnBottomInputFIeld);
table.row();
table.add(stateTitleText).spaceBottom(spacingOnBottomInputFIeld);
table.add(secondStateNameLabel).spaceBottom(spacingOnBottomInputFIeld);
table.row();
table.add(makeUserInputField()).size(inputFieldWidth, inputFieldHeight).spaceBottom(spacingOnBottom);
table.row();
......
package com.gameware.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
......@@ -44,11 +45,10 @@ public class MenuState extends State{
Table innerTable = new Table();
innerTable.add(makeHighScoreBtn()).size(buttonWidth, buttonHeight).spaceBottom(spacingOnBottomInputFIeld).spaceRight(spacingOnBottom);
innerTable.add(makeOptionsBtn()).size(buttonWidth, buttonHeight).spaceBottom(spacingOnBottomInputFIeld);
innerTable.row();
innerTable.add(makeLogOutBtn()).spaceBottom(spacingOnBottom);
table.add(innerTable);
stage.addActor(table);
stage.addActor(makeLogOutBtn());
}
private TextButton makeSinglePlayerBtn(){
......@@ -97,15 +97,22 @@ public class MenuState extends State{
@Override
public void clicked(InputEvent e, float x, float y){ handleLogOutBtnClick(); }
});
logOutBtn.setPosition(backBtnPlacementX, backBtnPlacementY);
return logOutBtn;
}
@Override
protected void handleInput() { }
protected void handleInput() {
if (Gdx.input.isKeyJustPressed(Input.Keys.BACK)){
handleLogOutBtnClick();
}
}
@Override
public void update(float dt) {
Gdx.input.setInputProcessor(stage);
Gdx.input.setCatchBackKey(true);
handleInput();
stage.act(dt);
}
......
package com.gameware.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox;
......@@ -9,6 +10,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.Scaling;
import com.gameware.game.GameWare;
import com.gameware.game.models.Game;
......@@ -17,6 +19,7 @@ public class OptionsState extends State {
private Table table;
private int spacingOnBottom = Gdx.graphics.getHeight()/25;
private Label stateNameLabel = new Label("Options", skin, "big");
private String backBtnText = "Back";
private String musicToggleLabelText = "Music on/off";
......@@ -31,11 +34,16 @@ public class OptionsState extends State {
@Override
protected void handleInput() {
if (Gdx.input.isKeyJustPressed(Input.Keys.BACK)){
handleBackBtnClick();
}
}
@Override
public void update(float dt) {
Gdx.input.setInputProcessor(stage);
Gdx.input.setCatchBackKey(true);
handleInput();
stage.act(dt);
}
......@@ -68,6 +76,11 @@ public class OptionsState extends State {
private void makeStage(){
table = new Table();
table.setFillParent(true);
table.setBackground(background);
stateNameLabel.setFontScale(titleFontBigScale);
table.add(stateNameLabel).spaceBottom(spacingOnBottomInputFIeld);
table.row();
table.row();
table.add(makeLabel(musicToggleLabelText,skin)).spaceBottom(spacingOnBottom);
......@@ -82,12 +95,12 @@ public class OptionsState extends State {
//table.add(makeDarkModeCheckBox(skin)).spaceBottom(spacingOnBottom);
table.row();
table.add(makeBackBtn(skin));
stage.addActor(table);
stage.addActor(makeBackBtn());
}
private TextButton makeBackBtn(Skin skin){
private TextButton makeBackBtn(){
TextButton backBtn = new TextButton(backBtnText, skin);
backBtn.addListener(new ClickListener() {
@Override
......@@ -95,6 +108,7 @@ public class OptionsState extends State {
handleBackBtnClick();
}
});
backBtn.setPosition(backBtnPlacementX, backBtnPlacementY);
return backBtn;
}
......@@ -105,7 +119,8 @@ public class OptionsState extends State {
private CheckBox makeMusicCheckBox(Skin skin){
CheckBox musicToggle = new CheckBox("",skin);
musicToggle.getImage().setScale(2,2);
musicToggle.getImage().setScaling(Scaling.fill);
musicToggle.getImageCell().size(Gdx.graphics.getWidth()/10);
if((GameWare.getInstance().getMusicOn() && !musicToggle.isChecked()) || (!GameWare.getInstance().getMusicOn() && musicToggle.isChecked())){
musicToggle.toggle();
}
......@@ -118,12 +133,15 @@ public class OptionsState extends State {
private CheckBox makeSoundEffectCheckBox(Skin skin){
CheckBox soundEffectToggle = new CheckBox("",skin);
soundEffectToggle.getImage().setScaling(Scaling.fill);
soundEffectToggle.getImageCell().size(Gdx.graphics.getWidth()/10);
soundEffectToggle.addListener(new ClickListener() {
@Override
public void clicked(InputEvent e, float x, float y){ GameWare.getInstance().toggleSoundEffects(); }
});
soundEffectToggle.getImage().setScale(2,2);
if((GameWare.getInstance().getSoundEffects() && !soundEffectToggle.isChecked()) || (!GameWare.getInstance().getSoundEffects() && soundEffectToggle.isChecked())){
soundEffectToggle.toggle();
}
return soundEffectToggle;
}
......
package com.gameware.game.states;
import com.badlogic.gdx.graphics.Texture;
import com.gameware.game.GameWare;
import com.gameware.game.QueryIntermediate;
import com.gameware.game.models.Round;
import com.gameware.game.models.RoundCheck;
import com.gameware.game.models.Tournament;
import java.io.IOException;
......@@ -13,8 +15,9 @@ public abstract class PlayStateTemplate extends State {
private int score;
private Round round = null;
private Tournament tournament = null;
private Round nextRound = null;
private Round updatedRound = null;
protected float totalGameTime = 30f;
protected Texture screenshot = null;
public PlayStateTemplate(GameStateManager gsm){
super(gsm);
......@@ -30,8 +33,9 @@ public abstract class PlayStateTemplate extends State {
public void gameDone(){
String id = "";
//Find the id to the game just played
for (String key : GameWare.getInstance().getGameIdToPlayState().keySet()){
if ( GameWare.getInstance().getGameIdToPlayState().get(key) instanceof ColorRushState){
if ( GameWare.getInstance().getGameIdToPlayState().get(key).getClass() == this.getClass()){
id = key;
break;
}
......@@ -41,13 +45,38 @@ public abstract class PlayStateTemplate extends State {
}catch(Exception e){
System.out.println(e);
}
GameWare.getInstance().updateGameMap(id, new ColorRushState(gsm));
try {
//Add new instance of the game into the HashMap in GameWare
GameWare.getInstance().updateGameMap(id, this.getClass().getConstructor(GameStateManager.class).newInstance(gsm));
}catch(Exception e){
e.printStackTrace();
}
RoundCheck rc = null;
try{
rc = QueryIntermediate.doRoundCheck(tournament.get_id());
}catch(Exception e){
e.printStackTrace();
}
if(round == null) {
//Singleplayer
gsm.set(new ScoreState(gsm, this.score, new SinglePlayerSelectGameState(gsm)));
} else if(!rc.isActive() || (updatedRound.getTournamentPoints() != 0 && updatedRound.getRoundNr() == tournament.getTotalGames())){
//Tournament finished
gsm.set(new ScoreState(gsm, this.score, new FinishedTournamentState(gsm, tournament)));
} else{
// TODO: change when backend gives updated round object
//Tournament not finished
if(updatedRound.getTournamentPoints() != 0) {
try {
//Get new round if ready
Round nextRound = QueryIntermediate.getRoundFromTournament(tournament.get_id(), GameWare.getInstance().getPlayer().getId(), updatedRound.getRoundNr()+1);
gsm.set(new ScoreState(gsm, this.score, new ViewTournamentState(gsm, tournament, nextRound)));
// gsm.set(new ScoreState(gsm, this.score, new CreateJoinTournamentState(gsm)));
} catch (Exception e) {
e.printStackTrace();
}
} else {
gsm.set(new ScoreState(gsm, this.score, new ViewTournamentState(gsm, tournament, updatedRound)));
}
}
}
......@@ -59,7 +88,7 @@ public abstract class PlayStateTemplate extends State {
if(round==null) {
QueryIntermediate.postHighscore(GameWare.getInstance().getPlayer().getId(), gameId, this.score);
} else{
nextRound = QueryIntermediate.putRoundScore(round.get_id(),tournament.get_id(), this.score);
updatedRound = QueryIntermediate.putRoundScore(round.get_id(),tournament.get_id(), this.score);
}
}
}
......
package com.gameware.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
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.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.gameware.game.GameWare;
import com.gameware.game.QueryIntermediate;
import com.gameware.game.models.Game;
import com.gameware.game.models.Tournament;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class SinglePlayerSelectGameState extends State {
private Table table;
private Table innerTable;
private ScrollPane scrollPane;
private List<Game> games = new ArrayList<>();
private final String backBtnText = "Back";
private Label stateNameLabel = new Label("Singleplayer", skin, "big");
private Label secondStateNameLabel = new Label("Select game", skin, "big");
protected SinglePlayerSelectGameState(GameStateManager gsm) {
super(gsm);
try {
......@@ -33,31 +44,62 @@ public class SinglePlayerSelectGameState extends State {
System.out.println(e);
}
makeStage();
}
private void makeStage(){
table = new Table();
table.setFillParent(true);
table.setBackground(background);
stateNameLabel.setFontScale(titleFontBigScale);
table.add(stateNameLabel).spaceBottom(spacingOnBottomInputFIeld);
table.row();
table.add(secondStateNameLabel).spaceBottom(spacingOnBottom);
table.row();
innerTable = new Table();
Pixmap bgPixmap = new Pixmap(1,1, Pixmap.Format.RGB565);
bgPixmap.setColor(Color.SKY);
bgPixmap.fill();
TextureRegionDrawable textureRegionDrawableBg = new TextureRegionDrawable(new TextureRegion(new Texture(bgPixmap)));
innerTable.setBackground(textureRegionDrawableBg);
for (Game g : games){
TextButton gameBtn = new TextButton(g.getName(), skin);
innerTable.add(new Image(GameWare.getInstance().getGameIdToPlayState().get(g.getId()).screenshot)).pad(spacingOnBottom);
Table innerInnerTable = new Table();
innerInnerTable.add(new Label(g.getName(),skin)).spaceBottom(spacingOnBottom);
innerInnerTable.row();
TextButton gameBtn = new TextButton("Play!", skin);
gameBtn.addListener(new SinglePlayerSelectGameState.MyClickListener(g));
table.add(gameBtn).spaceBottom(spacingOnBottom);
table.row();
innerInnerTable.add(gameBtn);
innerTable.add(innerInnerTable);
innerTable.row();
}
table.add(makeBackBtn()).spaceBottom(spacingOnBottom);
stage.addActor(table);
scrollPane = new ScrollPane(innerTable, skin);
table.add(scrollPane).spaceBottom(spacingOnBottom);
table.getCell(scrollPane).size(Gdx.graphics.getWidth()/1.3f, Gdx.graphics.getHeight()/3f);
table.row();
stage.addActor(table);
stage.addActor(makeBackBtn());
}
@Override
protected void handleInput() {
if (Gdx.input.isKeyJustPressed(Input.Keys.BACK)){
handleBackBtnClick();
}
}
@Override
public void update(float dt) {
Gdx.input.setInputProcessor(stage);
Gdx.input.setCatchBackKey(true);
handleInput();
stage.act();
}
......@@ -82,9 +124,11 @@ public class SinglePlayerSelectGameState extends State {
@Override
public void clicked(InputEvent e, float x, float y){ handleBackBtnClick(); }
});
backBtn.setPosition(backBtnPlacementX, backBtnPlacementY);
return backBtn;
}
private void handleBackBtnClick(){
gsm.set(new MenuState(gsm));
}
......@@ -105,6 +149,7 @@ public class SinglePlayerSelectGameState extends State {
this.game = game;
}
@Override
public void clicked(InputEvent event, float x, float y) {
Map<String, PlayStateTemplate> map = GameWare.getInstance().getGameIdToPlayState();
State s = map.get(game.getId());
......
......@@ -24,11 +24,16 @@ public abstract class State {
protected static final float spacingOnBottomInputFIeld = Gdx.graphics.getHeight()/15;
protected static final int buttonWidth = Gdx.graphics.getWidth()/3;
protected static final int buttonHeight = Gdx.graphics.getHeight()/12;
protected static final int backBtnPlacementX = Gdx.graphics.getWidth()/18;
protected static final int backBtnPlacementY = Gdx.graphics.getHeight()/25;
protected TextureRegionDrawable background = new TextureRegionDrawable(new TextureRegion(new Texture("bg1.jpg")));
protected TextureRegionDrawable backgroundLighter = new TextureRegionDrawable(new TextureRegion(new Texture("bg1_lighter.jpg")));
protected TextureRegionDrawable backgroundScore = new TextureRegionDrawable(new TextureRegion(new Texture("bg_score.jpg")));
// protected TextureRegionDrawable buttonDisabledDrawable = new TextureRegionDrawable(new TextureRegion(new Texture(Gdx.files.internal("glassy/raw/button-disabled.png"))));
protected TextureRegionDrawable backgroundFinTourn = new TextureRegionDrawable(new TextureRegion(new Texture("bg1_finTourn.jpg")));
protected State(GameStateManager gsm){
this.gsm = gsm;
cam = new OrthographicCamera();
......
package com.gameware.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
......@@ -83,10 +85,9 @@ public class TournamentHighScoreState extends State{
}
scrollPane = new ScrollPane(innerTable, skin);
table.add(scrollPane).spaceBottom(spacingOnBottomInputFIeld).spaceBottom(spacingOnBottomInputFIeld);
table.row();
table.add(makeBackBtn()).spaceBottom(spacingOnBottom);
stage.addActor(table);
stage.addActor(makeBackBtn());
}
private TextButton makeBackBtn(){
......@@ -97,6 +98,7 @@ public class TournamentHighScoreState extends State{
handleBackBtnClick();
}
});
backBtn.setPosition(backBtnPlacementX, backBtnPlacementY);
return backBtn;
}
......@@ -106,10 +108,17 @@ public class TournamentHighScoreState extends State{
@Override
protected void handleInput() { }
protected void handleInput() {
if (Gdx.input.isKeyJustPressed(Input.Keys.BACK)){
handleBackBtnClick();
}
}
@Override
public void update(float dt) {
Gdx.input.setInputProcessor(stage);
Gdx.input.setCatchBackKey(true);
handleInput();
stage.act(dt);
}
......
package com.gameware.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
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.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.gameware.game.GameWare;
import com.gameware.game.QueryIntermediate;
import com.gameware.game.models.Game;
......@@ -30,10 +36,17 @@ public class ViewHighScoreForGameState extends State {
private double playerHS;
private static List<Highscore> highscores = new ArrayList<>();
private Boolean isNoHS = true;
private Label gameNameText;
private Label stateNameText;
private ScrollPane scrollPane;
private String backBtnText = "Back";
private String playerLabelText = "You";
private String playerLabelText = "Your score: ";
private String noHSLabelText = "";
private String globalHighScoresText = "Global High Scores";
private String colOneText = "Place";
private String colTwoText = "Name";
private String colThreeText = "Score";
protected ViewHighScoreForGameState(GameStateManager gsm, Game game) {
super(gsm);
......@@ -51,16 +64,24 @@ public class ViewHighScoreForGameState extends State {
isNoHS = true;
}
gameNameText = new Label(game.getName(), skin, "big");
stateNameText = new Label(globalHighScoresText, skin, "big");
makeStage();
}
@Override
protected void handleInput() {
if (Gdx.input.isKeyJustPressed(Input.Keys.BACK)){
handleBackBtnClick();
}
}
@Override
public void update(float dt) {
Gdx.input.setInputProcessor(stage);
Gdx.input.setCatchBackKey(true);
handleInput();
stage.act(dt);
}
......@@ -87,6 +108,7 @@ public class ViewHighScoreForGameState extends State {
handleBackBtnClick();
}
});
backBtn.setPosition(backBtnPlacementX, backBtnPlacementY);
return backBtn;
}
......@@ -106,7 +128,25 @@ public class ViewHighScoreForGameState extends State {
private void makeStage() {
outerTable = new Table();
outerTable.setFillParent(true);
outerTable.setBackground(background);
stateNameText.setFontScale(tinierTitleFontBigScale);
gameNameText.setFontScale(tinierTitleFontBigScale);
outerTable.add(gameNameText);
outerTable.row();
outerTable.add(stateNameText).spaceBottom(spacingOnBottomInputFIeld);
outerTable.row();
innerTable = new Table();
Pixmap bgPixmap = new Pixmap(1,1, Pixmap.Format.RGB565);
bgPixmap.setColor(Color.SKY);
bgPixmap.fill();
TextureRegionDrawable textureRegionDrawableBg = new TextureRegionDrawable(new TextureRegion(new Texture(bgPixmap)));
innerTable.setBackground(textureRegionDrawableBg);
innerTable.setFillParent(true);
if(isNoHS){
noHSLabelText = "No high scores recorded.";
......@@ -124,10 +164,23 @@ public class ViewHighScoreForGameState extends State {
outerTable.row();
outerTable.add(hsPane).spaceBottom(spacingOnBottomInputFIeld);
outerTable.getCell(hsPane).size(Gdx.graphics.getWidth()/1.1f, Gdx.graphics.getWidth()/2.5f);
outerTable.row();
outerTable.add(makeBackBtn()).spaceBottom(spacingOnBottom);
Table secondInnerTable = new Table();
Pixmap secondBgPixmap = new Pixmap(1,1, Pixmap.Format.RGB565);
secondBgPixmap.setColor(Color.SKY);
secondBgPixmap.fill();
TextureRegionDrawable secondTextureRegionDrawableBg = new TextureRegionDrawable(new TextureRegion(new Texture(secondBgPixmap)));
secondInnerTable.setBackground(secondTextureRegionDrawableBg);
Label playerLabel = new Label(playerLabelText,skin);
Label playerScoreLabel = new Label(String.valueOf(playerHS),skin);
secondInnerTable.add(playerLabel).spaceTop(spacingOnBottom).pad(50);
secondInnerTable.add(playerScoreLabel).spaceTop(spacingOnBottom).pad(50);
outerTable.add(secondInnerTable);
stage.addActor(outerTable);
stage.addActor(makeBackBtn());
}
private void createHighScoreList() {
......@@ -139,12 +192,17 @@ public class ViewHighScoreForGameState extends State {
e.printStackTrace();
}
innerTable.add(new Label(colOneText, skin));
innerTable.add(new Label(colTwoText, skin)).spaceRight(spacingOnBottom);
innerTable.add(new Label(colThreeText, skin));
innerTable.row();
int length = Math.min(highscores.size(),5);
for (int i = 0; i < length; i++){
Highscore hs = highscores.get(i);
Label placementLabel = new Label(String.valueOf(i+1)+". place: ",skin);
Label placementLabel = new Label(String.valueOf(i+1)+". ",skin);
Label nameLabel = new Label(hs.getName()+" ",skin);
Label scoreLabel = new Label(String.valueOf(hs.getValue()),skin);
......@@ -153,13 +211,6 @@ public class ViewHighScoreForGameState extends State {
innerTable.add(scoreLabel);
innerTable.row();
}
Label playerLabel = new Label(playerLabelText,skin);
Label playerScoreLabel = new Label(String.valueOf(playerHS),skin);
innerTable.add(playerLabel).spaceTop(spacingOnBottom);
innerTable.add(playerScoreLabel).spaceTop(spacingOnBottom);
innerTable.row();
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment