diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs b/BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs index 6922bfb1a6..f23f874269 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs @@ -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); + } } } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Tastudio.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Tastudio.cs index cf145e2429..34d0af7dc9 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Tastudio.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Tastudio.cs @@ -18,6 +18,15 @@ namespace BizHawk.Client.EmuHawk public override string Name { get { return "tastudio"; } } + private TAStudio Tastudio + { + get + { + return GlobalWin.Tools.Get() 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(); // 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(); + } + } + } } }