Skip to content

Commit 92743b7

Browse files
committed
Use UUIDs instead of indices for branch params in new functions
1 parent 02cabac commit 92743b7

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,13 @@ public string GetMarker(int frame)
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[i].Markers
468-
: Tastudio.CurrentTasMovie.Markers;
465+
private TasMovieMarkerList MarkerListForBranch(string/*?*/ branchID)
466+
{
467+
var found = Guid.TryParseExact(branchID, format: "D", out var parsed)
468+
? Tastudio.CurrentTasMovie.Branches.FirstOrDefault(branch => branch.Uuid == parsed)
469+
: null;
470+
return found?.Markers ?? Tastudio.CurrentTasMovie.Markers;
471+
}
469472

470473
[LuaMethodExample("""
471474
local marker_label = tastudio.getmarker(tastudio.find_marker_on_or_before(100));
@@ -475,9 +478,9 @@ private TasMovieMarkerList MarkerListForBranch(int? branchIndex)
475478
description: "Returns the frame number of the marker closest to the given frame (including that frame, but not after it)."
476479
+ " This may be the power-on marker at 0."
477480
+ " If branchIndex is specified, searches the markers in that branch instead.")]
478-
public int FindMarkerOnOrBefore(int frame, int? branchIndex = null)
481+
public int FindMarkerOnOrBefore(int frame, string/*?*/ branchID = null)
479482
=> Engaged()
480-
? MarkerListForBranch(branchIndex).PreviousOrCurrent(frame).Frame
483+
? MarkerListForBranch(branchID).PreviousOrCurrent(frame).Frame
481484
: default;
482485

483486
[LuaMethodExample("""
@@ -487,9 +490,9 @@ public int FindMarkerOnOrBefore(int frame, int? branchIndex = null)
487490
name: "get_frames_with_markers",
488491
description: "Returns a list of all the frames which have markers on them."
489492
+ " If branchIndex is specified, instead returns the frames which have markers in that branch.")]
490-
public LuaTable GetFramesWithMarkers(int? branchIndex = null)
493+
public LuaTable GetFramesWithMarkers(string/*?*/ branchID = null)
491494
=> Engaged()
492-
? _th.EnumerateToLuaTable(MarkerListForBranch(branchIndex).Select(static m => m.Frame))
495+
? _th.EnumerateToLuaTable(MarkerListForBranch(branchID).Select(static m => m.Frame))
493496
: _th.CreateTable();
494497

495498
[LuaMethodExample("tastudio.removemarker( 500 );")]

0 commit comments

Comments
 (0)