Some more Movies 2.0 work

This commit is contained in:
adelikat 2014-06-11 21:14:13 +00:00
parent 525871d6e4
commit 54c9c2c0a0
7 changed files with 30 additions and 15 deletions

View File

@ -6,7 +6,7 @@ using System.Text;
namespace BizHawk.Client.Common namespace BizHawk.Client.Common
{ {
public static class MovieLoader public static class MovieService
{ {
public static IMovie Load(string path) public static IMovie Load(string path)
{ {

View File

@ -40,6 +40,11 @@ namespace BizHawk.Client.Common
public string PreferredExtension { get { return "bk2"; } } public string PreferredExtension { get { return "bk2"; } }
public bool IsCountingRerecords { get; set; } public bool IsCountingRerecords { get; set; }
public bool PreLoadText(HawkFile hawkFile)
{
throw new NotImplementedException();
}
public SubtitleList Subtitles public SubtitleList Subtitles
{ {
get { throw new NotImplementedException(); } get { throw new NotImplementedException(); }

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using BizHawk.Common;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
namespace BizHawk.Client.Common namespace BizHawk.Client.Common
@ -64,6 +65,8 @@ namespace BizHawk.Client.Common
string GameName { get; set; } string GameName { get; set; }
string SystemID { get; set; } string SystemID { get; set; }
string Hash { get; set; } string Hash { get; set; }
bool PreLoadText(HawkFile hawkFile); // Movies 2.0 TODO: find a better way to not need this
#endregion #endregion
#region File Handling API #region File Handling API

View File

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using BizHawk.Common;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
namespace BizHawk.Client.Common namespace BizHawk.Client.Common
@ -69,6 +71,11 @@ namespace BizHawk.Client.Common
#region IMovie Implementation #region IMovie Implementation
public bool PreLoadText(HawkFile hawkFile)
{
throw new NotImplementedException();
}
public TasMovie(string filename, bool startsFromSavestate = false) public TasMovie(string filename, bool startsFromSavestate = false)
: this(startsFromSavestate) : this(startsFromSavestate)
{ {

View File

@ -2192,7 +2192,7 @@ namespace BizHawk.Client.EmuHawk
} }
else if (MovieSession.IsValidMovieExtension(ext)) else if (MovieSession.IsValidMovieExtension(ext))
{ {
StartNewMovie(MovieLoader.Load(filePaths[0]), false); StartNewMovie(MovieService.Get(filePaths[0]), false);
} }
else if (ext.ToUpper() == ".STATE") else if (ext.ToUpper() == ".STATE")
{ {
@ -2232,7 +2232,7 @@ namespace BizHawk.Client.EmuHawk
string errorMsg; string errorMsg;
string warningMsg; string warningMsg;
var movie = MovieImport.ImportFile(filePaths[0], out errorMsg, out warningMsg); var movie = MovieImport.ImportFile(filePaths[0], out errorMsg, out warningMsg);
if (!String.IsNullOrEmpty(errorMsg)) if (!string.IsNullOrEmpty(errorMsg))
{ {
MessageBox.Show(errorMsg, "Conversion error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(errorMsg, "Conversion error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }

View File

@ -265,7 +265,7 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
var movie = MovieLoader.Load(cmdMovie); var movie = MovieService.Get(cmdMovie);
Global.MovieSession.ReadOnly = true; Global.MovieSession.ReadOnly = true;
// if user is dumping and didnt supply dump length, make it as long as the loaded movie // if user is dumping and didnt supply dump length, make it as long as the loaded movie
@ -286,7 +286,7 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
StartNewMovie(MovieLoader.Load(Global.Config.RecentMovies.MostRecent), false); StartNewMovie(MovieService.Get(Global.Config.RecentMovies.MostRecent), false);
} }
} }
@ -1439,7 +1439,7 @@ namespace BizHawk.Client.EmuHawk
private void LoadMoviesFromRecent(string path) private void LoadMoviesFromRecent(string path)
{ {
var movie = MovieLoader.Load(path); var movie = MovieService.Get(path);
// Movies 2.0 TODO // Movies 2.0 TODO
if (!(movie as Movie).Loaded) if (!(movie as Movie).Loaded)

View File

@ -125,8 +125,7 @@ namespace BizHawk.Client.EmuHawk
private IMovie PreLoadMovieFile(HawkFile hf, bool force) private IMovie PreLoadMovieFile(HawkFile hf, bool force)
{ {
// Movies 2.0 TODO: don't cast and find a way to load this stuff with only IMovie! var movie = MovieService.Get(hf.CanonicalFullPath);
var movie = (MovieLoader.Load(hf.CanonicalFullPath) as Movie);
try try
{ {
@ -188,10 +187,12 @@ namespace BizHawk.Client.EmuHawk
var tas = new List<int>(); var tas = new List<int>();
for (var i = 0; i < indices.Count; i++) for (var i = 0; i < indices.Count; i++)
{ {
// Movies 2.0 TODO: MovieLoader could have a list of valid extensiosn to match foreach (var ext in MovieService.MovieExtensions)
if (Path.GetExtension(_movieList[indices[i]].Filename).ToUpper() == "." + Movie.Extension)
{ {
tas.Add(i); if (Path.GetExtension(_movieList[indices[i]].Filename).ToUpper() == "." + ext)
{
tas.Add(i);
}
} }
} }
@ -296,9 +297,8 @@ namespace BizHawk.Client.EmuHawk
{ {
var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop); var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
// Movies 2.0 TODO: MovieLoader could have a list of valid extensiosn to match
filePaths filePaths
.Where(path => Path.GetExtension(path) == "." + Movie.Extension) .Where(path => MovieService.MovieExtensions.Contains(Path.GetExtension(path).Replace(".", "")))
.ToList() .ToList()
.ForEach(path => AddMovieToList(path, force: true)); .ForEach(path => AddMovieToList(path, force: true));
@ -607,8 +607,8 @@ namespace BizHawk.Client.EmuHawk
{ {
var ofd = new OpenFileDialog var ofd = new OpenFileDialog
{ {
// Movies 2.0 TODO // Movies 2.0 TODO - add tasproj in addition to default, hardcoded is fine in this case
Filter = "Movie Files (*." + Movie.Extension + ")|*." + Movie.Extension + "|Savestates|*.state|All Files|*.*", Filter = "Movie Files (*." + Movie.Extension + ")|*." + MovieService.DefaultExtension + "|All Files|*.*",
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null) InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null)
}; };