Merge ctors using default params, resolves a TODO

This commit is contained in:
YoshiRulz 2020-01-02 22:10:42 +10:00
parent 060255471b
commit 9ef32cf8f5
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 5 additions and 32 deletions

View File

@ -9,20 +9,14 @@ namespace BizHawk.Client.Common
{ {
private Bk2ControllerAdapter _adapter; private Bk2ControllerAdapter _adapter;
public Bk2Movie(string filename) public Bk2Movie(string filename = null)
: this()
{
Rerecords = 0;
Filename = filename;
}
public Bk2Movie()
{ {
Subtitles = new SubtitleList(); Subtitles = new SubtitleList();
Comments = new List<string>(); Comments = new List<string>();
Filename = ""; Filename = filename ?? string.Empty;
IsCountingRerecords = true; IsCountingRerecords = true;
if (filename != null) Rerecords = 0;
Mode = MovieMode.Inactive; Mode = MovieMode.Inactive;
MakeBackup = true; MakeBackup = true;

View File

@ -47,28 +47,7 @@ namespace BizHawk.Client.Common
}; };
/// <exception cref="InvalidOperationException">loaded core does not implement <see cref="IStatable"/></exception> /// <exception cref="InvalidOperationException">loaded core does not implement <see cref="IStatable"/></exception>
public TasMovie(string path, bool startsFromSavestate = false) public TasMovie(string path = null, bool startsFromSavestate = false) : base(path)
: base(path)
{
// TODO: how to call the default constructor AND the base(path) constructor? And is base(path) calling base() ?
if (!Global.Emulator.HasSavestates())
{
throw new InvalidOperationException($"Cannot create a {nameof(TasMovie)} against a core that does not implement {nameof(IStatable)}");
}
ChangeLog = new TasMovieChangeLog(this);
TasStateManager = new TasStateManager(this);
Session = new TasSession(this);
Header[HeaderKeys.MOVIEVERSION] = "BizHawk v2.0 Tasproj v1.0";
Markers = new TasMovieMarkerList(this);
Markers.CollectionChanged += Markers_CollectionChanged;
Markers.Add(0, startsFromSavestate ? "Savestate" : "Power on");
BindMarkersToInput = false;
CurrentBranch = -1;
}
/// <exception cref="InvalidOperationException">loaded core does not implement <see cref="IStatable"/></exception>
public TasMovie(bool startsFromSavestate = false)
{ {
if (!Global.Emulator.HasSavestates()) if (!Global.Emulator.HasSavestates())
{ {

View File

@ -555,7 +555,7 @@ namespace BizHawk.Client.EmuHawk
return false; return false;
} }
TasMovie newMovie = new TasMovie(startsFromSavestate); TasMovie newMovie = new TasMovie(startsFromSavestate: startsFromSavestate);
newMovie.TasStateManager.InvalidateCallback = GreenzoneInvalidated; newMovie.TasStateManager.InvalidateCallback = GreenzoneInvalidated;
newMovie.Filename = file.FullName; newMovie.Filename = file.FullName;