Play Movie - include subdirectories option, fix a crash bug

This commit is contained in:
andres.delikat 2011-07-10 18:21:43 +00:00
parent 58ac4b176f
commit be20aa3af8
2 changed files with 55 additions and 11 deletions

View File

@ -45,6 +45,7 @@
this.button1 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.MovieCount = new System.Windows.Forms.Label(); this.MovieCount = new System.Windows.Forms.Label();
this.ReadOnlyCheckBox = new System.Windows.Forms.CheckBox(); this.ReadOnlyCheckBox = new System.Windows.Forms.CheckBox();
this.IncludeSubDirectories = new System.Windows.Forms.CheckBox();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -52,7 +53,7 @@
// //
this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.Cancel.Location = new System.Drawing.Point(628, 361); this.Cancel.Location = new System.Drawing.Point(628, 352);
this.Cancel.Name = "Cancel"; this.Cancel.Name = "Cancel";
this.Cancel.Size = new System.Drawing.Size(75, 23); this.Cancel.Size = new System.Drawing.Size(75, 23);
this.Cancel.TabIndex = 0; this.Cancel.TabIndex = 0;
@ -63,7 +64,7 @@
// OK // OK
// //
this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.OK.Location = new System.Drawing.Point(537, 361); this.OK.Location = new System.Drawing.Point(547, 352);
this.OK.Name = "OK"; this.OK.Name = "OK";
this.OK.Size = new System.Drawing.Size(75, 23); this.OK.Size = new System.Drawing.Size(75, 23);
this.OK.TabIndex = 1; this.OK.TabIndex = 1;
@ -73,7 +74,8 @@
// //
// BrowseMovies // BrowseMovies
// //
this.BrowseMovies.Location = new System.Drawing.Point(12, 366); this.BrowseMovies.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.BrowseMovies.Location = new System.Drawing.Point(12, 352);
this.BrowseMovies.Name = "BrowseMovies"; this.BrowseMovies.Name = "BrowseMovies";
this.BrowseMovies.Size = new System.Drawing.Size(75, 23); this.BrowseMovies.Size = new System.Drawing.Size(75, 23);
this.BrowseMovies.TabIndex = 2; this.BrowseMovies.TabIndex = 2;
@ -132,6 +134,9 @@
// //
// DetailsView // DetailsView
// //
this.DetailsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.DetailsView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.DetailsView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader5, this.columnHeader5,
this.columnHeader6}); this.columnHeader6});
@ -139,7 +144,7 @@
this.DetailsView.GridLines = true; this.DetailsView.GridLines = true;
this.DetailsView.Location = new System.Drawing.Point(15, 19); this.DetailsView.Location = new System.Drawing.Point(15, 19);
this.DetailsView.Name = "DetailsView"; this.DetailsView.Name = "DetailsView";
this.DetailsView.Size = new System.Drawing.Size(228, 226); this.DetailsView.Size = new System.Drawing.Size(228, 242);
this.DetailsView.TabIndex = 4; this.DetailsView.TabIndex = 4;
this.DetailsView.UseCompatibleStateImageBehavior = false; this.DetailsView.UseCompatibleStateImageBehavior = false;
this.DetailsView.View = System.Windows.Forms.View.Details; this.DetailsView.View = System.Windows.Forms.View.Details;
@ -156,6 +161,8 @@
// //
// groupBox1 // groupBox1
// //
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.button2); this.groupBox1.Controls.Add(this.button2);
this.groupBox1.Controls.Add(this.button1); this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Controls.Add(this.DetailsView); this.groupBox1.Controls.Add(this.DetailsView);
@ -168,8 +175,9 @@
// //
// button2 // button2
// //
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button2.Enabled = false; this.button2.Enabled = false;
this.button2.Location = new System.Drawing.Point(125, 251); this.button2.Location = new System.Drawing.Point(125, 267);
this.button2.Name = "button2"; this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23); this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 6; this.button2.TabIndex = 6;
@ -179,8 +187,9 @@
// //
// button1 // button1
// //
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.button1.Enabled = false; this.button1.Enabled = false;
this.button1.Location = new System.Drawing.Point(15, 251); this.button1.Location = new System.Drawing.Point(15, 267);
this.button1.Name = "button1"; this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23); this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 5; this.button1.TabIndex = 5;
@ -191,7 +200,7 @@
// MovieCount // MovieCount
// //
this.MovieCount.AutoSize = true; this.MovieCount.AutoSize = true;
this.MovieCount.Location = new System.Drawing.Point(13, 338); this.MovieCount.Location = new System.Drawing.Point(12, 9);
this.MovieCount.Name = "MovieCount"; this.MovieCount.Name = "MovieCount";
this.MovieCount.Size = new System.Drawing.Size(31, 13); this.MovieCount.Size = new System.Drawing.Size(31, 13);
this.MovieCount.TabIndex = 7; this.MovieCount.TabIndex = 7;
@ -199,23 +208,37 @@
// //
// ReadOnlyCheckBox // ReadOnlyCheckBox
// //
this.ReadOnlyCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ReadOnlyCheckBox.AutoSize = true; this.ReadOnlyCheckBox.AutoSize = true;
this.ReadOnlyCheckBox.Checked = true; this.ReadOnlyCheckBox.Checked = true;
this.ReadOnlyCheckBox.CheckState = System.Windows.Forms.CheckState.Checked; this.ReadOnlyCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.ReadOnlyCheckBox.Location = new System.Drawing.Point(131, 370); this.ReadOnlyCheckBox.Location = new System.Drawing.Point(444, 356);
this.ReadOnlyCheckBox.Name = "ReadOnlyCheckBox"; this.ReadOnlyCheckBox.Name = "ReadOnlyCheckBox";
this.ReadOnlyCheckBox.Size = new System.Drawing.Size(74, 17); this.ReadOnlyCheckBox.Size = new System.Drawing.Size(74, 17);
this.ReadOnlyCheckBox.TabIndex = 8; this.ReadOnlyCheckBox.TabIndex = 8;
this.ReadOnlyCheckBox.Text = "Read only"; this.ReadOnlyCheckBox.Text = "Read only";
this.ReadOnlyCheckBox.UseVisualStyleBackColor = true; this.ReadOnlyCheckBox.UseVisualStyleBackColor = true;
// //
// IncludeSubDirectories
//
this.IncludeSubDirectories.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.IncludeSubDirectories.AutoSize = true;
this.IncludeSubDirectories.Location = new System.Drawing.Point(107, 356);
this.IncludeSubDirectories.Name = "IncludeSubDirectories";
this.IncludeSubDirectories.Size = new System.Drawing.Size(131, 17);
this.IncludeSubDirectories.TabIndex = 9;
this.IncludeSubDirectories.Text = "Include Subdirectories";
this.IncludeSubDirectories.UseVisualStyleBackColor = true;
this.IncludeSubDirectories.CheckedChanged += new System.EventHandler(this.IncludeSubDirectories_CheckedChanged);
//
// PlayMovie // PlayMovie
// //
this.AcceptButton = this.OK; this.AcceptButton = this.OK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.Cancel; this.CancelButton = this.Cancel;
this.ClientSize = new System.Drawing.Size(715, 401); this.ClientSize = new System.Drawing.Size(715, 387);
this.Controls.Add(this.IncludeSubDirectories);
this.Controls.Add(this.ReadOnlyCheckBox); this.Controls.Add(this.ReadOnlyCheckBox);
this.Controls.Add(this.MovieCount); this.Controls.Add(this.MovieCount);
this.Controls.Add(this.groupBox1); this.Controls.Add(this.groupBox1);
@ -253,5 +276,6 @@
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label MovieCount; private System.Windows.Forms.Label MovieCount;
private System.Windows.Forms.CheckBox ReadOnlyCheckBox; private System.Windows.Forms.CheckBox ReadOnlyCheckBox;
private System.Windows.Forms.CheckBox IncludeSubDirectories;
} }
} }

