Follow-up to #27.

- Removed 'isSpinner' field from GameData.hitResult() since it's now being passed the full OsuHitObject.
- Minor Javadoc fixes.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2015-03-01 13:58:03 -05:00
parent 33e880df77
commit 4bf5943ee0
8 changed files with 57 additions and 62 deletions

View File

@ -1031,9 +1031,10 @@ public class GameData {
* @param result the hit result (HIT_* constants) * @param result the hit result (HIT_* constants)
* @param x the x coordinate * @param x the x coordinate
* @param y the y coordinate * @param y the y coordinate
* @param hitSound the object's hit sound * @param hitObject the hit object
* @param repeat the current repeat number
*/ */
public void sliderTickResult(int time, int result, float x, float y, OsuHitObject hitObject, int repeats) { public void sliderTickResult(int time, int result, float x, float y, OsuHitObject hitObject, int repeat) {
int hitValue = 0; int hitValue = 0;
switch (result) { switch (result) {
case HIT_SLIDER30: case HIT_SLIDER30:
@ -1041,9 +1042,9 @@ public class GameData {
incrementComboStreak(); incrementComboStreak();
changeHealth(1f); changeHealth(1f);
SoundController.playHitSound( SoundController.playHitSound(
hitObject.getEdgeHitSoundType(repeats), hitObject.getEdgeHitSoundType(repeat),
hitObject.getSampleSet(repeats), hitObject.getSampleSet(repeat),
hitObject.getAdditionSampleSet(repeats)); hitObject.getAdditionSampleSet(repeat));
break; break;
case HIT_SLIDER10: case HIT_SLIDER10:
hitValue = 10; hitValue = 10;
@ -1075,11 +1076,11 @@ public class GameData {
* @param y the y coordinate * @param y the y coordinate
* @param color the combo color * @param color the combo color
* @param end true if this is the last hit object in the combo * @param end true if this is the last hit object in the combo
* @param hitSound the object's hit sound * @param hitObject the hit object
* @param isSpinner whether the hit object was a spinner * @param repeat the current repeat number (for sliders, or 0 otherwise)
*/ */
public void hitResult(int time, int result, float x, float y, Color color, public void hitResult(int time, int result, float x, float y, Color color,
boolean end, OsuHitObject hitObject, int repeats, boolean isSpinner) { boolean end, OsuHitObject hitObject, int repeat) {
int hitValue = 0; int hitValue = 0;
boolean perfectHit = false; boolean perfectHit = false;
switch (result) { switch (result) {
@ -1108,10 +1109,9 @@ public class GameData {
} }
if (hitValue > 0) { if (hitValue > 0) {
SoundController.playHitSound( SoundController.playHitSound(
hitObject.getEdgeHitSoundType(repeats), hitObject.getEdgeHitSoundType(repeat),
hitObject.getSampleSet(repeats), hitObject.getSampleSet(repeat),
hitObject.getAdditionSampleSet(repeats)); hitObject.getAdditionSampleSet(repeat));
/** /**
* [SCORE FORMULA] * [SCORE FORMULA]
* Score = Hit Value + Hit Value * (Combo * Difficulty * Mod) / 25 * Score = Hit Value + Hit Value * (Combo * Difficulty * Mod) / 25
@ -1149,7 +1149,7 @@ public class GameData {
if (perfectHit && !Options.isPerfectHitBurstEnabled()) if (perfectHit && !Options.isPerfectHitBurstEnabled())
; // hide perfect hit results ; // hide perfect hit results
else else
hitResultList.add(new OsuHitObjectResult(time, result, x, y, color, isSpinner)); hitResultList.add(new OsuHitObjectResult(time, result, x, y, color, hitObject.isSpinner()));
} }
/** /**

View File

@ -89,16 +89,12 @@ public class OsuHitObject {
/** Spinner end time (in ms). */ /** Spinner end time (in ms). */
private int endTime; private int endTime;
/** Edge Hit sound type (SOUND_* bitmask). */ /** Slider edge hit sound type (SOUND_* bitmask). */
private byte[] edgeHitSound; private byte[] edgeHitSound;
/** Edge Hit sound addition (sampleSet, AdditionSampleSet). */ /** Slider edge hit sound addition (sampleSet, AdditionSampleSet). */
private byte[][] edgeAddition; private byte[][] edgeAddition;
// additional v10+ parameters not implemented...
// addition -> sampl:add:cust:vol:hitsound
// edge_hitsound, edge_addition (sliders only)
/** Current index in combo color array. */ /** Current index in combo color array. */
private int comboIndex; private int comboIndex;
@ -152,7 +148,7 @@ public class OsuHitObject {
* x,y,time,type,hitSound,endTime,addition * x,y,time,type,hitSound,endTime,addition
* 256,192,654,12,0,4029,0:0:0:0: * 256,192,654,12,0,4029,0:0:0:0:
* *
* NOTE: 'addition' is optional, and defaults to "0:0:0:0:". * NOTE: 'addition' -> sampl:add:cust:vol:hitsound (optional, defaults to "0:0:0:0:")
*/ */
String tokens[] = line.split(","); String tokens[] = line.split(",");
@ -167,7 +163,7 @@ public class OsuHitObject {
if ((type & OsuHitObject.TYPE_CIRCLE) > 0) { if ((type & OsuHitObject.TYPE_CIRCLE) > 0) {
if (tokens.length > 5) { if (tokens.length > 5) {
String[] additionTokens = tokens[5].split(":"); String[] additionTokens = tokens[5].split(":");
addition = new byte[additionTokens.length]; this.addition = new byte[additionTokens.length];
for (int j = 0; j < additionTokens.length; j++) for (int j = 0; j < additionTokens.length; j++)
this.addition[j] = Byte.parseByte(additionTokens[j]); this.addition[j] = Byte.parseByte(additionTokens[j]);
} }
@ -187,10 +183,9 @@ public class OsuHitObject {
if (tokens.length > 8) { if (tokens.length > 8) {
String[] edgeHitSoundTokens = tokens[8].split("\\|"); String[] edgeHitSoundTokens = tokens[8].split("\\|");
this.edgeHitSound = new byte[edgeHitSoundTokens.length]; this.edgeHitSound = new byte[edgeHitSoundTokens.length];
for (int j = 0; j < edgeHitSoundTokens.length; j++) { for (int j = 0; j < edgeHitSoundTokens.length; j++)
edgeHitSound[j] = Byte.parseByte(edgeHitSoundTokens[j]); edgeHitSound[j] = Byte.parseByte(edgeHitSoundTokens[j]);
} }
}
if (tokens.length > 9) { if (tokens.length > 9) {
String[] edgeAdditionTokens = tokens[9].split("\\|"); String[] edgeAdditionTokens = tokens[9].split("\\|");
this.edgeAddition = new byte[edgeAdditionTokens.length][2]; this.edgeAddition = new byte[edgeAdditionTokens.length][2];
@ -206,7 +201,7 @@ public class OsuHitObject {
if (index != -1) if (index != -1)
tokens[5] = tokens[5].substring(0, index); tokens[5] = tokens[5].substring(0, index);
this.endTime = Integer.parseInt(tokens[5]); this.endTime = Integer.parseInt(tokens[5]);
/* 'addition' not implemented. */ /* TODO: 'addition' not implemented. */
} }
} }
@ -247,7 +242,8 @@ public class OsuHitObject {
public byte getEdgeHitSoundType(int i) { public byte getEdgeHitSoundType(int i) {
if (edgeHitSound != null) if (edgeHitSound != null)
return edgeHitSound[i]; return edgeHitSound[i];
else return hitSound; else
return hitSound;
} }
/** /**
@ -340,22 +336,26 @@ public class OsuHitObject {
public int getComboSkip() { return (type >> TYPE_NEWCOMBO); } public int getComboSkip() { return (type >> TYPE_NEWCOMBO); }
/** /**
* Returns the Sample Set at i. * Returns the sample set at the given index.
* @param index the index (for sliders, ignored otherwise)
* @return the sample set, or 0 if none available
*/ */
public byte getSampleSet(int i) { public byte getSampleSet(int index) {
if (edgeAddition != null) if (edgeAddition != null)
return edgeAddition[i][0]; return edgeAddition[index][0];
if (addition != null) if (addition != null)
return addition[0]; return addition[0];
return 0; return 0;
} }
/** /**
* Returns the Addition Sample Set at i. * Returns the 'addition' sample set at the given index.
* @param index the index (for sliders, ignored otherwise)
* @return the sample set, or 0 if none available
*/ */
public byte getAdditionSampleSet(int i) { public byte getAdditionSampleSet(int index) {
if (edgeAddition != null) if (edgeAddition != null)
return edgeAddition[i][1]; return edgeAddition[index][1];
if (addition != null) if (addition != null)
return addition[1]; return addition[1];
return 0; return 0;

View File

@ -130,7 +130,7 @@ public enum HitSound implements SoundController.SoundComponent {
/** /**
* Sets the default sample set to use when playing hit sounds. * Sets the default sample set to use when playing hit sounds.
* @param sampleSet the sample set (0:auto, 1:normal, 2:soft, 3:drum) * @param sampleType the sample set (0:auto, 1:normal, 2:soft, 3:drum)
*/ */
public static void setDefaultSampleSet(byte sampleType) { public static void setDefaultSampleSet(byte sampleType) {
currentDefaultSampleSet = SampleSet.NORMAL; currentDefaultSampleSet = SampleSet.NORMAL;
@ -141,6 +141,7 @@ public enum HitSound implements SoundController.SoundComponent {
} }
} }
} }
/** /**
* Sets the sample set to use when playing hit sounds. * Sets the sample set to use when playing hit sounds.
* @param sampleType the sample set (0:auto, 1:normal, 2:soft, 3:drum) * @param sampleType the sample set (0:auto, 1:normal, 2:soft, 3:drum)
@ -154,6 +155,4 @@ public enum HitSound implements SoundController.SoundComponent {
} }
} }
} }
} }

View File

@ -251,6 +251,8 @@ public class SoundController {
/** /**
* Plays hit sound(s) using an OsuHitObject bitmask. * Plays hit sound(s) using an OsuHitObject bitmask.
* @param hitSound the hit sound (bitmask) * @param hitSound the hit sound (bitmask)
* @param sampleSet the sample set
* @param additionSampleSet the 'addition' sample set
*/ */
public static void playHitSound(byte hitSound, byte sampleSet, byte additionSampleSet) { public static void playHitSound(byte hitSound, byte sampleSet, byte additionSampleSet) {
if (hitSound < 0) if (hitSound < 0)

View File

@ -141,7 +141,7 @@ public class Circle implements HitObject {
data.hitResult( data.hitResult(
hitObject.getTime(), result, hitObject.getTime(), result,
hitObject.getX(), hitObject.getY(), hitObject.getX(), hitObject.getY(),
color, comboEnd, hitObject, 0, false color, comboEnd, hitObject, 0
); );
return true; return true;
} }
@ -160,17 +160,17 @@ public class Circle implements HitObject {
if (overlap || trackPosition > time + hitResultOffset[GameData.HIT_50]) { if (overlap || trackPosition > time + hitResultOffset[GameData.HIT_50]) {
if (isAutoMod) // "auto" mod: catch any missed notes due to lag if (isAutoMod) // "auto" mod: catch any missed notes due to lag
data.hitResult(time, GameData.HIT_300, x, y, color, comboEnd, hitObject, 0, false); data.hitResult(time, GameData.HIT_300, x, y, color, comboEnd, hitObject, 0);
else // no more points can be scored, so send a miss else // no more points can be scored, so send a miss
data.hitResult(time, GameData.HIT_MISS, x, y, null, comboEnd, hitObject, 0, false); data.hitResult(time, GameData.HIT_MISS, x, y, null, comboEnd, hitObject, 0);
return true; return true;
} }
// "auto" mod: send a perfect hit result // "auto" mod: send a perfect hit result
else if (isAutoMod) { else if (isAutoMod) {
if (Math.abs(trackPosition - time) < hitResultOffset[GameData.HIT_300]) { if (Math.abs(trackPosition - time) < hitResultOffset[GameData.HIT_300]) {
data.hitResult(time, GameData.HIT_300, x, y, color, comboEnd, hitObject, 0, false); data.hitResult(time, GameData.HIT_300, x, y, color, comboEnd, hitObject, 0);
return true; return true;
} }
} }

View File

@ -253,14 +253,10 @@ public class Slider implements HitObject {
if (currentRepeats % 2 == 0) { // last circle if (currentRepeats % 2 == 0) { // last circle
float[] lastPos = curve.pointAt(1); float[] lastPos = curve.pointAt(1);
data.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result, data.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result,
lastPos[0],lastPos[1], color, comboEnd, lastPos[0], lastPos[1], color, comboEnd, hitObject, currentRepeats + 1);
hitObject, currentRepeats+1
, false);
} else { // first circle } else { // first circle
data.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result, data.hitResult(hitObject.getTime() + (int) sliderTimeTotal, result,
hitObject.getX(), hitObject.getY(), color, comboEnd, hitObject.getX(), hitObject.getY(), color, comboEnd, hitObject, currentRepeats + 1);
hitObject, currentRepeats+1
, false);
} }
return result; return result;
@ -290,9 +286,7 @@ public class Slider implements HitObject {
data.addHitError(hitObject.getTime(), x,y,trackPosition - hitObject.getTime()); data.addHitError(hitObject.getTime(), x,y,trackPosition - hitObject.getTime());
sliderClickedInitial = true; sliderClickedInitial = true;
data.sliderTickResult(hitObject.getTime(), result, data.sliderTickResult(hitObject.getTime(), result,
hitObject.getX(), hitObject.getY(), hitObject.getX(), hitObject.getY(), hitObject, currentRepeats);
hitObject, currentRepeats
);
return true; return true;
} }
} }

View File

@ -164,7 +164,7 @@ public class Spinner implements HitObject {
result = GameData.HIT_MISS; result = GameData.HIT_MISS;
data.hitResult(hitObject.getEndTime(), result, width / 2, height / 2, data.hitResult(hitObject.getEndTime(), result, width / 2, height / 2,
Color.transparent, true, hitObject, 0, true); Color.transparent, true, hitObject, 0);
return result; return result;
} }