Allow players to mute shellmap background music
This commit is contained in:
committed by
Paul Chote
parent
28f7604172
commit
3e2022a3dd
@@ -199,6 +199,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public bool CashTicks = true;
|
public bool CashTicks = true;
|
||||||
public bool Mute = false;
|
public bool Mute = false;
|
||||||
|
public bool MuteBackgroundMusic = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PlayerSettings
|
public class PlayerSettings
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
"It cannot be paused, but can be overridden by selecting a new track.")]
|
"It cannot be paused, but can be overridden by selecting a new track.")]
|
||||||
public readonly string BackgroundMusic = null;
|
public readonly string BackgroundMusic = null;
|
||||||
|
|
||||||
|
[Desc("Allow the background music to be muted by the player.")]
|
||||||
|
public readonly bool AllowMuteBackgroundMusic = false;
|
||||||
|
|
||||||
[Desc("Disable all world sounds (combat etc).")]
|
[Desc("Disable all world sounds (combat etc).")]
|
||||||
public readonly bool DisableWorldSounds = false;
|
public readonly bool DisableWorldSounds = false;
|
||||||
|
|
||||||
@@ -49,6 +52,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public readonly bool IsMusicInstalled;
|
public readonly bool IsMusicInstalled;
|
||||||
public readonly bool IsMusicAvailable;
|
public readonly bool IsMusicAvailable;
|
||||||
|
public readonly bool AllowMuteBackgroundMusic;
|
||||||
|
|
||||||
|
public bool IsBackgroundMusicMuted
|
||||||
|
{
|
||||||
|
get { return AllowMuteBackgroundMusic && Game.Settings.Sound.MuteBackgroundMusic; }
|
||||||
|
}
|
||||||
|
|
||||||
public bool CurrentSongIsBackground { get; private set; }
|
public bool CurrentSongIsBackground { get; private set; }
|
||||||
|
|
||||||
MusicInfo currentSong;
|
MusicInfo currentSong;
|
||||||
@@ -73,6 +83,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
random = playlist.Shuffle(Game.CosmeticRandom).ToArray();
|
random = playlist.Shuffle(Game.CosmeticRandom).ToArray();
|
||||||
IsMusicAvailable = playlist.Any();
|
IsMusicAvailable = playlist.Any();
|
||||||
|
AllowMuteBackgroundMusic = info.AllowMuteBackgroundMusic;
|
||||||
|
|
||||||
if (SongExists(info.BackgroundMusic))
|
if (SongExists(info.BackgroundMusic))
|
||||||
{
|
{
|
||||||
@@ -150,7 +161,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
void Play()
|
void Play()
|
||||||
{
|
{
|
||||||
if (!SongExists(currentSong))
|
if (!SongExists(currentSong) || (CurrentSongIsBackground && IsBackgroundMusicMuted))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Game.Sound.PlayMusicThen(currentSong, () =>
|
Game.Sound.PlayMusicThen(currentSong, () =>
|
||||||
@@ -228,6 +239,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
currentSong = currentBackgroundSong;
|
currentSong = currentBackgroundSong;
|
||||||
CurrentSongIsBackground = true;
|
CurrentSongIsBackground = true;
|
||||||
|
|
||||||
|
if (!IsBackgroundMusicMuted)
|
||||||
Play();
|
Play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Support;
|
using OpenRA.Support;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
@@ -401,10 +402,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
Action InitAudioPanel(Widget panel)
|
Action InitAudioPanel(Widget panel)
|
||||||
{
|
{
|
||||||
|
var musicPlaylist = worldRenderer.World.WorldActor.Trait<MusicPlaylist>();
|
||||||
var ss = Game.Settings.Sound;
|
var ss = Game.Settings.Sound;
|
||||||
|
|
||||||
BindCheckboxPref(panel, "CASH_TICKS", ss, "CashTicks");
|
BindCheckboxPref(panel, "CASH_TICKS", ss, "CashTicks");
|
||||||
BindCheckboxPref(panel, "MUTE_SOUND", ss, "Mute");
|
BindCheckboxPref(panel, "MUTE_SOUND", ss, "Mute");
|
||||||
|
BindCheckboxPref(panel, "MUTE_BACKGROUND_MUSIC", ss, "MuteBackgroundMusic");
|
||||||
|
|
||||||
BindSliderPref(panel, "SOUND_VOLUME", ss, "SoundVolume");
|
BindSliderPref(panel, "SOUND_VOLUME", ss, "SoundVolume");
|
||||||
BindSliderPref(panel, "MUSIC_VOLUME", ss, "MusicVolume");
|
BindSliderPref(panel, "MUSIC_VOLUME", ss, "MusicVolume");
|
||||||
@@ -425,6 +428,19 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
Game.Sound.UnmuteAudio();
|
Game.Sound.UnmuteAudio();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var muteBackgroundMusicCheckbox = panel.Get<CheckboxWidget>("MUTE_BACKGROUND_MUSIC");
|
||||||
|
var muteBackgroundMusicCheckboxOnClick = muteBackgroundMusicCheckbox.OnClick;
|
||||||
|
muteBackgroundMusicCheckbox.OnClick = () =>
|
||||||
|
{
|
||||||
|
muteBackgroundMusicCheckboxOnClick();
|
||||||
|
|
||||||
|
if (!musicPlaylist.AllowMuteBackgroundMusic)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (musicPlaylist.CurrentSongIsBackground)
|
||||||
|
musicPlaylist.Stop();
|
||||||
|
};
|
||||||
|
|
||||||
// Replace controls with a warning label if sound is disabled
|
// Replace controls with a warning label if sound is disabled
|
||||||
var noDeviceLabel = panel.GetOrNull("NO_AUDIO_DEVICE");
|
var noDeviceLabel = panel.GetOrNull("NO_AUDIO_DEVICE");
|
||||||
if (noDeviceLabel != null)
|
if (noDeviceLabel != null)
|
||||||
@@ -471,6 +487,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
ss.VideoVolume = dss.VideoVolume;
|
ss.VideoVolume = dss.VideoVolume;
|
||||||
ss.CashTicks = dss.CashTicks;
|
ss.CashTicks = dss.CashTicks;
|
||||||
ss.Mute = dss.Mute;
|
ss.Mute = dss.Mute;
|
||||||
|
ss.MuteBackgroundMusic = dss.MuteBackgroundMusic;
|
||||||
ss.Device = dss.Device;
|
ss.Device = dss.Device;
|
||||||
|
|
||||||
panel.Get<SliderWidget>("SOUND_VOLUME").Value = ss.SoundVolume;
|
panel.Get<SliderWidget>("SOUND_VOLUME").Value = ss.SoundVolume;
|
||||||
|
|||||||
@@ -311,6 +311,13 @@ Container@SETTINGS_PANEL:
|
|||||||
Height: 20
|
Height: 20
|
||||||
Font: Regular
|
Font: Regular
|
||||||
Text: Mute Sound
|
Text: Mute Sound
|
||||||
|
Checkbox@MUTE_BACKGROUND_MUSIC:
|
||||||
|
X: 15
|
||||||
|
Y: 103
|
||||||
|
Width: 200
|
||||||
|
Height: 20
|
||||||
|
Font: Regular
|
||||||
|
Text: Mute Background Music
|
||||||
Label@SOUND_LABEL:
|
Label@SOUND_LABEL:
|
||||||
X: PARENT_RIGHT - WIDTH - 270
|
X: PARENT_RIGHT - WIDTH - 270
|
||||||
Y: 40
|
Y: 40
|
||||||
|
|||||||
@@ -32,4 +32,5 @@ Rules:
|
|||||||
-CrateSpawner:
|
-CrateSpawner:
|
||||||
MusicPlaylist:
|
MusicPlaylist:
|
||||||
BackgroundMusic: map1
|
BackgroundMusic: map1
|
||||||
|
AllowMuteBackgroundMusic: true
|
||||||
DisableWorldSounds: true
|
DisableWorldSounds: true
|
||||||
|
|||||||
@@ -322,6 +322,13 @@ Background@SETTINGS_PANEL:
|
|||||||
Height: 20
|
Height: 20
|
||||||
Font: Regular
|
Font: Regular
|
||||||
Text: Mute Sound
|
Text: Mute Sound
|
||||||
|
Checkbox@MUTE_BACKGROUND_MUSIC:
|
||||||
|
X: 15
|
||||||
|
Y: 103
|
||||||
|
Width: 200
|
||||||
|
Height: 20
|
||||||
|
Font: Regular
|
||||||
|
Text: Mute Background Music
|
||||||
Label@SOUND_LABEL:
|
Label@SOUND_LABEL:
|
||||||
X: PARENT_RIGHT - WIDTH - 270
|
X: PARENT_RIGHT - WIDTH - 270
|
||||||
Y: 40
|
Y: 40
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ World:
|
|||||||
Maximum: 3
|
Maximum: 3
|
||||||
MusicPlaylist:
|
MusicPlaylist:
|
||||||
BackgroundMusic: options
|
BackgroundMusic: options
|
||||||
|
AllowMuteBackgroundMusic: true
|
||||||
DisableWorldSounds: true
|
DisableWorldSounds: true
|
||||||
LuaScript:
|
LuaScript:
|
||||||
Scripts: d2k-shellmap.lua
|
Scripts: d2k-shellmap.lua
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ World:
|
|||||||
-MPStartLocations:
|
-MPStartLocations:
|
||||||
MusicPlaylist:
|
MusicPlaylist:
|
||||||
BackgroundMusic: intro
|
BackgroundMusic: intro
|
||||||
|
AllowMuteBackgroundMusic: true
|
||||||
DisableWorldSounds: true
|
DisableWorldSounds: true
|
||||||
ResourceType@ore:
|
ResourceType@ore:
|
||||||
ValuePerUnit: 0
|
ValuePerUnit: 0
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ World:
|
|||||||
MusicPlaylist:
|
MusicPlaylist:
|
||||||
BackgroundMusic: intro
|
BackgroundMusic: intro
|
||||||
DisableWorldSounds: true
|
DisableWorldSounds: true
|
||||||
|
AllowMuteBackgroundMusic: true
|
||||||
GlobalLightingPaletteEffect:
|
GlobalLightingPaletteEffect:
|
||||||
Blue: 0.7
|
Blue: 0.7
|
||||||
Ambient: 0.7
|
Ambient: 0.7
|
||||||
|
|||||||
Reference in New Issue
Block a user