Unstatic the Sound class.

This commit is contained in:
Paul Chote
2015-09-05 18:31:21 +01:00
parent ff10fe3e07
commit ef55d646f7
82 changed files with 207 additions and 206 deletions

View File

@@ -126,10 +126,10 @@ namespace OpenRA.Mods.Common.Widgets
if (!IsDisabled())
{
OnKeyPress(e);
Sound.PlayNotification(ModRules, null, "Sounds", "ClickSound", null);
Game.Sound.PlayNotification(ModRules, null, "Sounds", "ClickSound", null);
}
else
Sound.PlayNotification(ModRules, null, "Sounds", "ClickDisabledSound", null);
Game.Sound.PlayNotification(ModRules, null, "Sounds", "ClickDisabledSound", null);
return true;
}
@@ -167,12 +167,12 @@ namespace OpenRA.Mods.Common.Widgets
{
OnMouseDown(mi);
Depressed = true;
Sound.PlayNotification(ModRules, null, "Sounds", "ClickSound", null);
Game.Sound.PlayNotification(ModRules, null, "Sounds", "ClickSound", null);
}
else
{
YieldMouseFocus(mi);
Sound.PlayNotification(ModRules, null, "Sounds", "ClickDisabledSound", null);
Game.Sound.PlayNotification(ModRules, null, "Sounds", "ClickDisabledSound", null);
}
}
else if (mi.Event == MouseInputEvent.Move && HasMouseFocus)

View File

@@ -71,7 +71,7 @@ namespace OpenRA.Mods.Common.Widgets
recentLines.Add(new ChatLine(from, text, Game.LocalTick + RemoveTime, c));
if (Notification != null)
Sound.Play(Notification);
Game.Sound.Play(Notification);
while (recentLines.Count > LogLength)
recentLines.RemoveAt(0);

View File

@@ -84,7 +84,7 @@ namespace OpenRA.Mods.Common.Widgets
// Mask to prevent any clicks from being sent to other widgets
fullscreenMask = new MaskWidget();
fullscreenMask.Bounds = new Rectangle(0, 0, Game.Renderer.Resolution.Width, Game.Renderer.Resolution.Height);
fullscreenMask.OnMouseDown += mi => { Sound.PlayNotification(this.ModRules, null, "Sounds", "ClickSound", null); RemovePanel(); };
fullscreenMask.OnMouseDown += mi => { Game.Sound.PlayNotification(this.ModRules, null, "Sounds", "ClickSound", null); RemovePanel(); };
if (onCancel != null)
fullscreenMask.OnMouseDown += _ => onCancel();

View File

@@ -203,7 +203,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
chatScrollPanel.ScrollToBottom(smooth: true);
if (!replayCache)
Sound.PlayNotification(modRules, null, "Sounds", "ChatLine", null);
Game.Sound.PlayNotification(modRules, null, "Sounds", "ChatLine", null);
}
}
}

View File

@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
Action onQuit = () =>
{
if (world.Type == WorldType.Regular)
Sound.PlayNotification(world.Map.Rules, null, "Speech", "Leave", world.LocalPlayer == null ? null : world.LocalPlayer.Faction.InternalName);
Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", "Leave", world.LocalPlayer == null ? null : world.LocalPlayer.Faction.InternalName);
leaving = true;

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
.Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive);
if (radarEnabled != cachedRadarEnabled)
Sound.PlayNotification(world.Map.Rules, null, "Sounds", radarEnabled ? "RadarUp" : "RadarDown", null);
Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", radarEnabled ? "RadarUp" : "RadarDown", null);
cachedRadarEnabled = radarEnabled;
};

View File

@@ -653,7 +653,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (scrolledToBottom)
chatPanel.ScrollToBottom(smooth: true);
Sound.PlayNotification(modRules, null, "Sounds", "ChatLine", null);
Game.Sound.PlayNotification(modRules, null, "Sounds", "ChatLine", null);
}
bool SwitchTeamChat()

