Commit 3317cc7a authored by Thomas Lecluse's avatar Thomas Lecluse
Browse files

Merge branch 'feature/main/cleanV2' into 'int/v2'

Feature/main/clean v2

See merge request !37
parents 239befc8 8d09de53
......@@ -63,14 +63,14 @@
<mainClass>main.java.Main</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<configuration>
<mainClass>main.java.Main</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<configuration>
<mainClass>main.java.Main</mainClass>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
......
package main.java.client.main.controller;
import java.io.IOException;
import javafx.beans.value.ObservableValue;
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.net.URL;
import java.util.ResourceBundle;
......@@ -23,105 +35,130 @@ import main.java.client.main.model.MainApplicationModel;
import main.java.common.dataModel.UserLight;
public class FXCreateGame implements Initializable {
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;
@FXML
private Text errorFieldsInteger;
public FXCreateGame() {
model = ClientApp.mainCore.getFX().getModel();
stage = new Stage();
}
public void setStage(Stage stage) {
this.stage = stage;
}
@Override
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((ChangeListener<String>) (selected, oldValue, newValue) -> System.out.println(newValue));
spectatorsCombo.getItems().setAll("Oui", "Non");
spectatorsCombo.getSelectionModel().selectedItemProperty()
.addListener((ChangeListener<String>) (selected, oldValue, newValue) -> System.out.println(newValue));
colorCombo.getItems().setAll("Blanc", "Noir");
colorCombo.getSelectionModel().selectedItemProperty()
.addListener((ChangeListener<String>) (selected, oldValue, 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":
stage = (Stage) ((Node) e.getSource()).getScene().getWindow();
FXHome fxHome = new FXHome();
fxHome.initialize("../fxml/home.fxml", stage);
break;
default:
System.out.println("[" + buttonSource + "] A handler button was triggered, but no action was performed.");
}
}
private void createGame() throws IOException {
UserLight userLight = model.getUserLight();
try {
Boolean chat = chatCombo.getValue().equals("Oui") ? true : false;
Boolean spectators = spectatorsCombo.getValue().equals("Oui") ? true : false;
Boolean colorWhite = colorCombo.getValue().equals("Blanc") ? true : false;
int limitMove = Integer.parseInt(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, 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);
}
}
}
private MainApplicationModel model;
private Stage stage;
@FXML
protected ComboBox<String> spectatorsCombo = new ComboBox<String>();
@FXML
private ComboBox<String> chatCombo;
@FXML
protected ComboBox<String> colorCombo = new ComboBox<String>();
@FXML
private TextField createGameTextFieldLimitMove;
@FXML
private Text errorFields;
@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, stage);
} 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);
}
}
}
}
package main.java.client.main.controller;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.layout.Border;
......
......@@ -10,7 +10,7 @@
<?import javafx.scene.text.Text?>
<?import javafx.scene.control.DatePicker?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="889.0" style="-fx-background-color: white;" xmlns="http://javafx.com/javafx/8.0.172-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="main.java.client.main.controller.FXProfileConsult">
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="889.0" style="-fx-background-color: white;" xmlns="http://javafx.com/javafx/8.0.172-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="main.java.client.main.controller.FXModifyProfile">
<bottom>
<Pane prefHeight="50.0" prefWidth="200.0" BorderPane.alignment="CENTER" />
</bottom>
......
......@@ -38,17 +38,23 @@
</font>
</Text>
<Text layoutX="40.0" layoutY="94.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Nom" />
<Text fx:id="displayProfileLastName" layoutX="120.0" layoutY="94.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Nom" />
<Text layoutX="41.0" layoutY="171.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Age" />
<Text fx:id="displayProfileAge" layoutX="121.0" layoutY="171.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Age" />
<Text layoutX="39.0" layoutY="58.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Pseudo" />
<Text fx:id="displayProfilePseudo" layoutX="119.0" layoutY="58.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Pseudo" />
<Text layoutX="305.0" layoutY="52.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Avatar" />
<Text layoutX="41.0" layoutY="133.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Prénom" />
<Text fx:id="displayProfileFirstName" layoutX="121.0" layoutY="133.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Prénom" />
<ImageView fitHeight="150.0" fitWidth="125.0" layoutX="282.0" layoutY="145.0" pickOnBounds="true" preserveRatio="true" />
<Button fx:id="viewProfileButtonEdit" layoutX="253.0" layoutY="295.0" mnemonicParsing="false" onMouseClicked="#handleButtonClick" text="Modifier" />
<Button fx:id="viewProfileButtonExport" layoutX="331.0" layoutY="295.0" mnemonicParsing="false" onMouseClicked="#handleButtonClick" text="Exporter" />
<Button fx:id="viewProfileButtonClose" layoutX="404.0" layoutY="295.0" mnemonicParsing="false" onMouseClicked="#handleButtonClick" text="Fermer" />
<ImageView fitHeight="164.0" fitWidth="134.0" layoutX="305.0" layoutY="70.0" pickOnBounds="true" preserveRatio="true" />
<Text layoutX="40.0" layoutY="209.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Nb parties" />
<Text fx:id="displayProfileNbGames" layoutX="120.0" layoutY="209.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Nb parties" />
<Text layoutX="40.0" layoutY="247.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Nb victoires" />
<Text fx:id="displayProfileNbVictories" layoutX="120.0" layoutY="247.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Nb victoires" />
</children>
</Pane>
</center>
......
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