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

#50 makes ViewHighScoreState prettier

parent 20271da3
No related branches found
No related tags found
1 merge request!66Resolve "Make it look pretty"
...@@ -2,13 +2,22 @@ package com.gameware.game.states; ...@@ -2,13 +2,22 @@ package com.gameware.game.states;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input; 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.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputEvent;
import java.util.List; import java.util.List;
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.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.gameware.game.QueryIntermediate; import com.gameware.game.QueryIntermediate;
import com.gameware.game.GameWare; import com.gameware.game.GameWare;
import com.gameware.game.models.Game; import com.gameware.game.models.Game;
...@@ -21,9 +30,15 @@ import java.io.IOException; ...@@ -21,9 +30,15 @@ import java.io.IOException;
public class ViewHighScoreState extends State { public class ViewHighScoreState extends State {
private Table table; private Table table;
private Table innerTable;
private ScrollPane tournamentsPane;
private List<Game> games; private List<Game> games;
private String backBtnText = "Back"; private String backBtnText = "Back";
private String BtnText = "View High Score!";
private Label stateNameLabel = new Label("High Scores", skin, "big");
private Label secondStateNameLabel = new Label("Select game", skin, "big");
public ViewHighScoreState(GameStateManager gsm) { public ViewHighScoreState(GameStateManager gsm) {
super(gsm); super(gsm);
...@@ -35,18 +50,46 @@ public class ViewHighScoreState extends State { ...@@ -35,18 +50,46 @@ public class ViewHighScoreState extends State {
e.printStackTrace(); e.printStackTrace();
} }
makeStage();
}
private void makeStage(){
table = new Table(); table = new Table();
table.setFillParent(true); table.setFillParent(true);
table.setBackground(background);
stateNameLabel.setFontScale(titleFontBigScale);
table.add(stateNameLabel).spaceBottom(spacingOnBottomInputFIeld);
table.row();
table.add(secondStateNameLabel).spaceBottom(spacingOnBottom);
table.row(); 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){ 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(BtnText, skin);
gameBtn.addListener(new ViewHighScoreState.MyClickListener(g)); gameBtn.addListener(new ViewHighScoreState.MyClickListener(g));
table.add(gameBtn).spaceBottom(spacingOnBottom); innerInnerTable.add(gameBtn);
table.row(); innerTable.add(innerInnerTable);
innerTable.row();
} }
tournamentsPane = new ScrollPane(innerTable, skin);
table.add(tournamentsPane).spaceBottom(spacingOnBottom);
table.getCell(tournamentsPane).size(Gdx.graphics.getWidth()/1.2f, Gdx.graphics.getHeight()/3f);
table.row();
stage.addActor(table); stage.addActor(table);
stage.addActor(makeBackBtn()); stage.addActor(makeBackBtn());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment