diff --git a/OpenRA.Game/Widgets/VqaPlayerWidget.cs b/OpenRA.Game/Widgets/VqaPlayerWidget.cs index f971b4016c..6257d37cb2 100644 --- a/OpenRA.Game/Widgets/VqaPlayerWidget.cs +++ b/OpenRA.Game/Widgets/VqaPlayerWidget.cs @@ -31,6 +31,14 @@ namespace OpenRA.Widgets public bool Paused { get { return paused; } } + + readonly World world; + [ObjectCreator.UseCtor] + public VqaPlayerWidget( [ObjectCreator.Param] World world ) + { + this.world = world; + } + public bool DrawOverlay = true; public void Load(string filename) { @@ -148,7 +156,7 @@ namespace OpenRA.Widgets Sound.StopVideo(); video.Reset(); videoSprite.sheet.Texture.SetData(video.FrameData); - OnComplete(); + world.AddFrameEndTask(_ => OnComplete()); } } } diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 1aebffba2c..f51f6e33ff 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -119,9 +119,9 @@ namespace OpenRA } // Hacky workaround for orderManager visibility - public void OpenWindow(string widget) + public Widget OpenWindow(string widget) { - Widget.OpenWindow(widget, new Dictionary{{"world", this}, { "orderManager", orderManager }}); + return Widget.OpenWindow(widget, new Dictionary{{"world", this}, { "orderManager", orderManager }}); } public Actor CreateActor( string name, TypeDictionary initDict ) @@ -163,16 +163,18 @@ namespace OpenRA public bool DisableTick = false; public void Tick() { - if (DisableTick) - return; - - actors.Do( x => x.Tick() ); - Queries.WithTraitMultiple().DoTimed( x => + // Todo: Expose this as an order so it can be synced + if (!DisableTick) { - x.Trait.Tick( x.Actor ); - }, "[{2}] Trait: {0} ({1:0.000} ms)", Game.Settings.Debug.LongTickThreshold ); - - effects.DoTimed( e => e.Tick( this ), "[{2}] Effect: {0} ({1:0.000} ms)", Game.Settings.Debug.LongTickThreshold ); + actors.Do( x => x.Tick() ); + Queries.WithTraitMultiple().DoTimed( x => + { + x.Trait.Tick( x.Actor ); + }, "[{2}] Trait: {0} ({1:0.000} ms)", Game.Settings.Debug.LongTickThreshold ); + + effects.DoTimed( e => e.Tick( this ), "[{2}] Effect: {0} ({1:0.000} ms)", Game.Settings.Debug.LongTickThreshold ); + } + while (frameEndActions.Count != 0) frameEndActions.Dequeue()(this); Game.viewport.Tick(); diff --git a/OpenRA.Mods.RA/Scripting/Media.cs b/OpenRA.Mods.RA/Scripting/Media.cs index c947afc222..d6c37f9981 100644 --- a/OpenRA.Mods.RA/Scripting/Media.cs +++ b/OpenRA.Mods.RA/Scripting/Media.cs @@ -23,15 +23,14 @@ namespace OpenRA.Scripting { public static void PlayFMVFullscreen(World w, string movie, Action onComplete) { - var playerRoot = Widget.OpenWindow("FMVPLAYER"); + var playerRoot = w.OpenWindow("FMVPLAYER"); var player = playerRoot.GetWidget("PLAYER"); w.DisableTick = true; - - Console.WriteLine("PlayFMV {0}",movie); player.Load(movie); // Mute world sounds var oldModifier = Sound.SoundVolumeModifier; + // Todo: this also modifies vqa audio //Sound.SoundVolumeModifier = 0f; // Stop music while fmv plays