Skip to content

Commit b914bd1

Browse files
committed
Use UUIDs instead of indices for branch params in new functions
1 parent babc51f commit b914bd1

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/TAStudioLuaLibrary.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,10 @@ public void LoadBranch(int index)
462462
}
463463

464464
/// <remarks>assumes a TAStudio project is loaded</remarks>
465-
private TasMovieMarkerList/*?*/ MarkerListForBranch(int? branchIndex)
466-
=> branchIndex is int i
467-
? Tastudio.CurrentTasMovie.Branches.ElementAtOrDefault(i)?.Markers
468-
: Tastudio.CurrentTasMovie.Markers;
465+
private TasMovieMarkerList/*?*/ MarkerListForBranch(string/*?*/ branchID)
466+
=> Guid.TryParseExact(branchID, format: "D", out var parsed)
467+
? Tastudio.CurrentTasMovie.Branches.FirstOrDefault(branch => branch.Uuid == parsed)?.Markers
468+
: branchID is null ? Tastudio.CurrentTasMovie.Markers : null; // not a typo; null `branchID` indicates main log
469469

470470
[LuaMethodExample("""
471471
local marker_label = tastudio.getmarker(tastudio.find_marker_on_or_before(100));
@@ -474,9 +474,9 @@ public void LoadBranch(int index)
474474
name: "find_marker_on_or_before",
475475
description: "Returns the frame number of the marker closest to the given frame (including that frame, but not after it)."
476476
+ " This may be the power-on marker at 0. Returns nil if the arguments are invalid or TAStudio isn't active."
477-
+ " If branchIndex is specified, searches the markers in that branch instead.")]
478-
public int? FindMarkerOnOrBefore(int frame, int? branchIndex = null)
479-
=> Engaged() && MarkerListForBranch(branchIndex) is TasMovieMarkerList markers
477+
+ " If branchID is specified, searches the markers in that branch instead.")]
478+
public int? FindMarkerOnOrBefore(int frame, string/*?*/ branchID = null)
479+
=> Engaged() && MarkerListForBranch(branchID) is TasMovieMarkerList markers
480480
? markers.PreviousOrCurrent(frame)?.Frame
481481
: null;
482482

@@ -486,9 +486,9 @@ public void LoadBranch(int index)
486486
[LuaMethod(
487487
name: "get_frames_with_markers",
488488
description: "Returns a list of all the frames which have markers on them."
489-
+ " If branchIndex is specified, instead returns the frames which have markers in that branch.")]
490-
public LuaTable GetFramesWithMarkers(int? branchIndex = null)
491-
=> Engaged() && MarkerListForBranch(branchIndex) is TasMovieMarkerList markers
489+
+ " If branchID is specified, instead returns the frames which have markers in that branch.")]
490+
public LuaTable GetFramesWithMarkers(string/*?*/ branchID = null)
491+
=> Engaged() && MarkerListForBranch(branchID) is TasMovieMarkerList markers
492492
? _th.EnumerateToLuaTable(markers.Select(static m => m.Frame))
493493
: _th.CreateTable();
494494

0 commit comments

Comments
 (0)