Renamed "OsuParser" to "BeatmapParser"; moved into "opsu.beatmaps".

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2015-05-29 03:07:58 -04:00
parent 3f081f1a8a
commit 00a08f1327
8 changed files with 37 additions and 39 deletions

View File

@ -20,8 +20,8 @@ package itdelatrisu.opsu.audio;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.OsuParser;
import itdelatrisu.opsu.beatmap.Beatmap;
import itdelatrisu.opsu.beatmap.BeatmapParser;
import java.io.File;
import java.io.IOException;
@ -90,7 +90,7 @@ public class MusicController {
reset();
System.gc();
switch (OsuParser.getExtension(beatmap.audioFilename.getName())) {
switch (BeatmapParser.getExtension(beatmap.audioFilename.getName())) {
case "ogg":
case "mp3":
trackLoader = new Thread() {

View File

@ -16,13 +16,11 @@
* along with opsu!. If not, see <http://www.gnu.org/licenses/>.
*/
package itdelatrisu.opsu;
package itdelatrisu.opsu.beatmap;
import itdelatrisu.opsu.beatmap.Beatmap;
import itdelatrisu.opsu.beatmap.BeatmapSetList;
import itdelatrisu.opsu.beatmap.BeatmapSetNode;
import itdelatrisu.opsu.beatmap.HitObject;
import itdelatrisu.opsu.beatmap.TimingPoint;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.db.BeatmapDB;
import java.io.BufferedReader;
@ -43,9 +41,9 @@ import org.newdawn.slick.Color;
import org.newdawn.slick.util.Log;
/**
* Parser for OSU files.
* Parser for beatmaps.
*/
public class OsuParser {
public class BeatmapParser {
/** The string lookup database. */
private static HashMap<String, String> stringdb = new HashMap<String, String>();
@ -68,7 +66,7 @@ public class OsuParser {
private static Status status = Status.NONE;
// This class should not be instantiated.
private OsuParser() {}
private BeatmapParser() {}
/**
* Invokes parser for each OSU file in a root directory and
@ -441,7 +439,7 @@ public class OsuParser {
switch (tokens[0]) {
case "0": // background
tokens[2] = tokens[2].replaceAll("^\"|\"$", "");
String ext = OsuParser.getExtension(tokens[2]);
String ext = BeatmapParser.getExtension(tokens[2]);
if (ext.equals("jpg") || ext.equals("png"))
beatmap.bg = getDBString(tokens[2]);
break;

View File

@ -20,8 +20,8 @@ package itdelatrisu.opsu.db;
import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.OsuParser;
import itdelatrisu.opsu.beatmap.Beatmap;
import itdelatrisu.opsu.beatmap.BeatmapParser;
import java.io.File;
import java.sql.Connection;
@ -439,14 +439,14 @@ public class BeatmapDB {
try {
beatmap.beatmapID = rs.getInt(4);
beatmap.beatmapSetID = rs.getInt(5);
beatmap.title = OsuParser.getDBString(rs.getString(6));
beatmap.titleUnicode = OsuParser.getDBString(rs.getString(7));
beatmap.artist = OsuParser.getDBString(rs.getString(8));
beatmap.artistUnicode = OsuParser.getDBString(rs.getString(9));
beatmap.creator = OsuParser.getDBString(rs.getString(10));
beatmap.version = OsuParser.getDBString(rs.getString(11));
beatmap.source = OsuParser.getDBString(rs.getString(12));
beatmap.tags = OsuParser.getDBString(rs.getString(13));
beatmap.title = BeatmapParser.getDBString(rs.getString(6));
beatmap.titleUnicode = BeatmapParser.getDBString(rs.getString(7));
beatmap.artist = BeatmapParser.getDBString(rs.getString(8));
beatmap.artistUnicode = BeatmapParser.getDBString(rs.getString(9));
beatmap.creator = BeatmapParser.getDBString(rs.getString(10));
beatmap.version = BeatmapParser.getDBString(rs.getString(11));
beatmap.source = BeatmapParser.getDBString(rs.getString(12));
beatmap.tags = BeatmapParser.getDBString(rs.getString(13));
beatmap.hitObjectCircle = rs.getInt(14);
beatmap.hitObjectSlider = rs.getInt(15);
beatmap.hitObjectSpinner = rs.getInt(16);
@ -459,17 +459,17 @@ public class BeatmapDB {
beatmap.bpmMin = rs.getInt(23);
beatmap.bpmMax = rs.getInt(24);
beatmap.endTime = rs.getInt(25);
beatmap.audioFilename = new File(beatmap.getFile().getParentFile(), OsuParser.getDBString(rs.getString(26)));
beatmap.audioFilename = new File(beatmap.getFile().getParentFile(), BeatmapParser.getDBString(rs.getString(26)));
beatmap.audioLeadIn = rs.getInt(27);
beatmap.previewTime = rs.getInt(28);
beatmap.countdown = rs.getByte(29);
beatmap.sampleSet = OsuParser.getDBString(rs.getString(30));
beatmap.sampleSet = BeatmapParser.getDBString(rs.getString(30));
beatmap.stackLeniency = rs.getFloat(31);
beatmap.mode = rs.getByte(32);
beatmap.letterboxInBreaks = rs.getBoolean(33);
beatmap.widescreenStoryboard = rs.getBoolean(34);
beatmap.epilepsyWarning = rs.getBoolean(35);
beatmap.bg = OsuParser.getDBString(rs.getString(36));
beatmap.bg = BeatmapParser.getDBString(rs.getString(36));
} catch (SQLException e) {
throw e;
} catch (Exception e) {

View File

@ -21,7 +21,6 @@ package itdelatrisu.opsu.states;
import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.OsuParser;
import itdelatrisu.opsu.OszUnpacker;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController;
@ -29,6 +28,7 @@ import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.audio.SoundEffect;
import itdelatrisu.opsu.beatmap.BeatmapSetList;
import itdelatrisu.opsu.beatmap.BeatmapSetNode;
import itdelatrisu.opsu.beatmap.BeatmapParser;
import itdelatrisu.opsu.downloads.Download;
import itdelatrisu.opsu.downloads.DownloadList;
import itdelatrisu.opsu.downloads.DownloadNode;
@ -616,7 +616,7 @@ public class DownloadsMenu extends BasicGameState {
// invoke unpacker and parser
File[] dirs = OszUnpacker.unpackAllFiles(Options.getOSZDir(), Options.getBeatmapDir());
if (dirs != null && dirs.length > 0) {
BeatmapSetNode node = OsuParser.parseDirectories(dirs);
BeatmapSetNode node = BeatmapParser.parseDirectories(dirs);
if (node != null) {
// stop preview
previewID = -1;
@ -748,7 +748,7 @@ public class DownloadsMenu extends BasicGameState {
switch (key) {
case Input.KEY_ESCAPE:
if (importThread != null) {
// beatmap importing: stop parsing beatmaps by sending interrupt to OsuParser
// beatmap importing: stop parsing beatmaps by sending interrupt to BeatmapParser
importThread.interrupt();
} else if (!search.getText().isEmpty()) {
// clear search text

View File

@ -24,7 +24,6 @@ import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.OsuParser;
import itdelatrisu.opsu.ScoreData;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.HitSound;
@ -33,6 +32,7 @@ import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.audio.SoundEffect;
import itdelatrisu.opsu.beatmap.Beatmap;
import itdelatrisu.opsu.beatmap.HitObject;
import itdelatrisu.opsu.beatmap.BeatmapParser;
import itdelatrisu.opsu.beatmap.TimingPoint;
import itdelatrisu.opsu.db.BeatmapDB;
import itdelatrisu.opsu.db.ScoreDB;
@ -1265,7 +1265,7 @@ public class Game extends BasicGameState {
Display.setTitle(String.format("%s - %s", game.getTitle(), beatmap.toString()));
if (beatmap.timingPoints == null || beatmap.combo == null)
BeatmapDB.load(beatmap, BeatmapDB.LOAD_ARRAY);
OsuParser.parseHitObjects(beatmap);
BeatmapParser.parseHitObjects(beatmap);
HitSound.setDefaultSampleSet(beatmap.sampleSet);
}

View File

@ -24,7 +24,6 @@ import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.OsuParser;
import itdelatrisu.opsu.OszUnpacker;
import itdelatrisu.opsu.ScoreData;
import itdelatrisu.opsu.Utils;
@ -36,6 +35,7 @@ import itdelatrisu.opsu.beatmap.Beatmap;
import itdelatrisu.opsu.beatmap.BeatmapSetList;
import itdelatrisu.opsu.beatmap.BeatmapSetNode;
import itdelatrisu.opsu.beatmap.BeatmapSortOrder;
import itdelatrisu.opsu.beatmap.BeatmapParser;
import itdelatrisu.opsu.db.BeatmapDB;
import itdelatrisu.opsu.db.ScoreDB;
import itdelatrisu.opsu.states.ButtonMenu.MenuState;
@ -730,7 +730,7 @@ public class SongMenu extends BasicGameState {
switch (key) {
case Input.KEY_ESCAPE:
if (reloadThread != null) {
// beatmap reloading: stop parsing beatmaps by sending interrupt to OsuParser
// beatmap reloading: stop parsing beatmaps by sending interrupt to BeatmapParser
reloadThread.interrupt();
} else if (!search.getText().isEmpty()) {
// clear search text
@ -1093,7 +1093,7 @@ public class SongMenu extends BasicGameState {
// invoke unpacker and parser
File beatmapDir = Options.getBeatmapDir();
OszUnpacker.unpackAllFiles(Options.getOSZDir(), beatmapDir);
OsuParser.parseAllFiles(beatmapDir);
BeatmapParser.parseAllFiles(beatmapDir);
// initialize song list
if (BeatmapSetList.get().size() > 0) {

View File

@ -21,12 +21,12 @@ package itdelatrisu.opsu.states;
import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.OsuParser;
import itdelatrisu.opsu.OszUnpacker;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.beatmap.BeatmapSetList;
import itdelatrisu.opsu.beatmap.BeatmapParser;
import itdelatrisu.opsu.ui.UI;
import java.io.File;
@ -103,7 +103,7 @@ public class Splash extends BasicGameState {
OszUnpacker.unpackAllFiles(Options.getOSZDir(), beatmapDir);
// parse song directory
OsuParser.parseAllFiles(beatmapDir);
BeatmapParser.parseAllFiles(beatmapDir);
// load sounds
SoundController.init();
@ -151,7 +151,7 @@ public class Splash extends BasicGameState {
if (++escapeCount >= 3)
container.exit();
// stop parsing beatmaps by sending interrupt to OsuParser
// stop parsing beatmaps by sending interrupt to BeatmapParser
else if (thread != null)
thread.interrupt();
}

View File

@ -22,10 +22,10 @@ import itdelatrisu.opsu.ErrorHandler;
import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.OsuParser;
import itdelatrisu.opsu.OszUnpacker;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.beatmap.BeatmapParser;
import itdelatrisu.opsu.skins.Skin;
import java.nio.IntBuffer;
@ -510,10 +510,10 @@ public class UI {
if ((file = OszUnpacker.getCurrentFileName()) != null) {
text = "Unpacking new beatmaps...";
progress = OszUnpacker.getUnpackerProgress();
} else if ((file = OsuParser.getCurrentFileName()) != null) {
text = (OsuParser.getStatus() == OsuParser.Status.INSERTING) ?
} else if ((file = BeatmapParser.getCurrentFileName()) != null) {
text = (BeatmapParser.getStatus() == BeatmapParser.Status.INSERTING) ?
"Updating database..." : "Loading beatmaps...";
progress = OsuParser.getParserProgress();
progress = BeatmapParser.getParserProgress();
} else if ((file = SoundController.getCurrentFileName()) != null) {
text = "Loading sounds...";
progress = SoundController.getLoadingProgress();