Shellmap music
This commit is contained in:
@@ -18,13 +18,23 @@ using OpenRA.Mods.RA.Move;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
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
|
class CncShellmapScript: IWorldLoaded, ITick
|
||||||
{
|
{
|
||||||
|
CncShellmapScriptInfo Info;
|
||||||
Dictionary<string, Actor> Actors;
|
Dictionary<string, Actor> Actors;
|
||||||
static int2 ViewportOrigin;
|
static int2 ViewportOrigin;
|
||||||
|
|
||||||
|
public CncShellmapScript(CncShellmapScriptInfo info)
|
||||||
|
{
|
||||||
|
Info = info;
|
||||||
|
}
|
||||||
|
|
||||||
public void WorldLoaded(World w)
|
public void WorldLoaded(World w)
|
||||||
{
|
{
|
||||||
var b = w.Map.Bounds;
|
var b = w.Map.Bounds;
|
||||||
@@ -32,7 +42,20 @@ namespace OpenRA.Mods.RA
|
|||||||
Game.MoveViewport(ViewportOrigin);
|
Game.MoveViewport(ViewportOrigin);
|
||||||
|
|
||||||
Actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
|
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;
|
int ticks = 0;
|
||||||
|
|||||||
@@ -253,6 +253,14 @@ namespace OpenRA.Mods.Cnc.Widgets
|
|||||||
|
|
||||||
chatPanel = lobby.GetWidget<CncScrollPanelWidget>("CHAT_DISPLAY");
|
chatPanel = lobby.GetWidget<CncScrollPanelWidget>("CHAT_DISPLAY");
|
||||||
chatTemplate = chatPanel.GetWidget("CHAT_TEMPLATE");
|
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)
|
public void AddChatLine(Color c, string from, string text)
|
||||||
|
|||||||
@@ -361,6 +361,13 @@ Container@SERVER_LOBBY:
|
|||||||
Width:140
|
Width:140
|
||||||
Height:35
|
Height:35
|
||||||
Text:Leave Game
|
Text:Leave Game
|
||||||
|
CncMenuButton@MUSIC_BUTTON:
|
||||||
|
Id:MUSIC_BUTTON
|
||||||
|
X:300
|
||||||
|
Y:499
|
||||||
|
Width:140
|
||||||
|
Height:35
|
||||||
|
Text:Music
|
||||||
CncMenuButton@CHANGEMAP_BUTTON:
|
CncMenuButton@CHANGEMAP_BUTTON:
|
||||||
Id:CHANGEMAP_BUTTON
|
Id:CHANGEMAP_BUTTON
|
||||||
X:450
|
X:450
|
||||||
|
|||||||
Reference in New Issue
Block a user