Skip to content
Snippets Groups Projects
Commit 4aebc83b authored by Ivar Nordvik Myrstad's avatar Ivar Nordvik Myrstad
Browse files

Merge branch '90-small-frontend-stuff' into 'dev'

Resolve "Small frontend stuff"

Closes #90

See merge request !89
parents f3794195 d7dc8769
No related branches found
No related tags found
1 merge request!89Resolve "Small frontend stuff"
frontend/android/assets/tableBG.png

725 B | W: | H:

frontend/android/assets/tableBG.png

2.09 KiB | W: | H:

frontend/android/assets/tableBG.png
frontend/android/assets/tableBG.png
frontend/android/assets/tableBG.png
frontend/android/assets/tableBG.png
  • 2-up
  • Swipe
  • Onion skin
frontend/android/assets/tableBGRounded.png

3.67 KiB | W: | H:

frontend/android/assets/tableBGRounded.png

9.29 KiB | W: | H:

frontend/android/assets/tableBGRounded.png
frontend/android/assets/tableBGRounded.png
frontend/android/assets/tableBGRounded.png
frontend/android/assets/tableBGRounded.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -60,6 +60,10 @@ public class CreateNewTournamentState extends State { ...@@ -60,6 +60,10 @@ public class CreateNewTournamentState extends State {
private final String createBtnText = "Create"; private final String createBtnText = "Create";
private final String nextBtnText = "Next"; private final String nextBtnText = "Next";
private final String noNameText = "No name given";
private final String noGamesSelectedText = "No games selected";
private final String IOExceptionText = "Something went wrong when\ncreating the tournament";
// Input fields // Input fields
private TextField nameInputField = new TextField("",skin); private TextField nameInputField = new TextField("",skin);
...@@ -80,7 +84,7 @@ public class CreateNewTournamentState extends State { ...@@ -80,7 +84,7 @@ public class CreateNewTournamentState extends State {
private final int inputFieldHeight = Gdx.graphics.getHeight()/15; private final int inputFieldHeight = Gdx.graphics.getHeight()/15;
private final int nameFieldWidth = Gdx.graphics.getWidth()/3; private final int nameFieldWidth = Gdx.graphics.getWidth()/3;
private final float checkBoxSize = Gdx.graphics.getWidth()/15; private final float checkBoxSize = Gdx.graphics.getWidth()/15;
private final float scrollPaneWidth = Gdx.graphics.getWidth()/1.13f; private final float scrollPaneWidth = Gdx.graphics.getWidth()/1.14f;
private final float scrollPaneHeight = Gdx.graphics.getHeight()/2.3f; private final float scrollPaneHeight = Gdx.graphics.getHeight()/2.3f;
private Table rootTable; private Table rootTable;
...@@ -263,7 +267,7 @@ public class CreateNewTournamentState extends State { ...@@ -263,7 +267,7 @@ public class CreateNewTournamentState extends State {
dialog.getContentTable().add(label).width(Gdx.graphics.getWidth()/1.5f).pad(dialog.getHeight()/5f).padBottom(0); dialog.getContentTable().add(label).width(Gdx.graphics.getWidth()/1.5f).pad(dialog.getHeight()/5f).padBottom(0);
dialog.button("Okay", true); //sends "true" as the result dialog.button("Okay", true); //sends "true" as the result
dialog.getButtonTable().pad(dialog.getHeight()/5f); dialog.getButtonTable().pad(dialog.getHeight()/2f);
return dialog; return dialog;
} }
...@@ -287,8 +291,14 @@ public class CreateNewTournamentState extends State { ...@@ -287,8 +291,14 @@ public class CreateNewTournamentState extends State {
public void clicked(InputEvent e, float x, float y){ public void clicked(InputEvent e, float x, float y){
if(GameWare.getInstance().isSoundEffectsOn()){ buttonPressSound.play(); } if(GameWare.getInstance().isSoundEffectsOn()){ buttonPressSound.play(); }
if(getTournamentName().equals("")){
errorLabel.setText(noNameText);
return;
}
page ++; page ++;
errorLabel.setText("");
nameUserInput = getTournamentName(); nameUserInput = getTournamentName();
timePerRoundUserInput = getTimePerRound(); timePerRoundUserInput = getTimePerRound();
maxPlayersUserInput = getMaxPlayers(); maxPlayersUserInput = getMaxPlayers();
...@@ -363,6 +373,7 @@ public class CreateNewTournamentState extends State { ...@@ -363,6 +373,7 @@ public class CreateNewTournamentState extends State {
stage.clear(); stage.clear();
makeStage(); makeStage();
errorLabel.setText("");
nameInputField.setText(nameUserInput); nameInputField.setText(nameUserInput);
timePerRoundSelectBox.setSelected(timePerRoundUserInput); timePerRoundSelectBox.setSelected(timePerRoundUserInput);
maxPlayersSelectBox.setSelected(maxPlayersUserInput); maxPlayersSelectBox.setSelected(maxPlayersUserInput);
...@@ -374,21 +385,18 @@ public class CreateNewTournamentState extends State { ...@@ -374,21 +385,18 @@ public class CreateNewTournamentState extends State {
private void handleCreateBtnClick(){ private void handleCreateBtnClick(){
if(GameWare.getInstance().isSoundEffectsOn()){ buttonPressSound.play(); } if(GameWare.getInstance().isSoundEffectsOn()){ buttonPressSound.play(); }
if(chosenGames.isEmpty()){ if(chosenGames.isEmpty()){
errorLabel.setText("No games chosen."); errorLabel.setText(noGamesSelectedText);
return;
}
if(getTournamentName().equals("")){
errorLabel.setText("No name given.");
return; return;
} }
try { try {
tournament = new Tournament(GameWare.getInstance().getPlayer().getId(),chosenGames,nameUserInput, timePerRoundUserInput, maxPlayersUserInput, roundsPerGameUserInput,1,chosenGames.size(),startDelayUserInput); tournament = new Tournament(GameWare.getInstance().getPlayer().getId(),chosenGames,nameUserInput, timePerRoundUserInput, maxPlayersUserInput, roundsPerGameUserInput,1,chosenGames.size(),startDelayUserInput);
tournamentFromDB = QueryIntermediate.createNewTournament(tournament); tournamentFromDB = QueryIntermediate.createNewTournament(tournament);
round = QueryIntermediate.getRoundFromTournament(tournamentFromDB.get_id(), GameWare.getInstance().getPlayer().getId(), tournamentFromDB.getCurrentRound()); round = QueryIntermediate.getRoundFromTournament(tournamentFromDB.get_id(), GameWare.getInstance().getPlayer().getId(), tournamentFromDB.getCurrentRound());
gsm.set(new ViewTournamentState(gsm,tournamentFromDB,round));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
errorLabel.setText(IOExceptionText);
} }
gsm.set(new ViewTournamentState(gsm,tournamentFromDB,round));
} }
private String getTournamentName(){ private String getTournamentName(){
......
...@@ -23,7 +23,8 @@ public class LoginState extends State { ...@@ -23,7 +23,8 @@ public class LoginState extends State {
// Labels // Labels
private final Label titleLabel = new Label("GameWare", skin, "big"); private final Label titleLabel = new Label("GameWare", skin, "big");
private final Label subHeadLabel = new Label("Log in / Create User", skin, "big"); private final Label subHeadLabelLogIn = new Label("Log in", skin, "big");
private final Label subHeadLabelCreateUser = new Label("Create User", skin, "big");
private Label errorLabel = new Label("", skin, "error"); private Label errorLabel = new Label("", skin, "error");
// Input fields // Input fields
...@@ -31,22 +32,23 @@ public class LoginState extends State { ...@@ -31,22 +32,23 @@ public class LoginState extends State {
private TextField usernameInputField; private TextField usernameInputField;
private String passwordInputText = "Password"; private String passwordInputText = "Password";
private TextField passwordInputField; private TextField passwordInputField;
private String confirmPasswordInputText = "Confirm password";
private TextField confirmPasswordInputField;
private final char passwordCharacter = '*'; private final char passwordCharacter = '*';
private final int inputFieldWidth = Gdx.graphics.getWidth()/2; private final int inputFieldWidth = Gdx.graphics.getWidth()/2;
private final int inputFieldHeight = Gdx.graphics.getHeight()/15; private final int inputFieldHeight = Gdx.graphics.getHeight()/15;
// Button texts // Button texts
private final String loginBtnText = "Log in"; private final String loginBtnText = "Log in";
private final String createUserText = "Create User";
private final String signUpBtnText = "Sign Up"; private final String signUpBtnText = "Sign Up";
private final String backText = "Back";
// Feedback texts // Feedback texts
private final String wrongLoginText = "User not found"; private final String wrongLoginText = "User not found";
private final String takenUsernameText = "Username already taken"; private final String takenUsernameText = "Username already taken";
private final String ioExceptionText = "Something went wrong with query"; private final String ioExceptionText = "Something went wrong with query";
private final String passwordNotMatchingText = "Passwords do not match";
// Feedback label animation
private final int animationDelay = 2;
private final int animationDuration = 1;
// Loading text // Loading text
private LoadingText loadingText = new LoadingText(); private LoadingText loadingText = new LoadingText();
...@@ -54,6 +56,10 @@ public class LoginState extends State { ...@@ -54,6 +56,10 @@ public class LoginState extends State {
private boolean signUpBtnClicked = false; private boolean signUpBtnClicked = false;
// Variables
private int page = 0;
public LoginState(GameStateManager gsm) { public LoginState(GameStateManager gsm) {
super(gsm); super(gsm);
makeStage(); makeStage();
...@@ -64,9 +70,11 @@ public class LoginState extends State { ...@@ -64,9 +70,11 @@ public class LoginState extends State {
// Add widgets // Add widgets
titleLabel.setFontScale(titleFontBigScale); titleLabel.setFontScale(titleFontBigScale);
rootTable.add(titleLabel).expandY(); rootTable.add(titleLabel).expandY().top();
rootTable.row(); rootTable.row();
rootTable.add(subHeadLabel).expandY();
if (page == 0) {
rootTable.add(subHeadLabelLogIn).expandY();
rootTable.row(); rootTable.row();
rootTable.add(makeUserInputField()).size(inputFieldWidth, inputFieldHeight); rootTable.add(makeUserInputField()).size(inputFieldWidth, inputFieldHeight);
rootTable.row(); rootTable.row();
...@@ -76,7 +84,22 @@ public class LoginState extends State { ...@@ -76,7 +84,22 @@ public class LoginState extends State {
rootTable.row(); rootTable.row();
rootTable.add(makeLoginBtn()).size(buttonWidth, buttonHeight); rootTable.add(makeLoginBtn()).size(buttonWidth, buttonHeight);
rootTable.row(); rootTable.row();
rootTable.add(makeSignUpBtn()).size(buttonWidth, buttonHeight).padBottom(spacingLarge); rootTable.add(makeCreateUserBtn()).size(buttonWidth, buttonHeight).padBottom(spacingMedium).expandY().top();
} else if (page == 1){
rootTable.add(subHeadLabelCreateUser).expandY().spaceBottom(spacingMedium);
rootTable.row();
rootTable.add(makeUserInputField()).size(inputFieldWidth, inputFieldHeight);
rootTable.row();
rootTable.add(makePasswordInputField()).size(inputFieldWidth, inputFieldHeight);
rootTable.row();
rootTable.add(makeConfirmPasswordInputField()).size(inputFieldWidth, inputFieldHeight);
rootTable.row();
rootTable.add(errorLabel);
rootTable.row();
rootTable.add(makeSignUpBtn()).size(buttonWidth, buttonHeight);
rootTable.row();
rootTable.add(makeBackBtn()).expand().bottom().left();
}
removeKeyPadAtTouch(); removeKeyPadAtTouch();
...@@ -116,6 +139,22 @@ public class LoginState extends State { ...@@ -116,6 +139,22 @@ public class LoginState extends State {
return passwordInputField; return passwordInputField;
} }
private TextField makeConfirmPasswordInputField( ){
confirmPasswordInputField = new TextField(confirmPasswordInputText, skin);
confirmPasswordInputField.setPasswordCharacter(passwordCharacter);
confirmPasswordInputField.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
if(confirmPasswordInputField.getText().equals(confirmPasswordInputText)){
confirmPasswordInputField.setText("");
confirmPasswordInputField.setPasswordMode(true);
}
}
});
return confirmPasswordInputField;
}
private TextButton makeLoginBtn( ){ private TextButton makeLoginBtn( ){
TextButton loginBtn = new TextButton(loginBtnText, skin); TextButton loginBtn = new TextButton(loginBtnText, skin);
loginBtn.addListener(new ClickListener() { loginBtn.addListener(new ClickListener() {
...@@ -127,17 +166,51 @@ public class LoginState extends State { ...@@ -127,17 +166,51 @@ public class LoginState extends State {
return loginBtn; return loginBtn;
} }
private TextButton makeCreateUserBtn( ){
TextButton createUserBtn = new TextButton(createUserText, skin);
createUserBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent e, float x, float y){
page ++;
errorLabel.setText("");
stage.clear();
makeStage();
}
});
return createUserBtn;
}
private TextButton makeSignUpBtn( ){ private TextButton makeSignUpBtn( ){
TextButton signUpBtn = new TextButton(signUpBtnText, skin); TextButton signUpBtn = new TextButton(signUpBtnText, skin);
signUpBtn.addListener(new ClickListener() { signUpBtn.addListener(new ClickListener() {
@Override @Override
public void clicked(InputEvent e, float x, float y){ public void clicked(InputEvent e, float x, float y){
try{
isValidPassword();
setSignUpBtnClicked(); setSignUpBtnClicked();
}catch(IllegalArgumentException exception){
errorLabel.setText(passwordNotMatchingText);
}
} }
}); });
return signUpBtn; return signUpBtn;
} }
private TextButton makeBackBtn(){
TextButton backBtn = new TextButton(backText, skin);
backBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent e, float x, float y){
page --;
errorLabel.setText("");
stage.clear();
makeStage();
}
});
return backBtn;
}
// Handle click methods // Handle click methods
private void handleLoginBtnClick(){ private void handleLoginBtnClick(){
...@@ -157,12 +230,6 @@ public class LoginState extends State { ...@@ -157,12 +230,6 @@ public class LoginState extends State {
}catch(Exception e) { }catch(Exception e) {
e.printStackTrace(); e.printStackTrace();
// Add animation
errorLabel.getColor().a = 1;
errorLabel.addAction(Actions.sequence(
new DelayAction(animationDelay),
Actions.fadeOut(animationDuration)));
// Different feedback text depending on which exception // Different feedback text depending on which exception
if (e instanceof NoSuchElementException) { if (e instanceof NoSuchElementException) {
errorLabel.setText(wrongLoginText); errorLabel.setText(wrongLoginText);
...@@ -191,12 +258,6 @@ public class LoginState extends State { ...@@ -191,12 +258,6 @@ public class LoginState extends State {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
// Add animation
errorLabel.getColor().a = 1;
errorLabel.addAction(Actions.sequence(
new DelayAction(animationDelay),
Actions.fadeOut(animationDuration)));
// Different feedback text depending on which exception // Different feedback text depending on which exception
if (e instanceof NoSuchElementException) { if (e instanceof NoSuchElementException) {
errorLabel.setText(takenUsernameText); errorLabel.setText(takenUsernameText);
...@@ -221,6 +282,12 @@ public class LoginState extends State { ...@@ -221,6 +282,12 @@ public class LoginState extends State {
} }
private void isValidPassword() throws IllegalArgumentException {
if(!passwordInputField.getText().equals(confirmPasswordInputField.getText())){
throw new IllegalArgumentException();
}
}
@Override @Override
public void update(float dt) { public void update(float dt) {
super.update(dt); super.update(dt);
...@@ -264,5 +331,7 @@ public class LoginState extends State { ...@@ -264,5 +331,7 @@ public class LoginState extends State {
public void reset() { public void reset() {
usernameInputField.setText(usernameInputText); usernameInputField.setText(usernameInputText);
passwordInputField.setText(passwordInputText); passwordInputField.setText(passwordInputText);
confirmPasswordInputField.setText(confirmPasswordInputText);
errorLabel.setText("");
} }
} }
...@@ -41,6 +41,8 @@ public class OptionsState extends State { ...@@ -41,6 +41,8 @@ public class OptionsState extends State {
// Make inner Table + adds labels and checkboxes // Make inner Table + adds labels and checkboxes
Table innerTable = new Table(); Table innerTable = new Table();
innerTable.pad(padding);
innerTable.setBackground(backgroundTableBlueRounded);
innerTable.defaults().spaceBottom(spacingMedium); innerTable.defaults().spaceBottom(spacingMedium);
innerTable.columnDefaults(0).spaceRight(spacingMedium); innerTable.columnDefaults(0).spaceRight(spacingMedium);
......
package com.gameware.game.states; package com.gameware.game.states;
import com.badlogic.gdx.Gdx; 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.Actions;
import com.badlogic.gdx.scenes.scene2d.actions.DelayAction; import com.badlogic.gdx.scenes.scene2d.actions.DelayAction;
import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction; import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction;
...@@ -22,6 +23,7 @@ public class ScoreState extends State { ...@@ -22,6 +23,7 @@ public class ScoreState extends State {
// Variables // Variables
private float currentTime = 0f; private float currentTime = 0f;
private float scoreLabelDifferance = 0f;
public ScoreState(GameStateManager gsm, int score, State nextState){ public ScoreState(GameStateManager gsm, int score, State nextState){
...@@ -31,6 +33,10 @@ public class ScoreState extends State { ...@@ -31,6 +33,10 @@ public class ScoreState extends State {
scoreLabel.setText(score+""); scoreLabel.setText(score+"");
continueLabel.getColor().a = 0; continueLabel.getColor().a = 0;
GlyphLayout g = new GlyphLayout();
g.setText(skin.getFont("font-big"), score+"");
scoreLabelDifferance = (g.width - (g.width*titleFontBigScale*2))/2;
makeStage(); makeStage();
} }
...@@ -54,7 +60,7 @@ public class ScoreState extends State { ...@@ -54,7 +60,7 @@ public class ScoreState extends State {
scoreContainer.addAction(Actions.sequence( scoreContainer.addAction(Actions.sequence(
new DelayAction(1f), new DelayAction(1f),
Actions.parallel( Actions.parallel(
Actions.moveBy(-(titleFontBigScale*35), -(titleFontBigScale*50),2), Actions.moveBy(scoreLabelDifferance, -(titleFontBigScale*50),2),
Actions.scaleTo(titleFontBigScale*2, titleFontBigScale*2, 2)))); Actions.scaleTo(titleFontBigScale*2, titleFontBigScale*2, 2))));
continueLabel.addAction(Actions.sequence( continueLabel.addAction(Actions.sequence(
......
...@@ -4,10 +4,13 @@ import com.badlogic.gdx.Gdx; ...@@ -4,10 +4,13 @@ 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.Color;
import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Dialog;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Label;
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.utils.Align;
import com.gameware.game.GameWare; import com.gameware.game.GameWare;
import com.gameware.game.QueryIntermediate; import com.gameware.game.QueryIntermediate;
import com.gameware.game.models.Point; import com.gameware.game.models.Point;
...@@ -32,10 +35,17 @@ public class TournamentHighScoreState extends State{ ...@@ -32,10 +35,17 @@ public class TournamentHighScoreState extends State{
private final Label colTwoLabel = new Label("Total", skin, "big"); private final Label colTwoLabel = new Label("Total", skin, "big");
private final Label colThreeLabel = new Label("Last Round", skin, "big"); private final Label colThreeLabel = new Label("Last Round", skin, "big");
private final Label yourScoreThisRoundLabel = new Label("Your score this round: ", skin); private final Label yourScoreThisRoundLabel = new Label("Your score this round: ", skin);
private final Label totalDialogLabel = new Label("Total number of tournament points (TP). The number of TP you get, depends on how many players there are in the tournament. Therefore no TP will be given until all players are finished with their round.\n\nFor example if there are 3 players in a tournament, then the one with the highest score would get 30 TP and the player with the lowest score would get 10 TP. ", skin);
private final Label lastRoundLabel = new Label("Tournament points (TP) recieved in the last round of the tournament. TP depends on every players score, so no TP will be given until all players are finished with their round.", skin);
// Texts // Texts
private final String backBtnText = "Back"; private final String backBtnText = "Back";
// Dialogs
private Dialog totalDialog;
private Dialog lastRoundDialog;
// Variables // Variables
private final Color scrollPaneBGColor = Color.SKY; private final Color scrollPaneBGColor = Color.SKY;
private final int padding = 50; private final int padding = 50;
...@@ -51,6 +61,10 @@ public class TournamentHighScoreState extends State{ ...@@ -51,6 +61,10 @@ public class TournamentHighScoreState extends State{
}catch(Exception e){ }catch(Exception e){
e.printStackTrace(); e.printStackTrace();
} }
totalDialog = makeDialog(totalDialogLabel);
lastRoundDialog = makeDialog(lastRoundLabel);
makeStage(); makeStage();
} }
...@@ -66,7 +80,7 @@ public class TournamentHighScoreState extends State{ ...@@ -66,7 +80,7 @@ public class TournamentHighScoreState extends State{
rootTable.add(subHeadLabel).expandY().top(); rootTable.add(subHeadLabel).expandY().top();
rootTable.row(); rootTable.row();
rootTable.add(makeHighScoreTable()); rootTable.add(makeHighScoreTable()).maxHeight(Gdx.graphics.getHeight()/1.75f);
rootTable.row(); rootTable.row();
Table yourScoreTable = new Table(); Table yourScoreTable = new Table();
...@@ -74,7 +88,7 @@ public class TournamentHighScoreState extends State{ ...@@ -74,7 +88,7 @@ public class TournamentHighScoreState extends State{
yourScoreTable.setBackground(backgroundTableBlueRounded); yourScoreTable.setBackground(backgroundTableBlueRounded);
yourScoreTable.add(yourScoreThisRoundLabel); yourScoreTable.add(yourScoreThisRoundLabel);
yourScoreTable.add(new Label(((int)round.getScoreValue())+"", skin)); yourScoreTable.add(new Label(((int)round.getScoreValue())+"", skin));
rootTable.add(yourScoreTable); rootTable.add(yourScoreTable).height(Gdx.graphics.getHeight()/10);
rootTable.row(); rootTable.row();
rootTable.add(makeBackBtn()).expand().bottom().left(); rootTable.add(makeBackBtn()).expand().bottom().left();
...@@ -86,12 +100,12 @@ public class TournamentHighScoreState extends State{ ...@@ -86,12 +100,12 @@ public class TournamentHighScoreState extends State{
private Table makeHighScoreTable(){ private Table makeHighScoreTable(){
Table innerTable = new Table(); Table innerTable = new Table();
innerTable.pad(padding); innerTable.pad(padding);
innerTable.defaults().space(spacingLittle); innerTable.defaults().space(spacingLittle).expand();
innerTable.setBackground(backgroundTableBlueRounded); innerTable.setBackground(backgroundTableBlueRounded);
innerTable.add(colOneLabel).expandX(); innerTable.add(colOneLabel).top();
innerTable.add(colTwoLabel).expandX(); innerTable.add(makeRow(colTwoLabel,totalDialog)).top();
innerTable.add(colThreeLabel).expandX(); innerTable.add(makeRow(colThreeLabel,lastRoundDialog)).top();
innerTable.row(); innerTable.row();
for(Point point : points){ for(Point point : points){
...@@ -103,6 +117,36 @@ public class TournamentHighScoreState extends State{ ...@@ -103,6 +117,36 @@ public class TournamentHighScoreState extends State{
return innerTable; return innerTable;
} }
private Table makeRow(Label label, final Dialog dialog){
Table table = new Table();
table.add(label).spaceRight(spacingLittle/2);
Image questionMarkImage = new Image(questionMark);
questionMarkImage.addListener(new ClickListener(){
@Override
public void clicked(InputEvent e, float x, float y){
if(GameWare.getInstance().isSoundEffectsOn()){ checkBoxSound.play(); }
dialog.show(stage);
}
});
table.add(questionMarkImage).width(questionMarkWidthAndHeight).height(questionMarkWidthAndHeight).top();
return table;
}
private Dialog makeDialog(Label label){
Dialog dialog = new Dialog("", skin, "dialog") {
public void result(Object obj) { }
};
label.setAlignment(Align.center);
label.setWrap(true);
dialog.getContentTable().add(label).width(Gdx.graphics.getWidth()/1.5f).pad(dialog.getHeight()/5f).padBottom(0);
dialog.button("Okay", true); //sends "true" as the result
dialog.getButtonTable().pad(dialog.getHeight()/2f);
return dialog;
}
private TextButton makeBackBtn(){ private TextButton makeBackBtn(){
TextButton backBtn = new TextButton(backBtnText, skin); TextButton backBtn = new TextButton(backBtnText, skin);
backBtn.addListener(new ClickListener() { backBtn.addListener(new ClickListener() {
......
...@@ -16,10 +16,13 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; ...@@ -16,10 +16,13 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Align;
import com.gameware.game.GameWare; import com.gameware.game.GameWare;
import com.gameware.game.QueryIntermediate; import com.gameware.game.QueryIntermediate;
import com.gameware.game.models.Game;
import com.gameware.game.models.Round; import com.gameware.game.models.Round;
import com.gameware.game.models.Tournament; import com.gameware.game.models.Tournament;
import com.gameware.game.sprites.LoadingText; import com.gameware.game.sprites.LoadingText;
import java.util.List;
public class ViewTournamentState extends State { public class ViewTournamentState extends State {
// Data // Data
...@@ -40,6 +43,8 @@ public class ViewTournamentState extends State { ...@@ -40,6 +43,8 @@ public class ViewTournamentState extends State {
private final String roundsLeftText = "Rounds left:"; private final String roundsLeftText = "Rounds left:";
private final String leaveDialogText = "Are you sure want to\nleave "; private final String leaveDialogText = "Are you sure want to\nleave ";
private String gameName = "";
// Variables // Variables
private final float playBtnWidth = buttonWidth*1.4f; private final float playBtnWidth = buttonWidth*1.4f;
private final float playBtnHeight = buttonHeight*1.2f; private final float playBtnHeight = buttonHeight*1.2f;
...@@ -60,6 +65,18 @@ public class ViewTournamentState extends State { ...@@ -60,6 +65,18 @@ public class ViewTournamentState extends State {
this.round = r; this.round = r;
titleLabel.setText(tournament.getName()); titleLabel.setText(tournament.getName());
roundDeadline.setText("Round deadline\n"+round.getDeadlineDate().toLocaleString()); 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(); makeStage();
} }
...@@ -78,8 +95,15 @@ public class ViewTournamentState extends State { ...@@ -78,8 +95,15 @@ public class ViewTournamentState extends State {
rootTable.add(makePlayBtn()).size(playBtnWidth, playBtnHeight).colspan(2); rootTable.add(makePlayBtn()).size(playBtnWidth, playBtnHeight).colspan(2);
rootTable.row(); 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()); 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.row();
rootTable.add(new Label(nrPlayersText+" "+tournament.getCurrentPlayers(), skin)).colspan(2); rootTable.add(new Label(nrPlayersText+" "+tournament.getCurrentPlayers(), skin)).colspan(2);
...@@ -102,17 +126,17 @@ public class ViewTournamentState extends State { ...@@ -102,17 +126,17 @@ public class ViewTournamentState extends State {
rootTable.add(roundDeadline).expand().bottom().right(); rootTable.add(roundDeadline).expand().bottom().right();
stage.addActor(rootTable); stage.addActor(rootTable);
makeDialog(); makeLeaveDialog();
} }
// Make widgets methods // Make widgets methods
private void makeDialog(){ private void makeLeaveDialog(){
dialog = new Dialog("", skin, "dialog") { dialog = new Dialog("", skin, "dialog") {
public void result(Object obj) { public void result(Object obj) {
if(obj.equals(true)){ if(obj.equals(true)){
setLeaveConfirmed(); setLeaveConfirmed();
} else{ } else{
makeDialog(); makeLeaveDialog();
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment