diff --git a/OpenRA.Mods.Cnc/Missions/CncShellmapScript.cs b/OpenRA.Mods.Cnc/Missions/CncShellmapScript.cs index b49e2d3b60..2ab0010994 100755 --- a/OpenRA.Mods.Cnc/Missions/CncShellmapScript.cs +++ b/OpenRA.Mods.Cnc/Missions/CncShellmapScript.cs @@ -18,13 +18,23 @@ using OpenRA.Mods.RA.Move; namespace OpenRA.Mods.RA { - class CncShellmapScriptInfo : TraitInfo { } + class CncShellmapScriptInfo : ITraitInfo + { + public string Music = "otp"; + public object Create(ActorInitializer init) { return new CncShellmapScript(this); } + } class CncShellmapScript: IWorldLoaded, ITick { + CncShellmapScriptInfo Info; Dictionary Actors; static int2 ViewportOrigin; + public CncShellmapScript(CncShellmapScriptInfo info) + { + Info = info; + } + public void WorldLoaded(World w) { var b = w.Map.Bounds; @@ -32,7 +42,20 @@ namespace OpenRA.Mods.RA Game.MoveViewport(ViewportOrigin); Actors = w.WorldActor.Trait().Actors; - Sound.SoundVolumeModifier = 0.25f; + // Mute world sounds + Sound.SoundVolumeModifier = 0f; + + LoopMusic(); + } + + void LoopMusic() + { + if (!Game.Settings.Game.ShellmapMusic || + Info.Music == null || + !Rules.Music[Info.Music].Exists) + return; + + Sound.PlayMusicThen(Rules.Music[Info.Music].Filename, () => LoopMusic()); } int ticks = 0; diff --git a/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs b/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs index 785dada658..6ab9f525a1 100755 --- a/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/CncLobbyLogic.cs @@ -253,6 +253,14 @@ namespace OpenRA.Mods.Cnc.Widgets chatPanel = lobby.GetWidget("CHAT_DISPLAY"); chatTemplate = chatPanel.GetWidget("CHAT_TEMPLATE"); + + lobby.GetWidget("MUSIC_BUTTON").OnClick = () => + { + Widget.OpenWindow("MUSIC_PANEL", new WidgetArgs() + { + { "onExit", () => {} }, + }); + }; } public void AddChatLine(Color c, string from, string text) diff --git a/mods/cnc/chrome/lobby.yaml b/mods/cnc/chrome/lobby.yaml index 1f1c3f6403..e2d9aabc69 100644 --- a/mods/cnc/chrome/lobby.yaml +++ b/mods/cnc/chrome/lobby.yaml @@ -361,6 +361,13 @@ Container@SERVER_LOBBY: Width:140 Height:35 Text:Leave Game + CncMenuButton@MUSIC_BUTTON: + Id:MUSIC_BUTTON + X:300 + Y:499 + Width:140 + Height:35 + Text:Music CncMenuButton@CHANGEMAP_BUTTON: Id:CHANGEMAP_BUTTON X:450