Rename some VideoPlayerWidget methods for clarity

This commit is contained in:
penev92
2023-01-26 21:08:47 +02:00
committed by abcdefg30
parent 6321432d97
commit c3fcbf77ed
4 changed files with 15 additions and 7 deletions

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Scripting
try try
{ {
player.Load(videoFileName); player.LoadAndPlay(videoFileName);
} }
catch (FileNotFoundException) catch (FileNotFoundException)
{ {
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Scripting
try try
{ {
player.Load(videoFileName); player.LoadAndPlay(videoFileName);
} }
catch (FileNotFoundException) catch (FileNotFoundException)
{ {

View File

@@ -550,7 +550,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (video != null) if (video != null)
{ {
player = panel.Get<VideoPlayerWidget>("PLAYER"); player = panel.Get<VideoPlayerWidget>("PLAYER");
player.Load(prefix + filename); player.LoadAndPlay(prefix + filename);
player.DrawOverlay = false; player.DrawOverlay = false;
isVideoLoaded = true; isVideoLoaded = true;

View File

@@ -370,7 +370,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
StopVideo(player); StopVideo(player);
playingVideo = pv; playingVideo = pv;
player.Load(video); player.LoadAndPlay(video);
if (player.Video == null) if (player.Video == null)
{ {

View File

@@ -41,19 +41,27 @@ namespace OpenRA.Mods.Common.Widgets
Action onComplete; Action onComplete;
public void Load(string filename) /// <summary>
/// Tries to load a video from the specified file and play it. Does nothing if the file name matches the already loaded video.
/// </summary>
/// <param name="filename">Name of the file, including the extension.</param>
public void LoadAndPlay(string filename)
{ {
if (filename == cachedVideoFileName) if (filename == cachedVideoFileName)
return; return;
var stream = Game.ModData.DefaultFileSystem.Open(filename); var stream = Game.ModData.DefaultFileSystem.Open(filename);
var video = VideoLoader.GetVideo(stream, true, Game.ModData.VideoLoaders); var video = VideoLoader.GetVideo(stream, true, Game.ModData.VideoLoaders);
Open(video); Play(video);
cachedVideoFileName = filename; cachedVideoFileName = filename;
} }
public void Open(IVideo video) /// <summary>
/// Plays the given <see cref="IVideo"/>.
/// </summary>
/// <param name="video">An <see cref="IVideo"/> instance.</param>
public void Play(IVideo video)
{ {
this.video = video; this.video = video;