View File

@@ -213,18 +213,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
float cachedMusicVolume;
void MuteSounds()
{
cachedSoundVolume = Sound.SoundVolume;
cachedMusicVolume = Sound.MusicVolume;
Sound.SoundVolume = Sound.MusicVolume = 0;
cachedSoundVolume = Game.Sound.SoundVolume;
cachedMusicVolume = Game.Sound.MusicVolume;
Game.Sound.SoundVolume = Game.Sound.MusicVolume = 0;
}
void UnMuteSounds()
{
if (cachedSoundVolume > 0)
Sound.SoundVolume = cachedSoundVolume;
Game.Sound.SoundVolume = cachedSoundVolume;
if (cachedMusicVolume > 0)
Sound.MusicVolume = cachedMusicVolume;
Game.Sound.MusicVolume = cachedMusicVolume;
}
void PlayVideo(VqaPlayerWidget player, string video, PlayingVideo pv, Action onComplete)

View File

@@ -41,12 +41,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var playButton = panel.Get<ButtonWidget>("BUTTON_PLAY");
playButton.OnClick = Play;
playButton.IsDisabled = noMusic;
playButton.IsVisible = () => !Sound.MusicPlaying;
playButton.IsVisible = () => !Game.Sound.MusicPlaying;
var pauseButton = panel.Get<ButtonWidget>("BUTTON_PAUSE");
pauseButton.OnClick = Sound.PauseMusic;
pauseButton.OnClick = Game.Sound.PauseMusic;
pauseButton.IsDisabled = noMusic;
pauseButton.IsVisible = () => Sound.MusicPlaying;
pauseButton.IsVisible = () => Game.Sound.MusicPlaying;
var stopButton = panel.Get<ButtonWidget>("BUTTON_STOP");
stopButton.OnClick = () => { musicPlaylist.Stop(); };
@@ -75,8 +75,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (currentSong == null || musicPlaylist.CurrentSongIsBackground)
return "";
var minutes = (int)Sound.MusicSeekPosition / 60;
var seconds = (int)Sound.MusicSeekPosition % 60;
var minutes = (int)Game.Sound.MusicSeekPosition / 60;
var seconds = (int)Game.Sound.MusicSeekPosition % 60;
var totalMinutes = currentSong.Length / 60;
var totalSeconds = currentSong.Length % 60;
@@ -84,8 +84,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
};
var musicSlider = panel.Get<SliderWidget>("MUSIC_SLIDER");
musicSlider.OnChange += x => Sound.MusicVolume = x;
musicSlider.Value = Sound.MusicVolume;
musicSlider.OnChange += x => Game.Sound.MusicVolume = x;
musicSlider.Value = Game.Sound.MusicVolume;
var installButton = widget.GetOrNull<ButtonWidget>("INSTALL_BUTTON");
if (installButton != null)
@@ -108,10 +108,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (musicPlaylist.CurrentSongIsBackground && currentSong != null)
currentSong = null;
if (Sound.CurrentMusic == null || currentSong == Sound.CurrentMusic || musicPlaylist.CurrentSongIsBackground)
if (Game.Sound.CurrentMusic == null || currentSong == Game.Sound.CurrentMusic || musicPlaylist.CurrentSongIsBackground)
return;
currentSong = Sound.CurrentMusic;
currentSong = Game.Sound.CurrentMusic;
};
}

View File

