changed shader options to slider; did some cleaning;

This commit is contained in:
Harrison Deng 2018-03-18 00:21:27 -05:00
parent f35691536b
commit 2aa498e292
4 changed files with 46 additions and 70 deletions

View File

@ -49,7 +49,7 @@ public class HorizontalVisualizer extends Visualizer {
y = 0; y = 0;
smoothRange = 3; smoothRange = 2;
angleRot = new Vector2(MathUtils.cosDeg(rotation), MathUtils.sinDeg(rotation)); angleRot = new Vector2(MathUtils.cosDeg(rotation), MathUtils.sinDeg(rotation));
bars = new Sprite[barCount]; bars = new Sprite[barCount];
barHeights = new float[barCount]; barHeights = new float[barCount];

View File

@ -3,9 +3,9 @@ package zero1hd.rhythmbullet.desktop.graphics.ui.components;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences; import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox;
import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Slider;
import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
@ -16,7 +16,7 @@ import zero1hd.rhythmbullet.desktop.screens.MainMenuScreen;
public class GraphicsOptions extends Table { public class GraphicsOptions extends Table {
private Label resolutions, shaders; private Label resolutions, shaders;
private Preferences prefs; private Preferences prefs;
private CheckBox glowShader, enhancedGlow; private Slider glowShaderLevel;
private ResolutionButton private ResolutionButton
_3840x2160, _3840x2160,
@ -32,44 +32,20 @@ public class GraphicsOptions extends Table {
align(Align.center); align(Align.center);
defaults().space(10f); defaults().space(10f);
this.prefs = prefs; this.prefs = prefs;
shaders = new Label("OpenGL Shaders", skin); shaders = new Label("OpenGL Shader", skin);
add(shaders).fillX(); add(shaders).fillX();
row(); row();
glowShader = new CheckBox(" Glow Shader", skin); glowShaderLevel = new Slider(0, 4, 1, false, skin);
glowShader.setChecked(prefs.getBoolean("glow shader", true)); glowShaderLevel.addListener(new ChangeListener() {
glowShader.addListener(new ChangeListener() {
@Override @Override
public void changed(ChangeEvent event, Actor actor) { public void changed(ChangeEvent event, Actor actor) {
save(); mainMenu.setGlowLevel((int) glowShaderLevel.getValue());
if (glowShader.isChecked()) {
mainMenu.setBlurlvl(1);
enhancedGlow.setDisabled(false);
} else {
mainMenu.setBlurlvl(0);
enhancedGlow.setChecked(false);
enhancedGlow.setDisabled(true);
}
} }
}); });
add(glowShader); glowShaderLevel.setValue(prefs.getInteger("glow shader"));
row(); add(glowShaderLevel).fillX();
enhancedGlow = new CheckBox(" Enhanced Glow", skin);
enhancedGlow.setChecked(prefs.getBoolean("enhanced glow", false));
enhancedGlow.setDisabled(!prefs.getBoolean("glow shader", false));
enhancedGlow.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
save();
if (enhancedGlow.isChecked()) {
mainMenu.setBlurlvl(5);
} else {
mainMenu.setBlurlvl(1);
}
}
});
add(enhancedGlow);
row(); row();
resolutions = new Label("Resolutions: ", skin); resolutions = new Label("Resolutions: ", skin);
@ -124,7 +100,6 @@ public class GraphicsOptions extends Table {
public void save() { public void save() {
Gdx.app.debug("Preferences", "Saved shading values values."); Gdx.app.debug("Preferences", "Saved shading values values.");
prefs.putBoolean("glow shader", glowShader.isChecked()); prefs.putInteger("glow shader", (int) glowShaderLevel.getValue());
prefs.putBoolean("enhanced glow", enhancedGlow.isChecked());
} }
} }

View File

