diff --git a/frontend/core/src/com/gameware/game/states/ViewHighScoreState.java b/frontend/core/src/com/gameware/game/states/ViewHighScoreState.java index 3f0e1a5308d4b0ec880f7353054f22bab8468c8e..b19a173cdc9810917e4962bbd980c7fb777bea7c 100644 --- a/frontend/core/src/com/gameware/game/states/ViewHighScoreState.java +++ b/frontend/core/src/com/gameware/game/states/ViewHighScoreState.java @@ -2,13 +2,22 @@ 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 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.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.QueryIntermediate; import com.gameware.game.GameWare; import com.gameware.game.models.Game; @@ -21,9 +30,15 @@ import java.io.IOException; public class ViewHighScoreState extends State { private Table table; + private Table innerTable; + private ScrollPane tournamentsPane; private List<Game> games; 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) { super(gsm); @@ -35,18 +50,46 @@ public class ViewHighScoreState extends State { e.printStackTrace(); } + 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(BtnText, skin); gameBtn.addListener(new ViewHighScoreState.MyClickListener(g)); - table.add(gameBtn).spaceBottom(spacingOnBottom); - table.row(); + innerInnerTable.add(gameBtn); + 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(makeBackBtn()); }