Skip to content

Commit 3de9146

Browse files
committed
Code style fixes
1 parent 07c0f27 commit 3de9146

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
@@ -459,74 +459,41 @@ public string GetMarker(int frame)
459459
return "";
460460
}
461461

462-
[LuaMethodExample("local markerframe = tastudio.getmarkerabove(100).Frame")]
463-
[LuaMethod("getmarkerabove", "returns a table of the marker at or above the given frame with fields Frame and Text")]
464-
public LuaTable GetMarkerAbove(int frame)
462+
private LuaTable CreateMarkerTuple(TasMovieMarker marker)
465463
{
466464
var table = _th.CreateTable();
467-
if (!Engaged()) return table;
468-
469-
var marker = Tastudio.CurrentTasMovie.Markers.PreviousOrCurrent(frame);
470465
table["Frame"] = marker.Frame;
471466
table["Text"] = marker.Message;
472-
473467
return table;
474468
}
475469

470+
[LuaMethodExample("local markerframe = tastudio.getmarkerabove(100).Frame")]
471+
[LuaMethod("getmarkerabove", "returns a table of the marker at or above the given frame with fields Frame and Text")]
472+
public LuaTable GetMarkerAbove(int frame)
473+
=> Engaged()
474+
? CreateMarkerTuple(Tastudio.CurrentTasMovie.Markers.PreviousOrCurrent(frame))
475+
: _th.CreateTable();
476+
476477
[LuaMethodExample("local branchmarkertext = tastudio.getbranchmarkerabove(0, 100).Text")]
477478
[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")]
478479
public LuaTable GetBranchMarkerAbove(int index, int frame)
479-
{
480-
var table = _th.CreateTable();
481-
if (!Engaged()) return table;
482-
483-
if (index >= Tastudio.CurrentTasMovie.Branches.Count) return table;
484-
485-
var branch = Tastudio.CurrentTasMovie.Branches[index];
486-
var marker = branch.Markers.PreviousOrCurrent(frame);
487-
table["Frame"] = marker.Frame;
488-
table["Text"] = marker.Message;
489-
490-
return table;
491-
}
480+
=> Engaged()
481+
? CreateMarkerTuple(Tastudio.CurrentTasMovie.Branches[index].Markers.PreviousOrCurrent(frame))
482+
: _th.CreateTable();
492483

493-
[LuaMethodExample("local markertext = tastudio.getmarkers()[0].Text")]
484+
[LuaMethodExample("local markertext = tastudio.getmarkers()[1].Text")]
494485
[LuaMethod("getmarkers", "returns a table of all markers with fields Frame and Text")]
495486
public LuaTable GetMarkers()
496-
{
497-
if (!Engaged()) return _th.CreateTable();
498-
499-
return _th.EnumerateToLuaTable(
500-
Tastudio.CurrentTasMovie.Markers.Select(m =>
501-
{
502-
var table = _th.CreateTable();
503-
table["Frame"] = m.Frame;
504-
table["Text"] = m.Message;
505-
return table;
506-
}),
507-
indexFrom: 0);
508-
}
487+
=> Engaged()
488+
? _th.EnumerateToLuaTable(Tastudio.CurrentTasMovie.Markers.Select(CreateMarkerTuple))
489+
: _th.CreateTable();
509490

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

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

0 commit comments

Comments
 (0)