Fix sound button not updating its state

This commit is contained in:
Lonami Exo 2017-02-02 15:46:13 +01:00
parent 6524fe8518
commit 8550359cb7
4 changed files with 14 additions and 15 deletions

View file

@ -13,7 +13,7 @@ public class SoftButton extends ImageButton {
//region Members
private int styleIndex;
private Drawable image;
public Drawable image;
//endregion

View file

@ -10,7 +10,6 @@ import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
@ -58,7 +57,7 @@ class CustomizeScreen implements Screen {
optionsGroup.space(12);
// Back to the previous screen
final ImageButton backButton = new SoftButton(1, "back_texture");
final SoftButton backButton = new SoftButton(1, "back_texture");
backButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
@ -68,21 +67,21 @@ class CustomizeScreen implements Screen {
optionsGroup.addActor(backButton);
// Turn sound on/off
final ImageButton soundButton = new SoftButton(
final SoftButton soundButton = new SoftButton(
0, Klooni.soundsEnabled() ? "sound_on_texture" : "sound_off_texture");
soundButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
Klooni.toggleSound();
soundButton.getStyle().imageUp = CustomizeScreen.this.game.skin.getDrawable(
soundButton.image = CustomizeScreen.this.game.skin.getDrawable(
Klooni.soundsEnabled() ? "sound_on_texture" : "sound_off_texture");
}
});
optionsGroup.addActor(soundButton);
// Issues
final ImageButton issuesButton = new SoftButton(3, "issues_texture");
final SoftButton issuesButton = new SoftButton(3, "issues_texture");
issuesButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
@ -92,7 +91,7 @@ class CustomizeScreen implements Screen {
optionsGroup.addActor(issuesButton);
// Website
final ImageButton webButton = new SoftButton(2, "web_texture");
final SoftButton webButton = new SoftButton(2, "web_texture");
webButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {

View file

@ -43,7 +43,7 @@ public class MainMenuScreen extends InputListener implements Screen {
stage.addActor(table);
// Play button
final ImageButton playButton = new SoftButton(0, "play_texture");
final SoftButton playButton = new SoftButton(0, "play_texture");
playButton.addListener(new ChangeListener() {
public void changed (ChangeEvent event, Actor actor) {
MainMenuScreen.this.game.setScreen(new GameScreen(MainMenuScreen.this.game));
@ -55,7 +55,7 @@ public class MainMenuScreen extends InputListener implements Screen {
table.row();
// Star button (on GitHub)
final ImageButton starButton = new SoftButton(1, "star_texture");
final SoftButton starButton = new SoftButton(1, "star_texture");
starButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
@ -65,11 +65,11 @@ public class MainMenuScreen extends InputListener implements Screen {
table.add(starButton).space(16);
// Stats button (high scores)
final ImageButton statsButton = new SoftButton(2, "stats_texture");
final SoftButton statsButton = new SoftButton(2, "stats_texture");
table.add(statsButton).space(16);
// Palette button (buy colors)
final ImageButton paletteButton = new SoftButton(3, "palette_texture");
final SoftButton paletteButton = new SoftButton(3, "palette_texture");
paletteButton.addListener(new ChangeListener() {
public void changed (ChangeEvent event, Actor actor) {
MainMenuScreen.this.game.setScreen(new CustomizeScreen(MainMenuScreen.this.game, MainMenuScreen.this.game.getScreen()));

View file

@ -56,7 +56,7 @@ class PauseMenuStage extends Stage {
addActor(band);
// Home screen button
final ImageButton homeButton = new SoftButton(3, "home_texture");
final SoftButton homeButton = new SoftButton(3, "home_texture");
table.add(homeButton).space(16);
homeButton.addListener(new ChangeListener() {
@ -67,7 +67,7 @@ class PauseMenuStage extends Stage {
});
// Replay button
final ImageButton replayButton = new SoftButton(0, "replay_texture");
final SoftButton replayButton = new SoftButton(0, "replay_texture");
table.add(replayButton).space(16);
replayButton.addListener(new ChangeListener() {
@ -81,7 +81,7 @@ class PauseMenuStage extends Stage {
table.row();
// Palette button (buy colors)
final ImageButton paletteButton = new SoftButton(1, "palette_texture");
final SoftButton paletteButton = new SoftButton(1, "palette_texture");
table.add(paletteButton).space(16);
paletteButton.addListener(new ChangeListener() {
@ -94,7 +94,7 @@ class PauseMenuStage extends Stage {
// Continue playing OR share (if game over) button
// TODO Enable both actions for this button? Or leave play?
final ImageButton playButton = new SoftButton(2, "play_texture");
final SoftButton playButton = new SoftButton(2, "play_texture");
table.add(playButton).space(16);
playButton.addListener(new ChangeListener() {