Tiny improvement to toggle settings
This commit is contained in:
parent
05d1e99117
commit
46214456f1
2 changed files with 12 additions and 8 deletions
|
@ -119,16 +119,20 @@ public class Klooni extends Game {
|
|||
return !prefs.getBoolean("muteSound", false);
|
||||
}
|
||||
|
||||
public static void toggleSound() {
|
||||
prefs.putBoolean("muteSound", soundsEnabled()).flush();
|
||||
public static boolean toggleSound() {
|
||||
final boolean result = soundsEnabled();
|
||||
prefs.putBoolean("muteSound", result).flush();
|
||||
return !result;
|
||||
}
|
||||
|
||||
public static boolean shouldSnapToGrid() {
|
||||
return prefs.getBoolean("snapToGrid", false);
|
||||
}
|
||||
|
||||
public static void toggleSnapToGrid() {
|
||||
prefs.putBoolean("snapToGrid", !shouldSnapToGrid()).flush();
|
||||
public static boolean toggleSnapToGrid() {
|
||||
final boolean result = !shouldSnapToGrid();
|
||||
prefs.putBoolean("snapToGrid", result).flush();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static boolean isThemeBought(Theme theme) {
|
||||
|
|
|
@ -73,9 +73,9 @@ class CustomizeScreen implements Screen {
|
|||
soundButton.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
Klooni.toggleSound();
|
||||
final boolean enabled = Klooni.toggleSound();
|
||||
soundButton.image = CustomizeScreen.this.game.skin.getDrawable(
|
||||
Klooni.soundsEnabled() ? "sound_on_texture" : "sound_off_texture");
|
||||
enabled ? "sound_on_texture" : "sound_off_texture");
|
||||
}
|
||||
});
|
||||
optionsGroup.addActor(soundButton);
|
||||
|
@ -87,9 +87,9 @@ class CustomizeScreen implements Screen {
|
|||
snapButton.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
Klooni.toggleSnapToGrid();
|
||||
final boolean shouldSnap = Klooni.toggleSnapToGrid();
|
||||
snapButton.image = CustomizeScreen.this.game.skin.getDrawable(
|
||||
Klooni.shouldSnapToGrid() ? "snap_on_texture" : "snap_off_texture");
|
||||
shouldSnap ? "snap_on_texture" : "snap_off_texture");
|
||||
}
|
||||
});
|
||||
optionsGroup.addActor(snapButton);
|
||||
|
|
Loading…
Reference in a new issue