From 539cdc29f3d8b75ca49af6ee0592e3872bbad43f Mon Sep 17 00:00:00 2001 From: zeromus Date: Sat, 4 Feb 2017 21:40:29 -0600 Subject: [PATCH] add SetPlayback to tastudio lua library. Can't be 100% sure it works, but it seems to be working OK. it may hang everything up if you seek through a really long redzone..... --- .../movie/tasproj/TasMovieMarker.cs | 5 ++++ .../Lua/Libraries/EmuLuaLibrary.Tastudio.cs | 24 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs b/BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs index 0137bb51cb..d74de738ce 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovieMarker.cs @@ -282,6 +282,11 @@ namespace BizHawk.Client.Common .FirstOrDefault(); } + public int FindIndex(string markerName) + { + return this.FindIndex(m => m.Message == markerName); + } + public bool IsMarker(int frame) { return this.Any(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 1f6cae1c57..b0011ae680 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Tastudio.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Tastudio.cs @@ -155,6 +155,30 @@ namespace BizHawk.Client.EmuHawk return false; } + [LuaMethodAttributes( + "setplayback", + "Seeks the given frame (a number) or marker (a string)" + )] + public void SetPlayback(object frame) + { + if (Engaged()) + { + int f; + if (frame is double) f = (int)(double)frame; + else + { + //r marker = Tastudio.CurrentTasMovie.Markers.Get(frame); + f = Tastudio.CurrentTasMovie.Markers.FindIndex((string)frame); + if (f == -1) return; + f = Tastudio.CurrentTasMovie.Markers[f].Frame; + } + if (f < Tastudio.CurrentTasMovie.InputLogLength && f>=0) + { + Tastudio.GoToFrame(f); + } + } + } + [LuaMethodAttributes( "onqueryitembg", "called during the background draw event of the tastudio listview"