tastudio/lua - implement tastudio.getmarker(), tastudio.setmarker(), and tastudio.removemarker()
This commit is contained in:
parent
56442d9f8d
commit
8b212da594
|
@ -216,5 +216,10 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
return this.Any(m => m == frame);
|
||||
}
|
||||
|
||||
public TasMovieMarker Get(int frame)
|
||||
{
|
||||
return this.FirstOrDefault(m => m == frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public override string Name { get { return "tastudio"; } }
|
||||
|
||||
private TAStudio Tastudio
|
||||
{
|
||||
get
|
||||
{
|
||||
return GlobalWin.Tools.Get<TAStudio>() as TAStudio;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"engaged",
|
||||
"returns whether or not tastudio is currently engaged (active)"
|
||||
|
@ -26,5 +35,61 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
return GlobalWin.Tools.Has<TAStudio>(); // TODO: eventually tastudio should have an engaged flag
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"getmarker",
|
||||
"returns the marker text at the given frame, or an empty string if there is no marker for the given frame"
|
||||
)]
|
||||
public string GetMarker(int frame)
|
||||
{
|
||||
if (Engaged())
|
||||
{
|
||||
var marker = Tastudio.CurrentMovie.Markers.Get(frame);
|
||||
if (marker != null)
|
||||
{
|
||||
return marker.Message;
|
||||
}
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"removemarker",
|
||||
"if there is a marker for the given frame, it will be removed"
|
||||
)]
|
||||
public void RemoveMarker(int frame)
|
||||
{
|
||||
if (Engaged())
|
||||
{
|
||||
var marker = Tastudio.CurrentMovie.Markers.Get(frame);
|
||||
if (marker != null)
|
||||
{
|
||||
Tastudio.CurrentMovie.Markers.Remove(marker);
|
||||
Tastudio.UpdateValues();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"setmarker",
|
||||
"Adds or sets a marker at the given frame with the given message"
|
||||
)]
|
||||
public void SetMarker(int frame, string message)
|
||||
{
|
||||
if (Engaged())
|
||||
{
|
||||
var marker = Tastudio.CurrentMovie.Markers.Get(frame);
|
||||
if (marker != null)
|
||||
{
|
||||
marker.Message = message;
|
||||
}
|
||||
else
|
||||
{
|
||||
Tastudio.CurrentMovie.Markers.Add(frame, message);
|
||||
Tastudio.UpdateValues();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue