Skip to content

Commit da1b08f

Browse files
committed
Code style fixes
1 parent fff66c3 commit da1b08f

File tree

1 file changed

+19
-52
lines changed

1 file changed

+19
-52
lines changed

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

Lines changed: 19 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -461,74 +461,41 @@ public void LoadBranch(int index)
461461
return null;
462462
}
463463

464-
[LuaMethodExample("local markerframe = tastudio.getmarkerabove(100).Frame")]
465-
[LuaMethod("getmarkerabove", "returns a table of the marker at or above the given frame with fields Frame and Text")]
466-
public LuaTable GetMarkerAbove(int frame)
464+
private LuaTable CreateMarkerTuple(TasMovieMarker marker)
467465
{
468466
var table = _th.CreateTable();
469-
if (!Engaged()) return table;
470-
471-
var marker = Tastudio.CurrentTasMovie.Markers.PreviousOrCurrent(frame);
472467
table["Frame"] = marker.Frame;
473468
table["Text"] = marker.Message;
474-
475469
return table;
476470
}
477471

472+
[LuaMethodExample("local markerframe = tastudio.getmarkerabove(100).Frame")]
473+
[LuaMethod("getmarkerabove", "returns a table of the marker at or above the given frame with fields Frame and Text")]
474+
public LuaTable GetMarkerAbove(int frame)
475+
=> Engaged()
476+
? CreateMarkerTuple(Tastudio.CurrentTasMovie.Markers.PreviousOrCurrent(frame))
477+
: _th.CreateTable();
478+
478479
[LuaMethodExample("local branchmarkertext = tastudio.getbranchmarkerabove(0, 100).Text")]
479480
[LuaMethod("getbranchmarkerabove", "returns a table of the marker at or above the given frame for the given branch index, starting at 0, with fields Frame and Text")]
480481
public LuaTable GetBranchMarkerAbove(int index, int frame)
481-
{
482-
var table = _th.CreateTable();
483-
if (!Engaged()) return table;
484-
485-
if (index >= Tastudio.CurrentTasMovie.Branches.Count) return table;
486-
487-
var branch = Tastudio.CurrentTasMovie.Branches[index];
488-
var marker = branch.Markers.PreviousOrCurrent(frame);
489-
table["Frame"] = marker.Frame;
490-
table["Text"] = marker.Message;
491-
492-
return table;
493-
}
482+
=> Engaged()
483+
? CreateMarkerTuple(Tastudio.CurrentTasMovie.Branches[index].Markers.PreviousOrCurrent(frame))
484+
: _th.CreateTable();
494485

495-
[LuaMethodExample("local markertext = tastudio.getmarkers()[0].Text")]
486+
[LuaMethodExample("local markertext = tastudio.getmarkers()[1].Text")]
496487
[LuaMethod("getmarkers", "returns a table of all markers with fields Frame and Text")]
497488
public LuaTable GetMarkers()
498-
{
499-
if (!Engaged()) return _th.CreateTable();
500-
501-
return _th.EnumerateToLuaTable(
502-
Tastudio.CurrentTasMovie.Markers.Select(m =>
503-
{
504-
var table = _th.CreateTable();
505-
table["Frame"] = m.Frame;
506-
table["Text"] = m.Message;
507-
return table;
508-
}),
509-
indexFrom: 0);
510-
}
489+
=> Engaged()
490+
? _th.EnumerateToLuaTable(Tastudio.CurrentTasMovie.Markers.Select(CreateMarkerTuple))
491+
: _th.CreateTable();
511492

512-
[LuaMethodExample("local branchmarkerframe = tastudio.getmarkers(0)[0].Frame")]
493+
[LuaMethodExample("local branchmarkerframe = tastudio.getmarkers(0)[1].Frame")]
513494
[LuaMethod("getbranchmarkers", "returns a table of all markers for the given branch index, starting at 0, with fields Frame and Text")]
514495
public LuaTable GetBranchMarkers(int index)
515-
{
516-
if (!Engaged()) return _th.CreateTable();
517-
518-
if (index >= Tastudio.CurrentTasMovie.Branches.Count) return _th.CreateTable();
519-
520-
var branch = Tastudio.CurrentTasMovie.Branches[index];
521-
522-
return _th.EnumerateToLuaTable(
523-
branch.Markers.Select(m =>
524-
{
525-
var table = _th.CreateTable();
526-
table["Frame"] = m.Frame;
527-
table["Text"] = m.Message;
528-
return table;
529-
}),
530-
indexFrom: 0);
531-
}
496+
=> Engaged()
497+
? _th.EnumerateToLuaTable(Tastudio.CurrentTasMovie.Branches[index].Markers.Select(CreateMarkerTuple))
498+
: _th.CreateTable();
532499

533500
[LuaMethodExample("tastudio.removemarker( 500 );")]
534501
[LuaMethod("removemarker", "if there is a marker for the given frame, it will be removed")]

0 commit comments

Comments
 (0)