BizHawk/BizHawk.Client.Common/movie/MovieService.cs

84 lines
1.7 KiB
C#
Raw Normal View History

2014-06-29 03:03:27 +00:00
using System.Collections.Generic;
2014-06-11 02:33:57 +00:00
using System.IO;
using System.Linq;
using BizHawk.Client.Common.MovieConversionExtensions;
2014-06-12 11:53:25 +00:00
2014-06-11 02:33:57 +00:00
namespace BizHawk.Client.Common
{
2014-06-11 21:14:13 +00:00
public static class MovieService
2014-06-11 02:33:57 +00:00
{
2014-06-12 11:53:25 +00:00
public static IMovie Get(string path)
2014-06-11 02:33:57 +00:00
{
2014-06-12 11:53:25 +00:00
// TODO: change IMovies to take HawkFiles only and not path
2014-06-29 03:03:27 +00:00
if (Path.GetExtension(path).EndsWith("tasproj"))
2014-06-14 20:17:07 +00:00
{
return new TasMovie(path);
}
if (Path.GetExtension(path).EndsWith("bkm"))
2014-06-29 03:03:27 +00:00
{
2014-07-16 23:22:30 +00:00
var bkm = new BkmMovie(path);
bkm.Load(false);
2015-06-08 22:49:30 +00:00
// Hackery to fix how things used to work
if (bkm.SystemID == "GBC")
{
bkm.SystemID = "GB";
}
2014-07-16 23:22:30 +00:00
return bkm.ToBk2();
}
2014-06-29 03:03:27 +00:00
// Default to bk2
return new Bk2Movie(path);
2014-06-11 02:33:57 +00:00
}
2014-06-12 11:53:25 +00:00
/// <summary>
/// Gets the file extension for the default movie implementation used in the client
/// </summary>
public static string DefaultExtension
{
get
{
return "bk2";
}
2014-06-12 11:53:25 +00:00
}
/// <summary>
/// Returns a list of extensions for all IMovie implementations
/// </summary>
public static IEnumerable<string> MovieExtensions
{
get
{
yield return "bkm";
yield return "bk2";
yield return "tasproj";
}
}
2014-06-12 21:45:47 +00:00
2014-06-14 14:09:55 +00:00
public static bool IsValidMovieExtension(string ext)
{
if (MovieExtensions.Contains(ext.ToLower().Replace(".", "")))
{
return true;
}
return false;
}
2014-06-12 21:45:47 +00:00
/// <summary>
/// Creates a default instance of the default implementation,
/// no path is specified so this is in a minimal state that would not be able to be saved
/// </summary>
public static IMovie DefaultInstance
{
get
{
return new Bk2Movie();
2014-06-12 21:45:47 +00:00
}
}
2014-06-11 02:33:57 +00:00
}
}