SoundController refactoring.

- Added enum classes SoundEffect and HitSound.
- Added a SoundComponent interface for sound effects and hit sounds, and extended playSound() and playHitSound() methods to play any SoundComponent.
- Moved features related to sample sets to the HitSound class, and rewrote sample sets as an internal enum class.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2015-01-07 19:29:51 -05:00
parent 3127571886
commit 1e806bc9c6
17 changed files with 365 additions and 219 deletions

View File

@ -18,6 +18,10 @@
package itdelatrisu.opsu; package itdelatrisu.opsu;
import itdelatrisu.opsu.audio.HitSound;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.audio.SoundEffect;
import itdelatrisu.opsu.states.Options; import itdelatrisu.opsu.states.Options;
import java.io.File; import java.io.File;
@ -841,7 +845,7 @@ public class GameScore {
*/ */
private void resetComboStreak() { private void resetComboStreak() {
if (combo >= 20) if (combo >= 20)
SoundController.playSound(SoundController.SOUND_COMBOBREAK); SoundController.playSound(SoundEffect.COMBOBREAK);
combo = 0; combo = 0;
if (GameMod.SUDDEN_DEATH.isActive()) if (GameMod.SUDDEN_DEATH.isActive())
health = 0f; health = 0f;
@ -867,7 +871,7 @@ public class GameScore {
case HIT_SLIDER10: case HIT_SLIDER10:
hitValue = 10; hitValue = 10;
incrementComboStreak(); incrementComboStreak();
SoundController.playHitSound(SoundController.HIT_SLIDERTICK); SoundController.playHitSound(HitSound.SLIDERTICK);
break; break;
case HIT_MISS: case HIT_MISS:
resetComboStreak(); resetComboStreak();

View File

@ -18,6 +18,7 @@
package itdelatrisu.opsu; package itdelatrisu.opsu;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.states.Game; import itdelatrisu.opsu.states.Game;
import itdelatrisu.opsu.states.GamePauseMenu; import itdelatrisu.opsu.states.GamePauseMenu;
import itdelatrisu.opsu.states.GameRanking; import itdelatrisu.opsu.states.GameRanking;

View File

@ -18,6 +18,8 @@
package itdelatrisu.opsu; package itdelatrisu.opsu;
import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.audio.SoundEffect;
import itdelatrisu.opsu.states.Options; import itdelatrisu.opsu.states.Options;
import java.awt.Font; import java.awt.Font;
@ -476,7 +478,7 @@ public class Utils {
File file = new File(dir, String.format("screenshot_%s.%s", File file = new File(dir, String.format("screenshot_%s.%s",
date.format(new Date()), Options.getScreenshotFormat())); date.format(new Date()), Options.getScreenshotFormat()));
SoundController.playSound(SoundController.SOUND_SHUTTER); SoundController.playSound(SoundEffect.SHUTTER);
// copy the screen // copy the screen
Image screen = new Image(container.getWidth(), container.getHeight()); Image screen = new Image(container.getWidth(), container.getHeight());

View File

@ -0,0 +1,159 @@
/*
* opsu! - an open-source osu! client
* Copyright (C) 2014 Jeffrey Han
*
* opsu! is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* opsu! is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with opsu!. If not, see <http://www.gnu.org/licenses/>.
*/
package itdelatrisu.opsu.audio;
import java.util.HashMap;
import javax.sound.sampled.Clip;
/**
* Hit sounds.
*/
public enum HitSound implements SoundController.SoundComponent {
CLAP ("hitclap"),
FINISH ("hitfinish"),
NORMAL ("hitnormal"),
WHISTLE ("hitwhistle"),
SLIDERSLIDE ("sliderslide"),
SLIDERTICK ("slidertick"),
SLIDERWHISTLE ("sliderwhistle");
/**
* Sound sample sets.
*/
public static enum SampleSet {
NORMAL ("normal", 1),
SOFT ("soft", 2),
DRUM ("drum", 3);
// TAIKO ("taiko", 4);
/**
* The sample set name.
*/
private String name;
/**
* The sample set index.
*/
private int index;
/**
* Total number of sample sets.
*/
public static final int SIZE = SampleSet.values().length;
/**
* Constructor.
* @param name the sample set name
*/
SampleSet(String name, int index) {
this.name = name;
this.index = index;
}
/**
* Returns the sample set name.
* @return the name
*/
public String getName() { return name; }
/**
* Returns the sample set index.
* @return the index
*/
public int getIndex() { return index; }
}
/**
* Current sample set.
*/
private static SampleSet currentSampleSet;
/**
* The file name.
*/
private String filename;
/**
* The Clip associated with the hit sound.
*/
private HashMap<SampleSet, Clip> clips;
/**
* Total number of hit sounds.
*/
public static final int SIZE = HitSound.values().length;
/**
* Constructor.
* @param filename the sound file name
*/
HitSound(String filename) {
this.filename = filename;
this.clips = new HashMap<SampleSet, Clip>();
}
/**
* Returns the file name.
* @return the file name
*/
public String getFileName() { return filename; }
@Override
public Clip getClip() {
return (currentSampleSet != null) ? clips.get(currentSampleSet) : null;
}
/**
* Sets the hit sound Clip for the sample type.
* @param s the sample set
* @param clip the Clip
*/
public void setClip(SampleSet s, Clip clip) {
clips.put(s, clip);
}
/**
* Sets the sample set to use when playing hit sounds.
* @param sampleSet the sample set ("None", "Normal", "Soft", "Drum")
*/
public static void setSampleSet(String sampleSet) {
currentSampleSet = null;
for (SampleSet ss : SampleSet.values()) {
if (sampleSet.equalsIgnoreCase(ss.getName())) {
currentSampleSet = ss;
return;
}
}
}
/**
* Sets the sample set to use when playing hit sounds.
* @param sampleType the sample set (0:none, 1:normal, 2:soft, 3:drum)
*/
public static void setSampleSet(byte sampleType) {
currentSampleSet = null;
for (SampleSet ss : SampleSet.values()) {
if (sampleType == ss.getIndex()) {
currentSampleSet = ss;
return;
}
}
}
}

View File

@ -16,8 +16,10 @@
* along with opsu!. If not, see <http://www.gnu.org/licenses/>. * along with opsu!. If not, see <http://www.gnu.org/licenses/>.
*/ */
package itdelatrisu.opsu; package itdelatrisu.opsu.audio;
import itdelatrisu.opsu.OsuFile;
import itdelatrisu.opsu.OsuParser;
import itdelatrisu.opsu.states.Options; import itdelatrisu.opsu.states.Options;
import java.io.File; import java.io.File;

View File

@ -16,8 +16,10 @@
* along with opsu!. If not, see <http://www.gnu.org/licenses/>. * along with opsu!. If not, see <http://www.gnu.org/licenses/>.
*/ */
package itdelatrisu.opsu; package itdelatrisu.opsu.audio;
import itdelatrisu.opsu.OsuHitObject;
import itdelatrisu.opsu.audio.HitSound.SampleSet;
import itdelatrisu.opsu.states.Options; import itdelatrisu.opsu.states.Options;
import java.io.IOException; import java.io.IOException;
@ -36,108 +38,20 @@ import org.newdawn.slick.util.Log;
import org.newdawn.slick.util.ResourceLoader; import org.newdawn.slick.util.ResourceLoader;
/** /**
* Controller for all sound effects. * Controller for all (non-music) sound components.
* Note: Uses Java Sound because OpenAL lags too much for accurate hit sounds. * Note: Uses Java Sound because OpenAL lags too much for accurate hit sounds.
*/ */
public class SoundController { public class SoundController {
/** /**
* Sound effect constants. * Interface for all (non-music) sound components.
*/ */
public static final int public interface SoundComponent {
SOUND_APPLAUSE = 0,
SOUND_COMBOBREAK = 1,
// SOUND_COUNT = , // ?
SOUND_COUNT1 = 2,
SOUND_COUNT2 = 3,
SOUND_COUNT3 = 4,
SOUND_FAIL = 5,
SOUND_GO = 6,
SOUND_MENUBACK = 7,
SOUND_MENUCLICK = 8,
SOUND_MENUHIT = 9,
SOUND_READY = 10,
SOUND_SECTIONFAIL = 11,
SOUND_SECTIONPASS = 12,
SOUND_SHUTTER = 13,
SOUND_SPINNERBONUS = 14,
SOUND_SPINNEROSU = 15,
SOUND_SPINNERSPIN = 16,
SOUND_MAX = 17; // not a sound
/** /**
* Sound effect names (indexed by SOUND_* constants). * Returns the Clip associated with the sound component.
* @return the Clip
*/ */
private static final String[] soundNames = { public Clip getClip();
"applause", }
"combobreak",
// "count", // ?
"count1s",
"count2s",
"count3s",
"failsound",
"gos",
"menuback",
"menuclick",
"menuhit",
"readys",
"sectionfail",
"sectionpass",
"shutter",
"spinnerbonus",
"spinner-osu",
"spinnerspin",
};
/**
* Sound effects (indexed by SOUND_* constants).
*/
private static Clip[] sounds = new Clip[SOUND_MAX];
/**
* Sound sample sets.
*/
private static final String[] sampleSets = {
"normal",
"soft",
"drum",
// "taiko"
};
/**
* Current sample set (index in sampleSet[] array).
*/
private static int sampleSetIndex = -1;
/**
* Hit sound effects.
*/
public static final int
HIT_CLAP = 0,
HIT_FINISH = 1,
HIT_NORMAL = 2,
HIT_WHISTLE = 3,
HIT_SLIDERSLIDE = 4,
HIT_SLIDERTICK = 5,
HIT_SLIDERWHISTLE = 6,
HIT_MAX = 7; // not a sound
/**
* Hit sound effect names (indexed by HIT_* constants).
*/
private static final String[] hitSoundNames = {
"hitclap",
"hitfinish",
"hitnormal",
"hitwhistle",
"sliderslide",
"slidertick",
"sliderwhistle"
};
/**
* Hit sound effects (indexed by sampleSets[], HIT_* constants).
*/
private static Clip[][] hitSounds = new Clip[sampleSets.length][HIT_MAX];
/** /**
* Sample volume multiplier, from timing points [0, 1]. * Sample volume multiplier, from timing points [0, 1].
@ -175,7 +89,7 @@ public class SoundController {
clip.open(audioIn); clip.open(audioIn);
return clip; return clip;
} catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) { } catch (UnsupportedAudioFileException | IOException | LineUnavailableException | RuntimeException e) {
Log.error(String.format("Failed to load file '%s'.", ref), e); Log.error(String.format("Failed to load file '%s'.", ref), e);
} }
return null; return null;
@ -192,16 +106,18 @@ public class SoundController {
currentFileIndex = 0; currentFileIndex = 0;
// menu and game sounds // menu and game sounds
for (int i = 0; i < SOUND_MAX; i++, currentFileIndex++) { for (SoundEffect s : SoundEffect.values()) {
currentFileName = String.format("%s.wav", soundNames[i]); currentFileName = String.format("%s.wav", s.getFileName());
sounds[i] = loadClip(currentFileName); s.setClip(loadClip(currentFileName));
currentFileIndex++;
} }
// hit sounds // hit sounds
for (int i = 0; i < sampleSets.length; i++) { for (SampleSet ss : SampleSet.values()) {
for (int j = 0; j < HIT_MAX; j++, currentFileIndex++) { for (HitSound s : HitSound.values()) {
currentFileName = String.format("%s-%s.wav", sampleSets[i], hitSoundNames[j]); currentFileName = String.format("%s-%s.wav", ss.getName(), s.getFileName());
hitSounds[i][j] = loadClip(currentFileName); s.setClip(ss, loadClip(currentFileName));
currentFileIndex++;
} }
} }
@ -209,29 +125,6 @@ public class SoundController {
currentFileIndex = -1; currentFileIndex = -1;
} }
/**
* Sets the sample set to use when playing hit sounds.
* @param sampleSet the sample set ("None", "Normal", "Soft", "Drum")
*/
public static void setSampleSet(String sampleSet) {
sampleSetIndex = -1;
for (int i = 0; i < sampleSets.length; i++) {
if (sampleSet.equalsIgnoreCase(sampleSets[i])) {
sampleSetIndex = i;
return;
}
}
}
/**
* Sets the sample set to use when playing hit sounds.
* @param sampleType the sample set (0:none, 1:normal, 2:soft, 3:drum)
*/
public static void setSampleSet(byte sampleType) {
if (sampleType >= 0 && sampleType <= 3)
sampleSetIndex = sampleType - 1;
}
/** /**
* Sets the sample volume (modifies the global sample volume). * Sets the sample volume (modifies the global sample volume).
* @param volume the sample volume [0, 1] * @param volume the sample volume [0, 1]
@ -273,21 +166,18 @@ public class SoundController {
/** /**
* Plays a sound. * Plays a sound.
* @param sound the sound (SOUND_* constant) * @param s the sound effect
*/ */
public static void playSound(int sound) { public static void playSound(SoundComponent s) {
if (sound < 0 || sound >= SOUND_MAX) playClip(s.getClip(), Options.getEffectVolume());
return;
playClip(sounds[sound], Options.getEffectVolume());
} }
/** /**
* Plays hit sound(s) using an OsuHitObject bitmask. * Plays hit sound(s) using an OsuHitObject bitmask.
* @param hitSound the sound (bitmask) * @param hitSound the hit sound (bitmask)
*/ */
public static void playHitSound(byte hitSound) { public static void playHitSound(byte hitSound) {
if (sampleSetIndex < 0 || hitSound < 0) if (hitSound < 0)
return; return;
float volume = Options.getHitSoundVolume() * sampleVolumeMultiplier; float volume = Options.getHitSoundVolume() * sampleVolumeMultiplier;
@ -296,27 +186,23 @@ public class SoundController {
// play all sounds // play all sounds
if (hitSound == OsuHitObject.SOUND_NORMAL) if (hitSound == OsuHitObject.SOUND_NORMAL)
playClip(hitSounds[sampleSetIndex][HIT_NORMAL], volume); playClip(HitSound.NORMAL.getClip(), volume);
else { else {
if ((hitSound & OsuHitObject.SOUND_WHISTLE) > 0) if ((hitSound & OsuHitObject.SOUND_WHISTLE) > 0)
playClip(hitSounds[sampleSetIndex][HIT_WHISTLE], volume); playClip(HitSound.WHISTLE.getClip(), volume);
if ((hitSound & OsuHitObject.SOUND_FINISH) > 0) if ((hitSound & OsuHitObject.SOUND_FINISH) > 0)
playClip(hitSounds[sampleSetIndex][HIT_FINISH], volume); playClip(HitSound.FINISH.getClip(), volume);
if ((hitSound & OsuHitObject.SOUND_CLAP) > 0) if ((hitSound & OsuHitObject.SOUND_CLAP) > 0)
playClip(hitSounds[sampleSetIndex][HIT_CLAP], volume); playClip(HitSound.CLAP.getClip(), volume);
} }
} }
/** /**
* Plays a hit sound. * Plays a hit sound.
* @param sound (HIT_* constant) * @param s the hit sound
*/ */
public static void playHitSound(int sound) { public static void playHitSound(SoundComponent s) {
if (sampleSetIndex < 0 || sound < 0 || sound > HIT_MAX) playClip(s.getClip(), Options.getHitSoundVolume() * sampleVolumeMultiplier);
return;
playClip(hitSounds[sampleSetIndex][sound],
Options.getHitSoundVolume() * sampleVolumeMultiplier);
} }
/** /**
@ -334,6 +220,6 @@ public class SoundController {
if (currentFileIndex == -1) if (currentFileIndex == -1)
return -1; return -1;
return currentFileIndex * 100 / (SOUND_MAX + (sampleSets.length * HIT_MAX)); return currentFileIndex * 100 / (SoundEffect.SIZE + (HitSound.SIZE * SampleSet.SIZE));
} }
} }

View File

@ -0,0 +1,83 @@
/*
* opsu! - an open-source osu! client
* Copyright (C) 2014 Jeffrey Han
*
* opsu! is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* opsu! is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with opsu!. If not, see <http://www.gnu.org/licenses/>.
*/
package itdelatrisu.opsu.audio;
import javax.sound.sampled.Clip;
/**
* Sound effects.
*/
public enum SoundEffect implements SoundController.SoundComponent {
APPLAUSE ("applause"),
COMBOBREAK ("combobreak"),
// COUNT ("count"), // ?
COUNT1 ("count1s"),
COUNT2 ("count2s"),
COUNT3 ("count3s"),
FAIL ("failsound"),
GO ("gos"),
MENUBACK ("menuback"),
MENUCLICK ("menuclick"),
MENUHIT ("menuhit"),
READY ("readys"),
SECTIONFAIL ("sectionfail"),
SECTIONPASS ("sectionpass"),
SHUTTER ("shutter"),
SPINNERBONUS ("spinnerbonus"),
SPINNEROSU ("spinner-osu"),
SPINNERSPIN ("spinnerspin");
/**
* The file name.
*/
private String filename;
/**
* The Clip associated with the sound effect.
*/
private Clip clip;
/**
* Total number of sound effects.
*/
public static final int SIZE = SoundEffect.values().length;
/**
* Constructor.
* @param filename the sound file name
*/
SoundEffect(String filename) {
this.filename = filename;
}
/**
* Returns the file name.
* @return the file name
*/
public String getFileName() { return filename; }
@Override
public Clip getClip() { return clip; }
/**
* Sets the Clip for the sound.
* @param clip the clip
*/
public void setClip(Clip clip) { this.clip = clip; }
}

View File

@ -21,9 +21,9 @@ package itdelatrisu.opsu.objects;
import itdelatrisu.opsu.GameImage; import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.GameMod; import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.GameScore; import itdelatrisu.opsu.GameScore;
import itdelatrisu.opsu.MusicController;
import itdelatrisu.opsu.OsuHitObject; import itdelatrisu.opsu.OsuHitObject;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.states.Game; import itdelatrisu.opsu.states.Game;
import org.newdawn.slick.Color; import org.newdawn.slick.Color;

View File

@ -21,10 +21,10 @@ package itdelatrisu.opsu.objects;
import itdelatrisu.opsu.GameImage; import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.GameMod; import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.GameScore; import itdelatrisu.opsu.GameScore;
import itdelatrisu.opsu.MusicController;
import itdelatrisu.opsu.OsuFile; import itdelatrisu.opsu.OsuFile;
import itdelatrisu.opsu.OsuHitObject; import itdelatrisu.opsu.OsuHitObject;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.states.Game; import itdelatrisu.opsu.states.Game;
import java.io.File; import java.io.File;

View File

@ -21,10 +21,11 @@ package itdelatrisu.opsu.objects;
import itdelatrisu.opsu.GameImage; import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.GameMod; import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.GameScore; import itdelatrisu.opsu.GameScore;
import itdelatrisu.opsu.MusicController;
import itdelatrisu.opsu.OsuHitObject; import itdelatrisu.opsu.OsuHitObject;
import itdelatrisu.opsu.SoundController;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.audio.SoundEffect;
import itdelatrisu.opsu.states.Game; import itdelatrisu.opsu.states.Game;
import org.newdawn.slick.Color; import org.newdawn.slick.Color;
@ -152,7 +153,7 @@ public class Spinner {
if (ratio >= 1.0f || if (ratio >= 1.0f ||
GameMod.AUTO.isActive() || GameMod.SPUN_OUT.isActive()) { GameMod.AUTO.isActive() || GameMod.SPUN_OUT.isActive()) {
result = GameScore.HIT_300; result = GameScore.HIT_300;
SoundController.playSound(SoundController.SOUND_SPINNEROSU); SoundController.playSound(SoundEffect.SPINNEROSU);
} else if (ratio >= 0.8f) } else if (ratio >= 0.8f)
result = GameScore.HIT_100; result = GameScore.HIT_100;
else if (ratio >= 0.5f) else if (ratio >= 0.5f)
@ -231,10 +232,10 @@ public class Spinner {
if (Math.floor(newRotations) > rotations) { if (Math.floor(newRotations) > rotations) {
if (newRotations > rotationsNeeded) { // extra rotations if (newRotations > rotationsNeeded) { // extra rotations
score.changeScore(1000); score.changeScore(1000);
SoundController.playSound(SoundController.SOUND_SPINNERBONUS); SoundController.playSound(SoundEffect.SPINNERBONUS);
} else { } else {
score.changeScore(100); score.changeScore(100);
SoundController.playSound(SoundController.SOUND_SPINNERSPIN); SoundController.playSound(SoundEffect.SPINNERSPIN);
} }
} }

View File

@ -18,17 +18,19 @@
package itdelatrisu.opsu.states; package itdelatrisu.opsu.states;
import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.GameImage; import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.GameMod; import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.GameScore; import itdelatrisu.opsu.GameScore;
import itdelatrisu.opsu.MusicController; import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.Opsu; import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.OsuFile; import itdelatrisu.opsu.OsuFile;
import itdelatrisu.opsu.OsuHitObject; import itdelatrisu.opsu.OsuHitObject;
import itdelatrisu.opsu.OsuTimingPoint; import itdelatrisu.opsu.OsuTimingPoint;
import itdelatrisu.opsu.SoundController;
import itdelatrisu.opsu.Utils; 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.objects.Circle; import itdelatrisu.opsu.objects.Circle;
import itdelatrisu.opsu.objects.Slider; import itdelatrisu.opsu.objects.Slider;
import itdelatrisu.opsu.objects.Spinner; import itdelatrisu.opsu.objects.Spinner;
@ -292,13 +294,13 @@ public class Game extends BasicGameState {
if (score.getHealth() >= 50) { if (score.getHealth() >= 50) {
GameImage.SECTION_PASS.getImage().drawCentered(width / 2f, height / 2f); GameImage.SECTION_PASS.getImage().drawCentered(width / 2f, height / 2f);
if (!breakSound) { if (!breakSound) {
SoundController.playSound(SoundController.SOUND_SECTIONPASS); SoundController.playSound(SoundEffect.SECTIONPASS);
breakSound = true; breakSound = true;
} }
} else { } else {
GameImage.SECTION_FAIL.getImage().drawCentered(width / 2f, height / 2f); GameImage.SECTION_FAIL.getImage().drawCentered(width / 2f, height / 2f);
if (!breakSound) { if (!breakSound) {
SoundController.playSound(SoundController.SOUND_SECTIONFAIL); SoundController.playSound(SoundEffect.SECTIONFAIL);
breakSound = true; breakSound = true;
} }
} }
@ -359,28 +361,28 @@ public class Game extends BasicGameState {
if (timeDiff >= 1500) { if (timeDiff >= 1500) {
GameImage.COUNTDOWN_READY.getImage().drawCentered(width / 2, height / 2); GameImage.COUNTDOWN_READY.getImage().drawCentered(width / 2, height / 2);
if (!countdownReadySound) { if (!countdownReadySound) {
SoundController.playSound(SoundController.SOUND_READY); SoundController.playSound(SoundEffect.READY);
countdownReadySound = true; countdownReadySound = true;
} }
} }
if (timeDiff < 2000) { if (timeDiff < 2000) {
GameImage.COUNTDOWN_3.getImage().draw(0, 0); GameImage.COUNTDOWN_3.getImage().draw(0, 0);
if (!countdown3Sound) { if (!countdown3Sound) {
SoundController.playSound(SoundController.SOUND_COUNT3); SoundController.playSound(SoundEffect.COUNT3);
countdown3Sound = true; countdown3Sound = true;
} }
} }
if (timeDiff < 1500) { if (timeDiff < 1500) {
GameImage.COUNTDOWN_2.getImage().draw(width - GameImage.COUNTDOWN_2.getImage().getWidth(), 0); GameImage.COUNTDOWN_2.getImage().draw(width - GameImage.COUNTDOWN_2.getImage().getWidth(), 0);
if (!countdown2Sound) { if (!countdown2Sound) {
SoundController.playSound(SoundController.SOUND_COUNT2); SoundController.playSound(SoundEffect.COUNT2);
countdown2Sound = true; countdown2Sound = true;
} }
} }
if (timeDiff < 1000) { if (timeDiff < 1000) {
GameImage.COUNTDOWN_1.getImage().drawCentered(width / 2, height / 2); GameImage.COUNTDOWN_1.getImage().drawCentered(width / 2, height / 2);
if (!countdown1Sound) { if (!countdown1Sound) {
SoundController.playSound(SoundController.SOUND_COUNT1); SoundController.playSound(SoundEffect.COUNT1);
countdown1Sound = true; countdown1Sound = true;
} }
} }
@ -389,7 +391,7 @@ public class Game extends BasicGameState {
go.setAlpha((timeDiff < 0) ? 1 - (timeDiff / -1000f) : 1); go.setAlpha((timeDiff < 0) ? 1 - (timeDiff / -1000f) : 1);
go.drawCentered(width / 2, height / 2); go.drawCentered(width / 2, height / 2);
if (!countdownGoSound) { if (!countdownGoSound) {
SoundController.playSound(SoundController.SOUND_GO); SoundController.playSound(SoundEffect.GO);
countdownGoSound = true; countdownGoSound = true;
} }
} }
@ -510,7 +512,7 @@ public class Game extends BasicGameState {
beatLengthBase = beatLength = timingPoint.getBeatLength(); beatLengthBase = beatLength = timingPoint.getBeatLength();
else else
beatLength = beatLengthBase * timingPoint.getSliderMultiplier(); beatLength = beatLengthBase * timingPoint.getSliderMultiplier();
SoundController.setSampleSet(timingPoint.getSampleType()); HitSound.setSampleSet(timingPoint.getSampleType());
SoundController.setSampleVolume(timingPoint.getSampleVolume()); SoundController.setSampleVolume(timingPoint.getSampleVolume());
timingPointIndex++; timingPointIndex++;
} }
@ -650,7 +652,7 @@ public class Game extends BasicGameState {
int position = (pauseTime > -1) ? pauseTime : trackPosition; int position = (pauseTime > -1) ? pauseTime : trackPosition;
if (Options.setCheckpoint(position / 1000)) if (Options.setCheckpoint(position / 1000))
SoundController.playSound(SoundController.SOUND_MENUCLICK); SoundController.playSound(SoundEffect.MENUCLICK);
} }
break; break;
case Input.KEY_L: case Input.KEY_L:
@ -667,7 +669,7 @@ public class Game extends BasicGameState {
leadInTime = 0; leadInTime = 0;
MusicController.resume(); MusicController.resume();
} }
SoundController.playSound(SoundController.SOUND_MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
// skip to checkpoint // skip to checkpoint
MusicController.setPosition(checkpoint); MusicController.setPosition(checkpoint);
@ -805,7 +807,7 @@ public class Game extends BasicGameState {
OsuTimingPoint timingPoint = osu.timingPoints.get(0); OsuTimingPoint timingPoint = osu.timingPoints.get(0);
if (!timingPoint.isInherited()) { if (!timingPoint.isInherited()) {
beatLengthBase = beatLength = timingPoint.getBeatLength(); beatLengthBase = beatLength = timingPoint.getBeatLength();
SoundController.setSampleSet(timingPoint.getSampleType()); HitSound.setSampleSet(timingPoint.getSampleType());
SoundController.setSampleVolume(timingPoint.getSampleVolume()); SoundController.setSampleVolume(timingPoint.getSampleVolume());
timingPointIndex++; timingPointIndex++;
} }
@ -839,7 +841,7 @@ public class Game extends BasicGameState {
MusicController.resume(); MusicController.resume();
} }
MusicController.setPosition(firstObjectTime - SKIP_OFFSET); MusicController.setPosition(firstObjectTime - SKIP_OFFSET);
SoundController.playSound(SoundController.SOUND_MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
return true; return true;
} }
return false; return false;

View File

@ -18,12 +18,13 @@
package itdelatrisu.opsu.states; package itdelatrisu.opsu.states;
import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.GameImage; import itdelatrisu.opsu.GameImage;
import itdelatrisu.opsu.MusicController; import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.Opsu; import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.SoundController;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.audio.SoundEffect;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import org.newdawn.slick.Color; import org.newdawn.slick.Color;
@ -126,10 +127,10 @@ public class GamePauseMenu extends BasicGameState {
if (Game.getRestart() == Game.RESTART_LOSE) { if (Game.getRestart() == Game.RESTART_LOSE) {
MusicController.stop(); MusicController.stop();
MusicController.playAt(MusicController.getOsuFile().previewTime, true); MusicController.playAt(MusicController.getOsuFile().previewTime, true);
SoundController.playSound(SoundController.SOUND_MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
} else { } else {
SoundController.playSound(SoundController.SOUND_MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
Game.setRestart(Game.RESTART_FALSE); Game.setRestart(Game.RESTART_FALSE);
game.enterState(Opsu.STATE_GAME); game.enterState(Opsu.STATE_GAME);
} }
@ -159,17 +160,17 @@ public class GamePauseMenu extends BasicGameState {
return; return;
if (continueButton.contains(x, y) && !loseState) { if (continueButton.contains(x, y) && !loseState) {
SoundController.playSound(SoundController.SOUND_MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
Game.setRestart(Game.RESTART_FALSE); Game.setRestart(Game.RESTART_FALSE);
game.enterState(Opsu.STATE_GAME); game.enterState(Opsu.STATE_GAME);
} else if (retryButton.contains(x, y)) { } else if (retryButton.contains(x, y)) {
SoundController.playSound(SoundController.SOUND_MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
Game.setRestart(Game.RESTART_MANUAL); Game.setRestart(Game.RESTART_MANUAL);
game.enterState(Opsu.STATE_GAME); game.enterState(Opsu.STATE_GAME);
} else if (backButton.contains(x, y)) { } else if (backButton.contains(x, y)) {
MusicController.pause(); // lose state MusicController.pause(); // lose state
MusicController.playAt(MusicController.getOsuFile().previewTime, true); MusicController.playAt(MusicController.getOsuFile().previewTime, true);
SoundController.playSound(SoundController.SOUND_MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
} }
} }
@ -180,7 +181,7 @@ public class GamePauseMenu extends BasicGameState {
pauseStartTime = System.currentTimeMillis(); pauseStartTime = System.currentTimeMillis();
if (Game.getRestart() == Game.RESTART_LOSE) { if (Game.getRestart() == Game.RESTART_LOSE) {
MusicController.fadeOut(FADEOUT_TIME); MusicController.fadeOut(FADEOUT_TIME);
SoundController.playSound(SoundController.SOUND_FAIL); SoundController.playSound(SoundEffect.FAIL);
} else } else
MusicController.pause(); MusicController.pause();
continueButton.setScale(1f); continueButton.setScale(1f);

View File

@ -18,14 +18,15 @@
package itdelatrisu.opsu.states; package itdelatrisu.opsu.states;
import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.GameMod; import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.GameScore; import itdelatrisu.opsu.GameScore;
import itdelatrisu.opsu.MusicController; import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.Opsu; import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.OsuFile; import itdelatrisu.opsu.OsuFile;
import itdelatrisu.opsu.SoundController;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.audio.SoundEffect;
import org.lwjgl.opengl.Display; import org.lwjgl.opengl.Display;
import org.newdawn.slick.Color; import org.newdawn.slick.Color;
@ -153,7 +154,7 @@ public class GameRanking extends BasicGameState {
case Input.KEY_ESCAPE: case Input.KEY_ESCAPE:
MusicController.pause(); MusicController.pause();
MusicController.playAt(MusicController.getOsuFile().previewTime, true); MusicController.playAt(MusicController.getOsuFile().previewTime, true);
SoundController.playSound(SoundController.SOUND_MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
break; break;
case Input.KEY_F12: case Input.KEY_F12:
@ -172,16 +173,16 @@ public class GameRanking extends BasicGameState {
OsuFile osu = MusicController.getOsuFile(); OsuFile osu = MusicController.getOsuFile();
Display.setTitle(String.format("%s - %s", game.getTitle(), osu.toString())); Display.setTitle(String.format("%s - %s", game.getTitle(), osu.toString()));
Game.setRestart(Game.RESTART_MANUAL); Game.setRestart(Game.RESTART_MANUAL);
SoundController.playSound(SoundController.SOUND_MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
game.enterState(Opsu.STATE_GAME, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_GAME, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
} else if (exitButton.contains(x, y)) { } else if (exitButton.contains(x, y)) {
SoundController.playSound(SoundController.SOUND_MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
((MainMenu) game.getState(Opsu.STATE_MAINMENU)).reset(); ((MainMenu) game.getState(Opsu.STATE_MAINMENU)).reset();
game.enterState(Opsu.STATE_MAINMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_MAINMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
} else if (Utils.getBackButton().contains(x, y)) { } else if (Utils.getBackButton().contains(x, y)) {
MusicController.pause(); MusicController.pause();
MusicController.playAt(MusicController.getOsuFile().previewTime, true); MusicController.playAt(MusicController.getOsuFile().previewTime, true);
SoundController.playSound(SoundController.SOUND_MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
} }
} }
@ -191,6 +192,6 @@ public class GameRanking extends BasicGameState {
throws SlickException { throws SlickException {
Display.setTitle(game.getTitle()); Display.setTitle(game.getTitle());
Utils.getBackButton().setScale(1f); Utils.getBackButton().setScale(1f);
SoundController.playSound(SoundController.SOUND_APPLAUSE); SoundController.playSound(SoundEffect.APPLAUSE);
} }
} }

View File

@ -19,12 +19,13 @@
package itdelatrisu.opsu.states; package itdelatrisu.opsu.states;
import itdelatrisu.opsu.MenuButton; import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.MusicController;
import itdelatrisu.opsu.Opsu; import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.OsuFile; import itdelatrisu.opsu.OsuFile;
import itdelatrisu.opsu.OsuGroupNode; import itdelatrisu.opsu.OsuGroupNode;
import itdelatrisu.opsu.SoundController;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.audio.SoundEffect;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@ -355,14 +356,14 @@ public class MainMenu extends BasicGameState {
logoTimer = 0; logoTimer = 0;
playButton.getImage().setAlpha(0f); playButton.getImage().setAlpha(0f);
exitButton.getImage().setAlpha(0f); exitButton.getImage().setAlpha(0f);
SoundController.playSound(SoundController.SOUND_MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
} }
} }
// other button actions (if visible) // other button actions (if visible)
else if (logoClicked) { else if (logoClicked) {
if (logo.contains(x, y) || playButton.contains(x, y)) { if (logo.contains(x, y) || playButton.contains(x, y)) {
SoundController.playSound(SoundController.SOUND_MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
} else if (exitButton.contains(x, y)) { } else if (exitButton.contains(x, y)) {
Options.saveOptions(); Options.saveOptions();
@ -385,9 +386,9 @@ public class MainMenu extends BasicGameState {
logoTimer = 0; logoTimer = 0;
playButton.getImage().setAlpha(0f); playButton.getImage().setAlpha(0f);
exitButton.getImage().setAlpha(0f); exitButton.getImage().setAlpha(0f);
SoundController.playSound(SoundController.SOUND_MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
} else { } else {
SoundController.playSound(SoundController.SOUND_MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
} }
break; break;

View File

@ -18,12 +18,13 @@
package itdelatrisu.opsu.states; package itdelatrisu.opsu.states;
import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.GameMod; import itdelatrisu.opsu.GameMod;
import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.Opsu; import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.OsuFile; import itdelatrisu.opsu.OsuFile;
import itdelatrisu.opsu.SoundController;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.audio.SoundEffect;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter; import java.io.BufferedWriter;
@ -548,7 +549,7 @@ public class Options extends BasicGameState {
// back // back
if (Utils.getBackButton().contains(x, y)) { if (Utils.getBackButton().contains(x, y)) {
SoundController.playSound(SoundController.SOUND_MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition(Color.black));
return; return;
} }
@ -558,7 +559,7 @@ public class Options extends BasicGameState {
if (optionTabs[i].contains(x, y)) { if (optionTabs[i].contains(x, y)) {
if (i != currentTab) { if (i != currentTab) {
currentTab = i; currentTab = i;
SoundController.playSound(SoundController.SOUND_MENUCLICK); SoundController.playSound(SoundEffect.MENUCLICK);
} }
return; return;
} }
@ -570,7 +571,7 @@ public class Options extends BasicGameState {
boolean prevState = mod.isActive(); boolean prevState = mod.isActive();
mod.toggle(true); mod.toggle(true);
if (mod.isActive() != prevState) if (mod.isActive() != prevState)
SoundController.playSound(SoundController.SOUND_MENUCLICK); SoundController.playSound(SoundEffect.MENUCLICK);
return; return;
} }
} }
@ -766,7 +767,7 @@ public class Options extends BasicGameState {
switch (key) { switch (key) {
case Input.KEY_ESCAPE: case Input.KEY_ESCAPE:
SoundController.playSound(SoundController.SOUND_MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition(Color.black));
break; break;
case Input.KEY_F12: case Input.KEY_F12:
@ -777,7 +778,7 @@ public class Options extends BasicGameState {
if (input.isKeyDown(Input.KEY_LSHIFT) || input.isKeyDown(Input.KEY_RSHIFT)) if (input.isKeyDown(Input.KEY_LSHIFT) || input.isKeyDown(Input.KEY_RSHIFT))
i = TAB_MAX - 1; i = TAB_MAX - 1;
currentTab = (currentTab + i) % TAB_MAX; currentTab = (currentTab + i) % TAB_MAX;
SoundController.playSound(SoundController.SOUND_MENUCLICK); SoundController.playSound(SoundEffect.MENUCLICK);
break; break;
} }
} }

View File

@ -19,14 +19,16 @@
package itdelatrisu.opsu.states; package itdelatrisu.opsu.states;
import itdelatrisu.opsu.MenuButton; import itdelatrisu.opsu.MenuButton;
import itdelatrisu.opsu.MusicController;
import itdelatrisu.opsu.Opsu; import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.OsuFile; import itdelatrisu.opsu.OsuFile;
import itdelatrisu.opsu.OsuGroupNode; import itdelatrisu.opsu.OsuGroupNode;
import itdelatrisu.opsu.OsuParser; import itdelatrisu.opsu.OsuParser;
import itdelatrisu.opsu.SongSort; import itdelatrisu.opsu.SongSort;
import itdelatrisu.opsu.SoundController;
import itdelatrisu.opsu.Utils; 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 org.lwjgl.opengl.Display; import org.lwjgl.opengl.Display;
import org.newdawn.slick.Animation; import org.newdawn.slick.Animation;
@ -351,7 +353,7 @@ public class SongMenu extends BasicGameState {
// back // back
if (Utils.getBackButton().contains(x, y)) { if (Utils.getBackButton().contains(x, y)) {
SoundController.playSound(SoundController.SOUND_MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
((MainMenu) game.getState(Opsu.STATE_MAINMENU)).reset(); ((MainMenu) game.getState(Opsu.STATE_MAINMENU)).reset();
game.enterState(Opsu.STATE_MAINMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_MAINMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
return; return;
@ -359,7 +361,7 @@ public class SongMenu extends BasicGameState {
// options // options
if (optionsButton.contains(x, y)) { if (optionsButton.contains(x, y)) {
SoundController.playSound(SoundController.SOUND_MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
game.enterState(Opsu.STATE_OPTIONS, new EmptyTransition(), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_OPTIONS, new EmptyTransition(), new FadeInTransition(Color.black));
return; return;
} }
@ -372,7 +374,7 @@ public class SongMenu extends BasicGameState {
if (sort.contains(x, y)) { if (sort.contains(x, y)) {
if (sort != SongSort.getSort()) { if (sort != SongSort.getSort()) {
SongSort.setSort(sort); SongSort.setSort(sort);
SoundController.playSound(SoundController.SOUND_MENUCLICK); SoundController.playSound(SoundEffect.MENUCLICK);
OsuGroupNode oldFocusBase = Opsu.groups.getBaseNode(focusNode.index); OsuGroupNode oldFocusBase = Opsu.groups.getBaseNode(focusNode.index);
int oldFocusFileIndex = focusNode.osuFileIndex; int oldFocusFileIndex = focusNode.osuFileIndex;
focusNode = null; focusNode = null;
@ -400,7 +402,7 @@ public class SongMenu extends BasicGameState {
} else { } else {
// focus the node // focus the node
SoundController.playSound(SoundController.SOUND_MENUCLICK); SoundController.playSound(SoundEffect.MENUCLICK);
setFocus(node, 0, false); setFocus(node, 0, false);
} }
break; break;
@ -408,7 +410,7 @@ public class SongMenu extends BasicGameState {
// clicked node is a new group // clicked node is a new group
else { else {
SoundController.playSound(SoundController.SOUND_MENUCLICK); SoundController.playSound(SoundEffect.MENUCLICK);
setFocus(node, -1, false); setFocus(node, -1, false);
break; break;
} }
@ -424,7 +426,7 @@ public class SongMenu extends BasicGameState {
search.setText(""); search.setText("");
searchTimer = SEARCH_DELAY; searchTimer = SEARCH_DELAY;
} else { } else {
SoundController.playSound(SoundController.SOUND_MENUBACK); SoundController.playSound(SoundEffect.MENUBACK);
((MainMenu) game.getState(Opsu.STATE_MAINMENU)).reset(); ((MainMenu) game.getState(Opsu.STATE_MAINMENU)).reset();
game.enterState(Opsu.STATE_MAINMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_MAINMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
} }
@ -453,7 +455,7 @@ public class SongMenu extends BasicGameState {
break; break;
OsuGroupNode next = focusNode.next; OsuGroupNode next = focusNode.next;
if (next != null) { if (next != null) {
SoundController.playSound(SoundController.SOUND_MENUCLICK); SoundController.playSound(SoundEffect.MENUCLICK);
setFocus(next, 0, false); setFocus(next, 0, false);
} }
break; break;
@ -462,7 +464,7 @@ public class SongMenu extends BasicGameState {
break; break;
OsuGroupNode prev = focusNode.prev; OsuGroupNode prev = focusNode.prev;
if (prev != null) { if (prev != null) {
SoundController.playSound(SoundController.SOUND_MENUCLICK); SoundController.playSound(SoundEffect.MENUCLICK);
setFocus(prev, (prev.index == focusNode.index) ? 0 : prev.osuFiles.size() - 1, false); setFocus(prev, (prev.index == focusNode.index) ? 0 : prev.osuFiles.size() - 1, false);
} }
break; break;
@ -621,11 +623,11 @@ public class SongMenu extends BasicGameState {
if (MusicController.isTrackLoading()) if (MusicController.isTrackLoading())
return; return;
SoundController.playSound(SoundController.SOUND_MENUHIT); SoundController.playSound(SoundEffect.MENUHIT);
OsuFile osu = MusicController.getOsuFile(); OsuFile osu = MusicController.getOsuFile();
Display.setTitle(String.format("%s - %s", game.getTitle(), osu.toString())); Display.setTitle(String.format("%s - %s", game.getTitle(), osu.toString()));
OsuParser.parseHitObjects(osu); OsuParser.parseHitObjects(osu);
SoundController.setSampleSet(osu.sampleSet); HitSound.setSampleSet(osu.sampleSet);
Game.setRestart(Game.RESTART_NEW); Game.setRestart(Game.RESTART_NEW);
game.enterState(Opsu.STATE_GAME, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); game.enterState(Opsu.STATE_GAME, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
} }

View File

@ -18,12 +18,12 @@
package itdelatrisu.opsu.states; package itdelatrisu.opsu.states;
import itdelatrisu.opsu.MusicController;
import itdelatrisu.opsu.Opsu; import itdelatrisu.opsu.Opsu;
import itdelatrisu.opsu.OsuParser; import itdelatrisu.opsu.OsuParser;
import itdelatrisu.opsu.OszUnpacker; import itdelatrisu.opsu.OszUnpacker;
import itdelatrisu.opsu.SoundController;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.audio.SoundController;
import java.io.File; import java.io.File;