Populate the list from yaml; Define ra-allies movies; Additional polish.
This commit is contained in:
@@ -24,6 +24,7 @@ namespace OpenRA
|
||||
public static Dictionary<string, WeaponInfo> Weapons;
|
||||
public static Dictionary<string, VoiceInfo> Voices;
|
||||
public static Dictionary<string, MusicInfo> Music;
|
||||
public static Dictionary<string, string> Movies;
|
||||
public static Dictionary<string, TileSet> TileSets;
|
||||
|
||||
public static void LoadRules(Manifest m, Map map)
|
||||
@@ -32,6 +33,7 @@ namespace OpenRA
|
||||
Weapons = LoadYamlRules(m.Weapons, map.Weapons, (k, _) => new WeaponInfo(k.Key.ToLowerInvariant(), k.Value));
|
||||
Voices = LoadYamlRules(m.Voices, map.Voices, (k, _) => new VoiceInfo(k.Value));
|
||||
Music = LoadYamlRules(m.Music, map.Music, (k, _) => new MusicInfo(k.Value));
|
||||
Movies = LoadYamlRules(m.Movies, new Dictionary<string,MiniYaml>(), (k, v) => k.Value.Value);
|
||||
|
||||
TileSets = new Dictionary<string, TileSet>();
|
||||
foreach (var file in m.TileSets)
|
||||
|
||||
@@ -16,17 +16,13 @@ namespace OpenRA.Widgets.Delegates
|
||||
{
|
||||
public class VideoPlayerDelegate : IWidgetDelegate
|
||||
{
|
||||
string Selected = null;
|
||||
string Selected;
|
||||
public VideoPlayerDelegate()
|
||||
{
|
||||
var bg = Widget.RootWidget.GetWidget("VIDEOPLAYER_MENU");
|
||||
var player = bg.GetWidget<VqaPlayerWidget>("VIDEOPLAYER");
|
||||
bg.GetWidget("BUTTON_PLAY").OnMouseUp = mi =>
|
||||
{
|
||||
if (Selected == null)
|
||||
return true;
|
||||
|
||||
player.Load(Selected);
|
||||
player.Play();
|
||||
return true;
|
||||
};
|
||||
@@ -53,14 +49,11 @@ namespace OpenRA.Widgets.Delegates
|
||||
var itemTemplate = vl.GetWidget<LabelWidget>("VIDEO_TEMPLATE");
|
||||
int offset = itemTemplate.Bounds.Y;
|
||||
|
||||
// Todo: pull into per-mod yaml / Manifest
|
||||
var tempVideos = new Dictionary<string,string>();
|
||||
tempVideos.Add("obel.vqa", "Obelisk ZZZZAAAAAP");
|
||||
tempVideos.Add("ally1.vqa", "Allies briefing #1");
|
||||
tempVideos.Add("ally10.vqa", "Allies briefing #10");
|
||||
Selected = Rules.Movies.Keys.FirstOrDefault();
|
||||
if (Selected != null)
|
||||
player.Load(Selected);
|
||||
|
||||
Selected = tempVideos.Keys.FirstOrDefault();
|
||||
foreach (var kv in tempVideos)
|
||||
foreach (var kv in Rules.Movies)
|
||||
{
|
||||
var video = kv.Key;
|
||||
var title = kv.Value;
|
||||
@@ -73,10 +66,8 @@ namespace OpenRA.Widgets.Delegates
|
||||
template.GetBackground = () => ((video == Selected) ? "dialog2" : null);
|
||||
template.OnMouseDown = mi =>
|
||||
{
|
||||
if (Selected == video)
|
||||
return true;
|
||||
player.Stop();
|
||||
Selected = video;
|
||||
player.Load(video);
|
||||
return true;
|
||||
};
|
||||
template.Parent = vl;
|
||||
|
||||
@@ -28,6 +28,12 @@ namespace OpenRA.Widgets
|
||||
if (filename == cachedVideo)
|
||||
return;
|
||||
|
||||
if (playing)
|
||||
{
|
||||
playing = false;
|
||||
Sound.StopVideoSoundtrack();
|
||||
}
|
||||
|
||||
cachedVideo = filename;
|
||||
video = new VqaReader(FileSystem.Open(filename));
|
||||
invLength = video.Framerate*1f/video.Frames;
|
||||
@@ -35,7 +41,8 @@ namespace OpenRA.Widgets
|
||||
var size = Math.Max(video.Width, video.Height);
|
||||
var textureSize = OpenRA.Graphics.Util.NextPowerOf2(size);
|
||||
videoSprite = new Sprite(new Sheet(new Size(textureSize,textureSize)), new Rectangle( 0, 0, video.Width, video.Height ), TextureChannel.Alpha);
|
||||
|
||||
videoSprite.sheet.Texture.SetData(video.FrameData);
|
||||
|
||||
var scale = Math.Min(RenderBounds.Width / video.Width, RenderBounds.Height / video.Height);
|
||||
videoOrigin = new float2(RenderBounds.X + (RenderBounds.Width - scale*video.Width)/2, RenderBounds.Y + (RenderBounds.Height - scale*video.Height)/2);
|
||||
videoSize = new float2(video.Width * scale, video.Height * scale);
|
||||
@@ -45,38 +52,47 @@ namespace OpenRA.Widgets
|
||||
Stopwatch sw = new Stopwatch();
|
||||
public override void DrawInner(World world)
|
||||
{
|
||||
if (!playing)
|
||||
if (video == null)
|
||||
return;
|
||||
|
||||
var nextFrame = (int)float2.Lerp(0, video.Frames, (float)(sw.ElapsedTime()*invLength));
|
||||
if (nextFrame > video.Frames)
|
||||
{
|
||||
Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
while (nextFrame > video.CurrentFrame)
|
||||
if (playing)
|
||||
{
|
||||
video.AdvanceFrame();
|
||||
if (nextFrame == video.CurrentFrame)
|
||||
videoSprite.sheet.Texture.SetData(video.FrameData);
|
||||
var nextFrame = (int)float2.Lerp(0, video.Frames, (float)(sw.ElapsedTime()*invLength));
|
||||
if (nextFrame > video.Frames)
|
||||
{
|
||||
Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
while (nextFrame > video.CurrentFrame)
|
||||
{
|
||||
video.AdvanceFrame();
|
||||
if (nextFrame == video.CurrentFrame)
|
||||
videoSprite.sheet.Texture.SetData(video.FrameData);
|
||||
}
|
||||
}
|
||||
Game.Renderer.RgbaSpriteRenderer.DrawSprite(videoSprite, videoOrigin, "chrome", videoSize);
|
||||
}
|
||||
|
||||
public void Play()
|
||||
{
|
||||
if (playing || video == null)
|
||||
return;
|
||||
|
||||
playing = true;
|
||||
video.Reset();
|
||||
videoSprite.sheet.Texture.SetData(video.FrameData);
|
||||
sw.Reset();
|
||||
Sound.PlayVideoSoundtrack(video.AudioData);
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (!playing || video == null)
|
||||
return;
|
||||
|
||||
playing = false;
|
||||
Sound.StopVideoSoundtrack();
|
||||
video.Reset();
|
||||
videoSprite.sheet.Texture.SetData(video.FrameData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user