@ -12,12 +12,12 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.rhythmbullet.desktop.graphics.ui.components.GraphicsOptions; import zero1hd.rhythmbullet.desktop.graphics.ui.components.GraphicsOptions;
import zero1hd.rhythmbullet.desktop.screens.MainMenuScreen; import zero1hd.rhythmbullet.desktop.screens.MainMenuScreen;
public class VideoOptionsPage extends Page { public class GraphicsOptionsPage extends Page {
private ScrollPane scrollPane; private ScrollPane scrollPane;
private GraphicsOptions graphicsTable; private GraphicsOptions graphicsTable;
private TextButton backButton; private TextButton backButton;
public VideoOptionsPage(Skin skin, Preferences prefs, final MainMenuScreen menu, AssetManager assets) { public GraphicsOptionsPage(Skin skin, Preferences prefs, final MainMenuScreen menu, AssetManager assets) {
graphicsTable = new GraphicsOptions(menu, skin, prefs); graphicsTable = new GraphicsOptions(menu, skin, prefs);
scrollPane = new ScrollPane(graphicsTable, skin); scrollPane = new ScrollPane(graphicsTable, skin);
scrollPane.setFadeScrollBars(false); scrollPane.setFadeScrollBars(false);

View File

@ -30,7 +30,7 @@ import zero1hd.rhythmbullet.desktop.graphics.ui.pages.KeybindOptionsPage;
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.MainPage; import zero1hd.rhythmbullet.desktop.graphics.ui.pages.MainPage;
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.MusicSelectionPage; import zero1hd.rhythmbullet.desktop.graphics.ui.pages.MusicSelectionPage;
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.OptionsPage; import zero1hd.rhythmbullet.desktop.graphics.ui.pages.OptionsPage;
import zero1hd.rhythmbullet.desktop.graphics.ui.pages.VideoOptionsPage; import zero1hd.rhythmbullet.desktop.graphics.ui.pages.GraphicsOptionsPage;
import zero1hd.rhythmbullet.util.AdvancedResizeScreen; import zero1hd.rhythmbullet.util.AdvancedResizeScreen;
public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScreen { public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScreen {
@ -41,7 +41,7 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
private OptionsPage optionsPage; private OptionsPage optionsPage;
private CreditsPage creditsPage; private CreditsPage creditsPage;
private KeybindOptionsPage keybindPage; private KeybindOptionsPage keybindPage;
private VideoOptionsPage graphicsPage; private GraphicsOptionsPage graphicsPage;
private MusicSelectionPage musicSelectionPage; private MusicSelectionPage musicSelectionPage;
private AnalysisPage analysisPage; private AnalysisPage analysisPage;
private RhythmBullet core; private RhythmBullet core;
@ -59,7 +59,7 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
private FrameBuffer hBlur, vBlur; private FrameBuffer hBlur, vBlur;
private TextureRegion fboRegion; private TextureRegion fboRegion;
private int fboSize; private int fboSize;
private int blurlvl; private int glowLevel;
private Texture background; private Texture background;
@ -86,7 +86,7 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
Gdx.gl.glClearColor(0f, 0f, 0f, 1f); Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act(delta); stage.act(delta);
if (blurlvl > 0) { if (glowLevel > 0) {
// Begin drawing a normal version of screen // Begin drawing a normal version of screen
normalBuffer.begin(); normalBuffer.begin();
stage.getViewport().apply(); stage.getViewport().apply();
@ -110,7 +110,7 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
screenBatch.flush(); screenBatch.flush();
lightFilterBuffer.end(); lightFilterBuffer.end();
for (int i = 0; i < blurlvl; i++) { for (int i = 0; i < glowLevel; i++) {
// Horizontal gaussian blur // Horizontal gaussian blur
hBlur.begin(); hBlur.begin();
if (i > 0) { if (i > 0) {
@ -173,7 +173,7 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
musicSelectionPage.dispose(); musicSelectionPage.dispose();
dismantleShaders(); dismantleShaders();
setBlurlvl(0); setGlowLevel(0);
background = null; background = null;
} }
@ -181,16 +181,7 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
@Override @Override
public void postAssetLoad() { public void postAssetLoad() {
background = core.getAssetManager().get("backgrounds/mainBG.png", Texture.class); background = core.getAssetManager().get("backgrounds/mainBG.png", Texture.class);
screenBatch = new SpriteBatch();
if (core.getPrefs().getBoolean("glow shader", true)) {
setupShaders();
if (core.getPrefs().getBoolean("enhanced glow", false)) {
setBlurlvl(1);
} else {
setBlurlvl(4);
}
}
mainPage = new MainPage(core, cameraPosition, mlc, this); mainPage = new MainPage(core, cameraPosition, mlc, this);
mainPage.setPosition(0, 0); mainPage.setPosition(0, 0);
@ -201,7 +192,7 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
keybindPage.setPosition(-1f*Gdx.graphics.getWidth(), -1f*Gdx.graphics.getHeight()); keybindPage.setPosition(-1f*Gdx.graphics.getWidth(), -1f*Gdx.graphics.getHeight());
stage.addActor(keybindPage); stage.addActor(keybindPage);
graphicsPage = new VideoOptionsPage(core.getDefaultSkin(), core.getPrefs(), this, core.getAssetManager()); graphicsPage = new GraphicsOptionsPage(core.getDefaultSkin(), core.getPrefs(), this, core.getAssetManager());
graphicsPage.setPosition(-1f*Gdx.graphics.getWidth(), 1f*Gdx.graphics.getHeight()); graphicsPage.setPosition(-1f*Gdx.graphics.getWidth(), 1f*Gdx.graphics.getHeight());
stage.addActor(graphicsPage); stage.addActor(graphicsPage);
@ -287,14 +278,16 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
@Override @Override
public void dispose() { public void dispose() {
stage.dispose(); stage.dispose();
if (gaussianBlurShader != null) {
dismantleShaders(); dismantleShaders();
}
mic.dispose(); mic.dispose();
screenBatch.dispose();
super.dispose(); super.dispose();
} }
public void setupShaders() { public void setupShaders() {
Gdx.app.debug("Shader", "Loading glow shaders."); Gdx.app.debug("Shader", "Loading glow shaders.");
screenBatch = new SpriteBatch();
screenViewport = new ScreenViewport(); screenViewport = new ScreenViewport();
screenViewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); screenViewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
((OrthographicCamera) screenViewport.getCamera()).setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); ((OrthographicCamera) screenViewport.getCamera()).setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
@ -355,7 +348,6 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
} }
public void dismantleShaders() { public void dismantleShaders() {
if (core.getPrefs().getBoolean("glow shader")) {
brightFilterShader.dispose(); brightFilterShader.dispose();
combineShader.dispose(); combineShader.dispose();
gaussianBlurShader.dispose(); gaussianBlurShader.dispose();
@ -363,7 +355,6 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
lightFilterBuffer.dispose(); lightFilterBuffer.dispose();
vBlur.dispose(); vBlur.dispose();
hBlur.dispose(); hBlur.dispose();
}
brightFilterShader = null; brightFilterShader = null;
combineShader = null; combineShader = null;
@ -373,11 +364,21 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
vBlur = null; vBlur = null;
hBlur = null; hBlur = null;
setBlurlvl(0); setGlowLevel(0);
} }
public void setBlurlvl(int blurlvl) { public void setGlowLevel(int glowLevel) {
this.blurlvl = blurlvl; if (glowLevel > 0) {
if (gaussianBlurShader == null) {
setupShaders();
}
} else {
if (gaussianBlurShader != null) {
dismantleShaders();
}
}
this.glowLevel = glowLevel;
} }
public Vector3 getCameraPosition() { public Vector3 getCameraPosition() {
@ -388,7 +389,7 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
return creditsPage; return creditsPage;
} }
public VideoOptionsPage getGraphicsPage() { public GraphicsOptionsPage getGraphicsPage() {
return graphicsPage; return graphicsPage;
} }