Major refactoring - now using far more logical class names.

- Renamed "OsuFile" to "Beatmap".  All related variables and methods with "osu" have also been renamed to "beatmap" (or variants of each).
- Renamed "OsuGroupNode" to "BeatmapSetNode".  Avoids confusion since groups are identified by a "set ID", not a "group ID".
- Renamed "OsuGroupList" to "BeatmapSetList", for the same reason as above.
- Renamed "OsuDB" to "BeatmapDB", for the same reason as above.
- Moved classes directly related to parsed beatmaps (Beatmap, BeatmapSetList, BeatmapSetNode, OsuHitObject, and TimingPoint) into a new "beatmap" package.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han
2015-05-16 21:25:19 -04:00
parent 0a80590505
commit 53c79c5d85
36 changed files with 786 additions and 761 deletions

View File

@@ -20,8 +20,8 @@ package itdelatrisu.opsu.audio;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.OsuFile;
import itdelatrisu.opsu.OsuParser;
import itdelatrisu.opsu.beatmap.Beatmap;
import java.io.File;
import java.io.IOException;
@@ -50,8 +50,8 @@ public class MusicController {
/** The current music track. */
private static Music player;
/** The last OsuFile passed to play(). */
private static OsuFile lastOsu;
/** The last beatmap passed to play(). */
private static Beatmap lastBeatmap;
/** The track duration. */
private static int duration = 0;
@@ -80,23 +80,23 @@ public class MusicController {
/**
* Plays an audio file at the preview position.
* If the audio file is already playing, then nothing will happen.
* @param osu the OsuFile to play
* @param beatmap the beatmap to play
* @param loop whether or not to loop the track
* @param preview whether to start at the preview time (true) or beginning (false)
*/
public static void play(final OsuFile osu, final boolean loop, final boolean preview) {
public static void play(final Beatmap beatmap, final boolean loop, final boolean preview) {
// new track: load and play
if (lastOsu == null || !osu.audioFilename.equals(lastOsu.audioFilename)) {
if (lastBeatmap == null || !beatmap.audioFilename.equals(lastBeatmap.audioFilename)) {
reset();
System.gc();
switch (OsuParser.getExtension(osu.audioFilename.getName())) {
switch (OsuParser.getExtension(beatmap.audioFilename.getName())) {
case "ogg":
case "mp3":
trackLoader = new Thread() {
@Override
public void run() {
loadTrack(osu.audioFilename, (preview) ? osu.previewTime : 0, loop);
loadTrack(beatmap.audioFilename, (preview) ? beatmap.previewTime : 0, loop);
}
};
trackLoader.start();
@@ -107,10 +107,10 @@ public class MusicController {
}
// new track position: play at position
else if (osu.previewTime != lastOsu.previewTime)
playAt(osu.previewTime, loop);
else if (beatmap.previewTime != lastBeatmap.previewTime)
playAt(beatmap.previewTime, loop);
lastOsu = osu;
lastBeatmap = beatmap;
}
/**
@@ -170,9 +170,9 @@ public class MusicController {
public static boolean trackExists() { return (player != null); }
/**
* Returns the OsuFile associated with the current track.
* Returns the beatmap associated with the current track.
*/
public static OsuFile getOsuFile() { return lastOsu; }
public static Beatmap getBeatmap() { return lastBeatmap; }
/**
* Returns true if the current track is playing.
@@ -251,17 +251,17 @@ public class MusicController {
* Returns the duration of the current track, in milliseconds.
* Currently only works for MP3s.
* @return the duration, or -1 if no track exists, else the {@code endTime}
* field of the OsuFile loaded
* field of the beatmap loaded
* @author Tom Brito (http://stackoverflow.com/a/3056161)
*/
public static int getDuration() {
if (!trackExists() || lastOsu == null)
if (!trackExists() || lastBeatmap == null)
return -1;
if (duration == 0) {
if (lastOsu.audioFilename.getName().endsWith(".mp3")) {
if (lastBeatmap.audioFilename.getName().endsWith(".mp3")) {
try {
AudioFileFormat fileFormat = AudioSystem.getAudioFileFormat(lastOsu.audioFilename);
AudioFileFormat fileFormat = AudioSystem.getAudioFileFormat(lastBeatmap.audioFilename);
if (fileFormat instanceof TAudioFileFormat) {
Map<?, ?> properties = ((TAudioFileFormat) fileFormat).properties();
Long microseconds = (Long) properties.get("duration");
@@ -270,7 +270,7 @@ public class MusicController {
}
} catch (UnsupportedAudioFileException | IOException e) {}
}
duration = lastOsu.endTime;
duration = lastBeatmap.endTime;
}
return duration;
}
@@ -316,16 +316,16 @@ public class MusicController {
*/
public static void loopTrackIfEnded(boolean preview) {
if (trackEnded && trackExists())
playAt((preview) ? lastOsu.previewTime : 0, false);
playAt((preview) ? lastBeatmap.previewTime : 0, false);
}
/**
* Plays the theme song.
*/
public static void playThemeSong() {
OsuFile osu = Options.getOsuTheme();
if (osu != null) {
play(osu, true, false);
Beatmap beatmap = Options.getThemeBeatmap();
if (beatmap != null) {
play(beatmap, true, false);
themePlaying = true;
}
}
@@ -376,7 +376,7 @@ public class MusicController {
trackLoader = null;
// reset state
lastOsu = null;
lastBeatmap = null;
duration = 0;
trackEnded = false;
themePlaying = false;

View File

@@ -20,8 +20,8 @@ package itdelatrisu.opsu.audio;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.OsuHitObject;
import itdelatrisu.opsu.audio.HitSound.SampleSet;
import itdelatrisu.opsu.beatmap.OsuHitObject;
import java.io.File;
import java.io.IOException;