fix it so it works when have no movies

This commit is contained in:
Chris Forbes
2010-08-12 20:34:47 +12:00
committed by Paul Chote
parent a0d7435550
commit 726449b6fb

View File

@@ -1,7 +1,3 @@
using System.Collections.Generic;
using OpenRA.FileFormats;
using System.Drawing;
using System.Linq;
#region Copyright & License Information
/*
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
@@ -12,11 +8,15 @@ using System.Linq;
*/
#endregion
using System.Drawing;
using OpenRA.FileFormats;
namespace OpenRA.Widgets.Delegates
{
public class VideoPlayerDelegate : IWidgetDelegate
{
string Selected;
public VideoPlayerDelegate()
{
var bg = Widget.RootWidget.GetWidget("VIDEOPLAYER_MENU");
@@ -49,10 +49,6 @@ namespace OpenRA.Widgets.Delegates
var itemTemplate = vl.GetWidget<LabelWidget>("VIDEO_TEMPLATE");
int offset = itemTemplate.Bounds.Y;
Selected = Rules.Movies.Keys.FirstOrDefault();
if (Selected != null)
player.Load(Selected);
foreach (var kv in Rules.Movies)
{
var video = kv.Key;
@@ -60,6 +56,9 @@ namespace OpenRA.Widgets.Delegates
if (!FileSystem.Exists(video))
continue;
if (Selected == null)
player.Load(Selected = video);
var template = itemTemplate.Clone() as LabelWidget;
template.Id = "VIDEO_{0}".F(video);
template.GetText = () => " " + title;