move methods for Log copying from ITasMovie to IMovie. This bloats the IMovie contract more, but this allows for converting from one IMovie to another without an IEmulator dependency. Refactor conversion extensions to use these methods and remove emulator and movie session dependencies
This commit is contained in:
parent
b88f20faed
commit
b22f9e6e01
|
@ -331,7 +331,7 @@ namespace BizHawk.Client.Common
|
||||||
public void ConvertToTasProj()
|
public void ConvertToTasProj()
|
||||||
{
|
{
|
||||||
Movie.Save();
|
Movie.Save();
|
||||||
Movie = Movie.ToTasMovie(this);
|
Movie = Movie.ToTasMovie();
|
||||||
Movie.Save();
|
Movie.Save();
|
||||||
Movie.SwitchToPlay();
|
Movie.SwitchToPlay();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Common;
|
||||||
using BizHawk.Emulation.Cores;
|
using BizHawk.Emulation.Cores;
|
||||||
|
|
||||||
|
@ -92,6 +93,17 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IStringLog GetLogEntries() => Log;
|
||||||
|
|
||||||
|
public void CopyLog(IEnumerable<string> log)
|
||||||
|
{
|
||||||
|
Log.Clear();
|
||||||
|
foreach (var entry in log)
|
||||||
|
{
|
||||||
|
Log.Add(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void AppendFrame(IController source)
|
public void AppendFrame(IController source)
|
||||||
{
|
{
|
||||||
var lg = LogGeneratorInstance(source);
|
var lg = LogGeneratorInstance(source);
|
||||||
|
|
|
@ -15,20 +15,11 @@ namespace BizHawk.Client.Common.MovieConversionExtensions
|
||||||
{
|
{
|
||||||
public static class MovieConversionExtensions
|
public static class MovieConversionExtensions
|
||||||
{
|
{
|
||||||
public static ITasMovie ToTasMovie(this IMovie old, IMovieSession session)
|
public static ITasMovie ToTasMovie(this IMovie old)
|
||||||
{
|
{
|
||||||
string newFilename = GetNewFileName(old.Filename);
|
string newFilename = GetNewFileName(old.Filename);
|
||||||
var tas = (ITasMovie)MovieService.Get(newFilename);
|
var tas = (ITasMovie)MovieService.Get(newFilename);
|
||||||
|
tas.CopyLog(old.GetLogEntries());
|
||||||
// TODO: this relies on the fact that the emulator core here will be the same as when it is load
|
|
||||||
// so this specifically only works in the scenario of a running bk2 converted to tasproj in tastudio
|
|
||||||
// need to untangle and not be so dependent on core loading behavior
|
|
||||||
tas.Attach(session, old.Emulator);
|
|
||||||
for (var i = 0; i < old.InputLogLength; i++)
|
|
||||||
{
|
|
||||||
var input = old.GetInputState(i);
|
|
||||||
tas.AppendFrame(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
old.Truncate(0); // Trying to minimize ram usage
|
old.Truncate(0); // Trying to minimize ram usage
|
||||||
|
|
||||||
|
@ -63,12 +54,7 @@ namespace BizHawk.Client.Common.MovieConversionExtensions
|
||||||
public static IMovie ToBk2(this IMovie old)
|
public static IMovie ToBk2(this IMovie old)
|
||||||
{
|
{
|
||||||
var bk2 = MovieService.Get(old.Filename.Replace(old.PreferredExtension, Bk2Movie.Extension));
|
var bk2 = MovieService.Get(old.Filename.Replace(old.PreferredExtension, Bk2Movie.Extension));
|
||||||
|
bk2.CopyLog(old.GetLogEntries());
|
||||||
for (var i = 0; i < old.InputLogLength; i++)
|
|
||||||
{
|
|
||||||
var input = old.GetInputState(i);
|
|
||||||
bk2.AppendFrame(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
bk2.HeaderEntries.Clear();
|
bk2.HeaderEntries.Clear();
|
||||||
foreach (var kvp in old.HeaderEntries)
|
foreach (var kvp in old.HeaderEntries)
|
||||||
|
|
|
@ -240,6 +240,9 @@ namespace BizHawk.Client.Common
|
||||||
/// The currently attached core or null if not yet attached
|
/// The currently attached core or null if not yet attached
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IEmulator Emulator { get; }
|
IEmulator Emulator { get; }
|
||||||
|
|
||||||
|
IStringLog GetLogEntries();
|
||||||
|
void CopyLog(IEnumerable<string> log);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MovieExtensions
|
public static class MovieExtensions
|
||||||
|
|
|
@ -26,7 +26,6 @@ namespace BizHawk.Client.Common
|
||||||
string DisplayValue(int frame, string buttonName);
|
string DisplayValue(int frame, string buttonName);
|
||||||
void FlagChanges();
|
void FlagChanges();
|
||||||
void ClearChanges();
|
void ClearChanges();
|
||||||
IStringLog GetLogEntries();
|
|
||||||
|
|
||||||
void GreenzoneCurrentFrame();
|
void GreenzoneCurrentFrame();
|
||||||
void ToggleBoolState(int frame, string buttonName);
|
void ToggleBoolState(int frame, string buttonName);
|
||||||
|
@ -48,7 +47,6 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
void LoadBranch(TasBranch branch);
|
void LoadBranch(TasBranch branch);
|
||||||
|
|
||||||
void CopyLog(IEnumerable<string> log);
|
|
||||||
void CopyVerificationLog(IEnumerable<string> log);
|
void CopyVerificationLog(IEnumerable<string> log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,15 +165,7 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CopyLog(IEnumerable<string> log)
|
|
||||||
{
|
|
||||||
Log.Clear();
|
|
||||||
foreach (var entry in log)
|
|
||||||
{
|
|
||||||
Log.Add(entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CopyVerificationLog(IEnumerable<string> log)
|
public void CopyVerificationLog(IEnumerable<string> log)
|
||||||
{
|
{
|
||||||
foreach (string entry in log)
|
foreach (string entry in log)
|
||||||
|
@ -182,8 +174,6 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IStringLog GetLogEntries() => Log;
|
|
||||||
|
|
||||||
// TODO: this is 99% copy pasting of bad code
|
// TODO: this is 99% copy pasting of bad code
|
||||||
public override bool ExtractInputLog(TextReader reader, out string errorMessage)
|
public override bool ExtractInputLog(TextReader reader, out string errorMessage)
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,11 +46,10 @@ namespace BizHawk.Client.Common
|
||||||
|
|
||||||
public void Attach(IEmulator emulator)
|
public void Attach(IEmulator emulator)
|
||||||
{
|
{
|
||||||
// TODO: we aren't ready for this, attach is called when converting a bk2 to tasproj and again to officially load the emulator
|
if (!_emulator.IsNull())
|
||||||
//if (!_emulator.IsNull())
|
{
|
||||||
//{
|
throw new InvalidOperationException("A core has already been attached!");
|
||||||
// throw new InvalidOperationException("A core has already been attached!");
|
}
|
||||||
//}
|
|
||||||
|
|
||||||
if (!emulator.HasSavestates())
|
if (!emulator.HasSavestates())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue