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
ebd858b3
Commit
ebd858b3
authored
Nov 27, 2019
by
Louis Bal Dit Sollier
Browse files
Merge branch 'feature/main/createGame' into 'int/v2'
Feature/main/createGame See merge request
!33
parents
7ca04d65
01ad1106
Changes
3
Show whitespace changes
Inline
Side-by-side
src/main/java/client/main/controller/FXCreateGame.java
View file @
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
;
...
...
@@ -22,6 +32,132 @@ 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
>();
@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
,
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
;
...
...
@@ -111,5 +247,6 @@ public class FXCreateGame implements Initializable {
}
}
>>>>>>>
src
/
main
/
java
/
client
/
main
/
controller
/
FXCreateGame
.
java
}
src/main/java/client/main/controller/FXHome.java
View file @
ebd858b3
package
main.java.client.main.controller
;
import
javafx.scene.Node
;
import
javafx.scene.Parent
;
import
javafx.scene.layout.Border
;
import
javafx.collections.FXCollections
;
import
javafx.collections.ObservableList
;
import
main.java.client.ClientApp
;
import
main.java.client.main.model.MainApplicationModel
;
import
main.java.common.dataModel.UserLight
;
...
...
@@ -105,11 +111,11 @@ public class FXHome {
this
.
stage
.
setScene
(
new
Scene
(
layout
));
break
;
case
"homeButtonCreateGame"
:
BorderPane
layout
=
FXMLLoader
.
load
(
new
URL
(
FXHome
.
class
.
getResource
(
"../fxml/createGame.fxml"
).
toExternalForm
()
)
);
stage
.
setScene
(
new
Scene
(
layout
)
);
stage
.
s
how
(
);
FXMLLoader
loader
=
new
FXMLLoader
(
getClass
().
getResource
(
"../fxml/createGame.fxml"
));
Parent
padre
=
loader
.
load
()
;
Scene
switcher
=
new
Scene
(
padre
);
this
.
stage
=
(
Stage
)((
Node
)
e
.
getSource
()).
getScene
().
getWindow
(
);
this
.
stage
.
s
etScene
(
switcher
);
break
;
case
"homeDeconnection"
:
FXConnection
fxConnection
=
new
FXConnection
();
...
...
src/main/java/client/main/fxml/createGame.fxml
View file @
ebd858b3
...
...
@@ -7,11 +7,8 @@
<?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?>
...
...
@@ -57,6 +54,7 @@
<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"
/>
<Text
text=
"* Le champ 'Limite de coups' doit être un entier "
fx:id=
"errorFieldsInteger"
layoutX=
"51.0"
layoutY=
"333.0"
/>
</children>
</Pane>
</center>
...
...
Louis Bal Dit Sollier
@lbaldits
mentioned in commit
e7477a23
·
Nov 27, 2019
mentioned in commit
e7477a23
mentioned in commit e7477a2339be7aec6eb1b004cc0489c896442c1d
Toggle commit list
Write
Preview
Supports
Markdown
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