Fix exception when a "Starts from Now" movie is made with the record movie dialog when the folder selected does not already exist
This commit is contained in:
parent
d5ea2567ba
commit
5fc78efe85
|
@ -31,7 +31,7 @@
|
|||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RecordMovie));
|
||||
this.Cancel = new System.Windows.Forms.Button();
|
||||
this.OK = new System.Windows.Forms.Button();
|
||||
this.Browse = new System.Windows.Forms.Button();
|
||||
this.BrowseBtn = new System.Windows.Forms.Button();
|
||||
this.RecordBox = new System.Windows.Forms.TextBox();
|
||||
this.StartFromCombo = new System.Windows.Forms.ComboBox();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
|
@ -64,18 +64,18 @@
|
|||
this.OK.TabIndex = 0;
|
||||
this.OK.Text = "&Ok";
|
||||
this.OK.UseVisualStyleBackColor = true;
|
||||
this.OK.Click += new System.EventHandler(this.OK_Click);
|
||||
this.OK.Click += new System.EventHandler(this.Ok_Click);
|
||||
//
|
||||
// Browse
|
||||
// BrowseBtn
|
||||
//
|
||||
this.Browse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.Browse.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.OpenFile;
|
||||
this.Browse.Location = new System.Drawing.Point(423, 13);
|
||||
this.Browse.Name = "Browse";
|
||||
this.Browse.Size = new System.Drawing.Size(25, 23);
|
||||
this.Browse.TabIndex = 1;
|
||||
this.Browse.UseVisualStyleBackColor = true;
|
||||
this.Browse.Click += new System.EventHandler(this.button1_Click);
|
||||
this.BrowseBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.BrowseBtn.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.OpenFile;
|
||||
this.BrowseBtn.Location = new System.Drawing.Point(423, 13);
|
||||
this.BrowseBtn.Name = "BrowseBtn";
|
||||
this.BrowseBtn.Size = new System.Drawing.Size(25, 23);
|
||||
this.BrowseBtn.TabIndex = 1;
|
||||
this.BrowseBtn.UseVisualStyleBackColor = true;
|
||||
this.BrowseBtn.Click += new System.EventHandler(this.BrowseBtn_Click);
|
||||
//
|
||||
// RecordBox
|
||||
//
|
||||
|
@ -109,7 +109,7 @@
|
|||
this.groupBox1.Controls.Add(this.DefaultAuthorCheckBox);
|
||||
this.groupBox1.Controls.Add(this.AuthorBox);
|
||||
this.groupBox1.Controls.Add(this.StartFromCombo);
|
||||
this.groupBox1.Controls.Add(this.Browse);
|
||||
this.groupBox1.Controls.Add(this.BrowseBtn);
|
||||
this.groupBox1.Controls.Add(this.label3);
|
||||
this.groupBox1.Controls.Add(this.label2);
|
||||
this.groupBox1.Controls.Add(this.label1);
|
||||
|
@ -197,7 +197,7 @@
|
|||
|
||||
private System.Windows.Forms.Button Cancel;
|
||||
private System.Windows.Forms.Button OK;
|
||||
private System.Windows.Forms.Button Browse;
|
||||
private System.Windows.Forms.Button BrowseBtn;
|
||||
private System.Windows.Forms.TextBox RecordBox;
|
||||
private System.Windows.Forms.ComboBox StartFromCombo;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Emulation.Cores.ColecoVision;
|
||||
using BizHawk.Emulation.Cores.Sega.MasterSystem;
|
||||
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
|
||||
using BizHawk.Emulation.Cores.Nintendo.N64;
|
||||
using BizHawk.Emulation.Cores.Nintendo.NES;
|
||||
using BizHawk.Emulation.Cores.Nintendo.SNES;
|
||||
using BizHawk.Emulation.Cores.Nintendo.N64;
|
||||
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Emulation.Cores.Sega.MasterSystem;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public partial class RecordMovie : Form
|
||||
{
|
||||
//TODO
|
||||
//Allow relative paths in record textbox
|
||||
|
||||
// TODO
|
||||
// Allow relative paths in record textbox
|
||||
public RecordMovie()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -29,6 +28,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
var path = RecordBox.Text;
|
||||
if (path.LastIndexOf(Path.DirectorySeparatorChar) == -1)
|
||||
{
|
||||
|
@ -36,12 +36,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
path = path.Insert(0, Path.DirectorySeparatorChar.ToString());
|
||||
}
|
||||
|
||||
path = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null) + path;
|
||||
|
||||
if (path[path.Length - 4] != '.') //If no file extension, add movie extension
|
||||
if (path[path.Length - 4] != '.') // If no file extension, add movie extension
|
||||
{
|
||||
path += "." + Global.Config.MovieExtension;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
else
|
||||
|
@ -50,7 +52,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
private void OK_Click(object sender, EventArgs e)
|
||||
private void Ok_Click(object sender, EventArgs e)
|
||||
{
|
||||
var path = MakePath();
|
||||
if (!String.IsNullOrWhiteSpace(path))
|
||||
|
@ -69,6 +71,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (StartFromCombo.SelectedItem.ToString() == "Now")
|
||||
{
|
||||
var fileInfo = new FileInfo(path);
|
||||
if (!fileInfo.Exists)
|
||||
{
|
||||
Directory.CreateDirectory(fileInfo.DirectoryName);
|
||||
}
|
||||
|
||||
_movieToRecord = new Movie(path, startsFromSavestate: true);
|
||||
var temppath = path;
|
||||
var writer = new StreamWriter(temppath);
|
||||
|
@ -93,7 +101,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
_movieToRecord = new Movie(path);
|
||||
}
|
||||
|
||||
//Header
|
||||
// Header
|
||||
_movieToRecord.Header[HeaderKeys.AUTHOR] = AuthorBox.Text;
|
||||
_movieToRecord.Header[HeaderKeys.EMULATIONVERSION] = VersionInfo.GetEmuVersion();
|
||||
_movieToRecord.Header[HeaderKeys.MOVIEVERSION] = HeaderKeys.MovieVersion1;
|
||||
|
@ -125,7 +133,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (Global.Emulator is LibsnesCore)
|
||||
{
|
||||
_movieToRecord.Header[HeaderKeys.SGB] = ((Global.Emulator) as LibsnesCore).IsSGB.ToString();
|
||||
_movieToRecord.Header[HeaderKeys.SGB] = (Global.Emulator as LibsnesCore).IsSGB.ToString();
|
||||
if ((Global.Emulator as LibsnesCore).DisplayType == DisplayType.PAL)
|
||||
{
|
||||
_movieToRecord.Header[HeaderKeys.PAL] = "1";
|
||||
|
@ -149,7 +157,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
_movieToRecord.Header[HeaderKeys.SKIPBIOS] = Global.Config.ColecoSkipBiosIntro.ToString();
|
||||
}
|
||||
|
||||
else if (Global.Emulator is N64)
|
||||
{
|
||||
_movieToRecord.Header[HeaderKeys.VIDEOPLUGIN] = Global.Config.N64VidPlugin;
|
||||
|
@ -157,7 +164,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (Global.Config.N64VidPlugin == "Rice")
|
||||
{
|
||||
var rice_settings = Global.Config.RicePlugin.GetPluginSettings();
|
||||
foreach(var setting in rice_settings)
|
||||
foreach (var setting in rice_settings)
|
||||
{
|
||||
_movieToRecord.Header[setting.Key] = setting.Value.ToString();
|
||||
}
|
||||
|
@ -184,13 +191,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
Global.Config.DefaultAuthor = AuthorBox.Text;
|
||||
}
|
||||
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Please select a movie to record", "File selection error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Cancel_Click(object sender, EventArgs e)
|
||||
|
@ -198,7 +205,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
Close();
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
private void BrowseBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
var filename = String.Empty;
|
||||
var sfd = new SaveFileDialog
|
||||
|
|
Loading…
Reference in New Issue