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)
@@ -10,13 +6,17 @@ using System.Linq;
* as published by the Free Software Foundation. For more information,
* see LICENSE.
*/
#endregion
#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,16 +49,15 @@ 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;
var title = kv.Value;
if (!FileSystem.Exists(video))
continue;
continue;
if (Selected == null)
player.Load(Selected = video);
var template = itemTemplate.Clone() as LabelWidget;
template.Id = "VIDEO_{0}".F(video);