@@ -307,11 +307,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
BindSliderPref(panel, "VIDEO_VOLUME", ss, "VideoVolume");
// Update volume immediately
panel.Get<SliderWidget>("SOUND_VOLUME").OnChange += x => Sound.SoundVolume = x;
panel.Get<SliderWidget>("MUSIC_VOLUME").OnChange += x => Sound.MusicVolume = x;
panel.Get<SliderWidget>("VIDEO_VOLUME").OnChange += x => Sound.VideoVolume = x;
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 = Sound.AvailableDevices();
var devices = Game.Sound.AvailableDevices();
soundDevice = devices.FirstOrDefault(d => d.Engine == ss.Engine && d.Device == ss.Device) ?? devices.First();
var audioDeviceDropdown = panel.Get<DropDownButtonWidget>("AUDIO_DEVICE");
@@ -339,12 +339,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
ss.Engine = dss.Engine;
panel.Get<SliderWidget>("SOUND_VOLUME").Value = ss.SoundVolume;
Sound.SoundVolume = ss.SoundVolume;
Game.Sound.SoundVolume = ss.SoundVolume;
panel.Get<SliderWidget>("MUSIC_VOLUME").Value = ss.MusicVolume;
Sound.MusicVolume = ss.MusicVolume;
Game.Sound.MusicVolume = ss.MusicVolume;
panel.Get<SliderWidget>("VIDEO_VOLUME").Value = ss.VideoVolume;
Sound.VideoVolume = ss.VideoVolume;
soundDevice = Sound.AvailableDevices().First();
Game.Sound.VideoVolume = ss.VideoVolume;
soundDevice = Game.Sound.AvailableDevices().First();
};
}

View File

@@ -220,14 +220,14 @@ namespace OpenRA.Mods.Common.Widgets
{
if (PickUpCompletedBuildingIcon(icon, item))
{
Sound.Play(TabClick);
Game.Sound.Play(TabClick);
return true;
}
if (item != null && item.Paused)
{
// Resume a paused item
Sound.Play(TabClick);
Game.Sound.Play(TabClick);
World.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, icon.Name, false));
return true;
}
@@ -235,8 +235,8 @@ namespace OpenRA.Mods.Common.Widgets
if (CurrentQueue.BuildableItems().Any(a => a.Name == icon.Name))
{
// Queue a new item
Sound.Play(TabClick);
Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, World.LocalPlayer.Faction.InternalName);
Game.Sound.Play(TabClick);
Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, World.LocalPlayer.Faction.InternalName);
World.IssueOrder(Order.StartProduction(CurrentQueue.Actor, icon.Name,
handleMultiple ? 5 : 1));
return true;
@@ -250,19 +250,19 @@ namespace OpenRA.Mods.Common.Widgets
if (item == null)
return false;
Sound.Play(TabClick);
Game.Sound.Play(TabClick);
if (item.Paused || item.Done || item.TotalCost == item.RemainingCost)
{
// Instant cancel of things we have not started yet and things that are finished
Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, World.LocalPlayer.Faction.InternalName);
Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, World.LocalPlayer.Faction.InternalName);
World.IssueOrder(Order.CancelProduction(CurrentQueue.Actor, icon.Name,
handleMultiple ? 5 : 1));
}
else
{
// Pause an existing item
Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.OnHoldAudio, World.LocalPlayer.Faction.InternalName);
Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.OnHoldAudio, World.LocalPlayer.Faction.InternalName);
World.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, icon.Name, true));
}
@@ -276,7 +276,7 @@ namespace OpenRA.Mods.Common.Widgets
: HandleRightClick(item, icon, handleMultiple);
if (!handled)
Sound.Play(DisabledTabClick);
Game.Sound.Play(DisabledTabClick);
return true;
}

View File