View File

@ -12,7 +12,6 @@ namespace BizHawk.MultiClient
{ {
public partial class PlayMovie : Form public partial class PlayMovie : Form
{ {
// Option to include subdirectories
// Option to include savestate files (that have an input log) // Option to include savestate files (that have an input log)
List<Movie> MovieList = new List<Movie>(); List<Movie> MovieList = new List<Movie>();
@ -160,7 +159,7 @@ namespace BizHawk.MultiClient
//Pull out matching names //Pull out matching names
for (int x = 0; x < MovieList.Count; x++) for (int x = 0; x < MovieList.Count; x++)
{ {
if (Global.Game.FilesystemSafeName == Path.GetFileNameWithoutExtension(MovieList[x].GetGameName())) if (Global.Game.FilesystemSafeName == MovieList[x].GetGameName())
Indexes.Add(x); Indexes.Add(x);
} }
if (Indexes.Count == 0) return; if (Indexes.Count == 0) return;
@ -214,9 +213,11 @@ namespace BizHawk.MultiClient
private void PlayMovie_Load(object sender, EventArgs e) private void PlayMovie_Load(object sender, EventArgs e)
{ {
IncludeSubDirectories.Checked = Global.Config.PlayMovie_IncludeSubdir;
string d = PathManager.MakeAbsolutePath(Global.Config.MoviesPath, ""); string d = PathManager.MakeAbsolutePath(Global.Config.MoviesPath, "");
if (!Directory.Exists(d)) if (!Directory.Exists(d))
Directory.CreateDirectory(d); Directory.CreateDirectory(d);
foreach (string f in Directory.GetFiles(d, "*.tas")) foreach (string f in Directory.GetFiles(d, "*.tas"))
AddMovieToList(f); AddMovieToList(f);
foreach (string f in Directory.GetFiles(d, "*.fm2")) foreach (string f in Directory.GetFiles(d, "*.fm2"))
@ -224,6 +225,20 @@ namespace BizHawk.MultiClient
foreach (string f in Directory.GetFiles(d, "*.mc2")) foreach (string f in Directory.GetFiles(d, "*.mc2"))
AddMovieToList(f); AddMovieToList(f);
if (Global.Config.PlayMovie_IncludeSubdir)
{
string[] subs = Directory.GetDirectories(d);
foreach (string dir in subs)
{
foreach (string f in Directory.GetFiles(dir, "*.tas"))
AddMovieToList(f);
foreach (string f in Directory.GetFiles(dir, "*.fm2"))
AddMovieToList(f);
foreach (string f in Directory.GetFiles(dir, "*.mc2"))
AddMovieToList(f);
}
}
PreHighlightMovie(); PreHighlightMovie();
} }
@ -310,5 +325,10 @@ namespace BizHawk.MultiClient
MovieView.Refresh(); MovieView.Refresh();
} }
private void IncludeSubDirectories_CheckedChanged(object sender, EventArgs e)
{
Global.Config.PlayMovie_IncludeSubdir = IncludeSubDirectories.Checked;
}
} }
} }