@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
Func<bool> noMusic = () => !musicPlaylist.IsMusicAvailable || musicPlaylist.CurrentSongIsBackground || currentSong == null;
|
||||
panel.Get("NO_MUSIC_LABEL").IsVisible = () => !musicPlaylist.IsMusicAvailable;
|
||||
|
||||
if (musicPlaylist.IsMusicAvailable)
|
||||
{
|
||||
panel.Get<LabelWidget>("MUTE_LABEL").GetText = () =>
|
||||
{
|
||||
if (Game.Settings.Sound.Mute)
|
||||
return "Audio has been muted in settings.";
|
||||
|
||||
return "";
|
||||
};
|
||||
}
|
||||
|
||||
var playButton = panel.Get<ButtonWidget>("BUTTON_PLAY");
|
||||
playButton.OnClick = Play;
|
||||
playButton.IsDisabled = noMusic;
|
||||
|
||||
@@ -305,15 +305,30 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var ss = Game.Settings.Sound;
|
||||
|
||||
BindCheckboxPref(panel, "CASH_TICKS", ss, "CashTicks");
|
||||
BindCheckboxPref(panel, "MUTE_SOUND", ss, "Mute");
|
||||
|
||||
BindSliderPref(panel, "SOUND_VOLUME", ss, "SoundVolume");
|
||||
BindSliderPref(panel, "MUSIC_VOLUME", ss, "MusicVolume");
|
||||
BindSliderPref(panel, "VIDEO_VOLUME", ss, "VideoVolume");
|
||||
|
||||
// Update volume immediately
|
||||
panel.Get<SliderWidget>("SOUND_VOLUME").OnChange += x => Game.Sound.SoundVolume = x;
|
||||
panel.Get<SliderWidget>("MUSIC_VOLUME").OnChange += x => Game.Sound.MusicVolume = x;
|
||||
panel.Get<SliderWidget>("VIDEO_VOLUME").OnChange += x => Game.Sound.VideoVolume = x;
|
||||
var muteCheckbox = panel.Get<CheckboxWidget>("MUTE_SOUND");
|
||||
var muteCheckboxOnClick = muteCheckbox.OnClick;
|
||||
muteCheckbox.OnClick = () =>
|
||||
{
|
||||
muteCheckboxOnClick();
|
||||
|
||||
if (ss.Mute)
|
||||
Game.Sound.MuteAudio();
|
||||
else
|
||||
Game.Sound.UnmuteAudio();
|
||||
};
|
||||
|
||||
if (!ss.Mute)
|
||||
{
|
||||
panel.Get<SliderWidget>("SOUND_VOLUME").OnChange += x => Game.Sound.SoundVolume = x;
|
||||
panel.Get<SliderWidget>("MUSIC_VOLUME").OnChange += x => Game.Sound.MusicVolume = x;
|
||||
panel.Get<SliderWidget>("VIDEO_VOLUME").OnChange += x => Game.Sound.VideoVolume = x;
|
||||
}
|
||||
|
||||
var devices = Game.Sound.AvailableDevices();
|
||||
soundDevice = devices.FirstOrDefault(d => d.Engine == ss.Engine && d.Device == ss.Device) ?? devices.First();
|
||||
@@ -339,6 +354,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
ss.MusicVolume = dss.MusicVolume;
|
||||
ss.VideoVolume = dss.VideoVolume;
|
||||
ss.CashTicks = dss.CashTicks;
|
||||
ss.Mute = dss.Mute;
|
||||
ss.Device = dss.Device;
|
||||
ss.Engine = dss.Engine;
|
||||
|
||||
@@ -348,6 +364,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
Game.Sound.MusicVolume = ss.MusicVolume;
|
||||
panel.Get<SliderWidget>("VIDEO_VOLUME").Value = ss.VideoVolume;
|
||||
Game.Sound.VideoVolume = ss.VideoVolume;
|
||||
Game.Sound.UnmuteAudio();
|
||||
soundDevice = Game.Sound.AvailableDevices().First();
|
||||
};
|
||||
}
|
||||
@@ -414,6 +431,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
{ "CycleStatusBarsKey", "Cycle status bars display" },
|
||||
{ "TogglePixelDoubleKey", "Toggle pixel doubling" },
|
||||
{ "ToggleMuteKey", "Toggle audio mute" },
|
||||
|
||||
{ "MapScrollUp", "Map scroll up" },
|
||||
{ "MapScrollDown", "Map scroll down" },
|
||||
|
||||
@@ -212,6 +212,9 @@ namespace OpenRA.Platforms.Default
|
||||
if (!TryGetSourceFromPool(out source))
|
||||
return null;
|
||||
|
||||
if (Game.Settings.Sound.Mute)
|
||||
Game.Sound.MuteAudio();
|
||||
|
||||
var slot = sourcePool[source];
|
||||
slot.Pos = pos;
|
||||
slot.FrameStarted = currFrame;
|
||||
|
||||
@@ -31,6 +31,12 @@ Container@LOBBY_MUSIC_BIN:
|
||||
Width: 308
|
||||
Height: PARENT_BOTTOM
|
||||
Children:
|
||||
Label@MUTE_LABEL:
|
||||
X: 25
|
||||
Y: 10
|
||||
Width: 300
|
||||
Height: 20
|
||||
Font: Small
|
||||
Label@TITLE_LABEL:
|
||||
Y: 45
|
||||
Width: PARENT_RIGHT
|
||||
|
||||
@@ -176,6 +176,12 @@ Container@MUSIC_PANEL:
|
||||
Width: 140
|
||||
Height: 35
|
||||
Text: Install Music
|
||||
Label@MUTE_LABEL:
|
||||
X: 165
|
||||
Y: 399
|
||||
Width: 300
|
||||
Height: 20
|
||||
Font: Small
|
||||
|
||||
Container@INSTALL_MUSIC_PANEL:
|
||||
Logic: InstallMusicLogic
|
||||
|
||||
@@ -269,6 +269,13 @@ Container@SETTINGS_PANEL:
|
||||
Height: 20
|
||||
Font: Regular
|
||||
Text: Cash Ticks
|
||||
Checkbox@MUTE_SOUND:
|
||||
X: 15
|
||||
Y: 70
|
||||
Width: 200
|
||||
Height: 20
|
||||
Font: Regular
|
||||
Text: Mute Sound
|
||||
Label@MUSIC_LABEL:
|
||||
X: PARENT_RIGHT - WIDTH - 270
|
||||
Y: 67
|
||||
|
||||
@@ -31,6 +31,12 @@ Container@LOBBY_MUSIC_BIN:
|
||||
Width: 268
|
||||
Height: PARENT_BOTTOM
|
||||
Children:
|
||||
Label@MUTE_LABEL:
|
||||
X: 25
|
||||
Y: 10
|
||||
Width: 300
|
||||
Height: 20
|
||||
Font: Small
|
||||
Label@TITLE_LABEL:
|
||||
Y: 45
|
||||
Width: PARENT_RIGHT
|
||||
|
||||
@@ -165,6 +165,12 @@ Background@MUSIC_PANEL:
|
||||
Text: Close
|
||||
Font: Bold
|
||||
Key: escape
|
||||
Label@MUTE_LABEL:
|
||||
X: 25
|
||||
Y: PARENT_BOTTOM - 45
|
||||
Width: 300
|
||||
Height: 20
|
||||
Font: Small
|
||||
|
||||
Background@INSTALL_MUSIC_PANEL:
|
||||
Logic: InstallMusicLogic
|
||||
|
||||
@@ -277,6 +277,13 @@ Background@SETTINGS_PANEL:
|
||||
Height: 20
|
||||
Font: Regular
|
||||
Text: Cash Ticks
|
||||
Checkbox@MUTE_SOUND:
|
||||
X: 15
|
||||
Y: 70
|
||||
Width: 200
|
||||
Height: 20
|
||||
Font: Regular
|
||||
Text: Mute Sound
|
||||
Label@MUSIC_LABEL:
|
||||
X: PARENT_RIGHT - WIDTH - 270
|
||||
Y: 67
|
||||
|
||||
Reference in New Issue
Block a user