Add mute option to the game
This commit is contained in:
@@ -127,6 +127,7 @@ namespace OpenRA
|
||||
public string Device = null;
|
||||
|
||||
public bool CashTicks = true;
|
||||
public bool Mute = false;
|
||||
}
|
||||
|
||||
public class PlayerSettings
|
||||
@@ -204,6 +205,7 @@ namespace OpenRA
|
||||
public Hotkey DevReloadChromeKey = new Hotkey(Keycode.C, Modifiers.Ctrl | Modifiers.Shift);
|
||||
public Hotkey HideUserInterfaceKey = new Hotkey(Keycode.H, Modifiers.Ctrl | Modifiers.Shift);
|
||||
public Hotkey TakeScreenshotKey = new Hotkey(Keycode.P, Modifiers.Ctrl);
|
||||
public Hotkey ToggleMuteKey = new Hotkey(Keycode.M, Modifiers.None);
|
||||
|
||||
public Hotkey Production01Key = new Hotkey(Keycode.F1, Modifiers.None);
|
||||
public Hotkey Production02Key = new Hotkey(Keycode.F2, Modifiers.None);
|
||||
|
||||
@@ -114,6 +114,16 @@ namespace OpenRA
|
||||
soundEngine.StopAllSounds();
|
||||
}
|
||||
|
||||
public void MuteAudio()
|
||||
{
|
||||
soundEngine.Volume = 0f;
|
||||
}
|
||||
|
||||
public void UnmuteAudio()
|
||||
{
|
||||
soundEngine.Volume = 1f;
|
||||
}
|
||||
|
||||
public ISound Play(string name) { return Play(null, name, true, WPos.Zero, 1f); }
|
||||
public ISound Play(string name, WPos pos) { return Play(null, name, false, pos, 1f); }
|
||||
public ISound Play(string name, float volumeModifier) { return Play(null, name, true, WPos.Zero, volumeModifier); }
|
||||
|
||||
@@ -302,6 +302,8 @@ namespace OpenRA.Widgets
|
||||
return CycleStatusBars();
|
||||
else if (key == Game.Settings.Keys.TogglePixelDoubleKey)
|
||||
return TogglePixelDouble();
|
||||
else if (key == Game.Settings.Keys.ToggleMuteKey)
|
||||
return ToggleMute();
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -360,5 +362,23 @@ namespace OpenRA.Widgets
|
||||
worldRenderer.Viewport.Zoom = Game.Settings.Graphics.PixelDouble ? 2 : 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ToggleMute()
|
||||
{
|
||||
Game.Settings.Sound.Mute ^= true;
|
||||
|
||||
if (Game.Settings.Sound.Mute)
|
||||
{
|
||||
Game.Sound.MuteAudio();
|
||||
Game.Debug("Audio muted");
|
||||
}
|
||||
else
|
||||
{
|
||||
Game.Sound.UnmuteAudio();
|
||||
Game.Debug("Audio unmuted");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user