Add a generic video player widget.
This commit is contained in:
committed by
abcdefg30
parent
514652bb6a
commit
7bc17b59f5
@@ -17,6 +17,7 @@ using System.Linq;
|
||||
using OpenRA.FileSystem;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Video;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
@@ -44,7 +45,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
IReadOnlyPackage currentPackage;
|
||||
Sprite[] currentSprites;
|
||||
IModel currentVoxel;
|
||||
VqaPlayerWidget player = null;
|
||||
VideoPlayerWidget player = null;
|
||||
bool isVideoLoaded = false;
|
||||
bool isLoadError = false;
|
||||
int currentFrame;
|
||||
@@ -84,7 +85,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
spriteWidget.IsVisible = () => !isVideoLoaded && !isLoadError && currentSprites != null;
|
||||
}
|
||||
|
||||
var playerWidget = panel.GetOrNull<VqaPlayerWidget>("PLAYER");
|
||||
var playerWidget = panel.GetOrNull<VideoPlayerWidget>("PLAYER");
|
||||
if (playerWidget != null)
|
||||
playerWidget.IsVisible = () => isVideoLoaded && !isLoadError;
|
||||
|
||||
@@ -379,9 +380,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
prefix += "|";
|
||||
}
|
||||
|
||||
if (Path.GetExtension(filename.ToLowerInvariant()) == ".vqa")
|
||||
var video = VideoLoader.GetVideo(Game.ModData.DefaultFileSystem.Open(filename), Game.ModData.VideoLoaders);
|
||||
if (video != null)
|
||||
{
|
||||
player = panel.Get<VqaPlayerWidget>("PLAYER");
|
||||
player = panel.Get<VideoPlayerWidget>("PLAYER");
|
||||
player.Load(prefix + filename);
|
||||
player.DrawOverlay = false;
|
||||
isVideoLoaded = true;
|
||||
|
||||
@@ -17,6 +17,7 @@ using System.Threading;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Network;
|
||||
using OpenRA.Video;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
@@ -36,7 +37,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
readonly ButtonWidget stopBriefingVideoButton;
|
||||
readonly ButtonWidget startInfoVideoButton;
|
||||
readonly ButtonWidget stopInfoVideoButton;
|
||||
readonly VqaPlayerWidget videoPlayer;
|
||||
readonly VideoPlayerWidget videoPlayer;
|
||||
readonly BackgroundWidget fullscreenVideoPlayer;
|
||||
|
||||
readonly ScrollPanelWidget missionList;
|
||||
@@ -71,7 +72,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
previewWidget.Preview = () => selectedMap;
|
||||
previewWidget.IsVisible = () => playingVideo == PlayingVideo.None;
|
||||
|
||||
videoPlayer = widget.Get<VqaPlayerWidget>("MISSION_VIDEO");
|
||||
videoPlayer = widget.Get<VideoPlayerWidget>("MISSION_VIDEO");
|
||||
widget.Get("MISSION_BIN").IsVisible = () => playingVideo != PlayingVideo.None;
|
||||
fullscreenVideoPlayer = Ui.LoadWidget<BackgroundWidget>("FULLSCREEN_PLAYER", Ui.Root, new WidgetArgs { { "world", world } });
|
||||
|
||||
@@ -329,7 +330,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
Game.Sound.MusicVolume = cachedMusicVolume;
|
||||
}
|
||||
|
||||
void PlayVideo(VqaPlayerWidget player, string video, PlayingVideo pv, Action onComplete = null)
|
||||
void PlayVideo(VideoPlayerWidget player, string video, PlayingVideo pv, Action onComplete = null)
|
||||
{
|
||||
if (!modData.DefaultFileSystem.Exists(video))
|
||||
{
|
||||
@@ -358,7 +359,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
}
|
||||
|
||||
void StopVideo(VqaPlayerWidget player)
|
||||
void StopVideo(VideoPlayerWidget player)
|
||||
{
|
||||
if (playingVideo == PlayingVideo.None)
|
||||
return;
|
||||
@@ -385,7 +386,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var missionData = selectedMap.Rules.Actors["world"].TraitInfoOrDefault<MissionDataInfo>();
|
||||
if (missionData != null && missionData.StartVideo != null && modData.DefaultFileSystem.Exists(missionData.StartVideo))
|
||||
{
|
||||
var fsPlayer = fullscreenVideoPlayer.Get<VqaPlayerWidget>("PLAYER");
|
||||
var fsPlayer = fullscreenVideoPlayer.Get<VideoPlayerWidget>("PLAYER");
|
||||
fullscreenVideoPlayer.Visible = true;
|
||||
PlayVideo(fsPlayer, missionData.StartVideo, PlayingVideo.GameStart, () =>
|
||||
{
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
|
||||
using System;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.FileFormats;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Video;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
public class VqaPlayerWidget : Widget
|
||||
public class VideoPlayerWidget : Widget
|
||||
{
|
||||
public Hotkey CancelKey = new Hotkey(Keycode.ESCAPE, Modifiers.None);
|
||||
public float AspectRatio = 1.2f;
|
||||
@@ -25,11 +25,11 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
public bool Skippable = true;
|
||||
|
||||
public bool Paused { get { return paused; } }
|
||||
public VqaReader Video { get { return video; } }
|
||||
public IVideo Video { get { return video; } }
|
||||
|
||||
Sprite videoSprite, overlaySprite;
|
||||
Sheet overlaySheet;
|
||||
VqaReader video = null;
|
||||
IVideo video = null;
|
||||
string cachedVideo;
|
||||
float invLength;
|
||||
float2 videoOrigin, videoSize;
|
||||
@@ -44,13 +44,14 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
if (filename == cachedVideo)
|
||||
return;
|
||||
var video = new VqaReader(Game.ModData.DefaultFileSystem.Open(filename));
|
||||
|
||||
var video = VideoLoader.GetVideo(Game.ModData.DefaultFileSystem.Open(filename), Game.ModData.VideoLoaders);
|
||||
Open(video);
|
||||
|
||||
cachedVideo = filename;
|
||||
Open(video);
|
||||
}
|
||||
|
||||
public void Open(VqaReader video)
|
||||
public void Open(IVideo video)
|
||||
{
|
||||
this.video = video;
|
||||
|
||||
Reference in New Issue
Block a user