Skip to content
This repository has been archived by the owner on Nov 11, 2022. It is now read-only.

Commit

Permalink
add epilepsy warning img
Browse files Browse the repository at this point in the history
  • Loading branch information
yugecin committed Nov 16, 2016
1 parent 0d0cf47 commit a1a9dde
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
Binary file added res/epiwarning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/itdelatrisu/opsu/GameImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
10 changes: 10 additions & 0 deletions src/itdelatrisu/opsu/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
32 changes: 32 additions & 0 deletions src/itdelatrisu/opsu/states/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -1443,6 +1474,7 @@ else if (hitObject.isSpinner())
this.leadInTime = Math.max(leadIntime, this.leadInTime);
}
}
this.leadInTime += epiImgTime;
SoundController.mute(false);
}

Expand Down
1 change: 1 addition & 0 deletions src/itdelatrisu/opsu/states/OptionsMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a1a9dde

Please sign in to comment.