Movie Import cleanup - use IMovie more, don't redundantly save in Pjm and Psx importers, cleanups

This commit is contained in:
adelikat 2019-11-14 15:59:01 -06:00
parent ab5d30c797
commit 0043c1de1e
4 changed files with 30 additions and 41 deletions

View File

@ -84,7 +84,7 @@ namespace BizHawk.Client.Common
public IList<string> Warnings { get; } = new List<string>();
public IList<string> Errors { get; } = new List<string>();
public Bk2Movie Movie { get; set; }
public IMovie Movie { get; set; }
}
[AttributeUsage(AttributeTargets.Class)]

View File

@ -69,7 +69,7 @@ namespace BizHawk.Client.Common
return null;
}
Bk2Movie movie = null;
IMovie movie = null;
try
{

View File

@ -10,31 +10,25 @@ namespace BizHawk.Client.Common
{
protected override void RunImport()
{
Bk2Movie movie = Result.Movie;
Result.Movie.HeaderEntries[HeaderKeys.PLATFORM] = "PSX";
movie.HeaderEntries[HeaderKeys.PLATFORM] = "PSX";
using var fs = SourceFile.OpenRead();
using var br = new BinaryReader(fs);
var info = ParseHeader(Result.Movie, "PJM ", br);
using (var fs = SourceFile.OpenRead())
fs.Seek(info.ControllerDataOffset, SeekOrigin.Begin);
if (info.BinaryFormat)
{
using var br = new BinaryReader(fs);
var info = ParseHeader(movie, "PJM ", br);
fs.Seek(info.ControllerDataOffset, SeekOrigin.Begin);
if (info.BinaryFormat)
{
ParseBinaryInputLog(br, movie, info);
}
else
{
ParseTextInputLog(br, movie, info);
}
ParseBinaryInputLog(br, Result.Movie, info);
}
else
{
ParseTextInputLog(br, Result.Movie, info);
}
movie.Save();
}
protected MiscHeaderInfo ParseHeader(Bk2Movie movie, string expectedMagic, BinaryReader br)
protected MiscHeaderInfo ParseHeader(IMovie movie, string expectedMagic, BinaryReader br)
{
var info = new MiscHeaderInfo();
@ -175,7 +169,7 @@ namespace BizHawk.Client.Common
return info;
}
protected void ParseBinaryInputLog(BinaryReader br, Bk2Movie movie, MiscHeaderInfo info)
protected void ParseBinaryInputLog(BinaryReader br, IMovie movie, MiscHeaderInfo info)
{
var settings = new Octoshock.SyncSettings();
var controllers = new SimpleController();
@ -286,7 +280,7 @@ namespace BizHawk.Client.Common
}
}
protected void ParseTextInputLog(BinaryReader br, Bk2Movie movie, MiscHeaderInfo info)
protected void ParseTextInputLog(BinaryReader br, IMovie movie, MiscHeaderInfo info)
{
Octoshock.SyncSettings settings = new Octoshock.SyncSettings();
SimpleController controllers = new SimpleController();

View File

@ -14,28 +14,23 @@ namespace BizHawk.Client.Common.Movie.Import
{
protected override void RunImport()
{
Bk2Movie movie = Result.Movie;
var movie = Result.Movie;
movie.HeaderEntries[HeaderKeys.PLATFORM] = "PSX";
using (var fs = SourceFile.OpenRead())
using var fs = SourceFile.OpenRead();
using var br = new BinaryReader(fs);
var info = ParseHeader(movie, "PXM ", br);
fs.Seek(info.ControllerDataOffset, SeekOrigin.Begin);
if (info.BinaryFormat)
{
using var br = new BinaryReader(fs);
var info = ParseHeader(movie, "PXM ", br);
fs.Seek(info.ControllerDataOffset, SeekOrigin.Begin);
if (info.BinaryFormat)
{
ParseBinaryInputLog(br, movie, info);
}
else
{
ParseTextInputLog(br, movie, info);
}
ParseBinaryInputLog(br, movie, info);
}
else
{
ParseTextInputLog(br, movie, info);
}
movie.Save();
}
}
}