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
bb7d4fe9
Commit
bb7d4fe9
authored
5 years ago
by
Haakon Gunleiksrud
Browse files
Options
Downloads
Patches
Plain Diff
#32
Tried to add a lambda expression to OptionState for a general checkbox maker.
parent
72106186
No related branches found
No related tags found
1 merge request
!26
Resolve "Options-functionality"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/core/src/com/gameware/game/states/OptionsState.java
+24
-5
24 additions, 5 deletions
frontend/core/src/com/gameware/game/states/OptionsState.java
with
24 additions
and
5 deletions
frontend/core/src/com/gameware/game/states/OptionsState.java
+
24
−
5
View file @
bb7d4fe9
...
...
@@ -2,6 +2,8 @@ package com.gameware.game.states;
import
com.badlogic.gdx.Gdx
;
import
com.badlogic.gdx.graphics.g2d.SpriteBatch
;
import
com.badlogic.gdx.scenes.scene2d.Event
;
import
com.badlogic.gdx.scenes.scene2d.EventListener
;
import
com.badlogic.gdx.scenes.scene2d.InputEvent
;
import
com.badlogic.gdx.scenes.scene2d.Stage
;
import
com.badlogic.gdx.scenes.scene2d.ui.CheckBox
;
...
...
@@ -39,10 +41,20 @@ public class OptionsState extends State {
table
.
setFillParent
(
true
);
//T
o do learn more about lambda expressions and make a general check box maker method, which takes in a listener
.
//T
ODO: Make the functional interfaces work
.
table
.
row
();
table
.
add
(
makeLabel
(
musicToggleLabelText
,
skin
));
table
.
add
(
makeMusicCheckBox
(
skin
));
table
.
add
(
makeMusicCheckBox
(
skin
,
new
checkBoxInterface
()
{
@Override
public
boolean
handle
(
Event
event
)
{
new
ClickListener
()
{
@Override
public
void
clicked
(
InputEvent
event
,
float
x
,
float
y
){
GameWare
.
toggleMusic
();
}
};
return
false
;
}
}));
table
.
row
();
table
.
add
(
makeLabel
(
soundEffectToggleLabelText
,
skin
));
...
...
@@ -102,12 +114,15 @@ public class OptionsState extends State {
return
label
;
}
private
CheckBox
makeMusicCheckBox
(
Skin
skin
){
private
CheckBox
makeMusicCheckBox
(
Skin
skin
,
checkBoxInterface
obj
){
CheckBox
musicToggle
=
new
CheckBox
(
""
,
skin
);
/*
musicToggle.addListener(new ClickListener() {
@Override
public void clicked(InputEvent e, float x, float y){ GameWare.toggleMusic(); }
});
*/
musicToggle
.
addListener
((
EventListener
)
obj
);
return
musicToggle
;
}
...
...
@@ -115,7 +130,7 @@ public class OptionsState extends State {
CheckBox
soundEffectToggle
=
new
CheckBox
(
""
,
skin
);
soundEffectToggle
.
addListener
(
new
ClickListener
()
{
@Override
public
void
clicked
(
InputEvent
e
,
float
x
,
float
y
){
GameWare
.
toggle
Music
();
}
public
void
clicked
(
InputEvent
e
,
float
x
,
float
y
){
GameWare
.
toggle
SoundEffects
();
}
});
return
soundEffectToggle
;
}
...
...
@@ -124,11 +139,15 @@ public class OptionsState extends State {
CheckBox
darkModeToggle
=
new
CheckBox
(
""
,
skin
);
darkModeToggle
.
addListener
(
new
ClickListener
()
{
@Override
public
void
clicked
(
InputEvent
e
,
float
x
,
float
y
){
GameWare
.
toggle
Music
();
}
public
void
clicked
(
InputEvent
e
,
float
x
,
float
y
){
GameWare
.
toggle
DarkMode
();
}
});
return
darkModeToggle
;
}
public
interface
checkBoxInterface
extends
EventListener
{
}
private
void
backBtnClick
(){
gsm
.
set
(
new
MenuState
(
gsm
));
}
...
...
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