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

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