Half of having choices of music and a player of it (not finished)
This commit is contained in:
@@ -61,7 +61,7 @@ namespace OpenRA.FileFormats
|
|||||||
public readonly string[]
|
public readonly string[]
|
||||||
Folders, Packages, Rules,
|
Folders, Packages, Rules,
|
||||||
Sequences, Chrome, Assemblies, ChromeLayout,
|
Sequences, Chrome, Assemblies, ChromeLayout,
|
||||||
Weapons, Voices, Terrain;
|
Weapons, Voices, Music, Terrain;
|
||||||
|
|
||||||
public readonly string ShellmapUid;
|
public readonly string ShellmapUid;
|
||||||
|
|
||||||
@@ -80,6 +80,7 @@ namespace OpenRA.FileFormats
|
|||||||
ChromeLayout = YamlList(yaml, "ChromeLayout");
|
ChromeLayout = YamlList(yaml, "ChromeLayout");
|
||||||
Weapons = YamlList(yaml, "Weapons");
|
Weapons = YamlList(yaml, "Weapons");
|
||||||
Voices = YamlList(yaml, "Voices");
|
Voices = YamlList(yaml, "Voices");
|
||||||
|
Music = YamlList(yaml, "Music");
|
||||||
Terrain = YamlList(yaml, "Terrain");
|
Terrain = YamlList(yaml, "Terrain");
|
||||||
|
|
||||||
ShellmapUid = yaml["ShellmapUid"].Value;
|
ShellmapUid = yaml["ShellmapUid"].Value;
|
||||||
|
|||||||
50
OpenRA.Game/GameRules/MusicInfo.cs
Normal file
50
OpenRA.Game/GameRules/MusicInfo.cs
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
|
|
||||||
|
namespace OpenRA.GameRules
|
||||||
|
{
|
||||||
|
public class MusicInfo
|
||||||
|
{
|
||||||
|
public readonly Lazy<Dictionary<string, MusicPool>> Pools;
|
||||||
|
public readonly string[] Music = { };
|
||||||
|
|
||||||
|
public MusicInfo( MiniYaml y )
|
||||||
|
{
|
||||||
|
FieldLoader.Load(this, y);
|
||||||
|
|
||||||
|
Pools = Lazy.New(() =>
|
||||||
|
new Dictionary<string, MusicPool>
|
||||||
|
{
|
||||||
|
{ "Music", new MusicPool(Music) },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MusicPool
|
||||||
|
{
|
||||||
|
readonly string[] clips;
|
||||||
|
readonly List<string> liveclips = new List<string>();
|
||||||
|
|
||||||
|
public MusicPool(params string[] clips)
|
||||||
|
{
|
||||||
|
this.clips = clips;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetNext()
|
||||||
|
{
|
||||||
|
if (liveclips.Count == 0)
|
||||||
|
liveclips.AddRange(clips);
|
||||||
|
|
||||||
|
if (liveclips.Count == 0)
|
||||||
|
return null; /* avoid crashing if there's no clips at all */
|
||||||
|
|
||||||
|
var i = Game.CosmeticRandom.Next(liveclips.Count);
|
||||||
|
var s = liveclips[i];
|
||||||
|
liveclips.RemoveAt(i);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,6 +33,7 @@ namespace OpenRA
|
|||||||
public static Dictionary<string, ActorInfo> Info;
|
public static Dictionary<string, ActorInfo> Info;
|
||||||
public static Dictionary<string, WeaponInfo> Weapons;
|
public static Dictionary<string, WeaponInfo> Weapons;
|
||||||
public static Dictionary<string, VoiceInfo> Voices;
|
public static Dictionary<string, VoiceInfo> Voices;
|
||||||
|
public static Dictionary<string, MusicInfo> Music;
|
||||||
public static Dictionary<TerrainType, TerrainCost> TerrainTypes;
|
public static Dictionary<TerrainType, TerrainCost> TerrainTypes;
|
||||||
|
|
||||||
public static void LoadRules(Manifest m)
|
public static void LoadRules(Manifest m)
|
||||||
@@ -44,6 +45,7 @@ namespace OpenRA
|
|||||||
Info = LoadYamlRules(m.Rules, (k, y) => new ActorInfo(k.Key.ToLowerInvariant(), k.Value, y));
|
Info = LoadYamlRules(m.Rules, (k, y) => new ActorInfo(k.Key.ToLowerInvariant(), k.Value, y));
|
||||||
Weapons = LoadYamlRules(m.Weapons, (k, _) => new WeaponInfo(k.Key.ToLowerInvariant(), k.Value));
|
Weapons = LoadYamlRules(m.Weapons, (k, _) => new WeaponInfo(k.Key.ToLowerInvariant(), k.Value));
|
||||||
Voices = LoadYamlRules(m.Voices, (k, _) => new VoiceInfo(k.Value));
|
Voices = LoadYamlRules(m.Voices, (k, _) => new VoiceInfo(k.Value));
|
||||||
|
Music = LoadYamlRules(m.Music, (k, _) => new MusicInfo(k.Value));
|
||||||
TerrainTypes = LoadYamlRules(m.Terrain, (k, _) => new TerrainCost(k.Value))
|
TerrainTypes = LoadYamlRules(m.Terrain, (k, _) => new TerrainCost(k.Value))
|
||||||
.ToDictionary(kv => (TerrainType)Enum.Parse(typeof(TerrainType), kv.Key, true), kv => kv.Value);
|
.ToDictionary(kv => (TerrainType)Enum.Parse(typeof(TerrainType), kv.Key, true), kv => kv.Value);
|
||||||
|
|
||||||
|
|||||||
@@ -312,6 +312,7 @@
|
|||||||
<Compile Include="Traits\World\BridgeLayer.cs" />
|
<Compile Include="Traits\World\BridgeLayer.cs" />
|
||||||
<Compile Include="Widgets\Delegates\LobbyDelegate.cs" />
|
<Compile Include="Widgets\Delegates\LobbyDelegate.cs" />
|
||||||
<Compile Include="Widgets\ColorBlockWidget.cs" />
|
<Compile Include="Widgets\ColorBlockWidget.cs" />
|
||||||
|
<Compile Include="GameRules\MusicInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||||
|
|||||||
@@ -42,6 +42,18 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
bg.Visible = false;
|
bg.Visible = false;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
bg.GetWidget("BUTTON_NEXT").OnMouseUp = mi => {
|
||||||
|
Sound.MusicPaused = false;
|
||||||
|
bg.GetWidget("BUTTON_PLAY").Visible = false;
|
||||||
|
bg.GetWidget("BUTTON_PAUSE").Visible = true;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
bg.GetWidget("BUTTON_PREV").OnMouseUp = mi => {
|
||||||
|
Sound.MusicPaused = false;
|
||||||
|
bg.GetWidget("BUTTON_PLAY").Visible = false;
|
||||||
|
bg.GetWidget("BUTTON_PAUSE").Visible = true;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -629,34 +629,48 @@ Container:
|
|||||||
Background@MUSIC_BG:
|
Background@MUSIC_BG:
|
||||||
Id:MUSIC_BG
|
Id:MUSIC_BG
|
||||||
Delegate:MusicPlayerDelegate
|
Delegate:MusicPlayerDelegate
|
||||||
X:WINDOW_RIGHT - 100
|
X:WINDOW_RIGHT - 175
|
||||||
Y:WINDOW_BOTTOM - 65
|
Y:WINDOW_BOTTOM - 65
|
||||||
Width: 90
|
Width: 160
|
||||||
Height: 55
|
Height: 55
|
||||||
Visible: true
|
Visible: true
|
||||||
Children:
|
Children:
|
||||||
Button@BUTTON_PLAY:
|
Button@BUTTON_PLAY:
|
||||||
Id:BUTTON_PLAY
|
Id:BUTTON_PLAY
|
||||||
Visible:false
|
Visible:false
|
||||||
X:15
|
X:50
|
||||||
Y:15
|
Y:15
|
||||||
Width:25
|
Width:25
|
||||||
Height:25
|
Height:25
|
||||||
Text:|>
|
Text:|>
|
||||||
Button@BUTTON_PAUSE:
|
Button@BUTTON_PAUSE:
|
||||||
Id:BUTTON_PAUSE
|
Id:BUTTON_PAUSE
|
||||||
X:15
|
X:50
|
||||||
Y:15
|
Y:15
|
||||||
Width:25
|
Width:25
|
||||||
Height:25
|
Height:25
|
||||||
Text:||
|
Text:||
|
||||||
Button@BUTTON_STOP:
|
Button@BUTTON_STOP:
|
||||||
Id:BUTTON_STOP
|
Id:BUTTON_STOP
|
||||||
X:50
|
X:85
|
||||||
Y:15
|
Y:15
|
||||||
Width:25
|
Width:25
|
||||||
Height:25
|
Height:25
|
||||||
Text:[]
|
Text:[]
|
||||||
|
Button@BUTTON_NEXT:
|
||||||
|
Id:BUTTON_NEXT
|
||||||
|
X:120
|
||||||
|
Y:15
|
||||||
|
Width:25
|
||||||
|
Height:25
|
||||||
|
Text:>>
|
||||||
|
Button@BUTTON_PREV:
|
||||||
|
Id:BUTTON_PREV
|
||||||
|
X:15
|
||||||
|
Y:15
|
||||||
|
Width:25
|
||||||
|
Height:25
|
||||||
|
Text:<<
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
mods/ra/music.yaml
Normal file
2
mods/ra/music.yaml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
AllMusic:
|
||||||
|
Music: hell226m.aud
|
||||||
Reference in New Issue
Block a user