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

#36 added creation of tournament table from list of tournaments where the id follows when entered

parent 1dbdbcbb
No related branches found
No related tags found
1 merge request!35Resolve "MultiplayerCreateJoinState"
...@@ -20,7 +20,7 @@ public class GameWare extends ApplicationAdapter { ...@@ -20,7 +20,7 @@ public class GameWare extends ApplicationAdapter {
public static final String TITLE = "WackyWare!"; public static final String TITLE = "WackyWare!";
public static final String skinFilePath = "glassy/skin/glassy-ui.json"; public static final String skinFilePath = "glassy/skin/glassy-ui.json";
// TODO: Add music // TODO: Add music
// TODO: private User user; + get og set // TODO: private Player player; + get og set
private static GameWare instance = null; private static GameWare instance = null;
//Singleton (lazy initialization) //Singleton (lazy initialization)
......
...@@ -24,6 +24,12 @@ public class Tournament { ...@@ -24,6 +24,12 @@ public class Tournament {
public Tournament() { public Tournament() {
} }
//Just testing delete afterwards
public Tournament(String _id, String name) {
this._id = _id;
this.name = name;
}
public String get_id() { public String get_id() {
return _id; return _id;
} }
......
...@@ -5,10 +5,14 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch; ...@@ -5,10 +5,14 @@ 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.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane; import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
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.gameware.game.GameWare;
import com.gameware.game.models.Tournament;
import java.util.ArrayList;
import java.util.List;
public class CreateJoinTournamentState extends State { public class CreateJoinTournamentState extends State {
...@@ -22,62 +26,41 @@ public class CreateJoinTournamentState extends State { ...@@ -22,62 +26,41 @@ public class CreateJoinTournamentState extends State {
private String joinBtnText = "Join new"; private String joinBtnText = "Join new";
private String tournamentText = "Tournament 1"; private String tournamentText = "Tournament 1";
private List<Tournament> tournaments = new ArrayList<>();
public class MyClickListener extends ClickListener{
private Tournament tournament;
public MyClickListener(Tournament tournament){
this.tournament = tournament;
}
public void clicked(InputEvent event, float x, float y) {
handleEnterBtnClick(tournament.get_id());
};
}
public CreateJoinTournamentState(GameStateManager gsm) { public CreateJoinTournamentState(GameStateManager gsm) {
super(gsm); super(gsm);
System.out.println("Du er i create join tournament state :0"); System.out.println("Du er i create join tournament state :0");
tournaments.add(new Tournament("id1", "Tournament 1"));
tournaments.add(new Tournament("id2", "Beste tournament!!"));
tournaments.add(new Tournament("id3", "La oss spille >:D"));
//tournaments = QueryIntermediate.getTournamentsForPlayer(GameWare.getPlayer().getId());
outerTable = new Table(); outerTable = new Table();
outerTable.setFillParent(true); outerTable.setFillParent(true);
innerTable = new Table(); innerTable = new Table();
outerTable.setFillParent(true); innerTable.setFillParent(true);
outerTable.row();
innerTable.row();
Label tournamentLabel = new Label(tournamentText,skin); for (Tournament t : tournaments){
//TODO: autogenerere utifra query og putt dem i en liste Label tournamentLabel = new Label(t.getName(),skin);
TextButton enterBtn = new TextButton(enterBtnText, skin); TextButton enterBtn = new TextButton(enterBtnText, skin);
enterBtn.addListener(new ClickListener() { enterBtn.addListener(new MyClickListener(t));
@Override innerTable.add(tournamentLabel);
public void clicked(InputEvent e, float x, float y){
handleEnterBtnClick();
}
});
TextButton enterBtn2 = new TextButton(enterBtnText, skin);
enterBtn2.addListener(new ClickListener() {
@Override
public void clicked(InputEvent e, float x, float y){
handleEnterBtnClick();
}
});
TextButton enterBtn3 = new TextButton(enterBtnText, skin);
enterBtn3.addListener(new ClickListener() {
@Override
public void clicked(InputEvent e, float x, float y){
handleEnterBtnClick();
}
});
TextButton enterBtn4 = new TextButton(enterBtnText, skin);
enterBtn4.addListener(new ClickListener() {
@Override
public void clicked(InputEvent e, float x, float y){
handleEnterBtnClick();
}
});
innerTable.add(tournamentLabel).size(Gdx.graphics.getWidth()/5);
innerTable.add(enterBtn); innerTable.add(enterBtn);
innerTable.row(); innerTable.row();
innerTable.add(enterBtn2); }
innerTable.row();
innerTable.add(enterBtn3);
innerTable.row();
innerTable.add(enterBtn4);
innerTable.row();
ScrollPane tournamentsPane = new ScrollPane(innerTable, skin); ScrollPane tournamentsPane = new ScrollPane(innerTable, skin);
outerTable.add(tournamentsPane).spaceBottom(spacingOnBottom); outerTable.add(tournamentsPane).spaceBottom(spacingOnBottom);
...@@ -86,14 +69,8 @@ public class CreateJoinTournamentState extends State { ...@@ -86,14 +69,8 @@ public class CreateJoinTournamentState extends State {
outerTable.add(makeCreateBtn()).spaceBottom(spacingOnBottom); outerTable.add(makeCreateBtn()).spaceBottom(spacingOnBottom);
outerTable.add(makeJoinBtn()).spaceBottom(spacingOnBottom); outerTable.add(makeJoinBtn()).spaceBottom(spacingOnBottom);
outerTable.row(); outerTable.row();
outerTable.add(makeBackBtn()).spaceBottom(spacingOnBottom); outerTable.add(makeBackBtn()).spaceBottom(spacingOnBottom);
//outerTable.row();
Label tournamentLabel1 = new Label(tournamentText,skin);
outerTable.add(tournamentLabel1).size(labelSize);
stage.addActor(outerTable); stage.addActor(outerTable);
} }
...@@ -164,12 +141,17 @@ public class CreateJoinTournamentState extends State { ...@@ -164,12 +141,17 @@ public class CreateJoinTournamentState extends State {
gsm.set(new MenuState(gsm)); gsm.set(new MenuState(gsm));
} }
private void handleEnterBtnClick(){ private void handleEnterBtnClick(String id){
System.out.println(id);
gsm.set(new ViewTournamentState(gsm)); gsm.set(new ViewTournamentState(gsm));
} }
private void handleCreateBtnClick(){}; private void handleCreateBtnClick(){
//gsm.set(new CreateTournamentState(gsm));
};
private void handleJoinBtnClick(){}; private void handleJoinBtnClick(){
//QueryIntermediate.joinATournament(GameWare.getPlayer().getId());
};
} }
...@@ -3,7 +3,6 @@ package com.gameware.game.states; ...@@ -3,7 +3,6 @@ package com.gameware.game.states;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
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.ui.Skin;
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.ui.TextField; import com.badlogic.gdx.scenes.scene2d.ui.TextField;
...@@ -121,12 +120,12 @@ public class LoginState extends State { ...@@ -121,12 +120,12 @@ public class LoginState extends State {
private void handleLoginBtnClick(){ private void handleLoginBtnClick(){
String username = usernameInputField.getText(); String username = usernameInputField.getText();
String password = passwordInputField.getText(); String password = passwordInputField.getText();
// User user; // Player player;
try { try {
//TODO: //TODO:
// User user = QueryIntermediate.getUser(username, password); // Player player = QueryIntermediate.getUser(username, password);
// gsm.set(new MenuState(gsm)); gsm.set(new MenuState(gsm));
// GameWare.setUser(user); // GameWare.setPlayer(player);
}catch(Exception e){ }catch(Exception e){
// TODO: Endre fra exception til spesifisert Element Not Found Exception eller hva det heter // TODO: Endre fra exception til spesifisert Element Not Found Exception eller hva det heter
// melding ut om at brukeren ikke eksisterer // melding ut om at brukeren ikke eksisterer
...@@ -136,12 +135,12 @@ public class LoginState extends State { ...@@ -136,12 +135,12 @@ public class LoginState extends State {
private void handleSignUpBtnClick(){ private void handleSignUpBtnClick(){
String username = usernameInputField.getText(); String username = usernameInputField.getText();
String password = passwordInputField.getText(); String password = passwordInputField.getText();
// User user; // Player player;
try { try {
// TODO: // TODO:
// QueryIntermediate.createPlayer(username, password) // QueryIntermediate.createPlayer(username, password)
// gsm.set(new MenuState(gsm)); gsm.set(new MenuState(gsm));
// GameWare.setUser(user); // GameWare.setPlayer(player);
}catch(Exception e){ }catch(Exception e){
// TODO: Endre fra exception til spesifisert Element Not Found Exception eller hva det heter // TODO: Endre fra exception til spesifisert Element Not Found Exception eller hva det heter
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment