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);
|
return !prefs.getBoolean("muteSound", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toggleSound() {
|
public static boolean toggleSound() {
|
||||||
prefs.putBoolean("muteSound", soundsEnabled()).flush();
|
final boolean result = soundsEnabled();
|
||||||
|
prefs.putBoolean("muteSound", result).flush();
|
||||||
|
return !result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean shouldSnapToGrid() {
|
public static boolean shouldSnapToGrid() {
|
||||||
return prefs.getBoolean("snapToGrid", false);
|
return prefs.getBoolean("snapToGrid", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toggleSnapToGrid() {
|
public static boolean toggleSnapToGrid() {
|
||||||
prefs.putBoolean("snapToGrid", !shouldSnapToGrid()).flush();
|
final boolean result = !shouldSnapToGrid();
|
||||||
|
prefs.putBoolean("snapToGrid", result).flush();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isThemeBought(Theme theme) {
|
public static boolean isThemeBought(Theme theme) {
|
||||||
|
|
|
@ -73,9 +73,9 @@ class CustomizeScreen implements Screen {
|
||||||
soundButton.addListener(new ChangeListener() {
|
soundButton.addListener(new ChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
Klooni.toggleSound();
|
final boolean enabled = Klooni.toggleSound();
|
||||||
soundButton.image = CustomizeScreen.this.game.skin.getDrawable(
|
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);
|
optionsGroup.addActor(soundButton);
|
||||||
|
@ -87,9 +87,9 @@ class CustomizeScreen implements Screen {
|
||||||
snapButton.addListener(new ChangeListener() {
|
snapButton.addListener(new ChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
Klooni.toggleSnapToGrid();
|
final boolean shouldSnap = Klooni.toggleSnapToGrid();
|
||||||
snapButton.image = CustomizeScreen.this.game.skin.getDrawable(
|
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);
|
optionsGroup.addActor(snapButton);
|
||||||
|
|
Loading…
Reference in a new issue