Start pulling out useful scripting components - stalled by widget changes having broken the fmv player.
This commit is contained in:
@@ -14,10 +14,12 @@ using OpenRA.Traits;
|
||||
using OpenRA.Widgets;
|
||||
using OpenRA.Traits.Activities;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using System;
|
||||
using OpenRA.Mods.RA;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
class Gdi01ScriptInfo : TraitInfo<Gdi01Script> { }
|
||||
|
||||
@@ -27,29 +29,6 @@ namespace OpenRA.Mods.RA
|
||||
Dictionary<string, Player> Players;
|
||||
Map Map;
|
||||
|
||||
public static void PlayFullscreenFMVThen(World w, string movie, Action then)
|
||||
{
|
||||
var playerRoot = Widget.OpenWindow("FMVPLAYER");
|
||||
var player = playerRoot.GetWidget<VqaPlayerWidget>("PLAYER");
|
||||
w.DisableTick = true;
|
||||
player.Load(movie);
|
||||
|
||||
// Stop music while fmv plays
|
||||
var music = Sound.MusicPlaying;
|
||||
if (music)
|
||||
Sound.PauseMusic();
|
||||
|
||||
player.PlayThen(() =>
|
||||
{
|
||||
if (music)
|
||||
Sound.PlayMusic();
|
||||
|
||||
Widget.CloseWindow();
|
||||
w.DisableTick = false;
|
||||
then();
|
||||
});
|
||||
}
|
||||
|
||||
public void WorldLoaded(World w)
|
||||
{
|
||||
Map = w.Map;
|
||||
@@ -57,7 +36,8 @@ namespace OpenRA.Mods.RA
|
||||
Actors = w.WorldActor.Trait<SpawnMapActors>().Actors;
|
||||
Game.MoveViewport((.5f * (w.Map.TopLeft + w.Map.BottomRight).ToFloat2()).ToInt2());
|
||||
|
||||
PlayFullscreenFMVThen(w, "gdi1.vqa", () => PlayFullscreenFMVThen(w, "landing.vqa", () =>
|
||||
Scripting.Media.PlayFMVFullscreen(w, "gdi1.vqa",
|
||||
() => Scripting.Media.PlayFMVFullscreen(w, "landing.vqa", () =>
|
||||
{
|
||||
Sound.PlayMusic(Rules.Music["aoi"].Filename);
|
||||
started = true;
|
||||
@@ -72,7 +52,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
w.WorldActor.CancelActivity();
|
||||
w.WorldActor.QueueActivity(new Wait(125));
|
||||
w.WorldActor.QueueActivity(new CallFunc(() => PlayFullscreenFMVThen(w, "consyard.vqa", () =>
|
||||
w.WorldActor.QueueActivity(new CallFunc(() => Scripting.Media.PlayFMVFullscreen(w, "consyard.vqa", () =>
|
||||
{
|
||||
Sound.StopMusic();
|
||||
Game.Disconnect();
|
||||
@@ -87,7 +67,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
w.WorldActor.CancelActivity();
|
||||
w.WorldActor.QueueActivity(new Wait(125));
|
||||
w.WorldActor.QueueActivity(new CallFunc(() => PlayFullscreenFMVThen(w, "gameover.vqa", () =>
|
||||
w.WorldActor.QueueActivity(new CallFunc(() => Scripting.Media.PlayFMVFullscreen(w, "gameover.vqa", () =>
|
||||
{
|
||||
Sound.StopMusic();
|
||||
Game.Disconnect();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -262,6 +262,7 @@
|
||||
<Compile Include="Activities\IdleAnimation.cs" />
|
||||
<Compile Include="IdleAnimation.cs" />
|
||||
<Compile Include="World\SmudgeLayer.cs" />
|
||||
<Compile Include="Scripting\Media.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
@@ -288,4 +289,7 @@
|
||||
copy "$(TargetPath)" "$(SolutionDir)mods/ra/"
|
||||
cd "$(SolutionDir)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Scripting\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
54
OpenRA.Mods.RA/Scripting/Media.cs
Normal file
54
OpenRA.Mods.RA/Scripting/Media.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2010 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 LICENSE.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Widgets;
|
||||
using OpenRA.Traits.Activities;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using System;
|
||||
|
||||
namespace OpenRA.Scripting
|
||||
{
|
||||
public class Media
|
||||
{
|
||||
public static void PlayFMVFullscreen(World w, string movie, Action onComplete)
|
||||
{
|
||||
var playerRoot = Widget.OpenWindow("FMVPLAYER");
|
||||
var player = playerRoot.GetWidget<VqaPlayerWidget>("PLAYER");
|
||||
w.DisableTick = true;
|
||||
|
||||
Console.WriteLine("PlayFMV {0}",movie);
|
||||
player.Load(movie);
|
||||
|
||||
// Mute world sounds
|
||||
var oldModifier = Sound.SoundVolumeModifier;
|
||||
//Sound.SoundVolumeModifier = 0f;
|
||||
|
||||
// Stop music while fmv plays
|
||||
var music = Sound.MusicPlaying;
|
||||
if (music)
|
||||
Sound.PauseMusic();
|
||||
|
||||
player.PlayThen(() =>
|
||||
{
|
||||
if (music)
|
||||
Sound.PlayMusic();
|
||||
|
||||
Widget.CloseWindow();
|
||||
Sound.SoundVolumeModifier = oldModifier;
|
||||
w.DisableTick = false;
|
||||
onComplete();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user