Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Alexandre Ducarne
ai12-othello
Commits
77555add
Commit
77555add
authored
Nov 26, 2019
by
Thomas Lecluse
Browse files
Merge branch 'feature/main/createGame' into 'int/v2'
Merge feature/main/createGame into int/v2 See merge request
!28
parents
10b31ec9
0b16322e
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/client/main/controller/FXCreateGame.java
0 → 100644
View file @
77555add
package
main.java.client.main.controller
;
import
javafx.fxml.Initializable
;
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
;
import
javafx.fxml.FXMLLoader
;
import
javafx.scene.Scene
;
import
javafx.scene.control.*
;
import
javafx.scene.text.Text
;
import
javafx.scene.input.MouseEvent
;
import
javafx.scene.layout.BorderPane
;
import
javafx.stage.Stage
;
import
javafx.beans.value.ChangeListener
;
import
javafx.beans.value.ObservableValue
;
import
java.io.IOException
;
public
class
FXCreateGame
implements
Initializable
{
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
;
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
);
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"
:
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
(
Exception
e
)
{
if
(
this
.
chatCombo
.
getValue
()
==
null
||
this
.
spectatorsCombo
.
getValue
()
==
null
||
this
.
colorCombo
.
getValue
()
==
null
||
this
.
createGameTextFieldLimitMove
.
getText
().
trim
().
isEmpty
()){
errorFields
.
setVisible
(
true
);
}
}
}
}
src/main/java/client/main/controller/FXHome.java
View file @
77555add
package
main.java.client.main.controller
;
import
javafx.scene.layout.Border
;
import
main.java.client.ClientApp
;
import
main.java.client.main.model.MainApplicationModel
;
import
main.java.common.dataModel.UserHeavy
;
import
main.java.common.dataModel.UserLight
;
import
javafx.fxml.FXML
;
import
javafx.fxml.FXMLLoader
;
import
java.net.URL
;
import
javafx.scene.Scene
;
import
javafx.scene.control.Button
;
import
javafx.scene.input.MouseEvent
;
...
...
@@ -64,6 +66,13 @@ public class FXHome {
FXProfileConsult
fxProfileConsult
=
new
FXProfileConsult
();
fxProfileConsult
.
initialize
(
"../fxml/viewProfile.fxml"
,
this
.
stage
);
break
;
case
"homeButtonCreateGame"
:
BorderPane
layout
=
FXMLLoader
.
load
(
new
URL
(
FXHome
.
class
.
getResource
(
"../fxml/createGame.fxml"
).
toExternalForm
())
);
stage
.
setScene
(
new
Scene
(
layout
));
stage
.
show
();
break
;
case
"homeDeconnection"
:
FXConnection
fxConnection
=
new
FXConnection
();
fxConnection
.
initialize
(
"../fxml/login.fxml"
,
this
.
stage
);
...
...
src/main/java/client/main/fxml/createGame.fxml
0 → 100644
View file @
77555add
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.shape.Rectangle?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.ComboBox?>
<?import java.lang.String?>
<?import javafx.collections.FXCollections?>
<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.FXCreateGame"
>
<bottom>
<Pane
prefHeight=
"50.0"
prefWidth=
"200.0"
BorderPane.alignment=
"CENTER"
/>
</bottom>
<top>
<Pane
prefHeight=
"100.0"
prefWidth=
"200.0"
BorderPane.alignment=
"CENTER"
>
<children>
<Text
fx:id=
"loginTextAppTitle"
layoutX=
"327.0"
layoutY=
"64.0"
strokeType=
"OUTSIDE"
strokeWidth=
"0.0"
text=
"Projet Baleine"
>
<font>
<Font
name=
"System Bold"
size=
"36.0"
/>
</font>
</Text>
</children></Pane>
</top>
<left>
<Pane
prefHeight=
"200.0"
prefWidth=
"200.0"
BorderPane.alignment=
"CENTER"
/>
</left>
<right>
<Pane
prefHeight=
"200.0"
prefWidth=
"200.0"
BorderPane.alignment=
"CENTER"
/>
</right>
<center>
<Pane
prefHeight=
"350.0"
prefWidth=
"489.0"
BorderPane.alignment=
"CENTER"
>
<children>
<Rectangle
arcHeight=
"5.0"
arcWidth=
"5.0"
fill=
"#fffffa"
height=
"350.0"
stroke=
"BLACK"
strokeType=
"INSIDE"
width=
"489.0"
/>
<Text
layoutX=
"219.0"
layoutY=
"20.0"
strokeType=
"OUTSIDE"
strokeWidth=
"0.0"
text=
"Profil"
>
<font>
<Font
name=
"System Bold"
size=
"16.0"
/>
</font>
</Text>
<ImageView
fitHeight=
"150.0"
fitWidth=
"125.0"
layoutX=
"282.0"
layoutY=
"145.0"
pickOnBounds=
"true"
preserveRatio=
"true"
/>
<Button
fx:id=
"createGameButtonValidate"
layoutX=
"331.0"
layoutY=
"295.0"
mnemonicParsing=
"false"
onMouseClicked=
"#handleButtonClick"
text=
"Créer"
/>
<Button
fx:id=
"createGameButtonClose"
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"
/>
<ComboBox
fx:id=
"spectatorsCombo"
layoutX=
"51.0"
layoutY=
"73.0"
/>
<ComboBox
fx:id=
"chatCombo"
layoutX=
"51.0"
layoutY=
"133.0"
/>
<ComboBox
fx:id=
"colorCombo"
layoutX=
"51.0"
layoutY=
"193.0"
/>
<Text
layoutX=
"51.0"
layoutY=
"63.0"
strokeType=
"OUTSIDE"
strokeWidth=
"0.0"
text=
"Autoriser Spectateurs"
/>
<Text
layoutX=
"51.0"
layoutY=
"123.0"
strokeType=
"OUTSIDE"
strokeWidth=
"0.0"
text=
"Activer Chat"
/>
<Text
layoutX=
"51.0"
layoutY=
"183.0"
strokeType=
"OUTSIDE"
strokeWidth=
"0.0"
text=
"Couleur"
/>
<Text
layoutX=
"51.0"
layoutY=
"233.0"
strokeType=
"OUTSIDE"
strokeWidth=
"0.0"
text=
"Limite de coups"
/>
<TextField
fx:id=
"createGameTextFieldLimitMove"
layoutX=
"51.0"
layoutY=
"243.0"
/>
<Text
text=
"* Un ou plusieurs des champs sont vides"
fx:id=
"errorFields"
layoutX=
"51.0"
layoutY=
"313.0"
/>
</children>
</Pane>
</center>
</BorderPane>
src/main/java/client/main/fxml/home.fxml
View file @
77555add
...
...
@@ -19,7 +19,7 @@
</font>
</Text>
<Rectangle
arcHeight=
"5.0"
arcWidth=
"5.0"
fill=
"#fffffa"
height=
"43.0"
layoutY=
"60.0"
stroke=
"BLACK"
strokeType=
"INSIDE"
width=
"889.0"
/>
<Button
layoutX=
"14.0"
layoutY=
"69.0"
mnemonicParsing=
"false"
text=
"Créer une partie"
/>
<Button
fx:id=
"homeButtonCreateGame"
layoutX=
"14.0"
layoutY=
"69.0"
mnemonicParsing=
"false"
onMouseClicked=
"#handleButtonClick"
text=
"Créer une partie"
/>
<Button
layoutX=
"124.0"
layoutY=
"69.0"
mnemonicParsing=
"false"
text=
"Revoir une partie"
/>
<Button
fx:id=
"homeDeconnection"
layoutX=
"789.0"
layoutY=
"69.0"
mnemonicParsing=
"false"
onMouseClicked=
"#handleButtonClick"
text=
"Déconnexion"
/>
<Button
fx:id=
"homeButtonMyProfile"
layoutX=
"709.0"
layoutY=
"69.0"
mnemonicParsing=
"false"
onMouseClicked=
"#handleButtonClick"
text=
"Mon Profil"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment