diff --git a/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs b/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs index 188edbe604..394783343a 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs @@ -25,6 +25,16 @@ namespace BizHawk.Client.Common } } + public Action InvalidateCallback { get; set; } + + private void CallInvalidateCallback(int index) + { + if (InvalidateCallback != null) + { + InvalidateCallback(index); + } + } + private readonly SortedList States = new SortedList(); private string statePath { @@ -329,6 +339,8 @@ namespace BizHawk.Client.Common accessed.Remove(state.Key); States.Remove(state.Key); } + + CallInvalidateCallback(frame); } } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Tastudio.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Tastudio.cs index 5367f1230d..04f26a6c01 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Tastudio.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Tastudio.cs @@ -173,5 +173,20 @@ namespace BizHawk.Client.EmuHawk }; } } + + [LuaMethodAttributes( + "ongreenzoneinvalidated", + "called whenever the greenzone is invalidated and returns the first frame that was invalidated" + )] + public void OnGreenzoneInvalidated(LuaFunction luaf) + { + if (Engaged()) + { + Tastudio.GreenzoneInvalidatedCallback = (int index) => + { + luaf.Call(index); + }; + } + } } } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index e3861d91e4..6a613abd82 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -121,6 +121,15 @@ namespace BizHawk.Client.EmuHawk return null; } + public Action GreenzoneInvalidatedCallback { get; set; } + private void GreenzoneInvalidated(int index) + { + if (GreenzoneInvalidatedCallback != null) + { + GreenzoneInvalidatedCallback(index); + } + } + #endregion private void TasView_QueryItemBkColor(int index, InputRoll.RollColumn column, ref Color color) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 3f1c589b3a..6061dff40c 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -328,6 +328,7 @@ namespace BizHawk.Client.EmuHawk if (CurrentTasMovie == null) { Global.MovieSession.Movie = new TasMovie(false, _saveBackgroundWorker); + (Global.MovieSession.Movie as TasMovie).TasStateManager.InvalidateCallback = GreenzoneInvalidated; } CurrentTasMovie.Filename = file.FullName; @@ -357,6 +358,7 @@ namespace BizHawk.Client.EmuHawk if (AskSaveChanges()) { Global.MovieSession.Movie = new TasMovie(false, _saveBackgroundWorker); + (Global.MovieSession.Movie as TasMovie).TasStateManager.InvalidateCallback = GreenzoneInvalidated; CurrentTasMovie.PropertyChanged += new PropertyChangedEventHandler(this.TasMovie_OnPropertyChanged); CurrentTasMovie.Filename = DefaultTasProjName(); // TODO don't do this, take over any mainform actions that can crash without a filename CurrentTasMovie.PopulateWithDefaultHeaderValues();