Skip to content

Commit

Permalink
Added support for default playfield image and an override option.
Browse files Browse the repository at this point in the history
- Credits: https://osu.ppy.sh/forum/t/198483 (image by Xiaounlimited)

Other changes:
- Added "Unranked" text image, currently displayed for "Auto" mod plays only (image by XinCrin).
Signed-off-by: Jeffrey Han <[email protected]>
  • Loading branch information
itdelatrisu committed Jul 3, 2014
1 parent 03be293 commit f195ffb
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 5 deletions.
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The images included in opsu! belong to their respective authors.
* Garygoh884 - "Skylanders 1.3b"
* Misaki Louize - "Yukino II"
* Alic1a - "AL's IA -Blue-"
* Xiaounlimited - "Nexus Ivory"
* pictuga - "osu! web"
* sherrie__fay
* kouyang
Expand Down
Binary file added res/play-unranked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/playfield.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 34 additions & 1 deletion src/itdelatrisu/opsu/states/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,17 @@ public class Game extends BasicGameState {
*/
private float pausePulse;

/**
* Default playfield background (optional).
* Overridden by song background unless "ForceDefaultPlayfield" option enabled.
*/
private Image playfield;

/**
* Image displayed during unranked plays.
*/
private Image unrankedImage;

// game-related variables
private GameContainer container;
private StateBasedGame game;
Expand Down Expand Up @@ -251,6 +262,16 @@ public void init(GameContainer container, StateBasedGame game)
// hit circle select
hitCircleSelect = new Image("hitcircleselect.png");

// "unranked" image
unrankedImage = new Image("play-unranked.png");

// playfield background
try {
playfield = new Image("playfield.png").getScaledCopy(width, height);
} catch (Exception e) {
// optional
}

// create the associated GameScore object
score = new GameScore(width, height);
}
Expand All @@ -263,7 +284,14 @@ public void render(GameContainer container, StateBasedGame game, Graphics g)

// background
g.setBackground(Color.black);
osu.drawBG(width, height, Options.getBackgroundDim());
float dimLevel = Options.getBackgroundDim();
if (Options.isDefaultPlayfieldForced() && playfield != null) {
playfield.setAlpha(dimLevel);
playfield.draw();
} else if (!osu.drawBG(width, height, dimLevel) && playfield != null) {
playfield.setAlpha(dimLevel);
playfield.draw();
}

int trackPosition = MusicController.getPosition();
if (pauseTime > -1) // returning from pause screen
Expand Down Expand Up @@ -313,6 +341,8 @@ public void render(GameContainer container, StateBasedGame game, Graphics g)
}
}

if (Options.isModActive(Options.MOD_AUTO))
unrankedImage.drawCentered(width / 2, height * 0.077f);
Utils.drawFPS();
Utils.drawCursor();
return;
Expand Down Expand Up @@ -411,6 +441,9 @@ else if ((hitObject.type & OsuHitObject.TYPE_SPINNER) > 0) {
// draw OsuHitObjectResult objects
score.drawHitResults(trackPosition);

if (Options.isModActive(Options.MOD_AUTO))
unrankedImage.drawCentered(width / 2, height * 0.077f);

// returning from pause screen
if (pauseTime > -1 && pausedMouseX > -1 && pausedMouseY > -1) {
// darken the screen
Expand Down
34 changes: 30 additions & 4 deletions src/itdelatrisu/opsu/states/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ private enum GameOption {
NEW_CURSOR,
DYNAMIC_BACKGROUND,
SHOW_PERFECT_HIT,
BACKGROUND_DIM;
BACKGROUND_DIM,
FORCE_DEFAULT_PLAYFIELD;
};

/**
Expand Down Expand Up @@ -187,6 +188,7 @@ private enum GameOption {
*/
private static final GameOption[] gameplayOptions = {
GameOption.BACKGROUND_DIM,
GameOption.FORCE_DEFAULT_PLAYFIELD,
GameOption.SHOW_HIT_LIGHTING,
GameOption.SHOW_COMBO_BURSTS,
GameOption.SHOW_PERFECT_HIT
Expand Down Expand Up @@ -304,6 +306,11 @@ private enum GameOption {
*/
private static int backgroundDim = 30;

/**
* Whether or not to always display the default playfield background.
*/
private static boolean forceDefaultPlayfield = false;

/**
* Game option coordinate modifiers (for drawing).
*/
Expand Down Expand Up @@ -535,6 +542,9 @@ public void mousePressed(int button, int x, int y) {
case SHOW_PERFECT_HIT:
showPerfectHit = !showPerfectHit;
break;
case FORCE_DEFAULT_PLAYFIELD:
forceDefaultPlayfield = !forceDefaultPlayfield;
break;
default:
break;
}
Expand Down Expand Up @@ -705,6 +715,12 @@ private void drawOption(GameOption option, int pos) {
"Percentage to dim the background image during gameplay."
);
break;
case FORCE_DEFAULT_PLAYFIELD:
drawOption(pos, "Force Default Playfield",
forceDefaultPlayfield ? "Yes" : "No",
"Override the song background with the default playfield background."
);
break;
case SHOW_HIT_LIGHTING:
drawOption(pos, "Show Hit Lighting",
showHitLighting ? "Yes" : "No",
Expand Down Expand Up @@ -733,7 +749,7 @@ private void drawOption(GameOption option, int pos) {
* @param pos the element position
* @param label the option name
* @param value the option value
* @param notes additional notes (optional)
* @param notes additional notes
*/
private void drawOption(int pos, String label, String value, String notes) {
int width = container.getWidth();
Expand All @@ -743,8 +759,7 @@ private void drawOption(int pos, String label, String value, String notes) {
g.setColor(Color.white);
g.drawString(label, width / 30, y);
g.drawString(value, width / 2, y);
if (notes != null)
Utils.FONT_SMALL.drawString(width / 30, y + textHeight, notes);
Utils.FONT_SMALL.drawString(width / 30, y + textHeight, notes);
g.setColor(Utils.COLOR_WHITE_ALPHA);
g.drawLine(0, y + textHeight, width, y + textHeight);
}
Expand Down Expand Up @@ -899,6 +914,12 @@ private static void toggleMod(int mod) {
*/
public static float getBackgroundDim() { return (100 - backgroundDim) / 100f; }

/**
* Returns whether or not to override the song background with the default playfield background.
* @return true if forced
*/
public static boolean isDefaultPlayfieldForced() { return forceDefaultPlayfield; }

/**
* Returns the current beatmap directory.
* If invalid, this will attempt to search for the directory,
Expand Down Expand Up @@ -1020,6 +1041,9 @@ public static void parseOptions() {
if (i >= 0 && i <= 100)
backgroundDim = i;
break;
case "ForceDefaultPlayfield":
forceDefaultPlayfield = Boolean.parseBoolean(value);
break;
case "HitLighting":
showHitLighting = Boolean.parseBoolean(value);
break;
Expand Down Expand Up @@ -1086,6 +1110,8 @@ public static void saveOptions() {
writer.newLine();
writer.write(String.format("DimLevel = %d", backgroundDim));
writer.newLine();
writer.write(String.format("ForceDefaultPlayfield = %b", forceDefaultPlayfield));
writer.newLine();
writer.write(String.format("HitLighting = %b", showHitLighting));
writer.newLine();
writer.write(String.format("ComboBurst = %b", showComboBursts));
Expand Down

0 comments on commit f195ffb

Please sign in to comment.