Movie Import cleanup - use IMovie more, don't redundantly save in Pjm and Psx importers, cleanups
This commit is contained in:
parent
ab5d30c797
commit
0043c1de1e
|
@ -84,7 +84,7 @@ namespace BizHawk.Client.Common
|
||||||
public IList<string> Warnings { get; } = new List<string>();
|
public IList<string> Warnings { get; } = new List<string>();
|
||||||
public IList<string> Errors { 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)]
|
[AttributeUsage(AttributeTargets.Class)]
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace BizHawk.Client.Common
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bk2Movie movie = null;
|
IMovie movie = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,31 +10,25 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
protected override void RunImport()
|
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);
|
ParseBinaryInputLog(br, Result.Movie, info);
|
||||||
var info = ParseHeader(movie, "PJM ", br);
|
}
|
||||||
|
else
|
||||||
fs.Seek(info.ControllerDataOffset, SeekOrigin.Begin);
|
{
|
||||||
|
ParseTextInputLog(br, Result.Movie, info);
|
||||||
if (info.BinaryFormat)
|
|
||||||
{
|
|
||||||
ParseBinaryInputLog(br, movie, info);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ParseTextInputLog(br, 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();
|
var info = new MiscHeaderInfo();
|
||||||
|
|
||||||
|
@ -175,7 +169,7 @@ namespace BizHawk.Client.Common
|
||||||
return info;
|
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 settings = new Octoshock.SyncSettings();
|
||||||
var controllers = new SimpleController();
|
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();
|
Octoshock.SyncSettings settings = new Octoshock.SyncSettings();
|
||||||
SimpleController controllers = new SimpleController();
|
SimpleController controllers = new SimpleController();
|
||||||
|
|
|
@ -14,28 +14,23 @@ namespace BizHawk.Client.Common.Movie.Import
|
||||||
{
|
{
|
||||||
protected override void RunImport()
|
protected override void RunImport()
|
||||||
{
|
{
|
||||||
Bk2Movie movie = Result.Movie;
|
var movie = Result.Movie;
|
||||||
|
|
||||||
movie.HeaderEntries[HeaderKeys.PLATFORM] = "PSX";
|
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);
|
ParseBinaryInputLog(br, movie, info);
|
||||||
var info = ParseHeader(movie, "PXM ", br);
|
}
|
||||||
|
else
|
||||||
fs.Seek(info.ControllerDataOffset, SeekOrigin.Begin);
|
{
|
||||||
|
ParseTextInputLog(br, movie, info);
|
||||||
if (info.BinaryFormat)
|
|
||||||
{
|
|
||||||
ParseBinaryInputLog(br, movie, info);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ParseTextInputLog(br, movie, info);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
movie.Save();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue