lua: movie.save

see 
This commit is contained in:
feos 2016-01-30 16:09:58 +03:00
parent a821fce6c8
commit c641d94e05
1 changed files with 24 additions and 0 deletions
BizHawk.Client.Common/lua

View File

@ -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"