@@ -32,21 +32,9 @@ namespace OpenRA.GameRules
|
|||||||
|
|
||||||
var ext = nd.ContainsKey("Extension") ? nd["Extension"].Value : "aud";
|
var ext = nd.ContainsKey("Extension") ? nd["Extension"].Value : "aud";
|
||||||
Filename = (nd.ContainsKey("Filename") ? nd["Filename"].Value : key) + "." + ext;
|
Filename = (nd.ContainsKey("Filename") ? nd["Filename"].Value : key) + "." + ext;
|
||||||
|
|
||||||
if (!GlobalFileSystem.Exists(Filename))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Exists = true;
|
|
||||||
using (var s = GlobalFileSystem.Open(Filename))
|
|
||||||
{
|
|
||||||
if (Filename.ToLowerInvariant().EndsWith("wav"))
|
|
||||||
Length = (int)WavLoader.WaveLength(s);
|
|
||||||
else
|
|
||||||
Length = (int)AudLoader.SoundLength(s);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Reload()
|
public void Load()
|
||||||
{
|
{
|
||||||
if (!GlobalFileSystem.Exists(Filename))
|
if (!GlobalFileSystem.Exists(Filename))
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
using (new PerfTimer("Music"))
|
using (new PerfTimer("Music"))
|
||||||
music = LoadYamlRules(musicCache, m.Music,
|
music = LoadYamlRules(musicCache, m.Music,
|
||||||
NoMapRules,
|
map != null ? map.MusicDefinitions : NoMapRules,
|
||||||
(k, _) => new MusicInfo(k.Key, k.Value));
|
(k, _) => new MusicInfo(k.Key, k.Value));
|
||||||
|
|
||||||
using (new PerfTimer("TileSets"))
|
using (new PerfTimer("TileSets"))
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ using System.Linq;
|
|||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using OpenRA.FileSystem;
|
using OpenRA.FileSystem;
|
||||||
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
using OpenRA.Support;
|
using OpenRA.Support;
|
||||||
@@ -228,6 +229,7 @@ namespace OpenRA
|
|||||||
[FieldLoader.Ignore] public List<MiniYamlNode> VoxelSequenceDefinitions = new List<MiniYamlNode>();
|
[FieldLoader.Ignore] public List<MiniYamlNode> VoxelSequenceDefinitions = new List<MiniYamlNode>();
|
||||||
[FieldLoader.Ignore] public List<MiniYamlNode> WeaponDefinitions = new List<MiniYamlNode>();
|
[FieldLoader.Ignore] public List<MiniYamlNode> WeaponDefinitions = new List<MiniYamlNode>();
|
||||||
[FieldLoader.Ignore] public List<MiniYamlNode> VoiceDefinitions = new List<MiniYamlNode>();
|
[FieldLoader.Ignore] public List<MiniYamlNode> VoiceDefinitions = new List<MiniYamlNode>();
|
||||||
|
[FieldLoader.Ignore] public List<MiniYamlNode> MusicDefinitions = new List<MiniYamlNode>();
|
||||||
[FieldLoader.Ignore] public List<MiniYamlNode> NotificationDefinitions = new List<MiniYamlNode>();
|
[FieldLoader.Ignore] public List<MiniYamlNode> NotificationDefinitions = new List<MiniYamlNode>();
|
||||||
[FieldLoader.Ignore] public List<MiniYamlNode> TranslationDefinitions = new List<MiniYamlNode>();
|
[FieldLoader.Ignore] public List<MiniYamlNode> TranslationDefinitions = new List<MiniYamlNode>();
|
||||||
[FieldLoader.Ignore] public List<MiniYamlNode> PlayerDefinitions = new List<MiniYamlNode>();
|
[FieldLoader.Ignore] public List<MiniYamlNode> PlayerDefinitions = new List<MiniYamlNode>();
|
||||||
@@ -360,6 +362,7 @@ namespace OpenRA
|
|||||||
VoxelSequenceDefinitions = MiniYaml.NodesOrEmpty(yaml, "VoxelSequences");
|
VoxelSequenceDefinitions = MiniYaml.NodesOrEmpty(yaml, "VoxelSequences");
|
||||||
WeaponDefinitions = MiniYaml.NodesOrEmpty(yaml, "Weapons");
|
WeaponDefinitions = MiniYaml.NodesOrEmpty(yaml, "Weapons");
|
||||||
VoiceDefinitions = MiniYaml.NodesOrEmpty(yaml, "Voices");
|
VoiceDefinitions = MiniYaml.NodesOrEmpty(yaml, "Voices");
|
||||||
|
MusicDefinitions = MiniYaml.NodesOrEmpty(yaml, "Music");
|
||||||
NotificationDefinitions = MiniYaml.NodesOrEmpty(yaml, "Notifications");
|
NotificationDefinitions = MiniYaml.NodesOrEmpty(yaml, "Notifications");
|
||||||
TranslationDefinitions = MiniYaml.NodesOrEmpty(yaml, "Translations");
|
TranslationDefinitions = MiniYaml.NodesOrEmpty(yaml, "Translations");
|
||||||
PlayerDefinitions = MiniYaml.NodesOrEmpty(yaml, "Players");
|
PlayerDefinitions = MiniYaml.NodesOrEmpty(yaml, "Players");
|
||||||
@@ -572,6 +575,7 @@ namespace OpenRA
|
|||||||
root.Add(new MiniYamlNode("VoxelSequences", null, VoxelSequenceDefinitions));
|
root.Add(new MiniYamlNode("VoxelSequences", null, VoxelSequenceDefinitions));
|
||||||
root.Add(new MiniYamlNode("Weapons", null, WeaponDefinitions));
|
root.Add(new MiniYamlNode("Weapons", null, WeaponDefinitions));
|
||||||
root.Add(new MiniYamlNode("Voices", null, VoiceDefinitions));
|
root.Add(new MiniYamlNode("Voices", null, VoiceDefinitions));
|
||||||
|
root.Add(new MiniYamlNode("Music", null, MusicDefinitions));
|
||||||
root.Add(new MiniYamlNode("Notifications", null, NotificationDefinitions));
|
root.Add(new MiniYamlNode("Notifications", null, NotificationDefinitions));
|
||||||
root.Add(new MiniYamlNode("Translations", null, TranslationDefinitions));
|
root.Add(new MiniYamlNode("Translations", null, TranslationDefinitions));
|
||||||
|
|
||||||
|
|||||||
@@ -171,6 +171,11 @@ namespace OpenRA
|
|||||||
using (new Support.PerfTimer("Map.SequenceProvider.Preload"))
|
using (new Support.PerfTimer("Map.SequenceProvider.Preload"))
|
||||||
map.SequenceProvider.Preload();
|
map.SequenceProvider.Preload();
|
||||||
|
|
||||||
|
// Load music with map assets mounted
|
||||||
|
using (new Support.PerfTimer("Map.Music"))
|
||||||
|
foreach (var entry in map.Rules.Music)
|
||||||
|
entry.Value.Load();
|
||||||
|
|
||||||
VoxelProvider.Initialize(Manifest.VoxelSequences, map.VoxelSequenceDefinitions);
|
VoxelProvider.Initialize(Manifest.VoxelSequences, map.VoxelSequenceDefinitions);
|
||||||
VoxelLoader.Finish();
|
VoxelLoader.Finish();
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using Eluant;
|
|||||||
using OpenRA.Effects;
|
using OpenRA.Effects;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.FileSystem;
|
using OpenRA.FileSystem;
|
||||||
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Mods.Common.Effects;
|
using OpenRA.Mods.Common.Effects;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
@@ -55,14 +56,22 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
}
|
}
|
||||||
|
|
||||||
Action onComplete;
|
Action onComplete;
|
||||||
[Desc("Play track defined in music.yaml or keep it empty for a random song.")]
|
[Desc("Play track defined in music.yaml or map.yaml, or keep track empty for playing a random song.")]
|
||||||
public void PlayMusic(string track = null, LuaFunction func = null)
|
public void PlayMusic(string track = null, LuaFunction func = null)
|
||||||
{
|
{
|
||||||
if (!playlist.IsMusicAvailable)
|
if (!playlist.IsMusicAvailable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var musicInfo = !string.IsNullOrEmpty(track) ? world.Map.Rules.Music[track]
|
MusicInfo musicInfo;
|
||||||
: playlist.GetNextSong();
|
if (string.IsNullOrEmpty(track))
|
||||||
|
musicInfo = playlist.GetNextSong();
|
||||||
|
else if (world.Map.Rules.Music.ContainsKey(track))
|
||||||
|
musicInfo = world.Map.Rules.Music[track];
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.Write("lua", "Missing music track: " + track);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (func != null)
|
if (func != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,7 +44,3 @@ float_v2: Floating
|
|||||||
grndwire: Ground Wire
|
grndwire: Ground Wire
|
||||||
search: The Search
|
search: The Search
|
||||||
wastelnd: Wasteland
|
wastelnd: Wasteland
|
||||||
|
|
||||||
# Special effects
|
|
||||||
rain: Rain (ambient)
|
|
||||||
Hidden: true
|
|
||||||
@@ -20,6 +20,10 @@ Type: Minigame
|
|||||||
|
|
||||||
Videos:
|
Videos:
|
||||||
|
|
||||||
|
Music:
|
||||||
|
rain: Rain (ambient)
|
||||||
|
Hidden: true
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
Fog: True
|
Fog: True
|
||||||
Shroud: True
|
Shroud: True
|
||||||
|
|||||||
Reference in New Issue
Block a user