@@ -261,9 +261,9 @@ namespace OpenRA.Mods.Common.Widgets
if (leftPressed || rightPressed)
{
if ((leftPressed && !leftDisabled) || (rightPressed && !rightDisabled))
Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickSound", null);
Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickSound", null);
else
Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickDisabledSound", null);
Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickDisabledSound", null);
}
// Check production tabs
@@ -271,7 +271,7 @@ namespace OpenRA.Mods.Common.Widgets
if (offsetloc.X > 0 && offsetloc.X < contentWidth)
{
CurrentQueue = Groups[queueGroup].Tabs[offsetloc.X / (TabWidth - 1)].Queue;
Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickSound", null);
Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickSound", null);
}
return true;
@@ -286,12 +286,12 @@ namespace OpenRA.Mods.Common.Widgets
if (hotkey == Game.Settings.Keys.NextProductionTabKey)
{
Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickSound", null);
Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickSound", null);
return SelectNextTab(false);
}
else if (hotkey == Game.Settings.Keys.PreviousProductionTabKey)
{
Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickSound", null);
Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickSound", null);
return SelectNextTab(true);
}

View File

@@ -335,7 +335,7 @@ namespace OpenRA.Mods.Common.Widgets
// Enable/Disable the radar
var enabled = IsEnabled();
if (enabled != cachedEnabled)
Sound.Play(enabled ? RadarOnlineSound : RadarOfflineSound);
Game.Sound.Play(enabled ? RadarOnlineSound : RadarOfflineSound);
cachedEnabled = enabled;
if (enabled)

View File

@@ -321,7 +321,7 @@ namespace OpenRA.Mods.Common.Widgets
lastMouseLocation = mi.Location;
if (mi.Event == MouseInputEvent.Down && ((upPressed && !upDisabled) || (downPressed && !downDisabled) || thumbPressed))
Sound.PlayNotification(modRules, null, "Sounds", "ClickSound", null);
Game.Sound.PlayNotification(modRules, null, "Sounds", "ClickSound", null);
}
return upPressed || downPressed || thumbPressed;

View File

@@ -113,7 +113,7 @@ namespace OpenRA.Mods.Common.Widgets
protected void ClickIcon(SupportPowerIcon clicked)
{
if (!clicked.Power.Active)
Sound.PlayToPlayer(spm.Self.Owner, clicked.Power.Info.InsufficientPowerSound);
Game.Sound.PlayToPlayer(spm.Self.Owner, clicked.Power.Info.InsufficientPowerSound);
else
clicked.Power.Target();
}

View File

@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Widgets
stopped = true;
paused = true;
Sound.StopVideo();
Game.Sound.StopVideo();
onComplete = () => { };
invLength = video.Framerate * 1f / video.Frames;
@@ -113,7 +113,7 @@ namespace OpenRA.Mods.Common.Widgets
{
var nextFrame = 0;
if (video.HasAudio)
nextFrame = (int)float2.Lerp(0, video.Frames, Sound.VideoSeekPosition * invLength);
nextFrame = (int)float2.Lerp(0, video.Frames, Game.Sound.VideoSeekPosition * invLength);
else
nextFrame = video.CurrentFrame + 1;
@@ -176,9 +176,9 @@ namespace OpenRA.Mods.Common.Widgets
onComplete = after;
if (stopped)
Sound.PlayVideo(video.AudioData, video.AudioChannels, video.SampleBits, video.SampleRate);
Game.Sound.PlayVideo(video.AudioData, video.AudioChannels, video.SampleBits, video.SampleRate);
else
Sound.PlayVideo();
Game.Sound.PlayVideo();
stopped = paused = false;
}
@@ -189,7 +189,7 @@ namespace OpenRA.Mods.Common.Widgets
return;
paused = true;
Sound.PauseVideo();
Game.Sound.PauseVideo();
}
public void Stop()
@@ -199,7 +199,7 @@ namespace OpenRA.Mods.Common.Widgets
stopped = true;
paused = true;
Sound.StopVideo();
Game.Sound.StopVideo();
video.Reset();
videoSprite.Sheet.GetTexture().SetData(video.FrameData);
world.AddFrameEndTask(_ => onComplete());

View File

@@ -241,7 +241,7 @@ namespace OpenRA.Mods.Common.Widgets
world.Selection.Combine(world, new Actor[] { next }, false, true);
Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickSound", null);
Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickSound", null);
return ToSelection();
}