diff --git a/core/src/zero1hd/polyjet/Polyjet.java b/core/src/zero1hd/polyjet/Polyjet.java index e58c0d5..328f995 100755 --- a/core/src/zero1hd/polyjet/Polyjet.java +++ b/core/src/zero1hd/polyjet/Polyjet.java @@ -240,6 +240,10 @@ public class Polyjet extends Game { CheckBoxStyle defaultCheckBox = new CheckBoxStyle(getDefaultSkin().getDrawable("check-off"), getDefaultSkin().getDrawable("check-on"), getDefaultSkin().getFont("window-font"), getDefaultSkin().getColor("default")); getDefaultSkin().add("default", defaultCheckBox); + CheckBoxStyle expandableCheckBox = new CheckBoxStyle(defaultCheckBox); + expandableCheckBox.font = getDefaultSkin().getFont("sub-font"); + getDefaultSkin().add("expandable", expandableCheckBox); + SelectBoxStyle defaultSelectBox = new SelectBoxStyle(getDefaultSkin().getFont("default-font"), getDefaultSkin().getColor("default"), getDefaultSkin().getDrawable("default-select"), defaultScrollPane, defaultList); getDefaultSkin().add("default", defaultSelectBox); diff --git a/core/src/zero1hd/polyjet/screens/MainMenu.java b/core/src/zero1hd/polyjet/screens/MainMenu.java index 54ffed6..f64c7e9 100755 --- a/core/src/zero1hd/polyjet/screens/MainMenu.java +++ b/core/src/zero1hd/polyjet/screens/MainMenu.java @@ -99,6 +99,7 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter { public void hide() { if (optionsPage != null) { optionsPage.saveOptions(core.getPrefs()); + moreOptionsPage.getGraphicsSettings().save(core.getPrefs()); } super.hide(); } diff --git a/core/src/zero1hd/polyjet/ui/builders/GraphicsTable.java b/core/src/zero1hd/polyjet/ui/builders/GraphicsTable.java index ecc9c77..ed4843c 100755 --- a/core/src/zero1hd/polyjet/ui/builders/GraphicsTable.java +++ b/core/src/zero1hd/polyjet/ui/builders/GraphicsTable.java @@ -3,6 +3,7 @@ package zero1hd.polyjet.ui.builders; 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.Table; @@ -11,7 +12,9 @@ import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.badlogic.gdx.utils.Align; public class GraphicsTable extends Table { - private Label title; + private Label resolutions, shaders; + + private CheckBox glowShader, bgShader, invertShader; private SetResolutionButton _3840x2160, @@ -28,8 +31,27 @@ public class GraphicsTable extends Table { align(Align.center); defaults().space(10f); - title = new Label("Optimized Resolutions", skin); - add(title).left(); + shaders = new Label("OpenGL Shaders", skin); + add(shaders).fillX(); + row(); + + invertShader = new CheckBox(" Invert Shader", skin, "expandable"); + invertShader.setChecked(pref.getBoolean("invert_shader", false)); + add(invertShader).minHeight(shaders.getHeight()); + row(); + + glowShader = new CheckBox(" Glow Shader", skin, "expandable"); + glowShader.setChecked(pref.getBoolean("glow_shader", true)); + add(glowShader).minHeight(shaders.getHeight()); + row(); + + bgShader = new CheckBox(" Background Shader", skin, "expandable"); + bgShader.setChecked(pref.getBoolean("bg_shader", true)); + add(bgShader).minHeight(shaders.getHeight()); + row(); + + resolutions = new Label("Optimized Resolutions", skin); + add(resolutions).left(); row(); @@ -80,4 +102,11 @@ public class GraphicsTable extends Table { add(_800x480).fillX(); row(); } + + public void save(Preferences prefs) { + prefs.putBoolean("bg_shader", bgShader.isChecked()); + prefs.putBoolean("glow_shader", glowShader.isChecked()); + prefs.putBoolean("invert_shader", invertShader.isChecked()); + prefs.flush(); + } } diff --git a/core/src/zero1hd/polyjet/ui/pages/MainPage.java b/core/src/zero1hd/polyjet/ui/pages/MainPage.java index 4966690..100ac5c 100755 --- a/core/src/zero1hd/polyjet/ui/pages/MainPage.java +++ b/core/src/zero1hd/polyjet/ui/pages/MainPage.java @@ -1,7 +1,6 @@ package zero1hd.polyjet.ui.pages; import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.scenes.scene2d.Actor; diff --git a/core/src/zero1hd/polyjet/ui/pages/MoreOptionsPage.java b/core/src/zero1hd/polyjet/ui/pages/MoreOptionsPage.java index 2e6312d..c6105f6 100755 --- a/core/src/zero1hd/polyjet/ui/pages/MoreOptionsPage.java +++ b/core/src/zero1hd/polyjet/ui/pages/MoreOptionsPage.java @@ -67,4 +67,8 @@ public class MoreOptionsPage extends Page { break; } } + + public GraphicsTable getGraphicsSettings() { + return graphicsSettings; + } } diff --git a/core/src/zero1hd/polyjet/ui/stages/GamePlayArea.java b/core/src/zero1hd/polyjet/ui/stages/GamePlayArea.java index 78721d7..7ca496d 100755 --- a/core/src/zero1hd/polyjet/ui/stages/GamePlayArea.java +++ b/core/src/zero1hd/polyjet/ui/stages/GamePlayArea.java @@ -3,8 +3,10 @@ package zero1hd.polyjet.ui.stages; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Preferences; import com.badlogic.gdx.assets.AssetManager; +import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.glutils.ShaderProgram; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.utils.viewport.FitViewport; @@ -30,7 +32,9 @@ public class GamePlayArea extends Stage { private int score; private ShaderProgram invert; + private ShaderProgram bgShader; + private ShapeRenderer bg; public GamePlayArea(AssetManager assetManager, Preferences prefs) { super(new FitViewport(Polyjet.GAME_AREA_WIDTH, Polyjet.GAME_AREA_HEIGHT)); @@ -45,13 +49,33 @@ public class GamePlayArea extends Stage { System.err.println(invert.getLog()); System.exit(0); } - if (invert.getLog().length()!=0) + if (invert.getLog().length()!=0) { System.out.println(invert.getLog()); - + } getBatch().setShader(invert); } + if (prefs.getBoolean("bg_shader")) { + bgShader = new ShaderProgram(Gdx.files.internal("shaders/invert_vert.glsl").readString(), Gdx.files.internal("shaders/star_frag.glsl").readString()); + if (!invert.isCompiled()) { + System.err.println(invert.getLog()); + System.exit(0); + } + if (invert.getLog().length()!=0) { + System.out.println(invert.getLog()); + } + + bg = new ShapeRenderer(8, bgShader); + bg.setColor(Color.BLACK); + } else { + bg = new ShapeRenderer(); + bg.setTransformMatrix(getCamera().combined); + bg.setColor(Color.WHITE); + } + + ShaderProgram.pedantic = false; + shapes = new ShapeRenderer(64, getBatch().getShader()); shapes.setProjectionMatrix(getCamera().combined); ec = new EntityController(assetManager, shapes); @@ -59,6 +83,14 @@ public class GamePlayArea extends Stage { ec.activeAllies.add(polyjet); } + @Override + public void draw() { + bg.begin(ShapeType.Filled); + bg.rect(0, 0, Polyjet.GAME_AREA_WIDTH, Polyjet.GAME_AREA_HEIGHT); + bg.end(); + super.draw(); + } + @Override public void act(float delta) { collisionDetector.collisionCheck(); diff --git a/core/src/zero1hd/polyjet/ui/windows/BeatViewer.java b/core/src/zero1hd/polyjet/ui/windows/BeatViewer.java index dddd667..83e002d 100755 --- a/core/src/zero1hd/polyjet/ui/windows/BeatViewer.java +++ b/core/src/zero1hd/polyjet/ui/windows/BeatViewer.java @@ -20,7 +20,7 @@ public class BeatViewer extends Window { private AudioAnalyzer data; public BeatViewer(String title, Skin skin) { - super(title, skin); + super(title, skin, "tinted"); defaults().space(5f); setSize(64, 100); diff --git a/core/src/zero1hd/polyjet/ui/windows/FPSWindow.java b/core/src/zero1hd/polyjet/ui/windows/FPSWindow.java index 17ba75f..e9d978f 100755 --- a/core/src/zero1hd/polyjet/ui/windows/FPSWindow.java +++ b/core/src/zero1hd/polyjet/ui/windows/FPSWindow.java @@ -8,7 +8,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Window; public class FPSWindow extends Window { public FPSWindow(String title, Skin skin) { - super(title, skin); + super(title, skin, "tinted"); Label FPS = new Label("FPS: ", skin, "window-font", skin.getColor("default")) { @Override public void act(float delta) { diff --git a/core/src/zero1hd/polyjet/ui/windows/GraphWindow.java b/core/src/zero1hd/polyjet/ui/windows/GraphWindow.java index 18e05c1..702f4fb 100755 --- a/core/src/zero1hd/polyjet/ui/windows/GraphWindow.java +++ b/core/src/zero1hd/polyjet/ui/windows/GraphWindow.java @@ -12,7 +12,7 @@ public class GraphWindow extends Window { AudioData audioData; public GraphWindow(String title, Skin skin) { - super(title, skin); + super(title, skin, "tinted"); graph = new AudioGraph(300, 150); add(graph); setSize(305, 155); diff --git a/core/src/zero1hd/polyjet/ui/windows/LoadingWindow.java b/core/src/zero1hd/polyjet/ui/windows/LoadingWindow.java index da6d64b..1696bc1 100755 --- a/core/src/zero1hd/polyjet/ui/windows/LoadingWindow.java +++ b/core/src/zero1hd/polyjet/ui/windows/LoadingWindow.java @@ -16,7 +16,7 @@ public class LoadingWindow extends Window implements Disposable { private Sound openSound; private float vol; public LoadingWindow(Skin skin, boolean progress, AssetManager assets, float vol) { - super("loading...", skin); + super("loading...", skin, "tinted"); this.openSound = assets.get("pop_open.ogg", Sound.class); this.closeSound = assets.get("pop_close.ogg", Sound.class); diff --git a/core/src/zero1hd/polyjet/ui/windows/MusicController.java b/core/src/zero1hd/polyjet/ui/windows/MusicController.java index c9f3460..1977163 100755 --- a/core/src/zero1hd/polyjet/ui/windows/MusicController.java +++ b/core/src/zero1hd/polyjet/ui/windows/MusicController.java @@ -22,7 +22,7 @@ public class MusicController extends Window { private AudioData audiofile; public MusicController(final Skin skin) { - super("Playback Controller", skin); + super("Playback Controller", skin, "tinted"); defaults().space(5f); diff --git a/core/src/zero1hd/polyjet/ui/windows/MusicSelector.java b/core/src/zero1hd/polyjet/ui/windows/MusicSelector.java index 0aa904c..8901773 100755 --- a/core/src/zero1hd/polyjet/ui/windows/MusicSelector.java +++ b/core/src/zero1hd/polyjet/ui/windows/MusicSelector.java @@ -27,7 +27,7 @@ public class MusicSelector extends Window { public MiniSender miniSender; public MusicSelector(String title, Skin skin, final String path, String listStyle) { - super(title, skin); + super(title, skin, "tinted"); this.path = path; padTop(25f); padLeft(5f); diff --git a/core/src/zero1hd/polyjet/ui/windows/NoticeWindow.java b/core/src/zero1hd/polyjet/ui/windows/NoticeWindow.java index 2439011..90fb4c8 100755 --- a/core/src/zero1hd/polyjet/ui/windows/NoticeWindow.java +++ b/core/src/zero1hd/polyjet/ui/windows/NoticeWindow.java @@ -11,7 +11,7 @@ public class NoticeWindow extends Window { private Label noticeText; private Skin skin; public NoticeWindow(Skin skin, String styleName, String text) { - super("Notice", skin); + super("Notice", skin, "tinted"); this.skin = skin; noticeText = new Label(text, skin, "sub-font", skin.getColor("default")); diff --git a/core/src/zero1hd/polyjet/ui/windows/Spawnables.java b/core/src/zero1hd/polyjet/ui/windows/Spawnables.java index 21d9dbf..533d3c6 100755 --- a/core/src/zero1hd/polyjet/ui/windows/Spawnables.java +++ b/core/src/zero1hd/polyjet/ui/windows/Spawnables.java @@ -8,7 +8,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Window; public class Spawnables extends Window { public Spawnables(String title, Skin skin) { - super(title, skin); + super(title, skin, "tinted"); Table spawnButtons = new Table(skin); diff --git a/core/src/zero1hd/polyjet/ui/windows/SpawnerWindow.java b/core/src/zero1hd/polyjet/ui/windows/SpawnerWindow.java index 5f306aa..b220c35 100755 --- a/core/src/zero1hd/polyjet/ui/windows/SpawnerWindow.java +++ b/core/src/zero1hd/polyjet/ui/windows/SpawnerWindow.java @@ -33,7 +33,7 @@ public class SpawnerWindow extends Window { private Slider mod4; public SpawnerWindow(String title, Skin skin, EntityController ec, Stage stageForEntities) { - super(title, skin); + super(title, skin, "tinted"); this.ec = ec; stage = stageForEntities; diff --git a/core/src/zero1hd/polyjet/ui/windows/VolumeWindow.java b/core/src/zero1hd/polyjet/ui/windows/VolumeWindow.java index faa614f..341b7f6 100755 --- a/core/src/zero1hd/polyjet/ui/windows/VolumeWindow.java +++ b/core/src/zero1hd/polyjet/ui/windows/VolumeWindow.java @@ -19,7 +19,7 @@ public class VolumeWindow extends Window { private AudioData music; public VolumeWindow(String title, Skin skin, Preferences prefs) { - super(title, skin); + super(title, skin, "tinted"); this.prefs = prefs; setSize(360f, 100f);