Skip to content

Commit

Permalink
Fix crash on fmv completion
Browse files Browse the repository at this point in the history
  • Loading branch information
pchote committed Oct 14, 2010
1 parent 185ba80 commit 2a02df9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
10 changes: 9 additions & 1 deletion OpenRA.Game/Widgets/VqaPlayerWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ public class VqaPlayerWidget : Widget

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)
{
Expand Down Expand Up @@ -148,7 +156,7 @@ public void Stop()
Sound.StopVideo();
video.Reset();
videoSprite.sheet.Texture.SetData(video.FrameData);
OnComplete();
world.AddFrameEndTask(_ => OnComplete());
}
}
}
24 changes: 13 additions & 11 deletions OpenRA.Game/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ internal World(Manifest manifest, Map map, OrderManager orderManager)
}

// Hacky workaround for orderManager visibility
public void OpenWindow(string widget)
public Widget OpenWindow(string widget)
{
Widget.OpenWindow(widget, new Dictionary<string,object>{{"world", this}, { "orderManager", orderManager }});
return Widget.OpenWindow(widget, new Dictionary<string,object>{{"world", this}, { "orderManager", orderManager }});
}

public Actor CreateActor( string name, TypeDictionary initDict )
Expand Down Expand Up @@ -163,16 +163,18 @@ public void Remove(Actor a)
public bool DisableTick = false;
public void Tick()
{
if (DisableTick)
return;

actors.Do( x => x.Tick() );
Queries.WithTraitMultiple<ITick>().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<ITick>().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();
Expand Down
5 changes: 2 additions & 3 deletions OpenRA.Mods.RA/Scripting/Media.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ public class Media
{
public static void PlayFMVFullscreen(World w, string movie, Action onComplete)
{
var playerRoot = Widget.OpenWindow("FMVPLAYER");
var playerRoot = w.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;
// Todo: this also modifies vqa audio
//Sound.SoundVolumeModifier = 0f;

// Stop music while fmv plays
Expand Down

0 comments on commit 2a02df9

Please sign in to comment.