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

Merge branch '64-start-delay-frontend' into 'dev'

Resolve "Start delay frontend"

Closes #64

See merge request !61
parents 4133c0fa 94008d55
No related branches found
No related tags found
1 merge request!61Resolve "Start delay frontend"
...@@ -11,6 +11,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table; ...@@ -11,6 +11,7 @@ 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.ui.TextField; import com.badlogic.gdx.scenes.scene2d.ui.TextField;
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.Game; import com.gameware.game.models.Game;
...@@ -26,12 +27,14 @@ public class CreateNewTournamentState extends State { ...@@ -26,12 +27,14 @@ public class CreateNewTournamentState extends State {
private Label title = new Label("Create new\ntournament", skin, "big"); private Label title = new Label("Create new\ntournament", skin, "big");
private String nameText = "Name"; private String nameText = "Name";
private TextField nameInputField; private TextField nameInputField;
private String timePerRoundText = "Minutes per round"; private String timePerRoundText = "Hours to \n complete each round";
private SelectBox timePerRoundSelectBox; private SelectBox timePerRoundSelectBox;
private String maxPlayersText = "Max number of players"; private String maxPlayersText = "Max number of players";
private SelectBox maxPlayersSelectBox; private SelectBox maxPlayersSelectBox;
private String roundsPerGameText = "Round per game"; private String roundsPerGameText = "Round per game";
private SelectBox roundsPerGameSelectBox; private SelectBox roundsPerGameSelectBox;
private String startDelayText = "Hours waiting for more \n players before start";
private SelectBox startDelaySelectBox;
private Label errorLabel = new Label("", skin, "error"); private Label errorLabel = new Label("", skin, "error");
...@@ -61,31 +64,42 @@ public class CreateNewTournamentState extends State { ...@@ -61,31 +64,42 @@ public class CreateNewTournamentState extends State {
table = new Table(); table = new Table();
table.setFillParent(true); table.setFillParent(true);
table.setBackground(background);
title.setFontScale(titleFontBigScale); title.setFontScale(titleFontBigScale);
table.add(title).colspan(2).spaceBottom(spacingOnBottomInputFIeld); table.add(title).colspan(2).spaceBottom(spacingOnBottomInputFIeld);
table.row(); table.row();
table.add(makeLabel(nameText,skin)); table.add(makeLabel(nameText,skin));
nameInputField = new TextField("",skin); nameInputField = new TextField("",skin);
nameInputField.setMaxLength(10); nameInputField.setMaxLength(10);
table.add(nameInputField).size(nameFieldWidth, inputFieldHeight).spaceBottom(spacingOnBottom); table.add(nameInputField).size(nameFieldWidth, inputFieldHeight).spaceBottom(spacingOnBottom);
table.row(); table.row();
table.add(makeLabel(timePerRoundText,skin)); table.add(makeLabel(timePerRoundText,skin));
timePerRoundSelectBox = new SelectBox(skin); timePerRoundSelectBox = new SelectBox(skin);
timePerRoundSelectBox.setItems(1,2,3,4,5); timePerRoundSelectBox.setItems(1,2,3,4,5);
table.add(timePerRoundSelectBox).spaceBottom(spacingOnBottom); table.add(timePerRoundSelectBox).spaceBottom(spacingOnBottom);
table.row(); table.row();
table.add(makeLabel(maxPlayersText,skin)); table.add(makeLabel(maxPlayersText,skin));
maxPlayersSelectBox = new SelectBox(skin); maxPlayersSelectBox = new SelectBox(skin);
maxPlayersSelectBox.setItems(2,3,4,5); maxPlayersSelectBox.setItems(2,3,4,5);
table.add(maxPlayersSelectBox).spaceBottom(spacingOnBottom); table.add(maxPlayersSelectBox).spaceBottom(spacingOnBottom);
table.row(); table.row();
table.add(makeLabel(roundsPerGameText,skin)); table.add(makeLabel(roundsPerGameText,skin));
roundsPerGameSelectBox = new SelectBox(skin); roundsPerGameSelectBox = new SelectBox(skin);
roundsPerGameSelectBox.setItems(1,2,3); roundsPerGameSelectBox.setItems(1,2,3);
table.add(roundsPerGameSelectBox).spaceBottom(spacingOnBottom); table.add(roundsPerGameSelectBox).spaceBottom(spacingOnBottom);
table.row(); table.row();
table.add(makeLabel(startDelayText,skin)).spaceBottom(spacingOnBottom);
startDelaySelectBox = new SelectBox(skin);
startDelaySelectBox.setItems(1,2,3);
table.add(startDelaySelectBox).spaceBottom(spacingOnBottom);
table.row();
for (final Game g : games){ for (final Game g : games){
Label gameLabel = new Label(g.getName(),skin); Label gameLabel = new Label(g.getName(),skin);
table.add(gameLabel).spaceBottom(spacingOnBottom); table.add(gameLabel).spaceBottom(spacingOnBottom);
...@@ -116,6 +130,7 @@ public class CreateNewTournamentState extends State { ...@@ -116,6 +130,7 @@ public class CreateNewTournamentState extends State {
private Label makeLabel(String text, Skin skin){ private Label makeLabel(String text, Skin skin){
Label label = new Label(text,skin); Label label = new Label(text,skin);
label.setAlignment(Align.center);
return label; return label;
} }
...@@ -188,7 +203,7 @@ public class CreateNewTournamentState extends State { ...@@ -188,7 +203,7 @@ public class CreateNewTournamentState extends State {
} }
try { try {
tournament = new Tournament(GameWare.getInstance().getPlayer().getId(),chosenGames,getTournamentName(),getTimePerRound(),getMaxPlayers(),getRoundsPerGame(),1,chosenGames.size(), 1); tournament = new Tournament(GameWare.getInstance().getPlayer().getId(),chosenGames,getTournamentName(),getTimePerRound(),getMaxPlayers(),getRoundsPerGame(),1,chosenGames.size(),getStartDelay());
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());
} catch (IOException e) { } catch (IOException e) {
...@@ -213,4 +228,6 @@ public class CreateNewTournamentState extends State { ...@@ -213,4 +228,6 @@ public class CreateNewTournamentState extends State {
return (int) roundsPerGameSelectBox.getSelected(); return (int) roundsPerGameSelectBox.getSelected();
} }
private int getStartDelay(){ return (int) startDelaySelectBox.getSelected(); }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment