From c641d94e0502bfec6e636b66094c184820144a34 Mon Sep 17 00:00:00 2001 From: feos Date: Sat, 30 Jan 2016 16:09:58 +0300 Subject: [PATCH] lua: movie.save see #384 --- .../lua/EmuLuaLibrary.Movie.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Movie.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Movie.cs index 17e84bcfa1..322aa82a8d 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Movie.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Movie.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using LuaInterface; namespace BizHawk.Client.Common @@ -157,6 +158,29 @@ namespace BizHawk.Client.Common return GetRerecordCount().ToString(); } + [LuaMethodAttributes( + "save", + "Saves the current movie to the disc. If the filename is provided (no extension or path needed), the movie is saved under the specified name to the current movie directory. The filename may contain a subdirectory, it will be created if it doesn't exist. Existing files won't get overwritten." + )] + public void Save(string filename = "") + { + if (!Global.MovieSession.Movie.IsActive) + return; + + if (!string.IsNullOrEmpty(filename)) + { + filename += "." + Global.MovieSession.Movie.PreferredExtension; + var test = new FileInfo(filename); + if (test.Exists) + { + Log(string.Format("File {0} already exists, will not overwrite.", filename)); + return; + } + Global.MovieSession.Movie.Filename = filename; + } + Global.MovieSession.Movie.Save(); + } + [LuaMethodAttributes( "setreadonly", "Sets the read-only state to the given value. true for read only, false for read+write"