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

#Adds game name in View Tournament and fixed scorestate score width problem

parent c83f79cf
No related branches found
No related tags found
1 merge request!89Resolve "Small frontend stuff"
package com.gameware.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.actions.DelayAction;
import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction;
......@@ -22,6 +23,7 @@ public class ScoreState extends State {
// Variables
private float currentTime = 0f;
private float scoreLabelDifferance = 0f;
public ScoreState(GameStateManager gsm, int score, State nextState){
......@@ -31,6 +33,10 @@ public class ScoreState extends State {
scoreLabel.setText(score+"");
continueLabel.getColor().a = 0;
GlyphLayout g = new GlyphLayout();
g.setText(skin.getFont("font-big"), score+"");
scoreLabelDifferance = (g.width - (g.width*titleFontBigScale*2))/2;
makeStage();
}
......@@ -54,7 +60,7 @@ public class ScoreState extends State {
scoreContainer.addAction(Actions.sequence(
new DelayAction(1f),
Actions.parallel(
Actions.moveBy(-(titleFontBigScale*35), -(titleFontBigScale*50),2),
Actions.moveBy(scoreLabelDifferance, -(titleFontBigScale*50),2),
Actions.scaleTo(titleFontBigScale*2, titleFontBigScale*2, 2))));
continueLabel.addAction(Actions.sequence(
......
......@@ -80,7 +80,7 @@ public class TournamentHighScoreState extends State{
rootTable.add(subHeadLabel).expandY().top();
rootTable.row();
rootTable.add(makeHighScoreTable());
rootTable.add(makeHighScoreTable()).maxHeight(Gdx.graphics.getHeight()/1.75f);
rootTable.row();
Table yourScoreTable = new Table();
......@@ -88,7 +88,7 @@ public class TournamentHighScoreState extends State{
yourScoreTable.setBackground(backgroundTableBlueRounded);
yourScoreTable.add(yourScoreThisRoundLabel);
yourScoreTable.add(new Label(((int)round.getScoreValue())+"", skin));
rootTable.add(yourScoreTable);
rootTable.add(yourScoreTable).height(Gdx.graphics.getHeight()/10);
rootTable.row();
rootTable.add(makeBackBtn()).expand().bottom().left();
......@@ -100,12 +100,12 @@ public class TournamentHighScoreState extends State{
private Table makeHighScoreTable(){
Table innerTable = new Table();
innerTable.pad(padding);
innerTable.defaults().space(spacingLittle);
innerTable.defaults().space(spacingLittle).expand();
innerTable.setBackground(backgroundTableBlueRounded);
innerTable.add(colOneLabel).expandX();
innerTable.add(makeRow(colTwoLabel,totalDialog)).expandX();
innerTable.add(makeRow(colThreeLabel,lastRoundDialog)).expandX();
innerTable.add(colOneLabel).top();
innerTable.add(makeRow(colTwoLabel,totalDialog)).top();
innerTable.add(makeRow(colThreeLabel,lastRoundDialog)).top();
innerTable.row();
for(Point point : points){
......
......@@ -16,10 +16,13 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.Align;
import com.gameware.game.GameWare;
import com.gameware.game.QueryIntermediate;
import com.gameware.game.models.Game;
import com.gameware.game.models.Round;
import com.gameware.game.models.Tournament;
import com.gameware.game.sprites.LoadingText;
import java.util.List;
public class ViewTournamentState extends State {
// Data
......@@ -40,6 +43,8 @@ public class ViewTournamentState extends State {
private final String roundsLeftText = "Rounds left:";
private final String leaveDialogText = "Are you sure want to\nleave ";
private String gameName = "";
// Variables
private final float playBtnWidth = buttonWidth*1.4f;
private final float playBtnHeight = buttonHeight*1.2f;
......@@ -60,6 +65,18 @@ public class ViewTournamentState extends State {
this.round = r;
titleLabel.setText(tournament.getName());
roundDeadline.setText("Round deadline\n"+round.getDeadlineDate().toLocaleString());
try{
List<Game> games = GameWare.getInstance().getGames();
for (Game g : games){
if(g.getId().equals(r.getGameId())){
gameName = g.getName();
}
}
}catch(Exception e){
e.printStackTrace();
}
makeStage();
}
......@@ -78,8 +95,15 @@ public class ViewTournamentState extends State {
rootTable.add(makePlayBtn()).size(playBtnWidth, playBtnHeight).colspan(2);
rootTable.row();
Table currentRoundTable = new Table();
currentRoundTable.pad(padding);
currentRoundTable.setBackground(backgroundTableBlueRounded);
currentRoundTable.add(new Label("This round:\n\n"+gameName,skin)).space(spacingLittle);
PlayStateTemplate state = GameWare.getInstance().getGameIdToPlayState().get(round.getGameId());
rootTable.add(new Image(state.screenshot)).width(imageWidthAndHeigh).height(imageWidthAndHeigh).spaceBottom(spacingMedium).colspan(2);
currentRoundTable.add(new Image(state.screenshot)).width(imageWidthAndHeigh).height(imageWidthAndHeigh).spaceBottom(spacingMedium).colspan(2);
rootTable.add(currentRoundTable).maxHeight(Gdx.graphics.getHeight()/5).colspan(2);
rootTable.row();
rootTable.add(new Label(nrPlayersText+" "+tournament.getCurrentPlayers(), skin)).colspan(2);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment