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