From 60fafaa5a7731090334f7d427b8f2b2c161053cb Mon Sep 17 00:00:00 2001 From: Zimmermann Gyula Date: Fri, 26 Jun 2015 02:45:43 +0200 Subject: [PATCH 1/3] Refactors the music player. --- OpenRA.Game/Game.cs | 1 - OpenRA.Game/OpenRA.Game.csproj | 1 + OpenRA.Game/Traits/World/MusicPlaylist.cs | 150 ++++++++++++++++++ OpenRA.Game/World.cs | 1 - .../Scripting/Global/MediaGlobal.cs | 30 ++-- .../Widgets/Logic/MusicPlayerLogic.cs | 64 ++------ 6 files changed, 178 insertions(+), 69 deletions(-) create mode 100644 OpenRA.Game/Traits/World/MusicPlaylist.cs diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 9f3ef7729e..9088610862 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -286,7 +286,6 @@ namespace OpenRA Console.WriteLine("Loading mod: {0}", mod); Settings.Game.Mod = mod; - Sound.StopMusic(); Sound.StopVideo(); Sound.Initialize(); diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 29f7099e1d..d7ea45367c 100644 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -182,6 +182,7 @@ + diff --git a/OpenRA.Game/Traits/World/MusicPlaylist.cs b/OpenRA.Game/Traits/World/MusicPlaylist.cs new file mode 100644 index 0000000000..49201338f0 --- /dev/null +++ b/OpenRA.Game/Traits/World/MusicPlaylist.cs @@ -0,0 +1,150 @@ +#region Copyright & License Information +/* + * Copyright 2007-2015 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 System; +using System.Linq; +using OpenRA.GameRules; + +namespace OpenRA.Traits +{ + [Desc("Trait for music handling. Attach this to the world actor.")] + public class MusicPlaylistInfo : ITraitInfo + { + public readonly string StartingMusic = null; + public readonly bool LoopStartingMusic = false; + + public object Create(ActorInitializer init) { return new MusicPlaylist(init.World, this); } + } + + public class MusicPlaylist : INotifyActorDisposing + { + readonly MusicInfo[] random; + readonly MusicInfo[] playlist; + + public readonly bool IsMusicAvailable; + + MusicInfo currentSong; + bool repeat; + + public MusicPlaylist(World world, MusicPlaylistInfo info) + { + IsMusicAvailable = world.Map.Rules.InstalledMusic.Any(); + + playlist = world.Map.Rules.InstalledMusic.Select(a => a.Value).ToArray(); + + if (!IsMusicAvailable) + return; + + random = playlist.Shuffle(Game.CosmeticRandom).ToArray(); + + if (Game.Settings.Sound.MapMusic + && !string.IsNullOrEmpty(info.StartingMusic) + && world.Map.Rules.Music.ContainsKey(info.StartingMusic) + && world.Map.Rules.Music[info.StartingMusic].Exists) + { + currentSong = world.Map.Rules.Music[info.StartingMusic]; + repeat = info.LoopStartingMusic; + } + else + { + currentSong = Game.Settings.Sound.Shuffle ? random.First() : playlist.First(); + repeat = Game.Settings.Sound.Repeat; + } + + Play(); + } + + public MusicInfo CurrentSong() + { + return currentSong; + } + + public MusicInfo[] AvailablePlaylist() + { + // TO-DO: add filter options for Race-specific music + return playlist; + } + + void Play() + { + if (currentSong == null || !IsMusicAvailable) + return; + + Sound.PlayMusicThen(currentSong, () => + { + if (!repeat) + currentSong = GetNextSong(); + + Play(); + }); + } + + public void Play(MusicInfo music) + { + if (music == null || !IsMusicAvailable) + return; + + currentSong = music; + repeat = Game.Settings.Sound.Repeat; + + Sound.PlayMusicThen(music, () => + { + if (!repeat) + currentSong = GetNextSong(); + + Play(); + }); + } + + public void Play(MusicInfo music, Action onComplete) + { + if (music == null || !IsMusicAvailable) + return; + + currentSong = music; + Sound.PlayMusicThen(music, onComplete); + } + + public MusicInfo GetNextSong() + { + return GetSong(false); + } + + public MusicInfo GetPrevSong() + { + return GetSong(true); + } + + MusicInfo GetSong(bool reverse) + { + if (!IsMusicAvailable) + return null; + + var songs = Game.Settings.Sound.Shuffle ? random : playlist; + + return reverse ? songs.SkipWhile(m => m != currentSong) + .Skip(1).FirstOrDefault() ?? songs.FirstOrDefault() : + songs.Reverse().SkipWhile(m => m != currentSong) + .Skip(1).FirstOrDefault() ?? songs.Reverse().FirstOrDefault(); + } + + public void Stop() + { + currentSong = null; + Sound.StopMusic(); + } + + public void Disposing(Actor self) + { + if (currentSong != null) + Stop(); + } + } +} diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 16ed7023d8..2413c73913 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -388,7 +388,6 @@ namespace OpenRA frameEndActions.Clear(); Sound.StopAudio(); - Sound.StopMusic(); Sound.StopVideo(); // Dispose newer actors first, and the world actor last diff --git a/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs index bcc0d41058..182a2ea815 100644 --- a/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs +++ b/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs @@ -11,26 +11,28 @@ using System; using System.Drawing; using System.IO; -using System.Linq; using Eluant; using OpenRA.Effects; using OpenRA.FileFormats; using OpenRA.FileSystem; -using OpenRA.GameRules; using OpenRA.Graphics; using OpenRA.Mods.Common.Effects; using OpenRA.Scripting; +using OpenRA.Traits; namespace OpenRA.Mods.Common.Scripting { [ScriptGlobal("Media")] public class MediaGlobal : ScriptGlobal { - World world; + readonly World world; + readonly MusicPlaylist playlist; + public MediaGlobal(ScriptContext context) : base(context) { world = context.World; + playlist = world.WorldActor.Trait(); } [Desc("Play an announcer voice listed in notifications.yaml")] @@ -51,23 +53,15 @@ namespace OpenRA.Mods.Common.Scripting Sound.Play(file); } - MusicInfo previousMusic; Action onComplete; [Desc("Play track defined in music.yaml or keep it empty for a random song.")] public void PlayMusic(string track = null, LuaFunction func = null) { - if (!Game.Settings.Sound.MapMusic) - return; - - var music = world.Map.Rules.InstalledMusic.Select(a => a.Value).ToArray(); - if (!music.Any()) + if (!Game.Settings.Sound.MapMusic || !playlist.IsMusicAvailable) return; var musicInfo = !string.IsNullOrEmpty(track) ? world.Map.Rules.Music[track] - : Game.Settings.Sound.Repeat && previousMusic != null ? previousMusic - : Game.Settings.Sound.Shuffle ? music.Random(Game.CosmeticRandom) - : previousMusic == null ? music.First() - : music.SkipWhile(s => s != previousMusic).Skip(1).First(); + : playlist.GetNextSong(); if (func != null) { @@ -84,19 +78,17 @@ namespace OpenRA.Mods.Common.Scripting Context.FatalError(e.Message); } }; + + playlist.Play(musicInfo, onComplete); } else - onComplete = () => { }; - - Sound.PlayMusicThen(musicInfo, onComplete); - - previousMusic = Sound.CurrentMusic; + playlist.Play(musicInfo); } [Desc("Stop the current song.")] public void StopMusic() { - Sound.StopMusic(); + playlist.Stop(); } Action onCompleteFullscreen; diff --git a/OpenRA.Mods.Common/Widgets/Logic/MusicPlayerLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MusicPlayerLogic.cs index 67e2a37b39..2830512b0e 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MusicPlayerLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MusicPlayerLogic.cs @@ -18,29 +18,24 @@ namespace OpenRA.Mods.Common.Widgets.Logic { public class MusicPlayerLogic { - readonly Ruleset modRules; + readonly ScrollPanelWidget musicList; + readonly ScrollItemWidget itemTemplate; - bool installed; + readonly MusicPlaylist musicPlaylist; MusicInfo currentSong = null; - MusicInfo[] music; - MusicInfo[] random; - ScrollPanelWidget musicList; - - ScrollItemWidget itemTemplate; [ObjectCreator.UseCtor] public MusicPlayerLogic(Widget widget, Ruleset modRules, World world, Action onExit) { - this.modRules = modRules; - var panel = widget.Get("MUSIC_PANEL"); musicList = panel.Get("MUSIC_LIST"); itemTemplate = musicList.Get("MUSIC_TEMPLATE"); + musicPlaylist = world.WorldActor.Trait(); BuildMusicTable(); - Func noMusic = () => !installed; + Func noMusic = () => !musicPlaylist.IsMusicAvailable; panel.Get("NO_MUSIC_LABEL").IsVisible = noMusic; var playButton = panel.Get("BUTTON_PLAY"); @@ -54,15 +49,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic pauseButton.IsVisible = () => Sound.MusicPlaying; var stopButton = panel.Get("BUTTON_STOP"); - stopButton.OnClick = Sound.StopMusic; + stopButton.OnClick = () => { musicPlaylist.Stop(); }; stopButton.IsDisabled = noMusic; var nextButton = panel.Get("BUTTON_NEXT"); - nextButton.OnClick = () => { currentSong = GetNextSong(); Play(); }; + nextButton.OnClick = () => { currentSong = musicPlaylist.GetNextSong(); Play(); }; nextButton.IsDisabled = noMusic; var prevButton = panel.Get("BUTTON_PREV"); - prevButton.OnClick = () => { currentSong = GetPrevSong(); Play(); }; + prevButton.OnClick = () => { currentSong = musicPlaylist.GetPrevSong(); Play(); }; prevButton.IsDisabled = noMusic; var shuffleCheckbox = panel.Get("SHUFFLE"); @@ -111,11 +106,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic public void BuildMusicTable() { - music = modRules.InstalledMusic.Select(a => a.Value).ToArray(); - random = music.Shuffle(Game.CosmeticRandom).ToArray(); - currentSong = Sound.CurrentMusic; + if (!musicPlaylist.IsMusicAvailable) + return; + + var music = musicPlaylist.AvailablePlaylist(); + currentSong = musicPlaylist.CurrentSong(); if (currentSong == null && music.Any()) - currentSong = Game.Settings.Sound.Shuffle ? random.First() : music.First(); + currentSong = musicPlaylist.GetNextSong(); musicList.RemoveChildren(); foreach (var s in music) @@ -124,8 +121,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (currentSong == null) currentSong = song; - // TODO: We leak the currentSong MusicInfo across map load, so compare the Filename instead. - var item = ScrollItemWidget.Setup(song.Filename, itemTemplate, () => currentSong.Filename == song.Filename, () => { currentSong = song; Play(); }, () => { }); + var item = ScrollItemWidget.Setup(song.Filename, itemTemplate, () => currentSong == song, () => { currentSong = song; Play(); }, () => { }); item.Get("TITLE").GetText = () => song.Title; item.Get("LENGTH").GetText = () => SongLengthLabel(song); musicList.AddChild(item); @@ -133,8 +129,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (currentSong != null) musicList.ScrollToItem(currentSong.Filename); - - installed = modRules.InstalledMusic.Any(); } void Play() @@ -143,38 +137,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic return; musicList.ScrollToItem(currentSong.Filename); - - Sound.PlayMusicThen(currentSong, () => - { - if (!Game.Settings.Sound.Repeat) - currentSong = GetNextSong(); - Play(); - }); + musicPlaylist.Play(currentSong); } static string SongLengthLabel(MusicInfo song) { return "{0:D1}:{1:D2}".F(song.Length / 60, song.Length % 60); } - - MusicInfo GetNextSong() - { - if (!music.Any()) - return null; - - var songs = Game.Settings.Sound.Shuffle ? random : music; - return songs.SkipWhile(m => m != currentSong) - .Skip(1).FirstOrDefault() ?? songs.FirstOrDefault(); - } - - MusicInfo GetPrevSong() - { - if (!music.Any()) - return null; - - var songs = Game.Settings.Sound.Shuffle ? random : music; - return songs.Reverse().SkipWhile(m => m != currentSong) - .Skip(1).FirstOrDefault() ?? songs.Reverse().FirstOrDefault(); - } } } From e875f675b89014c94380c65659c6a9c76ad0e17b Mon Sep 17 00:00:00 2001 From: Zimmermann Gyula Date: Fri, 26 Jun 2015 12:14:58 +0200 Subject: [PATCH 2/3] Updates all base mods with the MusicPlaylist trait. --- mods/cnc/maps/funpark01/map.yaml | 2 ++ mods/cnc/maps/funpark01/scj01ea.lua | 7 ------- mods/cnc/maps/gdi01/gdi01.lua | 8 -------- mods/cnc/maps/gdi01/map.yaml | 2 ++ mods/cnc/maps/gdi02/gdi02.lua | 8 -------- mods/cnc/maps/gdi02/map.yaml | 2 ++ mods/cnc/maps/gdi03/gdi03.lua | 8 -------- mods/cnc/maps/gdi03/map.yaml | 2 ++ mods/cnc/maps/gdi04a/gdi04a.lua | 8 -------- mods/cnc/maps/gdi04a/map.yaml | 2 ++ mods/cnc/maps/gdi04b/gdi04b.lua | 8 -------- mods/cnc/maps/gdi04b/map.yaml | 2 ++ mods/cnc/maps/gdi04c/gdi04c.lua | 8 -------- mods/cnc/maps/gdi04c/map.yaml | 2 ++ mods/cnc/maps/gdi05a/gdi05a.lua | 9 --------- mods/cnc/maps/gdi05a/map.yaml | 2 ++ mods/cnc/maps/gdi05b/gdi05b.lua | 8 -------- mods/cnc/maps/gdi05b/map.yaml | 2 ++ mods/cnc/maps/nod01/map.yaml | 2 ++ mods/cnc/maps/nod01/nod01.lua | 8 -------- mods/cnc/maps/nod02a/map.yaml | 2 ++ mods/cnc/maps/nod02a/nod02a.lua | 8 -------- mods/cnc/maps/nod02b/map.yaml | 2 ++ mods/cnc/maps/nod02b/nod02b.lua | 8 -------- mods/cnc/maps/nod03a/map.yaml | 2 ++ mods/cnc/maps/nod03a/nod03a.lua | 8 -------- mods/cnc/maps/nod03b/map.yaml | 2 ++ mods/cnc/maps/nod03b/nod03b.lua | 8 -------- mods/cnc/maps/nod04a/map.yaml | 2 ++ mods/cnc/maps/nod04a/nod04a.lua | 8 -------- mods/cnc/maps/nod04b/map.yaml | 2 ++ mods/cnc/maps/nod04b/nod04b.lua | 8 -------- mods/cnc/maps/nod05/map.yaml | 2 ++ mods/cnc/maps/nod05/nod05.lua | 9 --------- mods/cnc/maps/nod06a/map.yaml | 2 ++ mods/cnc/maps/nod06a/nod06a.lua | 8 -------- mods/cnc/maps/nod06b/map.yaml | 2 ++ mods/cnc/maps/nod06b/nod06b.lua | 8 -------- mods/cnc/maps/nod06c/map.yaml | 2 ++ mods/cnc/maps/nod06c/nod06c.lua | 8 -------- mods/cnc/maps/shellmap/map.yaml | 3 +++ mods/cnc/maps/shellmap/shellmap.lua | 5 ----- mods/cnc/rules/world.yaml | 1 + mods/d2k/maps/shellmap/map.yaml | 2 ++ mods/d2k/maps/shellmap/shellmap.lua | 3 --- mods/d2k/rules/world.yaml | 1 + mods/ra/maps/desert-shellmap/desert-shellmap.lua | 2 -- mods/ra/rules/world.yaml | 1 + mods/ts/maps/blank-shellmap/map.yaml | 5 +++-- mods/ts/maps/blank-shellmap/shellmap.lua | 7 ------- mods/ts/rules/world.yaml | 1 + 51 files changed, 52 insertions(+), 180 deletions(-) delete mode 100644 mods/ts/maps/blank-shellmap/shellmap.lua diff --git a/mods/cnc/maps/funpark01/map.yaml b/mods/cnc/maps/funpark01/map.yaml index 93e882740c..e8fc1baf2e 100644 --- a/mods/cnc/maps/funpark01/map.yaml +++ b/mods/cnc/maps/funpark01/map.yaml @@ -441,6 +441,8 @@ Rules: Scripts: scj01ea.lua ObjectivesPanel: PanelName: MISSION_OBJECTIVES + MusicPlaylist: + StartingMusic: j1 ^Vehicle: Tooltip: GenericVisibility: Enemy diff --git a/mods/cnc/maps/funpark01/scj01ea.lua b/mods/cnc/maps/funpark01/scj01ea.lua index 8d31bb9c4d..2130e84c48 100644 --- a/mods/cnc/maps/funpark01/scj01ea.lua +++ b/mods/cnc/maps/funpark01/scj01ea.lua @@ -32,12 +32,6 @@ ReinforceWithLandingCraft = function(units, transportStart, transportUnload, ral Media.PlaySpeechNotification(player, "Reinforce") end -initialSong = "j1" -PlayMusic = function() - Media.PlayMusic(initialSong, PlayMusic) - initialSong = nil -end - WorldLoaded = function() nod = Player.GetPlayer("Nod") dinosaur = Player.GetPlayer("Dinosaur") @@ -91,7 +85,6 @@ WorldLoaded = function() end Camera.Position = CameraStart.CenterPosition - PlayMusic() end Tick = function() diff --git a/mods/cnc/maps/gdi01/gdi01.lua b/mods/cnc/maps/gdi01/gdi01.lua index c8e61459a8..24c4265c0c 100644 --- a/mods/cnc/maps/gdi01/gdi01.lua +++ b/mods/cnc/maps/gdi01/gdi01.lua @@ -56,12 +56,6 @@ CheckForBase = function() return #baseBuildings >= 3 end -initialSong = "aoi" -PlayMusic = function() - Media.PlayMusic(initialSong, PlayMusic) - initialSong = nil -end - WorldLoaded = function() player = Player.GetPlayer("GDI") enemy = Player.GetPlayer("Nod") @@ -93,8 +87,6 @@ WorldLoaded = function() ReinforceWithLandingCraft(MCVReinforcements, lstStart.Location + CVec.New(2, 0), lstEnd.Location + CVec.New(2, 0), mcvTarget.Location) Reinforce(InfantryReinforcements) - PlayMusic() - Trigger.OnIdle(Gunboat, function() SetGunboatPath(Gunboat) end) SendNodPatrol() diff --git a/mods/cnc/maps/gdi01/map.yaml b/mods/cnc/maps/gdi01/map.yaml index 8a350ccf64..f5ad68a83f 100644 --- a/mods/cnc/maps/gdi01/map.yaml +++ b/mods/cnc/maps/gdi01/map.yaml @@ -428,6 +428,8 @@ Rules: Scripts: gdi01.lua ObjectivesPanel: PanelName: MISSION_OBJECTIVES + MusicPlaylist: + StartingMusic: aoi Player: -ConquestVictoryConditions: MissionObjectives: diff --git a/mods/cnc/maps/gdi02/gdi02.lua b/mods/cnc/maps/gdi02/gdi02.lua index fe37e3ab53..5b3b6fa14d 100644 --- a/mods/cnc/maps/gdi02/gdi02.lua +++ b/mods/cnc/maps/gdi02/gdi02.lua @@ -56,18 +56,10 @@ NodAttack = function() end end -initialSong = "befeared" -PlayMusic = function() - Media.PlayMusic(initialSong, PlayMusic) - initialSong = nil -end - WorldLoaded = function() player = Player.GetPlayer("GDI") enemy = Player.GetPlayer("Nod") - PlayMusic() - Trigger.OnObjectiveAdded(player, function(p, id) Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective") end) diff --git a/mods/cnc/maps/gdi02/map.yaml b/mods/cnc/maps/gdi02/map.yaml index b88f777d1e..f70a34397f 100644 --- a/mods/cnc/maps/gdi02/map.yaml +++ b/mods/cnc/maps/gdi02/map.yaml @@ -655,6 +655,8 @@ Rules: Scripts: gdi02.lua ObjectivesPanel: PanelName: MISSION_OBJECTIVES + MusicPlaylist: + StartingMusic: befeared Player: -ConquestVictoryConditions: MissionObjectives: diff --git a/mods/cnc/maps/gdi03/gdi03.lua b/mods/cnc/maps/gdi03/gdi03.lua index 4556d615db..3d470f19bc 100644 --- a/mods/cnc/maps/gdi03/gdi03.lua +++ b/mods/cnc/maps/gdi03/gdi03.lua @@ -45,18 +45,10 @@ SendReinforcements = function() Media.PlaySpeechNotification(player, "Reinforce") end -initialSong = "crep226m" -PlayMusic = function() - Media.PlayMusic(initialSong, PlayMusic) - initialSong = nil -end - WorldLoaded = function() player = Player.GetPlayer("GDI") enemy = Player.GetPlayer("Nod") - PlayMusic() - Trigger.OnObjectiveAdded(player, function(p, id) Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective") end) diff --git a/mods/cnc/maps/gdi03/map.yaml b/mods/cnc/maps/gdi03/map.yaml index e0612e91f2..0ea63bc6bb 100644 --- a/mods/cnc/maps/gdi03/map.yaml +++ b/mods/cnc/maps/gdi03/map.yaml @@ -730,6 +730,8 @@ Rules: Scripts: gdi03.lua ObjectivesPanel: PanelName: MISSION_OBJECTIVES + MusicPlaylist: + StartingMusic: crep226m Player: -ConquestVictoryConditions: MissionObjectives: diff --git a/mods/cnc/maps/gdi04a/gdi04a.lua b/mods/cnc/maps/gdi04a/gdi04a.lua index 9b56e3a316..795380b4a1 100644 --- a/mods/cnc/maps/gdi04a/gdi04a.lua +++ b/mods/cnc/maps/gdi04a/gdi04a.lua @@ -103,20 +103,12 @@ SetupWorld = function() Trigger.OnRemovedFromWorld(crate, function() gdi.MarkCompletedObjective(gdiObjective) end) end -initialSong = "fist226m" -PlayMusic = function() - Media.PlayMusic(initialSong, PlayMusic) - initialSong = nil -end - WorldLoaded = function() gdi = Player.GetPlayer("GDI") nod = Player.GetPlayer("Nod") SetupWorld() - PlayMusic() - Trigger.OnObjectiveAdded(gdi, function(p, id) Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective") end) diff --git a/mods/cnc/maps/gdi04a/map.yaml b/mods/cnc/maps/gdi04a/map.yaml index c63f3f55bf..f0315f2e5a 100644 --- a/mods/cnc/maps/gdi04a/map.yaml +++ b/mods/cnc/maps/gdi04a/map.yaml @@ -489,6 +489,8 @@ Rules: Scripts: gdi04a.lua ObjectivesPanel: PanelName: MISSION_OBJECTIVES + MusicPlaylist: + StartingMusic: fist226m Player: -ConquestVictoryConditions: MissionObjectives: diff --git a/mods/cnc/maps/gdi04b/gdi04b.lua b/mods/cnc/maps/gdi04b/gdi04b.lua index 070ce89fbe..d7bc55a270 100644 --- a/mods/cnc/maps/gdi04b/gdi04b.lua +++ b/mods/cnc/maps/gdi04b/gdi04b.lua @@ -110,12 +110,6 @@ SetupWorld = function() Trigger.OnRemovedFromWorld(crate, function() gdi.MarkCompletedObjective(gdiObjective) end) end -initialSong = "fist226m" -PlayMusic = function() - Media.PlayMusic(initialSong, PlayMusic) - initialSong = nil -end - WorldLoaded = function() gdi = Player.GetPlayer("GDI") nod = Player.GetPlayer("Nod") @@ -144,8 +138,6 @@ WorldLoaded = function() SetupWorld() - PlayMusic() - bhndTrigger = false Trigger.OnExitedFootprint(BhndTrigger, function(a, id) if not bhndTrigger and a.Owner == gdi then diff --git a/mods/cnc/maps/gdi04b/map.yaml b/mods/cnc/maps/gdi04b/map.yaml index abb91362a3..eb0777c620 100644 --- a/mods/cnc/maps/gdi04b/map.yaml +++ b/mods/cnc/maps/gdi04b/map.yaml @@ -560,6 +560,8 @@ Rules: Scripts: gdi04b.lua ObjectivesPanel: PanelName: MISSION_OBJECTIVES + MusicPlaylist: + StartingMusic: fist226m Player: -ConquestVictoryConditions: MissionObjectives: diff --git a/mods/cnc/maps/gdi04c/gdi04c.lua b/mods/cnc/maps/gdi04c/gdi04c.lua index da1622be7a..7d9defda4d 100644 --- a/mods/cnc/maps/gdi04c/gdi04c.lua +++ b/mods/cnc/maps/gdi04c/gdi04c.lua @@ -61,18 +61,10 @@ SendGDIReinforcements = function() end) end -initialSong = "ind" -PlayMusic = function() - Media.PlayMusic(initialSong, PlayMusic) - initialSong = nil -end - WorldLoaded = function() player = Player.GetPlayer("GDI") nod = Player.GetPlayer("Nod") - PlayMusic() - Trigger.OnObjectiveAdded(player, function(p, id) Media.DisplayMessage(p.GetObjectiveDescription(id), "New " .. string.lower(p.GetObjectiveType(id)) .. " objective") end) diff --git a/mods/cnc/maps/gdi04c/map.yaml b/mods/cnc/maps/gdi04c/map.yaml index 510093acc9..edf37d37ed 100644 --- a/mods/cnc/maps/gdi04c/map.yaml +++ b/mods/cnc/maps/gdi04c/map.yaml @@ -785,6 +785,8 @@ Rules: Scripts: gdi04c.lua ObjectivesPanel: PanelName: MISSION_OBJECTIVES + MusicPlaylist: + StartingMusic: ind Player: -ConquestVictoryConditions: MissionObjectives: diff --git a/mods/cnc/maps/gdi05a/gdi05a.lua b/mods/cnc/maps/gdi05a/gdi05a.lua index b184251b9f..e119088a9a 100644 --- a/mods/cnc/maps/gdi05a/gdi05a.lua +++ b/mods/cnc/maps/gdi05a/gdi05a.lua @@ -183,12 +183,6 @@ SetupWorld = function() Grd3Action() end -initialSong = "rain" -PlayMusic = function() - Media.PlayMusic(initialSong, PlayMusic) - initialSong = nil -end - WorldLoaded = function() gdiBase = Player.GetPlayer("AbandonedBase") gdi = Player.GetPlayer("GDI") @@ -219,9 +213,6 @@ WorldLoaded = function() SetupWorld() Camera.Position = GdiTankRallyPoint.CenterPosition - - PlayMusic() - end Tick = function() diff --git a/mods/cnc/maps/gdi05a/map.yaml b/mods/cnc/maps/gdi05a/map.yaml index 4659bdfc18..5a938477b7 100644 --- a/mods/cnc/maps/gdi05a/map.yaml +++ b/mods/cnc/maps/gdi05a/map.yaml @@ -797,6 +797,8 @@ Rules: Scripts: gdi05a.lua ObjectivesPanel: PanelName: MISSION_OBJECTIVES + MusicPlaylist: + StartingMusic: rain Player: -ConquestVictoryConditions: MissionObjectives: diff --git a/mods/cnc/maps/gdi05b/gdi05b.lua b/mods/cnc/maps/gdi05b/gdi05b.lua index 8926f6bd21..5df1e1acae 100644 --- a/mods/cnc/maps/gdi05b/gdi05b.lua +++ b/mods/cnc/maps/gdi05b/gdi05b.lua @@ -118,12 +118,6 @@ IdleHunt = function(unit) end end -initialSong = "rain" -PlayMusic = function() - Media.PlayMusic(initialSong, PlayMusic) - initialSong = nil -end - WorldLoaded = function() gdi = Player.GetPlayer("GDI") gdiBase = Player.GetPlayer("AbandonedBase") @@ -185,8 +179,6 @@ WorldLoaded = function() end) Camera.Position = UnitsRally.CenterPosition - - PlayMusic() InsertGdiUnits() end diff --git a/mods/cnc/maps/gdi05b/map.yaml b/mods/cnc/maps/gdi05b/map.yaml index d80299897b..07925a9106 100644 --- a/mods/cnc/maps/gdi05b/map.yaml +++ b/mods/cnc/maps/gdi05b/map.yaml @@ -639,6 +639,8 @@ Rules: MissionObjectives: EarlyGameOver: true EnemyWatcher: + MusicPlaylist: + StartingMusic: rain World: -CrateSpawner: -SpawnMPUnits: diff --git a/mods/cnc/maps/nod01/map.yaml b/mods/cnc/maps/nod01/map.yaml index 387a6fb8ff..85d17c774d 100644 --- a/mods/cnc/maps/nod01/map.yaml +++ b/mods/cnc/maps/nod01/map.yaml @@ -289,6 +289,8 @@ Rules: Scripts: nod01.lua ObjectivesPanel: PanelName: MISSION_OBJECTIVES + MusicPlaylist: + StartingMusic: nomercy C10: Tooltip: Name: Nikoomba diff --git a/mods/cnc/maps/nod01/nod01.lua b/mods/cnc/maps/nod01/nod01.lua index 3603a1b912..9476e36509 100644 --- a/mods/cnc/maps/nod01/nod01.lua +++ b/mods/cnc/maps/nod01/nod01.lua @@ -31,12 +31,6 @@ SendLastInfantryReinforcements = function() end) end -initialSong = "nomercy" -PlayMusic = function() - Media.PlayMusic(initialSong, PlayMusic) - initialSong = nil -end - WorldLoaded = function() nod = Player.GetPlayer("Nod") gdi = Player.GetPlayer("GDI") @@ -74,8 +68,6 @@ WorldLoaded = function() Camera.Position = StartRallyPoint.CenterPosition - PlayMusic() - SendInitialForces() Trigger.AfterDelay(DateTime.Seconds(30), SendFirstInfantryReinforcements) Trigger.AfterDelay(DateTime.Seconds(60), SendSecondInfantryReinforcements) diff --git a/mods/cnc/maps/nod02a/map.yaml b/mods/cnc/maps/nod02a/map.yaml index cb756333a9..bf42e40551 100644 --- a/mods/cnc/maps/nod02a/map.yaml +++ b/mods/cnc/maps/nod02a/map.yaml @@ -226,6 +226,8 @@ Rules: PanelName: MISSION_OBJECTIVES LuaScript: Scripts: nod02a.lua + MusicPlaylist: + StartingMusic: ind2 ^Vehicle: Tooltip: GenericVisibility: Enemy diff --git a/mods/cnc/maps/nod02a/nod02a.lua b/mods/cnc/maps/nod02a/nod02a.lua index 00647f8428..7a22835809 100644 --- a/mods/cnc/maps/nod02a/nod02a.lua +++ b/mods/cnc/maps/nod02a/nod02a.lua @@ -159,12 +159,6 @@ Pat1Movement = function(unit) IdleHunt(unit) end -initialSong = "ind2" -PlayMusic = function() - Media.PlayMusic(initialSong, PlayMusic) - initialSong = nil -end - WorldLoaded = function() GDI = Player.GetPlayer("GDI") Nod = Player.GetPlayer("Nod") @@ -222,8 +216,6 @@ WorldLoaded = function() end end) - PlayMusic() - Trigger.AfterDelay(0, getStartUnits) InsertNodUnits() end diff --git a/mods/cnc/maps/nod02b/map.yaml b/mods/cnc/maps/nod02b/map.yaml index 644728419c..a2e61a2735 100644 --- a/mods/cnc/maps/nod02b/map.yaml +++ b/mods/cnc/maps/nod02b/map.yaml @@ -268,6 +268,8 @@ Rules: PanelName: MISSION_OBJECTIVES LuaScript: Scripts: nod02b.lua + MusicPlaylist: + StartingMusic: ind2 ^Vehicle: Tooltip: GenericVisibility: Enemy diff --git a/mods/cnc/maps/nod02b/nod02b.lua b/mods/cnc/maps/nod02b/nod02b.lua index f0135e3a41..c1a0f3e112 100644 --- a/mods/cnc/maps/nod02b/nod02b.lua +++ b/mods/cnc/maps/nod02b/nod02b.lua @@ -96,12 +96,6 @@ Gdi3Movement = function(unit) IdleHunt(unit) end -initialSong = "ind2" -PlayMusic = function() - Media.PlayMusic(initialSong, PlayMusic) - initialSong = nil -end - WorldLoaded = function() GDI = Player.GetPlayer("GDI") Nod = Player.GetPlayer("Nod") @@ -141,8 +135,6 @@ WorldLoaded = function() Trigger.AfterDelay(0, getStartUnits) Harvester.FindResources() - PlayMusic() - InsertNodUnits() end diff --git a/mods/cnc/maps/nod03a/map.yaml b/mods/cnc/maps/nod03a/map.yaml index dfb3ef6411..cbc36d8d04 100644 --- a/mods/cnc/maps/nod03a/map.yaml +++ b/mods/cnc/maps/nod03a/map.yaml @@ -467,6 +467,8 @@ Rules: Scripts: nod03a.lua ObjectivesPanel: PanelName: MISSION_OBJECTIVES + MusicPlaylist: + StartingMusic: chrg226m ^Vehicle: Tooltip: GenericVisibility: Enemy diff --git a/mods/cnc/maps/nod03a/nod03a.lua b/mods/cnc/maps/nod03a/nod03a.lua index 9c10d3b1c9..ed72aabe5e 100644 --- a/mods/cnc/maps/nod03a/nod03a.lua +++ b/mods/cnc/maps/nod03a/nod03a.lua @@ -16,12 +16,6 @@ InsertNodUnits = function() end) end -initialSong = "chrg226m" -PlayMusic = function() - Media.PlayMusic(initialSong, PlayMusic) - initialSong = nil -end - WorldLoaded = function() player = Player.GetPlayer("Nod") enemy = Player.GetPlayer("GDI") @@ -58,8 +52,6 @@ WorldLoaded = function() player.MarkFailedObjective(nodObjective1) end) - PlayMusic() - InsertNodUnits() Trigger.AfterDelay(DateTime.Seconds(20), function() SendAttackWave(FirstAttackWave, AttackWaveSpawnA.Location) end) Trigger.AfterDelay(DateTime.Seconds(50), function() SendAttackWave(SecondThirdAttackWave, AttackWaveSpawnB.Location) end) diff --git a/mods/cnc/maps/nod03b/map.yaml b/mods/cnc/maps/nod03b/map.yaml index 6e64d0d6b2..527c88c00d 100644 --- a/mods/cnc/maps/nod03b/map.yaml +++ b/mods/cnc/maps/nod03b/map.yaml @@ -511,6 +511,8 @@ Rules: Scripts: nod03b.lua ObjectivesPanel: PanelName: MISSION_OBJECTIVES + MusicPlaylist: + StartingMusic: chrg226m ^Vehicle: Tooltip: GenericVisibility: Enemy diff --git a/mods/cnc/maps/nod03b/nod03b.lua b/mods/cnc/maps/nod03b/nod03b.lua index 3e1c922d26..51510db360 100644 --- a/mods/cnc/maps/nod03b/nod03b.lua +++ b/mods/cnc/maps/nod03b/nod03b.lua @@ -33,12 +33,6 @@ InsertNodUnits = function() end) end -initialSong = "chrg226m" -PlayMusic = function() - Media.PlayMusic(initialSong, PlayMusic) - initialSong = nil -end - WorldLoaded = function() player = Player.GetPlayer("Nod") enemy = Player.GetPlayer("GDI") @@ -72,8 +66,6 @@ WorldLoaded = function() end) end) - PlayMusic() - InsertNodUnits() Trigger.AfterDelay(DateTime.Seconds(40), function() SendAttackWave(FirstAttackWaveUnits, FirstAttackWave) end) Trigger.AfterDelay(DateTime.Seconds(80), function() SendAttackWave(SecondAttackWaveUnits, SecondAttackWave) end) diff --git a/mods/cnc/maps/nod04a/map.yaml b/mods/cnc/maps/nod04a/map.yaml index 17eb11a634..c8fc9ab427 100644 --- a/mods/cnc/maps/nod04a/map.yaml +++ b/mods/cnc/maps/nod04a/map.yaml @@ -568,6 +568,8 @@ Rules: Scripts: nod04a.lua ObjectivesPanel: PanelName: MISSION_OBJECTIVES + MusicPlaylist: + StartingMusic: valkyrie ^Vehicle: Tooltip: GenericVisibility: Enemy diff --git a/mods/cnc/maps/nod04a/nod04a.lua b/mods/cnc/maps/nod04a/nod04a.lua index e0a084c2fb..46dadfea02 100644 --- a/mods/cnc/maps/nod04a/nod04a.lua +++ b/mods/cnc/maps/nod04a/nod04a.lua @@ -171,12 +171,6 @@ CreateCivilians = function(actor, discoverer) end) end -initialSong = "valkyrie" -PlayMusic = function() - Media.PlayMusic(initialSong, PlayMusic) - initialSong = nil -end - WorldLoaded = function() NodSupporter = Player.GetPlayer("NodSupporter") Nod = Player.GetPlayer("Nod") @@ -290,8 +284,6 @@ WorldLoaded = function() GDIObjective = GDI.AddPrimaryObjective("Eliminate all Nod forces in the area.") NodObjective1 = Nod.AddPrimaryObjective("Kill all civilian GDI supporters.") - PlayMusic() - InsertNodUnits() Camera.Position = waypoint6.CenterPosition end diff --git a/mods/cnc/maps/nod04b/map.yaml b/mods/cnc/maps/nod04b/map.yaml index 9565289096..616d2df796 100644 --- a/mods/cnc/maps/nod04b/map.yaml +++ b/mods/cnc/maps/nod04b/map.yaml @@ -507,6 +507,8 @@ Rules: PanelName: MISSION_OBJECTIVES LuaScript: Scripts: nod04b.lua + MusicPlaylist: + StartingMusic: warfare ^Vehicle: Tooltip: GenericVisibility: Enemy diff --git a/mods/cnc/maps/nod04b/nod04b.lua b/mods/cnc/maps/nod04b/nod04b.lua index b1b2f8d557..36f17e0875 100644 --- a/mods/cnc/maps/nod04b/nod04b.lua +++ b/mods/cnc/maps/nod04b/nod04b.lua @@ -74,12 +74,6 @@ InsertNodUnits = function() Reinforcements.ReinforceWithTransport(Nod, 'tran', NodUnitsGunner, { EntryPointGunner.Location, RallyPointGunner.Location }, { EntryPointGunner.Location }, nil, nil) end -initialSong = "warfare" -PlayMusic = function() - Media.PlayMusic(initialSong, PlayMusic) - initialSong = nil -end - WorldLoaded = function() GDI = Player.GetPlayer("GDI") Nod = Player.GetPlayer("Nod") @@ -147,8 +141,6 @@ WorldLoaded = function() NodObjective1 = Nod.AddPrimaryObjective("Destroy the village and kill all civilians.") NodObjective2 = Nod.AddSecondaryObjective("Kill all GDI units in the area.") - PlayMusic() - InsertNodUnits() end diff --git a/mods/cnc/maps/nod05/map.yaml b/mods/cnc/maps/nod05/map.yaml index d30094141a..e5ec9568cd 100644 --- a/mods/cnc/maps/nod05/map.yaml +++ b/mods/cnc/maps/nod05/map.yaml @@ -402,6 +402,8 @@ Rules: PanelName: MISSION_OBJECTIVES LuaScript: Scripts: nod05.lua + MusicPlaylist: + StartingMusic: airstrik ^Vehicle: Tooltip: GenericVisibility: Enemy diff --git a/mods/cnc/maps/nod05/nod05.lua b/mods/cnc/maps/nod05/nod05.lua index ea2c5c301d..afb7db6e42 100644 --- a/mods/cnc/maps/nod05/nod05.lua +++ b/mods/cnc/maps/nod05/nod05.lua @@ -163,12 +163,6 @@ InsertNodUnits = function() end) end -initialSong = "airstrik" -PlayMusic = function() - Media.PlayMusic(initialSong, PlayMusic) - initialSong = nil -end - WorldLoaded = function() GDI = Player.GetPlayer("GDI") Nod = Player.GetPlayer("Nod") @@ -247,9 +241,6 @@ WorldLoaded = function() end) Trigger.AfterDelay(0, getStartUnits) - - PlayMusic() - end Tick = function() diff --git a/mods/cnc/maps/nod06a/map.yaml b/mods/cnc/maps/nod06a/map.yaml index 0975a13452..dcf76654f8 100644 --- a/mods/cnc/maps/nod06a/map.yaml +++ b/mods/cnc/maps/nod06a/map.yaml @@ -675,6 +675,8 @@ Rules: PanelName: MISSION_OBJECTIVES LuaScript: Scripts: nod06a.lua + MusicPlaylist: + StartingMusic: rout ^Vehicle: Tooltip: GenericVisibility: Enemy diff --git a/mods/cnc/maps/nod06a/nod06a.lua b/mods/cnc/maps/nod06a/nod06a.lua index 4df5cf0783..ffffea6056 100644 --- a/mods/cnc/maps/nod06a/nod06a.lua +++ b/mods/cnc/maps/nod06a/nod06a.lua @@ -118,12 +118,6 @@ InsertNodUnits = function() Reinforcements.Reinforce(Nod, NodStartUnitsRight, { UnitsEntryRight.Location, UnitsRallyRight.Location }, 15) end -initialSong = "rout" -PlayMusic = function() - Media.PlayMusic(initialSong, PlayMusic) - initialSong = nil -end - WorldLoaded = function() GDI = Player.GetPlayer("GDI") Nod = Player.GetPlayer("Nod") @@ -153,8 +147,6 @@ WorldLoaded = function() GDIObjective = GDI.AddPrimaryObjective("Stop the Nod taskforce from escaping with the detonator.") - PlayMusic() - InsertNodUnits() Trigger.AfterDelay(Grd1TriggerFunctionTime, Grd1TriggerFunction) diff --git a/mods/cnc/maps/nod06b/map.yaml b/mods/cnc/maps/nod06b/map.yaml index 67d197cce7..630c6548fd 100644 --- a/mods/cnc/maps/nod06b/map.yaml +++ b/mods/cnc/maps/nod06b/map.yaml @@ -617,6 +617,8 @@ Rules: PanelName: MISSION_OBJECTIVES LuaScript: Scripts: nod06b.lua + MusicPlaylist: + StartingMusic: rout ^Vehicle: Tooltip: GenericVisibility: Enemy diff --git a/mods/cnc/maps/nod06b/nod06b.lua b/mods/cnc/maps/nod06b/nod06b.lua index 11036e8459..4da90d6e70 100644 --- a/mods/cnc/maps/nod06b/nod06b.lua +++ b/mods/cnc/maps/nod06b/nod06b.lua @@ -94,12 +94,6 @@ InsertNodUnits = function() Reinforcements.Reinforce(Nod, NodUnitsRocket, { UnitsEntryRocket.Location, UnitsRallyRocket.Location }, 25) end -initialSong = "rout" -PlayMusic = function() - Media.PlayMusic(initialSong, PlayMusic) - initialSong = nil -end - WorldLoaded = function() GDI = Player.GetPlayer("GDI") Nod = Player.GetPlayer("Nod") @@ -127,8 +121,6 @@ WorldLoaded = function() NodObjective1 = Nod.AddPrimaryObjective("Steal the GDI nuclear detonator.") GDIObjective = GDI.AddPrimaryObjective("Stop the Nod taskforce from escaping with the detonator.") - PlayMusic() - InsertNodUnits() Trigger.OnEnteredFootprint(HuntCellTriggerActivator, function(a, id) diff --git a/mods/cnc/maps/nod06c/map.yaml b/mods/cnc/maps/nod06c/map.yaml index 32df9a1ded..9bf7c2d860 100644 --- a/mods/cnc/maps/nod06c/map.yaml +++ b/mods/cnc/maps/nod06c/map.yaml @@ -503,6 +503,8 @@ Rules: PanelName: MISSION_OBJECTIVES LuaScript: Scripts: nod06c.lua + MusicPlaylist: + StartingMusic: rout ^Vehicle: Tooltip: GenericVisibility: Enemy diff --git a/mods/cnc/maps/nod06c/nod06c.lua b/mods/cnc/maps/nod06c/nod06c.lua index ca3316ca74..359eca404b 100644 --- a/mods/cnc/maps/nod06c/nod06c.lua +++ b/mods/cnc/maps/nod06c/nod06c.lua @@ -82,12 +82,6 @@ InsertNodUnits = function() Reinforcements.Reinforce(Nod, NodStartUnitsRight, { UnitsEntryRight.Location, UnitsRallyRight.Location }, 15) end -initialSong = "rout" -PlayMusic = function() - Media.PlayMusic(initialSong, PlayMusic) - initialSong = nil -end - WorldLoaded = function() GDI = Player.GetPlayer("GDI") Nod = Player.GetPlayer("Nod") @@ -116,8 +110,6 @@ WorldLoaded = function() NodObjective3 = Nod.AddSecondaryObjective("Infiltrate the barracks, weapon factory and \nthe construction yard.") GDIObjective = GDI.AddPrimaryObjective("Stop the Nod taskforce from escaping with the detonator.") - PlayMusic() - InsertNodUnits() Trigger.AfterDelay(Atk1TriggerFunctionTime, Atk1TriggerFunction) diff --git a/mods/cnc/maps/shellmap/map.yaml b/mods/cnc/maps/shellmap/map.yaml index 2596ac7b31..6bf0fb3dc3 100644 --- a/mods/cnc/maps/shellmap/map.yaml +++ b/mods/cnc/maps/shellmap/map.yaml @@ -994,6 +994,9 @@ Rules: Effect: Desaturated LuaScript: Scripts: shellmap.lua + MusicPlaylist: + StartingMusic: map1 + LoopStartingMusic: True LST: Mobile: Speed: 42 diff --git a/mods/cnc/maps/shellmap/shellmap.lua b/mods/cnc/maps/shellmap/shellmap.lua index 3a847feaa9..2b72205e06 100644 --- a/mods/cnc/maps/shellmap/shellmap.lua +++ b/mods/cnc/maps/shellmap/shellmap.lua @@ -17,7 +17,6 @@ WorldLoaded = function() for i, unit in ipairs(units) do LoopTrack(unit, CPos.New(8, unit.Location.Y), CPos.New(87, unit.Location.Y)) end - PlayMusic() end LoopTrack = function(actor, left, right) @@ -26,10 +25,6 @@ LoopTrack = function(actor, left, right) actor.CallFunc(function() LoopTrack(actor, left, right) end) end -PlayMusic = function() - Media.PlayMusic("map1", PlayMusic) -end - LoadTransport = function(transport, passenger) transport.LoadPassenger(Actor.Create(passenger, false, { Owner = transport.Owner, Facing = transport.Facing })) end \ No newline at end of file diff --git a/mods/cnc/rules/world.yaml b/mods/cnc/rules/world.yaml index f27ea40b00..5a4c6f174a 100644 --- a/mods/cnc/rules/world.yaml +++ b/mods/cnc/rules/world.yaml @@ -3,6 +3,7 @@ Inherits: ^Palettes ScreenMap: ActorMap: + MusicPlaylist: TerrainGeometryOverlay: ShroudRenderer: ShroudVariants: typea, typeb, typec, typed diff --git a/mods/d2k/maps/shellmap/map.yaml b/mods/d2k/maps/shellmap/map.yaml index 66506681b2..adda1a729f 100644 --- a/mods/d2k/maps/shellmap/map.yaml +++ b/mods/d2k/maps/shellmap/map.yaml @@ -125,6 +125,8 @@ Rules: Maximum: 1 LuaScript: Scripts: shellmap.lua + MusicPlaylist: + StartingMusic: score rockettower: Power: Amount: 100 diff --git a/mods/d2k/maps/shellmap/shellmap.lua b/mods/d2k/maps/shellmap/shellmap.lua index 6361538ea5..e69de29bb2 100644 --- a/mods/d2k/maps/shellmap/shellmap.lua +++ b/mods/d2k/maps/shellmap/shellmap.lua @@ -1,3 +0,0 @@ -WorldLoaded = function() - Media.PlayMusic("score") -end \ No newline at end of file diff --git a/mods/d2k/rules/world.yaml b/mods/d2k/rules/world.yaml index 3c1c215b2a..b90ee115b6 100644 --- a/mods/d2k/rules/world.yaml +++ b/mods/d2k/rules/world.yaml @@ -3,6 +3,7 @@ AlwaysVisible: ScreenMap: ActorMap: + MusicPlaylist: TerrainGeometryOverlay: ShroudRenderer: ShroudVariants: typea, typeb, typec, typed diff --git a/mods/ra/maps/desert-shellmap/desert-shellmap.lua b/mods/ra/maps/desert-shellmap/desert-shellmap.lua index 32eb763cd7..34efded0f9 100644 --- a/mods/ra/maps/desert-shellmap/desert-shellmap.lua +++ b/mods/ra/maps/desert-shellmap/desert-shellmap.lua @@ -162,6 +162,4 @@ WorldLoaded = function() SendSovietUnits(Entry5.Location, UnitTypes, 50) SendSovietUnits(Entry6.Location, UnitTypes, 50) SendSovietUnits(Entry7.Location, BeachUnitTypes, 15) - - Media.PlayMusic() end diff --git a/mods/ra/rules/world.yaml b/mods/ra/rules/world.yaml index 4f6155d92e..2a1d469c82 100644 --- a/mods/ra/rules/world.yaml +++ b/mods/ra/rules/world.yaml @@ -3,6 +3,7 @@ AlwaysVisible: ActorMap: ScreenMap: + MusicPlaylist: TerrainGeometryOverlay: LoadWidgetAtGameStart: ShroudRenderer: diff --git a/mods/ts/maps/blank-shellmap/map.yaml b/mods/ts/maps/blank-shellmap/map.yaml index 50511b72dc..a7bd4c73b0 100644 --- a/mods/ts/maps/blank-shellmap/map.yaml +++ b/mods/ts/maps/blank-shellmap/map.yaml @@ -40,8 +40,9 @@ Rules: -StartGameNotification: -SpawnMPUnits: -MPStartLocations: - LuaScript: - Scripts: shellmap.lua + MusicPlaylist: + StartingMusic: intro + LoopStartingMusic: True Sequences: diff --git a/mods/ts/maps/blank-shellmap/shellmap.lua b/mods/ts/maps/blank-shellmap/shellmap.lua deleted file mode 100644 index 916c3ddf81..0000000000 --- a/mods/ts/maps/blank-shellmap/shellmap.lua +++ /dev/null @@ -1,7 +0,0 @@ -PlayMusic = function() - Media.PlayMusic("intro", PlayMusic) -end - -WorldLoaded = function() - PlayMusic() -end diff --git a/mods/ts/rules/world.yaml b/mods/ts/rules/world.yaml index 0eb5eeaeb9..c5a588430a 100644 --- a/mods/ts/rules/world.yaml +++ b/mods/ts/rules/world.yaml @@ -3,6 +3,7 @@ AlwaysVisible: ScreenMap: ActorMap: + MusicPlaylist: LoadWidgetAtGameStart: ShroudRenderer: Index: 255, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 20, 40, 56, 65, 97, 130, 148, 194, 24, 33, 66, 132, 28, 41, 67, 134, 1, 2, 4, 8, 3, 6, 12, 9, 7, 14, 13, 11, 5, 10, 15, 255 From 32c29e7dd67b9c0f5a0cbe82d57bd18e2ca3923b Mon Sep 17 00:00:00 2001 From: Zimmermann Gyula Date: Sun, 12 Jul 2015 13:44:56 +0200 Subject: [PATCH 3/3] Removes the MapMusic checkbox. --- OpenRA.Game/Settings.cs | 1 - OpenRA.Game/Traits/World/MusicPlaylist.cs | 3 +-- OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs | 2 +- OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs | 2 -- mods/cnc/chrome/settings.yaml | 9 +-------- mods/ra/chrome/settings.yaml | 9 +-------- 6 files changed, 4 insertions(+), 22 deletions(-) diff --git a/OpenRA.Game/Settings.cs b/OpenRA.Game/Settings.cs index f6237d6c09..6da0883537 100644 --- a/OpenRA.Game/Settings.cs +++ b/OpenRA.Game/Settings.cs @@ -108,7 +108,6 @@ namespace OpenRA public bool Shuffle = false; public bool Repeat = false; - public bool MapMusic = true; public string Engine = "AL"; public string Device = null; diff --git a/OpenRA.Game/Traits/World/MusicPlaylist.cs b/OpenRA.Game/Traits/World/MusicPlaylist.cs index 49201338f0..143bae11a0 100644 --- a/OpenRA.Game/Traits/World/MusicPlaylist.cs +++ b/OpenRA.Game/Traits/World/MusicPlaylist.cs @@ -44,8 +44,7 @@ namespace OpenRA.Traits random = playlist.Shuffle(Game.CosmeticRandom).ToArray(); - if (Game.Settings.Sound.MapMusic - && !string.IsNullOrEmpty(info.StartingMusic) + if (!string.IsNullOrEmpty(info.StartingMusic) && world.Map.Rules.Music.ContainsKey(info.StartingMusic) && world.Map.Rules.Music[info.StartingMusic].Exists) { diff --git a/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs index 182a2ea815..31df50c6d8 100644 --- a/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs +++ b/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs @@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Scripting [Desc("Play track defined in music.yaml or keep it empty for a random song.")] public void PlayMusic(string track = null, LuaFunction func = null) { - if (!Game.Settings.Sound.MapMusic || !playlist.IsMusicAvailable) + if (!playlist.IsMusicAvailable) return; var musicInfo = !string.IsNullOrEmpty(track) ? world.Map.Rules.Music[track] diff --git a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs index 6a7412acc1..bdb2e1fbb4 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs @@ -263,7 +263,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic { var ss = Game.Settings.Sound; - BindCheckboxPref(panel, "SHELLMAP_MUSIC", ss, "MapMusic"); BindCheckboxPref(panel, "CASH_TICKS", ss, "CashTicks"); BindSliderPref(panel, "SOUND_VOLUME", ss, "SoundVolume"); @@ -295,7 +294,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic var dss = new SoundSettings(); return () => { - ss.MapMusic = dss.MapMusic; ss.SoundVolume = dss.SoundVolume; ss.MusicVolume = dss.MusicVolume; ss.VideoVolume = dss.VideoVolume; diff --git a/mods/cnc/chrome/settings.yaml b/mods/cnc/chrome/settings.yaml index 5da00aea63..0d841758a1 100644 --- a/mods/cnc/chrome/settings.yaml +++ b/mods/cnc/chrome/settings.yaml @@ -238,13 +238,6 @@ Container@SETTINGS_PANEL: Font: Bold Text: Audio Align: Center - Checkbox@SHELLMAP_MUSIC: - X: 15 - Y: 40 - Width: 200 - Height: 20 - Font: Regular - Text: Shellmap / Mission Music Label@SOUND_LABEL: X: PARENT_RIGHT - WIDTH - 270 Y: 37 @@ -260,7 +253,7 @@ Container@SETTINGS_PANEL: Ticks: 5 Checkbox@CASH_TICKS: X: 15 - Y: 70 + Y: 40 Width: 200 Height: 20 Font: Regular diff --git a/mods/ra/chrome/settings.yaml b/mods/ra/chrome/settings.yaml index 3b994fd5cc..e844bc2796 100644 --- a/mods/ra/chrome/settings.yaml +++ b/mods/ra/chrome/settings.yaml @@ -246,13 +246,6 @@ Background@SETTINGS_PANEL: Width: PARENT_RIGHT - 10 Height: PARENT_BOTTOM Children: - Checkbox@SHELLMAP_MUSIC: - X: 15 - Y: 40 - Width: 200 - Height: 20 - Font: Regular - Text: Shellmap / Mission Music Label@SOUND_LABEL: X: PARENT_RIGHT - WIDTH - 270 Y: 37 @@ -268,7 +261,7 @@ Background@SETTINGS_PANEL: Ticks: 5 Checkbox@CASH_TICKS: X: 15 - Y: 70 + Y: 40 Width: 200 Height: 20 Font: Regular