Commit 239befc8 authored by Thomas's avatar Thomas
Browse files

Fixed merge conflicts from feature/main/createGame branch

parent ebd858b3
package main.java.client.main.controller;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import main.java.client.ClientApp;
import main.java.client.main.model.MainApplicationModel;
import main.java.common.dataModel.UserLight;
import javafx.fxml.FXML;
import javafx.scene.paint.Color;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
......@@ -18,6 +8,7 @@ import javafx.beans.value.ChangeListener;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
......@@ -32,19 +23,17 @@ import main.java.client.main.model.MainApplicationModel;
import main.java.common.dataModel.UserLight;
public class FXCreateGame implements Initializable {
<<<<<<< src/main/java/client/main/controller/FXCreateGame.java
private MainApplicationModel model;
private Stage stage;
@FXML
protected ComboBox<String> spectatorsCombo = new ComboBox<String>();
protected ComboBox<String> spectatorsCombo = new ComboBox<>();
@FXML
private ComboBox<String> chatCombo;
@FXML
protected ComboBox<String> colorCombo = new ComboBox<String>();
protected ComboBox<String> colorCombo = new ComboBox<>();
@FXML
private TextField createGameTextFieldLimitMove;
......@@ -55,127 +44,6 @@ public class FXCreateGame implements Initializable {
@FXML
private Text errorFieldsInteger;
public FXCreateGame(){
this.model = ClientApp.mainCore.getFX().getModel();
stage = new Stage();
}
public void setStage(Stage stage){
this.stage = stage;
}
public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
errorFields.setVisible(false);
errorFields.setFill(Color.RED);
errorFieldsInteger.setVisible(false);
errorFieldsInteger.setFill(Color.RED);
chatCombo.getItems().setAll("Oui", "Non");
chatCombo.getSelectionModel().selectedItemProperty().addListener(
new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> selected, //
String oldValue, String newValue) {
System.out.println(newValue);
}
}
);
spectatorsCombo.getItems().setAll("Oui", "Non");
spectatorsCombo.getSelectionModel().selectedItemProperty().addListener(
new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> selected, //
String oldValue, String newValue) {
System.out.println(newValue);
}
}
);
colorCombo.getItems().setAll("Blanc", "Noir");
colorCombo.getSelectionModel().selectedItemProperty().addListener(
new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> selected, //
String oldValue, String newValue) {
System.out.println(newValue);
}
}
);
}
@FXML
private void handleButtonClick(MouseEvent e) throws IOException {
String buttonSource = ((Button) e.getSource()).getId();
switch(buttonSource){
case "createGameButtonValidate":
createGame();
break;
case "createGameButtonClose":
this.stage = (Stage)((Node)e.getSource()).getScene().getWindow();
FXHome fxHome = new FXHome();
fxHome.initialize("../fxml/home.fxml", this.stage);
break;
default:
System.out.println("["+buttonSource+"] A handler button was triggered, but no action was performed.");
}
}
private void createGame() throws IOException {
UserLight userLight = this.model.getUserLight();
try {
Boolean chat = this.chatCombo.getValue().equals("Oui") ? true : false;
Boolean spectators = this.spectatorsCombo.getValue().equals("Oui") ? true : false;
Boolean colorWhite = this.colorCombo.getValue().equals("Blanc") ? true : false;
int limitMove = Integer.parseInt(this.createGameTextFieldLimitMove.getText());
BorderPane layout = FXMLLoader.load(
new URL(main.java.client.main.controller.FXHome.class.getResource("../fxml/createGame.fxml").toExternalForm())
);
Scene scene = new Scene(layout, ClientApp.APPLICATION_WIDTH, ClientApp.APPLICATION_HEIGHT);
scene.getStylesheets().add(ClientApp.CSS_FILE_PATH);
System.out.println(chat + " " + spectators + " " + colorWhite + " " + limitMove);
ClientApp.mainCore.getMainToData().newGame(userLight, spectators, chat, colorWhite, limitMove, scene);
} catch (NumberFormatException e) {
errorFieldsInteger.setVisible(true);
} catch (Exception e) {
if (this.chatCombo.getValue() == null || this.spectatorsCombo.getValue() == null || this.colorCombo.getValue() == null || this.createGameTextFieldLimitMove.getText().trim().isEmpty()){
errorFields.setVisible(true);
} else {
System.out.println(e);
}
}
}
=======
private MainApplicationModel model;
private Stage stage;
@FXML
protected ComboBox<String> spectatorsCombo = new ComboBox<>();
@FXML
private ComboBox<String> chatCombo;
@FXML
protected ComboBox<String> colorCombo = new ComboBox<>();
@FXML
private TextField createGameTextFieldLimitMove;
@FXML
private Text errorFields;
public FXCreateGame() {
model = ClientApp.mainCore.getFX().getModel();
stage = new Stage();
......@@ -191,6 +59,9 @@ public class FXCreateGame implements Initializable {
errorFields.setVisible(false);
errorFields.setFill(Color.RED);
errorFieldsInteger.setVisible(false);
errorFieldsInteger.setFill(Color.RED);
chatCombo.getItems().setAll("Oui", "Non");
chatCombo.getSelectionModel().selectedItemProperty()
.addListener((ChangeListener<String>) (selected, oldValue, newValue) -> System.out.println(newValue));
......@@ -213,6 +84,7 @@ public class FXCreateGame implements Initializable {
createGame();
break;
case "createGameButtonClose":
stage = (Stage) ((Node) e.getSource()).getScene().getWindow();
FXHome fxHome = new FXHome();
fxHome.initialize("../fxml/home.fxml", stage);
break;
......@@ -239,14 +111,17 @@ public class FXCreateGame implements Initializable {
System.out.println(chat + " " + spectators + " " + colorWhite + " " + limitMove);
ClientApp.mainCore.getMainToData().newGame(userLight, spectators, chat, colorWhite, limitMove, stage);
} catch (NumberFormatException e) {
errorFieldsInteger.setVisible(true);
} catch (Exception e) {
if (chatCombo.getValue() == null || spectatorsCombo.getValue() == null || colorCombo.getValue() == null
|| createGameTextFieldLimitMove.getText().trim().isEmpty()) {
errorFields.setVisible(true);
} else {
System.out.println(e);
}
}
}
>>>>>>> src/main/java/client/main/controller/FXCreateGame.java
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment