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
6f2c5a6c
Commit
6f2c5a6c
authored
5 years ago
by
Turid Cecilie Dahl
Browse files
Options
Downloads
Patches
Plain Diff
#50
makes ViewHighScoreForGameState prettier
parent
d4faee67
No related branches found
No related tags found
1 merge request
!66
Resolve "Make it look pretty"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/core/src/com/gameware/game/states/ViewHighScoreForGameState.java
+54
-9
54 additions, 9 deletions
...c/com/gameware/game/states/ViewHighScoreForGameState.java
with
54 additions
and
9 deletions
frontend/core/src/com/gameware/game/states/ViewHighScoreForGameState.java
+
54
−
9
View file @
6f2c5a6c
...
@@ -2,13 +2,18 @@ package com.gameware.game.states;
...
@@ -2,13 +2,18 @@ package com.gameware.game.states;
import
com.badlogic.gdx.Gdx
;
import
com.badlogic.gdx.Gdx
;
import
com.badlogic.gdx.Input
;
import
com.badlogic.gdx.Input
;
import
com.badlogic.gdx.graphics.Color
;
import
com.badlogic.gdx.graphics.Pixmap
;
import
com.badlogic.gdx.graphics.Texture
;
import
com.badlogic.gdx.graphics.g2d.SpriteBatch
;
import
com.badlogic.gdx.graphics.g2d.SpriteBatch
;
import
com.badlogic.gdx.graphics.g2d.TextureRegion
;
import
com.badlogic.gdx.scenes.scene2d.InputEvent
;
import
com.badlogic.gdx.scenes.scene2d.InputEvent
;
import
com.badlogic.gdx.scenes.scene2d.ui.Label
;
import
com.badlogic.gdx.scenes.scene2d.ui.Label
;
import
com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
;
import
com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
;
import
com.badlogic.gdx.scenes.scene2d.ui.Table
;
import
com.badlogic.gdx.scenes.scene2d.ui.Table
;
import
com.badlogic.gdx.scenes.scene2d.ui.TextButton
;
import
com.badlogic.gdx.scenes.scene2d.ui.TextButton
;
import
com.badlogic.gdx.scenes.scene2d.utils.ClickListener
;
import
com.badlogic.gdx.scenes.scene2d.utils.ClickListener
;
import
com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
;
import
com.gameware.game.GameWare
;
import
com.gameware.game.GameWare
;
import
com.gameware.game.QueryIntermediate
;
import
com.gameware.game.QueryIntermediate
;
import
com.gameware.game.models.Game
;
import
com.gameware.game.models.Game
;
...
@@ -31,10 +36,17 @@ public class ViewHighScoreForGameState extends State {
...
@@ -31,10 +36,17 @@ public class ViewHighScoreForGameState extends State {
private
double
playerHS
;
private
double
playerHS
;
private
static
List
<
Highscore
>
highscores
=
new
ArrayList
<>();
private
static
List
<
Highscore
>
highscores
=
new
ArrayList
<>();
private
Boolean
isNoHS
=
true
;
private
Boolean
isNoHS
=
true
;
private
Label
gameNameText
;
private
Label
stateNameText
;
private
ScrollPane
scrollPane
;
private
String
backBtnText
=
"Back"
;
private
String
backBtnText
=
"Back"
;
private
String
playerLabelText
=
"You"
;
private
String
playerLabelText
=
"You
r score:
"
;
private
String
noHSLabelText
=
""
;
private
String
noHSLabelText
=
""
;
private
String
globalHighScoresText
=
"Global High Scores"
;
private
String
colOneText
=
"Place"
;
private
String
colTwoText
=
"Name"
;
private
String
colThreeText
=
"Score"
;
protected
ViewHighScoreForGameState
(
GameStateManager
gsm
,
Game
game
)
{
protected
ViewHighScoreForGameState
(
GameStateManager
gsm
,
Game
game
)
{
super
(
gsm
);
super
(
gsm
);
...
@@ -52,6 +64,9 @@ public class ViewHighScoreForGameState extends State {
...
@@ -52,6 +64,9 @@ public class ViewHighScoreForGameState extends State {
isNoHS
=
true
;
isNoHS
=
true
;
}
}
gameNameText
=
new
Label
(
game
.
getName
(),
skin
,
"big"
);
stateNameText
=
new
Label
(
globalHighScoresText
,
skin
,
"big"
);
makeStage
();
makeStage
();
}
}
...
@@ -113,7 +128,25 @@ public class ViewHighScoreForGameState extends State {
...
@@ -113,7 +128,25 @@ public class ViewHighScoreForGameState extends State {
private
void
makeStage
()
{
private
void
makeStage
()
{
outerTable
=
new
Table
();
outerTable
=
new
Table
();
outerTable
.
setFillParent
(
true
);
outerTable
.
setFillParent
(
true
);
outerTable
.
setBackground
(
background
);
stateNameText
.
setFontScale
(
tinierTitleFontBigScale
);
gameNameText
.
setFontScale
(
tinierTitleFontBigScale
);
outerTable
.
add
(
gameNameText
);
outerTable
.
row
();
outerTable
.
add
(
stateNameText
).
spaceBottom
(
spacingOnBottomInputFIeld
);
outerTable
.
row
();
innerTable
=
new
Table
();
innerTable
=
new
Table
();
Pixmap
bgPixmap
=
new
Pixmap
(
1
,
1
,
Pixmap
.
Format
.
RGB565
);
bgPixmap
.
setColor
(
Color
.
SKY
);
bgPixmap
.
fill
();
TextureRegionDrawable
textureRegionDrawableBg
=
new
TextureRegionDrawable
(
new
TextureRegion
(
new
Texture
(
bgPixmap
)));
innerTable
.
setBackground
(
textureRegionDrawableBg
);
innerTable
.
setFillParent
(
true
);
if
(
isNoHS
){
if
(
isNoHS
){
noHSLabelText
=
"No high scores recorded."
;
noHSLabelText
=
"No high scores recorded."
;
...
@@ -132,6 +165,20 @@ public class ViewHighScoreForGameState extends State {
...
@@ -132,6 +165,20 @@ public class ViewHighScoreForGameState extends State {
outerTable
.
add
(
hsPane
).
spaceBottom
(
spacingOnBottomInputFIeld
);
outerTable
.
add
(
hsPane
).
spaceBottom
(
spacingOnBottomInputFIeld
);
outerTable
.
getCell
(
hsPane
).
size
(
Gdx
.
graphics
.
getWidth
()/
1.1f
,
Gdx
.
graphics
.
getWidth
()/
2.5f
);
outerTable
.
getCell
(
hsPane
).
size
(
Gdx
.
graphics
.
getWidth
()/
1.1f
,
Gdx
.
graphics
.
getWidth
()/
2.5f
);
outerTable
.
row
();
Table
secondInnerTable
=
new
Table
();
Pixmap
secondBgPixmap
=
new
Pixmap
(
1
,
1
,
Pixmap
.
Format
.
RGB565
);
secondBgPixmap
.
setColor
(
Color
.
SKY
);
secondBgPixmap
.
fill
();
TextureRegionDrawable
secondTextureRegionDrawableBg
=
new
TextureRegionDrawable
(
new
TextureRegion
(
new
Texture
(
secondBgPixmap
)));
secondInnerTable
.
setBackground
(
secondTextureRegionDrawableBg
);
Label
playerLabel
=
new
Label
(
playerLabelText
,
skin
);
Label
playerScoreLabel
=
new
Label
(
String
.
valueOf
(
playerHS
),
skin
);
secondInnerTable
.
add
(
playerLabel
).
spaceTop
(
spacingOnBottom
).
pad
(
50
);
secondInnerTable
.
add
(
playerScoreLabel
).
spaceTop
(
spacingOnBottom
).
pad
(
50
);
outerTable
.
add
(
secondInnerTable
);
stage
.
addActor
(
outerTable
);
stage
.
addActor
(
outerTable
);
stage
.
addActor
(
makeBackBtn
());
stage
.
addActor
(
makeBackBtn
());
}
}
...
@@ -145,12 +192,17 @@ public class ViewHighScoreForGameState extends State {
...
@@ -145,12 +192,17 @@ public class ViewHighScoreForGameState extends State {
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
innerTable
.
add
(
new
Label
(
colOneText
,
skin
));
innerTable
.
add
(
new
Label
(
colTwoText
,
skin
)).
spaceRight
(
spacingOnBottom
);
innerTable
.
add
(
new
Label
(
colThreeText
,
skin
));
innerTable
.
row
();
int
length
=
Math
.
min
(
highscores
.
size
(),
5
);
int
length
=
Math
.
min
(
highscores
.
size
(),
5
);
for
(
int
i
=
0
;
i
<
length
;
i
++){
for
(
int
i
=
0
;
i
<
length
;
i
++){
Highscore
hs
=
highscores
.
get
(
i
);
Highscore
hs
=
highscores
.
get
(
i
);
Label
placementLabel
=
new
Label
(
String
.
valueOf
(
i
+
1
)+
".
place:
"
,
skin
);
Label
placementLabel
=
new
Label
(
String
.
valueOf
(
i
+
1
)+
". "
,
skin
);
Label
nameLabel
=
new
Label
(
hs
.
getName
()+
" "
,
skin
);
Label
nameLabel
=
new
Label
(
hs
.
getName
()+
" "
,
skin
);
Label
scoreLabel
=
new
Label
(
String
.
valueOf
(
hs
.
getValue
()),
skin
);
Label
scoreLabel
=
new
Label
(
String
.
valueOf
(
hs
.
getValue
()),
skin
);
...
@@ -159,13 +211,6 @@ public class ViewHighScoreForGameState extends State {
...
@@ -159,13 +211,6 @@ public class ViewHighScoreForGameState extends State {
innerTable
.
add
(
scoreLabel
);
innerTable
.
add
(
scoreLabel
);
innerTable
.
row
();
innerTable
.
row
();
}
}
Label
playerLabel
=
new
Label
(
playerLabelText
,
skin
);
Label
playerScoreLabel
=
new
Label
(
String
.
valueOf
(
playerHS
),
skin
);
innerTable
.
add
(
playerLabel
).
spaceTop
(
spacingOnBottom
);
innerTable
.
add
(
playerScoreLabel
).
spaceTop
(
spacingOnBottom
);
innerTable
.
row
();
}
}
}
}
\ No newline at end of file
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