Implemented skinnable theme songs.
Plays a theme song when opsu! starts (can be disabled in options). The default song is "welcome to osu!" by nekodex, uploaded by CyberKitsune. To change the song, place a new "theme.osu" in the skins folder and edit the file name, metadata, and song length (at minimum). Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -293,11 +293,13 @@ public class MainMenu extends BasicGameState {
|
||||
else if (!MusicController.isTrackLoading())
|
||||
MusicController.resume();
|
||||
} else if (musicNext.contains(x, y)) {
|
||||
boolean isTheme = MusicController.isThemePlaying();
|
||||
SongMenu menu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
|
||||
OsuGroupNode node = menu.setFocus(Opsu.groups.getRandomNode(), -1, true);
|
||||
if (node != null)
|
||||
if (node != null && !isTheme)
|
||||
previous.add(node.index);
|
||||
if (Options.isDynamicBackgroundEnabled())
|
||||
if (Options.isDynamicBackgroundEnabled() &&
|
||||
MusicController.getOsuFile() != null && !MusicController.isThemePlaying())
|
||||
bgAlpha = 0f;
|
||||
} else if (musicPrevious.contains(x, y)) {
|
||||
if (!previous.isEmpty()) {
|
||||
|
||||
@@ -83,6 +83,11 @@ public class Options extends BasicGameState {
|
||||
*/
|
||||
public static final String FONT_NAME = "kochi-gothic.ttf";
|
||||
|
||||
/**
|
||||
* The theme song OsuFile file name.
|
||||
*/
|
||||
public static final String OSU_THEME_NAME = "theme.osu";
|
||||
|
||||
/**
|
||||
* The beatmap directory.
|
||||
*/
|
||||
@@ -134,7 +139,8 @@ public class Options extends BasicGameState {
|
||||
DISABLE_SOUNDS,
|
||||
KEY_LEFT,
|
||||
KEY_RIGHT,
|
||||
SHOW_UNICODE;
|
||||
SHOW_UNICODE,
|
||||
ENABLE_THEME_SONG;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -190,7 +196,8 @@ public class Options extends BasicGameState {
|
||||
GameOption.EFFECT_VOLUME,
|
||||
GameOption.HITSOUND_VOLUME,
|
||||
GameOption.MUSIC_OFFSET,
|
||||
GameOption.DISABLE_SOUNDS
|
||||
GameOption.DISABLE_SOUNDS,
|
||||
GameOption.ENABLE_THEME_SONG
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -344,6 +351,11 @@ public class Options extends BasicGameState {
|
||||
*/
|
||||
private static boolean ignoreBeatmapSkins = false;
|
||||
|
||||
/**
|
||||
* Whether or not to play the theme song.
|
||||
*/
|
||||
private static boolean themeSongEnabled = true;
|
||||
|
||||
/**
|
||||
* Fixed difficulty overrides.
|
||||
*/
|
||||
@@ -631,6 +643,9 @@ public class Options extends BasicGameState {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ENABLE_THEME_SONG:
|
||||
themeSongEnabled = !themeSongEnabled;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -938,6 +953,12 @@ public class Options extends BasicGameState {
|
||||
"Press CTRL+L while playing to load a checkpoint, and CTRL+S to set one."
|
||||
);
|
||||
break;
|
||||
case ENABLE_THEME_SONG:
|
||||
drawOption(pos, "Enable Theme Song",
|
||||
themeSongEnabled ? "Yes" : "No",
|
||||
"Whether to play the theme song upon starting opsu!"
|
||||
);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1168,6 +1189,12 @@ public class Options extends BasicGameState {
|
||||
*/
|
||||
public static boolean useUnicodeMetadata() { return showUnicode; }
|
||||
|
||||
/**
|
||||
* Returns whether or not to play the theme song.
|
||||
* @return true if enabled
|
||||
*/
|
||||
public static boolean isThemSongEnabled() { return themeSongEnabled; }
|
||||
|
||||
/**
|
||||
* Sets the track checkpoint time, if within bounds.
|
||||
* @param time the track position (in ms)
|
||||
@@ -1410,6 +1437,9 @@ public class Options extends BasicGameState {
|
||||
case "Checkpoint":
|
||||
setCheckpoint(Integer.parseInt(value));
|
||||
break;
|
||||
case "MenuMusic":
|
||||
themeSongEnabled = Boolean.parseBoolean(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@@ -1501,6 +1531,8 @@ public class Options extends BasicGameState {
|
||||
writer.newLine();
|
||||
writer.write(String.format("Checkpoint = %d", checkpoint));
|
||||
writer.newLine();
|
||||
writer.write(String.format("MenuMusic = %b", themeSongEnabled));
|
||||
writer.newLine();
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
Log.error(String.format("Failed to write to file '%s'.", OPTIONS_FILE.getAbsolutePath()), e);
|
||||
|
||||
@@ -501,6 +501,10 @@ public class SongMenu extends BasicGameState {
|
||||
public void enter(GameContainer container, StateBasedGame game)
|
||||
throws SlickException {
|
||||
Display.setTitle(game.getTitle());
|
||||
|
||||
// stop playing the theme song
|
||||
if (MusicController.isThemePlaying() && focusNode != null)
|
||||
MusicController.play(focusNode.osuFiles.get(focusNode.osuFileIndex), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package itdelatrisu.opsu.states;
|
||||
|
||||
import itdelatrisu.opsu.MusicController;
|
||||
import itdelatrisu.opsu.Opsu;
|
||||
import itdelatrisu.opsu.OsuParser;
|
||||
import itdelatrisu.opsu.OszUnpacker;
|
||||
@@ -140,6 +141,10 @@ public class Splash extends BasicGameState {
|
||||
Opsu.groups.init();
|
||||
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).setFocus(Opsu.groups.getRandomNode(), -1, true);
|
||||
|
||||
// play the theme song
|
||||
if (Options.isThemSongEnabled())
|
||||
MusicController.playThemeSong();
|
||||
|
||||
game.enterState(Opsu.STATE_MAINMENU);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user