Initial implementation of new Lua functions for TAStudio markers

This commit is contained in:
c7fab 2025-03-12 02:44:56 +01:00 committed by YoshiRulz
parent edda865afb
commit 07c0f27865
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 69 additions and 0 deletions

View File

@ -459,6 +459,75 @@ namespace BizHawk.Client.EmuHawk
return "";
}
[LuaMethodExample("local markerframe = tastudio.getmarkerabove(100).Frame")]
[LuaMethod("getmarkerabove", "returns a table of the marker at or above the given frame with fields Frame and Text")]
public LuaTable GetMarkerAbove(int frame)
{
var table = _th.CreateTable();
if (!Engaged()) return table;
var marker = Tastudio.CurrentTasMovie.Markers.PreviousOrCurrent(frame);
table["Frame"] = marker.Frame;
table["Text"] = marker.Message;
return table;
}
[LuaMethodExample("local branchmarkertext = tastudio.getbranchmarkerabove(0, 100).Text")]
[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")]
public LuaTable GetBranchMarkerAbove(int index, int frame)
{
var table = _th.CreateTable();
if (!Engaged()) return table;
if (index >= Tastudio.CurrentTasMovie.Branches.Count) return table;
var branch = Tastudio.CurrentTasMovie.Branches[index];
var marker = branch.Markers.PreviousOrCurrent(frame);
table["Frame"] = marker.Frame;
table["Text"] = marker.Message;
return table;
}
[LuaMethodExample("local markertext = tastudio.getmarkers()[0].Text")]
[LuaMethod("getmarkers", "returns a table of all markers with fields Frame and Text")]
public LuaTable GetMarkers()
{
if (!Engaged()) return _th.CreateTable();
return _th.EnumerateToLuaTable(
Tastudio.CurrentTasMovie.Markers.Select(m =>
{
var table = _th.CreateTable();
table["Frame"] = m.Frame;
table["Text"] = m.Message;
return table;
}),
indexFrom: 0);
}
[LuaMethodExample("local branchmarkerframe = tastudio.getmarkers(0)[0].Frame")]
[LuaMethod("getbranchmarkers", "returns a table of all markers for the given branch index, starting at 0, with fields Frame and Text")]
public LuaTable GetBranchMarkers(int index)
{
if (!Engaged()) return _th.CreateTable();
if (index >= Tastudio.CurrentTasMovie.Branches.Count) return _th.CreateTable();
var branch = Tastudio.CurrentTasMovie.Branches[index];
return _th.EnumerateToLuaTable(
branch.Markers.Select(m =>
{
var table = _th.CreateTable();
table["Frame"] = m.Frame;
table["Text"] = m.Message;
return table;
}),
indexFrom: 0);
}
[LuaMethodExample("tastudio.removemarker( 500 );")]
[LuaMethod("removemarker", "if there is a marker for the given frame, it will be removed")]
public void RemoveMarker(int frame)