Replaced all linear fade-out transitions with eased transitions.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2015-11-19 17:47:46 -05:00
parent fb789c8fc5
commit ba240797d8
11 changed files with 123 additions and 41 deletions

View File

@ -43,13 +43,12 @@ import java.net.InetAddress;
import java.net.ServerSocket; import java.net.ServerSocket;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer; import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Input; import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException; import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.StateBasedGame; import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.state.transition.FadeInTransition; import org.newdawn.slick.state.transition.FadeInTransition;
import org.newdawn.slick.state.transition.FadeOutTransition; import org.newdawn.slick.state.transition.EasedFadeOutTransition;
import org.newdawn.slick.util.DefaultLogSystem; import org.newdawn.slick.util.DefaultLogSystem;
import org.newdawn.slick.util.FileSystemLocation; import org.newdawn.slick.util.FileSystemLocation;
import org.newdawn.slick.util.Log; import org.newdawn.slick.util.Log;
@ -238,7 +237,7 @@ public class Opsu extends StateBasedGame {
if (UI.getCursor().isBeatmapSkinned()) if (UI.getCursor().isBeatmapSkinned())
UI.getCursor().reset(); UI.getCursor().reset();
songMenu.resetGameDataOnLoad(); songMenu.resetGameDataOnLoad();
this.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); this.enterState(Opsu.STATE_SONGMENU, new EasedFadeOutTransition(), new FadeInTransition());
return false; return false;
} }

View File

