forgot to add this important file...

This commit is contained in:
Harrison Deng 2017-10-14 16:56:07 -05:00
parent 871e667707
commit f345e1de8c

View File

@ -0,0 +1,105 @@
package zero1hd.rhythmbullet.graphics.ui.components;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox;
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import sun.security.provider.DSAPublicKeyImpl;
import zero1hd.rhythmbullet.audio.SongListController;
public class MusicControls extends HorizontalGroup {
private SongListController sc;
private ImageButton reverse, forward;
private CheckBox shuffle, play;
private float disableTimer;
public MusicControls(Skin skin, SongListController sc) {
this.sc = sc;
reverse = new ImageButton(skin, "rewind-button");
reverse.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
boolean wasPlaying = sc.getCurrentSong().isPlaying();
sc.previous();
if (wasPlaying) {
sc.play();
}
forward.setDisabled(true);
reverse.setDisabled(true);
disableTimer = 0.75f;
}
});
addActor(reverse);
play = new CheckBox(null, skin, "play-button") {
@Override
public void act(float delta) {
play.setChecked(sc.getCurrentSong().isPlaying());
super.act(delta);
}
};
play.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (play.isChecked()) {
sc.getCurrentSong().play();
} else {
sc.getCurrentSong().pause();
}
}
});
addActor(play);
forward = new ImageButton(skin, "fast-forward-button");
forward.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
boolean wasPlaying = sc.getCurrentSong().isPlaying();
sc.skip();
if (wasPlaying) {
sc.play();
}
forward.setDisabled(true);
reverse.setDisabled(true);
disableTimer = 0.75f;
}
});
addActor(forward);
shuffle = new CheckBox(null, skin, "shuffle-button") {
@Override
public void act(float delta) {
shuffle.setChecked(sc.isShuffle());
super.act(delta);
}
};
shuffle.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
if (shuffle.isChecked()) {
sc.setShuffle(true);
} else {
sc.setShuffle(false);
}
}
});
addActor(shuffle);
space(15);
}
@Override
public void act(float delta) {
if (disableTimer > 0) {
disableTimer -= delta;
if (disableTimer <= 0) {
forward.setDisabled(false);
reverse.setDisabled(false);
}
}
super.act(delta);
}
}