Shellmap music

This commit is contained in:
Paul Chote
2011-05-15 12:15:49 +12:00
parent cb565e5d3c
commit 0b0fac3c4b
3 changed files with 40 additions and 2 deletions

View File

@@ -18,13 +18,23 @@ using OpenRA.Mods.RA.Move;
namespace OpenRA.Mods.RA
{
class CncShellmapScriptInfo : TraitInfo<CncShellmapScript> { }
class CncShellmapScriptInfo : ITraitInfo
{
public string Music = "otp";
public object Create(ActorInitializer init) { return new CncShellmapScript(this); }
}
class CncShellmapScript: IWorldLoaded, ITick
{
CncShellmapScriptInfo Info;
Dictionary<string, Actor> 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<SpawnMapActors>().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;

View File

@@ -253,6 +253,14 @@ namespace OpenRA.Mods.Cnc.Widgets
chatPanel = lobby.GetWidget<CncScrollPanelWidget>("CHAT_DISPLAY");
chatTemplate = chatPanel.GetWidget("CHAT_TEMPLATE");
lobby.GetWidget<CncMenuButtonWidget>("MUSIC_BUTTON").OnClick = () =>
{
Widget.OpenWindow("MUSIC_PANEL", new WidgetArgs()
{
{ "onExit", () => {} },
});
};
}
public void AddChatLine(Color c, string from, string text)

View File

@@ -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