restructured way of handling the relationship between screens and pages
This commit is contained in:
parent
7dff918802
commit
590cb39902
@ -104,7 +104,7 @@ public class RhythmBullet extends Game {
|
||||
if (skin != null) skin.dispose();
|
||||
skin = new Skin();
|
||||
skinAtlas = assetManager.get("uiskin.atlas", TextureAtlas.class);
|
||||
getSkinSkin().addRegions(skinAtlas);
|
||||
getSkin().addRegions(skinAtlas);
|
||||
|
||||
assetPack.generateFonts(skin);
|
||||
assetPack.setupSkin(skin);
|
||||
@ -181,7 +181,7 @@ public class RhythmBullet extends Game {
|
||||
return assetManager;
|
||||
}
|
||||
|
||||
public Skin getSkinSkin() {
|
||||
public Skin getSkin() {
|
||||
return skin;
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@ public class RhythmBullet extends Game {
|
||||
Gdx.app.debug("Core", "disposing...");
|
||||
try {
|
||||
skinAtlas.dispose();
|
||||
getSkinSkin().dispose();
|
||||
getSkin().dispose();
|
||||
assetManager.dispose();
|
||||
getScreen().dispose();
|
||||
assetPack.dispose();
|
||||
|
160
core/src/zero1hd/rhythmbullet/graphics/shaders/BloomShader.java
Executable file
160
core/src/zero1hd/rhythmbullet/graphics/shaders/BloomShader.java
Executable file
@ -0,0 +1,160 @@
|
||||
package zero1hd.rhythmbullet.graphics.shaders;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer;
|
||||
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
import com.badlogic.gdx.utils.viewport.ScreenViewport;
|
||||
|
||||
public class BloomShader implements Disposable {
|
||||
private int bloomLevel;
|
||||
private ShaderProgram gaussianBlurShader;
|
||||
private ShaderProgram brightFilterShader;
|
||||
private ShaderProgram combineShader;
|
||||
private FrameBuffer lightFilterBuffer;
|
||||
private FrameBuffer normalBuffer;
|
||||
private FrameBuffer hBlur, vBlur;
|
||||
private TextureRegion fboRegion;
|
||||
private Batch screenBatch;
|
||||
private ScreenViewport screenViewport;
|
||||
|
||||
public BloomShader(Batch batch) {
|
||||
this.screenBatch = batch;
|
||||
|
||||
Gdx.app.debug("Shader", "Loading glow shaders.");
|
||||
screenViewport = new ScreenViewport();
|
||||
screenViewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
((OrthographicCamera) screenViewport.getCamera()).setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
|
||||
Gdx.app.debug("Shader", "using glow shader");
|
||||
brightFilterShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/bright_filter.fsh"));
|
||||
if (!brightFilterShader.isCompiled()) {
|
||||
Gdx.app.error("Shader failed to compile", brightFilterShader.getLog());
|
||||
System.exit(0);
|
||||
}
|
||||
if (brightFilterShader.getLog().length() != 0) {
|
||||
Gdx.app.error("Shader", brightFilterShader.getLog());
|
||||
}
|
||||
|
||||
gaussianBlurShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/gaussian_blur.fsh"));
|
||||
if (!gaussianBlurShader.isCompiled()) {
|
||||
Gdx.app.error("Shader failed to compile", gaussianBlurShader.getLog());
|
||||
System.exit(0);
|
||||
}
|
||||
if (gaussianBlurShader.getLog().length() != 0) {
|
||||
Gdx.app.error("Shader", gaussianBlurShader.getLog());
|
||||
}
|
||||
|
||||
combineShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/combine.fsh"));
|
||||
if (!combineShader.isCompiled()) {
|
||||
Gdx.app.error("Shader failed to compile", combineShader.getLog());
|
||||
System.exit(0);
|
||||
}
|
||||
if (combineShader.getLog().length() != 0) {
|
||||
Gdx.app.error("Shader", combineShader.getLog());
|
||||
}
|
||||
|
||||
lightFilterBuffer = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
|
||||
normalBuffer = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
|
||||
hBlur = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
|
||||
vBlur = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
|
||||
|
||||
fboRegion = new TextureRegion(normalBuffer.getColorBufferTexture());
|
||||
fboRegion.flip(false, true);
|
||||
|
||||
combineShader.begin();
|
||||
combineShader.setUniformi("u_texture1", 1);
|
||||
combineShader.end();
|
||||
|
||||
vBlur.getColorBufferTexture().bind(1);
|
||||
|
||||
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
|
||||
ShaderProgram.pedantic = false;
|
||||
}
|
||||
|
||||
public void begin() {
|
||||
// Begin drawing a normal version of screen
|
||||
normalBuffer.begin();
|
||||
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
public void end(float width, float height) {
|
||||
normalBuffer.end();
|
||||
|
||||
// BEGINNING NORMAL SCREEN RENDER
|
||||
screenViewport.apply();
|
||||
|
||||
// Begin light filtering
|
||||
lightFilterBuffer.begin();
|
||||
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
fboRegion.setTexture(normalBuffer.getColorBufferTexture());
|
||||
screenBatch.setShader(brightFilterShader);
|
||||
screenBatch.setProjectionMatrix(screenViewport.getCamera().combined);
|
||||
screenBatch.begin(); //SCREEN BATCH STARTS HERE
|
||||
screenBatch.draw(fboRegion, 0, 0, width, height);
|
||||
screenBatch.flush();
|
||||
lightFilterBuffer.end();
|
||||
|
||||
for (int i = 0; i <= bloomLevel; i++) {
|
||||
// Horizontal gaussian blur
|
||||
hBlur.begin();
|
||||
if (i > 0) {
|
||||
fboRegion.setTexture(vBlur.getColorBufferTexture());
|
||||
} else {
|
||||
fboRegion.setTexture(lightFilterBuffer.getColorBufferTexture());
|
||||
}
|
||||
screenBatch.setShader(gaussianBlurShader);
|
||||
gaussianBlurShader.setUniformi("horizontal", 1);
|
||||
screenBatch.draw(fboRegion, 0f, 0f, width, height);
|
||||
screenBatch.flush();
|
||||
hBlur.end();
|
||||
|
||||
// //Vertical gaussian blur
|
||||
vBlur.begin();
|
||||
fboRegion.setTexture(hBlur.getColorBufferTexture());
|
||||
screenBatch.setShader(gaussianBlurShader);
|
||||
gaussianBlurShader.setUniformi("horizontal", 0);
|
||||
screenBatch.draw(fboRegion, 0f, 0f, width, height);
|
||||
screenBatch.flush();
|
||||
vBlur.end();
|
||||
}
|
||||
|
||||
Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
screenBatch.setShader(combineShader);
|
||||
fboRegion.setTexture(normalBuffer.getColorBufferTexture());
|
||||
screenBatch.draw(fboRegion, 0f, 0f, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
screenBatch.setShader(null);
|
||||
screenBatch.end(); //STAGE BATCH ENDS HERE
|
||||
}
|
||||
|
||||
public void setBloomLevel(int bloomLevel) {
|
||||
this.bloomLevel = bloomLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
brightFilterShader.dispose();
|
||||
combineShader.dispose();
|
||||
gaussianBlurShader.dispose();
|
||||
normalBuffer.dispose();
|
||||
lightFilterBuffer.dispose();
|
||||
vBlur.dispose();
|
||||
hBlur.dispose();
|
||||
|
||||
brightFilterShader = null;
|
||||
combineShader = null;
|
||||
gaussianBlurShader = null;
|
||||
normalBuffer = null;
|
||||
lightFilterBuffer = null;
|
||||
vBlur = null;
|
||||
hBlur = null;
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ public class DoubleHorizontalVisualizer {
|
||||
* @param width the width of the visualizer.
|
||||
* @param spacePercentage the percentage of a bar that should be space.
|
||||
*/
|
||||
public DoubleHorizontalVisualizer(int barCount, int width, float spacePercentage, int height, MusicController musicController) {
|
||||
public DoubleHorizontalVisualizer(int barCount, int width, int height, float spacePercentage, MusicController musicController) {
|
||||
this.barCount = barCount;
|
||||
this.barWidth = width/barCount;
|
||||
this.spaceBetweenBars = (int) (barWidth * spacePercentage);
|
||||
@ -49,10 +49,8 @@ public class DoubleHorizontalVisualizer {
|
||||
amplitudes[bar] = (int) (normalizedAmplitude*multiplier);
|
||||
amplitudes[bar] /= binsPerBar;
|
||||
|
||||
float cappedDelta = Math.max(0, delta);
|
||||
cappedDelta = Math.min(1f, delta);
|
||||
|
||||
barHeights[bar] += Math.max(0, (amplitudes[bar] - barHeights[bar]) * barRate * cappedDelta);
|
||||
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++) {
|
||||
@ -73,6 +71,8 @@ public class DoubleHorizontalVisualizer {
|
||||
|
||||
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);
|
||||
|
@ -1,148 +0,0 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.components;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.utils.FloatArray;
|
||||
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
|
||||
public class AudioGraph extends Actor {
|
||||
private MusicManager audioData;
|
||||
ShapeRenderer shapeRender;
|
||||
FloatArray mainGraph;
|
||||
FloatArray overlayGraph;
|
||||
int dataIndex;
|
||||
int displayMode;
|
||||
public float normalDataG1 = 1f, normalDataG2 = 1f, avgG1 = 1f, avgG2 = 1f;
|
||||
float scale;
|
||||
public AudioGraph(int graphSizeW, int graphSizeH) {
|
||||
shapeRender = new ShapeRenderer();
|
||||
setSize(graphSizeW, graphSizeH);
|
||||
scale = graphSizeH;
|
||||
}
|
||||
|
||||
public void setAudioDataIndex(int audioDataIndex) {
|
||||
this.dataIndex = audioDataIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
batch.end();
|
||||
shapeRender.begin(ShapeType.Line);
|
||||
shapeRender.setColor(0f, 0f, 0f, 0.35f);
|
||||
shapeRender.rect(getX(), getY(), getWidth(), getHeight());
|
||||
if (overlayGraph != null) {
|
||||
if (Gdx.input.isKeyPressed(Keys.COMMA)) {
|
||||
if (scale > 0.05f) {
|
||||
scale -= 0.25f;
|
||||
}
|
||||
} else if (Gdx.input.isKeyPressed(Keys.PERIOD)) {
|
||||
if (scale < getHeight()*2) {
|
||||
scale += 0.4f;
|
||||
}
|
||||
}
|
||||
if (Gdx.input.isKeyJustPressed(Keys.M)) {
|
||||
Gdx.app.debug("Graph", "Switching to another graph.");
|
||||
displayMode++;
|
||||
if (displayMode == 3) {
|
||||
displayMode = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (displayMode) {
|
||||
case 0:
|
||||
shapeRender.setColor(1f, 0f, 0f, 1f);
|
||||
for (int x = 0; x < getWidth(); x++) {
|
||||
try {
|
||||
shapeRender.line(
|
||||
getX()+x,
|
||||
getY(),
|
||||
getX()+x,
|
||||
(int) ((mainGraph.get((int) (dataIndex+x-getWidth()/2))/normalDataG1)*scale)+getY());
|
||||
} catch (NullPointerException | IndexOutOfBoundsException e) {
|
||||
}
|
||||
shapeRender.line(
|
||||
getX(),
|
||||
MathUtils.round(scale*(avgG1/normalDataG1))+getY(),
|
||||
getWidth() + getX(),
|
||||
MathUtils.round(scale*(avgG1/normalDataG1))+getY());
|
||||
}
|
||||
|
||||
case 1:
|
||||
shapeRender.setColor(0f, 0f, 1f, 0.75f);
|
||||
for (int x = 0; x < getWidth(); x++) {
|
||||
try {
|
||||
shapeRender.line(
|
||||
getX()+x,
|
||||
getY(),
|
||||
getX()+x,
|
||||
(int) ((overlayGraph.get((int) (dataIndex+x-getWidth()/2))/normalDataG2)*scale)+getY());
|
||||
} catch (NullPointerException | IndexOutOfBoundsException e) {
|
||||
}
|
||||
shapeRender.line(
|
||||
getX(),
|
||||
MathUtils.round(scale*(avgG2/normalDataG2)) + getY(),
|
||||
getWidth() + getX(),
|
||||
MathUtils.round(scale*(avgG2/normalDataG2))+getY());
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
shapeRender.setColor(1f, 0f, 0f, 0.75f);
|
||||
for (int x = 0; x < getWidth(); x++) {
|
||||
try {
|
||||
shapeRender.line(
|
||||
getX()+x,
|
||||
getY(),
|
||||
getX()+x,
|
||||
(int) ((mainGraph.get((int) (dataIndex+x-getWidth()/2))/normalDataG1)*scale)+getY());
|
||||
} catch (NullPointerException | IndexOutOfBoundsException e) {
|
||||
}
|
||||
shapeRender.line(
|
||||
getX(),
|
||||
MathUtils.round(scale*(avgG1/normalDataG1))+getY(),
|
||||
getWidth() + getX(),
|
||||
MathUtils.round(scale*(avgG1/normalDataG1))+getY());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
shapeRender.setColor(0f, 1f, 0f, 1f);
|
||||
shapeRender.line(getX()+getWidth()/2, 0, getX()+getWidth()/2, getHeight()+getY());
|
||||
shapeRender.end();
|
||||
|
||||
batch.begin();
|
||||
super.draw(batch, parentAlpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
if (audioData != null) {
|
||||
setAudioDataIndex(audioData.getPlaybackIndexPosition());
|
||||
}
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set what arrays to graph
|
||||
* @param dataSet1 first audio data set
|
||||
* @param dataSet2 overlay graph. This one can be null.
|
||||
* @param audioData actual basic audio information for index position
|
||||
*/
|
||||
public void setGraphingData(FloatArray dataSet1, FloatArray dataSet2, MusicManager audioData) {
|
||||
this.mainGraph = dataSet1;
|
||||
this.overlayGraph = dataSet2;
|
||||
if (dataSet2 == null) {
|
||||
displayMode = 2;
|
||||
} else {
|
||||
displayMode = 0;
|
||||
}
|
||||
this.audioData = audioData;
|
||||
}
|
||||
|
||||
}
|
@ -1,148 +0,0 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.components;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.utils.FloatArray;
|
||||
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
|
||||
public class AudioGraphRelation extends Actor {
|
||||
private MusicManager audioData;
|
||||
ShapeRenderer shapeRender;
|
||||
FloatArray mainGraph;
|
||||
FloatArray overlayGraph;
|
||||
int dataIndex;
|
||||
int displayMode;
|
||||
public float normalDataG1 = 1f, normalDataG2 = 1f, avgG1 = 1f, avgG2 = 1f;
|
||||
float scale;
|
||||
public AudioGraphRelation(int graphSizeW, int graphSizeH) {
|
||||
shapeRender = new ShapeRenderer();
|
||||
setSize(graphSizeW, graphSizeH);
|
||||
scale = graphSizeH;
|
||||
}
|
||||
|
||||
public void setAudioDataIndex(int audioDataIndex) {
|
||||
this.dataIndex = audioDataIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
batch.end();
|
||||
shapeRender.begin(ShapeType.Line);
|
||||
shapeRender.setColor(0f, 0f, 0f, 0.35f);
|
||||
shapeRender.rect(getX(), getY(), getWidth(), getHeight());
|
||||
if (overlayGraph != null) {
|
||||
if (Gdx.input.isKeyPressed(Keys.COMMA)) {
|
||||
if (scale > 0.05f) {
|
||||
scale -= 0.25f;
|
||||
}
|
||||
} else if (Gdx.input.isKeyPressed(Keys.PERIOD)) {
|
||||
if (scale < getHeight()*2) {
|
||||
scale += 0.4f;
|
||||
}
|
||||
}
|
||||
if (Gdx.input.isKeyJustPressed(Keys.M)) {
|
||||
Gdx.app.debug("Graph", "Switching to another graph.");
|
||||
displayMode++;
|
||||
if (displayMode == 3) {
|
||||
displayMode = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (displayMode) {
|
||||
case 0:
|
||||
shapeRender.setColor(1f, 0f, 0f, 1f);
|
||||
for (int x = 0; x < getHeight() -1; x++) {
|
||||
try {
|
||||
shapeRender.line(
|
||||
getX()+x,
|
||||
getY(),
|
||||
getX()+x+1,
|
||||
(int) ((mainGraph.get((int) (dataIndex+x +1 -getWidth()/2))/normalDataG1)*scale)+getY());
|
||||
} catch (NullPointerException | IndexOutOfBoundsException e) {
|
||||
}
|
||||
shapeRender.line(
|
||||
getX(),
|
||||
MathUtils.round(scale*(avgG1/normalDataG1))+getY(),
|
||||
getWidth() + getX(),
|
||||
MathUtils.round(scale*(avgG1/normalDataG1))+getY());
|
||||
}
|
||||
|
||||
case 1:
|
||||
shapeRender.setColor(0f, 0f, 1f, 0.75f);
|
||||
for (int x = 0; x < getHeight() -1; x++) {
|
||||
try {
|
||||
shapeRender.line(
|
||||
getX()+x,
|
||||
getY(),
|
||||
getX()+x+1,
|
||||
(int) ((overlayGraph.get((int) (dataIndex+x +1 -getWidth()/2))/normalDataG2)*scale)+getY());
|
||||
} catch (NullPointerException | IndexOutOfBoundsException e) {
|
||||
}
|
||||
shapeRender.line(
|
||||
getX(),
|
||||
MathUtils.round(scale*(avgG2/normalDataG2)) + getY(),
|
||||
getWidth() + getX(),
|
||||
MathUtils.round(scale*(avgG2/normalDataG2))+getY());
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
shapeRender.setColor(1f, 0f, 0f, 0.75f);
|
||||
for (int x = 0; x < getWidth(); x++) {
|
||||
try {
|
||||
shapeRender.line(
|
||||
getX()+x,
|
||||
getY(),
|
||||
getX()+x+1,
|
||||
(int) ((mainGraph.get((int) (dataIndex+x +1 -getWidth()/2))/normalDataG1)*scale)+getY());
|
||||
} catch (NullPointerException | IndexOutOfBoundsException e) {
|
||||
}
|
||||
shapeRender.line(
|
||||
getX(),
|
||||
MathUtils.round(scale*(avgG1/normalDataG1))+getY(),
|
||||
getWidth() + getX(),
|
||||
MathUtils.round(scale*(avgG1/normalDataG1))+getY());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
shapeRender.setColor(0f, 1f, 0f, 1f);
|
||||
shapeRender.line(getX()+getWidth()/2, 0, getX()+getWidth()/2, getHeight()+getY());
|
||||
shapeRender.end();
|
||||
|
||||
batch.begin();
|
||||
super.draw(batch, parentAlpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
if (audioData != null) {
|
||||
setAudioDataIndex(audioData.getPlaybackIndexPosition());
|
||||
}
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set what arrays to graph
|
||||
* @param dataSet1 first audio data set
|
||||
* @param dataSet2 overlay graph. This one can be null.
|
||||
* @param audioData actual basic audio information for index position
|
||||
*/
|
||||
public void setGraphingData(FloatArray dataSet1, FloatArray dataSet2, MusicManager audioData) {
|
||||
this.mainGraph = dataSet1;
|
||||
this.overlayGraph = dataSet2;
|
||||
if (dataSet2 == null) {
|
||||
displayMode = 2;
|
||||
} else {
|
||||
displayMode = 0;
|
||||
}
|
||||
this.audioData = audioData;
|
||||
}
|
||||
|
||||
}
|
@ -11,8 +11,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
|
||||
import zero1hd.rhythmbullet.desktop.screens.MainScreen;
|
||||
|
||||
public class GraphicsOptions extends Table {
|
||||
private Label resolutions, shaders;
|
||||
private Preferences prefs;
|
||||
@ -28,7 +26,7 @@ public class GraphicsOptions extends Table {
|
||||
_1366x768;
|
||||
|
||||
|
||||
public GraphicsOptions(final MainScreen mainMenu, Skin skin, final Preferences prefs) {
|
||||
public GraphicsOptions(Skin skin, final Preferences prefs) {
|
||||
align(Align.center);
|
||||
defaults().space(10f);
|
||||
this.prefs = prefs;
|
||||
@ -37,12 +35,6 @@ public class GraphicsOptions extends Table {
|
||||
row();
|
||||
|
||||
glowShaderLevel = new Slider(0, 4, 1, false, skin);
|
||||
glowShaderLevel.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
mainMenu.setGlowLevel((int) glowShaderLevel.getValue());
|
||||
}
|
||||
});
|
||||
glowShaderLevel.setValue(prefs.getInteger("glow shader"));
|
||||
add(glowShaderLevel).fillX();
|
||||
|
||||
@ -102,4 +94,8 @@ public class GraphicsOptions extends Table {
|
||||
Gdx.app.debug("Preferences", "Saved shading values values.");
|
||||
prefs.putInteger("glow shader", (int) glowShaderLevel.getValue());
|
||||
}
|
||||
|
||||
public Slider getGlowLevelSlider() {
|
||||
return glowShaderLevel;
|
||||
}
|
||||
}
|
||||
|
@ -1,111 +0,0 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.components;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.audio.Music;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Widget;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
|
||||
import zero1hd.rhythmbullet.audio.visualizer.HorizontalVisualizer;
|
||||
import zero1hd.rhythmbullet.desktop.audio.visualizer.PCMMachine;
|
||||
|
||||
public class HorizontalVisualizerWidget extends Widget implements Disposable {
|
||||
private HorizontalVisualizer vis;
|
||||
private boolean updatePositioning = true;
|
||||
private Music music;
|
||||
private boolean initialLoad;
|
||||
private float visRefreshRate;
|
||||
private float timer;
|
||||
public HorizontalVisualizerWidget() {
|
||||
vis = new HorizontalVisualizer(new PCMMachine());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
vis.render(batch, parentAlpha);
|
||||
super.draw(batch, parentAlpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
if (music != null && music.isFinishedLoading() && !initialLoad) {
|
||||
visRefreshRate = music.getReadWindowSize()/music.getSampleRate();
|
||||
Gdx.app.debug("Visualizer", "\nsample count: " + music.getSampleCount()
|
||||
+ "\nDuration in seconds: " + music.getDuration() +
|
||||
"\nSample rate: " + music.getSampleRate() +
|
||||
"\nRefresh rate: " + visRefreshRate);
|
||||
vis.setMusic(music);
|
||||
initialLoad = true;
|
||||
}
|
||||
|
||||
if (updatePositioning) {
|
||||
vis.updatePositionInfo();
|
||||
vis.setX((getWidth() - vis.getActualWidth())/2f);
|
||||
}
|
||||
|
||||
vis.update(delta);
|
||||
updateVisualizerProperties();
|
||||
if (music != null && initialLoad) {
|
||||
if (timer >= visRefreshRate) {
|
||||
timer = 0;
|
||||
vis.calculate();
|
||||
vis.calcPCMData();
|
||||
} else {
|
||||
timer += delta;
|
||||
}
|
||||
}
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
public void setMusic(Music music) {
|
||||
initialLoad = false;
|
||||
this.music = music;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(Color color) {
|
||||
vis.setColor(color);
|
||||
super.setColor(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(float r, float g, float b, float a) {
|
||||
vis.setColor(r, g, b, a);
|
||||
super.setColor(r, g, b, a);
|
||||
}
|
||||
|
||||
public void updateVisualizerProperties() {
|
||||
vis.setHeight(getHeight());
|
||||
vis.setWidth(getWidth());
|
||||
vis.setX(getX());
|
||||
vis.setY(getY());
|
||||
vis.setRotation(getRotation());
|
||||
}
|
||||
|
||||
public void setUpdatePositioning(boolean updatePositioning) {
|
||||
updateVisualPosition();
|
||||
this.updatePositioning = updatePositioning;
|
||||
}
|
||||
|
||||
public void updateVisualPosition() {
|
||||
updateVisualizerProperties();
|
||||
vis.updatePositionInfo();
|
||||
vis.setX(((vis.getWidth() - vis.getActualWidth())/2f));
|
||||
vis.updatePositionInfo();
|
||||
}
|
||||
|
||||
public boolean isUpdatePositioning() {
|
||||
return updatePositioning;
|
||||
}
|
||||
|
||||
public HorizontalVisualizer getVisualizerType() {
|
||||
return vis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
vis.dispose();
|
||||
}
|
||||
|
||||
}
|
@ -10,7 +10,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
|
||||
import zero1hd.rhythmbullet.audio.MusicInfo;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.MusicSelectionPage;
|
||||
import zero1hd.rhythmbullet.desktop.screens.main.MusicSelectionPage;
|
||||
import zero1hd.rhythmbullet.graphics.ui.components.ShortenedTextLabel;
|
||||
|
||||
public class MusicSelectable extends WidgetGroup implements Disposable {
|
||||
|
@ -1,132 +0,0 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.components;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
|
||||
import com.badlogic.gdx.graphics.g2d.ParticleEffectPool;
|
||||
import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
|
||||
import zero1hd.rhythmbullet.audio.visualizer.MirrorVisualizer;
|
||||
|
||||
public class TitleBarVisualizer extends Group implements Disposable {
|
||||
private HorizontalVisualizerWidget visual;
|
||||
private MirrorVisualizer visual2;
|
||||
private Texture bgTexture;
|
||||
private Image bg;
|
||||
private Image titleImage;
|
||||
|
||||
//Particle pools;
|
||||
ParticleEffectPool beatEffectPool;
|
||||
Array<PooledEffect> effects = new Array<>();
|
||||
|
||||
private float particleLimitTime;
|
||||
public TitleBarVisualizer(AssetManager assets) {
|
||||
if (assets == null) throw new NullPointerException("TitleBarVisualizer requires assets manager... ITS NULL YOU FOOL");
|
||||
visual = new HorizontalVisualizerWidget();
|
||||
visual.getVisualizerType().setSpaceBetweenBars(visual.getVisualizerType().getBarWidth()- 2);
|
||||
addActor(visual);
|
||||
|
||||
setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()*0.2f);
|
||||
setPosition(0, (Gdx.graphics.getHeight()-getHeight())/2f);
|
||||
visual.setWidth(getWidth());
|
||||
visual.setHeight(getHeight());
|
||||
visual.getVisualizerType().flip();
|
||||
visual.getVisualizerType().reverse();
|
||||
visual2 = new MirrorVisualizer();
|
||||
visual.setUpdatePositioning(false);
|
||||
visual.getVisualizerType().addMirrorVisualizer(visual2);
|
||||
visual2.setyPos(MathUtils.round(getHeight()));
|
||||
visual.setY(-2);
|
||||
visual.updateVisualPosition();
|
||||
|
||||
Pixmap pixmap = new Pixmap(MathUtils.round(getWidth()), MathUtils.round(getHeight()), Format.RGBA8888);
|
||||
pixmap.setColor(Color.WHITE);
|
||||
pixmap.drawLine(0, 0, pixmap.getWidth(), 0);
|
||||
pixmap.drawLine(0, 1, pixmap.getWidth(), 1);
|
||||
pixmap.drawLine(0, pixmap.getHeight()-1, pixmap.getWidth(), pixmap.getHeight()-1);
|
||||
pixmap.drawLine(0, pixmap.getHeight()-2, pixmap.getWidth(), pixmap.getHeight()-2);
|
||||
bgTexture = new Texture(pixmap);
|
||||
pixmap.dispose();
|
||||
|
||||
bg = new Image(bgTexture);
|
||||
bg.setSize(getWidth(), getHeight());
|
||||
addActor(bg);
|
||||
|
||||
titleImage = new Image(assets.get("title.png", Texture.class));
|
||||
titleImage.setScale((bg.getHeight()-(0.1f*Gdx.graphics.getHeight()))/titleImage.getHeight());
|
||||
|
||||
if (titleImage.getWidth() > 0.8f*getWidth()) {
|
||||
titleImage.setScale((bg.getWidth()-(0.2f*Gdx.graphics.getWidth()))/titleImage.getWidth());
|
||||
}
|
||||
titleImage.setPosition((getWidth() - titleImage.getWidth()*titleImage.getScaleX())/2f, (getHeight() - titleImage.getHeight()*titleImage.getScaleY())/2f -5);
|
||||
titleImage.setColor(Color.WHITE);
|
||||
addActor(titleImage);
|
||||
|
||||
beatEffectPool = new ParticleEffectPool(assets.get("beateffect.p", ParticleEffect.class), 0, 8) {
|
||||
@Override
|
||||
protected PooledEffect newObject() {
|
||||
PooledEffect effect = super.newObject();
|
||||
effect.scaleEffect(Gdx.graphics.getWidth()/64f);
|
||||
return effect;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
if (particleLimitTime > 1f/60f) {
|
||||
if (visual.getVisualizerType().getVisualizer().getMM() != null && visual.getVisualizerType().getVisualizer().getMM().isPlaying() && visual.getVisualizerType().getCurrentAvg() > visual.getVisualizerType().getMaxAvgHeight()*0.55f) {
|
||||
PooledEffect effect = beatEffectPool.obtain();
|
||||
effect.setPosition(0, 0);
|
||||
effects.add(effect);
|
||||
particleLimitTime = 0;
|
||||
}
|
||||
} else {
|
||||
particleLimitTime += delta;
|
||||
}
|
||||
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
for (int i = 0; i < effects.size; i++) {
|
||||
effects.get(i).draw(batch, Gdx.graphics.getDeltaTime());
|
||||
if (effects.get(i).isComplete()) {
|
||||
effects.get(i).free();
|
||||
effects.removeIndex(i);
|
||||
}
|
||||
}
|
||||
super.draw(batch, parentAlpha);
|
||||
}
|
||||
|
||||
public HorizontalVisualizerWidget getHvisual() {
|
||||
return visual;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
visual.dispose();
|
||||
bgTexture.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(Color color) {
|
||||
super.setColor(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(float r, float g, float b, float a) {
|
||||
super.setColor(r, g, b, a);
|
||||
}
|
||||
}
|
@ -1,117 +0,0 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.pages;
|
||||
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
|
||||
import zero1hd.rhythmbullet.RhythmBullet;
|
||||
import zero1hd.rhythmbullet.audio.MusicController;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.components.MusicControls;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.components.TitleBarVisualizer;
|
||||
import zero1hd.rhythmbullet.desktop.screens.MainScreen;
|
||||
import zero1hd.rhythmbullet.graphics.ui.components.ScrollText;
|
||||
|
||||
public class MainPage extends Page implements Observer {
|
||||
private Label versionLabel;
|
||||
|
||||
private MusicController mc;
|
||||
private TitleBarVisualizer titleBar;
|
||||
private Table table;
|
||||
private TextButton playButton;
|
||||
private TextButton optionsButton;
|
||||
private TextButton quitButton;
|
||||
|
||||
private MusicControls musicControls;
|
||||
private MainScreen mMenu;
|
||||
private ScrollText scrollText;
|
||||
|
||||
public MainPage(RhythmBullet core, Vector3 targetPosition, MusicController mlc, MainScreen mainMenu) {
|
||||
this.mc = mlc;
|
||||
this.mMenu = mainMenu;
|
||||
titleBar = new TitleBarVisualizer(core.getAssetManager());
|
||||
addActor(titleBar);
|
||||
|
||||
versionLabel = new Label("Version: " + RhythmBullet.VERSION, core.getSkinSkin(), "sub-font",
|
||||
core.getSkinSkin().getColor("default"));
|
||||
versionLabel.setPosition(3, 3);
|
||||
addActor(versionLabel);
|
||||
|
||||
table = new Table();
|
||||
table.setSize(getWidth(), titleBar.getY());
|
||||
table.align(Align.center);
|
||||
table.defaults().space(10f);
|
||||
addActor(table);
|
||||
playButton = new TextButton("Start!", core.getSkinSkin());
|
||||
playButton.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
targetPosition.x = Gdx.graphics.getWidth()*1.5f;
|
||||
getStage().setKeyboardFocus(mainMenu.getMusicSelectionPage());
|
||||
}
|
||||
});
|
||||
table.add(playButton).width(Gdx.graphics.getWidth()*0.2f);
|
||||
|
||||
table.row();
|
||||
|
||||
optionsButton = new TextButton("Options", core.getSkinSkin(), "sub");
|
||||
optionsButton.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
targetPosition.x = Gdx.graphics.getWidth()*-0.5f;
|
||||
}
|
||||
});
|
||||
table.add(optionsButton).fillX();
|
||||
|
||||
table.row();
|
||||
|
||||
quitButton = new TextButton("Quit", core.getSkinSkin(), "sub");
|
||||
quitButton.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
Gdx.app.exit();
|
||||
}
|
||||
});
|
||||
table.add(quitButton).fillX();
|
||||
|
||||
musicControls = new MusicControls(core.getSkinSkin(), mlc);
|
||||
musicControls.setPosition((getWidth()-musicControls.getMinWidth() - 20f), getHeight()-musicControls.getMinHeight()-20f);
|
||||
addActor(musicControls);
|
||||
|
||||
scrollText = new ScrollText("...", "...", core.getSkinSkin(), false, true);
|
||||
scrollText.setWidth(0.5f*getWidth());
|
||||
scrollText.setPosition(15, getHeight() - scrollText.getHeight()-25f);
|
||||
addActor(scrollText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
super.draw(batch, parentAlpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
titleBar.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Observable o, Object arg) {
|
||||
if (o == mc && arg == MusicController.States.Loaded) {
|
||||
scrollText.setText("Currently playing: " + mc.getCurrentSongName(), null);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,22 +1,29 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.pages;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.Touchable;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.utils.Disposable;
|
||||
import com.badlogic.gdx.utils.viewport.ScreenViewport;
|
||||
|
||||
public class Page extends Group implements Disposable {
|
||||
private Label pageTitle;
|
||||
public Page() {
|
||||
private int baseXPos, baseYPos;
|
||||
|
||||
public Page(int baseXPos, int baseYPos) {
|
||||
this.baseXPos = baseXPos;
|
||||
this.baseYPos = baseYPos;
|
||||
setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
setTouchable(Touchable.childrenOnly);
|
||||
setToBasePosition();
|
||||
}
|
||||
|
||||
public Page(String titleText, Skin skin) {
|
||||
setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
setTouchable(Touchable.childrenOnly);
|
||||
public Page(int baseXPos, int baseYPos, String titleText, Skin skin) {
|
||||
this(baseXPos, baseYPos);
|
||||
pageTitle = new Label(titleText, skin, "large-font", skin.getColor("default"));
|
||||
pageTitle.setPosition(18f, getHeight()-pageTitle.getHeight()-15f);
|
||||
addActor(pageTitle);
|
||||
@ -26,6 +33,23 @@ public class Page extends Group implements Disposable {
|
||||
return pageTitle.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setStage(Stage stage) {
|
||||
if (!(stage.getViewport() instanceof ScreenViewport)) {
|
||||
throw new IllegalArgumentException("Pages are explicitly for GUIs, and thus should have a 1:1 ratio between pixel and texture size for maximum clarity. This means that the stage should be using a ScreenViewport.");
|
||||
}
|
||||
super.setStage(stage);
|
||||
}
|
||||
|
||||
public void setCameraPositionToPage(Vector3 cameraPosition) {
|
||||
cameraPosition.x = (baseXPos+0.5f) * getWidth();
|
||||
cameraPosition.y = (baseYPos+0.5f) * getHeight();
|
||||
}
|
||||
|
||||
public void setToBasePosition() {
|
||||
setPosition(baseXPos*getWidth(), baseYPos*getHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
}
|
||||
|
@ -1,413 +0,0 @@
|
||||
package zero1hd.rhythmbullet.desktop.screens;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.ScreenAdapter;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer;
|
||||
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
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.utils.ClickListener;
|
||||
import com.badlogic.gdx.utils.viewport.ScreenViewport;
|
||||
|
||||
import zero1hd.rhythmbullet.RhythmBullet;
|
||||
import zero1hd.rhythmbullet.audio.MusicMetadataController;
|
||||
import zero1hd.rhythmbullet.audio.MusicList;
|
||||
import zero1hd.rhythmbullet.audio.MusicController;
|
||||
import zero1hd.rhythmbullet.desktop.audio.processor.DesktopAudioProcessorFactory;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.AnalysisPage;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.CreditsPage;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.KeybindOptionsPage;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.MainPage;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.MusicSelectionPage;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.OptionsPage;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.GraphicsOptionsPage;
|
||||
import zero1hd.rhythmbullet.util.ResizeReadyScreen;
|
||||
|
||||
public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
||||
public Stage stage;
|
||||
private Vector3 cameraPosition;
|
||||
|
||||
private MainPage mainPage;
|
||||
private OptionsPage optionsPage;
|
||||
private CreditsPage creditsPage;
|
||||
private KeybindOptionsPage keybindPage;
|
||||
private GraphicsOptionsPage graphicsPage;
|
||||
private MusicSelectionPage musicSelectionPage;
|
||||
private AnalysisPage analysisPage;
|
||||
private RhythmBullet core;
|
||||
|
||||
private MusicController mlc;
|
||||
private MusicMetadataController mmc;
|
||||
|
||||
private float lerpAlpha;
|
||||
|
||||
private ShaderProgram gaussianBlurShader;
|
||||
private ShaderProgram brightFilterShader;
|
||||
private ShaderProgram combineShader;
|
||||
private FrameBuffer lightFilterBuffer;
|
||||
private FrameBuffer normalBuffer;
|
||||
private FrameBuffer hBlur, vBlur;
|
||||
private TextureRegion fboRegion;
|
||||
private int fboSize;
|
||||
private int glowLevel;
|
||||
|
||||
private Texture background;
|
||||
|
||||
private Batch screenBatch;
|
||||
private ScreenViewport screenViewport;
|
||||
|
||||
public MainScreen(RhythmBullet core) {
|
||||
this.core = core;
|
||||
stage = new Stage(new ScreenViewport());
|
||||
cameraPosition = new Vector3(stage.getCamera().position);
|
||||
|
||||
MusicList musicList = new MusicList(new DesktopAudioProcessorFactory());
|
||||
musicList.setSearchPath(core.getPrefs().getString("music dir"));
|
||||
mlc = new MusicController(musicList, core.getPrefs());
|
||||
mlc.setAutoPlay(true);
|
||||
mlc.setShuffle(true);
|
||||
|
||||
mmc = new MusicMetadataController(musicList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(float delta) {
|
||||
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
stage.act(delta);
|
||||
if (glowLevel > 0) {
|
||||
// Begin drawing a normal version of screen
|
||||
normalBuffer.begin();
|
||||
stage.getViewport().apply();
|
||||
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
draw();
|
||||
normalBuffer.end();
|
||||
|
||||
// BEGINNING NORMAL SCREEN RENDER
|
||||
screenViewport.apply();
|
||||
|
||||
// Begin light filtering
|
||||
lightFilterBuffer.begin();
|
||||
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
fboRegion.setTexture(normalBuffer.getColorBufferTexture());
|
||||
screenBatch.setShader(brightFilterShader);
|
||||
screenBatch.setProjectionMatrix(screenViewport.getCamera().combined);
|
||||
screenBatch.begin(); //SCREEN BATCH STARTS HERE
|
||||
screenBatch.draw(fboRegion, 0, 0, stage.getWidth(), stage.getHeight());
|
||||
screenBatch.flush();
|
||||
lightFilterBuffer.end();
|
||||
|
||||
for (int i = 0; i < glowLevel; i++) {
|
||||
// Horizontal gaussian blur
|
||||
hBlur.begin();
|
||||
if (i > 0) {
|
||||
fboRegion.setTexture(vBlur.getColorBufferTexture());
|
||||
} else {
|
||||
fboRegion.setTexture(lightFilterBuffer.getColorBufferTexture());
|
||||
}
|
||||
screenBatch.setShader(gaussianBlurShader);
|
||||
gaussianBlurShader.setUniformi("horizontal", 1);
|
||||
screenBatch.draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight());
|
||||
screenBatch.flush();
|
||||
hBlur.end();
|
||||
|
||||
// //Vertical gaussian blur
|
||||
vBlur.begin();
|
||||
fboRegion.setTexture(hBlur.getColorBufferTexture());
|
||||
screenBatch.setShader(gaussianBlurShader);
|
||||
gaussianBlurShader.setUniformi("horizontal", 0);
|
||||
screenBatch.draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight());
|
||||
screenBatch.flush();
|
||||
vBlur.end();
|
||||
}
|
||||
|
||||
Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
screenBatch.setShader(combineShader);
|
||||
fboRegion.setTexture(normalBuffer.getColorBufferTexture());
|
||||
screenBatch.draw(fboRegion, 0f, 0f, fboSize, fboSize);
|
||||
screenBatch.setShader(null);
|
||||
screenBatch.end(); //STAGE BATCH ENDS HERE
|
||||
|
||||
} else {
|
||||
draw();
|
||||
}
|
||||
|
||||
if (stage.getCamera().position.x != cameraPosition.x || stage.getCamera().position.y != cameraPosition.y) {
|
||||
stage.getCamera().position.lerp(cameraPosition, delta*lerpAlpha);
|
||||
stage.getViewport().apply();
|
||||
}
|
||||
|
||||
super.render(delta);
|
||||
}
|
||||
|
||||
private void draw() {
|
||||
if (background != null) {
|
||||
screenBatch.begin();
|
||||
screenBatch.draw(background, 0, 0, stage.getWidth(), stage.getHeight());
|
||||
screenBatch.end();
|
||||
}
|
||||
stage.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preAssetLoad() {
|
||||
stage.clear();
|
||||
mainPage.dispose();
|
||||
optionsPage.dispose();
|
||||
creditsPage.dispose();
|
||||
keybindPage.dispose();
|
||||
musicSelectionPage.dispose();
|
||||
|
||||
dismantleShaders();
|
||||
setGlowLevel(0);
|
||||
|
||||
background = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postAssetLoad() {
|
||||
mlc.deleteObservers();
|
||||
|
||||
background = core.getAssetManager().get("backgrounds/mainBG.png", Texture.class);
|
||||
screenBatch = new SpriteBatch();
|
||||
|
||||
mainPage = new MainPage(core, cameraPosition, mlc, this);
|
||||
mainPage.setPosition(0, 0);
|
||||
stage.addActor(mainPage);
|
||||
//End main menu
|
||||
|
||||
keybindPage = new KeybindOptionsPage(core.getSkinSkin(), core.getAssetManager(), cameraPosition);
|
||||
keybindPage.setPosition(-1f*Gdx.graphics.getWidth(), -1f*Gdx.graphics.getHeight());
|
||||
stage.addActor(keybindPage);
|
||||
|
||||
graphicsPage = new GraphicsOptionsPage(core.getSkinSkin(), core.getPrefs(), this, core.getAssetManager());
|
||||
|
||||
graphicsPage.setPosition(-1f*Gdx.graphics.getWidth(), 1f*Gdx.graphics.getHeight());
|
||||
stage.addActor(graphicsPage);
|
||||
|
||||
optionsPage = new OptionsPage(core, cameraPosition, keybindPage, mlc);
|
||||
optionsPage.setPosition(-Gdx.graphics.getWidth(), 0);
|
||||
stage.addActor(optionsPage);
|
||||
|
||||
creditsPage = new CreditsPage(core.getSkinSkin());
|
||||
creditsPage.setPosition(0, Gdx.graphics.getHeight());
|
||||
stage.addActor(creditsPage);
|
||||
|
||||
analysisPage = new AnalysisPage(core, cameraPosition);
|
||||
analysisPage.setPosition(2*Gdx.graphics.getWidth(), 0f);
|
||||
stage.addActor(analysisPage);
|
||||
|
||||
musicSelectionPage = new MusicSelectionPage(core.getSkinSkin(), mlc, mmc, core.getAssetManager(), cameraPosition, analysisPage);
|
||||
musicSelectionPage.setPosition(1f*Gdx.graphics.getWidth(), 0f);
|
||||
stage.addActor(musicSelectionPage);
|
||||
stage.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean keyUp(InputEvent event, int keycode) {
|
||||
if (keycode == Keys.ESCAPE) {
|
||||
stage.unfocusAll();
|
||||
keybindPage.unselect();
|
||||
}
|
||||
return super.keyUp(event, keycode);
|
||||
}
|
||||
});
|
||||
|
||||
stage.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
if (stage.hit(x, y, true) == null) {
|
||||
stage.unfocusAll();
|
||||
keybindPage.unselect();
|
||||
}
|
||||
super.clicked(event, x, y);
|
||||
}
|
||||
});
|
||||
|
||||
mlc.addObserver(musicSelectionPage);
|
||||
mlc.addObserver(mainPage);
|
||||
|
||||
mlc.getMusicList().asyncSearch();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
Gdx.input.setInputProcessor(stage);
|
||||
calcLerpAlpha(Gdx.graphics.getWidth());
|
||||
super.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
saveAll();
|
||||
super.hide();
|
||||
}
|
||||
|
||||
public void saveAll() {
|
||||
if (optionsPage != null) {
|
||||
optionsPage.saveOptions(core.getPrefs());
|
||||
core.getPrefs().flush();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(int width, int height) {
|
||||
stage.getViewport().update(width, height, false);
|
||||
cameraPosition.x = width/2;
|
||||
cameraPosition.y = height/2;
|
||||
calcLerpAlpha(width);
|
||||
super.resize(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
stage.dispose();
|
||||
if (gaussianBlurShader != null) {
|
||||
dismantleShaders();
|
||||
}
|
||||
mmc.dispose();
|
||||
screenBatch.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public void setupShaders() {
|
||||
Gdx.app.debug("Shader", "Loading glow shaders.");
|
||||
screenViewport = new ScreenViewport();
|
||||
screenViewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
((OrthographicCamera) screenViewport.getCamera()).setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
|
||||
Gdx.app.debug("Shader", "using glow shader");
|
||||
brightFilterShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/bright_filter.fsh"));
|
||||
if (!brightFilterShader.isCompiled()) {
|
||||
Gdx.app.error("Shader failed to compile", brightFilterShader.getLog());
|
||||
System.exit(0);
|
||||
}
|
||||
if (brightFilterShader.getLog().length() != 0) {
|
||||
Gdx.app.error("Shader", brightFilterShader.getLog());
|
||||
}
|
||||
|
||||
gaussianBlurShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/gaussian_blur.fsh"));
|
||||
if (!gaussianBlurShader.isCompiled()) {
|
||||
Gdx.app.error("Shader failed to compile", gaussianBlurShader.getLog());
|
||||
System.exit(0);
|
||||
}
|
||||
if (gaussianBlurShader.getLog().length() != 0) {
|
||||
Gdx.app.error("Shader", gaussianBlurShader.getLog());
|
||||
}
|
||||
|
||||
combineShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/combine.fsh"));
|
||||
if (!combineShader.isCompiled()) {
|
||||
Gdx.app.error("Shader failed to compile", combineShader.getLog());
|
||||
System.exit(0);
|
||||
}
|
||||
if (combineShader.getLog().length() != 0) {
|
||||
Gdx.app.error("Shader", combineShader.getLog());
|
||||
}
|
||||
|
||||
|
||||
if (Gdx.graphics.getWidth() < 1024) {
|
||||
fboSize = 1024;
|
||||
} else if (Gdx.graphics.getWidth() < 2048) {
|
||||
fboSize = 2048;
|
||||
} else {
|
||||
fboSize = 4096;
|
||||
}
|
||||
|
||||
lightFilterBuffer = new FrameBuffer(Format.RGBA8888, fboSize/2, fboSize/2, false);
|
||||
normalBuffer = new FrameBuffer(Format.RGBA8888, fboSize, fboSize, false);
|
||||
hBlur = new FrameBuffer(Format.RGBA8888, fboSize/2, fboSize/2, false);
|
||||
vBlur = new FrameBuffer(Format.RGBA8888, fboSize/2, fboSize/2, false);
|
||||
|
||||
fboRegion = new TextureRegion(normalBuffer.getColorBufferTexture());
|
||||
fboRegion.flip(false, true);
|
||||
|
||||
combineShader.begin();
|
||||
combineShader.setUniformi("u_texture1", 1);
|
||||
combineShader.end();
|
||||
|
||||
vBlur.getColorBufferTexture().bind(1);
|
||||
|
||||
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
|
||||
ShaderProgram.pedantic = false;
|
||||
}
|
||||
|
||||
public void dismantleShaders() {
|
||||
brightFilterShader.dispose();
|
||||
combineShader.dispose();
|
||||
gaussianBlurShader.dispose();
|
||||
normalBuffer.dispose();
|
||||
lightFilterBuffer.dispose();
|
||||
vBlur.dispose();
|
||||
hBlur.dispose();
|
||||
|
||||
brightFilterShader = null;
|
||||
combineShader = null;
|
||||
gaussianBlurShader = null;
|
||||
normalBuffer = null;
|
||||
lightFilterBuffer = null;
|
||||
vBlur = null;
|
||||
hBlur = null;
|
||||
|
||||
setGlowLevel(0);
|
||||
}
|
||||
|
||||
public void setGlowLevel(int glowLevel) {
|
||||
if (glowLevel > 0) {
|
||||
if (gaussianBlurShader == null) {
|
||||
setupShaders();
|
||||
}
|
||||
} else {
|
||||
if (gaussianBlurShader != null) {
|
||||
dismantleShaders();
|
||||
}
|
||||
}
|
||||
|
||||
this.glowLevel = glowLevel;
|
||||
}
|
||||
|
||||
public Vector3 getCameraPosition() {
|
||||
return cameraPosition;
|
||||
}
|
||||
|
||||
public CreditsPage getCreditsPage() {
|
||||
return creditsPage;
|
||||
}
|
||||
|
||||
public GraphicsOptionsPage getGraphicsPage() {
|
||||
return graphicsPage;
|
||||
}
|
||||
|
||||
public KeybindOptionsPage getKeybindPage() {
|
||||
return keybindPage;
|
||||
}
|
||||
|
||||
public MusicSelectionPage getMusicSelectionPage() {
|
||||
return musicSelectionPage;
|
||||
}
|
||||
|
||||
public OptionsPage getOptionsPage() {
|
||||
return optionsPage;
|
||||
}
|
||||
|
||||
|
||||
private void calcLerpAlpha(int width) {
|
||||
if (width <= 3835) {
|
||||
lerpAlpha = 5.0f;
|
||||
} else {
|
||||
lerpAlpha = 5.5f;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -13,6 +13,7 @@ import com.badlogic.gdx.utils.viewport.ScreenViewport;
|
||||
|
||||
import zero1hd.rhythmbullet.InitialScreen;
|
||||
import zero1hd.rhythmbullet.RhythmBullet;
|
||||
import zero1hd.rhythmbullet.desktop.screens.main.MainScreen;
|
||||
import zero1hd.rhythmbullet.util.ResizeReadyScreen;
|
||||
|
||||
public class SplashScreen extends ScreenAdapter implements ResizeReadyScreen, InitialScreen {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.pages;
|
||||
package zero1hd.rhythmbullet.desktop.screens.main;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
@ -13,9 +13,8 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
|
||||
import zero1hd.rhythmbullet.RhythmBullet;
|
||||
import zero1hd.rhythmbullet.audio.MusicInfo;
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
import zero1hd.rhythmbullet.audio.analyzer.AudioAnalyzer;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
|
||||
import zero1hd.rhythmbullet.desktop.screens.GameScreen;
|
||||
|
||||
public class AnalysisPage extends Page {
|
||||
@ -32,14 +31,15 @@ public class AnalysisPage extends Page {
|
||||
private Image albumArt;
|
||||
private RhythmBullet core;
|
||||
|
||||
public AnalysisPage(RhythmBullet core, Vector3 cameraPosition) {
|
||||
public AnalysisPage(MainScreen mainScreen) {
|
||||
super(2, 0);
|
||||
table = new Table();
|
||||
table.setFillParent(true);
|
||||
table.defaults().space(10f);
|
||||
addActor(table);
|
||||
this.core = core;
|
||||
this.core = mainScreen.rhythmBullet;
|
||||
adjustment = new Table();
|
||||
Skin skin = core.getSkinSkin();
|
||||
Skin skin = core.getSkin();
|
||||
|
||||
difficultyModLabel = new Label("Difficulty Modifier: ", skin, "sub-font", skin.getColor("default"));
|
||||
difficultyModifierSlider = new Slider(1, 3, 0.5f, false, skin);
|
||||
@ -104,7 +104,7 @@ public class AnalysisPage extends Page {
|
||||
backButton.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
cameraPosition.x = 1.5f*Gdx.graphics.getWidth();
|
||||
mainScreen.setDisplayedPage(mainScreen.musicSelectionPage);
|
||||
aa.dispose();
|
||||
}
|
||||
});
|
@ -1,11 +1,15 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.pages;
|
||||
package zero1hd.rhythmbullet.desktop.screens.main;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
|
||||
|
||||
public class CreditsPage extends Page {
|
||||
|
||||
public CreditsPage(Skin skin) {
|
||||
super(0, 1);
|
||||
|
||||
Label title = new Label("Credits", skin, "large-font", skin.getColor("default"));
|
||||
title.setPosition(15, getHeight()-title.getHeight()-15);
|
||||
addActor(title);
|
@ -1,36 +1,35 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.pages;
|
||||
package zero1hd.rhythmbullet.desktop.screens.main;
|
||||
|
||||
import com.badlogic.gdx.Preferences;
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Slider;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.components.GraphicsOptions;
|
||||
import zero1hd.rhythmbullet.desktop.screens.MainScreen;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
|
||||
|
||||
public class GraphicsOptionsPage extends Page {
|
||||
private ScrollPane scrollPane;
|
||||
private GraphicsOptions graphicsTable;
|
||||
private TextButton backButton;
|
||||
|
||||
public GraphicsOptionsPage(Skin skin, Preferences prefs, final MainScreen menu, AssetManager assets) {
|
||||
graphicsTable = new GraphicsOptions(menu, skin, prefs);
|
||||
scrollPane = new ScrollPane(graphicsTable, skin);
|
||||
public GraphicsOptionsPage(MainScreen mainScreen) {
|
||||
super(-1, 1);
|
||||
graphicsTable = new GraphicsOptions(mainScreen.rhythmBullet.getSkin(), mainScreen.rhythmBullet.getPrefs());
|
||||
scrollPane = new ScrollPane(graphicsTable, mainScreen.rhythmBullet.getSkin());
|
||||
scrollPane.setFadeScrollBars(false);
|
||||
scrollPane.setFillParent(true);
|
||||
addActor(scrollPane);
|
||||
|
||||
backButton = new TextButton("Back", skin);
|
||||
backButton = new TextButton("Back", mainScreen.rhythmBullet.getSkin());
|
||||
backButton.setPosition(10, getHeight() - 10 - backButton.getHeight());
|
||||
backButton.setWidth(backButton.getWidth() + 20);
|
||||
backButton.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
menu.getCameraPosition().y = 0.5f*getHeight();
|
||||
mainScreen.setDisplayedPage(mainScreen.optionsPage);
|
||||
}
|
||||
});
|
||||
|
||||
@ -50,4 +49,8 @@ public class GraphicsOptionsPage extends Page {
|
||||
public void save() {
|
||||
graphicsTable.save();
|
||||
}
|
||||
|
||||
public Slider getGlowLevelSlider() {
|
||||
return graphicsTable.getGlowLevelSlider();
|
||||
}
|
||||
}
|
@ -1,33 +1,32 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.pages;
|
||||
package zero1hd.rhythmbullet.desktop.screens.main;
|
||||
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
|
||||
import zero1hd.rhythmbullet.controls.KeyMap;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.components.ControlOptions;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
|
||||
|
||||
public class KeybindOptionsPage extends Page {
|
||||
private ControlOptions controlTable;
|
||||
private KeyMap keyMap;
|
||||
private TextButton backButton;
|
||||
public KeybindOptionsPage(Skin skin, AssetManager assets, final Vector3 cameraPosition) {
|
||||
keyMap = new KeyMap(assets);
|
||||
controlTable = new ControlOptions(skin, keyMap);
|
||||
public KeybindOptionsPage(MainScreen mainScreen) {
|
||||
super(-1, -1);
|
||||
keyMap = new KeyMap(mainScreen.rhythmBullet.getAssetManager());
|
||||
controlTable = new ControlOptions(mainScreen.rhythmBullet.getSkin(), keyMap);
|
||||
|
||||
addActor(controlTable);
|
||||
|
||||
backButton = new TextButton("Back", skin);
|
||||
backButton = new TextButton("Back", mainScreen.rhythmBullet.getSkin());
|
||||
backButton.setPosition(10, getHeight() - 10 - backButton.getHeight());
|
||||
backButton.setWidth(backButton.getWidth() + 20);
|
||||
backButton.addListener(new ChangeListener() {
|
||||
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
cameraPosition.y = 0.5f*getHeight();
|
||||
mainScreen.setDisplayedPage(mainScreen.optionsPage);
|
||||
}
|
||||
});
|
||||
|
129
desktop/src/zero1hd/rhythmbullet/desktop/screens/main/MainPage.java
Executable file
129
desktop/src/zero1hd/rhythmbullet/desktop/screens/main/MainPage.java
Executable file
@ -0,0 +1,129 @@
|
||||
package zero1hd.rhythmbullet.desktop.screens.main;
|
||||
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
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.desktop.graphics.ui.components.MusicControls;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
|
||||
import zero1hd.rhythmbullet.graphics.ui.components.ScrollText;
|
||||
|
||||
public class MainPage extends Page implements Observer {
|
||||
private MusicController mc;
|
||||
|
||||
private Label versionLabel;
|
||||
private Image title;
|
||||
|
||||
private Table menuTable;
|
||||
private TextButton playButton;
|
||||
private TextButton optionsButton;
|
||||
private TextButton quitButton;
|
||||
|
||||
private MusicControls musicControls;
|
||||
private ScrollText scrollText;
|
||||
|
||||
private DoubleHorizontalVisualizer dhv;
|
||||
|
||||
private RhythmBullet rhythmBullet;
|
||||
public MainPage(MainScreen mainScreen) {
|
||||
super(0, 0);
|
||||
this.mc = mainScreen.musicController;
|
||||
this.rhythmBullet = mainScreen.rhythmBullet;
|
||||
|
||||
dhv = new DoubleHorizontalVisualizer(70, (int) getWidth(), (int) (getHeight()*0.3), 0.3f, mc);
|
||||
dhv.setPosition(0, (int) ((getHeight() - dhv.getHeight())/2f));
|
||||
|
||||
title = new Image(rhythmBullet.getAssetManager().get("title.png", Texture.class));
|
||||
title.setScale(dhv.getHeight()/title.getHeight());
|
||||
title.setPosition((getWidth()-title.getWidth())/2f, (getHeight()-title.getHeight())/2f);
|
||||
addActor(title);
|
||||
|
||||
versionLabel = new Label("Version: " + RhythmBullet.VERSION, rhythmBullet.getSkin(), "sub-font",
|
||||
rhythmBullet.getSkin().getColor("default"));
|
||||
versionLabel.setPosition(3, 3);
|
||||
addActor(versionLabel);
|
||||
|
||||
menuTable = new Table();
|
||||
menuTable.setSize(getWidth(), dhv.getY());
|
||||
menuTable.align(Align.center);
|
||||
menuTable.defaults().space(10f);
|
||||
addActor(menuTable);
|
||||
playButton = new TextButton("Start!", rhythmBullet.getSkin());
|
||||
playButton.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
mainScreen.setDisplayedPage(mainScreen.musicSelectionPage);
|
||||
getStage().setKeyboardFocus(mainScreen.musicSelectionPage);
|
||||
}
|
||||
});
|
||||
menuTable.add(playButton).width(Gdx.graphics.getWidth()*0.2f);
|
||||
|
||||
menuTable.row();
|
||||
|
||||
optionsButton = new TextButton("Options", rhythmBullet.getSkin(), "sub");
|
||||
optionsButton.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
mainScreen.setDisplayedPage(mainScreen.optionsPage);
|
||||
}
|
||||
});
|
||||
menuTable.add(optionsButton).fillX();
|
||||
|
||||
menuTable.row();
|
||||
|
||||
quitButton = new TextButton("Quit", rhythmBullet.getSkin(), "sub");
|
||||
quitButton.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
Gdx.app.exit();
|
||||
}
|
||||
});
|
||||
menuTable.add(quitButton).fillX();
|
||||
|
||||
musicControls = new MusicControls(rhythmBullet.getSkin(), mc);
|
||||
musicControls.setPosition((getWidth()-musicControls.getMinWidth() - 20f), getHeight()-musicControls.getMinHeight()-20f);
|
||||
addActor(musicControls);
|
||||
|
||||
scrollText = new ScrollText("...", "...", rhythmBullet.getSkin(), false, true);
|
||||
scrollText.setWidth(0.5f*getWidth());
|
||||
scrollText.setPosition(15, getHeight() - scrollText.getHeight()-25f);
|
||||
addActor(scrollText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
dhv.act(delta);
|
||||
super.act(delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
dhv.draw(batch, parentAlpha);
|
||||
super.draw(batch, parentAlpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Observable o, Object arg) {
|
||||
if (o == mc && arg == MusicController.States.Loaded) {
|
||||
scrollText.setText("Currently playing: " + mc.getCurrentSongName(), null);
|
||||
}
|
||||
}
|
||||
}
|
236
desktop/src/zero1hd/rhythmbullet/desktop/screens/main/MainScreen.java
Executable file
236
desktop/src/zero1hd/rhythmbullet/desktop/screens/main/MainScreen.java
Executable file
@ -0,0 +1,236 @@
|
||||
package zero1hd.rhythmbullet.desktop.screens.main;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.ScreenAdapter;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
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.utils.ChangeListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
|
||||
import com.badlogic.gdx.utils.viewport.ScreenViewport;
|
||||
|
||||
import zero1hd.rhythmbullet.RhythmBullet;
|
||||
import zero1hd.rhythmbullet.audio.MusicMetadataController;
|
||||
import zero1hd.rhythmbullet.audio.MusicList;
|
||||
import zero1hd.rhythmbullet.audio.MusicController;
|
||||
import zero1hd.rhythmbullet.desktop.audio.processor.DesktopAudioProcessorFactory;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
|
||||
import zero1hd.rhythmbullet.graphics.shaders.BloomShader;
|
||||
import zero1hd.rhythmbullet.util.ResizeReadyScreen;
|
||||
|
||||
public class MainScreen extends ScreenAdapter implements ResizeReadyScreen {
|
||||
private Stage stage;
|
||||
private Vector3 cameraPosition;
|
||||
|
||||
protected MainPage mainPage;
|
||||
protected OptionsPage optionsPage;
|
||||
protected CreditsPage creditsPage;
|
||||
protected KeybindOptionsPage keybindPage;
|
||||
protected GraphicsOptionsPage graphicsPage;
|
||||
protected MusicSelectionPage musicSelectionPage;
|
||||
protected AnalysisPage analysisPage;
|
||||
|
||||
protected MusicController musicController;
|
||||
protected MusicMetadataController musicMetadataController;
|
||||
|
||||
protected RhythmBullet rhythmBullet;
|
||||
|
||||
private BloomShader bloomShader;
|
||||
|
||||
private float lerpAlpha;
|
||||
|
||||
private Texture background;
|
||||
|
||||
private Batch screenBatch;
|
||||
|
||||
public MainScreen(RhythmBullet core) {
|
||||
this.rhythmBullet = core;
|
||||
stage = new Stage(new ScreenViewport());
|
||||
cameraPosition = new Vector3(stage.getCamera().position);
|
||||
|
||||
MusicList musicList = new MusicList(new DesktopAudioProcessorFactory());
|
||||
musicList.setSearchPath(core.getPrefs().getString("music dir"));
|
||||
musicController = new MusicController(musicList, core.getPrefs());
|
||||
musicController.setAutoPlay(true);
|
||||
musicController.setShuffle(true);
|
||||
|
||||
musicMetadataController = new MusicMetadataController(musicList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(float delta) {
|
||||
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
stage.act(delta);
|
||||
if (bloomShader != null) {
|
||||
bloomShader.begin();
|
||||
draw();
|
||||
bloomShader.end(stage.getWidth(), stage.getHeight());
|
||||
} else {
|
||||
draw();
|
||||
}
|
||||
|
||||
if (stage.getCamera().position.x != cameraPosition.x || stage.getCamera().position.y != cameraPosition.y) {
|
||||
stage.getCamera().position.lerp(cameraPosition, delta*lerpAlpha);
|
||||
stage.getViewport().apply();
|
||||
}
|
||||
|
||||
super.render(delta);
|
||||
}
|
||||
|
||||
private void draw() {
|
||||
stage.getViewport().apply();
|
||||
screenBatch.begin();
|
||||
screenBatch.draw(background, 0, 0, stage.getWidth(), stage.getHeight());
|
||||
screenBatch.end();
|
||||
stage.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preAssetLoad() {
|
||||
stage.clear();
|
||||
mainPage.dispose();
|
||||
optionsPage.dispose();
|
||||
creditsPage.dispose();
|
||||
keybindPage.dispose();
|
||||
musicSelectionPage.dispose();
|
||||
bloomShader.dispose();
|
||||
bloomShader = null;
|
||||
background = null;
|
||||
screenBatch.dispose();
|
||||
musicController.deleteObservers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postAssetLoad() {
|
||||
|
||||
background = rhythmBullet.getAssetManager().get("backgrounds/mainBG.png", Texture.class);
|
||||
screenBatch = new SpriteBatch();
|
||||
|
||||
mainPage = new MainPage(this);
|
||||
stage.addActor(mainPage);
|
||||
//End main menu
|
||||
|
||||
optionsPage = new OptionsPage(this);
|
||||
stage.addActor(optionsPage);
|
||||
|
||||
analysisPage = new AnalysisPage(this);
|
||||
stage.addActor(analysisPage);
|
||||
|
||||
musicSelectionPage = new MusicSelectionPage(this);
|
||||
stage.addActor(musicSelectionPage);
|
||||
|
||||
|
||||
keybindPage = new KeybindOptionsPage(this);
|
||||
stage.addActor(keybindPage);
|
||||
|
||||
graphicsPage = new GraphicsOptionsPage(this);
|
||||
if (graphicsPage.getGlowLevelSlider().getValue() > 0) {
|
||||
if (bloomShader == null) bloomShader = new BloomShader(screenBatch);
|
||||
bloomShader.setBloomLevel((int) graphicsPage.getGlowLevelSlider().getValue());
|
||||
}
|
||||
graphicsPage.getGlowLevelSlider().addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
if (graphicsPage.getGlowLevelSlider().getValue() > 0) {
|
||||
if (bloomShader == null) bloomShader = new BloomShader(screenBatch);
|
||||
bloomShader.setBloomLevel((int) graphicsPage.getGlowLevelSlider().getValue());
|
||||
} else if (bloomShader != null) {
|
||||
bloomShader.dispose();
|
||||
bloomShader = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
stage.addActor(graphicsPage);
|
||||
|
||||
|
||||
creditsPage = new CreditsPage(rhythmBullet.getSkin());
|
||||
creditsPage.setPosition(0, Gdx.graphics.getHeight());
|
||||
stage.addActor(creditsPage);
|
||||
|
||||
stage.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean keyUp(InputEvent event, int keycode) {
|
||||
if (keycode == Keys.ESCAPE) {
|
||||
stage.unfocusAll();
|
||||
keybindPage.unselect();
|
||||
}
|
||||
return super.keyUp(event, keycode);
|
||||
}
|
||||
});
|
||||
|
||||
stage.addListener(new ClickListener() {
|
||||
@Override
|
||||
public void clicked(InputEvent event, float x, float y) {
|
||||
if (stage.hit(x, y, true) == null) {
|
||||
stage.unfocusAll();
|
||||
keybindPage.unselect();
|
||||
}
|
||||
super.clicked(event, x, y);
|
||||
}
|
||||
});
|
||||
|
||||
musicController.addObserver(musicSelectionPage);
|
||||
musicController.addObserver(mainPage);
|
||||
|
||||
musicController.getMusicList().asyncSearch();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
Gdx.input.setInputProcessor(stage);
|
||||
calcLerpAlpha(Gdx.graphics.getWidth());
|
||||
super.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
saveAll();
|
||||
super.hide();
|
||||
}
|
||||
|
||||
public void saveAll() {
|
||||
if (optionsPage != null) {
|
||||
optionsPage.saveOptions(rhythmBullet.getPrefs());
|
||||
rhythmBullet.getPrefs().flush();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(int width, int height) {
|
||||
stage.getViewport().update(width, height, false);
|
||||
cameraPosition.x = width/2;
|
||||
cameraPosition.y = height/2;
|
||||
calcLerpAlpha(width);
|
||||
super.resize(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
stage.dispose();
|
||||
musicMetadataController.dispose();
|
||||
screenBatch.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
private void calcLerpAlpha(int width) {
|
||||
if (width <= 3835) {
|
||||
lerpAlpha = 5.0f;
|
||||
} else {
|
||||
lerpAlpha = 5.5f;
|
||||
}
|
||||
}
|
||||
|
||||
public void setDisplayedPage(Page page) {
|
||||
page.setCameraPositionToPage(cameraPosition);
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.pages;
|
||||
package zero1hd.rhythmbullet.desktop.screens.main;
|
||||
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
@ -25,18 +25,17 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
|
||||
import zero1hd.rhythmbullet.audio.MusicInfo;
|
||||
import zero1hd.rhythmbullet.audio.MusicMetadataController;
|
||||
import zero1hd.rhythmbullet.audio.MusicController;
|
||||
import zero1hd.rhythmbullet.audio.MusicManager;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.components.MusicSelectable;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
|
||||
import zero1hd.rhythmbullet.graphics.ui.components.ScrollText;
|
||||
|
||||
public class MusicSelectionPage extends Page implements Observer {
|
||||
Preferences musicFileAnnotation;
|
||||
|
||||
private MusicController mc;
|
||||
private MusicMetadataController mic;
|
||||
private MusicMetadataController mmc;
|
||||
private Array<MusicSelectable> selectables;
|
||||
private Table musicTable;
|
||||
private ScrollPane musicTableScrollPane;
|
||||
@ -65,11 +64,12 @@ public class MusicSelectionPage extends Page implements Observer {
|
||||
private int uiSongInfoCount;
|
||||
private float scrollTimer, scrollDelay = 0.2f, scrollDelMod, songSelectionTimer;
|
||||
|
||||
public MusicSelectionPage(Skin skin, MusicController musicListController, MusicMetadataController musicInfoController, AssetManager assetManager, final Vector3 cameraTarget, final AnalysisPage ap) {
|
||||
this.assets = assetManager;
|
||||
this.skin = skin;
|
||||
this.mc = musicListController;
|
||||
this.mic = musicInfoController;
|
||||
public MusicSelectionPage(MainScreen mainScreen) {
|
||||
super(1, 0);
|
||||
this.assets = mainScreen.rhythmBullet.getAssetManager();
|
||||
this.skin = mainScreen.rhythmBullet.getSkin();
|
||||
this.mc = mainScreen.musicController;
|
||||
this.mmc = mainScreen.musicMetadataController;
|
||||
musicFileAnnotation = Gdx.app.getPreferences("music_file_annotation");
|
||||
musicTable = new Table();
|
||||
musicTableScrollPane = new ScrollPane(musicTable, skin);
|
||||
@ -86,7 +86,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
||||
back.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
cameraTarget.x = 0.5f*Gdx.graphics.getWidth();
|
||||
mainScreen.setDisplayedPage(mainScreen.mainPage);
|
||||
}
|
||||
});
|
||||
addActor(back);
|
||||
@ -131,15 +131,15 @@ public class MusicSelectionPage extends Page implements Observer {
|
||||
songLength = new Label(null, skin, "sub-font", skin.getColor("default"));
|
||||
previousTop = new Label(null, skin, "sub-font", skin.getColor("default"));
|
||||
ratedDifficulty = new Label(null, skin, "sub-font", skin.getColor("default"));
|
||||
albumCover = new Image(assetManager.get("defaultCover.png", Texture.class));
|
||||
albumCover = new Image(assets.get("defaultCover.png", Texture.class));
|
||||
|
||||
beginButton = new TextButton("Begin", skin);
|
||||
beginButton.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
if (getSelectedMusic() != null) {
|
||||
cameraTarget.x = 2.5f*getWidth();
|
||||
ap.processSong(mc.getMusicList().newAudioProcessor(getSelectedMusic()), (albumCoverTexture != null ? albumCoverTexture : assets.get("defaultCover.png", Texture.class)), mic.getInfo(getSelectedMusic()));
|
||||
mainScreen.setDisplayedPage(mainScreen.analysisPage);
|
||||
ap.processSong(mc.getMusicList().newAudioProcessor(getSelectedMusic()), (albumCoverTexture != null ? albumCoverTexture : assets.get("defaultCover.png", Texture.class)), mmc.getInfo(getSelectedMusic()));
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -194,8 +194,8 @@ public class MusicSelectionPage extends Page implements Observer {
|
||||
if (uiSongCount == mc.getMusicList().getTotal()) {
|
||||
selectMusicUI(mc.getCurrentMusicManager());
|
||||
}
|
||||
} else if (uiSongInfoCount < selectables.size && mic.isDone()) {
|
||||
selectables.get(uiSongInfoCount).updateInfo(mic.getMetadataArray().get(uiSongInfoCount));
|
||||
} else if (uiSongInfoCount < selectables.size && mmc.isDone()) {
|
||||
selectables.get(uiSongInfoCount).updateInfo(mmc.getMetadataArray().get(uiSongInfoCount));
|
||||
uiSongInfoCount++;
|
||||
if (uiSongInfoCount == selectables.size) {
|
||||
updateInformation();
|
||||
@ -220,7 +220,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
||||
for (int i = 0; i < selectables.size; i++) {
|
||||
selectables.get(i).dispose();
|
||||
}
|
||||
mic.loadSongInfo();
|
||||
mmc.loadSongInfo();
|
||||
musicTable.clear();
|
||||
selectables.clear();
|
||||
musicInfoTable.clear();
|
||||
@ -268,7 +268,7 @@ public class MusicSelectionPage extends Page implements Observer {
|
||||
this.currentlySelected = currentlySelected;
|
||||
songSelectionTimer = 1f;
|
||||
|
||||
if (mic.isDone() && uiSongInfoCount == selectables.size) {
|
||||
if (mmc.isDone() && uiSongInfoCount == selectables.size) {
|
||||
updateInformation();
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.pages;
|
||||
package zero1hd.rhythmbullet.desktop.screens.main;
|
||||
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
@ -9,6 +9,8 @@ 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;
|
@ -1,9 +1,8 @@
|
||||
package zero1hd.rhythmbullet.desktop.graphics.ui.pages;
|
||||
package zero1hd.rhythmbullet.desktop.screens.main;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Preferences;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
import com.badlogic.gdx.math.Vector3;
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ProgressBar;
|
||||
@ -13,8 +12,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
|
||||
import zero1hd.rhythmbullet.RhythmBullet;
|
||||
import zero1hd.rhythmbullet.audio.MusicController;
|
||||
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.Page;
|
||||
|
||||
public class OptionsPage extends Page {
|
||||
Table optionsTable;
|
||||
@ -23,15 +21,15 @@ public class OptionsPage extends Page {
|
||||
private TextField directoryField;
|
||||
private float musicSearchTimer;
|
||||
|
||||
public OptionsPage(final RhythmBullet core, final Vector3 targetPosition, KeybindOptionsPage moreOptionsPage, MusicController mlc) {
|
||||
super("General", core.getSkinSkin());
|
||||
public OptionsPage(MainScreen mainScreen) {
|
||||
super(-1, 0, "General", mainScreen.rhythmBullet.getSkin());
|
||||
|
||||
//Back button
|
||||
TextButton backButton = new TextButton("Back", core.getSkinSkin());
|
||||
TextButton backButton = new TextButton("Back", mainScreen.rhythmBullet.getSkin());
|
||||
backButton.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
targetPosition.x = 0.5f*Gdx.graphics.getWidth();
|
||||
mainScreen.setDisplayedPage(mainScreen.mainPage);
|
||||
}
|
||||
});
|
||||
backButton.setWidth(backButton.getWidth() + 20);
|
||||
@ -43,36 +41,36 @@ public class OptionsPage extends Page {
|
||||
optionsTable.setSize(getWidth(), getHeight());
|
||||
addActor(optionsTable);
|
||||
|
||||
Label musicVolSliderLabel = new Label("Music Volume: ", core.getSkinSkin());
|
||||
Label musicVolSliderLabel = new Label("Music Volume: ", mainScreen.rhythmBullet.getSkin());
|
||||
optionsTable.add(musicVolSliderLabel);
|
||||
musicVolSlider = new Slider(0, 100, 0.1f, false, core.getSkinSkin());
|
||||
musicVolSlider.setValue(core.getPrefs().getFloat("music vol", 100f)*100f);
|
||||
musicVolSlider = new Slider(0, 100, 0.1f, false, mainScreen.rhythmBullet.getSkin());
|
||||
musicVolSlider.setValue(mainScreen.rhythmBullet.getPrefs().getFloat("music vol", 100f)*100f);
|
||||
optionsTable.add(musicVolSlider).minWidth(0.3f*getWidth());
|
||||
final Label musicVolPercentage = new Label(MathUtils.round(musicVolSlider.getValue()) + "%", core.getSkinSkin());
|
||||
final Label musicVolPercentage = new Label(MathUtils.round(musicVolSlider.getValue()) + "%", mainScreen.rhythmBullet.getSkin());
|
||||
musicVolSlider.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
musicVolPercentage.setText(MathUtils.round(musicVolSlider.getValue()) + "%");
|
||||
mlc.getCurrentMusicManager().setVolume(musicVolSlider.getPercent());
|
||||
mainScreen.musicController.getCurrentMusic().setVolume(musicVolSlider.getPercent());
|
||||
|
||||
core.getPrefs().putFloat("music vol", musicVolSlider.getPercent());
|
||||
mainScreen.rhythmBullet.getPrefs().putFloat("music vol", musicVolSlider.getPercent());
|
||||
}
|
||||
});
|
||||
optionsTable.add(musicVolPercentage);
|
||||
|
||||
optionsTable.row();
|
||||
|
||||
Label fxVolSliderLabel = new Label("FX Volume: ", core.getSkinSkin());
|
||||
Label fxVolSliderLabel = new Label("FX Volume: ", mainScreen.rhythmBullet.getSkin());
|
||||
optionsTable.add(fxVolSliderLabel);
|
||||
fxVolSlider = new Slider(0, 100, 0.1f, false, core.getSkinSkin());
|
||||
fxVolSlider.setValue(core.getPrefs().getFloat("fx vol", 100f)*100f);
|
||||
fxVolSlider = new Slider(0, 100, 0.1f, false, mainScreen.rhythmBullet.getSkin());
|
||||
fxVolSlider.setValue(mainScreen.rhythmBullet.getPrefs().getFloat("fx vol", 100f)*100f);
|
||||
optionsTable.add(fxVolSlider).fillX();
|
||||
final Label fxVolPercentage = new Label(MathUtils.round(fxVolSlider.getValue()) + "%", core.getSkinSkin());
|
||||
final Label fxVolPercentage = new Label(MathUtils.round(fxVolSlider.getValue()) + "%", mainScreen.rhythmBullet.getSkin());
|
||||
fxVolSlider.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
fxVolPercentage.setText(MathUtils.round(fxVolSlider.getValue()) + "%");
|
||||
core.getPrefs().putFloat("fx vol", fxVolSlider.getPercent());
|
||||
mainScreen.rhythmBullet.getPrefs().putFloat("fx vol", fxVolSlider.getPercent());
|
||||
}
|
||||
});
|
||||
|
||||
@ -80,22 +78,22 @@ public class OptionsPage extends Page {
|
||||
|
||||
optionsTable.row();
|
||||
|
||||
Label musicDirectoryLabel = new Label("Music Directory: ", core.getSkinSkin());
|
||||
Label musicDirectoryLabel = new Label("Music Directory: ", mainScreen.rhythmBullet.getSkin());
|
||||
optionsTable.add(musicDirectoryLabel);
|
||||
directoryField = new TextField(null, core.getSkinSkin() ) {
|
||||
directoryField = new TextField(null, mainScreen.rhythmBullet.getSkin() ) {
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
if (musicSearchTimer > 0) {
|
||||
musicSearchTimer -= delta;
|
||||
if (musicSearchTimer <= 0) {
|
||||
mlc.getMusicList().setSearchPath(directoryField.getText());
|
||||
mlc.getMusicList().asyncSearch();
|
||||
mainScreen.musicController.getMusicList().setSearchPath(directoryField.getText());
|
||||
mainScreen.musicController.getMusicList().asyncSearch();
|
||||
}
|
||||
}
|
||||
super.act(delta);
|
||||
}
|
||||
};
|
||||
directoryField.setText(core.getPrefs().getString("music dir", System.getProperty("user.home")+System.getProperty("file.separator")+"Music"));
|
||||
directoryField.setText(mainScreen.rhythmBullet.getPrefs().getString("music dir", System.getProperty("user.home")+System.getProperty("file.separator")+"Music"));
|
||||
directoryField.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
@ -106,32 +104,32 @@ public class OptionsPage extends Page {
|
||||
|
||||
optionsTable.row();
|
||||
|
||||
TextButton keybindSettings = new TextButton("Set Controls", core.getSkinSkin());
|
||||
TextButton keybindSettings = new TextButton("Set Controls", mainScreen.rhythmBullet.getSkin());
|
||||
keybindSettings.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
targetPosition.y = -0.5f*Gdx.graphics.getHeight();
|
||||
mainScreen.setDisplayedPage(mainScreen.keybindPage);
|
||||
}
|
||||
});
|
||||
optionsTable.add(keybindSettings).colspan(2).fillX();
|
||||
|
||||
optionsTable.row();
|
||||
|
||||
TextButton graphicsSettings = new TextButton("Graphics", core.getSkinSkin());
|
||||
TextButton graphicsSettings = new TextButton("Graphics", mainScreen.rhythmBullet.getSkin());
|
||||
graphicsSettings.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
targetPosition.y = 1.5f*Gdx.graphics.getHeight();
|
||||
mainScreen.setDisplayedPage(mainScreen.graphicsPage);
|
||||
}
|
||||
});
|
||||
optionsTable.add(graphicsSettings).colspan(2).fillX();
|
||||
|
||||
optionsTable.row();
|
||||
|
||||
Label fpsLabel = new Label("", core.getSkinSkin()) {
|
||||
Label fpsLabel = new Label("", mainScreen.rhythmBullet.getSkin()) {
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
setText("Current Frames Per Second: " + Gdx.graphics.getFramesPerSecond());
|
||||
setText("Current FPS: " + Gdx.graphics.getFramesPerSecond());
|
||||
super.act(delta);
|
||||
}
|
||||
};
|
||||
@ -139,7 +137,7 @@ public class OptionsPage extends Page {
|
||||
|
||||
optionsTable.row();
|
||||
|
||||
Label usageLabel = new Label("Current usage (lower the better): " + 100f*((float)(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/(float)Runtime.getRuntime().totalMemory()) + "%", core.getSkinSkin()) {
|
||||
Label usageLabel = new Label("Current usage (lower the better): " + 100f*((float)(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/(float)Runtime.getRuntime().totalMemory()) + "%", mainScreen.rhythmBullet.getSkin()) {
|
||||
float refreshTime = 60;
|
||||
@Override
|
||||
public void act(float delta) {
|
Loading…
Reference in New Issue
Block a user