Play Movie - clean up some code before I go fixing things
This commit is contained in:
parent
00d5c4d5ae
commit
bca069325b
|
@ -3,20 +3,20 @@ using System.Drawing;
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used for the sorting of the moviedetails in PlayMovie.cs
|
/// Used for the sorting of the moviedetails in PlayMovie.cs
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MovieDetails
|
public class MovieDetails
|
||||||
{
|
{
|
||||||
public String keys { get; set; }
|
public string Keys { get; set; }
|
||||||
public String values { get; set; }
|
public string Values { get; set; }
|
||||||
public Color backgroundColor { get; set; }
|
public Color BackgroundColor { get; set; }
|
||||||
|
|
||||||
public MovieDetails()
|
public MovieDetails()
|
||||||
{
|
{
|
||||||
keys = String.Empty;
|
Keys = string.Empty;
|
||||||
values = String.Empty;
|
Values = string.Empty;
|
||||||
backgroundColor = Color.White;
|
BackgroundColor = Color.White;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
this.OK.Text = "&Ok";
|
this.OK.Text = "&Ok";
|
||||||
this.toolTip1.SetToolTip(this.OK, "Load selected movie");
|
this.toolTip1.SetToolTip(this.OK, "Load selected movie");
|
||||||
this.OK.UseVisualStyleBackColor = true;
|
this.OK.UseVisualStyleBackColor = true;
|
||||||
this.OK.Click += new System.EventHandler(this.OK_Click);
|
this.OK.Click += new System.EventHandler(this.Ok_Click);
|
||||||
//
|
//
|
||||||
// BrowseMovies
|
// BrowseMovies
|
||||||
//
|
//
|
||||||
|
@ -144,7 +144,7 @@
|
||||||
this.SubtitlesBtn.TabIndex = 20;
|
this.SubtitlesBtn.TabIndex = 20;
|
||||||
this.SubtitlesBtn.Text = "Subtitles";
|
this.SubtitlesBtn.Text = "Subtitles";
|
||||||
this.SubtitlesBtn.UseVisualStyleBackColor = true;
|
this.SubtitlesBtn.UseVisualStyleBackColor = true;
|
||||||
this.SubtitlesBtn.Click += new System.EventHandler(this.button2_Click);
|
this.SubtitlesBtn.Click += new System.EventHandler(this.SubtitlesBtn_Click);
|
||||||
//
|
//
|
||||||
// CommentsBtn
|
// CommentsBtn
|
||||||
//
|
//
|
||||||
|
@ -156,7 +156,7 @@
|
||||||
this.CommentsBtn.TabIndex = 15;
|
this.CommentsBtn.TabIndex = 15;
|
||||||
this.CommentsBtn.Text = "Comments";
|
this.CommentsBtn.Text = "Comments";
|
||||||
this.CommentsBtn.UseVisualStyleBackColor = true;
|
this.CommentsBtn.UseVisualStyleBackColor = true;
|
||||||
this.CommentsBtn.Click += new System.EventHandler(this.button1_Click);
|
this.CommentsBtn.Click += new System.EventHandler(this.CommentsBtn_Click);
|
||||||
//
|
//
|
||||||
// MovieCount
|
// MovieCount
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
using BizHawk.Common;
|
|
||||||
using BizHawk.Client.Common;
|
using BizHawk.Client.Common;
|
||||||
|
using BizHawk.Common;
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
|
@ -26,93 +26,54 @@ namespace BizHawk.Client.EmuHawk
|
||||||
MovieView.QueryItemText += MovieView_QueryItemText;
|
MovieView.QueryItemText += MovieView_QueryItemText;
|
||||||
MovieView.VirtualMode = true;
|
MovieView.VirtualMode = true;
|
||||||
_sortReverse = false;
|
_sortReverse = false;
|
||||||
_sortedCol = String.Empty;
|
_sortedCol = string.Empty;
|
||||||
|
|
||||||
_sortDetailsReverse = false;
|
_sortDetailsReverse = false;
|
||||||
_sortedDetailsCol = String.Empty;
|
_sortedDetailsCol = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MovieView_QueryItemText(int index, int column, out string text)
|
private void PlayMovie_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
text = String.Empty;
|
IncludeSubDirectories.Checked = Global.Config.PlayMovie_IncludeSubdir;
|
||||||
if (column == 0) //File
|
ShowStateFiles.Checked = Global.Config.PlayMovie_ShowStateFiles;
|
||||||
|
MatchGameNameCheckBox.Checked = Global.Config.PlayMovie_MatchGameName;
|
||||||
|
ScanFiles();
|
||||||
|
PreHighlightMovie();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MovieView_QueryItemText(int index, int column, out string text)
|
||||||
|
{
|
||||||
|
text = string.Empty;
|
||||||
|
if (column == 0) // File
|
||||||
{
|
{
|
||||||
text = Path.GetFileName(_movieList[index].Filename);
|
text = Path.GetFileName(_movieList[index].Filename);
|
||||||
}
|
}
|
||||||
if (column == 1) //System
|
|
||||||
|
if (column == 1) // System
|
||||||
{
|
{
|
||||||
text = _movieList[index].Header.SystemID;
|
text = _movieList[index].Header.SystemID;
|
||||||
}
|
}
|
||||||
if (column == 2) //Game
|
|
||||||
|
if (column == 2) // Game
|
||||||
{
|
{
|
||||||
text = _movieList[index].Header.GameName;
|
text = _movieList[index].Header.GameName;
|
||||||
}
|
}
|
||||||
if (column == 3) //Time
|
|
||||||
|
if (column == 3) // Time
|
||||||
{
|
{
|
||||||
text = _movieList[index].Time.ToString(@"hh\:mm\:ss\.fff");
|
text = _movieList[index].Time.ToString(@"hh\:mm\:ss\.fff");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Cancel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Run()
|
private void Run()
|
||||||
{
|
{
|
||||||
var indices = MovieView.SelectedIndices;
|
var indices = MovieView.SelectedIndices;
|
||||||
if (indices.Count > 0) //Import file if necessary
|
if (indices.Count > 0) // Import file if necessary
|
||||||
{
|
{
|
||||||
GlobalWin.MainForm.StartNewMovie(_movieList[MovieView.SelectedIndices[0]], false);
|
GlobalWin.MainForm.StartNewMovie(_movieList[MovieView.SelectedIndices[0]], false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OK_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Run();
|
|
||||||
Global.MovieSession.ReadOnly = ReadOnlyCheckBox.Checked;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void BrowseMovies_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var ofd = new OpenFileDialog { InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null) };
|
|
||||||
var filter = "Movie Files (*." + Global.Config.MovieExtension + ")|*." + Global.Config.MovieExtension + "|Savestates|*.state|All Files|*.*";
|
|
||||||
ofd.Filter = filter;
|
|
||||||
|
|
||||||
var result = ofd.ShowHawkDialog();
|
|
||||||
if (result == DialogResult.OK)
|
|
||||||
{
|
|
||||||
var file = new FileInfo(ofd.FileName);
|
|
||||||
if (!file.Exists)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (file.Extension.ToUpper() == "STATE")
|
|
||||||
{
|
|
||||||
var movie = new Movie(file.FullName);
|
|
||||||
movie.Load(); //State files will have to load everything unfortunately
|
|
||||||
if (movie.FrameCount == 0)
|
|
||||||
{
|
|
||||||
MessageBox.Show("No input log detected in this savestate, aborting", "Can not load file", MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Hand);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int? index = AddMovieToList(ofd.FileName, true);
|
|
||||||
if (index.HasValue)
|
|
||||||
{
|
|
||||||
MovieView.SelectedIndices.Clear();
|
|
||||||
MovieView.setSelection(index.Value);
|
|
||||||
MovieView.SelectItem(index.Value, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AddStateToList(string filename)
|
private void AddStateToList(string filename)
|
||||||
{
|
{
|
||||||
using (var file = new HawkFile(filename))
|
using (var file = new HawkFile(filename))
|
||||||
|
@ -122,12 +83,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
if (!IsDuplicateOf(filename).HasValue)
|
if (!IsDuplicateOf(filename).HasValue)
|
||||||
{
|
{
|
||||||
var movie = new Movie(file.CanonicalFullPath);
|
var movie = new Movie(file.CanonicalFullPath);
|
||||||
movie.Load(); //State files will have to load everything unfortunately
|
movie.Load(); // State files will have to load everything unfortunately
|
||||||
if (movie.FrameCount > 0)
|
if (movie.FrameCount > 0)
|
||||||
{
|
{
|
||||||
_movieList.Add(movie);
|
_movieList.Add(movie);
|
||||||
_sortReverse = false;
|
_sortReverse = false;
|
||||||
_sortedCol = String.Empty;
|
_sortedCol = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,27 +103,26 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
var index = IsDuplicateOf(filename);
|
||||||
|
if (!index.HasValue)
|
||||||
{
|
{
|
||||||
int? index = IsDuplicateOf(filename);
|
PreLoadMovieFile(file, force);
|
||||||
if (!index.HasValue)
|
MovieView.ItemCount = _movieList.Count;
|
||||||
{
|
UpdateList();
|
||||||
PreLoadMovieFile(file, force);
|
|
||||||
MovieView.ItemCount = _movieList.Count;
|
|
||||||
UpdateList();
|
|
||||||
|
|
||||||
_sortReverse = false;
|
_sortReverse = false;
|
||||||
_sortedCol = String.Empty;
|
_sortedCol = string.Empty;
|
||||||
index = _movieList.Count - 1;
|
index = _movieList.Count - 1;
|
||||||
}
|
|
||||||
return index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int? IsDuplicateOf(string filename)
|
private int? IsDuplicateOf(string filename)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _movieList.Count; i++)
|
for (var i = 0; i < _movieList.Count; i++)
|
||||||
{
|
{
|
||||||
if (_movieList[i].Filename == filename)
|
if (_movieList[i].Filename == filename)
|
||||||
{
|
{
|
||||||
|
@ -179,7 +139,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
movie.PreLoadText(hf);
|
movie.PreLoadText(hf);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Don't do this from browse
|
// Don't do this from browse
|
||||||
if (movie.Header[HeaderKeys.GAMENAME] == Global.Game.Name ||
|
if (movie.Header[HeaderKeys.GAMENAME] == Global.Game.Name ||
|
||||||
Global.Config.PlayMovie_MatchGameName == false || force)
|
Global.Config.PlayMovie_MatchGameName == false || force)
|
||||||
{
|
{
|
||||||
|
@ -195,72 +155,76 @@ namespace BizHawk.Client.EmuHawk
|
||||||
private void UpdateList()
|
private void UpdateList()
|
||||||
{
|
{
|
||||||
MovieView.Refresh();
|
MovieView.Refresh();
|
||||||
UpdateMovieCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateMovieCount()
|
|
||||||
{
|
|
||||||
MovieCount.Text = _movieList.Count + " movie"
|
MovieCount.Text = _movieList.Count + " movie"
|
||||||
+ (_movieList.Count != 1 ? "s" : String.Empty);
|
+ (_movieList.Count != 1 ? "s" : string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PreHighlightMovie()
|
private void PreHighlightMovie()
|
||||||
{
|
{
|
||||||
if (Global.Game == null) return;
|
if (Global.Game == null)
|
||||||
var Indices = new List<int>();
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Pull out matching names
|
var indices = new List<int>();
|
||||||
for (int i = 0; i < _movieList.Count; i++)
|
|
||||||
|
// Pull out matching names
|
||||||
|
for (var i = 0; i < _movieList.Count; i++)
|
||||||
{
|
{
|
||||||
if (PathManager.FilesystemSafeName(Global.Game) == _movieList[i].Header.GameName)
|
if (PathManager.FilesystemSafeName(Global.Game) == _movieList[i].Header.GameName)
|
||||||
{
|
{
|
||||||
Indices.Add(i);
|
indices.Add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Indices.Count == 0) return;
|
|
||||||
if (Indices.Count == 1)
|
if (indices.Count == 0)
|
||||||
{
|
{
|
||||||
HighlightMovie(Indices[0]);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Prefer tas files
|
if (indices.Count == 1)
|
||||||
var TAS = new List<int>();
|
|
||||||
for (int i = 0; i < Indices.Count; i++)
|
|
||||||
{
|
{
|
||||||
if (Path.GetExtension(_movieList[Indices[i]].Filename).ToUpper() == "." + Global.Config.MovieExtension)
|
HighlightMovie(indices[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prefer tas files
|
||||||
|
var tas = new List<int>();
|
||||||
|
for (var i = 0; i < indices.Count; i++)
|
||||||
|
{
|
||||||
|
if (Path.GetExtension(_movieList[indices[i]].Filename).ToUpper() == "." + Global.Config.MovieExtension)
|
||||||
{
|
{
|
||||||
TAS.Add(i);
|
tas.Add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TAS.Count == 1)
|
if (tas.Count == 1)
|
||||||
{
|
{
|
||||||
HighlightMovie(TAS[0]);
|
HighlightMovie(tas[0]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (TAS.Count > 1)
|
|
||||||
|
if (tas.Count > 1)
|
||||||
{
|
{
|
||||||
Indices = new List<int>(TAS);
|
indices = new List<int>(tas);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Final tie breaker - Last used file
|
// Final tie breaker - Last used file
|
||||||
var file = new FileInfo(_movieList[Indices[0]].Filename);
|
var file = new FileInfo(_movieList[indices[0]].Filename);
|
||||||
var time = file.LastAccessTime;
|
var time = file.LastAccessTime;
|
||||||
int mostRecent = Indices.First();
|
var mostRecent = indices.First();
|
||||||
for (int i = 1; i < Indices.Count; i++)
|
for (var i = 1; i < indices.Count; i++)
|
||||||
{
|
{
|
||||||
file = new FileInfo(_movieList[Indices[0]].Filename);
|
file = new FileInfo(_movieList[indices[0]].Filename);
|
||||||
if (file.LastAccessTime > time)
|
if (file.LastAccessTime > time)
|
||||||
{
|
{
|
||||||
time = file.LastAccessTime;
|
time = file.LastAccessTime;
|
||||||
mostRecent = Indices[i];
|
mostRecent = indices[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HighlightMovie(mostRecent);
|
HighlightMovie(mostRecent);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HighlightMovie(int index)
|
private void HighlightMovie(int index)
|
||||||
|
@ -270,16 +234,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
MovieView.SelectItem(index, true);
|
MovieView.SelectItem(index, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClearList()
|
private void ScanFiles()
|
||||||
{
|
{
|
||||||
_movieList.Clear();
|
_movieList.Clear();
|
||||||
MovieView.ItemCount = 0;
|
MovieView.ItemCount = 0;
|
||||||
MovieView.Update();
|
MovieView.Update();
|
||||||
}
|
|
||||||
|
|
||||||
private void ScanFiles()
|
|
||||||
{
|
|
||||||
ClearList();
|
|
||||||
|
|
||||||
var directory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null);
|
var directory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null);
|
||||||
if (!Directory.Exists(directory))
|
if (!Directory.Exists(directory))
|
||||||
|
@ -295,7 +254,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
Directory.GetFiles(directory, "*.state")
|
Directory.GetFiles(directory, "*.state")
|
||||||
.ToList()
|
.ToList()
|
||||||
.ForEach(file => AddStateToList(file));
|
.ForEach(AddStateToList);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Global.Config.PlayMovie_IncludeSubdir)
|
if (Global.Config.PlayMovie_IncludeSubdir)
|
||||||
|
@ -309,113 +268,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
Directory.GetFiles(dir, "*.state")
|
Directory.GetFiles(dir, "*.state")
|
||||||
.ToList()
|
.ToList()
|
||||||
.ForEach(file => AddStateToList(file));
|
.ForEach(AddStateToList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PlayMovie_Load(object sender, EventArgs e)
|
#region Events
|
||||||
{
|
|
||||||
IncludeSubDirectories.Checked = Global.Config.PlayMovie_IncludeSubdir;
|
|
||||||
ShowStateFiles.Checked = Global.Config.PlayMovie_ShowStateFiles;
|
|
||||||
MatchGameNameCheckBox.Checked = Global.Config.PlayMovie_MatchGameName;
|
|
||||||
ScanFiles();
|
|
||||||
PreHighlightMovie();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MovieView_SelectedIndexChanged(object sender, EventArgs e)
|
#region Movie List
|
||||||
{
|
|
||||||
toolTip1.SetToolTip(DetailsView, String.Empty);
|
|
||||||
DetailsView.Items.Clear();
|
|
||||||
if (MovieView.SelectedIndices.Count < 1)
|
|
||||||
{
|
|
||||||
OK.Enabled = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
OK.Enabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int firstIndex = MovieView.SelectedIndices[0];
|
|
||||||
MovieView.ensureVisible(firstIndex);
|
|
||||||
|
|
||||||
foreach (var kvp in _movieList[firstIndex].Header)
|
|
||||||
{
|
|
||||||
var item = new ListViewItem(kvp.Key);
|
|
||||||
item.SubItems.Add(kvp.Value);
|
|
||||||
|
|
||||||
switch (kvp.Key)
|
|
||||||
{
|
|
||||||
case HeaderKeys.SHA1:
|
|
||||||
if (kvp.Value != Global.Game.Hash)
|
|
||||||
{
|
|
||||||
item.BackColor = Color.Pink;
|
|
||||||
toolTip1.SetToolTip(DetailsView, "Current SHA1: " + Global.Game.Hash);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case HeaderKeys.MOVIEVERSION:
|
|
||||||
if (kvp.Value != HeaderKeys.MovieVersion1)
|
|
||||||
{
|
|
||||||
item.BackColor = Color.Yellow;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case HeaderKeys.EMULATIONVERSION:
|
|
||||||
if (kvp.Value != VersionInfo.GetEmuVersion())
|
|
||||||
{
|
|
||||||
item.BackColor = Color.Yellow;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case HeaderKeys.PLATFORM:
|
|
||||||
if (kvp.Value != Global.Game.System)
|
|
||||||
{
|
|
||||||
item.BackColor = Color.Pink;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
DetailsView.Items.Add(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
var FpsItem = new ListViewItem("Fps");
|
|
||||||
FpsItem.SubItems.Add(String.Format("{0:0.#######}", _movieList[firstIndex].Fps));
|
|
||||||
DetailsView.Items.Add(FpsItem);
|
|
||||||
|
|
||||||
var FramesItem = new ListViewItem("Frames");
|
|
||||||
FramesItem.SubItems.Add(_movieList[firstIndex].FrameCount.ToString());
|
|
||||||
DetailsView.Items.Add(FramesItem);
|
|
||||||
CommentsBtn.Enabled = _movieList[firstIndex].Header.Comments.Any();
|
|
||||||
SubtitlesBtn.Enabled = _movieList[firstIndex].Header.Subtitles.Any();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void button1_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var indices = MovieView.SelectedIndices;
|
|
||||||
if (indices.Count > 0)
|
|
||||||
{
|
|
||||||
var form = new EditCommentsForm();
|
|
||||||
form.GetMovie(_movieList[MovieView.SelectedIndices[0]]);
|
|
||||||
form.Show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void button2_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var indices = MovieView.SelectedIndices;
|
|
||||||
if (indices.Count > 0)
|
|
||||||
{
|
|
||||||
var s = new EditSubtitlesForm { ReadOnly = true };
|
|
||||||
s.GetMovie(_movieList[MovieView.SelectedIndices[0]]);
|
|
||||||
s.Show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MovieView_DoubleClick(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Run();
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MovieView_DragEnter(object sender, DragEventArgs e)
|
private void MovieView_DragEnter(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -432,14 +292,38 @@ namespace BizHawk.Client.EmuHawk
|
||||||
.ForEach(path => AddMovieToList(path, force: true));
|
.ForEach(path => AddMovieToList(path, force: true));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MovieView_ColumnClick(object sender, ColumnClickEventArgs e)
|
private void MovieView_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
OrderColumn(e.Column);
|
if (e.Control && e.KeyCode == Keys.C)
|
||||||
|
{
|
||||||
|
var indexes = MovieView.SelectedIndices;
|
||||||
|
if (indexes.Count > 0)
|
||||||
|
{
|
||||||
|
var copyStr = new StringBuilder();
|
||||||
|
foreach (int index in indexes)
|
||||||
|
{
|
||||||
|
copyStr
|
||||||
|
.Append(_movieList[index].Filename).Append('\t')
|
||||||
|
.Append(_movieList[index].Header.SystemID).Append('\t')
|
||||||
|
.Append(_movieList[index].Header.GameName).Append('\t')
|
||||||
|
.Append(_movieList[index].Time.ToString(@"hh\:mm\:ss\.fff"))
|
||||||
|
.AppendLine();
|
||||||
|
|
||||||
|
Clipboard.SetDataObject(copyStr.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OrderColumn(int columnToOrder)
|
private void MovieView_DoubleClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var columnName = MovieView.Columns[columnToOrder].Text;
|
Run();
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MovieView_ColumnClick(object sender, ColumnClickEventArgs e)
|
||||||
|
{
|
||||||
|
var columnName = MovieView.Columns[e.Column].Text;
|
||||||
if (_sortedCol != columnName)
|
if (_sortedCol != columnName)
|
||||||
{
|
{
|
||||||
_sortReverse = false;
|
_sortReverse = false;
|
||||||
|
@ -534,6 +418,214 @@ namespace BizHawk.Client.EmuHawk
|
||||||
MovieView.Refresh();
|
MovieView.Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MovieView_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
toolTip1.SetToolTip(DetailsView, string.Empty);
|
||||||
|
DetailsView.Items.Clear();
|
||||||
|
if (MovieView.SelectedIndices.Count < 1)
|
||||||
|
{
|
||||||
|
OK.Enabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
OK.Enabled = true;
|
||||||
|
|
||||||
|
var firstIndex = MovieView.SelectedIndices[0];
|
||||||
|
MovieView.ensureVisible(firstIndex);
|
||||||
|
|
||||||
|
foreach (var kvp in _movieList[firstIndex].Header)
|
||||||
|
{
|
||||||
|
var item = new ListViewItem(kvp.Key);
|
||||||
|
item.SubItems.Add(kvp.Value);
|
||||||
|
|
||||||
|
switch (kvp.Key)
|
||||||
|
{
|
||||||
|
case HeaderKeys.SHA1:
|
||||||
|
if (kvp.Value != Global.Game.Hash)
|
||||||
|
{
|
||||||
|
item.BackColor = Color.Pink;
|
||||||
|
toolTip1.SetToolTip(DetailsView, "Current SHA1: " + Global.Game.Hash);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case HeaderKeys.MOVIEVERSION:
|
||||||
|
if (kvp.Value != HeaderKeys.MovieVersion1)
|
||||||
|
{
|
||||||
|
item.BackColor = Color.Yellow;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case HeaderKeys.EMULATIONVERSION:
|
||||||
|
if (kvp.Value != VersionInfo.GetEmuVersion())
|
||||||
|
{
|
||||||
|
item.BackColor = Color.Yellow;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case HeaderKeys.PLATFORM:
|
||||||
|
if (kvp.Value != Global.Game.System)
|
||||||
|
{
|
||||||
|
item.BackColor = Color.Pink;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
DetailsView.Items.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
var FpsItem = new ListViewItem("Fps");
|
||||||
|
FpsItem.SubItems.Add(string.Format("{0:0.#######}", _movieList[firstIndex].Fps));
|
||||||
|
DetailsView.Items.Add(FpsItem);
|
||||||
|
|
||||||
|
var FramesItem = new ListViewItem("Frames");
|
||||||
|
FramesItem.SubItems.Add(_movieList[firstIndex].FrameCount.ToString());
|
||||||
|
DetailsView.Items.Add(FramesItem);
|
||||||
|
CommentsBtn.Enabled = _movieList[firstIndex].Header.Comments.Any();
|
||||||
|
SubtitlesBtn.Enabled = _movieList[firstIndex].Header.Subtitles.Any();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Details
|
||||||
|
|
||||||
|
private void DetailsView_ColumnClick(object sender, ColumnClickEventArgs e)
|
||||||
|
{
|
||||||
|
var detailsList = new List<MovieDetails>();
|
||||||
|
for (var i = 0; i < DetailsView.Items.Count; i++)
|
||||||
|
{
|
||||||
|
detailsList.Add(new MovieDetails
|
||||||
|
{
|
||||||
|
Keys = DetailsView.Items[i].Text,
|
||||||
|
Values = DetailsView.Items[i].SubItems[1].Text,
|
||||||
|
BackgroundColor = DetailsView.Items[i].BackColor
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var columnName = DetailsView.Columns[e.Column].Text;
|
||||||
|
if (_sortedDetailsCol != columnName)
|
||||||
|
{
|
||||||
|
_sortDetailsReverse = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (columnName)
|
||||||
|
{
|
||||||
|
// Header, Value
|
||||||
|
case "Header":
|
||||||
|
if (_sortDetailsReverse)
|
||||||
|
{
|
||||||
|
detailsList = detailsList
|
||||||
|
.OrderByDescending(x => x.Keys)
|
||||||
|
.ThenBy(x => x.Values).ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
detailsList = detailsList
|
||||||
|
.OrderBy(x => x.Keys)
|
||||||
|
.ThenBy(x => x.Values).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "Value":
|
||||||
|
if (_sortDetailsReverse)
|
||||||
|
{
|
||||||
|
detailsList = detailsList
|
||||||
|
.OrderByDescending(x => x.Values)
|
||||||
|
.ThenBy(x => x.Keys).ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
detailsList = detailsList
|
||||||
|
.OrderBy(x => x.Values)
|
||||||
|
.ThenBy(x => x.Keys).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
DetailsView.Items.Clear();
|
||||||
|
foreach (var detail in detailsList)
|
||||||
|
{
|
||||||
|
var item = new ListViewItem { Text = detail.Keys, BackColor = detail.BackgroundColor };
|
||||||
|
item.SubItems.Add(detail.Values);
|
||||||
|
DetailsView.Items.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
_sortedDetailsCol = columnName;
|
||||||
|
_sortDetailsReverse = !_sortDetailsReverse;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CommentsBtn_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var indices = MovieView.SelectedIndices;
|
||||||
|
if (indices.Count > 0)
|
||||||
|
{
|
||||||
|
var form = new EditCommentsForm();
|
||||||
|
form.GetMovie(_movieList[MovieView.SelectedIndices[0]]);
|
||||||
|
form.Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SubtitlesBtn_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var indices = MovieView.SelectedIndices;
|
||||||
|
if (indices.Count > 0)
|
||||||
|
{
|
||||||
|
var s = new EditSubtitlesForm { ReadOnly = true };
|
||||||
|
s.GetMovie(_movieList[MovieView.SelectedIndices[0]]);
|
||||||
|
s.Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Misc Widgets
|
||||||
|
|
||||||
|
private void BrowseMovies_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var ofd = new OpenFileDialog
|
||||||
|
{
|
||||||
|
Filter = "Movie Files (*." + Global.Config.MovieExtension + ")|*." + Global.Config.MovieExtension + "|Savestates|*.state|All Files|*.*",
|
||||||
|
InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null)
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = ofd.ShowHawkDialog();
|
||||||
|
if (result == DialogResult.OK)
|
||||||
|
{
|
||||||
|
var file = new FileInfo(ofd.FileName);
|
||||||
|
if (!file.Exists)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file.Extension.ToUpper() == "STATE")
|
||||||
|
{
|
||||||
|
var movie = new Movie(file.FullName);
|
||||||
|
movie.Load(); // State files will have to load everything unfortunately
|
||||||
|
if (movie.FrameCount == 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show(
|
||||||
|
"No input log detected in this savestate, aborting",
|
||||||
|
"Can not load file",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Hand);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var index = AddMovieToList(ofd.FileName, true);
|
||||||
|
if (index.HasValue)
|
||||||
|
{
|
||||||
|
MovieView.SelectedIndices.Clear();
|
||||||
|
MovieView.setSelection(index.Value);
|
||||||
|
MovieView.SelectItem(index.Value, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Scan_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ScanFiles();
|
||||||
|
PreHighlightMovie();
|
||||||
|
}
|
||||||
|
|
||||||
private void IncludeSubDirectories_CheckedChanged(object sender, EventArgs e)
|
private void IncludeSubDirectories_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Global.Config.PlayMovie_IncludeSubdir = IncludeSubDirectories.Checked;
|
Global.Config.PlayMovie_IncludeSubdir = IncludeSubDirectories.Checked;
|
||||||
|
@ -548,12 +640,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
PreHighlightMovie();
|
PreHighlightMovie();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Scan_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
ScanFiles();
|
|
||||||
PreHighlightMovie();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MatchGameNameCheckBox_CheckedChanged(object sender, EventArgs e)
|
private void MatchGameNameCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Global.Config.PlayMovie_MatchGameName = MatchGameNameCheckBox.Checked;
|
Global.Config.PlayMovie_MatchGameName = MatchGameNameCheckBox.Checked;
|
||||||
|
@ -561,92 +647,20 @@ namespace BizHawk.Client.EmuHawk
|
||||||
PreHighlightMovie();
|
PreHighlightMovie();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MovieView_KeyDown(object sender, KeyEventArgs e)
|
private void Ok_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Control && e.KeyCode == Keys.C)
|
Run();
|
||||||
{
|
Global.MovieSession.ReadOnly = ReadOnlyCheckBox.Checked;
|
||||||
var indexes = MovieView.SelectedIndices;
|
Close();
|
||||||
if (indexes.Count > 0)
|
|
||||||
{
|
|
||||||
var copyStr = new StringBuilder();
|
|
||||||
foreach (int index in indexes)
|
|
||||||
{
|
|
||||||
copyStr
|
|
||||||
.Append(_movieList[index].Filename).Append('\t')
|
|
||||||
.Append(_movieList[index].Header.SystemID).Append('\t')
|
|
||||||
.Append(_movieList[index].Header.GameName).Append('\t')
|
|
||||||
.Append(_movieList[index].Time.ToString(@"hh\:mm\:ss\.fff"))
|
|
||||||
.AppendLine();
|
|
||||||
|
|
||||||
Clipboard.SetDataObject(copyStr.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DetailsView_ColumnClick(object sender, ColumnClickEventArgs e)
|
private void Cancel_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
OrderDetailsColumn(e.Column);
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
#endregion
|
||||||
/// Takes the values from DetailView and puts them in a List of Detail classes, this list is then sorted and put back in the DetailView
|
|
||||||
/// </summary>
|
#endregion
|
||||||
/// <param name="columnToOrder"></param>
|
|
||||||
private void OrderDetailsColumn(int columnToOrder)
|
|
||||||
{
|
|
||||||
List<MovieDetails> detailsList = new List<MovieDetails>();
|
|
||||||
for (int i = 0; i < DetailsView.Items.Count; i++)
|
|
||||||
{
|
|
||||||
detailsList.Add(new MovieDetails { keys = DetailsView.Items[i].Text, values = DetailsView.Items[i].SubItems[1].Text, backgroundColor = DetailsView.Items[i].BackColor });
|
|
||||||
}
|
|
||||||
var columnName = DetailsView.Columns[columnToOrder].Text;
|
|
||||||
if (_sortedDetailsCol != columnName)
|
|
||||||
{
|
|
||||||
_sortDetailsReverse = false;
|
|
||||||
}
|
|
||||||
switch (columnName)
|
|
||||||
{
|
|
||||||
//Header, Value
|
|
||||||
case "Header":
|
|
||||||
if (_sortDetailsReverse)
|
|
||||||
{
|
|
||||||
detailsList = detailsList
|
|
||||||
.OrderByDescending(x => x.keys)
|
|
||||||
.ThenBy(x => x.values).ToList();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
detailsList = detailsList
|
|
||||||
.OrderBy(x => x.keys)
|
|
||||||
.ThenBy(x => x.values).ToList();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "Value":
|
|
||||||
if (_sortDetailsReverse)
|
|
||||||
{
|
|
||||||
detailsList = detailsList
|
|
||||||
.OrderByDescending(x => x.values)
|
|
||||||
.ThenBy(x => x.keys).ToList();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
detailsList = detailsList
|
|
||||||
.OrderBy(x => x.values)
|
|
||||||
.ThenBy(x => x.keys).ToList();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
int firstIndex = MovieView.SelectedIndices[0];
|
|
||||||
DetailsView.Items.Clear();
|
|
||||||
foreach (var detail in detailsList)
|
|
||||||
{
|
|
||||||
ListViewItem item = new ListViewItem { Text = detail.keys, BackColor = detail.backgroundColor };
|
|
||||||
item.SubItems.Add(detail.values);
|
|
||||||
DetailsView.Items.Add(item);
|
|
||||||
}
|
|
||||||
_sortedDetailsCol = columnName;
|
|
||||||
_sortDetailsReverse = !_sortDetailsReverse;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue