Added option to disable sound effects from loading. (partially resolves issue #1)
- By default, sound effects will be disabled on Linux due to driver issues.
Other changes:
- Minor corner-case fix in song selection. (since 95f969f
)
Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
parent
842563c6a5
commit
5aa9620834
|
@ -185,6 +185,9 @@ public class SoundController {
|
||||||
* Loads all sound files.
|
* Loads all sound files.
|
||||||
*/
|
*/
|
||||||
public static void init() {
|
public static void init() {
|
||||||
|
if (Options.isSoundDisabled())
|
||||||
|
return;
|
||||||
|
|
||||||
// TODO: support MP3 sounds?
|
// TODO: support MP3 sounds?
|
||||||
currentFileIndex = 0;
|
currentFileIndex = 0;
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,8 @@ public class Options extends BasicGameState {
|
||||||
FIXED_AR,
|
FIXED_AR,
|
||||||
FIXED_OD,
|
FIXED_OD,
|
||||||
LOAD_VERBOSE,
|
LOAD_VERBOSE,
|
||||||
CHECKPOINT;
|
CHECKPOINT,
|
||||||
|
DISABLE_SOUNDS;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -197,7 +198,8 @@ public class Options extends BasicGameState {
|
||||||
GameOption.MUSIC_VOLUME,
|
GameOption.MUSIC_VOLUME,
|
||||||
GameOption.EFFECT_VOLUME,
|
GameOption.EFFECT_VOLUME,
|
||||||
GameOption.HITSOUND_VOLUME,
|
GameOption.HITSOUND_VOLUME,
|
||||||
GameOption.MUSIC_OFFSET
|
GameOption.MUSIC_OFFSET,
|
||||||
|
GameOption.DISABLE_SOUNDS
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -366,6 +368,15 @@ public class Options extends BasicGameState {
|
||||||
*/
|
*/
|
||||||
private static int checkpoint = 0;
|
private static int checkpoint = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not to disable all sounds.
|
||||||
|
* This will prevent SoundController from loading sound files.
|
||||||
|
* <p>
|
||||||
|
* By default, sound is disabled on Linux due to possible driver issues.
|
||||||
|
*/
|
||||||
|
private static boolean disableSound =
|
||||||
|
(System.getProperty("os.name").toLowerCase().indexOf("linux") > -1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game option coordinate modifiers (for drawing).
|
* Game option coordinate modifiers (for drawing).
|
||||||
*/
|
*/
|
||||||
|
@ -616,6 +627,9 @@ public class Options extends BasicGameState {
|
||||||
case LOAD_VERBOSE:
|
case LOAD_VERBOSE:
|
||||||
loadVerbose = !loadVerbose;
|
loadVerbose = !loadVerbose;
|
||||||
break;
|
break;
|
||||||
|
case DISABLE_SOUNDS:
|
||||||
|
disableSound = !disableSound;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -815,6 +829,12 @@ public class Options extends BasicGameState {
|
||||||
"Adjust this value if hit objects are out of sync."
|
"Adjust this value if hit objects are out of sync."
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
case DISABLE_SOUNDS:
|
||||||
|
drawOption(pos, "Disable All Sound Effects",
|
||||||
|
disableSound ? "Yes" : "No",
|
||||||
|
"May resolve Linux sound driver issues. Requires a restart."
|
||||||
|
);
|
||||||
|
break;
|
||||||
case BACKGROUND_DIM:
|
case BACKGROUND_DIM:
|
||||||
drawOption(pos, "Background Dim",
|
drawOption(pos, "Background Dim",
|
||||||
String.format("%d%%", backgroundDim),
|
String.format("%d%%", backgroundDim),
|
||||||
|
@ -1125,6 +1145,12 @@ public class Options extends BasicGameState {
|
||||||
*/
|
*/
|
||||||
public static int getCheckpoint() { return checkpoint * 1000; }
|
public static int getCheckpoint() { return checkpoint * 1000; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not all sound effects are disabled.
|
||||||
|
* @return true if disabled
|
||||||
|
*/
|
||||||
|
public static boolean isSoundDisabled() { return disableSound; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the track checkpoint time, if within bounds.
|
* Sets the track checkpoint time, if within bounds.
|
||||||
* @param time the track position (in ms)
|
* @param time the track position (in ms)
|
||||||
|
@ -1273,6 +1299,9 @@ public class Options extends BasicGameState {
|
||||||
if (i >= -500 && i <= 500)
|
if (i >= -500 && i <= 500)
|
||||||
musicOffset = i;
|
musicOffset = i;
|
||||||
break;
|
break;
|
||||||
|
case "DisableSound":
|
||||||
|
disableSound = Boolean.parseBoolean(value);
|
||||||
|
break;
|
||||||
case "DimLevel":
|
case "DimLevel":
|
||||||
i = Integer.parseInt(value);
|
i = Integer.parseInt(value);
|
||||||
if (i >= 0 && i <= 100)
|
if (i >= 0 && i <= 100)
|
||||||
|
@ -1367,6 +1396,8 @@ public class Options extends BasicGameState {
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
writer.write(String.format("Offset = %d", musicOffset));
|
writer.write(String.format("Offset = %d", musicOffset));
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
|
writer.write(String.format("DisableSound = %b", disableSound));
|
||||||
|
writer.newLine();
|
||||||
writer.write(String.format("DimLevel = %d", backgroundDim));
|
writer.write(String.format("DimLevel = %d", backgroundDim));
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
writer.write(String.format("ForceDefaultPlayfield = %b", forceDefaultPlayfield));
|
writer.write(String.format("ForceDefaultPlayfield = %b", forceDefaultPlayfield));
|
||||||
|
|
|
@ -569,7 +569,7 @@ public class SongMenu extends BasicGameState {
|
||||||
pos = (int) (Math.random() * length);
|
pos = (int) (Math.random() * length);
|
||||||
|
|
||||||
// change the focus node
|
// change the focus node
|
||||||
if (flag || (startNode.index == 0 && startNode.prev == null))
|
if (flag || (startNode.index == 0 && startNode.osuFileIndex == -1 && startNode.prev == null))
|
||||||
startNode = node;
|
startNode = node;
|
||||||
focusNode = Opsu.groups.getNode(node, pos);
|
focusNode = Opsu.groups.getNode(node, pos);
|
||||||
MusicController.play(focusNode.osuFiles.get(focusNode.osuFileIndex), true);
|
MusicController.play(focusNode.osuFiles.get(focusNode.osuFileIndex), true);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user