Skip to content

Commit

Permalink
Game ranking screen fixes.
Browse files Browse the repository at this point in the history
- Show retry button only when appropriate (e.g. not when viewing replays or when playing with "Auto" enabled).
- Watching a (fake) "replay" with "Auto" enabled will actually just call the "retry" code now.

Signed-off-by: Jeffrey Han <[email protected]>
  • Loading branch information
itdelatrisu committed Aug 21, 2015
1 parent ae149a6 commit 130f9bf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
14 changes: 10 additions & 4 deletions src/itdelatrisu/opsu/GameData.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public HitObjectResult(int time, int result, float x, float y, Color color,
private Replay replay;

/** Whether this object is used for gameplay (true) or score viewing (false). */
private boolean gameplay;
private boolean isGameplay;

/** Container dimensions. */
private int width, height;
Expand All @@ -337,7 +337,7 @@ public HitObjectResult(int time, int result, float x, float y, Color color,
public GameData(int width, int height) {
this.width = width;
this.height = height;
this.gameplay = true;
this.isGameplay = true;

clear();
}
Expand All @@ -353,7 +353,7 @@ public GameData(int width, int height) {
public GameData(ScoreData s, int width, int height) {
this.width = width;
this.height = height;
this.gameplay = false;
this.isGameplay = false;

this.scoreData = s;
this.score = s.score;
Expand Down Expand Up @@ -1468,7 +1468,13 @@ public Replay getReplay(ReplayFrame[] frames, Beatmap beatmap) {
* Returns whether or not this object is used for gameplay.
* @return true if gameplay, false if score viewing
*/
public boolean isGameplay() { return gameplay; }
public boolean isGameplay() { return isGameplay; }

/**
* Sets whether or not this object is used for gameplay.
* @return true if gameplay, false if score viewing
*/
public void setGameplay(boolean gameplay) { this.isGameplay = gameplay; }

/**
* Adds the hit into the list of hit error information.
Expand Down
3 changes: 3 additions & 0 deletions src/itdelatrisu/opsu/states/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ else if (replayFrames != null) {
r.save();
}
ScoreData score = data.getScoreData(beatmap);
data.setGameplay(!isReplay);

// add score to database
if (!unranked && !isReplay)
Expand Down Expand Up @@ -1111,6 +1112,8 @@ public void enter(GameContainer container, StateBasedGame game)
GameMod.loadModState(replay.mods);
}

data.setGameplay(true);

// check restart state
if (restart == Restart.NEW) {
// new game
Expand Down
12 changes: 8 additions & 4 deletions src/itdelatrisu/opsu/states/GameRanking.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import itdelatrisu.opsu.GameData;
import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.Utils;
Expand Down Expand Up @@ -113,7 +114,7 @@ public void render(GameContainer container, StateBasedGame game, Graphics g)

// buttons
replayButton.draw();
if (data.isGameplay())
if (data.isGameplay() && !GameMod.AUTO.isActive())
retryButton.draw();
UI.getBackButton().draw();

Expand Down Expand Up @@ -175,7 +176,8 @@ public void mousePressed(int button, int x, int y) {
// replay
Game gameState = (Game) game.getState(Opsu.STATE_GAME);
boolean returnToGame = false;
if (replayButton.contains(x, y)) {
boolean replayButtonPressed = replayButton.contains(x, y);
if (replayButtonPressed && !(data.isGameplay() && GameMod.AUTO.isActive())) {
Replay r = data.getReplay(null, null);
if (r != null) {
try {
Expand All @@ -194,7 +196,9 @@ public void mousePressed(int button, int x, int y) {
}

// retry
else if (data.isGameplay() && retryButton.contains(x, y)) {
else if (data.isGameplay() &&
(!GameMod.AUTO.isActive() && retryButton.contains(x, y)) ||
(GameMod.AUTO.isActive() && replayButtonPressed)) {
gameState.setReplay(null);
gameState.setRestart(Game.Restart.MANUAL);
returnToGame = true;
Expand All @@ -221,7 +225,7 @@ public void enter(GameContainer container, StateBasedGame game)
} else {
SoundController.playSound(SoundEffect.APPLAUSE);
retryButton.resetHover();
replayButton.setY(replayY);
replayButton.setY(!GameMod.AUTO.isActive() ? replayY : retryY);
}
replayButton.resetHover();
}
Expand Down

0 comments on commit 130f9bf

Please sign in to comment.