Tastudio - add an option to create a saveram anchored movie from a selected frame, just like the savestate anchored movie feature, it uses the current movie to create a verification log
This commit is contained in:
parent
26da2a0733
commit
a219e7150e
|
@ -190,6 +190,66 @@ namespace BizHawk.Client.Common.MovieConversionExtensions
|
|||
return tas;
|
||||
}
|
||||
|
||||
public static TasMovie ConvertToSaveRamAnchoredMovie(this TasMovie old, byte[] saveRam)
|
||||
{
|
||||
string newFilename = old.Filename + "." + TasMovie.Extension;
|
||||
|
||||
if (File.Exists(newFilename))
|
||||
{
|
||||
int fileNum = 1;
|
||||
bool fileConflict = true;
|
||||
while (fileConflict)
|
||||
{
|
||||
if (File.Exists(newFilename))
|
||||
{
|
||||
newFilename = old.Filename + " (" + fileNum + ")" + "." + TasMovie.Extension;
|
||||
fileNum++;
|
||||
}
|
||||
else
|
||||
{
|
||||
fileConflict = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TasMovie tas = new TasMovie(newFilename, true);
|
||||
tas.SaveRam = saveRam;
|
||||
tas.TasStateManager.Clear();
|
||||
tas.ClearLagLog();
|
||||
|
||||
List<string> entries = old.GetLogEntries();
|
||||
|
||||
tas.CopyVerificationLog(old.VerificationLog);
|
||||
tas.CopyVerificationLog(entries);
|
||||
|
||||
tas.HeaderEntries.Clear();
|
||||
foreach (var kvp in old.HeaderEntries)
|
||||
{
|
||||
tas.HeaderEntries[kvp.Key] = kvp.Value;
|
||||
}
|
||||
|
||||
tas.StartsFromSaveRam = true;
|
||||
tas.StartsFromSavestate = false;
|
||||
tas.SyncSettingsJson = old.SyncSettingsJson;
|
||||
|
||||
tas.Comments.Clear();
|
||||
foreach (string comment in old.Comments)
|
||||
{
|
||||
tas.Comments.Add(comment);
|
||||
}
|
||||
|
||||
tas.Subtitles.Clear();
|
||||
foreach (Subtitle sub in old.Subtitles)
|
||||
{
|
||||
tas.Subtitles.Add(sub);
|
||||
}
|
||||
|
||||
tas.TasStateManager.Settings = old.TasStateManager.Settings;
|
||||
|
||||
tas.Save();
|
||||
return tas;
|
||||
}
|
||||
|
||||
// TODO: This doesn't really belong here, but not sure where to put it
|
||||
public static void PopulateWithDefaultHeaderValues(this IMovie movie, string author = null)
|
||||
{
|
||||
|
|
|
@ -176,6 +176,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
this.BookMarkControl = new BizHawk.Client.EmuHawk.BookmarksBranchesBox();
|
||||
this.BranchesMarkersSplit = new System.Windows.Forms.SplitContainer();
|
||||
this.MainVertialSplit = new System.Windows.Forms.SplitContainer();
|
||||
this.StartANewProjectFromSaveRamMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.TASMenu.SuspendLayout();
|
||||
this.TasStatusStrip.SuspendLayout();
|
||||
this.MarkerContextMenu.SuspendLayout();
|
||||
|
@ -1190,9 +1191,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
this.TruncateContextMenuItem,
|
||||
this.BranchContextMenuItem,
|
||||
this.StartFromNowSeparator,
|
||||
this.StartNewProjectFromNowMenuItem});
|
||||
this.StartNewProjectFromNowMenuItem,
|
||||
this.StartANewProjectFromSaveRamMenuItem});
|
||||
this.RightClickMenu.Name = "RightClickMenu";
|
||||
this.RightClickMenu.Size = new System.Drawing.Size(273, 436);
|
||||
this.RightClickMenu.Size = new System.Drawing.Size(273, 480);
|
||||
this.RightClickMenu.Opened += new System.EventHandler(this.RightClickMenu_Opened);
|
||||
//
|
||||
// SetMarkersContextMenuItem
|
||||
|
@ -1430,6 +1432,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
this.MainVertialSplit.TabIndex = 10;
|
||||
this.MainVertialSplit.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.MainVertialSplit_SplitterMoved);
|
||||
//
|
||||
// StartANewProjectFromSaveRamMenuItem
|
||||
//
|
||||
this.StartANewProjectFromSaveRamMenuItem.Name = "StartANewProjectFromSaveRamMenuItem";
|
||||
this.StartANewProjectFromSaveRamMenuItem.Size = new System.Drawing.Size(272, 22);
|
||||
this.StartANewProjectFromSaveRamMenuItem.Text = "Start a new project from SaveRam";
|
||||
this.StartANewProjectFromSaveRamMenuItem.Click += new System.EventHandler(this.StartANewProjectFromSaveRamMenuItem_Click);
|
||||
//
|
||||
// TAStudio
|
||||
//
|
||||
this.AllowDrop = true;
|
||||
|
@ -1618,5 +1627,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
private System.Windows.Forms.ToolStripMenuItem wheelScrollSpeedToolStripMenuItem;
|
||||
private System.Windows.Forms.SplitContainer BranchesMarkersSplit;
|
||||
private System.Windows.Forms.SplitContainer MainVertialSplit;
|
||||
private System.Windows.Forms.ToolStripMenuItem StartANewProjectFromSaveRamMenuItem;
|
||||
}
|
||||
}
|
|
@ -10,9 +10,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
[RequiredService]
|
||||
public IEmulator Emulator { get; private set; }
|
||||
|
||||
[RequiredService]
|
||||
public IStatable StatableEmulator { get; private set; }
|
||||
|
||||
[OptionalService]
|
||||
public ISaveRam SaveRamEmulator { get; private set; }
|
||||
|
||||
private bool _hackyDontUpdate;
|
||||
private bool _initializing; // If true, will bypass restart logic, this is necessary since loading projects causes a movie to load which causes a rom to reload causing dialogs to restart
|
||||
|
||||
|
|
|
@ -983,15 +983,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
TruncateContextMenuItem.Enabled =
|
||||
TasView.AnyRowsSelected;
|
||||
|
||||
StartFromNowSeparator.Visible =
|
||||
StartNewProjectFromNowMenuItem.Visible =
|
||||
TasView.SelectedRows.Count() == 1;
|
||||
|
||||
|
||||
StartNewProjectFromNowMenuItem.Visible = TasView.SelectedRows.Count() == 1;
|
||||
StartANewProjectFromSaveRamMenuItem.Visible = TasView.SelectedRows.Count() == 1 && SaveRamEmulator != null;
|
||||
StartFromNowSeparator.Visible =StartNewProjectFromNowMenuItem.Visible || StartANewProjectFromSaveRamMenuItem.Visible;
|
||||
RemoveMarkersContextMenuItem.Enabled = CurrentTasMovie.Markers.Any(m => TasView.SelectedRows.Contains(m.Frame)); // Disable the option to remove markers if no markers are selected (FCEUX does this).
|
||||
|
||||
CancelSeekContextMenuItem.Enabled = GlobalWin.MainForm.PauseOnFrame.HasValue;
|
||||
|
||||
BranchContextMenuItem.Visible = TasView.CurrentCell.RowIndex == Global.Emulator.Frame;
|
||||
BranchContextMenuItem.Visible = TasView.CurrentCell.RowIndex == Emulator.Frame;
|
||||
}
|
||||
|
||||
private void CancelSeekContextMenuItem_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -881,5 +881,26 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
Settings.BranchMarkerSplitDistance = BranchesMarkersSplit.SplitterDistance;
|
||||
}
|
||||
|
||||
private void StartANewProjectFromSaveRamMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (TasView.SelectedRows.Count() == 1 &&
|
||||
!CurrentTasMovie.StartsFromSavestate &&
|
||||
!CurrentTasMovie.StartsFromSaveRam &&
|
||||
SaveRamEmulator != null)
|
||||
{
|
||||
if (AskSaveChanges())
|
||||
{
|
||||
int index = TasView.SelectedRows.First();
|
||||
GoToFrame(index);
|
||||
|
||||
TasMovie newProject = CurrentTasMovie.ConvertToSaveRamAnchoredMovie(
|
||||
(byte[])SaveRamEmulator.CloneSaveRam());
|
||||
|
||||
GlobalWin.MainForm.PauseEmulator();
|
||||
LoadFile(new FileInfo(newProject.Filename));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue