Skip to content

Commit

Permalink
New theme song.
Browse files Browse the repository at this point in the history
"Rainbows" by Kevin MacLeod.

Some config loading tweaks to make updating the theme song more seamless.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
  • Loading branch information
itdelatrisu committed Dec 22, 2016
1 parent e3276a3 commit 1436f23
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 14 deletions.
5 changes: 3 additions & 2 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ The following projects were referenced in creating opsu!:

Theme Song
----------
The theme song is "On the Bach" by Jingle Punks, from the [YouTube Audio Library]
(https://www.youtube.com/audiolibrary/music).
Rainbows - Kevin MacLeod (incompetech.com)
Licensed under Creative Commons: By Attribution 3.0 License
http://creativecommons.org/licenses/by/3.0/
Binary file added res/theme.mp3
Binary file not shown.
Binary file removed res/theme.ogg
Binary file not shown.
46 changes: 36 additions & 10 deletions src/itdelatrisu/opsu/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ public class Options {
private static int port = 49250;

/** The theme song string: {@code filename,title,artist,length(ms)} */
private static String themeString = "theme.ogg,On the Bach,Jingle Punks,66000";
private static String themeString = "theme.mp3,Rainbows,Kevin MacLeod,219350";

/** The theme song timing point string (for computing beats to pulse the logo) . */
private static String themeTimingPoint = "-44,631.578947368421,4,1,0,100,1,0";
private static String themeTimingPoint = "-1100,545.454545454545,4,1,0,100,0,0";

/**
* Returns whether the XDG flag in the manifest (if any) is set to "true".
Expand Down Expand Up @@ -267,7 +267,32 @@ public enum GameOption {
public String write() { return themeString; }

@Override
public void read(String s) { themeString = s; }
public void read(String s) {
String oldThemeString = themeString;
themeString = s;
Beatmap beatmap = getThemeBeatmap();
if (beatmap == null) {
themeString = oldThemeString;
Log.warn(String.format("The theme song string [%s] is malformed.", s));
} else if (!beatmap.audioFilename.isFile()) {
themeString = oldThemeString;
Log.warn(String.format("Cannot find theme song [%s].", beatmap.audioFilename.getAbsolutePath()));
}
}
},
THEME_SONG_TIMINGPOINT ("ThemeSongTiming") {
@Override
public String write() { return themeTimingPoint; }

@Override
public void read(String s) {
try {
new TimingPoint(s);
themeTimingPoint = s;
} catch (Exception e) {
Log.warn(String.format("The theme song timing point [%s] is malformed.", s));
}
}
},
PORT ("Port") {
@Override
Expand Down Expand Up @@ -1329,14 +1354,12 @@ public static File getSkinDir() {

/**
* Returns a dummy Beatmap containing the theme song.
* @return the theme song beatmap
* @return the theme song beatmap, or {@code null} if the theme string is malformed
*/
public static Beatmap getThemeBeatmap() {
String[] tokens = themeString.split(",");
if (tokens.length != 4) {
ErrorHandler.error("Theme song string is malformed.", null, false);
if (tokens.length != 4)
return null;
}

Beatmap beatmap = new Beatmap(null);
beatmap.audioFilename = new File(tokens[0]);
Expand All @@ -1345,11 +1368,14 @@ public static Beatmap getThemeBeatmap() {
try {
beatmap.endTime = Integer.parseInt(tokens[3]);
} catch (NumberFormatException e) {
ErrorHandler.error("Theme song length is not a valid integer", e, false);
return null;
}
beatmap.timingPoints = new ArrayList<>(1);
beatmap.timingPoints.add(new TimingPoint(themeTimingPoint));
try {
beatmap.timingPoints = new ArrayList<>(1);
beatmap.timingPoints.add(new TimingPoint(themeTimingPoint));
} catch (Exception e) {
return null;
}

return beatmap;
}
Expand Down
3 changes: 1 addition & 2 deletions src/itdelatrisu/opsu/audio/MusicController.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public static void play(final Beatmap beatmap, final boolean loop, final boolean
final File audioFile = beatmap.audioFilename;
if (!audioFile.isFile() && !ResourceLoader.resourceExists(audioFile.getPath())) {
UI.sendBarNotification(String.format("Could not find track '%s'.", audioFile.getName()));
System.out.println(beatmap);
return;
}

Expand Down Expand Up @@ -455,7 +454,7 @@ public static void reset() {
try {
trackLoader.join();
} catch (InterruptedException e) {
e.printStackTrace();
ErrorHandler.error(null, e, true);
}
}
trackLoader = null;
Expand Down
8 changes: 8 additions & 0 deletions src/itdelatrisu/opsu/beatmap/TimingPoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ public class TimingPoint {
* @param line the line to be parsed
*/
public TimingPoint(String line) {
/**
* [TIMING POINT FORMATS]
* Non-inherited:
* offset,msPerBeat,meter,sampleType,sampleSet,volume,inherited,kiai
*
* Inherited:
* offset,velocity,meter,sampleType,sampleSet,volume,inherited,kiai
*/
// TODO: better support for old formats
String[] tokens = line.split(",");
try {
Expand Down

0 comments on commit 1436f23

Please # to comment.