Avoid throwing when new functions called with nonexistent branch index
This commit is contained in:
parent
ac5e389cc9
commit
babc51f1f9
|
@ -462,9 +462,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <remarks>assumes a TAStudio project is loaded</remarks>
|
/// <remarks>assumes a TAStudio project is loaded</remarks>
|
||||||
private TasMovieMarkerList MarkerListForBranch(int? branchIndex)
|
private TasMovieMarkerList/*?*/ MarkerListForBranch(int? branchIndex)
|
||||||
=> branchIndex is int i
|
=> branchIndex is int i
|
||||||
? Tastudio.CurrentTasMovie.Branches[i].Markers
|
? Tastudio.CurrentTasMovie.Branches.ElementAtOrDefault(i)?.Markers
|
||||||
: Tastudio.CurrentTasMovie.Markers;
|
: Tastudio.CurrentTasMovie.Markers;
|
||||||
|
|
||||||
[LuaMethodExample("""
|
[LuaMethodExample("""
|
||||||
|
@ -476,8 +476,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
+ " This may be the power-on marker at 0. Returns nil if the arguments are invalid or TAStudio isn't active."
|
+ " This may be the power-on marker at 0. Returns nil if the arguments are invalid or TAStudio isn't active."
|
||||||
+ " If branchIndex is specified, searches the markers in that branch instead.")]
|
+ " If branchIndex is specified, searches the markers in that branch instead.")]
|
||||||
public int? FindMarkerOnOrBefore(int frame, int? branchIndex = null)
|
public int? FindMarkerOnOrBefore(int frame, int? branchIndex = null)
|
||||||
=> Engaged()
|
=> Engaged() && MarkerListForBranch(branchIndex) is TasMovieMarkerList markers
|
||||||
? MarkerListForBranch(branchIndex).PreviousOrCurrent(frame)?.Frame
|
? markers.PreviousOrCurrent(frame)?.Frame
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
[LuaMethodExample("""
|
[LuaMethodExample("""
|
||||||
|
@ -488,8 +488,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
description: "Returns a list of all the frames which have markers on them."
|
description: "Returns a list of all the frames which have markers on them."
|
||||||
+ " If branchIndex is specified, instead returns the frames which have markers in that branch.")]
|
+ " If branchIndex is specified, instead returns the frames which have markers in that branch.")]
|
||||||
public LuaTable GetFramesWithMarkers(int? branchIndex = null)
|
public LuaTable GetFramesWithMarkers(int? branchIndex = null)
|
||||||
=> Engaged()
|
=> Engaged() && MarkerListForBranch(branchIndex) is TasMovieMarkerList markers
|
||||||
? _th.EnumerateToLuaTable(MarkerListForBranch(branchIndex).Select(static m => m.Frame))
|
? _th.EnumerateToLuaTable(markers.Select(static m => m.Frame))
|
||||||
: _th.CreateTable();
|
: _th.CreateTable();
|
||||||
|
|
||||||
[LuaMethodExample("tastudio.removemarker( 500 );")]
|
[LuaMethodExample("tastudio.removemarker( 500 );")]
|
||||||
|
|
Loading…
Reference in New Issue