New theme song.

"Rainbows" by Kevin MacLeod.

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

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2016-12-22 18:36:31 -05:00
parent e3276a3365
commit 1436f2376e
6 changed files with 48 additions and 14 deletions

View File

@ -31,5 +31,6 @@ The following projects were referenced in creating opsu!:
Theme Song Theme Song
---------- ----------
The theme song is "On the Bach" by Jingle Punks, from the [YouTube Audio Library] Rainbows - Kevin MacLeod (incompetech.com)
(https://www.youtube.com/audiolibrary/music). Licensed under Creative Commons: By Attribution 3.0 License
http://creativecommons.org/licenses/by/3.0/

BIN
res/theme.mp3 Normal file

Binary file not shown.

Binary file not shown.

View File

@ -136,10 +136,10 @@ public class Options {
private static int port = 49250; private static int port = 49250;
/** The theme song string: {@code filename,title,artist,length(ms)} */ /** 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) . */ /** 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". * Returns whether the XDG flag in the manifest (if any) is set to "true".
@ -267,7 +267,32 @@ public class Options {
public String write() { return themeString; } public String write() { return themeString; }
@Override @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") { PORT ("Port") {
@Override @Override
@ -1329,14 +1354,12 @@ public class Options {
/** /**
* Returns a dummy Beatmap containing the theme song. * 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() { public static Beatmap getThemeBeatmap() {
String[] tokens = themeString.split(","); String[] tokens = themeString.split(",");
if (tokens.length != 4) { if (tokens.length != 4)
ErrorHandler.error("Theme song string is malformed.", null, false);
return null; return null;
}
Beatmap beatmap = new Beatmap(null); Beatmap beatmap = new Beatmap(null);
beatmap.audioFilename = new File(tokens[0]); beatmap.audioFilename = new File(tokens[0]);
@ -1345,11 +1368,14 @@ public class Options {
try { try {
beatmap.endTime = Integer.parseInt(tokens[3]); beatmap.endTime = Integer.parseInt(tokens[3]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
ErrorHandler.error("Theme song length is not a valid integer", e, false);
return null; return null;
} }
try {
beatmap.timingPoints = new ArrayList<>(1); beatmap.timingPoints = new ArrayList<>(1);
beatmap.timingPoints.add(new TimingPoint(themeTimingPoint)); beatmap.timingPoints.add(new TimingPoint(themeTimingPoint));
} catch (Exception e) {
return null;
}
return beatmap; return beatmap;
} }

View File

@ -99,7 +99,6 @@ public class MusicController {
final File audioFile = beatmap.audioFilename; final File audioFile = beatmap.audioFilename;
if (!audioFile.isFile() && !ResourceLoader.resourceExists(audioFile.getPath())) { if (!audioFile.isFile() && !ResourceLoader.resourceExists(audioFile.getPath())) {
UI.sendBarNotification(String.format("Could not find track '%s'.", audioFile.getName())); UI.sendBarNotification(String.format("Could not find track '%s'.", audioFile.getName()));
System.out.println(beatmap);
return; return;
} }
@ -455,7 +454,7 @@ public class MusicController {
try { try {
trackLoader.join(); trackLoader.join();
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); ErrorHandler.error(null, e, true);
} }
} }
trackLoader = null; trackLoader = null;

View File

@ -58,6 +58,14 @@ public class TimingPoint {
* @param line the line to be parsed * @param line the line to be parsed
*/ */
public TimingPoint(String line) { 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 // TODO: better support for old formats
String[] tokens = line.split(","); String[] tokens = line.split(",");
try { try {