Fixed a bug where sounds weren't reloaded when changing skins.

When restarting the program through the options menu, all sounds now get reloaded if the skin was changed.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han
2015-06-03 06:23:23 -04:00
parent f3825eba5e
commit 90c8c9e705
4 changed files with 67 additions and 12 deletions

View File

@@ -105,6 +105,12 @@ public enum HitSound implements SoundController.SoundComponent {
return (currentSampleSet != null) ? clips.get(currentSampleSet) : null;
}
/**
* Returns the Clip associated with the given sample set.
* @param s the sample set
*/
public MultiClip getClip(SampleSet s) { return clips.get(s); }
/**
* Sets the hit sound Clip for the sample type.
* @param s the sample set

View File

@@ -207,7 +207,14 @@ public class SoundController {
ErrorHandler.error(String.format("Could not find sound file '%s'.", s.getFileName()), null, false);
continue;
}
s.setClip(loadClip(currentFileName, currentFileName.endsWith(".mp3")));
MultiClip newClip = loadClip(currentFileName, currentFileName.endsWith(".mp3"));
if (s.getClip() != null) { // clip previously loaded (e.g. program restart)
if (newClip != null) {
s.getClip().destroy(); // destroy previous clip
s.setClip(newClip);
}
} else
s.setClip(newClip);
currentFileIndex++;
}
@@ -219,7 +226,14 @@ public class SoundController {
ErrorHandler.error(String.format("Could not find hit sound file '%s'.", filename), null, false);
continue;
}
s.setClip(ss, loadClip(currentFileName, false));
MultiClip newClip = loadClip(currentFileName, false);
if (s.getClip(ss) != null) { // clip previously loaded (e.g. program restart)
if (newClip != null) {
s.getClip(ss).destroy(); // destroy previous clip
s.setClip(ss, newClip);
}
} else
s.setClip(ss, newClip);
currentFileIndex++;
}
}