@ -46,8 +46,8 @@ import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException; import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState; import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame; import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.state.transition.EmptyTransition;
import org.newdawn.slick.state.transition.FadeInTransition; import org.newdawn.slick.state.transition.FadeInTransition;
import org.newdawn.slick.state.transition.EmptyTransition;
/** /**
* Generic button menu state. * Generic button menu state.
@ -456,7 +456,7 @@ public class ButtonMenu extends BasicGameState {
@Override @Override
public void click(GameContainer container, StateBasedGame game) { public void click(GameContainer container, StateBasedGame game) {
SoundController.playSound(SoundEffect.MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
game.enterState(Opsu.STATE_MAINMENU, new EmptyTransition(), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_MAINMENU, new EmptyTransition(), new FadeInTransition());
} }
}, },
CLEAR_SCORES ("Clear local scores", Color.magenta) { CLEAR_SCORES ("Clear local scores", Color.magenta) {
@ -465,7 +465,7 @@ public class ButtonMenu extends BasicGameState {
SoundController.playSound(SoundEffect.MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode(); BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode();
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.BEATMAP, node); ((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.BEATMAP, node);
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition());
} }
}, },
DELETE ("Delete...", Color.red) { DELETE ("Delete...", Color.red) {
@ -483,7 +483,7 @@ public class ButtonMenu extends BasicGameState {
@Override @Override
public void click(GameContainer container, StateBasedGame game) { public void click(GameContainer container, StateBasedGame game) {
SoundController.playSound(SoundEffect.MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition());
} }
}, },
DELETE_CONFIRM ("Yes, delete this beatmap!", Color.red) { DELETE_CONFIRM ("Yes, delete this beatmap!", Color.red) {
@ -492,7 +492,7 @@ public class ButtonMenu extends BasicGameState {
SoundController.playSound(SoundEffect.MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode(); BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode();
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.BEATMAP_DELETE_CONFIRM, node); ((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.BEATMAP_DELETE_CONFIRM, node);
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition());
} }
}, },
DELETE_GROUP ("Yes, delete all difficulties!", Color.red) { DELETE_GROUP ("Yes, delete all difficulties!", Color.red) {
@ -507,7 +507,7 @@ public class ButtonMenu extends BasicGameState {
SoundController.playSound(SoundEffect.MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode(); BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode();
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.BEATMAP_DELETE_SELECT, node); ((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.BEATMAP_DELETE_SELECT, node);
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition());
} }
}, },
CANCEL_DELETE ("Nooooo! I didn't mean to!", Color.gray) { CANCEL_DELETE ("Nooooo! I didn't mean to!", Color.gray) {
@ -521,7 +521,7 @@ public class ButtonMenu extends BasicGameState {
public void click(GameContainer container, StateBasedGame game) { public void click(GameContainer container, StateBasedGame game) {
SoundController.playSound(SoundEffect.MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.RELOAD); ((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.RELOAD);
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition());
} }
}, },
RELOAD_CANCEL ("Cancel", Color.red) { RELOAD_CANCEL ("Cancel", Color.red) {
@ -536,7 +536,7 @@ public class ButtonMenu extends BasicGameState {
SoundController.playSound(SoundEffect.MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
ScoreData scoreData = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getScoreData(); ScoreData scoreData = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getScoreData();
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.SCORE, scoreData); ((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.SCORE, scoreData);
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition());
} }
}, },
CLOSE ("Close", Color.gray) { CLOSE ("Close", Color.gray) {

View File

@ -62,8 +62,8 @@ import org.newdawn.slick.SlickException;
import org.newdawn.slick.gui.TextField; import org.newdawn.slick.gui.TextField;
import org.newdawn.slick.state.BasicGameState; import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame; import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.state.transition.EasedFadeOutTransition;
import org.newdawn.slick.state.transition.FadeInTransition; import org.newdawn.slick.state.transition.FadeInTransition;
import org.newdawn.slick.state.transition.FadeOutTransition;
import org.newdawn.slick.util.Log; import org.newdawn.slick.util.Log;
/** /**
@ -625,7 +625,7 @@ public class DownloadsMenu extends BasicGameState {
if (UI.getBackButton().contains(x, y)) { if (UI.getBackButton().contains(x, y)) {
SoundController.playSound(SoundEffect.MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
((MainMenu) game.getState(Opsu.STATE_MAINMENU)).reset(); ((MainMenu) game.getState(Opsu.STATE_MAINMENU)).reset();
game.enterState(Opsu.STATE_MAINMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_MAINMENU, new EasedFadeOutTransition(), new FadeInTransition());
return; return;
} }
@ -893,7 +893,7 @@ public class DownloadsMenu extends BasicGameState {
// return to main menu // return to main menu
SoundController.playSound(SoundEffect.MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
((MainMenu) game.getState(Opsu.STATE_MAINMENU)).reset(); ((MainMenu) game.getState(Opsu.STATE_MAINMENU)).reset();
game.enterState(Opsu.STATE_MAINMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_MAINMENU, new EasedFadeOutTransition(), new FadeInTransition());
} }
break; break;
case Input.KEY_ENTER: case Input.KEY_ENTER:

View File

@ -70,9 +70,9 @@ import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState; import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame; import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.state.transition.DelayedFadeOutTransition; import org.newdawn.slick.state.transition.DelayedFadeOutTransition;
import org.newdawn.slick.state.transition.EasedFadeOutTransition;
import org.newdawn.slick.state.transition.EmptyTransition; import org.newdawn.slick.state.transition.EmptyTransition;
import org.newdawn.slick.state.transition.FadeInTransition; import org.newdawn.slick.state.transition.FadeInTransition;
import org.newdawn.slick.state.transition.FadeOutTransition;
/** /**
* "Game" state. * "Game" state.
@ -767,7 +767,7 @@ public class Game extends BasicGameState {
if (!unranked && !isReplay) if (!unranked && !isReplay)
ScoreDB.addScore(score); ScoreDB.addScore(score);
game.enterState(Opsu.STATE_GAMERANKING, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_GAMERANKING, new EasedFadeOutTransition(), new FadeInTransition());
} }
return; return;
} }
@ -813,7 +813,7 @@ public class Game extends BasicGameState {
} }
if (MusicController.isPlaying() || isLeadIn()) if (MusicController.isPlaying() || isLeadIn())
pauseTime = trackPosition; pauseTime = trackPosition;
game.enterState(Opsu.STATE_GAMEPAUSEMENU, new EmptyTransition(), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_GAMEPAUSEMENU, new EmptyTransition(), new FadeInTransition());
} }
// drain health // drain health
@ -843,7 +843,7 @@ public class Game extends BasicGameState {
// fade to pause menu // fade to pause menu
game.enterState(Opsu.STATE_GAMEPAUSEMENU, game.enterState(Opsu.STATE_GAMEPAUSEMENU,
new DelayedFadeOutTransition(Color.black, MUSIC_FADEOUT_TIME, MUSIC_FADEOUT_TIME - LOSE_FADEOUT_TIME), new DelayedFadeOutTransition(Color.black, MUSIC_FADEOUT_TIME, MUSIC_FADEOUT_TIME - LOSE_FADEOUT_TIME),
new FadeInTransition(Color.black)); new FadeInTransition());
} }
} }
} }
@ -901,7 +901,7 @@ public class Game extends BasicGameState {
} }
if (MusicController.isPlaying() || isLeadIn()) if (MusicController.isPlaying() || isLeadIn())
pauseTime = trackPosition; pauseTime = trackPosition;
game.enterState(Opsu.STATE_GAMEPAUSEMENU, new EmptyTransition(), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_GAMEPAUSEMENU, new EmptyTransition(), new FadeInTransition());
break; break;
case Input.KEY_SPACE: case Input.KEY_SPACE:
// skip intro // skip intro
@ -1028,7 +1028,7 @@ public class Game extends BasicGameState {
} }
if (MusicController.isPlaying() || isLeadIn()) if (MusicController.isPlaying() || isLeadIn())
pauseTime = trackPosition; pauseTime = trackPosition;
game.enterState(Opsu.STATE_GAMEPAUSEMENU, new EmptyTransition(), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_GAMEPAUSEMENU, new EmptyTransition(), new FadeInTransition());
return; return;
} }

View File

@ -38,7 +38,7 @@ import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState; import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame; import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.state.transition.FadeInTransition; import org.newdawn.slick.state.transition.FadeInTransition;
import org.newdawn.slick.state.transition.FadeOutTransition; import org.newdawn.slick.state.transition.EasedFadeOutTransition;
/** /**
* "Game Pause/Fail" state. * "Game Pause/Fail" state.
@ -128,7 +128,7 @@ public class GamePauseMenu extends BasicGameState {
MusicController.playAt(MusicController.getBeatmap().previewTime, true); MusicController.playAt(MusicController.getBeatmap().previewTime, true);
if (UI.getCursor().isBeatmapSkinned()) if (UI.getCursor().isBeatmapSkinned())
UI.getCursor().reset(); UI.getCursor().reset();
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new EasedFadeOutTransition(), new FadeInTransition());
} else { } else {
SoundController.playSound(SoundEffect.MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
gameState.setRestart(Game.Restart.FALSE); gameState.setRestart(Game.Restart.FALSE);
@ -178,7 +178,7 @@ public class GamePauseMenu extends BasicGameState {
if (UI.getCursor().isBeatmapSkinned()) if (UI.getCursor().isBeatmapSkinned())
UI.getCursor().reset(); UI.getCursor().reset();
MusicController.setPitch(1.0f); MusicController.setPitch(1.0f);
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new EasedFadeOutTransition(), new FadeInTransition());
} }
} }

View File

@ -36,7 +36,6 @@ import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import org.lwjgl.opengl.Display; import org.lwjgl.opengl.Display;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer; import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics; import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image; import org.newdawn.slick.Image;
@ -45,7 +44,7 @@ import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState; import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame; import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.state.transition.FadeInTransition; import org.newdawn.slick.state.transition.FadeInTransition;
import org.newdawn.slick.state.transition.FadeOutTransition; import org.newdawn.slick.state.transition.EasedFadeOutTransition;
import org.newdawn.slick.util.Log; import org.newdawn.slick.util.Log;
/** /**
@ -207,7 +206,7 @@ public class GameRanking extends BasicGameState {
Beatmap beatmap = MusicController.getBeatmap(); Beatmap beatmap = MusicController.getBeatmap();
gameState.loadBeatmap(beatmap); gameState.loadBeatmap(beatmap);
SoundController.playSound(SoundEffect.MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
game.enterState(Opsu.STATE_GAME, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_GAME, new EasedFadeOutTransition(), new FadeInTransition());
return; return;
} }
} }
@ -248,7 +247,7 @@ public class GameRanking extends BasicGameState {
songMenu.resetGameDataOnLoad(); songMenu.resetGameDataOnLoad();
if (UI.getCursor().isBeatmapSkinned()) if (UI.getCursor().isBeatmapSkinned())
UI.getCursor().reset(); UI.getCursor().reset();
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new EasedFadeOutTransition(), new FadeInTransition());
} }
/** /**

View File

@ -54,7 +54,7 @@ import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState; import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame; import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.state.transition.FadeInTransition; import org.newdawn.slick.state.transition.FadeInTransition;
import org.newdawn.slick.state.transition.FadeOutTransition; import org.newdawn.slick.state.transition.EasedFadeOutTransition;
/** /**
* "Main Menu" state. * "Main Menu" state.
@ -498,7 +498,7 @@ public class MainMenu extends BasicGameState {
// downloads button actions // downloads button actions
if (downloadsButton.contains(x, y)) { if (downloadsButton.contains(x, y)) {
SoundController.playSound(SoundEffect.MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
game.enterState(Opsu.STATE_DOWNLOADSMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_DOWNLOADSMENU, new EasedFadeOutTransition(), new FadeInTransition());
return; return;
} }
@ -586,7 +586,7 @@ public class MainMenu extends BasicGameState {
break; break;
case Input.KEY_D: case Input.KEY_D:
SoundController.playSound(SoundEffect.MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
game.enterState(Opsu.STATE_DOWNLOADSMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_DOWNLOADSMENU, new EasedFadeOutTransition(), new FadeInTransition());
break; break;
case Input.KEY_R: case Input.KEY_R:
nextTrack(); nextTrack();
@ -671,6 +671,6 @@ public class MainMenu extends BasicGameState {
((DownloadsMenu) game.getState(Opsu.STATE_DOWNLOADSMENU)).notifyOnLoad("Download some beatmaps to get started!"); ((DownloadsMenu) game.getState(Opsu.STATE_DOWNLOADSMENU)).notifyOnLoad("Download some beatmaps to get started!");
state = Opsu.STATE_DOWNLOADSMENU; state = Opsu.STATE_DOWNLOADSMENU;
} }
game.enterState(state, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(state, new EasedFadeOutTransition(), new FadeInTransition());
} }
} }

View File

@ -42,8 +42,8 @@ import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException; import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState; import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame; import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.state.transition.EmptyTransition;
import org.newdawn.slick.state.transition.FadeInTransition; import org.newdawn.slick.state.transition.FadeInTransition;
import org.newdawn.slick.state.transition.EmptyTransition;
/** /**
* "Game Options" state. * "Game Options" state.
@ -297,7 +297,7 @@ public class OptionsMenu extends BasicGameState {
// back // back
if (UI.getBackButton().contains(x, y)) { if (UI.getBackButton().contains(x, y)) {
SoundController.playSound(SoundEffect.MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition());
return; return;
} }
@ -375,7 +375,7 @@ public class OptionsMenu extends BasicGameState {
switch (key) { switch (key) {
case Input.KEY_ESCAPE: case Input.KEY_ESCAPE:
SoundController.playSound(SoundEffect.MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition());
break; break;
case Input.KEY_F5: case Input.KEY_F5:
// restart application // restart application

View File

@ -72,9 +72,9 @@ import org.newdawn.slick.SpriteSheet;
import org.newdawn.slick.gui.TextField; import org.newdawn.slick.gui.TextField;
import org.newdawn.slick.state.BasicGameState; import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame; import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.state.transition.EmptyTransition;
import org.newdawn.slick.state.transition.FadeInTransition; import org.newdawn.slick.state.transition.FadeInTransition;
import org.newdawn.slick.state.transition.FadeOutTransition; import org.newdawn.slick.state.transition.EasedFadeOutTransition;
import org.newdawn.slick.state.transition.EmptyTransition;
/** /**
* "Song Selection" state. * "Song Selection" state.
@ -773,7 +773,7 @@ public class SongMenu extends BasicGameState {
if (UI.getBackButton().contains(x, y)) { if (UI.getBackButton().contains(x, y)) {
SoundController.playSound(SoundEffect.MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
((MainMenu) game.getState(Opsu.STATE_MAINMENU)).reset(); ((MainMenu) game.getState(Opsu.STATE_MAINMENU)).reset();
game.enterState(Opsu.STATE_MAINMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_MAINMENU, new EasedFadeOutTransition(), new FadeInTransition());
return; return;
} }
@ -789,7 +789,7 @@ public class SongMenu extends BasicGameState {
return; return;
} else if (selectOptionsButton.contains(x, y)) { } else if (selectOptionsButton.contains(x, y)) {
SoundController.playSound(SoundEffect.MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
game.enterState(Opsu.STATE_OPTIONSMENU, new EmptyTransition(), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_OPTIONSMENU, new EmptyTransition(), new FadeInTransition());
return; return;
} }
@ -863,7 +863,7 @@ public class SongMenu extends BasicGameState {
// view score // view score
GameData data = new GameData(focusScores[rank], container.getWidth(), container.getHeight()); GameData data = new GameData(focusScores[rank], container.getWidth(), container.getHeight());
((GameRanking) game.getState(Opsu.STATE_GAMERANKING)).setGameData(data); ((GameRanking) game.getState(Opsu.STATE_GAMERANKING)).setGameData(data);
game.enterState(Opsu.STATE_GAMERANKING, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_GAMERANKING, new EasedFadeOutTransition(), new FadeInTransition());
} else { } else {
// score management // score management
((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).setMenuState(MenuState.SCORE, focusScores[rank]); ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).setMenuState(MenuState.SCORE, focusScores[rank]);
@ -895,7 +895,7 @@ public class SongMenu extends BasicGameState {
// return to main menu // return to main menu
SoundController.playSound(SoundEffect.MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
((MainMenu) game.getState(Opsu.STATE_MAINMENU)).reset(); ((MainMenu) game.getState(Opsu.STATE_MAINMENU)).reset();
game.enterState(Opsu.STATE_MAINMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_MAINMENU, new EasedFadeOutTransition(), new FadeInTransition());
} }
break; break;
case Input.KEY_F1: case Input.KEY_F1:
@ -1611,6 +1611,6 @@ public class SongMenu extends BasicGameState {
gameState.loadBeatmap(beatmap); gameState.loadBeatmap(beatmap);
gameState.setRestart(Game.Restart.NEW); gameState.setRestart(Game.Restart.NEW);
gameState.setReplay(null); gameState.setReplay(null);
game.enterState(Opsu.STATE_GAME, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_GAME, new EasedFadeOutTransition(), new FadeInTransition());
} }
} }

View File

@ -39,6 +39,7 @@ public class DelayedFadeOutTransition implements Transition {
* @param color The color we're going to fade out to * @param color The color we're going to fade out to
* @param fadeTime The time it takes the fade to occur * @param fadeTime The time it takes the fade to occur
* @param delay The time before the fade starts (must be less than {@code fadeTime}) * @param delay The time before the fade starts (must be less than {@code fadeTime})
* @throws IllegalArgumentException if {@code delay} is greater than {@code fadeTime}
*/ */
public DelayedFadeOutTransition(Color color, int fadeTime, int delay) { public DelayedFadeOutTransition(Color color, int fadeTime, int delay) {
if (delay > fadeTime) if (delay > fadeTime)

View File

@ -0,0 +1,83 @@
package org.newdawn.slick.state.transition;
import itdelatrisu.opsu.ui.animations.AnimationEquation;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.state.GameState;
import org.newdawn.slick.state.StateBasedGame;
/**
* A transition to fade out to a given colour using an easing function.
*
* @author kevin (base)
*/
public class EasedFadeOutTransition implements Transition {
/** The color to fade to */
private final Color color;
/** The time it takes the fade to happen */
private final int fadeTime;
/** The easing function */
private final AnimationEquation eq;
/** The transition progress */
private float t = 0f;
/**
* Create a new eased fade out transition.
*/
public EasedFadeOutTransition() { this(Color.black, 500, AnimationEquation.OUT_QUART); }
/**
* Create a new eased fade out transition.
*
* @param color The color we're going to fade out to
*/
public EasedFadeOutTransition(Color color) { this(color, 500, AnimationEquation.OUT_QUART); }
/**
* Create a new eased fade out transition.
*
* @param color The color we're going to fade out to
* @param fadeTime The time it takes the fade to occur
*/
public EasedFadeOutTransition(Color color, int fadeTime) { this(color, fadeTime, AnimationEquation.OUT_QUART); }
/**
* Create a new eased fade out transition.
*
* @param color The color we're going to fade out to
* @param fadeTime The time it takes the fade to occur
* @param eq The easing function to use
*/
public EasedFadeOutTransition(Color color, int fadeTime, AnimationEquation eq) {
this.color = new Color(color);
this.color.a = 0;
this.fadeTime = fadeTime;
this.eq = eq;
}
@Override
public boolean isComplete() { return (color.a >= 1); }
@Override
public void postRender(StateBasedGame game, GameContainer container, Graphics g) {
Color old = g.getColor();
g.setColor(color);
g.fillRect(0, 0, container.getWidth() * 2, container.getHeight() * 2);
g.setColor(old);
}
@Override
public void update(StateBasedGame game, GameContainer container, int delta) {
t += delta * (1.0f / fadeTime);
float alpha = t > 1f ? 1f : eq.calc(t);
color.a = alpha;
}
@Override
public void preRender(StateBasedGame game, GameContainer container, Graphics g) {}
@Override
public void init(GameState firstState, GameState secondState) {}
}