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

#50 makes playBtn in VTS disabled istead of gone

parent 01824708
No related branches found
No related tags found
1 merge request!66Resolve "Make it look pretty"
frontend/android/assets/glassy/raw/button-disabled.png

15.8 KiB

......@@ -302,7 +302,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;
}
......
......@@ -50,11 +50,12 @@ public abstract class PlayStateTemplate extends State {
}catch(Exception e){
e.printStackTrace();
}
//TODO: if (tournamentpoints != null && currentRoundNr == (tournament.totalGames) -> gå til finished state
if(round == null) {
gsm.set(new ScoreState(gsm, this.score, new SinglePlayerSelectGameState(gsm)));
} else{
gsm.set(new ScoreState(gsm, this.score, new ViewTournamentState(gsm, tournament, nextRound)));
// gsm.set(new ScoreState(gsm, this.score, new CreateJoinTournamentState(gsm)));
}
}
......
......@@ -30,6 +30,7 @@ public abstract class State {
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 State(GameStateManager gsm){
this.gsm = gsm;
......
......@@ -2,8 +2,11 @@ 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.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Touchable;
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
......@@ -22,6 +25,8 @@ public class ViewTournamentState extends State {
private Round round;
private Dialog dialog;
TextButton playBtn;
private int padding = 50;
private Label stateNameText;
......@@ -29,11 +34,10 @@ public class ViewTournamentState extends State {
private String leaveBtnText = "Leave";
private String playBtnText = "Play Round";
private String viewPointsBtnText = "View Points";
private String nrPlayersText = "Players in tournament";
private String roundsLeftText = "Rounds left";
private String nrPlayersText = "Players in tournament:";
private String roundsLeftText = "Rounds left:";
public class LeaveClickListener extends ClickListener{
//TODO: if (tournamentpoints != null && currentRoundNr == (tournament.totalGames) -> gå til finished state
public void clicked(InputEvent event, float x, float y) {
handleLeaveBtnClick();
......@@ -57,11 +61,11 @@ public class ViewTournamentState extends State {
table.add(stateNameText).spaceBottom(spacingOnBottomInputFIeld);
table.row();
if(round.isPlayed()){
table.add(new Label("You have aldready played\nWait for others to finish", skin)).spaceBottom(spacingOnBottom);
}else {
// if(round.isPlayed()){
// table.add(new Label("You have aldready played\nWait for others to finish", skin)).spaceBottom(spacingOnBottom);
// }else {
table.add(makePlayBtn()).size(buttonWidth*1.4f, buttonHeight*1.2f).spaceBottom(spacingOnBottom);
}
// }
table.row();
PlayStateTemplate state = GameWare.getInstance().getGameIdToPlayState().get(round.getGameId());
......@@ -104,7 +108,7 @@ public class ViewTournamentState 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
}
......@@ -122,15 +126,27 @@ public class ViewTournamentState extends State {
}
private TextButton makePlayBtn(){
TextButton playBtn = new TextButton(playBtnText, skin);
if(round.isPlayed()){
TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
textButtonStyle.up = skin.newDrawable("button", Color.GRAY);
textButtonStyle.down = skin.newDrawable("button", Color.DARK_GRAY);
textButtonStyle.checked = skin.newDrawable("button", Color.DARK_GRAY);
textButtonStyle.over = skin.newDrawable("button", Color.LIGHT_GRAY);
textButtonStyle.font = skin.getFont("font-big");
textButtonStyle.fontColor = Color.LIGHT_GRAY;
playBtn = new TextButton(playBtnText, textButtonStyle);
playBtn.setTouchable(Touchable.disabled);
}
else{
playBtn = new TextButton(playBtnText, skin);
playBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent e, float x, float y){
handlePlayBtnClick();
}
});
if(round.isPlayed()){
playBtn.setDisabled(true);
}
return playBtn;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment