2011-02-11 02:30:45 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
2014-04-13 22:43:30 +00:00
|
|
|
|
using System.IO;
|
2013-10-28 00:21:00 +00:00
|
|
|
|
using System.Linq;
|
2011-02-11 02:30:45 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2013-10-25 00:57:23 +00:00
|
|
|
|
using BizHawk.Client.Common;
|
2014-04-13 22:43:30 +00:00
|
|
|
|
using BizHawk.Common;
|
2013-10-25 00:57:23 +00:00
|
|
|
|
|
2013-11-03 03:54:37 +00:00
|
|
|
|
namespace BizHawk.Client.EmuHawk
|
2011-02-11 02:30:45 +00:00
|
|
|
|
{
|
2014-04-13 22:16:47 +00:00
|
|
|
|
public partial class PlayMovie : Form
|
|
|
|
|
{
|
|
|
|
|
private List<IMovie> _movieList = new List<IMovie>();
|
|
|
|
|
private bool _sortReverse;
|
|
|
|
|
private string _sortedCol;
|
|
|
|
|
|
|
|
|
|
private bool _sortDetailsReverse;
|
|
|
|
|
private string _sortedDetailsCol;
|
|
|
|
|
|
|
|
|
|
public PlayMovie()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
MovieView.QueryItemText += MovieView_QueryItemText;
|
|
|
|
|
MovieView.VirtualMode = true;
|
|
|
|
|
_sortReverse = false;
|
2014-04-13 22:43:30 +00:00
|
|
|
|
_sortedCol = string.Empty;
|
2014-04-13 22:16:47 +00:00
|
|
|
|
|
|
|
|
|
_sortDetailsReverse = false;
|
2014-04-13 22:43:30 +00:00
|
|
|
|
_sortedDetailsCol = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PlayMovie_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
IncludeSubDirectories.Checked = Global.Config.PlayMovie_IncludeSubdir;
|
|
|
|
|
ShowStateFiles.Checked = Global.Config.PlayMovie_ShowStateFiles;
|
|
|
|
|
MatchGameNameCheckBox.Checked = Global.Config.PlayMovie_MatchGameName;
|
|
|
|
|
ScanFiles();
|
|
|
|
|
PreHighlightMovie();
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-04-13 22:43:30 +00:00
|
|
|
|
private void MovieView_QueryItemText(int index, int column, out string text)
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
2014-04-13 22:43:30 +00:00
|
|
|
|
text = string.Empty;
|
|
|
|
|
if (column == 0) // File
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
|
|
|
|
text = Path.GetFileName(_movieList[index].Filename);
|
|
|
|
|
}
|
2014-04-13 22:43:30 +00:00
|
|
|
|
|
|
|
|
|
if (column == 1) // System
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
|
|
|
|
text = _movieList[index].Header.SystemID;
|
|
|
|
|
}
|
2014-04-13 22:43:30 +00:00
|
|
|
|
|
|
|
|
|
if (column == 2) // Game
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
|
|
|
|
text = _movieList[index].Header.GameName;
|
|
|
|
|
}
|
2014-04-13 22:43:30 +00:00
|
|
|
|
|
|
|
|
|
if (column == 3) // Time
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
|
|
|
|
text = _movieList[index].Time.ToString(@"hh\:mm\:ss\.fff");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Run()
|
|
|
|
|
{
|
|
|
|
|
var indices = MovieView.SelectedIndices;
|
2014-04-13 22:43:30 +00:00
|
|
|
|
if (indices.Count > 0) // Import file if necessary
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
|
|
|
|
GlobalWin.MainForm.StartNewMovie(_movieList[MovieView.SelectedIndices[0]], false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddStateToList(string filename)
|
|
|
|
|
{
|
|
|
|
|
using (var file = new HawkFile(filename))
|
|
|
|
|
{
|
|
|
|
|
if (file.Exists)
|
|
|
|
|
{
|
|
|
|
|
if (!IsDuplicateOf(filename).HasValue)
|
|
|
|
|
{
|
|
|
|
|
var movie = new Movie(file.CanonicalFullPath);
|
2014-04-13 22:43:30 +00:00
|
|
|
|
movie.Load(); // State files will have to load everything unfortunately
|
2014-04-13 22:16:47 +00:00
|
|
|
|
if (movie.FrameCount > 0)
|
|
|
|
|
{
|
|
|
|
|
_movieList.Add(movie);
|
|
|
|
|
_sortReverse = false;
|
2014-04-13 22:43:30 +00:00
|
|
|
|
_sortedCol = string.Empty;
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int? AddMovieToList(string filename, bool force)
|
|
|
|
|
{
|
|
|
|
|
using (var file = new HawkFile(filename))
|
|
|
|
|
{
|
|
|
|
|
if (!file.Exists)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2014-04-13 22:43:30 +00:00
|
|
|
|
|
|
|
|
|
var index = IsDuplicateOf(filename);
|
|
|
|
|
if (!index.HasValue)
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
2014-04-13 22:43:30 +00:00
|
|
|
|
PreLoadMovieFile(file, force);
|
|
|
|
|
MovieView.ItemCount = _movieList.Count;
|
|
|
|
|
UpdateList();
|
2014-04-13 22:16:47 +00:00
|
|
|
|
|
2014-04-13 22:43:30 +00:00
|
|
|
|
_sortReverse = false;
|
|
|
|
|
_sortedCol = string.Empty;
|
|
|
|
|
index = _movieList.Count - 1;
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
2014-04-13 22:43:30 +00:00
|
|
|
|
|
|
|
|
|
return index;
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int? IsDuplicateOf(string filename)
|
|
|
|
|
{
|
2014-04-13 22:43:30 +00:00
|
|
|
|
for (var i = 0; i < _movieList.Count; i++)
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
|
|
|
|
if (_movieList[i].Filename == filename)
|
|
|
|
|
{
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PreLoadMovieFile(HawkFile hf, bool force)
|
|
|
|
|
{
|
|
|
|
|
var movie = new Movie(hf.CanonicalFullPath);
|
2014-04-13 23:18:45 +00:00
|
|
|
|
|
2014-04-13 22:16:47 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2014-04-13 23:18:45 +00:00
|
|
|
|
movie.PreLoadText(hf);
|
|
|
|
|
|
2014-04-13 22:43:30 +00:00
|
|
|
|
// Don't do this from browse
|
2014-04-13 22:16:47 +00:00
|
|
|
|
if (movie.Header[HeaderKeys.GAMENAME] == Global.Game.Name ||
|
|
|
|
|
Global.Config.PlayMovie_MatchGameName == false || force)
|
|
|
|
|
{
|
|
|
|
|
_movieList.Add(movie);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2014-04-13 23:18:45 +00:00
|
|
|
|
// TODO: inform the user that a movie failed to parse in some way
|
2014-04-13 22:16:47 +00:00
|
|
|
|
Console.WriteLine(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateList()
|
|
|
|
|
{
|
|
|
|
|
MovieView.Refresh();
|
|
|
|
|
MovieCount.Text = _movieList.Count + " movie"
|
2014-04-13 22:43:30 +00:00
|
|
|
|
+ (_movieList.Count != 1 ? "s" : string.Empty);
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PreHighlightMovie()
|
|
|
|
|
{
|
2014-04-13 22:43:30 +00:00
|
|
|
|
if (Global.Game == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var indices = new List<int>();
|
2014-04-13 22:16:47 +00:00
|
|
|
|
|
2014-04-13 22:43:30 +00:00
|
|
|
|
// Pull out matching names
|
|
|
|
|
for (var i = 0; i < _movieList.Count; i++)
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
|
|
|
|
if (PathManager.FilesystemSafeName(Global.Game) == _movieList[i].Header.GameName)
|
|
|
|
|
{
|
2014-04-13 22:43:30 +00:00
|
|
|
|
indices.Add(i);
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-04-13 22:43:30 +00:00
|
|
|
|
|
|
|
|
|
if (indices.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (indices.Count == 1)
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
2014-04-13 22:43:30 +00:00
|
|
|
|
HighlightMovie(indices[0]);
|
2014-04-13 22:16:47 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-13 22:43:30 +00:00
|
|
|
|
// Prefer tas files
|
|
|
|
|
var tas = new List<int>();
|
|
|
|
|
for (var i = 0; i < indices.Count; i++)
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
2014-04-13 22:43:30 +00:00
|
|
|
|
if (Path.GetExtension(_movieList[indices[i]].Filename).ToUpper() == "." + Global.Config.MovieExtension)
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
2014-04-13 22:43:30 +00:00
|
|
|
|
tas.Add(i);
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-13 22:43:30 +00:00
|
|
|
|
if (tas.Count == 1)
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
2014-04-13 22:43:30 +00:00
|
|
|
|
HighlightMovie(tas[0]);
|
2014-04-13 22:16:47 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2014-04-13 22:43:30 +00:00
|
|
|
|
|
|
|
|
|
if (tas.Count > 1)
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
2014-04-13 22:43:30 +00:00
|
|
|
|
indices = new List<int>(tas);
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-04-13 22:43:30 +00:00
|
|
|
|
// Final tie breaker - Last used file
|
|
|
|
|
var file = new FileInfo(_movieList[indices[0]].Filename);
|
2014-04-13 22:16:47 +00:00
|
|
|
|
var time = file.LastAccessTime;
|
2014-04-13 22:43:30 +00:00
|
|
|
|
var mostRecent = indices.First();
|
|
|
|
|
for (var i = 1; i < indices.Count; i++)
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
2014-04-13 22:43:30 +00:00
|
|
|
|
file = new FileInfo(_movieList[indices[0]].Filename);
|
2014-04-13 22:16:47 +00:00
|
|
|
|
if (file.LastAccessTime > time)
|
|
|
|
|
{
|
|
|
|
|
time = file.LastAccessTime;
|
2014-04-13 22:43:30 +00:00
|
|
|
|
mostRecent = indices[i];
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HighlightMovie(mostRecent);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HighlightMovie(int index)
|
|
|
|
|
{
|
|
|
|
|
MovieView.SelectedIndices.Clear();
|
|
|
|
|
MovieView.setSelection(index);
|
|
|
|
|
MovieView.SelectItem(index, true);
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-13 22:43:30 +00:00
|
|
|
|
private void ScanFiles()
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
|
|
|
|
_movieList.Clear();
|
|
|
|
|
MovieView.ItemCount = 0;
|
|
|
|
|
MovieView.Update();
|
|
|
|
|
|
|
|
|
|
var directory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null);
|
|
|
|
|
if (!Directory.Exists(directory))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(directory);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Directory.GetFiles(directory, "*." + Global.Config.MovieExtension)
|
|
|
|
|
.ToList()
|
|
|
|
|
.ForEach(file => AddMovieToList(file, force: false));
|
|
|
|
|
|
|
|
|
|
if (Global.Config.PlayMovie_ShowStateFiles)
|
|
|
|
|
{
|
|
|
|
|
Directory.GetFiles(directory, "*.state")
|
|
|
|
|
.ToList()
|
2014-04-13 22:43:30 +00:00
|
|
|
|
.ForEach(AddStateToList);
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Global.Config.PlayMovie_IncludeSubdir)
|
|
|
|
|
{
|
|
|
|
|
var subs = Directory.GetDirectories(directory);
|
|
|
|
|
foreach (var dir in subs)
|
|
|
|
|
{
|
|
|
|
|
Directory.GetFiles(dir, "*." + Global.Config.MovieExtension)
|
|
|
|
|
.ToList()
|
|
|
|
|
.ForEach(file => AddMovieToList(file, force: false));
|
|
|
|
|
|
|
|
|
|
Directory.GetFiles(dir, "*.state")
|
|
|
|
|
.ToList()
|
2014-04-13 22:43:30 +00:00
|
|
|
|
.ForEach(AddStateToList);
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-13 22:43:30 +00:00
|
|
|
|
#region Events
|
2014-04-13 22:16:47 +00:00
|
|
|
|
|
2014-04-13 22:43:30 +00:00
|
|
|
|
#region Movie List
|
2014-04-13 22:16:47 +00:00
|
|
|
|
|
|
|
|
|
private void MovieView_DragEnter(object sender, DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MovieView_DragDrop(object sender, DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
|
|
|
|
|
|
|
|
|
|
filePaths
|
|
|
|
|
.Where(path => Path.GetExtension(path) == "." + Global.Config.MovieExtension)
|
|
|
|
|
.ToList()
|
|
|
|
|
.ForEach(path => AddMovieToList(path, force: true));
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-13 22:43:30 +00:00
|
|
|
|
private void MovieView_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
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 MovieView_DoubleClick(object sender, EventArgs e)
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
2014-04-13 22:43:30 +00:00
|
|
|
|
Run();
|
|
|
|
|
Close();
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-04-13 22:43:30 +00:00
|
|
|
|
private void MovieView_ColumnClick(object sender, ColumnClickEventArgs e)
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
2014-04-13 22:43:30 +00:00
|
|
|
|
var columnName = MovieView.Columns[e.Column].Text;
|
2014-04-13 22:16:47 +00:00
|
|
|
|
if (_sortedCol != columnName)
|
|
|
|
|
{
|
|
|
|
|
_sortReverse = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (columnName)
|
|
|
|
|
{
|
|
|
|
|
case "File":
|
|
|
|
|
if (_sortReverse)
|
|
|
|
|
{
|
|
|
|
|
_movieList = _movieList
|
|
|
|
|
.OrderByDescending(x => Path.GetFileName(x.Filename))
|
|
|
|
|
.ThenBy(x => x.Header.SystemID)
|
|
|
|
|
.ThenBy(x => x.Header.GameName)
|
|
|
|
|
.ThenBy(x => x.FrameCount)
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_movieList = _movieList
|
|
|
|
|
.OrderBy(x => Path.GetFileName(x.Filename))
|
|
|
|
|
.ThenBy(x => x.Header.SystemID)
|
|
|
|
|
.ThenBy(x => x.Header.GameName)
|
|
|
|
|
.ThenBy(x => x.FrameCount)
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "SysID":
|
|
|
|
|
if (_sortReverse)
|
|
|
|
|
{
|
|
|
|
|
_movieList = _movieList
|
|
|
|
|
.OrderByDescending(x => x.Header.SystemID)
|
|
|
|
|
.ThenBy(x => Path.GetFileName(x.Filename))
|
|
|
|
|
.ThenBy(x => x.Header.GameName)
|
|
|
|
|
.ThenBy(x => x.FrameCount)
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_movieList = _movieList
|
|
|
|
|
.OrderBy(x => x.Header.SystemID)
|
|
|
|
|
.ThenBy(x => Path.GetFileName(x.Filename))
|
|
|
|
|
.ThenBy(x => x.Header.GameName)
|
|
|
|
|
.ThenBy(x => x.FrameCount)
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "Game":
|
|
|
|
|
if (_sortReverse)
|
|
|
|
|
{
|
|
|
|
|
_movieList = _movieList
|
|
|
|
|
.OrderByDescending(x => x.Header.GameName)
|
|
|
|
|
.ThenBy(x => Path.GetFileName(x.Filename))
|
|
|
|
|
.ThenBy(x => x.Header.SystemID)
|
|
|
|
|
.ThenBy(x => x.FrameCount)
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_movieList = _movieList
|
|
|
|
|
.OrderBy(x => x.Header.GameName)
|
|
|
|
|
.ThenBy(x => Path.GetFileName(x.Filename))
|
|
|
|
|
.ThenBy(x => x.Header.SystemID)
|
|
|
|
|
.ThenBy(x => x.FrameCount)
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "Length (est.)":
|
|
|
|
|
if (_sortReverse)
|
|
|
|
|
{
|
|
|
|
|
_movieList = _movieList
|
|
|
|
|
.OrderByDescending(x => x.FrameCount)
|
|
|
|
|
.ThenBy(x => Path.GetFileName(x.Filename))
|
|
|
|
|
.ThenBy(x => x.Header.SystemID)
|
|
|
|
|
.ThenBy(x => x.FrameCount)
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_movieList = _movieList
|
|
|
|
|
.OrderBy(x => x.FrameCount)
|
|
|
|
|
.ThenBy(x => Path.GetFileName(x.Filename))
|
|
|
|
|
.ThenBy(x => x.Header.SystemID)
|
|
|
|
|
.ThenBy(x => x.Header.GameName)
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_sortedCol = columnName;
|
|
|
|
|
_sortReverse = !_sortReverse;
|
|
|
|
|
MovieView.Refresh();
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-13 22:43:30 +00:00
|
|
|
|
private void MovieView_SelectedIndexChanged(object sender, EventArgs e)
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
2014-04-13 22:43:30 +00:00
|
|
|
|
toolTip1.SetToolTip(DetailsView, string.Empty);
|
|
|
|
|
DetailsView.Items.Clear();
|
|
|
|
|
if (MovieView.SelectedIndices.Count < 1)
|
|
|
|
|
{
|
|
|
|
|
OK.Enabled = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-04-13 22:16:47 +00:00
|
|
|
|
|
2014-04-13 22:43:30 +00:00
|
|
|
|
OK.Enabled = true;
|
2014-04-13 22:16:47 +00:00
|
|
|
|
|
2014-04-13 22:43:30 +00:00
|
|
|
|
var firstIndex = MovieView.SelectedIndices[0];
|
|
|
|
|
MovieView.ensureVisible(firstIndex);
|
2014-04-13 22:16:47 +00:00
|
|
|
|
|
2014-04-13 22:43:30 +00:00
|
|
|
|
foreach (var kvp in _movieList[firstIndex].Header)
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
2014-04-13 22:43:30 +00:00
|
|
|
|
var item = new ListViewItem(kvp.Key);
|
|
|
|
|
item.SubItems.Add(kvp.Value);
|
2014-04-13 22:16:47 +00:00
|
|
|
|
|
2014-04-13 22:43:30 +00:00
|
|
|
|
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;
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
2014-04-13 22:43:30 +00:00
|
|
|
|
|
|
|
|
|
DetailsView.Items.Add(item);
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-04-13 22:43:30 +00:00
|
|
|
|
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();
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-04-22 00:59:21 +00:00
|
|
|
|
private void EditMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
MovieView.SelectedIndices
|
|
|
|
|
.Cast<int>()
|
|
|
|
|
.Select(index => _movieList[index])
|
|
|
|
|
.ToList()
|
|
|
|
|
.ForEach(movie => System.Diagnostics.Process.Start(movie.Filename));
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-13 22:43:30 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Details
|
|
|
|
|
|
|
|
|
|
private void DetailsView_ColumnClick(object sender, ColumnClickEventArgs e)
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
2014-04-13 22:43:30 +00:00
|
|
|
|
var detailsList = new List<MovieDetails>();
|
|
|
|
|
for (var i = 0; i < DetailsView.Items.Count; i++)
|
2014-04-13 22:16:47 +00:00
|
|
|
|
{
|
2014-04-13 22:43:30 +00:00
|
|
|
|
detailsList.Add(new MovieDetails
|
|
|
|
|
{
|
|
|
|
|
Keys = DetailsView.Items[i].Text,
|
|
|
|
|
Values = DetailsView.Items[i].SubItems[1].Text,
|
|
|
|
|
BackgroundColor = DetailsView.Items[i].BackColor
|
|
|
|
|
});
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
2014-04-13 22:43:30 +00:00
|
|
|
|
|
|
|
|
|
var columnName = DetailsView.Columns[e.Column].Text;
|
2014-04-13 22:16:47 +00:00
|
|
|
|
if (_sortedDetailsCol != columnName)
|
|
|
|
|
{
|
|
|
|
|
_sortDetailsReverse = false;
|
|
|
|
|
}
|
2014-04-13 22:43:30 +00:00
|
|
|
|
|
2014-04-13 22:16:47 +00:00
|
|
|
|
switch (columnName)
|
|
|
|
|
{
|
2014-04-13 22:43:30 +00:00
|
|
|
|
// Header, Value
|
2014-04-13 22:16:47 +00:00
|
|
|
|
case "Header":
|
|
|
|
|
if (_sortDetailsReverse)
|
|
|
|
|
{
|
|
|
|
|
detailsList = detailsList
|
2014-04-13 22:43:30 +00:00
|
|
|
|
.OrderByDescending(x => x.Keys)
|
|
|
|
|
.ThenBy(x => x.Values).ToList();
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
detailsList = detailsList
|
2014-04-13 22:43:30 +00:00
|
|
|
|
.OrderBy(x => x.Keys)
|
|
|
|
|
.ThenBy(x => x.Values).ToList();
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
2014-04-13 22:43:30 +00:00
|
|
|
|
|
2014-04-13 22:16:47 +00:00
|
|
|
|
break;
|
|
|
|
|
case "Value":
|
|
|
|
|
if (_sortDetailsReverse)
|
|
|
|
|
{
|
|
|
|
|
detailsList = detailsList
|
2014-04-13 22:43:30 +00:00
|
|
|
|
.OrderByDescending(x => x.Values)
|
|
|
|
|
.ThenBy(x => x.Keys).ToList();
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
detailsList = detailsList
|
2014-04-13 22:43:30 +00:00
|
|
|
|
.OrderBy(x => x.Values)
|
|
|
|
|
.ThenBy(x => x.Keys).ToList();
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
2014-04-13 22:43:30 +00:00
|
|
|
|
|
2014-04-13 22:16:47 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2014-04-13 22:43:30 +00:00
|
|
|
|
|
2014-04-13 22:16:47 +00:00
|
|
|
|
DetailsView.Items.Clear();
|
|
|
|
|
foreach (var detail in detailsList)
|
|
|
|
|
{
|
2014-04-13 22:43:30 +00:00
|
|
|
|
var item = new ListViewItem { Text = detail.Keys, BackColor = detail.BackgroundColor };
|
|
|
|
|
item.SubItems.Add(detail.Values);
|
2014-04-13 22:16:47 +00:00
|
|
|
|
DetailsView.Items.Add(item);
|
|
|
|
|
}
|
2014-04-13 22:43:30 +00:00
|
|
|
|
|
2014-04-13 22:16:47 +00:00
|
|
|
|
_sortedDetailsCol = columnName;
|
|
|
|
|
_sortDetailsReverse = !_sortDetailsReverse;
|
|
|
|
|
}
|
2014-04-13 22:43:30 +00:00
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
Global.Config.PlayMovie_IncludeSubdir = IncludeSubDirectories.Checked;
|
|
|
|
|
ScanFiles();
|
|
|
|
|
PreHighlightMovie();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ShowStateFiles_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Global.Config.PlayMovie_ShowStateFiles = ShowStateFiles.Checked;
|
|
|
|
|
ScanFiles();
|
|
|
|
|
PreHighlightMovie();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MatchGameNameCheckBox_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Global.Config.PlayMovie_MatchGameName = MatchGameNameCheckBox.Checked;
|
|
|
|
|
ScanFiles();
|
|
|
|
|
PreHighlightMovie();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Ok_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Run();
|
|
|
|
|
Global.MovieSession.ReadOnly = ReadOnlyCheckBox.Checked;
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Cancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#endregion
|
2014-04-13 22:16:47 +00:00
|
|
|
|
}
|
2011-02-11 02:30:45 +00:00
|
|
|
|
}
|