removed old, unused code; music controls now updated to use new
framework; circular visualizer updated; moved visualizers to core for all platforms and accounted for different platform PCM reading with interface for visualizer in core;
This commit is contained in:
@@ -1,112 +0,0 @@
|
||||
package zero1hd.rhythmbullet.desktop.audio.visualizer;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
|
||||
|
||||
import zero1hd.rhythmbullet.audio.MusicController;
|
||||
|
||||
public class DoubleHorizontalVisualizer {
|
||||
private int width, height, barCount, barWidth, spaceBetweenBars;
|
||||
private int x, y;
|
||||
private float barRate = 0.75f;
|
||||
private ShapeRenderer shapeRenderer;
|
||||
private PCMMachine pcm;
|
||||
private int smoothRange;
|
||||
private int multiplier = 300;
|
||||
private int[] amplitudes;
|
||||
private int[] barHeights;
|
||||
private int binsPerBar;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param barCount amount of bars this visualizer should have.
|
||||
* @param width the width of the visualizer.
|
||||
* @param spacePercentage the percentage of a bar that should be space.
|
||||
*/
|
||||
public DoubleHorizontalVisualizer(int barCount, int width, int height, float spacePercentage, MusicController musicController) {
|
||||
this.barCount = barCount;
|
||||
this.barWidth = width/barCount;
|
||||
this.spaceBetweenBars = (int) (barWidth * spacePercentage);
|
||||
this.barWidth -= spaceBetweenBars;
|
||||
if (barWidth < 1) throw new IllegalArgumentException("The arguments you passed caused the bar width to be 0.");
|
||||
binsPerBar = (pcm.getWindowSize()/barCount);
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
pcm = new PCMMachine(musicController);
|
||||
amplitudes = new int[barCount];
|
||||
barHeights = new int[barCount];
|
||||
shapeRenderer = new ShapeRenderer();
|
||||
shapeRenderer.set(ShapeType.Filled);
|
||||
}
|
||||
|
||||
public void act(float delta) {
|
||||
for (int bar = 0; bar < amplitudes.length; bar++) {
|
||||
float normalizedAmplitude = 0;
|
||||
for (int freq = bar*binsPerBar; freq < bar*binsPerBar + binsPerBar; freq++) {
|
||||
normalizedAmplitude += Math.abs(pcm.getFrequencyBins()[freq]);
|
||||
}
|
||||
amplitudes[bar] = (int) (normalizedAmplitude*multiplier);
|
||||
amplitudes[bar] /= binsPerBar;
|
||||
|
||||
barHeights[bar] += Math.max(0, (amplitudes[bar] - barHeights[bar]) * barRate * delta);
|
||||
if (barHeights[bar] > amplitudes[bar]) barHeights[bar] = amplitudes[bar];
|
||||
|
||||
}
|
||||
for (int bar = 1; bar <= barHeights.length; bar++) {
|
||||
int smoothCount = 1;
|
||||
for (int range = 0; range < smoothRange; range++) {
|
||||
if (bar+range < amplitudes.length) {
|
||||
barHeights[bar] += amplitudes[bar+range];
|
||||
smoothCount++;
|
||||
}
|
||||
if (bar-range > 0) {
|
||||
barHeights[bar] += amplitudes[bar-range];
|
||||
smoothCount++;
|
||||
}
|
||||
}
|
||||
barHeights[bar] /= smoothCount;
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
shapeRenderer.begin();
|
||||
shapeRenderer.rect(x, y-2, width, y);
|
||||
shapeRenderer.rect(x, y+height, width, y+height+2);
|
||||
int beginX = x + spaceBetweenBars/2, beginY = y;
|
||||
for (int bar = 0; bar < barCount; bar++) {
|
||||
shapeRenderer.rect(beginX + spaceBetweenBars*bar, beginY+height, beginX+barWidth, beginY+barHeights[bar]+height);
|
||||
shapeRenderer.rect(beginX + spaceBetweenBars*bar, beginY, beginX+barWidth, beginY+barHeights[barHeights.length - 1 - bar]);
|
||||
}
|
||||
shapeRenderer.end();
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setX(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public void setY(int y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void setPosition(int x, int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
}
|
@@ -10,7 +10,6 @@ import java.util.Observer;
|
||||
import org.lwjgl.openal.AL11;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.assets.AssetLoaderParameters.LoadedCallback;
|
||||
import com.badlogic.gdx.backends.lwjgl.audio.OpenALMusic;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
import com.badlogic.gdx.utils.TimeUtils;
|
||||
@@ -20,8 +19,9 @@ import com.badlogic.gdx.utils.reflect.ReflectionException;
|
||||
|
||||
import zero1hd.rhythmbullet.audio.MusicController;
|
||||
import zero1hd.rhythmbullet.audio.visualizer.BasicFFT;
|
||||
import zero1hd.rhythmbullet.audio.visualizer.PCMSystem;
|
||||
|
||||
public class PCMMachine implements Observer, Disposable {
|
||||
public class PCMObtainer implements Observer, Disposable, PCMSystem {
|
||||
private int windowSize = 1024;
|
||||
private float[] PCM = new float[windowSize];
|
||||
private float[] frequencyBins = new float[windowSize / 2];
|
||||
@@ -38,7 +38,7 @@ public class PCMMachine implements Observer, Disposable {
|
||||
private int currentPlaybackWindow;
|
||||
private volatile boolean updated;
|
||||
|
||||
public PCMMachine(MusicController musicController) {
|
||||
public PCMObtainer(MusicController musicController) {
|
||||
this.mc = musicController;
|
||||
mc.addObserver(this);
|
||||
try {
|
||||
@@ -141,6 +141,7 @@ public class PCMMachine implements Observer, Disposable {
|
||||
buffer.rewind();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] getFrequencyBins() {
|
||||
if (updated) {
|
||||
synchronized (PCM) {
|
||||
@@ -151,6 +152,7 @@ public class PCMMachine implements Observer, Disposable {
|
||||
return frequencyBins;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWindowSize() {
|
||||
return windowSize;
|
||||
}
|
@@ -12,23 +12,16 @@ import zero1hd.rhythmbullet.audio.MusicController;
|
||||
public class MusicControls extends HorizontalGroup {
|
||||
private ImageButton reverse, forward;
|
||||
private CheckBox shuffle, play;
|
||||
private float disableTimer;
|
||||
public MusicControls(Skin skin, final MusicController sc) {
|
||||
reverse = new ImageButton(skin, "rewind-button");
|
||||
reverse.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
if (sc.getCurrentMusicManager() != null) {
|
||||
boolean wasPlaying = sc.getCurrentMusicManager().isPlaying();
|
||||
sc.previous();
|
||||
if (wasPlaying) {
|
||||
sc.play();
|
||||
}
|
||||
boolean wasPlaying = sc.isPlaying();
|
||||
sc.previous();
|
||||
if (wasPlaying) {
|
||||
sc.play();
|
||||
}
|
||||
|
||||
forward.setDisabled(true);
|
||||
reverse.setDisabled(true);
|
||||
disableTimer = 0.75f;
|
||||
}
|
||||
});
|
||||
addActor(reverse);
|
||||
@@ -36,8 +29,8 @@ public class MusicControls extends HorizontalGroup {
|
||||
play = new CheckBox(null, skin, "play-button") {
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
if (sc.getCurrentMusicManager() != null) {
|
||||
play.setChecked(sc.getCurrentMusicManager().isPlaying());
|
||||
if (sc.hasSongLoaded()) {
|
||||
play.setChecked(sc.isPlaying());
|
||||
} else {
|
||||
play.setChecked(false);
|
||||
}
|
||||
@@ -47,13 +40,11 @@ public class MusicControls extends HorizontalGroup {
|
||||
play.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
if (sc.getCurrentMusicManager() != null) {
|
||||
if (play.isChecked()) {
|
||||
sc.getCurrentMusicManager().play();
|
||||
} else {
|
||||
sc.getCurrentMusicManager().pause();
|
||||
}
|
||||
}
|
||||
if (play.isChecked()) {
|
||||
sc.play();
|
||||
} else {
|
||||
sc.pause();
|
||||
}
|
||||
}
|
||||
});
|
||||
addActor(play);
|
||||
@@ -62,17 +53,11 @@ public class MusicControls extends HorizontalGroup {
|
||||
forward.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
if (sc.getCurrentMusicManager() != null) {
|
||||
boolean wasPlaying = sc.getCurrentMusicManager().isPlaying();
|
||||
sc.skip();
|
||||
if (wasPlaying) {
|
||||
sc.play();
|
||||
}
|
||||
boolean wasPlaying = sc.isPlaying();
|
||||
sc.skip();
|
||||
if (wasPlaying) {
|
||||
sc.play();
|
||||
}
|
||||
|
||||
forward.setDisabled(true);
|
||||
reverse.setDisabled(true);
|
||||
disableTimer = 0.75f;
|
||||
}
|
||||
});
|
||||
addActor(forward);
|
||||
@@ -98,20 +83,4 @@ public class MusicControls extends HorizontalGroup {
|
||||
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
setWidth(getMinWidth());
|
||||
setHeight(getMinHeight());
|
||||
|
||||
if (disableTimer > 0) {
|
||||
disableTimer -= delta;
|
||||
if (disableTimer <= 0) {
|
||||
forward.setDisabled(false);
|
||||
reverse.setDisabled(false);
|
||||
disableTimer = 0;
|
||||
}
|
||||
}
|
||||
super.act(delta);
|
||||
}
|
||||
}
|
||||
|
@@ -1,44 +0,0 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.pages;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
|
||||
public class StatPage extends Page {
|
||||
private Table table;
|
||||
private Label winLabel;
|
||||
|
||||
private Label finalScore, damageTaken, enemiesKilled, shotsTaken, shotsMissed, accuracy;
|
||||
public StatPage(Skin skin, int score, int damageTake, int enemiesKilled, int shotsTaken, int shotsMissed, int accuracy) {
|
||||
table = new Table(skin);
|
||||
addActor(table);
|
||||
table.setFillParent(true);
|
||||
|
||||
winLabel = new Label("Win!", skin);
|
||||
table.add(winLabel);
|
||||
table.row();
|
||||
|
||||
this.finalScore = new Label("Your score: " + score, skin, "sub-font", skin.getColor("default"));
|
||||
table.add(this.finalScore);
|
||||
table.row();
|
||||
|
||||
this.damageTaken = new Label("Damage Taken: " + damageTake, skin, "sub-font", skin.getColor("default"));
|
||||
table.add(this.damageTaken);
|
||||
table.row();
|
||||
|
||||
this.enemiesKilled = new Label("Enemies slayed: " + enemiesKilled, skin, "sub-font", skin.getColor("default"));
|
||||
table.add(this.enemiesKilled);
|
||||
table.row();
|
||||
|
||||
this.shotsTaken = new Label("Shots taken: " + shotsTaken, skin, "sub-font", skin.getColor("default"));
|
||||
table.add(this.shotsTaken);
|
||||
table.row();
|
||||
|
||||
this.shotsMissed = new Label("Shots missed: " + shotsMissed, skin, "sub-font", skin.getColor("default"));
|
||||
table.add(this.shotsMissed);
|
||||
table.row();
|
||||
|
||||
this.accuracy = new Label("Accuracy: " + accuracy, skin, "sub-font", skin.getColor("default"));
|
||||
table.add(this.accuracy);
|
||||
}
|
||||
}
|
@@ -1,132 +0,0 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.windows;
|
||||
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Window;
|
||||
|
||||
import zero1hd.rhythmbullet.audio.AudioDataPackage;
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
|
||||
public class BeatViewer extends Window {
|
||||
Pixmap lights;
|
||||
int songIndex;
|
||||
MusicManager music;
|
||||
Texture lightOn;
|
||||
private AudioDataPackage data;
|
||||
|
||||
public BeatViewer(String title, Skin skin) {
|
||||
super(title, skin, "tinted");
|
||||
defaults().space(5f);
|
||||
setSize(64, 100);
|
||||
|
||||
|
||||
//Draw the 'lights'
|
||||
lights = new Pixmap(16, 16, Format.RGBA8888);
|
||||
lights.setColor(1, 0.2f, 0.2f, 1f);
|
||||
lights.fillCircle(lights.getWidth()/2, lights.getHeight()/2, 7);
|
||||
lightOn = new Texture(lights);
|
||||
|
||||
|
||||
WidgetGroup bassBar = new WidgetGroup();
|
||||
final Image bgBassBar = new Image(skin.getPatch("bar-empty"));
|
||||
bgBassBar.setHeight(50f);
|
||||
bassBar.setSize(bgBassBar.getWidth(), bgBassBar.getHeight());
|
||||
|
||||
final Image bassBarFill = new Image(skin.getPatch("bar-fill")) {
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
try {
|
||||
if (music != null && data.getBassPeaks().get(songIndex) != 0) {
|
||||
clearActions();
|
||||
addAction(Actions.sequence(Actions.sizeTo(getWidth(), (data.getBassPeaks().get(songIndex)/data.getBassMaxVal())*bgBassBar.getHeight()), Actions.sizeTo(getWidth(), 0, 0.3f)));
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
}
|
||||
super.act(delta);
|
||||
}
|
||||
};
|
||||
bassBarFill.setHeight(0f);
|
||||
bassBar.addActor(bgBassBar);
|
||||
bassBar.addActor(bassBarFill);
|
||||
add(bassBar).minSize(bassBar.getWidth(), bassBar.getHeight());
|
||||
|
||||
WidgetGroup UMBar = new WidgetGroup();
|
||||
final Image bgUMBar = new Image(skin.getPatch("bar-empty"));
|
||||
bgUMBar.setHeight(50f);
|
||||
UMBar.setSize(bgUMBar.getWidth(), bgUMBar.getHeight());
|
||||
Image UMBarFill = new Image(skin.getPatch("bar-fill")) {
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
try {
|
||||
if (music != null && data.getBassPeaks().get(songIndex) != 0) {
|
||||
clearActions();
|
||||
addAction(Actions.sequence(Actions.sizeTo(getWidth(), (data.getuMPeaks().get(songIndex)/data.getuMMaxval())*bgUMBar.getHeight()), Actions.sizeTo(getWidth(), 0f, 0.3f)));
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
|
||||
}
|
||||
super.act(delta);
|
||||
}
|
||||
};
|
||||
UMBarFill.setHeight(0f);
|
||||
UMBar.addActor(bgUMBar);
|
||||
UMBar.addActor(UMBarFill);
|
||||
add(UMBar).minSize(UMBar.getWidth(), UMBar.getHeight());
|
||||
|
||||
|
||||
row();
|
||||
|
||||
Image bassIndicator = new Image(lightOn) {
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
try {
|
||||
if (music != null && data.getBassPeaks().get(songIndex) != 0) {
|
||||
clearActions();
|
||||
addAction(Actions.sequence(Actions.alpha(1f), Actions.fadeOut(0.15f)));
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
}
|
||||
super.act(delta);
|
||||
}
|
||||
};
|
||||
|
||||
bassIndicator.setColor(1f, 1f, 1f, 0f);
|
||||
add(bassIndicator).center();
|
||||
|
||||
|
||||
Image UMIndicator = new Image(lightOn) {
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
try {
|
||||
if (music != null && data.getuMPeaks().get(songIndex) != 0) {
|
||||
clearActions();
|
||||
addAction(Actions.sequence(Actions.alpha(1f), Actions.fadeOut(0.15f)));
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
|
||||
}
|
||||
super.act(delta);
|
||||
}
|
||||
};
|
||||
UMIndicator.setColor(1f, 1f, 1f, 0f);
|
||||
add(UMIndicator).center();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
if (music != null) {
|
||||
songIndex = music.getPlaybackIndexPosition();
|
||||
}
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
public void setMusic(MusicManager audioData, AudioDataPackage adp) {
|
||||
this.music = audioData;
|
||||
this.data = adp;
|
||||
}
|
||||
}
|
@@ -1,77 +0,0 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.windows;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Slider;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Window;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
|
||||
public class DifficultyWindow extends Window {
|
||||
private Slider sensitivityRating;
|
||||
private Label sensitivityRatingTitle;
|
||||
private Slider speedModifier;
|
||||
private Label speedModifierTitle;
|
||||
private Slider healthModifier;
|
||||
private Label healthModifierTitle;
|
||||
|
||||
public DifficultyWindow(Skin skin) {
|
||||
super("Difficulty Adjuster", skin, "tinted");
|
||||
sensitivityRating = new Slider(0f, 100f, 1f, false, skin);
|
||||
sensitivityRating.setValue(0f);
|
||||
sensitivityRating.addListener(new ChangeListener() {
|
||||
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
sensitivityRatingTitle.setText("Base Difficulty: " + sensitivityRating.getValue());
|
||||
}
|
||||
});
|
||||
|
||||
sensitivityRatingTitle = new Label("Base Difficulty: " + sensitivityRating.getValue(), skin, "sub-font", skin.getColor("default"));
|
||||
add(sensitivityRatingTitle);
|
||||
add(sensitivityRating);
|
||||
|
||||
row();
|
||||
|
||||
speedModifier = new Slider(1f, 3f, 0.25f, false, skin);
|
||||
speedModifier.setValue(1f);
|
||||
speedModifier.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
speedModifierTitle.setText("Speed Modifier: " + speedModifier.getValue());
|
||||
}
|
||||
});
|
||||
speedModifierTitle = new Label("Speed Modifier: " + speedModifier.getValue(), skin, "sub-font", skin.getColor("default"));
|
||||
add(speedModifierTitle);
|
||||
add(speedModifier);
|
||||
|
||||
row();
|
||||
|
||||
healthModifier = new Slider(0f, 5f, 1f, false, skin);
|
||||
healthModifier.setValue(0f);
|
||||
healthModifier.addListener(new ChangeListener() {
|
||||
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
healthModifierTitle.setText("Health modifier: " + healthModifier.getValue());
|
||||
}
|
||||
});
|
||||
healthModifierTitle = new Label("Health modifier: " + healthModifier.getValue(), skin, "sub-font", skin.getColor("default"));
|
||||
add(healthModifierTitle);
|
||||
add(healthModifier);
|
||||
|
||||
pack();
|
||||
}
|
||||
|
||||
public float getOverallDiffMod() {
|
||||
return sensitivityRating.getValue();
|
||||
}
|
||||
|
||||
public float getSpeedModifier() {
|
||||
return speedModifier.getValue();
|
||||
}
|
||||
|
||||
public float getHealthModifier() {
|
||||
return healthModifier.getValue();
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.windows;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Window;
|
||||
|
||||
public class FPSWindow extends Window {
|
||||
public FPSWindow(String title, Skin skin) {
|
||||
super(title, skin, "tinted");
|
||||
Label FPS = new Label("FPS: ", skin, "window-font", skin.getColor("default")) {
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
setText("FPS: " + Gdx.graphics.getFramesPerSecond());
|
||||
super.act(delta);
|
||||
}
|
||||
};
|
||||
add(FPS).center();
|
||||
setSize(70, 70);
|
||||
}
|
||||
}
|
@@ -1,85 +0,0 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.windows;
|
||||
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.audio.Sound;
|
||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Window;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
|
||||
public class LoadingWindow extends Window implements Disposable {
|
||||
|
||||
private Label status;
|
||||
private Sound closeSound;
|
||||
private Sound openSound;
|
||||
private float vol;
|
||||
public LoadingWindow(Skin skin, boolean progress, AssetManager assets, float vol) {
|
||||
super("loading...", skin, "tinted");
|
||||
|
||||
this.openSound = assets.get("pop_open.ogg", Sound.class);
|
||||
this.closeSound = assets.get("pop_close.ogg", Sound.class);
|
||||
this.vol = vol;
|
||||
Image loading = new Image(skin, "loading");
|
||||
loading.addAction(Actions.forever(Actions.rotateBy(-360f, 2f)));
|
||||
add(loading).left();
|
||||
|
||||
setSize(loading.getWidth()+20f, loading.getHeight()+40f);
|
||||
|
||||
loading.setOrigin(loading.getWidth()/2, loading.getHeight()/2);
|
||||
|
||||
|
||||
|
||||
if (progress) {
|
||||
status = new Label("[ ]", skin, "sub-font", skin.getColor("default"));
|
||||
add(status).spaceLeft(10f).expandX().right();
|
||||
setSize(getWidth() + status.getWidth() + 45f, (loading.getHeight() >= status.getHeight() ? loading.getHeight() : status.getHeight()) + 74);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public LoadingWindow(Skin skin, String styleName, boolean progress, AssetManager assets, float vol) {
|
||||
super("loading...", skin, styleName);
|
||||
|
||||
this.openSound = assets.get("pop_open.ogg", Sound.class);
|
||||
this.closeSound = assets.get("pop_close.ogg", Sound.class);
|
||||
this.vol = vol;
|
||||
Image loading = new Image(skin, "loading");
|
||||
loading.addAction(Actions.forever(Actions.rotateBy(-360f, 2f)));
|
||||
add(loading).left();
|
||||
|
||||
setSize(loading.getWidth()+20f, loading.getHeight()+40f);
|
||||
|
||||
loading.setOrigin(loading.getWidth()/2, loading.getHeight()/2);
|
||||
|
||||
|
||||
|
||||
if (progress) {
|
||||
status = new Label("[ ]", skin, "sub-font", skin.getColor("default"));
|
||||
add(status).spaceLeft(10f).expandX().right();
|
||||
setSize(getWidth() + status.getWidth() + 45f, (loading.getHeight() >= status.getHeight() ? loading.getHeight() : status.getHeight()) + 74);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void playOpenSound() {
|
||||
openSound.play(vol/100f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove() {
|
||||
closeSound.play(vol/100f);
|
||||
return super.remove();
|
||||
}
|
||||
|
||||
public void setProgress(float progress) {
|
||||
status.setText(String.valueOf((int) progress) + '%');
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
openSound.dispose();
|
||||
closeSound.dispose();
|
||||
}
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.windows;
|
||||
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.audio.Sound;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Window;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
|
||||
public class NoticeWindow extends Window {
|
||||
private Label noticeText;
|
||||
private Skin skin;
|
||||
|
||||
private Sound closeSound;
|
||||
private Sound openSound;
|
||||
private float vol;
|
||||
public NoticeWindow(Skin skin, String styleName, String text, float vol, AssetManager assets) {
|
||||
super("Notice", skin, "tinted");
|
||||
this.skin = skin;
|
||||
|
||||
this.openSound = assets.get("pop_open.ogg", Sound.class);
|
||||
this.closeSound = assets.get("pop_close.ogg", Sound.class);
|
||||
this.vol = vol;
|
||||
|
||||
noticeText = new Label(text, skin, "sub-font", skin.getColor("default"));
|
||||
noticeText.setWrap(true);
|
||||
noticeText.setAlignment(Align.center);
|
||||
add(noticeText).expandX().fill().center().padLeft(20f).padRight(20f);
|
||||
}
|
||||
|
||||
public NoticeWindow(Skin skin, String styleName, String title, String text, float vol, AssetManager assets) {
|
||||
super(title, skin, styleName);
|
||||
this.skin = skin;
|
||||
|
||||
this.openSound = assets.get("pop_open.ogg", Sound.class);
|
||||
this.closeSound = assets.get("pop_close.ogg", Sound.class);
|
||||
this.vol = vol;
|
||||
|
||||
noticeText = new Label(text, skin, "sub-font", skin.getColor("default"));
|
||||
noticeText.setWrap(true);
|
||||
noticeText.setAlignment(Align.center);
|
||||
add(noticeText).expandX().fill().center().padLeft(20f).padRight(20f);
|
||||
}
|
||||
|
||||
public void setupButton(String text, ChangeListener changeListener, int alignment) {
|
||||
TextButton button = new TextButton(text, skin, "sub");
|
||||
button.addListener(changeListener);
|
||||
add(button).align(alignment);
|
||||
}
|
||||
|
||||
public void playOpenSound() {
|
||||
openSound.play(vol/100f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove() {
|
||||
closeSound.play(vol/100f);
|
||||
return super.remove();
|
||||
}
|
||||
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.windows;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Window;
|
||||
|
||||
public class PauseMenu extends Window {
|
||||
private Label label;
|
||||
private TextButton resumeButton;
|
||||
private TextButton quit;
|
||||
public PauseMenu(Skin skin) {
|
||||
super("Paused", skin, "tinted");
|
||||
defaults().pad(25f);
|
||||
label = new Label("Game is paused.", skin);
|
||||
add(label).spaceBottom(15f);
|
||||
row();
|
||||
|
||||
resumeButton = new TextButton("Resume", skin, "sub");
|
||||
add(resumeButton).spaceBottom(8f);
|
||||
quit = new TextButton("Quit", skin, "sub");
|
||||
add(quit);
|
||||
pack();
|
||||
|
||||
setModal(true);
|
||||
}
|
||||
|
||||
|
||||
public TextButton getResumeButton() {
|
||||
return resumeButton;
|
||||
}
|
||||
public TextButton getQuitButton() {
|
||||
return quit;
|
||||
}
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.windows;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Window;
|
||||
|
||||
public class Spawnables extends Window {
|
||||
|
||||
public Spawnables(String title, Skin skin) {
|
||||
super(title, skin, "tinted");
|
||||
|
||||
Table spawnButtons = new Table(skin);
|
||||
|
||||
ScrollPane entityListScroller = new ScrollPane(spawnButtons);
|
||||
entityListScroller.setSize(180, 80);
|
||||
add(entityListScroller);
|
||||
setSize(185, 85);
|
||||
}
|
||||
}
|
@@ -1,76 +0,0 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.windows;
|
||||
|
||||
import com.badlogic.gdx.Preferences;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Slider;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Window;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
|
||||
public class VolumeWindow extends Window {
|
||||
|
||||
private Slider fxVolSlider;
|
||||
private Slider musicVolSlider;
|
||||
private Preferences prefs;
|
||||
|
||||
private MusicManager music;
|
||||
public VolumeWindow(String title, Skin skin, Preferences prefs) {
|
||||
super(title, skin, "tinted");
|
||||
this.prefs = prefs;
|
||||
setSize(360f, 100f);
|
||||
|
||||
Label musicVolSliderLabel = new Label("Music Volume: ", skin, "window-font", skin.getColor("default"));
|
||||
add(musicVolSliderLabel).left().padLeft(5f);
|
||||
musicVolSlider = new Slider(0, 100, 0.1f, false, skin);
|
||||
musicVolSlider.setValue(prefs.getFloat("music vol", 100f));
|
||||
add(musicVolSlider).width(200f);
|
||||
final Label musicVolPercentage = new Label(MathUtils.round(musicVolSlider.getValue()) + "%", skin, "window-font", skin.getColor("default"));
|
||||
musicVolSlider.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
save();
|
||||
musicVolPercentage.setText(MathUtils.round(musicVolSlider.getValue()) + "%");
|
||||
if (music != null) {
|
||||
music.setVolume(musicVolSlider.getValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
add(musicVolPercentage).spaceLeft(10f).expandX().left();
|
||||
|
||||
row();
|
||||
|
||||
Label fxVolSliderLabel = new Label("FX Volume: ", skin, "window-font", skin.getColor("default"));
|
||||
add(fxVolSliderLabel).left().padLeft(5f);
|
||||
fxVolSlider = new Slider(0, 100, 1, false, skin);
|
||||
fxVolSlider.setValue(prefs.getFloat("fx vol", 100f));
|
||||
add(fxVolSlider).width(200f);
|
||||
final Label fxVolPercentage = new Label(MathUtils.round(fxVolSlider.getValue()) + "%", skin, "window-font", skin.getColor("default"));
|
||||
fxVolSlider.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
save();
|
||||
fxVolPercentage.setText(MathUtils.round(fxVolSlider.getValue()) + "%");
|
||||
}
|
||||
});
|
||||
|
||||
add(fxVolPercentage).spaceLeft(10f).expandX().left();
|
||||
}
|
||||
|
||||
public void save() {
|
||||
prefs.putFloat("music vol", musicVolSlider.getValue());
|
||||
prefs.putFloat("fx vol", fxVolSlider.getValue());
|
||||
prefs.flush();
|
||||
}
|
||||
|
||||
public void setMusic(MusicManager music) {
|
||||
this.music = music;
|
||||
if (music != null) {
|
||||
music.setVolume(prefs.getFloat("music vol"));
|
||||
}
|
||||
}
|
||||
}
|
@@ -10,8 +10,9 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.utils.viewport.ExtendViewport;
|
||||
|
||||
import zero1hd.rhythmbullet.RhythmBullet;
|
||||
import zero1hd.rhythmbullet.audio.MusicController;
|
||||
import zero1hd.rhythmbullet.audio.visualizer.CircularVisualizer;
|
||||
import zero1hd.rhythmbullet.desktop.audio.visualizer.PCMMachine;
|
||||
import zero1hd.rhythmbullet.desktop.audio.visualizer.PCMObtainer;
|
||||
import zero1hd.rhythmbullet.game.GameController;
|
||||
|
||||
public class GameScreen extends ScreenAdapter {
|
||||
@@ -21,11 +22,11 @@ public class GameScreen extends ScreenAdapter {
|
||||
private GameController gc;
|
||||
private CircularVisualizer circleVisualizer;
|
||||
|
||||
public GameScreen(AssetManager assets, Preferences prefs) {
|
||||
public GameScreen(AssetManager assets, Preferences prefs, MusicController musicController) {
|
||||
this.assets = assets;
|
||||
batch = new SpriteBatch();
|
||||
viewport = new ExtendViewport(RhythmBullet.WORLD_WIDTH, RhythmBullet.WORLD_HEIGHT);
|
||||
circleVisualizer = new CircularVisualizer(new PCMMachine());
|
||||
circleVisualizer = new CircularVisualizer(new PCMObtainer(musicController));
|
||||
circleVisualizer.setCenter(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2);
|
||||
circleVisualizer.setCamera(viewport.getCamera());
|
||||
circleVisualizer.setColor(Color.CYAN.toFloatBits());
|
||||
|
@@ -18,7 +18,8 @@ import com.badlogic.gdx.utils.Align;
|
||||
|
||||
import zero1hd.rhythmbullet.RhythmBullet;
|
||||
import zero1hd.rhythmbullet.audio.MusicController;
|
||||
import zero1hd.rhythmbullet.desktop.audio.visualizer.DoubleHorizontalVisualizer;
|
||||
import zero1hd.rhythmbullet.audio.visualizer.DoubleHorizontalVisualizer;
|
||||
import zero1hd.rhythmbullet.desktop.audio.visualizer.PCMObtainer;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.components.MusicControls;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
|
||||
import zero1hd.rhythmbullet.graphics.ui.components.ScrollText;
|
||||
@@ -43,7 +44,7 @@ public class MainPage extends Page implements Observer {
|
||||
super(0, 0);
|
||||
this.mc = musicController;
|
||||
|
||||
dhv = new DoubleHorizontalVisualizer(70, (int) getWidth(), (int) (getHeight()*0.3), 0.3f, mc);
|
||||
dhv = new DoubleHorizontalVisualizer(70, (int) getWidth(), (int) (getHeight()*0.3), 0.3f, mc, new PCMObtainer(mc));
|
||||
dhv.setPosition(0, (int) ((getHeight() - dhv.getHeight())/2f));
|
||||
|
||||
title = new Image(assetManager.get("title.png", Texture.class));
|
||||
|
@@ -1,40 +0,0 @@
|
||||
package zero1hd.rhythmbullet.desktop.screens.main;
|
||||
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Button;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
|
||||
|
||||
public class MusicStatusPage extends Page {
|
||||
Label statusText;
|
||||
Image loading;
|
||||
Button back;
|
||||
|
||||
public MusicStatusPage(Skin skin, final Vector3 v3) {
|
||||
super("Info", skin);
|
||||
|
||||
back = new Button(skin, "arrow-button");
|
||||
back.setPosition(15f, (getHeight()-back.getHeight())/2 -15);
|
||||
back.addListener(new ChangeListener() {
|
||||
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
v3.x = 0.5f*getWidth();
|
||||
}
|
||||
});
|
||||
addActor(back);
|
||||
|
||||
|
||||
loading = new Image(skin, "loading");
|
||||
loading.setPosition((getWidth()-loading.getWidth())/2, (getHeight()-loading.getHeight())/2);
|
||||
loading.setOrigin(loading.getWidth()/2, loading.getHeight()/2);
|
||||
loading.addAction(Actions.forever(Actions.rotateBy(-360f, 2f)));
|
||||
addActor(loading);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user