From 7ca69899b34e6eeb9f26a47ac4498368ca6b9794 Mon Sep 17 00:00:00 2001 From: Recrown Date: Mon, 15 Jan 2018 18:12:07 -0600 Subject: [PATCH] change all logging to the gdx system; removed unused debug outputs --- .../zero1hd/rhythmbullet/RhythmBullet.java | 1 - .../audio/visualizer/BasicVisualizer.java | 4 +- .../desktop/audio/Mp3Manager.java | 4 +- .../desktop/audio/MusicListController.java | 6 + .../graphics/ui/components/Visualizer.java | 8 +- .../desktop/graphics/ui/pages/MainPage.java | 1 - .../graphics/ui/pages/OptionsPage.java | 2 +- .../graphics/ui/windows/LoadingWindow.java | 1 - .../desktop/screens/GameScreen.java | 12 +- .../desktop/screens/MainMenu.java | 146 +++++++++--------- 10 files changed, 93 insertions(+), 92 deletions(-) diff --git a/core/src/zero1hd/rhythmbullet/RhythmBullet.java b/core/src/zero1hd/rhythmbullet/RhythmBullet.java index 314e8c7..f8891a9 100755 --- a/core/src/zero1hd/rhythmbullet/RhythmBullet.java +++ b/core/src/zero1hd/rhythmbullet/RhythmBullet.java @@ -61,7 +61,6 @@ public class RhythmBullet extends Game { @Override public void create() { Gdx.app.setLogLevel(Application.LOG_DEBUG); - prefs = Gdx.app.getPreferences("PolyJet_Preferences"); if (getPrefs().getBoolean("fullscreen", true)) { diff --git a/core/src/zero1hd/rhythmbullet/audio/visualizer/BasicVisualizer.java b/core/src/zero1hd/rhythmbullet/audio/visualizer/BasicVisualizer.java index 93329b9..fe26d99 100755 --- a/core/src/zero1hd/rhythmbullet/audio/visualizer/BasicVisualizer.java +++ b/core/src/zero1hd/rhythmbullet/audio/visualizer/BasicVisualizer.java @@ -180,9 +180,10 @@ public class BasicVisualizer extends VisualizerCore { } public void addMirrorVisualizer(MirrorVisualizer mirror) { + updatePositionInfo(); mirror.setup(bars, xPos, yPos, rotation); mirrors.add(mirror); - updatePositionInfo(); + setxPos(((getWidth() - getActualWidth())/2f)); } public void removeMirrorVisualizer(MirrorVisualizer mirror) { @@ -218,7 +219,6 @@ public class BasicVisualizer extends VisualizerCore { } public int getSpaceBetweenBars() { - System.out.println(spaceBetweenBars); return spaceBetweenBars; } } diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/audio/Mp3Manager.java b/desktop/src/zero1hd/rhythmbullet/desktop/audio/Mp3Manager.java index f4f97fc..e55b530 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/audio/Mp3Manager.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/audio/Mp3Manager.java @@ -163,7 +163,7 @@ public class Mp3Manager implements MusicManager { try { decoder.decodeFrame(header, bitstream); } catch (ArrayIndexOutOfBoundsException | DecoderException e) { - System.out.println(e); + Gdx.app.error("Shader Error", e.toString()); } bitstream.closeFrame(); bytesRead = sampleBuffer.reset(); @@ -187,13 +187,11 @@ public class Mp3Manager implements MusicManager { @Override public void pause() { - Gdx.app.debug("MP3Manager", "Pausing..."); playbackMusic.pause(); } @Override public void play() { - Gdx.app.debug("Mp3Manager", "MP3 Playing..."); playbackMusic.play(); } diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/audio/MusicListController.java b/desktop/src/zero1hd/rhythmbullet/desktop/audio/MusicListController.java index 6f047b6..41184ba 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/audio/MusicListController.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/audio/MusicListController.java @@ -42,6 +42,12 @@ public class MusicListController extends Observable implements OnCompletionListe } } + public void pause() { + if (mm != null) { + mm.pause(); + } + } + public void setMusicByIndex(int index) { this.currentPlaybackID = index; loadMusic(); diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/Visualizer.java b/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/Visualizer.java index 6748eb3..9603294 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/Visualizer.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/components/Visualizer.java @@ -56,12 +56,13 @@ public class Visualizer extends Widget implements Disposable { @Override public void act(float delta) { if (mm != null && mm.isFinishedLoading() && !mmSet) { - Gdx.app.debug("Visualizer", "\nsample count: " + mm.getSampleCount() - + "\nDuration in seconds: " + mm.getDuration() + - "\nSample rate: " + mm.getSampleRate()); vis.setMM(mm); visRefreshRate = mm.getReadWindowSize()/mm.getSampleRate(); mmSet = true; + Gdx.app.debug("Visualizer", "\nsample count: " + mm.getSampleCount() + + "\nDuration in seconds: " + mm.getDuration() + + "\nSample rate: " + mm.getSampleRate() + + "\nRefresh rate: " + visRefreshRate); } vis.update(delta); @@ -154,7 +155,6 @@ public class Visualizer extends Widget implements Disposable { } int originalPos = buffer.position(); - System.out.println(visRefreshRate); playingBuffer = ShortBuffer.allocate(buffer.capacity()); buffer.rewind(); playingBuffer.put(buffer); diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/pages/MainPage.java b/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/pages/MainPage.java index 3a3b301..4e0804d 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/pages/MainPage.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/pages/MainPage.java @@ -53,7 +53,6 @@ public class MainPage extends Page implements Observer { table.align(Align.center); table.defaults().space(10f); addActor(table); - playButton = new TextButton("Start!", core.getDefaultSkin()); playButton.addListener(new ChangeListener() { @Override diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/pages/OptionsPage.java b/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/pages/OptionsPage.java index 64d03e3..75b89a4 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/pages/OptionsPage.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/pages/OptionsPage.java @@ -162,7 +162,7 @@ public class OptionsPage extends Page { } public void saveOptions(Preferences prefs) { - Gdx.app.debug("Preferences", "Saved all basic options page values."); prefs.putString("music dir", directoryField.getText()); + Gdx.app.debug("Preferences", "Saved all basic options page values."); } } diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/windows/LoadingWindow.java b/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/windows/LoadingWindow.java index 674153d..75f645a 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/windows/LoadingWindow.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/graphics/ui/windows/LoadingWindow.java @@ -24,7 +24,6 @@ public class LoadingWindow extends Window implements Disposable { Image loading = new Image(skin, "loading"); loading.addAction(Actions.forever(Actions.rotateBy(-360f, 2f))); add(loading).left(); - System.out.println(loading.getHeight()); setSize(loading.getWidth()+20f, loading.getHeight()+40f); diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/screens/GameScreen.java b/desktop/src/zero1hd/rhythmbullet/desktop/screens/GameScreen.java index 244d9d5..88d4dbd 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/screens/GameScreen.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/screens/GameScreen.java @@ -98,29 +98,29 @@ public class GameScreen extends ScreenAdapter { 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()) { - System.err.println(brightFilterShader.getLog()); + Gdx.app.error("Shader Error", brightFilterShader.getLog()); System.exit(0); } if (brightFilterShader.getLog().length() != 0) { - System.out.println(brightFilterShader.getLog()); + Gdx.app.error("Shader Error", brightFilterShader.getLog()); } gaussianBlurShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/gaussian_blur.fsh")); if (!gaussianBlurShader.isCompiled()) { - System.err.println(gaussianBlurShader.getLog()); + Gdx.app.error("Shader Error", gaussianBlurShader.getLog()); System.exit(0); } if (gaussianBlurShader.getLog().length() != 0) { - System.out.println(gaussianBlurShader.getLog()); + Gdx.app.error("Shader Error", gaussianBlurShader.getLog()); } combineShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/combine.fsh")); if (!combineShader.isCompiled()) { - System.err.println(combineShader.getLog()); + Gdx.app.error("Shader Error", combineShader.getLog()); System.exit(0); } if (combineShader.getLog().length() != 0) { - System.out.println(combineShader.getLog()); + Gdx.app.error("Shader Error", combineShader.getLog()); } diff --git a/desktop/src/zero1hd/rhythmbullet/desktop/screens/MainMenu.java b/desktop/src/zero1hd/rhythmbullet/desktop/screens/MainMenu.java index d543d6a..a77685e 100755 --- a/desktop/src/zero1hd/rhythmbullet/desktop/screens/MainMenu.java +++ b/desktop/src/zero1hd/rhythmbullet/desktop/screens/MainMenu.java @@ -131,80 +131,11 @@ public class MainMenu extends ScreenAdapter implements AdvancedResizeScreen { } }); mlc.getMusicList().deleteObservers(); - mlc.deleteObservers();; + mlc.deleteObservers(); mlc.addObserver(musicSelectionPage); mlc.addObserver(mainPage); mlc.getMusicList().addObserver(mainPage); - } - - public void attemptLoadShaders() { - if (core.getPrefs().getBoolean("glow shader", true)) { - if (core.getPrefs().getBoolean("enhanced glow", false)) { - blurlvl = 5; - } else { - blurlvl = 1; - } - - batch = new SpriteBatch(); - 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()) { - System.err.println(brightFilterShader.getLog()); - System.exit(0); - } - if (brightFilterShader.getLog().length() != 0) { - System.out.println(brightFilterShader.getLog()); - } - - gaussianBlurShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/gaussian_blur.fsh")); - if (!gaussianBlurShader.isCompiled()) { - System.err.println(gaussianBlurShader.getLog()); - System.exit(0); - } - if (gaussianBlurShader.getLog().length() != 0) { - System.out.println(gaussianBlurShader.getLog()); - } - - combineShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/combine.fsh")); - if (!combineShader.isCompiled()) { - System.err.println(combineShader.getLog()); - System.exit(0); - } - if (combineShader.getLog().length() != 0) { - System.out.println(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; } @Override @@ -333,7 +264,7 @@ public class MainMenu extends ScreenAdapter implements AdvancedResizeScreen { } public void unloadShaders() { - try { + if (core.getPrefs().getBoolean("glow shader")) { brightFilterShader.dispose(); combineShader.dispose(); gaussianBlurShader.dispose(); @@ -341,8 +272,6 @@ public class MainMenu extends ScreenAdapter implements AdvancedResizeScreen { lightFilterBuffer.dispose(); vBlur.dispose(); hBlur.dispose(); - } catch (NullPointerException e) { - saveAll(); } brightFilterShader = null; @@ -387,4 +316,75 @@ public class MainMenu extends ScreenAdapter implements AdvancedResizeScreen { public OptionsPage getOptionsPage() { return optionsPage; } + + public void attemptLoadShaders() { + if (core.getPrefs().getBoolean("glow shader", true)) { + if (core.getPrefs().getBoolean("enhanced glow", false)) { + blurlvl = 5; + } else { + blurlvl = 1; + } + + batch = new SpriteBatch(); + 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 Error", brightFilterShader.getLog()); + System.exit(0); + } + if (brightFilterShader.getLog().length() != 0) { + Gdx.app.error("Shader Error", 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 Error", gaussianBlurShader.getLog()); + System.exit(0); + } + if (gaussianBlurShader.getLog().length() != 0) { + Gdx.app.error("Shader Error", gaussianBlurShader.getLog()); + } + + combineShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/combine.fsh")); + if (!combineShader.isCompiled()) { + Gdx.app.error("Shader Error", combineShader.getLog()); + System.exit(0); + } + if (combineShader.getLog().length() != 0) { + Gdx.app.error("Shader Error", 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; + } + }