misc movie code cleanups
This commit is contained in:
parent
ffd2aedfa5
commit
64f32983f6
|
@ -3,7 +3,6 @@ using System.IO;
|
|||
using System.Linq;
|
||||
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Common.BufferExtensions;
|
||||
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
|
@ -16,86 +15,84 @@ namespace BizHawk.Client.Common
|
|||
|
||||
// the old method of text savestate save is now gone.
|
||||
// a text savestate is just like a binary savestate, but with a different core lump
|
||||
using (var bs = new BinaryStateSaver(filename))
|
||||
using var bs = new BinaryStateSaver(filename);
|
||||
if (Global.Config.SaveStateType == Config.SaveStateTypeE.Text
|
||||
|| (Global.Config.SaveStateType == Config.SaveStateTypeE.Default && !core.BinarySaveStatesPreferred))
|
||||
{
|
||||
if (Global.Config.SaveStateType == Config.SaveStateTypeE.Text ||
|
||||
(Global.Config.SaveStateType == Config.SaveStateTypeE.Default && !core.BinarySaveStatesPreferred))
|
||||
// text savestate format
|
||||
using (new SimpleTime("Save Core"))
|
||||
{
|
||||
// text savestate format
|
||||
using (new SimpleTime("Save Core"))
|
||||
{
|
||||
bs.PutLump(BinaryStateLump.CorestateText, (tw) => core.SaveStateText(tw));
|
||||
}
|
||||
bs.PutLump(BinaryStateLump.CorestateText, tw => core.SaveStateText(tw));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// binary core lump format
|
||||
using (new SimpleTime("Save Core"))
|
||||
{
|
||||
bs.PutLump(BinaryStateLump.Corestate, bw => core.SaveStateBinary(bw));
|
||||
}
|
||||
}
|
||||
|
||||
if (Global.Config.SaveScreenshotWithStates && Global.Emulator.HasVideoProvider())
|
||||
{
|
||||
var vp = Global.Emulator.AsVideoProvider();
|
||||
var buff = vp.GetVideoBuffer();
|
||||
if (buff.Length == 1)
|
||||
{
|
||||
// is a hacky opengl texture ID. can't handle this now!
|
||||
// need to discuss options
|
||||
// 1. cores must be able to provide a pixels VideoProvider in addition to a texture ID, on command (not very hard overall but interface changing and work per core)
|
||||
// 2. SavestateManager must be setup with a mechanism for resolving texture IDs (even less work, but sloppy)
|
||||
// There are additional problems with AVWriting. They depend on VideoProvider providing pixels.
|
||||
}
|
||||
else
|
||||
{
|
||||
// binary core lump format
|
||||
using (new SimpleTime("Save Core"))
|
||||
int outWidth = vp.BufferWidth;
|
||||
int outHeight = vp.BufferHeight;
|
||||
|
||||
// if buffer is too big, scale down screenshot
|
||||
if (!Global.Config.NoLowResLargeScreenshotWithStates && buff.Length >= Global.Config.BigScreenshotSize)
|
||||
{
|
||||
bs.PutLump(BinaryStateLump.Corestate, bw => core.SaveStateBinary(bw));
|
||||
outWidth /= 2;
|
||||
outHeight /= 2;
|
||||
}
|
||||
|
||||
using (new SimpleTime("Save Framebuffer"))
|
||||
{
|
||||
bs.PutLump(BinaryStateLump.Framebuffer, s => QuickBmpFile.Save(Global.Emulator.AsVideoProvider(), s, outWidth, outHeight));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Global.Config.SaveScreenshotWithStates && Global.Emulator.HasVideoProvider())
|
||||
{
|
||||
var vp = Global.Emulator.AsVideoProvider();
|
||||
var buff = vp.GetVideoBuffer();
|
||||
if (buff.Length == 1)
|
||||
if (Global.MovieSession.Movie.IsActive)
|
||||
{
|
||||
bs.PutLump(BinaryStateLump.Input,
|
||||
delegate(TextWriter tw)
|
||||
{
|
||||
// is a hacky opengl texture ID. can't handle this now!
|
||||
// need to discuss options
|
||||
// 1. cores must be able to provide a pixels videoprovider in addition to a texture ID, on command (not very hard overall but interface changing and work per core)
|
||||
// 2. SavestateManager must be setup with a mechanism for resolving texture IDs (even less work, but sloppy)
|
||||
// There are additional problems with AVWriting. They depend on VideoProvider providing pixels.
|
||||
}
|
||||
else
|
||||
// this never should have been a core's responsibility
|
||||
tw.WriteLine("Frame {0}", Global.Emulator.Frame);
|
||||
Global.MovieSession.HandleMovieSaveState(tw);
|
||||
});
|
||||
}
|
||||
|
||||
if (Global.UserBag.Any())
|
||||
{
|
||||
bs.PutLump(BinaryStateLump.UserData,
|
||||
delegate(TextWriter tw)
|
||||
{
|
||||
int out_w = vp.BufferWidth;
|
||||
int out_h = vp.BufferHeight;
|
||||
var data = ConfigService.SaveWithType(Global.UserBag);
|
||||
tw.WriteLine(data);
|
||||
});
|
||||
}
|
||||
|
||||
// if buffer is too big, scale down screenshot
|
||||
if (!Global.Config.NoLowResLargeScreenshotWithStates && buff.Length >= Global.Config.BigScreenshotSize)
|
||||
{
|
||||
out_w /= 2;
|
||||
out_h /= 2;
|
||||
}
|
||||
|
||||
using (new SimpleTime("Save Framebuffer"))
|
||||
{
|
||||
bs.PutLump(BinaryStateLump.Framebuffer, s => QuickBmpFile.Save(Global.Emulator.AsVideoProvider(), s, out_w, out_h));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Global.MovieSession.Movie.IsActive)
|
||||
{
|
||||
bs.PutLump(BinaryStateLump.Input,
|
||||
delegate(TextWriter tw)
|
||||
{
|
||||
// this never should have been a core's responsibility
|
||||
tw.WriteLine("Frame {0}", Global.Emulator.Frame);
|
||||
Global.MovieSession.HandleMovieSaveState(tw);
|
||||
});
|
||||
}
|
||||
|
||||
if (Global.UserBag.Any())
|
||||
{
|
||||
bs.PutLump(BinaryStateLump.UserData,
|
||||
delegate(TextWriter tw)
|
||||
{
|
||||
var data = ConfigService.SaveWithType(Global.UserBag);
|
||||
tw.WriteLine(data);
|
||||
});
|
||||
}
|
||||
|
||||
if (Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie is TasMovie)
|
||||
{
|
||||
bs.PutLump(BinaryStateLump.LagLog,
|
||||
delegate(TextWriter tw)
|
||||
{
|
||||
(Global.MovieSession.Movie as TasMovie).TasLagLog.Save(tw);
|
||||
});
|
||||
}
|
||||
if (Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie is TasMovie)
|
||||
{
|
||||
bs.PutLump(BinaryStateLump.LagLog,
|
||||
delegate(TextWriter tw)
|
||||
{
|
||||
((TasMovie)Global.MovieSession.Movie).TasLagLog.Save(tw);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,17 +127,6 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
public static void PopulateFramebuffer(byte[] bytes)
|
||||
{
|
||||
using (var ms = new MemoryStream(bytes))
|
||||
{
|
||||
using (var br = new BinaryReader(ms))
|
||||
{
|
||||
PopulateFramebuffer(br);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool LoadStateFile(string path, string name)
|
||||
{
|
||||
var core = Global.Emulator.AsStatable();
|
||||
|
@ -208,10 +194,8 @@ namespace BizHawk.Client.Common
|
|||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,13 +14,6 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public class MovieSession : IMovieSession
|
||||
{
|
||||
public MovieSession()
|
||||
{
|
||||
ReadOnly = true;
|
||||
MovieControllerAdapter = MovieService.DefaultInstance.LogGeneratorInstance().MovieControllerAdapter;
|
||||
MultiTrack = new MultitrackRecorder();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the queued movie
|
||||
/// When initializing a movie, it will be stored here until Rom processes have been completed, then it will be moved to the Movie property
|
||||
|
@ -31,11 +24,11 @@ namespace BizHawk.Client.Common
|
|||
// This wrapper but the logic could change, don't make the client code understand these details
|
||||
public bool MovieIsQueued => QueuedMovie != null;
|
||||
|
||||
public MultitrackRecorder MultiTrack { get; }
|
||||
public IMovieController MovieControllerAdapter { get; set; }
|
||||
public MultitrackRecorder MultiTrack { get; } = new MultitrackRecorder();
|
||||
public IMovieController MovieControllerAdapter { get; set; } = MovieService.DefaultInstance.LogGeneratorInstance().MovieControllerAdapter;
|
||||
|
||||
public IMovie Movie { get; set; }
|
||||
public bool ReadOnly { get; set; }
|
||||
public bool ReadOnly { get; set; } = true;
|
||||
public Action<string> MessageCallback { get; set; }
|
||||
public Func<string, string, bool> AskYesNoCallback { get; set; }
|
||||
|
||||
|
@ -308,10 +301,10 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void HandleMovieAfterFrameLoop()
|
||||
{
|
||||
if (Movie is TasMovie)
|
||||
if (Movie is TasMovie tasMovie)
|
||||
{
|
||||
(Movie as TasMovie).GreenzoneCurrentFrame();
|
||||
if (Movie.IsPlaying && Global.Emulator.Frame >= Movie.InputLogLength)
|
||||
tasMovie.GreenzoneCurrentFrame();
|
||||
if (tasMovie.IsPlaying && Global.Emulator.Frame >= tasMovie.InputLogLength)
|
||||
{
|
||||
HandleFrameLoopForRecordMode();
|
||||
}
|
||||
|
@ -375,8 +368,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (ReadOnly)
|
||||
{
|
||||
string errorMsg;
|
||||
var result = Movie.CheckTimeLines(reader, out errorMsg);
|
||||
var result = Movie.CheckTimeLines(reader, out var errorMsg);
|
||||
if (!result)
|
||||
{
|
||||
Output(errorMsg);
|
||||
|
|
|
@ -10,11 +10,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
partial class MainForm
|
||||
{
|
||||
public void StartNewMovie(string path, bool record)
|
||||
{
|
||||
StartNewMovie(MovieService.Get(Global.Config.RecentMovies.MostRecent), false);
|
||||
}
|
||||
|
||||
public bool StartNewMovie(IMovie movie, bool record)
|
||||
{
|
||||
// SuuperW: Check changes. adelikat: this could break bk2 movies
|
||||
|
@ -30,7 +25,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
catch (MoviePlatformMismatchException ex)
|
||||
{
|
||||
using var ownerForm = new Form() { TopMost = true };
|
||||
using var ownerForm = new Form { TopMost = true };
|
||||
MessageBox.Show(ownerForm, ex.Message, "Movie/Platform Mismatch", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void StateHistorySettings_Load(object sender, EventArgs e)
|
||||
{
|
||||
_stateSizeMb = Statable.SaveStateBinary().Length / (decimal)1024 / (decimal)1024;
|
||||
_stateSizeMb = Statable.SaveStateBinary().Length / (decimal)1024 / 1024;
|
||||
|
||||
MemCapacityNumeric.Maximum = 1024 * 8;
|
||||
MemCapacityNumeric.Minimum = _stateSizeMb + 1;
|
||||
|
|
|
@ -157,10 +157,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (MarkerView.AnyRowsSelected)
|
||||
{
|
||||
while (MarkerView.SelectedRows.Last() > Markers.Count() - 1)
|
||||
while (MarkerView.SelectedRows.Last() > Markers.Count - 1)
|
||||
{
|
||||
MarkerView.SelectRow(Markers.Count(), false);
|
||||
MarkerView.SelectRow(Markers.Count() - 1, true);
|
||||
MarkerView.SelectRow(Markers.Count, false);
|
||||
MarkerView.SelectRow(Markers.Count - 1, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,11 +196,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
Markers.Add(new TasMovieMarker(markerFrame, ""));
|
||||
Markers.Add(new TasMovieMarker(markerFrame));
|
||||
UpdateValues();
|
||||
}
|
||||
|
||||
MarkerView.ScrollToIndex(Markers.Count() - 1);
|
||||
MarkerView.ScrollToIndex(Markers.Count - 1);
|
||||
Tastudio.RefreshDialog();
|
||||
}
|
||||
|
||||
|
@ -272,11 +272,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
private void MarkerView_ItemActivate(object sender, EventArgs e)
|
||||
{
|
||||
Tastudio.GoToMarker(SelectedMarkers.First());
|
||||
}
|
||||
|
||||
// SuuperW: Marker renaming can be done with a right-click.
|
||||
// A much more useful feature would be to easily jump to it.
|
||||
private void MarkerView_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
|
|
|
@ -16,56 +16,31 @@ namespace BizHawk.Client.EmuHawk
|
|||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool TurboSeek
|
||||
{
|
||||
get
|
||||
{
|
||||
return Global.Config.TurboSeek;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
TurboSeekCheckbox.Checked = value;
|
||||
}
|
||||
get => Global.Config.TurboSeek;
|
||||
set => TurboSeekCheckbox.Checked = value;
|
||||
}
|
||||
|
||||
[Browsable(true)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool AutoRestore
|
||||
{
|
||||
get
|
||||
{
|
||||
return Tastudio.Settings.AutoRestoreLastPosition;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
AutoRestoreCheckbox.Checked = value;
|
||||
}
|
||||
get => Tastudio.Settings.AutoRestoreLastPosition;
|
||||
set => AutoRestoreCheckbox.Checked = value;
|
||||
}
|
||||
|
||||
[Browsable(true)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool FollowCursor
|
||||
{
|
||||
get
|
||||
{
|
||||
return Tastudio.Settings.FollowCursor;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
FollowCursorCheckbox.Checked = value;
|
||||
}
|
||||
get => Tastudio.Settings.FollowCursor;
|
||||
set => FollowCursorCheckbox.Checked = value;
|
||||
}
|
||||
|
||||
[Browsable(true)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public bool RecordingMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return Global.MovieSession.Movie.IsRecording;
|
||||
}
|
||||
|
||||
get => Global.MovieSession.Movie.IsRecording;
|
||||
set
|
||||
{
|
||||
RecordingModeCheckbox.Checked = value;
|
||||
|
|
|
@ -4,9 +4,9 @@ using System.Windows.Forms;
|
|||
using BizHawk.Client.Common;
|
||||
|
||||
// We pretend it's a tooltip kind of thing, so show only the actual contents
|
||||
// and avoid stealing forcus, while still being topmost
|
||||
// and avoid stealing focus, while still being topmost
|
||||
// http://stackoverflow.com/a/25219399/2792852
|
||||
// This is not an actual tooltip, because they can't reliably fade in and out with trasparency
|
||||
// This is not an actual tooltip, because they can't reliably fade in and out with transparency
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public partial class ScreenshotForm : Form
|
||||
|
@ -22,9 +22,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
private TasBranch _branch;
|
||||
private int _drawingHeight;
|
||||
|
||||
new public Font Font;
|
||||
new public int Padding;
|
||||
new public string Text;
|
||||
public new Font Font;
|
||||
public new int Padding;
|
||||
public new string Text;
|
||||
|
||||
public ScreenshotForm()
|
||||
{
|
||||
|
|
|
@ -232,6 +232,7 @@
|
|||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Grafx/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=greenzone/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=greenzoned/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Hardpoint/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Highscore/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Homebrew/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Hotkey/@EntryIndexedValue">True</s:Boolean>
|
||||
|
@ -259,6 +260,7 @@
|
|||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mupen/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Nametable/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Nametables/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=neshawk/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Nintendulator/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=nsamp/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Numerics/@EntryIndexedValue">True</s:Boolean>
|
||||
|
@ -274,6 +276,7 @@
|
|||
<s:Boolean x:Key="/Default/UserDictionary/Words/=preload/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Prereqs/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=quickload/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=quicknes/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=quicksave/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Regionable/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=resizer/@EntryIndexedValue">True</s:Boolean>
|
||||
|
|
Loading…
Reference in New Issue