From a8a3036bc4915a1f4bba37de7f0dbafbb55a3d85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 20 Apr 2014 15:25:43 +0200 Subject: [PATCH 1/2] moved StartGameNotification into its own trait --- OpenRA.Game/Game.cs | 3 --- OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 1 + OpenRA.Mods.RA/StartGameNotification.cs | 36 +++++++++++++++++++++++++ mods/ra/maps/desert-shellmap/map.yaml | 1 + mods/ra/rules/world.yaml | 1 + mods/ts/maps/blank-shellmap/map.yaml | 1 + mods/ts/rules/world.yaml | 1 + 7 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 OpenRA.Mods.RA/StartGameNotification.cs diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 17d589b786..bcf50f1fd1 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -262,9 +262,6 @@ namespace OpenRA orderManager.LastTickTime = Environment.TickCount; orderManager.StartGame(); worldRenderer.RefreshPalette(); - - if (!isShellmap) - Sound.PlayNotification(null, "Speech", "StartGame", null); } public static bool IsHost diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 4c538e05da..ab8bb3ebb8 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -496,6 +496,7 @@ + diff --git a/OpenRA.Mods.RA/StartGameNotification.cs b/OpenRA.Mods.RA/StartGameNotification.cs new file mode 100644 index 0000000000..495a098b93 --- /dev/null +++ b/OpenRA.Mods.RA/StartGameNotification.cs @@ -0,0 +1,36 @@ +#region Copyright & License Information +/* + * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using OpenRA.Graphics; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA +{ + class StartGameNotificationInfo : ITraitInfo + { + public readonly string Notification = "StartGame"; + + public object Create(ActorInitializer init) { return new StartGameNotification(this); } + } + + class StartGameNotification : IWorldLoaded + { + StartGameNotificationInfo info; + public StartGameNotification(StartGameNotificationInfo info) + { + this.info = info; + } + + public void WorldLoaded(World w, WorldRenderer wr) + { + Sound.PlayNotification(null, "Speech", info.Notification, null); + } + } +} diff --git a/mods/ra/maps/desert-shellmap/map.yaml b/mods/ra/maps/desert-shellmap/map.yaml index df096a95d7..6046df662e 100644 --- a/mods/ra/maps/desert-shellmap/map.yaml +++ b/mods/ra/maps/desert-shellmap/map.yaml @@ -1307,6 +1307,7 @@ Rules: LuaScripts: desert-shellmap.lua LoadWidgetAtGameStart: Widget: MAINMENU + -StartGameNotification: TRAN.Husk2: Burns: Damage: 0 diff --git a/mods/ra/rules/world.yaml b/mods/ra/rules/world.yaml index 7c2889fadd..a59bc00154 100644 --- a/mods/ra/rules/world.yaml +++ b/mods/ra/rules/world.yaml @@ -165,4 +165,5 @@ World: ValidateOrder: DebugPauseState: RadarPings: + StartGameNotification: diff --git a/mods/ts/maps/blank-shellmap/map.yaml b/mods/ts/maps/blank-shellmap/map.yaml index dfa05fb7d2..979bde074b 100644 --- a/mods/ts/maps/blank-shellmap/map.yaml +++ b/mods/ts/maps/blank-shellmap/map.yaml @@ -37,6 +37,7 @@ Smudges: Rules: World: + -StartGameNotification: -SpawnMPUnits: -MPStartLocations: LoadWidgetAtGameStart: diff --git a/mods/ts/rules/world.yaml b/mods/ts/rules/world.yaml index e28bcc198a..79c2cfd1e7 100644 --- a/mods/ts/rules/world.yaml +++ b/mods/ts/rules/world.yaml @@ -97,4 +97,5 @@ World: DebugPauseState: ScreenShaker: RadarPings: + StartGameNotification: From f19fbb1794d9276bd9b916aaef3d87bac87ef6a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 20 Apr 2014 15:26:33 +0200 Subject: [PATCH 2/2] StyleCop --- OpenRA.Game/GameRules/SoundInfo.cs | 8 ++++---- OpenRA.Mods.RA/ActorLostNotification.cs | 11 +++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/OpenRA.Game/GameRules/SoundInfo.cs b/OpenRA.Game/GameRules/SoundInfo.cs index d7e923ec1d..6f88c6f114 100644 --- a/OpenRA.Game/GameRules/SoundInfo.cs +++ b/OpenRA.Game/GameRules/SoundInfo.cs @@ -26,12 +26,12 @@ namespace OpenRA.GameRules public readonly string[] DisableVariants = { }; public readonly string[] DisablePrefixes = { }; - static Dictionary Load( MiniYaml y, string name ) + static Dictionary Load(MiniYaml y, string name) { - return y.NodesDict.ContainsKey( name ) - ? y.NodesDict[ name ].NodesDict.ToDictionary( + return y.NodesDict.ContainsKey(name) + ? y.NodesDict[name].NodesDict.ToDictionary( a => a.Key, - a => FieldLoader.GetValue( "(value)", a.Value.Value ) ) + a => FieldLoader.GetValue("(value)", a.Value.Value)) : new Dictionary(); } diff --git a/OpenRA.Mods.RA/ActorLostNotification.cs b/OpenRA.Mods.RA/ActorLostNotification.cs index d053e79288..ea4e52d0e9 100644 --- a/OpenRA.Mods.RA/ActorLostNotification.cs +++ b/OpenRA.Mods.RA/ActorLostNotification.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2014 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, @@ -22,17 +22,16 @@ namespace OpenRA.Mods.RA class ActorLostNotification : INotifyKilled { - ActorLostNotificationInfo Info; + ActorLostNotificationInfo info; public ActorLostNotification(ActorLostNotificationInfo info) { - Info = info; + this.info = info; } public void Killed(Actor self, AttackInfo e) { - var player = (Info.NotifyAll) ? self.World.LocalPlayer : self.Owner; - Sound.PlayNotification(player, "Speech", Info.Notification, self.Owner.Country.Race); + var player = (info.NotifyAll) ? self.World.LocalPlayer : self.Owner; + Sound.PlayNotification(player, "Speech", info.Notification, self.Owner.Country.Race); } } } -