fixed visualizer width, changed scroll bar skin, changed functioning of shader options

This commit is contained in:
Harrison Deng 2017-10-13 19:09:17 -05:00
parent 36e121fef0
commit 31ad6f4a10
10 changed files with 82 additions and 22 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -68,7 +68,6 @@ public class BasicVisualizer extends VisualizerCore {
}
public void modify(float delta) {
//Averaging bins together
for (int i = 0; i < barCount; i++) {
float barHeight = 0;
@ -128,18 +127,18 @@ public class BasicVisualizer extends VisualizerCore {
int barSpace = 0;
angleRot.set(MathUtils.cosDeg(rotation), MathUtils.sinDeg(rotation));
barWidth = MathUtils.ceil((float) width/(float) barCount);
barWidth = MathUtils.round((float) width/(float) barCount);
barWidth -= spaceBetweenBars;
for (int i = 0; i < bars.length; i++) {
barSpace = i*(barWidth+spaceBetweenBars);
if (i == bars.length - 1) {
barSpace -= 2;
}
if (flip) {
bars[i].setRotation(rotation+180);
} else {
bars[i].setRotation(rotation);
}
if (i == bars.length-1 && width <= getActualWidth()) {
barSpace -= 2;
}
if (reverse) {
bars[bars.length-i-1].setPosition(xPos + barSpace*angleRot.x, yPos + barSpace*angleRot.y);
} else {
@ -147,10 +146,14 @@ public class BasicVisualizer extends VisualizerCore {
}
}
for (int i = 0; i < mirrors.size; i++) {
mirrors.get(i).position(barWidth, spaceBetweenBars);
mirrors.get(i).position(barWidth, spaceBetweenBars, (width <= getActualWidth()));
}
}
public float getActualWidth() {
return (barWidth+spaceBetweenBars)*(barCount - 1);
}
public void setColor(Color color) {
for (int i = 0; i < bars.length; i++) {
bars[i].setColor(color);
@ -184,6 +187,7 @@ public class BasicVisualizer extends VisualizerCore {
public void addMirrorVisualizer(MirrorVisualizer mirror) {
mirror.setup(bars, xPos, yPos, rotation);
mirrors.add(mirror);
updatePositionInfo();
}
public void removeMirrorVisualizer(MirrorVisualizer mirror) {
@ -217,4 +221,9 @@ public class BasicVisualizer extends VisualizerCore {
public float getMaxAvgHeight() {
return maxAvgHeight;
}
public int getSpaceBetweenBars() {
System.out.println(spaceBetweenBars);
return spaceBetweenBars;
}
}

View File

@ -34,7 +34,7 @@ public class MirrorVisualizer {
this.bars[renderID].draw(batch);
}
public void position(int barWidth, int spaceBetweenBars) {
public void position(int barWidth, int spaceBetweenBars, boolean shrink) {
int barSpaceMultiplier = barWidth + spaceBetweenBars;
for (int i = 0; i < bars.length; i ++) {
@ -44,7 +44,7 @@ public class MirrorVisualizer {
bars[i].setRotation(rotation);
}
int barSpace = i*(barWidth+spaceBetweenBars);
if (i == bars.length - 1) {
if (i == bars.length-1 && shrink) {
barSpace -= 2;
}
bars[i].setPosition(xPos + barSpace*rectCoordRot.x, yPos + barSpace*rectCoordRot.y);

View File

@ -76,4 +76,18 @@ public class VisualizerCore implements Disposable {
this.height = height;
}
public float getxPos() {
return xPos;
}
public float getyPos() {
return yPos;
}
public float getWidth() {
return width;
}
public float getHeight() {
return height;
}
}

View File

@ -11,6 +11,8 @@ 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.screens.MainMenu;
public class GraphicsOptions extends Table {
private Label resolutions, shaders;
private Preferences prefs;
@ -27,7 +29,7 @@ public class GraphicsOptions extends Table {
_800x480;
public GraphicsOptions(Skin skin, final Preferences prefs) {
public GraphicsOptions(MainMenu mainMenu, Skin skin, Preferences prefs) {
align(Align.center);
defaults().space(10f);
this.prefs = prefs;
@ -41,10 +43,10 @@ public class GraphicsOptions extends Table {
@Override
public void changed(ChangeEvent event, Actor actor) {
save();
if (prefs.getBoolean("fullscreen")) {
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
if (glowShader.isChecked()) {
mainMenu.loadShaders();
} else {
Gdx.graphics.setWindowedMode(prefs.getInteger("screen-width"), prefs.getInteger("screen-height"));
mainMenu.unloadShaders();
}
}
});
@ -57,10 +59,10 @@ public class GraphicsOptions extends Table {
@Override
public void changed(ChangeEvent event, Actor actor) {
save();
if (prefs.getBoolean("fullscreen")) {
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
if (enhancedGlow.isChecked()) {
mainMenu.setBlurlvl(6);
} else {
Gdx.graphics.setWindowedMode(prefs.getInteger("screen-width"), prefs.getInteger("screen-height"));
mainMenu.setBlurlvl(1);
}
}
});

View File

@ -44,8 +44,10 @@ public class TitleBarVisualizer extends Group implements Disposable {
visual.getVis().flip();
visual.getVis().reverse();
visual2 = new MirrorVisualizer();
visual.setUpdatePositioning(false);
visual.getVis().addMirrorVisualizer(visual2);
visual2.setyPos(MathUtils.round(getHeight()));
visual.updateVisualPosition();
Pixmap pixmap = new Pixmap(MathUtils.round(getWidth()), MathUtils.round(getHeight()), Format.RGBA8888);
pixmap.setColor(Color.WHITE);

View File

@ -41,6 +41,7 @@ public class Visualizer extends Widget {
vis.setRotation(getRotation());
if (updatePositioning) {
vis.updatePositionInfo();
vis.setxPos((getWidth() - vis.getActualWidth())/2f);
}
vis.calculate();
super.act(delta);
@ -65,9 +66,16 @@ public class Visualizer extends Widget {
}
public void setUpdatePositioning(boolean updatePositioning) {
vis.updatePositionInfo();
vis.setxPos(((vis.getWidth() - vis.getActualWidth())/2f));
vis.updatePositionInfo();
this.updatePositioning = updatePositioning;
}
public void updateVisualPosition() {
vis.updatePositionInfo();
}
public boolean isUpdatePositioning() {
return updatePositioning;
}

View File

@ -32,7 +32,6 @@ public class MainPage extends Page implements OnDifferentSongListener {
addActor(titleBar);
titleBar.getHvisual().setMM(sc.getCurrentSong());
sc.addOnDifferentSongListener(this);
versionLabel = new Label("Version: " + RhythmBullet.VERSION, core.getDefaultSkin(), "sub-font",

View File

@ -11,12 +11,13 @@ import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import zero1hd.rhythmbullet.graphics.ui.components.GraphicsOptions;
import zero1hd.rhythmbullet.screens.MainMenu;
public class VideoOptionsPage extends Page {
private ScrollPane scrollPane;
private GraphicsOptions graphicsTable;
public VideoOptionsPage(Skin skin, Preferences prefs) {
graphicsTable = new GraphicsOptions(skin, prefs);
public VideoOptionsPage(Skin skin, Preferences prefs, MainMenu menu) {
graphicsTable = new GraphicsOptions(menu, skin, prefs);
scrollPane = new ScrollPane(graphicsTable, skin);
scrollPane.setFadeScrollBars(false);
scrollPane.setFillParent(true);

View File

@ -54,7 +54,7 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
private Batch batch;
private ScreenViewport screenViewport;
public MainMenu(final RhythmBullet core) {
public MainMenu(RhythmBullet core) {
this.core = core;
stage = new Stage(new ScreenViewport());
targetPosition = new Vector3(stage.getCamera().position);
@ -83,7 +83,7 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
keybindPage.setPosition(1f*Gdx.graphics.getWidth(), -1f*Gdx.graphics.getHeight());
stage.addActor(keybindPage);
graphicsPage = new VideoOptionsPage(core.getDefaultSkin(), core.getPrefs());
graphicsPage = new VideoOptionsPage(core.getDefaultSkin(), core.getPrefs(), this);
graphicsPage.setPosition(1f*Gdx.graphics.getWidth(), 1f*Gdx.graphics.getHeight());
stage.addActor(graphicsPage);
@ -197,10 +197,10 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0.32f, 0f, 0f, 1f);
Gdx.gl.glClearColor(0.22f, 0f, 0f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act(delta);
if (gaussianBlurShader != null) {
if (blurlvl > 0) {
//Begin drawing a normal version of screen
normalBuffer.begin();
stage.getViewport().apply();
@ -309,6 +309,7 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
@Override
public void dispose() {
stage.dispose();
unloadShaders();
super.dispose();
}
@ -319,4 +320,28 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
lerpAlpha = 0.15f;
}
}
public void unloadShaders() {
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;
setBlurlvl(0);
}
public void setBlurlvl(int blurlvl) {
this.blurlvl = blurlvl;
}
}