Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Progark gruppe 3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Ingebrigt Ørstad
Progark gruppe 3
Commits
36c784da
Commit
36c784da
authored
5 years ago
by
Turid Cecilie Dahl
Browse files
Options
Downloads
Patches
Plain Diff
#90
game can't crash when something goes wrong with creating a tournament
parent
0825d354
No related branches found
No related tags found
1 merge request
!89
Resolve "Small frontend stuff"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/core/src/com/gameware/game/states/CreateNewTournamentState.java
+16
-8
16 additions, 8 deletions
...rc/com/gameware/game/states/CreateNewTournamentState.java
with
16 additions
and
8 deletions
frontend/core/src/com/gameware/game/states/CreateNewTournamentState.java
+
16
−
8
View file @
36c784da
...
...
@@ -60,6 +60,10 @@ public class CreateNewTournamentState extends State {
private
final
String
createBtnText
=
"Create"
;
private
final
String
nextBtnText
=
"Next"
;
private
final
String
noNameText
=
"No name given"
;
private
final
String
noGamesSelectedText
=
"No games selected"
;
private
final
String
IOExceptionText
=
"Something went wrong when\ncreating the tournament"
;
// Input fields
private
TextField
nameInputField
=
new
TextField
(
""
,
skin
);
...
...
@@ -80,7 +84,7 @@ public class CreateNewTournamentState extends State {
private
final
int
inputFieldHeight
=
Gdx
.
graphics
.
getHeight
()/
15
;
private
final
int
nameFieldWidth
=
Gdx
.
graphics
.
getWidth
()/
3
;
private
final
float
checkBoxSize
=
Gdx
.
graphics
.
getWidth
()/
15
;
private
final
float
scrollPaneWidth
=
Gdx
.
graphics
.
getWidth
()/
1.1
3
f
;
private
final
float
scrollPaneWidth
=
Gdx
.
graphics
.
getWidth
()/
1.1
4
f
;
private
final
float
scrollPaneHeight
=
Gdx
.
graphics
.
getHeight
()/
2.3f
;
private
Table
rootTable
;
...
...
@@ -263,7 +267,7 @@ public class CreateNewTournamentState extends State {
dialog
.
getContentTable
().
add
(
label
).
width
(
Gdx
.
graphics
.
getWidth
()/
1.5f
).
pad
(
dialog
.
getHeight
()/
5
f
).
padBottom
(
0
);
dialog
.
button
(
"Okay"
,
true
);
//sends "true" as the result
dialog
.
getButtonTable
().
pad
(
dialog
.
getHeight
()/
5
f
);
dialog
.
getButtonTable
().
pad
(
dialog
.
getHeight
()/
2
f
);
return
dialog
;
}
...
...
@@ -287,8 +291,14 @@ public class CreateNewTournamentState extends State {
public
void
clicked
(
InputEvent
e
,
float
x
,
float
y
){
if
(
GameWare
.
getInstance
().
isSoundEffectsOn
()){
buttonPressSound
.
play
();
}
if
(
getTournamentName
().
equals
(
""
)){
errorLabel
.
setText
(
noNameText
);
return
;
}
page
++;
errorLabel
.
setText
(
""
);
nameUserInput
=
getTournamentName
();
timePerRoundUserInput
=
getTimePerRound
();
maxPlayersUserInput
=
getMaxPlayers
();
...
...
@@ -363,6 +373,7 @@ public class CreateNewTournamentState extends State {
stage
.
clear
();
makeStage
();
errorLabel
.
setText
(
""
);
nameInputField
.
setText
(
nameUserInput
);
timePerRoundSelectBox
.
setSelected
(
timePerRoundUserInput
);
maxPlayersSelectBox
.
setSelected
(
maxPlayersUserInput
);
...
...
@@ -374,21 +385,18 @@ public class CreateNewTournamentState extends State {
private
void
handleCreateBtnClick
(){
if
(
GameWare
.
getInstance
().
isSoundEffectsOn
()){
buttonPressSound
.
play
();
}
if
(
chosenGames
.
isEmpty
()){
errorLabel
.
setText
(
"No games chosen."
);
return
;
}
if
(
getTournamentName
().
equals
(
""
)){
errorLabel
.
setText
(
"No name given."
);
errorLabel
.
setText
(
noGamesSelectedText
);
return
;
}
try
{
tournament
=
new
Tournament
(
GameWare
.
getInstance
().
getPlayer
().
getId
(),
chosenGames
,
nameUserInput
,
timePerRoundUserInput
,
maxPlayersUserInput
,
roundsPerGameUserInput
,
1
,
chosenGames
.
size
(),
startDelayUserInput
);
tournamentFromDB
=
QueryIntermediate
.
createNewTournament
(
tournament
);
round
=
QueryIntermediate
.
getRoundFromTournament
(
tournamentFromDB
.
get_id
(),
GameWare
.
getInstance
().
getPlayer
().
getId
(),
tournamentFromDB
.
getCurrentRound
());
gsm
.
set
(
new
ViewTournamentState
(
gsm
,
tournamentFromDB
,
round
));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
errorLabel
.
setText
(
IOExceptionText
);
}
gsm
.
set
(
new
ViewTournamentState
(
gsm
,
tournamentFromDB
,
round
));
}
private
String
getTournamentName
(){
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment