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

@@ -23,14 +23,14 @@ import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.OsuGroupList;
import itdelatrisu.opsu.OsuGroupNode;
import itdelatrisu.opsu.ScoreData;
import itdelatrisu.opsu.UI;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.audio.SoundEffect;
import itdelatrisu.opsu.beatmap.BeatmapSetList;
import itdelatrisu.opsu.beatmap.BeatmapSetNode;
import java.util.ArrayList;
import java.util.List;
@@ -66,9 +66,9 @@ public class ButtonMenu extends BasicGameState {
BEATMAP (new Button[] { Button.CLEAR_SCORES, Button.DELETE, Button.CANCEL }) {
@Override
public String[] getTitle(GameContainer container, StateBasedGame game) {
OsuGroupNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode();
String osuString = (node != null) ? OsuGroupList.get().getBaseNode(node.index).toString() : "";
return new String[] { osuString, "What do you want to do with this beatmap?" };
BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode();
String beatmapString = (node != null) ? BeatmapSetList.get().getBaseNode(node.index).toString() : "";
return new String[] { beatmapString, "What do you want to do with this beatmap?" };
}
@Override
@@ -86,9 +86,9 @@ public class ButtonMenu extends BasicGameState {
BEATMAP_DELETE_SELECT (new Button[] { Button.DELETE_GROUP, Button.DELETE_SONG, Button.CANCEL_DELETE }) {
@Override
public String[] getTitle(GameContainer container, StateBasedGame game) {
OsuGroupNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode();
String osuString = (node != null) ? node.toString() : "";
return new String[] { String.format("Are you sure you wish to delete '%s' from disk?", osuString) };
BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode();
String beatmapString = (node != null) ? node.toString() : "";
return new String[] { String.format("Are you sure you wish to delete '%s' from disk?", beatmapString) };
}
@Override
@@ -451,7 +451,7 @@ public class ButtonMenu extends BasicGameState {
@Override
public void click(GameContainer container, StateBasedGame game) {
SoundController.playSound(SoundEffect.MENUHIT);
OsuGroupNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode();
BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode();
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.BEATMAP, node);
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition(Color.black));
}
@@ -460,8 +460,8 @@ public class ButtonMenu extends BasicGameState {
@Override
public void click(GameContainer container, StateBasedGame game) {
SoundController.playSound(SoundEffect.MENUHIT);
OsuGroupNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode();
MenuState ms = (node.osuFileIndex == -1 || node.osuFiles.size() == 1) ?
BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode();
MenuState ms = (node.beatmapIndex == -1 || node.beatmaps.size() == 1) ?
MenuState.BEATMAP_DELETE_CONFIRM : MenuState.BEATMAP_DELETE_SELECT;
((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).setMenuState(ms, node);
game.enterState(Opsu.STATE_BUTTONMENU);
@@ -478,7 +478,7 @@ public class ButtonMenu extends BasicGameState {
@Override
public void click(GameContainer container, StateBasedGame game) {
SoundController.playSound(SoundEffect.MENUHIT);
OsuGroupNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode();
BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode();
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.BEATMAP_DELETE_CONFIRM, node);
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition(Color.black));
}
@@ -493,7 +493,7 @@ public class ButtonMenu extends BasicGameState {
@Override
public void click(GameContainer container, StateBasedGame game) {
SoundController.playSound(SoundEffect.MENUHIT);
OsuGroupNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode();
BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode();
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.BEATMAP_DELETE_SELECT, node);
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition(Color.black));
}
@@ -582,7 +582,7 @@ public class ButtonMenu extends BasicGameState {
private MenuState menuState;
/** The song node to process in the state. */
private OsuGroupNode node;
private BeatmapSetNode node;
/** The score data to process in the state. */
private ScoreData scoreData;
@@ -691,7 +691,7 @@ public class ButtonMenu extends BasicGameState {
* @param menuState the new menu state
* @param node the song node to process in the state
*/
public void setMenuState(MenuState menuState, OsuGroupNode node) { setMenuState(menuState, node, null); }
public void setMenuState(MenuState menuState, BeatmapSetNode node) { setMenuState(menuState, node, null); }
/**
* Changes the menu state.
@@ -706,7 +706,7 @@ public class ButtonMenu extends BasicGameState {
* @param node the song node to process in the state
* @param scoreData the score scoreData
*/
private void setMenuState(MenuState menuState, OsuGroupNode node, ScoreData scoreData) {
private void setMenuState(MenuState menuState, BeatmapSetNode node, ScoreData scoreData) {
this.menuState = menuState;
this.node = node;
this.scoreData = scoreData;
@@ -715,7 +715,7 @@ public class ButtonMenu extends BasicGameState {
/**
* Returns the song node being processed, or null if none.
*/
private OsuGroupNode getNode() { return node; }
private BeatmapSetNode getNode() { return node; }
/**
* Returns the score data being processed, or null if none.

View File

@@ -22,8 +22,6 @@ import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.OsuGroupList;
import itdelatrisu.opsu.OsuGroupNode;
import itdelatrisu.opsu.OsuParser;
import itdelatrisu.opsu.OszUnpacker;
import itdelatrisu.opsu.UI;
@@ -31,6 +29,8 @@ import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.audio.SoundEffect;
import itdelatrisu.opsu.beatmap.BeatmapSetList;
import itdelatrisu.opsu.beatmap.BeatmapSetNode;
import itdelatrisu.opsu.downloads.Download;
import itdelatrisu.opsu.downloads.DownloadList;
import itdelatrisu.opsu.downloads.DownloadNode;
@@ -482,7 +482,7 @@ public class DownloadsMenu extends BasicGameState {
final DownloadNode node = nodes[index];
// check if map is already loaded
boolean isLoaded = OsuGroupList.get().containsBeatmapSetID(node.getID());
boolean isLoaded = BeatmapSetList.get().containsBeatmapSetID(node.getID());
// track preview
if (DownloadNode.resultIconContains(x, y, i)) {
@@ -607,15 +607,15 @@ public class DownloadsMenu extends BasicGameState {
// invoke unpacker and parser
File[] dirs = OszUnpacker.unpackAllFiles(Options.getOSZDir(), Options.getBeatmapDir());
if (dirs != null && dirs.length > 0) {
OsuGroupNode node = OsuParser.parseDirectories(dirs);
BeatmapSetNode node = OsuParser.parseDirectories(dirs);
if (node != null) {
// stop preview
previewID = -1;
SoundController.stopTrack();
// initialize song list
OsuGroupList.get().reset();
OsuGroupList.get().init();
BeatmapSetList.get().reset();
BeatmapSetList.get().init();
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).setFocus(node, -1, true, true);
// send notification
@@ -739,7 +739,7 @@ public class DownloadsMenu extends BasicGameState {
switch (key) {
case Input.KEY_ESCAPE:
if (importThread != null) {
// beatmap importing: stop parsing OsuFiles by sending interrupt to OsuParser
// beatmap importing: stop parsing beatmaps by sending interrupt to OsuParser
importThread.interrupt();
} else if (!search.getText().isEmpty()) {
// clear search text

View File

@@ -25,18 +25,18 @@ import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.OsuFile;
import itdelatrisu.opsu.OsuHitObject;
import itdelatrisu.opsu.OsuParser;
import itdelatrisu.opsu.ScoreData;
import itdelatrisu.opsu.TimingPoint;
import itdelatrisu.opsu.UI;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.HitSound;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.audio.SoundEffect;
import itdelatrisu.opsu.db.OsuDB;
import itdelatrisu.opsu.beatmap.Beatmap;
import itdelatrisu.opsu.beatmap.OsuHitObject;
import itdelatrisu.opsu.beatmap.TimingPoint;
import itdelatrisu.opsu.db.BeatmapDB;
import itdelatrisu.opsu.db.ScoreDB;
import itdelatrisu.opsu.objects.Circle;
import itdelatrisu.opsu.objects.DummyObject;
@@ -96,8 +96,8 @@ public class Game extends BasicGameState {
/** Stack position offset modifier. */
private static final float STACK_OFFSET_MODIFIER = 0.05f;
/** The associated OsuFile object. */
private OsuFile osu;
/** The associated beatmap. */
private Beatmap beatmap;
/** The associated GameData object. */
private GameData data;
@@ -254,7 +254,7 @@ public class Game extends BasicGameState {
trackPosition = pauseTime;
else if (deathTime > -1) // "Easy" mod: health bar increasing
trackPosition = deathTime;
int firstObjectTime = osu.objects[0].getTime();
int firstObjectTime = beatmap.objects[0].getTime();
int timeDiff = firstObjectTime - trackPosition;
g.setBackground(Color.black);
@@ -273,7 +273,7 @@ public class Game extends BasicGameState {
else
dimLevel = 1f;
}
if (Options.isDefaultPlayfieldForced() || !osu.drawBG(width, height, dimLevel, false)) {
if (Options.isDefaultPlayfieldForced() || !beatmap.drawBG(width, height, dimLevel, false)) {
Image playfield = GameImage.PLAYFIELD.getImage();
playfield.setAlpha(dimLevel);
playfield.draw();
@@ -292,7 +292,7 @@ public class Game extends BasicGameState {
float[] autoXY = null;
if (isLeadIn()) {
// lead-in
float progress = Math.max((float) (leadInTime - osu.audioLeadIn) / approachTime, 0f);
float progress = Math.max((float) (leadInTime - beatmap.audioLeadIn) / approachTime, 0f);
autoMouseY = (int) (height / (2f - progress));
} else if (objectIndex == 0 && trackPosition < firstObjectTime) {
// before first object
@@ -301,20 +301,20 @@ public class Game extends BasicGameState {
float[] xy = hitObjects[0].getPointAt(trackPosition);
autoXY = getPointAt(autoMouseX, autoMouseY, xy[0], xy[1], 1f - ((float) timeDiff / Math.min(approachTime, firstObjectTime)));
}
} else if (objectIndex < osu.objects.length) {
} else if (objectIndex < beatmap.objects.length) {
// normal object
int objectTime = osu.objects[objectIndex].getTime();
int objectTime = beatmap.objects[objectIndex].getTime();
if (trackPosition < objectTime) {
float[] xyStart = hitObjects[objectIndex - 1].getPointAt(trackPosition);
int startTime = hitObjects[objectIndex - 1].getEndTime();
if (osu.breaks != null && breakIndex < osu.breaks.size()) {
if (beatmap.breaks != null && breakIndex < beatmap.breaks.size()) {
// starting a break: keep cursor at previous hit object position
if (breakTime > 0 || objectTime > osu.breaks.get(breakIndex))
if (breakTime > 0 || objectTime > beatmap.breaks.get(breakIndex))
autoXY = xyStart;
// after a break ends: move startTime to break end time
else if (breakIndex > 1) {
int lastBreakEndTime = osu.breaks.get(breakIndex - 1);
int lastBreakEndTime = beatmap.breaks.get(breakIndex - 1);
if (objectTime > lastBreakEndTime && startTime < lastBreakEndTime)
startTime = lastBreakEndTime;
}
@@ -326,8 +326,8 @@ public class Game extends BasicGameState {
// hit circles: show a mouse press
int offset300 = hitResultOffset[GameData.HIT_300];
if ((osu.objects[objectIndex].isCircle() && objectTime - trackPosition < offset300) ||
(osu.objects[objectIndex - 1].isCircle() && trackPosition - osu.objects[objectIndex - 1].getTime() < offset300))
if ((beatmap.objects[objectIndex].isCircle() && objectTime - trackPosition < offset300) ||
(beatmap.objects[objectIndex - 1].isCircle() && trackPosition - beatmap.objects[objectIndex - 1].getTime() < offset300))
autoMousePressed = true;
}
} else {
@@ -388,12 +388,12 @@ public class Game extends BasicGameState {
}
// break periods
if (osu.breaks != null && breakIndex < osu.breaks.size() && breakTime > 0) {
int endTime = osu.breaks.get(breakIndex);
if (beatmap.breaks != null && breakIndex < beatmap.breaks.size() && breakTime > 0) {
int endTime = beatmap.breaks.get(breakIndex);
int breakLength = endTime - breakTime;
// letterbox effect (black bars on top/bottom)
if (osu.letterboxInBreaks && breakLength >= 4000) {
if (beatmap.letterboxInBreaks && breakLength >= 4000) {
g.setColor(Color.black);
g.fillRect(0, 0, width, height * 0.125f);
g.fillRect(0, height * 0.875f, width, height * 0.125f);
@@ -441,7 +441,7 @@ public class Game extends BasicGameState {
// skip beginning
if (objectIndex == 0 &&
trackPosition < osu.objects[0].getTime() - SKIP_OFFSET)
trackPosition < beatmap.objects[0].getTime() - SKIP_OFFSET)
skipButton.draw();
// show retries
@@ -465,7 +465,7 @@ public class Game extends BasicGameState {
trackPosition = (leadInTime - Options.getMusicOffset()) * -1; // render approach circles during song lead-in
// countdown
if (osu.countdown > 0) {
if (beatmap.countdown > 0) {
float speedModifier = GameMod.getSpeedMultiplier() * playbackSpeed.getModifier();
timeDiff = firstObjectTime - trackPosition;
if (timeDiff >= 500 * speedModifier && timeDiff < 3000 * speedModifier) {
@@ -667,11 +667,11 @@ public class Game extends BasicGameState {
replayFrames.getFirst().setTimeDiff(replaySkipTime * -1);
replayFrames.addFirst(ReplayFrame.getStartFrame(replaySkipTime));
replayFrames.addFirst(ReplayFrame.getStartFrame(0));
Replay r = data.getReplay(replayFrames.toArray(new ReplayFrame[replayFrames.size()]), osu);
Replay r = data.getReplay(replayFrames.toArray(new ReplayFrame[replayFrames.size()]), beatmap);
if (r != null && !unranked)
r.save();
}
ScoreData score = data.getScoreData(osu);
ScoreData score = data.getScoreData(beatmap);
// add score to database
if (!unranked && !isReplay)
@@ -683,8 +683,8 @@ public class Game extends BasicGameState {
}
// timing points
if (timingPointIndex < osu.timingPoints.size()) {
TimingPoint timingPoint = osu.timingPoints.get(timingPointIndex);
if (timingPointIndex < beatmap.timingPoints.size()) {
TimingPoint timingPoint = beatmap.timingPoints.get(timingPointIndex);
if (trackPosition >= timingPoint.getTime()) {
setBeatLength(timingPoint, true);
timingPointIndex++;
@@ -692,12 +692,12 @@ public class Game extends BasicGameState {
}
// song beginning
if (objectIndex == 0 && trackPosition < osu.objects[0].getTime())
if (objectIndex == 0 && trackPosition < beatmap.objects[0].getTime())
return; // nothing to do here
// break periods
if (osu.breaks != null && breakIndex < osu.breaks.size()) {
int breakValue = osu.breaks.get(breakIndex);
if (beatmap.breaks != null && breakIndex < beatmap.breaks.size()) {
int breakValue = beatmap.breaks.get(breakIndex);
if (breakTime > 0) { // in a break period
if (trackPosition < breakValue)
return;
@@ -749,10 +749,10 @@ public class Game extends BasicGameState {
// update objects (loop in unlikely event of any skipped indexes)
boolean keyPressed = keys != ReplayFrame.KEY_NONE;
while (objectIndex < hitObjects.length && trackPosition > osu.objects[objectIndex].getTime()) {
while (objectIndex < hitObjects.length && trackPosition > beatmap.objects[objectIndex].getTime()) {
// check if we've already passed the next object's start time
boolean overlap = (objectIndex + 1 < hitObjects.length &&
trackPosition > osu.objects[objectIndex + 1].getTime() - hitResultOffset[GameData.HIT_300]);
trackPosition > beatmap.objects[objectIndex + 1].getTime() - hitResultOffset[GameData.HIT_300]);
// update hit object and check completion status
if (hitObjects[objectIndex].update(overlap, delta, mouseX, mouseY, keyPressed, trackPosition))
@@ -791,7 +791,7 @@ public class Game extends BasicGameState {
}
// pause game
if (pauseTime < 0 && breakTime <= 0 && trackPosition >= osu.objects[0].getTime()) {
if (pauseTime < 0 && breakTime <= 0 && trackPosition >= beatmap.objects[0].getTime()) {
pausedMouseX = mouseX;
pausedMouseY = mouseY;
pausePulse = 0f;
@@ -808,7 +808,7 @@ public class Game extends BasicGameState {
// restart
if (input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL)) {
try {
if (trackPosition < osu.objects[0].getTime())
if (trackPosition < beatmap.objects[0].getTime())
retries--; // don't count this retry (cancel out later increment)
restart = Restart.MANUAL;
enter(container, game);
@@ -835,7 +835,7 @@ public class Game extends BasicGameState {
// load checkpoint
if (input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL)) {
int checkpoint = Options.getCheckpoint();
if (checkpoint == 0 || checkpoint > osu.endTime)
if (checkpoint == 0 || checkpoint > beatmap.endTime)
break; // invalid checkpoint
try {
restart = Restart.MANUAL;
@@ -852,10 +852,10 @@ public class Game extends BasicGameState {
MusicController.setPosition(checkpoint);
MusicController.setPitch(GameMod.getSpeedMultiplier() * playbackSpeed.getModifier());
while (objectIndex < hitObjects.length &&
osu.objects[objectIndex++].getTime() <= checkpoint)
beatmap.objects[objectIndex++].getTime() <= checkpoint)
;
objectIndex--;
lastReplayTime = osu.objects[objectIndex].getTime();
lastReplayTime = beatmap.objects[objectIndex].getTime();
} catch (SlickException e) {
ErrorHandler.error("Failed to load checkpoint.", e, false);
}
@@ -905,7 +905,7 @@ public class Game extends BasicGameState {
// mouse wheel: pause the game
if (button == Input.MOUSE_MIDDLE_BUTTON && !Options.isMouseWheelDisabled()) {
int trackPosition = MusicController.getPosition();
if (pauseTime < 0 && breakTime <= 0 && trackPosition >= osu.objects[0].getTime()) {
if (pauseTime < 0 && breakTime <= 0 && trackPosition >= beatmap.objects[0].getTime()) {
pausedMouseX = x;
pausedMouseY = y;
pausePulse = 0f;
@@ -1021,8 +1021,8 @@ public class Game extends BasicGameState {
throws SlickException {
UI.enter();
if (osu == null || osu.objects == null)
throw new RuntimeException("Running game with no OsuFile loaded.");
if (beatmap == null || beatmap.objects == null)
throw new RuntimeException("Running game with no beatmap loaded.");
// grab the mouse (not working for touchscreen)
// container.setMouseGrabbed(true);
@@ -1044,8 +1044,8 @@ public class Game extends BasicGameState {
resetGameData();
// load the first timingPoint for stacking
if (!osu.timingPoints.isEmpty()) {
TimingPoint timingPoint = osu.timingPoints.get(0);
if (!beatmap.timingPoints.isEmpty()) {
TimingPoint timingPoint = beatmap.timingPoints.get(0);
if (!timingPoint.isInherited()) {
setBeatLength(timingPoint, true);
timingPointIndex++;
@@ -1053,20 +1053,20 @@ public class Game extends BasicGameState {
}
// initialize object maps
for (int i = 0; i < osu.objects.length; i++) {
OsuHitObject hitObject = osu.objects[i];
for (int i = 0; i < beatmap.objects.length; i++) {
OsuHitObject hitObject = beatmap.objects[i];
// is this the last note in the combo?
boolean comboEnd = false;
if (i + 1 < osu.objects.length && osu.objects[i + 1].isNewCombo())
if (i + 1 < beatmap.objects.length && beatmap.objects[i + 1].isNewCombo())
comboEnd = true;
Color color = osu.combo[hitObject.getComboIndex()];
Color color = beatmap.combo[hitObject.getComboIndex()];
// pass beatLength to hit objects
int hitObjectTime = hitObject.getTime();
while (timingPointIndex < osu.timingPoints.size()) {
TimingPoint timingPoint = osu.timingPoints.get(timingPointIndex);
while (timingPointIndex < beatmap.timingPoints.size()) {
TimingPoint timingPoint = beatmap.timingPoints.get(timingPointIndex);
if (timingPoint.getTime() > hitObjectTime)
break;
setBeatLength(timingPoint, false);
@@ -1095,8 +1095,8 @@ public class Game extends BasicGameState {
// load the first timingPoint
timingPointIndex = 0;
beatLengthBase = beatLength = 1;
if (!osu.timingPoints.isEmpty()) {
TimingPoint timingPoint = osu.timingPoints.get(0);
if (!beatmap.timingPoints.isEmpty()) {
TimingPoint timingPoint = beatmap.timingPoints.get(0);
if (!timingPoint.isInherited()) {
setBeatLength(timingPoint, true);
timingPointIndex++;
@@ -1140,7 +1140,7 @@ public class Game extends BasicGameState {
replayFrames.add(new ReplayFrame(0, 0, input.getMouseX(), input.getMouseY(), 0));
}
leadInTime = osu.audioLeadIn + approachTime;
leadInTime = beatmap.audioLeadIn + approachTime;
restart = Restart.FALSE;
// needs to play before setting position to resume without lag later
@@ -1181,27 +1181,27 @@ public class Game extends BasicGameState {
private void drawHitObjects(Graphics g, int trackPosition) {
// include previous object in follow points
int lastObjectIndex = -1;
if (objectIndex > 0 && objectIndex < osu.objects.length &&
trackPosition < osu.objects[objectIndex].getTime() && !osu.objects[objectIndex - 1].isSpinner())
if (objectIndex > 0 && objectIndex < beatmap.objects.length &&
trackPosition < beatmap.objects[objectIndex].getTime() && !beatmap.objects[objectIndex - 1].isSpinner())
lastObjectIndex = objectIndex - 1;
// draw hit objects in reverse order, or else overlapping objects are unreadable
Stack<Integer> stack = new Stack<Integer>();
for (int index = objectIndex; index < hitObjects.length && osu.objects[index].getTime() < trackPosition + approachTime; index++) {
for (int index = objectIndex; index < hitObjects.length && beatmap.objects[index].getTime() < trackPosition + approachTime; index++) {
stack.add(index);
// draw follow points
if (!Options.isFollowPointEnabled())
continue;
if (osu.objects[index].isSpinner()) {
if (beatmap.objects[index].isSpinner()) {
lastObjectIndex = -1;
continue;
}
if (lastObjectIndex != -1 && !osu.objects[index].isNewCombo()) {
if (lastObjectIndex != -1 && !beatmap.objects[index].isNewCombo()) {
// calculate points
final int followPointInterval = container.getHeight() / 14;
int lastObjectEndTime = hitObjects[lastObjectIndex].getEndTime() + 1;
int objectStartTime = osu.objects[index].getTime();
int objectStartTime = beatmap.objects[index].getTime();
float[] startXY = hitObjects[lastObjectIndex].getPointAt(lastObjectEndTime);
float[] endXY = hitObjects[index].getPointAt(objectStartTime);
float xDiff = endXY[0] - startXY[0];
@@ -1257,23 +1257,23 @@ public class Game extends BasicGameState {
}
/**
* Loads all required data from an OsuFile.
* @param osu the OsuFile to load
* Loads all required data from a beatmap.
* @param beatmap the beatmap to load
*/
public void loadOsuFile(OsuFile osu) {
this.osu = osu;
Display.setTitle(String.format("%s - %s", game.getTitle(), osu.toString()));
if (osu.timingPoints == null || osu.combo == null)
OsuDB.load(osu, OsuDB.LOAD_ARRAY);
OsuParser.parseHitObjects(osu);
HitSound.setDefaultSampleSet(osu.sampleSet);
public void loadBeatmap(Beatmap beatmap) {
this.beatmap = beatmap;
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);
HitSound.setDefaultSampleSet(beatmap.sampleSet);
}
/**
* Resets all game data and structures.
*/
public void resetGameData() {
hitObjects = new HitObject[osu.objects.length];
hitObjects = new HitObject[beatmap.objects.length];
data.clear();
objectIndex = 0;
breakIndex = 0;
@@ -1308,7 +1308,7 @@ public class Game extends BasicGameState {
* @return true if skipped, false otherwise
*/
private synchronized boolean skipIntro() {
int firstObjectTime = osu.objects[0].getTime();
int firstObjectTime = beatmap.objects[0].getTime();
int trackPosition = MusicController.getPosition();
if (objectIndex == 0 && trackPosition < firstObjectTime - SKIP_OFFSET) {
if (isLeadIn()) {
@@ -1336,7 +1336,7 @@ public class Game extends BasicGameState {
int height = container.getHeight();
// set images
File parent = osu.getFile().getParentFile();
File parent = beatmap.getFile().getParentFile();
for (GameImage img : GameImage.values()) {
if (img.isSkinnable()) {
img.setDefaultImage();
@@ -1365,10 +1365,10 @@ public class Game extends BasicGameState {
private void setMapModifiers() {
// map-based properties, re-initialized each game
float multiplier = GameMod.getDifficultyMultiplier();
float circleSize = Math.min(osu.circleSize * multiplier, 10f);
float approachRate = Math.min(osu.approachRate * multiplier, 10f);
float overallDifficulty = Math.min(osu.overallDifficulty * multiplier, 10f);
float HPDrainRate = Math.min(osu.HPDrainRate * multiplier, 10f);
float circleSize = Math.min(beatmap.circleSize * multiplier, 10f);
float approachRate = Math.min(beatmap.approachRate * multiplier, 10f);
float overallDifficulty = Math.min(beatmap.overallDifficulty * multiplier, 10f);
float HPDrainRate = Math.min(beatmap.HPDrainRate * multiplier, 10f);
// fixed difficulty overrides
if (Options.getFixedCS() > 0f)
@@ -1387,7 +1387,7 @@ public class Game extends BasicGameState {
// initialize objects
Circle.init(container, circleSize);
Slider.init(container, circleSize, osu);
Slider.init(container, circleSize, beatmap);
Spinner.init(container);
// approachRate (hit object approach time)
@@ -1522,7 +1522,7 @@ public class Game extends BasicGameState {
if (objectIndex >= hitObjects.length) // nothing to do here
return;
OsuHitObject hitObject = osu.objects[objectIndex];
OsuHitObject hitObject = beatmap.objects[objectIndex];
// circles
if (hitObject.isCircle() && hitObjects[objectIndex].mousePressed(x, y, trackPosition))
@@ -1582,14 +1582,14 @@ public class Game extends BasicGameState {
return;
int width = container.getWidth(), height = container.getHeight();
boolean firstObject = (objectIndex == 0 && trackPosition < osu.objects[0].getTime());
boolean firstObject = (objectIndex == 0 && trackPosition < beatmap.objects[0].getTime());
if (isLeadIn()) {
// lead-in: expand area
float progress = Math.max((float) (leadInTime - osu.audioLeadIn) / approachTime, 0f);
float progress = Math.max((float) (leadInTime - beatmap.audioLeadIn) / approachTime, 0f);
flashlightRadius = width - (int) ((width - (height * 2 / 3)) * progress);
} else if (firstObject) {
// before first object: shrink area
int timeDiff = osu.objects[0].getTime() - trackPosition;
int timeDiff = beatmap.objects[0].getTime() - trackPosition;
flashlightRadius = width;
if (timeDiff < approachTime) {
float progress = (float) timeDiff / approachTime;
@@ -1605,10 +1605,10 @@ public class Game extends BasicGameState {
targetRadius = height / 2;
else
targetRadius = height / 3;
if (osu.breaks != null && breakIndex < osu.breaks.size() && breakTime > 0) {
if (beatmap.breaks != null && breakIndex < beatmap.breaks.size() && breakTime > 0) {
// breaks: expand at beginning, shrink at end
flashlightRadius = targetRadius;
int endTime = osu.breaks.get(breakIndex);
int endTime = beatmap.breaks.get(breakIndex);
int breakLength = endTime - breakTime;
if (breakLength > approachTime * 3) {
float progress = 1f;
@@ -1642,7 +1642,7 @@ public class Game extends BasicGameState {
private void calculateStacks() {
// reverse pass for stack calculation
for (int i = hitObjects.length - 1; i > 0; i--) {
OsuHitObject hitObjectI = osu.objects[i];
OsuHitObject hitObjectI = beatmap.objects[i];
// already calculated
if (hitObjectI.getStack() != 0 || hitObjectI.isSpinner())
@@ -1650,12 +1650,12 @@ public class Game extends BasicGameState {
// search for hit objects in stack
for (int n = i - 1; n >= 0; n--) {
OsuHitObject hitObjectN = osu.objects[n];
OsuHitObject hitObjectN = beatmap.objects[n];
if (hitObjectN.isSpinner())
continue;
// check if in range stack calculation
float timeI = hitObjectI.getTime() - (STACK_TIMEOUT * osu.stackLeniency);
float timeI = hitObjectI.getTime() - (STACK_TIMEOUT * beatmap.stackLeniency);
float timeN = hitObjectN.isSlider() ? hitObjects[n].getEndTime() : hitObjectN.getTime();
if (timeI > timeN)
break;
@@ -1671,7 +1671,7 @@ public class Game extends BasicGameState {
if (distance < STACK_LENIENCE * OsuHitObject.getXMultiplier()) {
int offset = hitObjectI.getStack() - hitObjectN.getStack() + 1;
for (int j = n + 1; j <= i; j++) {
OsuHitObject hitObjectJ = osu.objects[j];
OsuHitObject hitObjectJ = beatmap.objects[j];
p1 = hitObjects[j].getPointAt(hitObjectJ.getTime());
distance = Utils.distance(p1[0], p1[1], p2[0], p2[1]);
@@ -1697,7 +1697,7 @@ public class Game extends BasicGameState {
// update hit object positions
for (int i = 0; i < hitObjects.length; i++) {
if (osu.objects[i].getStack() != 0)
if (beatmap.objects[i].getStack() != 0)
hitObjects[i].updatePosition();
}
}

View File

@@ -132,7 +132,7 @@ public class GamePauseMenu extends BasicGameState {
if (gameState.getRestart() == Game.Restart.LOSE) {
SoundController.playSound(SoundEffect.MENUBACK);
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).resetGameDataOnLoad();
MusicController.playAt(MusicController.getOsuFile().previewTime, true);
MusicController.playAt(MusicController.getBeatmap().previewTime, true);
UI.resetCursor();
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
} else {
@@ -183,7 +183,7 @@ public class GamePauseMenu extends BasicGameState {
SoundController.playSound(SoundEffect.MENUBACK);
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).resetGameDataOnLoad();
if (loseState)
MusicController.playAt(MusicController.getOsuFile().previewTime, true);
MusicController.playAt(MusicController.getBeatmap().previewTime, true);
else
MusicController.resume();
UI.resetCursor();

View File

@@ -23,12 +23,12 @@ import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.OsuFile;
import itdelatrisu.opsu.UI;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.audio.SoundEffect;
import itdelatrisu.opsu.beatmap.Beatmap;
import itdelatrisu.opsu.replay.Replay;
import java.io.FileNotFoundException;
@@ -102,14 +102,14 @@ public class GameRanking extends BasicGameState {
int width = container.getWidth();
int height = container.getHeight();
OsuFile osu = MusicController.getOsuFile();
Beatmap beatmap = MusicController.getBeatmap();
// background
if (!osu.drawBG(width, height, 0.7f, true))
if (!beatmap.drawBG(width, height, 0.7f, true))
GameImage.PLAYFIELD.getImage().draw(0,0);
// ranking screen elements
data.drawRankingElements(g, osu);
data.drawRankingElements(g, beatmap);
// buttons
replayButton.draw();
@@ -201,8 +201,8 @@ public class GameRanking extends BasicGameState {
}
if (returnToGame) {
OsuFile osu = MusicController.getOsuFile();
gameState.loadOsuFile(osu);
Beatmap beatmap = MusicController.getBeatmap();
gameState.loadBeatmap(beatmap);
SoundController.playSound(SoundEffect.MENUHIT);
game.enterState(Opsu.STATE_GAME, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
return;

View File

@@ -24,14 +24,14 @@ import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.MenuButton.Expand;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.OsuFile;
import itdelatrisu.opsu.OsuGroupList;
import itdelatrisu.opsu.OsuGroupNode;
import itdelatrisu.opsu.UI;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.audio.SoundEffect;
import itdelatrisu.opsu.beatmap.Beatmap;
import itdelatrisu.opsu.beatmap.BeatmapSetList;
import itdelatrisu.opsu.beatmap.BeatmapSetNode;
import itdelatrisu.opsu.downloads.Updater;
import itdelatrisu.opsu.states.ButtonMenu.MenuState;
@@ -91,7 +91,7 @@ public class MainMenu extends BasicGameState {
private MenuButton updateButton;
/** Application start time, for drawing the total running time. */
private long osuStartTime;
private long programStartTime;
/** Indexes of previous songs. */
private Stack<Integer> previous;
@@ -127,7 +127,7 @@ public class MainMenu extends BasicGameState {
this.game = game;
this.input = container.getInput();
osuStartTime = System.currentTimeMillis();
programStartTime = System.currentTimeMillis();
previous = new Stack<Integer>();
int width = container.getWidth();
@@ -199,9 +199,9 @@ public class MainMenu extends BasicGameState {
int height = container.getHeight();
// draw background
OsuFile osu = MusicController.getOsuFile();
Beatmap beatmap = MusicController.getBeatmap();
if (Options.isDynamicBackgroundEnabled() &&
osu != null && osu.drawBG(width, height, bgAlpha, true))
beatmap != null && beatmap.drawBG(width, height, bgAlpha, true))
;
else {
Image bg = GameImage.MENU_BG.getImage();
@@ -240,7 +240,7 @@ public class MainMenu extends BasicGameState {
g.setColor((musicPositionBarContains(mouseX, mouseY)) ? BG_HOVER : BG_NORMAL);
g.fillRoundRect(musicBarX, musicBarY, musicBarWidth, musicBarHeight, 4);
g.setColor(Color.white);
if (!MusicController.isTrackLoading() && osu != null) {
if (!MusicController.isTrackLoading() && beatmap != null) {
float musicBarPosition = Math.min((float) MusicController.getPosition() / MusicController.getDuration(), 1f);
g.fillRoundRect(musicBarX, musicBarY, musicBarWidth * musicBarPosition, musicBarHeight, 4);
}
@@ -274,17 +274,17 @@ public class MainMenu extends BasicGameState {
g.setFont(Utils.FONT_MEDIUM);
float lineHeight = Utils.FONT_MEDIUM.getLineHeight() * 0.925f;
g.drawString(String.format("Loaded %d songs and %d beatmaps.",
OsuGroupList.get().getMapSetCount(), OsuGroupList.get().getMapCount()), marginX, topMarginY);
BeatmapSetList.get().getMapSetCount(), BeatmapSetList.get().getMapCount()), marginX, topMarginY);
if (MusicController.isTrackLoading())
g.drawString("Track loading...", marginX, topMarginY + lineHeight);
else if (MusicController.trackExists()) {
if (Options.useUnicodeMetadata()) // load glyphs
Utils.loadGlyphs(Utils.FONT_MEDIUM, osu.titleUnicode, osu.artistUnicode);
Utils.loadGlyphs(Utils.FONT_MEDIUM, beatmap.titleUnicode, beatmap.artistUnicode);
g.drawString((MusicController.isPlaying()) ? "Now Playing:" : "Paused:", marginX, topMarginY + lineHeight);
g.drawString(String.format("%s: %s", osu.getArtist(), osu.getTitle()), marginX + 25, topMarginY + (lineHeight * 2));
g.drawString(String.format("%s: %s", beatmap.getArtist(), beatmap.getTitle()), marginX + 25, topMarginY + (lineHeight * 2));
}
g.drawString(String.format("opsu! has been running for %s.",
Utils.getTimeString((int) (System.currentTimeMillis() - osuStartTime) / 1000)),
Utils.getTimeString((int) (System.currentTimeMillis() - programStartTime) / 1000)),
marginX, height - bottomMarginY - (lineHeight * 2));
g.drawString(String.format("It is currently %s.",
new SimpleDateFormat("h:mm a").format(new Date())),
@@ -455,7 +455,7 @@ public class MainMenu extends BasicGameState {
} else if (musicPrevious.contains(x, y)) {
if (!previous.isEmpty()) {
SongMenu menu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
menu.setFocus(OsuGroupList.get().getBaseNode(previous.pop()), -1, true, false);
menu.setFocus(BeatmapSetList.get().getBaseNode(previous.pop()), -1, true, false);
if (Options.isDynamicBackgroundEnabled())
bgAlpha = 0f;
} else
@@ -603,10 +603,10 @@ public class MainMenu extends BasicGameState {
private void nextTrack() {
boolean isTheme = MusicController.isThemePlaying();
SongMenu menu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
OsuGroupNode node = menu.setFocus(OsuGroupList.get().getRandomNode(), -1, true, false);
BeatmapSetNode node = menu.setFocus(BeatmapSetList.get().getRandomNode(), -1, true, false);
boolean sameAudio = false;
if (node != null) {
sameAudio = MusicController.getOsuFile().audioFilename.equals(node.osuFiles.get(0).audioFilename);
sameAudio = MusicController.getBeatmap().audioFilename.equals(node.beatmaps.get(0).audioFilename);
if (!isTheme && !sameAudio)
previous.add(node.index);
}
@@ -619,7 +619,7 @@ public class MainMenu extends BasicGameState {
*/
private void enterSongMenu() {
int state = Opsu.STATE_SONGMENU;
if (OsuGroupList.get().getMapSetCount() == 0) {
if (BeatmapSetList.get().getMapSetCount() == 0) {
((DownloadsMenu) game.getState(Opsu.STATE_DOWNLOADSMENU)).notifyOnLoad("Download some beatmaps to get started!");
state = Opsu.STATE_DOWNLOADSMENU;
}

View File

@@ -25,9 +25,6 @@ import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.OsuFile;
import itdelatrisu.opsu.OsuGroupList;
import itdelatrisu.opsu.OsuGroupNode;
import itdelatrisu.opsu.OsuParser;
import itdelatrisu.opsu.OszUnpacker;
import itdelatrisu.opsu.ScoreData;
@@ -38,7 +35,10 @@ import itdelatrisu.opsu.audio.MultiClip;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.audio.SoundEffect;
import itdelatrisu.opsu.db.OsuDB;
import itdelatrisu.opsu.beatmap.Beatmap;
import itdelatrisu.opsu.beatmap.BeatmapSetList;
import itdelatrisu.opsu.beatmap.BeatmapSetNode;
import itdelatrisu.opsu.db.BeatmapDB;
import itdelatrisu.opsu.db.ScoreDB;
import itdelatrisu.opsu.states.ButtonMenu.MenuState;
@@ -91,28 +91,28 @@ public class SongMenu extends BasicGameState {
/** Line width of the header/footer divider. */
private static final int DIVIDER_LINE_WIDTH = 4;
/** Song node class representing an OsuGroupNode and file index. */
/** Song node class representing an BeatmapSetNode and file index. */
private static class SongNode {
/** Song node. */
private OsuGroupNode node;
private BeatmapSetNode node;
/** File index. */
private int index;
/**
* Constructor.
* @param node the OsuGroupNode
* @param node the BeatmapSetNode
* @param index the file index
*/
public SongNode(OsuGroupNode node, int index) {
public SongNode(BeatmapSetNode node, int index) {
this.node = node;
this.index = index;
}
/**
* Returns the associated OsuGroupNode.
* Returns the associated BeatmapSetNode.
*/
public OsuGroupNode getNode() { return node; }
public BeatmapSetNode getNode() { return node; }
/**
* Returns the associated file index.
@@ -121,10 +121,10 @@ public class SongMenu extends BasicGameState {
}
/** Current start node (topmost menu entry). */
private OsuGroupNode startNode;
private BeatmapSetNode startNode;
/** Current focused (selected) node. */
private OsuGroupNode focusNode;
private BeatmapSetNode focusNode;
/** The base node of the previous focus node. */
private SongNode oldFocusNode = null;
@@ -172,7 +172,7 @@ public class SongMenu extends BasicGameState {
private MenuState stateAction;
/** If non-null, the node that stateAction acts upon. */
private OsuGroupNode stateActionNode;
private BeatmapSetNode stateActionNode;
/** If non-null, the score data that stateAction acts upon. */
private ScoreData stateActionScore;
@@ -292,13 +292,13 @@ public class SongMenu extends BasicGameState {
// background
if (focusNode != null) {
OsuFile focusNodeOsu = focusNode.osuFiles.get(focusNode.osuFileIndex);
if (!focusNodeOsu.drawBG(width, height, 1.0f, true))
Beatmap focusNodeBeatmap = focusNode.beatmaps.get(focusNode.beatmapIndex);
if (!focusNodeBeatmap.drawBG(width, height, 1.0f, true))
GameImage.PLAYFIELD.getImage().draw();
}
// song buttons
OsuGroupNode node = startNode;
BeatmapSetNode node = startNode;
int songButtonIndex = 0;
if (node != null && node.prev != null) {
node = node.prev;
@@ -339,8 +339,8 @@ public class SongMenu extends BasicGameState {
if (songInfo == null) {
songInfo = focusNode.getInfo();
if (Options.useUnicodeMetadata()) { // load glyphs
OsuFile osu = focusNode.osuFiles.get(0);
Utils.loadGlyphs(Utils.FONT_LARGE, osu.titleUnicode, osu.artistUnicode);
Beatmap beatmap = focusNode.beatmaps.get(0);
Utils.loadGlyphs(Utils.FONT_LARGE, beatmap.titleUnicode, beatmap.artistUnicode);
}
}
marginX += 5;
@@ -437,14 +437,14 @@ public class SongMenu extends BasicGameState {
// scroll bar
if (focusNode != null) {
int focusNodes = focusNode.osuFiles.size();
int totalNodes = OsuGroupList.get().size() + focusNodes - 1;
int focusNodes = focusNode.beatmaps.size();
int totalNodes = BeatmapSetList.get().size() + focusNodes - 1;
if (totalNodes > MAX_SONG_BUTTONS) {
int startIndex = startNode.index;
if (startNode.index > focusNode.index)
startIndex += focusNodes;
else if (startNode.index == focusNode.index)
startIndex += startNode.osuFileIndex;
startIndex += startNode.beatmapIndex;
UI.drawScrollbar(g, startIndex, totalNodes, MAX_SONG_BUTTONS,
width, headerY + DIVIDER_LINE_WIDTH / 2, 0, buttonOffset - DIVIDER_LINE_WIDTH * 1.5f, buttonOffset,
Utils.COLOR_BLACK_ALPHA, Color.white, true);
@@ -501,9 +501,9 @@ public class SongMenu extends BasicGameState {
// store the start/focus nodes
if (focusNode != null)
oldFocusNode = new SongNode(OsuGroupList.get().getBaseNode(focusNode.index), focusNode.osuFileIndex);
oldFocusNode = new SongNode(BeatmapSetList.get().getBaseNode(focusNode.index), focusNode.beatmapIndex);
if (OsuGroupList.get().search(search.getText())) {
if (BeatmapSetList.get().search(search.getText())) {
// reset song stack
randomStack = new Stack<SongNode>();
@@ -515,19 +515,19 @@ public class SongMenu extends BasicGameState {
startNode = focusNode = null;
scoreMap = null;
focusScores = null;
if (OsuGroupList.get().size() > 0) {
OsuGroupList.get().init();
if (BeatmapSetList.get().size() > 0) {
BeatmapSetList.get().init();
if (search.getText().isEmpty()) { // cleared search
// use previous start/focus if possible
if (oldFocusNode != null)
setFocus(oldFocusNode.getNode(), oldFocusNode.getIndex(), true, true);
else
setFocus(OsuGroupList.get().getRandomNode(), -1, true, true);
setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true);
} else {
int size = OsuGroupList.get().size();
int size = BeatmapSetList.get().size();
searchResultString = String.format("%d match%s found!",
size, (size == 1) ? "" : "es");
setFocus(OsuGroupList.get().getRandomNode(), -1, true, true);
setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true);
}
oldFocusNode = null;
} else if (!search.getText().isEmpty())
@@ -555,9 +555,9 @@ public class SongMenu extends BasicGameState {
// mouse hover
boolean isHover = false;
if (mouseY > headerY && mouseY < footerY) {
OsuGroupNode node = startNode;
BeatmapSetNode node = startNode;
for (int i = 0; i < MAX_SONG_BUTTONS && node != null; i++, node = node.next) {
float cx = (node.index == OsuGroupList.get().getExpandedIndex()) ? buttonX * 0.9f : buttonX;
float cx = (node.index == BeatmapSetList.get().getExpandedIndex()) ? buttonX * 0.9f : buttonX;
if ((mouseX > cx && mouseX < cx + buttonWidth) &&
(mouseY > buttonY + (i * buttonOffset) && mouseY < buttonY + (i * buttonOffset) + buttonHeight)) {
if (i == hoverIndex) {
@@ -641,10 +641,10 @@ public class SongMenu extends BasicGameState {
if (sort != SongSort.getSort()) {
SongSort.setSort(sort);
SoundController.playSound(SoundEffect.MENUCLICK);
OsuGroupNode oldFocusBase = OsuGroupList.get().getBaseNode(focusNode.index);
int oldFocusFileIndex = focusNode.osuFileIndex;
BeatmapSetNode oldFocusBase = BeatmapSetList.get().getBaseNode(focusNode.index);
int oldFocusFileIndex = focusNode.beatmapIndex;
focusNode = null;
OsuGroupList.get().init();
BeatmapSetList.get().init();
setFocus(oldFocusBase, oldFocusFileIndex, true, true);
}
return;
@@ -653,8 +653,8 @@ public class SongMenu extends BasicGameState {
// song buttons
if (y > headerY && y < footerY) {
int expandedIndex = OsuGroupList.get().getExpandedIndex();
OsuGroupNode node = startNode;
int expandedIndex = BeatmapSetList.get().getExpandedIndex();
BeatmapSetNode node = startNode;
for (int i = 0; i < MAX_SONG_BUTTONS && node != null; i++, node = node.next) {
// is button at this index clicked?
float cx = (node.index == expandedIndex) ? buttonX * 0.9f : buttonX;
@@ -665,7 +665,7 @@ public class SongMenu extends BasicGameState {
// clicked node is already expanded
if (node.index == expandedIndex) {
if (node.osuFileIndex == focusNode.osuFileIndex) {
if (node.beatmapIndex == focusNode.beatmapIndex) {
// if already focused, load the beatmap
if (button != Input.MOUSE_RIGHT_BUTTON)
startGame();
@@ -730,7 +730,7 @@ public class SongMenu extends BasicGameState {
switch (key) {
case Input.KEY_ESCAPE:
if (reloadThread != null) {
// beatmap reloading: stop parsing OsuFiles by sending interrupt to OsuParser
// beatmap reloading: stop parsing beatmaps by sending interrupt to OsuParser
reloadThread.interrupt();
} else if (!search.getText().isEmpty()) {
// clear search text
@@ -761,8 +761,8 @@ public class SongMenu extends BasicGameState {
setFocus(prev.getNode(), prev.getIndex(), true, true);
} else {
// random track, add previous to stack
randomStack.push(new SongNode(OsuGroupList.get().getBaseNode(focusNode.index), focusNode.osuFileIndex));
setFocus(OsuGroupList.get().getRandomNode(), -1, true, true);
randomStack.push(new SongNode(BeatmapSetList.get().getBaseNode(focusNode.index), focusNode.beatmapIndex));
setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true);
}
break;
case Input.KEY_F3:
@@ -782,7 +782,7 @@ public class SongMenu extends BasicGameState {
break;
if (input.isKeyDown(Input.KEY_RSHIFT) || input.isKeyDown(Input.KEY_LSHIFT)) {
SoundController.playSound(SoundEffect.MENUHIT);
MenuState ms = (focusNode.osuFileIndex == -1 || focusNode.osuFiles.size() == 1) ?
MenuState ms = (focusNode.beatmapIndex == -1 || focusNode.beatmaps.size() == 1) ?
MenuState.BEATMAP_DELETE_CONFIRM : MenuState.BEATMAP_DELETE_SELECT;
((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).setMenuState(ms, focusNode);
game.enterState(Opsu.STATE_BUTTONMENU);
@@ -816,10 +816,10 @@ public class SongMenu extends BasicGameState {
case Input.KEY_RIGHT:
if (focusNode == null)
break;
OsuGroupNode next = focusNode.next;
BeatmapSetNode next = focusNode.next;
if (next != null) {
SoundController.playSound(SoundEffect.MENUCLICK);
OsuGroupNode oldStartNode = startNode;
BeatmapSetNode oldStartNode = startNode;
float oldHoverOffset = hoverOffset;
int oldHoverIndex = hoverIndex;
setFocus(next, 0, false, true);
@@ -832,13 +832,13 @@ public class SongMenu extends BasicGameState {
case Input.KEY_LEFT:
if (focusNode == null)
break;
OsuGroupNode prev = focusNode.prev;
BeatmapSetNode prev = focusNode.prev;
if (prev != null) {
SoundController.playSound(SoundEffect.MENUCLICK);
OsuGroupNode oldStartNode = startNode;
BeatmapSetNode oldStartNode = startNode;
float oldHoverOffset = hoverOffset;
int oldHoverIndex = hoverIndex;
setFocus(prev, (prev.index == focusNode.index) ? 0 : prev.osuFiles.size() - 1, false, true);
setFocus(prev, (prev.index == focusNode.index) ? 0 : prev.beatmaps.size() - 1, false, true);
if (startNode == oldStartNode) {
hoverOffset = oldHoverOffset;
hoverIndex = oldHoverIndex;
@@ -949,13 +949,13 @@ public class SongMenu extends BasicGameState {
randomStack = new Stack<SongNode>();
// set focus node if not set (e.g. theme song playing)
if (focusNode == null && OsuGroupList.get().size() > 0)
setFocus(OsuGroupList.get().getRandomNode(), -1, true, true);
if (focusNode == null && BeatmapSetList.get().size() > 0)
setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true);
// reset music track
else if (resetTrack) {
MusicController.pause();
MusicController.playAt(MusicController.getOsuFile().previewTime, true);
MusicController.playAt(MusicController.getBeatmap().previewTime, true);
resetTrack = false;
}
@@ -982,7 +982,7 @@ public class SongMenu extends BasicGameState {
// reload scores
if (focusNode != null) {
scoreMap = ScoreDB.getMapSetScores(focusNode.osuFiles.get(focusNode.osuFileIndex));
scoreMap = ScoreDB.getMapSetScores(focusNode.beatmaps.get(focusNode.beatmapIndex));
focusScores = getScoreDataForNode(focusNode, true);
}
@@ -993,31 +993,31 @@ public class SongMenu extends BasicGameState {
if (stateAction != null) {
switch (stateAction) {
case BEATMAP: // clear all scores
if (stateActionNode == null || stateActionNode.osuFileIndex == -1)
if (stateActionNode == null || stateActionNode.beatmapIndex == -1)
break;
OsuFile osu = stateActionNode.osuFiles.get(stateActionNode.osuFileIndex);
ScoreDB.deleteScore(osu);
Beatmap beatmap = stateActionNode.beatmaps.get(stateActionNode.beatmapIndex);
ScoreDB.deleteScore(beatmap);
if (stateActionNode == focusNode) {
focusScores = null;
scoreMap.remove(osu.version);
scoreMap.remove(beatmap.version);
}
break;
case SCORE: // clear single score
if (stateActionScore == null)
break;
ScoreDB.deleteScore(stateActionScore);
scoreMap = ScoreDB.getMapSetScores(focusNode.osuFiles.get(focusNode.osuFileIndex));
scoreMap = ScoreDB.getMapSetScores(focusNode.beatmaps.get(focusNode.beatmapIndex));
focusScores = getScoreDataForNode(focusNode, true);
startScore = 0;
break;
case BEATMAP_DELETE_CONFIRM: // delete song group
if (stateActionNode == null)
break;
OsuGroupNode
prev = OsuGroupList.get().getBaseNode(stateActionNode.index - 1),
next = OsuGroupList.get().getBaseNode(stateActionNode.index + 1);
BeatmapSetNode
prev = BeatmapSetList.get().getBaseNode(stateActionNode.index - 1),
next = BeatmapSetList.get().getBaseNode(stateActionNode.index + 1);
int oldIndex = stateActionNode.index, focusNodeIndex = focusNode.index, startNodeIndex = startNode.index;
OsuGroupList.get().deleteSongGroup(stateActionNode);
BeatmapSetList.get().deleteSongGroup(stateActionNode);
if (oldIndex == focusNodeIndex) {
if (prev != null)
setFocus(prev, -1, true, true);
@@ -1046,7 +1046,7 @@ public class SongMenu extends BasicGameState {
if (stateActionNode == null)
break;
int index = stateActionNode.index;
OsuGroupList.get().deleteSong(stateActionNode);
BeatmapSetList.get().deleteSong(stateActionNode);
if (stateActionNode == focusNode) {
if (stateActionNode.prev != null &&
!(stateActionNode.next != null && stateActionNode.next.index == index)) {
@@ -1088,7 +1088,7 @@ public class SongMenu extends BasicGameState {
@Override
public void run() {
// clear the beatmap cache
OsuDB.clearDatabase();
BeatmapDB.clearDatabase();
// invoke unpacker and parser
File beatmapDir = Options.getBeatmapDir();
@@ -1096,9 +1096,9 @@ public class SongMenu extends BasicGameState {
OsuParser.parseAllFiles(beatmapDir);
// initialize song list
if (OsuGroupList.get().size() > 0) {
OsuGroupList.get().init();
setFocus(OsuGroupList.get().getRandomNode(), -1, true, true);
if (BeatmapSetList.get().size() > 0) {
BeatmapSetList.get().init();
setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true);
} else
MusicController.playThemeSong();
@@ -1146,7 +1146,7 @@ public class SongMenu extends BasicGameState {
n++;
shifted = true;
} else if (n > 0 && startNode.next != null &&
OsuGroupList.get().getNode(startNode, MAX_SONG_BUTTONS) != null) {
BeatmapSetList.get().getNode(startNode, MAX_SONG_BUTTONS) != null) {
startNode = startNode.next;
buttonY -= buttonOffset / 4;
if (buttonY < headerY - height * 0.02f)
@@ -1166,69 +1166,69 @@ public class SongMenu extends BasicGameState {
/**
* Sets a new focus node.
* @param node the base node; it will be expanded if it isn't already
* @param osuFileIndex the OsuFile element to focus; if out of bounds, it will be randomly chosen
* @param beatmapIndex the beatmap element to focus; if out of bounds, it will be randomly chosen
* @param changeStartNode if true, startNode will be set to the first node in the group
* @param preview whether to start at the preview time (true) or beginning (false)
* @return the old focus node
*/
public OsuGroupNode setFocus(OsuGroupNode node, int osuFileIndex, boolean changeStartNode, boolean preview) {
public BeatmapSetNode setFocus(BeatmapSetNode node, int beatmapIndex, boolean changeStartNode, boolean preview) {
if (node == null)
return null;
hoverOffset = 0f;
hoverIndex = -1;
songInfo = null;
OsuGroupNode oldFocus = focusNode;
BeatmapSetNode oldFocus = focusNode;
// expand node before focusing it
int expandedIndex = OsuGroupList.get().getExpandedIndex();
int expandedIndex = BeatmapSetList.get().getExpandedIndex();
if (node.index != expandedIndex) {
node = OsuGroupList.get().expand(node.index);
node = BeatmapSetList.get().expand(node.index);
// if start node was previously expanded, move it
if (startNode != null && startNode.index == expandedIndex)
startNode = OsuGroupList.get().getBaseNode(startNode.index);
startNode = BeatmapSetList.get().getBaseNode(startNode.index);
}
// check osuFileIndex bounds
int length = node.osuFiles.size();
if (osuFileIndex < 0 || osuFileIndex > length - 1) // set a random index
osuFileIndex = (int) (Math.random() * length);
// check beatmapIndex bounds
int length = node.beatmaps.size();
if (beatmapIndex < 0 || beatmapIndex > length - 1) // set a random index
beatmapIndex = (int) (Math.random() * length);
// change the focus node
if (changeStartNode || (startNode.index == 0 && startNode.osuFileIndex == -1 && startNode.prev == null))
if (changeStartNode || (startNode.index == 0 && startNode.beatmapIndex == -1 && startNode.prev == null))
startNode = node;
focusNode = OsuGroupList.get().getNode(node, osuFileIndex);
OsuFile osu = focusNode.osuFiles.get(focusNode.osuFileIndex);
MusicController.play(osu, false, preview);
focusNode = BeatmapSetList.get().getNode(node, beatmapIndex);
Beatmap beatmap = focusNode.beatmaps.get(focusNode.beatmapIndex);
MusicController.play(beatmap, false, preview);
// load scores
scoreMap = ScoreDB.getMapSetScores(osu);
scoreMap = ScoreDB.getMapSetScores(beatmap);
focusScores = getScoreDataForNode(focusNode, true);
startScore = 0;
// check startNode bounds
while (startNode.index >= OsuGroupList.get().size() + length - MAX_SONG_BUTTONS && startNode.prev != null)
while (startNode.index >= BeatmapSetList.get().size() + length - MAX_SONG_BUTTONS && startNode.prev != null)
startNode = startNode.prev;
// make sure focusNode is on the screen (TODO: cleanup...)
int val = focusNode.index + focusNode.osuFileIndex - (startNode.index + MAX_SONG_BUTTONS) + 1;
int val = focusNode.index + focusNode.beatmapIndex - (startNode.index + MAX_SONG_BUTTONS) + 1;
if (val > 0) // below screen
changeIndex(val);
else { // above screen
if (focusNode.index == startNode.index) {
val = focusNode.index + focusNode.osuFileIndex - (startNode.index + startNode.osuFileIndex);
val = focusNode.index + focusNode.beatmapIndex - (startNode.index + startNode.beatmapIndex);
if (val < 0)
changeIndex(val);
} else if (startNode.index > focusNode.index) {
val = focusNode.index - focusNode.osuFiles.size() + focusNode.osuFileIndex - startNode.index + 1;
val = focusNode.index - focusNode.beatmaps.size() + focusNode.beatmapIndex - startNode.index + 1;
if (val < 0)
changeIndex(val);
}
}
// if start node is expanded and on group node, move it
if (startNode.index == focusNode.index && startNode.osuFileIndex == -1)
if (startNode.index == focusNode.index && startNode.beatmapIndex == -1)
changeIndex(1);
return oldFocus;
@@ -1255,7 +1255,7 @@ public class SongMenu extends BasicGameState {
* @param menuState the menu state determining the action
* @param node the song node to perform the action on
*/
public void doStateActionOnLoad(MenuState menuState, OsuGroupNode node) {
public void doStateActionOnLoad(MenuState menuState, BeatmapSetNode node) {
doStateActionOnLoad(menuState, node, null);
}
@@ -1274,32 +1274,32 @@ public class SongMenu extends BasicGameState {
* @param node the song node to perform the action on
* @param scoreData the score data to perform the action on
*/
private void doStateActionOnLoad(MenuState menuState, OsuGroupNode node, ScoreData scoreData) {
private void doStateActionOnLoad(MenuState menuState, BeatmapSetNode node, ScoreData scoreData) {
stateAction = menuState;
stateActionNode = node;
stateActionScore = scoreData;
}
/**
* Returns all the score data for an OsuGroupNode from scoreMap.
* Returns all the score data for an BeatmapSetNode from scoreMap.
* If no score data is available for the node, return null.
* @param node the OsuGroupNode
* @param node the BeatmapSetNode
* @param setTimeSince whether or not to set the "time since" field for the scores
* @return the ScoreData array
*/
private ScoreData[] getScoreDataForNode(OsuGroupNode node, boolean setTimeSince) {
if (scoreMap == null || scoreMap.isEmpty() || node.osuFileIndex == -1) // node not expanded
private ScoreData[] getScoreDataForNode(BeatmapSetNode node, boolean setTimeSince) {
if (scoreMap == null || scoreMap.isEmpty() || node.beatmapIndex == -1) // node not expanded
return null;
OsuFile osu = node.osuFiles.get(node.osuFileIndex);
ScoreData[] scores = scoreMap.get(osu.version);
Beatmap beatmap = node.beatmaps.get(node.beatmapIndex);
ScoreData[] scores = scoreMap.get(beatmap.version);
if (scores == null || scores.length < 1) // no scores
return null;
ScoreData s = scores[0];
if (osu.beatmapID == s.MID && osu.beatmapSetID == s.MSID &&
osu.title.equals(s.title) && osu.artist.equals(s.artist) &&
osu.creator.equals(s.creator)) {
if (beatmap.beatmapID == s.MID && beatmap.beatmapSetID == s.MSID &&
beatmap.title.equals(s.title) && beatmap.artist.equals(s.artist) &&
beatmap.creator.equals(s.creator)) {
if (setTimeSince) {
for (int i = 0; i < scores.length; i++)
scores[i].getTimeSince();
@@ -1318,9 +1318,9 @@ public class SongMenu extends BasicGameState {
SoundController.playSound(SoundEffect.MENUHIT);
MultiClip.destroyExtraClips();
OsuFile osu = MusicController.getOsuFile();
Beatmap beatmap = MusicController.getBeatmap();
Game gameState = (Game) game.getState(Opsu.STATE_GAME);
gameState.loadOsuFile(osu);
gameState.loadBeatmap(beatmap);
gameState.setRestart(Game.Restart.NEW);
gameState.setReplay(null);
game.enterState(Opsu.STATE_GAME, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));

View File

@@ -21,13 +21,13 @@ package itdelatrisu.opsu.states;
import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.OsuGroupList;
import itdelatrisu.opsu.OsuParser;
import itdelatrisu.opsu.OszUnpacker;
import itdelatrisu.opsu.UI;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.beatmap.BeatmapSetList;
import java.io.File;
@@ -89,7 +89,7 @@ public class Splash extends BasicGameState {
if (!init) {
init = true;
if (OsuGroupList.get() != null) {
if (BeatmapSetList.get() != null) {
// resources already loaded (from application restart)
finished = true;
} else {
@@ -125,12 +125,12 @@ public class Splash extends BasicGameState {
// change states when loading complete
if (finished && alpha >= 1f) {
// initialize song list
if (OsuGroupList.get().size() > 0) {
OsuGroupList.get().init();
if (BeatmapSetList.get().size() > 0) {
BeatmapSetList.get().init();
if (Options.isThemeSongEnabled())
MusicController.playThemeSong();
else
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).setFocus(OsuGroupList.get().getRandomNode(), -1, true, true);
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true);
}
// play the theme song
@@ -151,7 +151,7 @@ public class Splash extends BasicGameState {
if (++escapeCount >= 3)
container.exit();
// stop parsing OsuFiles by sending interrupt to OsuParser
// stop parsing beatmaps by sending interrupt to OsuParser
else if (thread != null)
thread.interrupt();
}