Implemented Floating Text and radar video

This commit is contained in:
DeadlySurprise
2014-12-14 14:39:41 +01:00
parent 5bcd56eb9d
commit 7b53582c5e
9 changed files with 209 additions and 40 deletions

View File

@@ -0,0 +1,38 @@
#region Copyright & License Information
/*
* Copyright 2007-2015 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 COPYING.
*/
#endregion
using System;
using System.Collections.Generic;
using OpenRA.Graphics;
namespace OpenRA.Effects
{
public class AsyncAction : IEffect
{
Action a;
IAsyncResult ar;
public AsyncAction(IAsyncResult ar, Action a)
{
this.a = a;
this.ar = ar;
}
public void Tick(World world)
{
if (ar.IsCompleted)
{
world.AddFrameEndTask(w => { w.Remove(this); a(); });
}
}
public IEnumerable<IRenderable> Render(WorldRenderer r) { yield break; }
}
}

View File

@@ -88,6 +88,7 @@
<Compile Include="GameRules\Warhead.cs" />
<Compile Include="Graphics\QuadRenderer.cs" />
<Compile Include="Download.cs" />
<Compile Include="Effects\AsyncAction.cs" />
<Compile Include="Effects\DelayedAction.cs" />
<Compile Include="Effects\FlashTarget.cs" />
<Compile Include="Effects\IEffect.cs" />

View File

@@ -21,6 +21,7 @@ namespace OpenRA.Widgets
public Hotkey CancelKey = new Hotkey(Keycode.ESCAPE, Modifiers.None);
public float AspectRatio = 1.2f;
public bool DrawOverlay = true;
public bool Skippable = true;
public bool Paused { get { return paused; } }
public VqaReader Video { get { return video; } }
@@ -48,15 +49,21 @@ namespace OpenRA.Widgets
{
if (filename == cachedVideo)
return;
var video = new VqaReader(GlobalFileSystem.Open(filename));
cachedVideo = filename;
Open(video);
}
public void Open(VqaReader video)
{
this.video = video;
stopped = true;
paused = true;
Sound.StopVideo();
onComplete = () => { };
cachedVideo = filename;
video = new VqaReader(GlobalFileSystem.Open(filename));
invLength = video.Framerate * 1f / video.Frames;
var size = Math.Max(video.Width, video.Height);
@@ -107,7 +114,8 @@ namespace OpenRA.Widgets
else
nextFrame = video.CurrentFrame + 1;
if (nextFrame > video.Frames)
// Without the 2nd check the sound playback sometimes ends before the final frame is displayed which causes the player to be stuck on the first frame
if (nextFrame > video.Frames || nextFrame < video.CurrentFrame)
{
Stop();
return;
@@ -136,7 +144,7 @@ namespace OpenRA.Widgets
public override bool HandleKeyPress(KeyInput e)
{
if (Hotkey.FromKeyInput(e) != CancelKey || e.Event != KeyInputEvent.Down)
if (Hotkey.FromKeyInput(e) != CancelKey || e.Event != KeyInputEvent.Down || !Skippable)
return false;
Stop();
@@ -188,5 +196,11 @@ namespace OpenRA.Widgets
videoSprite.Sheet.GetTexture().SetData(video.FrameData);
world.AddFrameEndTask(_ => onComplete());
}
public void CloseVideo()
{
Stop();
video = null;
}
}
}