diff --git a/res/epiwarning.png b/res/epiwarning.png new file mode 100644 index 00000000..be859feb Binary files /dev/null and b/res/epiwarning.png differ diff --git a/src/itdelatrisu/opsu/GameImage.java b/src/itdelatrisu/opsu/GameImage.java index 6e366f94..1d46cdd4 100644 --- a/src/itdelatrisu/opsu/GameImage.java +++ b/src/itdelatrisu/opsu/GameImage.java @@ -41,6 +41,7 @@ public enum GameImage { CURSOR_TRAIL_OLD ("cursortrail2", "png", false, false), // custom // Game + EPILEPSY_WARNING ("epiwarning", "png"), SECTION_PASS ("section-pass", "png"), SECTION_FAIL ("section-fail", "png"), WARNINGARROW ("play-warningarrow", "png"), diff --git a/src/itdelatrisu/opsu/Options.java b/src/itdelatrisu/opsu/Options.java index 78c9de77..cb7fbdc9 100644 --- a/src/itdelatrisu/opsu/Options.java +++ b/src/itdelatrisu/opsu/Options.java @@ -515,6 +515,15 @@ public String getValueString() { return String.valueOf(val * 100); } }, + EPILEPSY_WARNING ("Epilepsy warning image", "EpiWarn", "Show a little warning for flashing colours in the beginning", 20, 0, 20) { + @Override + public String getValueString() { + if (val == 0) { + return "Disabled"; + } + return String.valueOf(val * 100); + } + }, LOAD_HD_IMAGES ("Load HD Images", "LoadHDImages", String.format("Loads HD (%s) images when available. Increases memory usage and loading times.", GameImage.HD_SUFFIX), true), FIXED_CS ("Fixed Circle Size (CS)", "FixedCS", "Determines the size of circles and sliders.", 0, 0, 100) { @Override @@ -1710,6 +1719,7 @@ public static boolean setCheckpoint(int time) { public static int getMapStartDelay() { return GameOption.MAP_START_DELAY.getIntegerValue() * 100; } public static int getMapEndDelay() { return GameOption.MAP_END_DELAY.getIntegerValue() * 100; } + public static int getEpilepsyWarningLength() { return GameOption.EPILEPSY_WARNING.getIntegerValue() * 100; } /** * Returns whether or not to load HD (@2x) images. diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java index 311d9cb8..cd9b9329 100644 --- a/src/itdelatrisu/opsu/states/Game.java +++ b/src/itdelatrisu/opsu/states/Game.java @@ -259,6 +259,11 @@ public enum Restart { private int mirrorFrom; private int mirrorTo; + private Image epiImg; + private float epiImgX; + private float epiImgY; + private int epiImgTime; + /** Music position bar background colors. */ private static final Color MUSICBAR_NORMAL = new Color(12, 9, 10, 0.25f), @@ -395,6 +400,18 @@ else if (deathTime > -1) // "Easy" mod: health bar increasing } } + // epilepsy warning + if (epiImgTime > 0) { + if (epiImgTime < 200) { + // fade out + Color c = new Color(Color.white); + c.a = epiImgTime / 200f; + epiImg.draw(epiImgX, epiImgY, c); + } else { + epiImg.draw(epiImgX, epiImgY); + } + } + if (GameMod.FLASHLIGHT.isActive()) Graphics.setCurrent(g); @@ -699,6 +716,9 @@ public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { UI.update(delta); Pippi.update(delta); + if (epiImgTime > 0) { + epiImgTime -= delta; + } yugecin.opsudance.spinners.Spinner.update(delta); int mouseX = input.getMouseX(), mouseY = input.getMouseY(); sbOverlay.update(mouseX, mouseY); @@ -1307,6 +1327,17 @@ public void enter(GameContainer container, StateBasedGame game) // restart the game if (restart != Restart.FALSE) { + + // load epilepsy warning img + epiImgTime = Options.getEpilepsyWarningLength(); + if (epiImgTime > 0) { + epiImg = GameImage.EPILEPSY_WARNING.getImage(); + float desWidth = container.getWidth() / 2; + epiImg = epiImg.getScaledCopy(desWidth / epiImg.getWidth()); + epiImgX = (container.getWidth() - epiImg.getWidth()) / 2; + epiImgY = (container.getHeight() - epiImg.getHeight()) / 2; + } + // load mods if (isReplay) { previousMods = GameMod.getModState(); @@ -1443,6 +1474,7 @@ else if (hitObject.isSpinner()) this.leadInTime = Math.max(leadIntime, this.leadInTime); } } + this.leadInTime += epiImgTime; SoundController.mute(false); } diff --git a/src/itdelatrisu/opsu/states/OptionsMenu.java b/src/itdelatrisu/opsu/states/OptionsMenu.java index 9fee18a1..817933dd 100644 --- a/src/itdelatrisu/opsu/states/OptionsMenu.java +++ b/src/itdelatrisu/opsu/states/OptionsMenu.java @@ -90,6 +90,7 @@ private enum OptionTab { GameOption.SHOW_HIT_ERROR_BAR, GameOption.MAP_START_DELAY, GameOption.MAP_END_DELAY, + GameOption.EPILEPSY_WARNING, }), INPUT ("Input", new GameOption[] { GameOption.KEY_LEFT,