give movies the ability to write to any stream; decouple saving of movie from the import process, and make the bulk movie importer use new movie ability to write directly to output instead of copying (sometimes on top of itself in case source .fm2 was already in movie directory); make drag&dropped movies import to oldmovie.fm2.bkm.autoimported.bkm to prevent it from clobbering a legit movie you may have had there already
This commit is contained in:
parent
bf35f63aa3
commit
562eeb18bd
|
@ -1284,6 +1284,8 @@ namespace BizHawk.MultiClient
|
|||
|
||||
else if (MovieImport.IsValidMovieExtension(Path.GetExtension(filePaths[0])))
|
||||
{
|
||||
//tries to open a legacy movie format as if it were a BKM, by importing it
|
||||
|
||||
if (CurrentlyOpenRom == null)
|
||||
OpenROM();
|
||||
else
|
||||
|
@ -1298,6 +1300,11 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
else
|
||||
{
|
||||
//fix movie extension to something palatable for these purposes.
|
||||
//for instance, something which doesnt clobber movies you already may have had.
|
||||
//i'm evenly torn between this, and a file in %TEMP%, but since we dont really have a way to clean up this tempfile, i choose this:
|
||||
m.Filename += ".autoimported." + Global.Config.MovieExtension;
|
||||
m.WriteMovie();
|
||||
StartNewMovie(m, false);
|
||||
}
|
||||
Global.OSD.AddMessage(warningMsg);
|
||||
|
@ -4080,26 +4087,30 @@ namespace BizHawk.MultiClient
|
|||
|
||||
foreach (string fn in ofd.FileNames)
|
||||
{
|
||||
var file = new FileInfo(fn);
|
||||
string d = PathManager.MakeAbsolutePath(Global.Config.MoviesPath, "");
|
||||
string errorMsg = "";
|
||||
string warningMsg = "";
|
||||
Movie m = MovieImport.ImportFile(fn, out errorMsg, out warningMsg);
|
||||
if (errorMsg.Length > 0)
|
||||
MessageBox.Show(errorMsg, "Conversion error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
if (warningMsg.Length > 0)
|
||||
Global.OSD.AddMessage(warningMsg);
|
||||
else
|
||||
Global.OSD.AddMessage(Path.GetFileName(fn) + " imported as " + "Movies\\" +
|
||||
Path.GetFileName(fn) + "." + Global.Config.MovieExtension);
|
||||
if (!Directory.Exists(d))
|
||||
Directory.CreateDirectory(d);
|
||||
File.Copy(fn + "." + Global.Config.MovieExtension, d + "\\" + Path.GetFileName(fn) + "." + Global.Config.MovieExtension, true);
|
||||
File.Delete(fn + "." + Global.Config.MovieExtension);
|
||||
ProcessMovieImport(fn);
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessMovieImport(string fn)
|
||||
{
|
||||
var file = new FileInfo(fn);
|
||||
string d = PathManager.MakeAbsolutePath(Global.Config.MoviesPath, "");
|
||||
string errorMsg = "";
|
||||
string warningMsg = "";
|
||||
Movie m = MovieImport.ImportFile(fn, out errorMsg, out warningMsg);
|
||||
if (errorMsg.Length > 0)
|
||||
MessageBox.Show(errorMsg, "Conversion error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
if (warningMsg.Length > 0)
|
||||
Global.OSD.AddMessage(warningMsg);
|
||||
else
|
||||
Global.OSD.AddMessage(Path.GetFileName(fn) + " imported as " + "Movies\\" +
|
||||
Path.GetFileName(fn) + "." + Global.Config.MovieExtension);
|
||||
if (!Directory.Exists(d))
|
||||
Directory.CreateDirectory(d);
|
||||
|
||||
string outPath = d + "\\" + Path.GetFileName(fn) + "." + Global.Config.MovieExtension;
|
||||
m.WriteMovie(outPath);
|
||||
}
|
||||
|
||||
// workaround for possible memory leak in SysdrawingRenderPanel
|
||||
RetainedViewportPanel captureosd_rvp;
|
||||
|
|
|
@ -307,6 +307,41 @@ namespace BizHawk.MultiClient
|
|||
|
||||
#region Public File Handling
|
||||
|
||||
public void WriteMovie(Stream stream)
|
||||
{
|
||||
if (!Loaded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(new FileInfo(Filename).Directory.FullName);
|
||||
if (IsText)
|
||||
{
|
||||
WriteText(stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteBinary(stream);
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteMovie(string path)
|
||||
{
|
||||
if (!Loaded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Directory.CreateDirectory(new FileInfo(Filename).Directory.FullName);
|
||||
if (IsText)
|
||||
{
|
||||
WriteText(Filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteBinary(Filename);
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteMovie()
|
||||
{
|
||||
if (!Loaded)
|
||||
|
@ -317,16 +352,8 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(new FileInfo(Filename).Directory.FullName);
|
||||
if (IsText)
|
||||
{
|
||||
WriteText(Filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteBinary(Filename);
|
||||
}
|
||||
|
||||
WriteMovie(Filename);
|
||||
}
|
||||
|
||||
public void WriteBackup()
|
||||
|
@ -851,31 +878,40 @@ namespace BizHawk.MultiClient
|
|||
|
||||
#region Helpers
|
||||
|
||||
private void WriteText(string file)
|
||||
private void WriteText(string fn)
|
||||
{
|
||||
if (file.Length > 0)
|
||||
using (var fs = new FileStream(fn, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||
WriteText(fs);
|
||||
}
|
||||
|
||||
private void WriteBinary(string fn)
|
||||
{
|
||||
using (var fs = new FileStream(fn, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||
WriteBinary(fs);
|
||||
}
|
||||
|
||||
|
||||
private void WriteText(Stream stream)
|
||||
{
|
||||
int length = Log.Length;
|
||||
|
||||
using (StreamWriter sw = new StreamWriter(stream))
|
||||
{
|
||||
int length = Log.Length;
|
||||
Header.WriteText(sw);
|
||||
|
||||
using (StreamWriter sw = new StreamWriter(file))
|
||||
//TODO: clean this up
|
||||
if (LoopOffset >= 0)
|
||||
{
|
||||
Header.WriteText(sw);
|
||||
|
||||
//TODO: clean this up
|
||||
if (LoopOffset >= 0)
|
||||
{
|
||||
sw.WriteLine("LoopOffset " + LoopOffset.ToString());
|
||||
}
|
||||
|
||||
Subtitles.WriteText(sw);
|
||||
Log.WriteText(sw);
|
||||
sw.WriteLine("LoopOffset " + LoopOffset.ToString());
|
||||
}
|
||||
|
||||
Subtitles.WriteText(sw);
|
||||
Log.WriteText(sw);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteBinary(string file)
|
||||
private void WriteBinary(Stream stream)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private bool LoadText()
|
||||
|
|
|
@ -84,7 +84,6 @@ namespace BizHawk.MultiClient
|
|||
if (errorMsg == "")
|
||||
{
|
||||
m.Header.SetHeaderLine(MovieHeader.MOVIEVERSION, MovieHeader.MovieVersion);
|
||||
m.WriteMovie();
|
||||
}
|
||||
}
|
||||
catch (Exception except)
|
||||
|
|
Loading…
Reference in New Issue