2011-02-11 02:30:45 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
2011-05-10 00:38:20 +00:00
|
|
|
|
using System.IO;
|
2011-02-11 02:30:45 +00:00
|
|
|
|
|
|
|
|
|
namespace BizHawk.MultiClient
|
|
|
|
|
{
|
2011-06-19 19:10:01 +00:00
|
|
|
|
public partial class PlayMovie : Form
|
|
|
|
|
{
|
2011-07-10 17:04:24 +00:00
|
|
|
|
//Highlight movie on load that maches rom name
|
2011-06-19 19:10:01 +00:00
|
|
|
|
// Option to include subdirectories
|
|
|
|
|
// Option to include savestate files (that have an input log)
|
2011-07-10 17:04:24 +00:00
|
|
|
|
|
2011-06-19 19:10:01 +00:00
|
|
|
|
List<Movie> MovieList = new List<Movie>();
|
|
|
|
|
bool sortReverse;
|
|
|
|
|
string sortedCol;
|
|
|
|
|
|
|
|
|
|
public PlayMovie()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
MovieView.QueryItemText += new QueryItemTextHandler(MovieView_QueryItemText);
|
|
|
|
|
MovieView.QueryItemBkColor += new QueryItemBkColorHandler(MovieView_QueryItemBkColor);
|
|
|
|
|
MovieView.VirtualMode = true;
|
|
|
|
|
sortReverse = false;
|
|
|
|
|
sortedCol = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MovieView_QueryItemText(int index, int column, out string text)
|
|
|
|
|
{
|
|
|
|
|
text = "";
|
|
|
|
|
if (column == 0) //File
|
|
|
|
|
text = Path.GetFileName(MovieList[index].GetFilePath());
|
|
|
|
|
if (column == 1) //System
|
|
|
|
|
text = MovieList[index].GetSysID();
|
|
|
|
|
if (column == 2) //Game
|
|
|
|
|
text = MovieList[index].GetGameName();
|
|
|
|
|
if (column == 3) //Time
|
|
|
|
|
text = MovieList[index].GetTime(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MovieView_QueryItemBkColor(int index, int column, ref Color color)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Cancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Run()
|
|
|
|
|
{
|
2011-07-10 17:04:24 +00:00
|
|
|
|
ListView.SelectedIndexCollection indexes = MovieView.SelectedIndices;
|
|
|
|
|
if (indexes.Count == 0) return;
|
2011-06-19 19:10:01 +00:00
|
|
|
|
Global.MainForm.StartNewMovie(MovieList[MovieView.SelectedIndices[0]], false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OK_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Global.MainForm.ReadOnly = ReadOnlyCheckBox.Checked;
|
|
|
|
|
Run();
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BrowseMovies_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
OpenFileDialog ofd = new OpenFileDialog();
|
|
|
|
|
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.MoviesPath, "");
|
|
|
|
|
ofd.Filter = "Movie files (*.tas)|*.TAS;*.ZIP;*.7z|FCEUX Movies|*.FM2|PCEjin Movies|*.PCE|Archive Files|*.zip;*.7z|All Files|*.*";
|
|
|
|
|
|
|
|
|
|
Global.Sound.StopSound();
|
|
|
|
|
var result = ofd.ShowDialog();
|
|
|
|
|
Global.Sound.StartSound();
|
|
|
|
|
if (result == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
var file = new FileInfo(ofd.FileName);
|
|
|
|
|
if (!file.Exists)
|
|
|
|
|
return;
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-07-10 17:04:24 +00:00
|
|
|
|
int x = AddMovieToList(ofd.FileName);
|
|
|
|
|
if (x > 0)
|
|
|
|
|
{
|
|
|
|
|
MovieView.SelectedIndices.Clear();
|
|
|
|
|
MovieView.setSelection(x);
|
|
|
|
|
MovieView.SelectItem(x, true);
|
|
|
|
|
}
|
2011-06-19 19:10:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-10 17:04:24 +00:00
|
|
|
|
private int AddMovieToList(string filename)
|
2011-06-19 19:10:01 +00:00
|
|
|
|
{
|
2011-06-27 05:31:46 +00:00
|
|
|
|
using (var file = new HawkFile(filename))
|
2011-06-19 19:10:01 +00:00
|
|
|
|
{
|
2011-06-27 05:31:46 +00:00
|
|
|
|
if (!file.Exists)
|
2011-07-10 17:04:24 +00:00
|
|
|
|
return 0;
|
2011-06-27 05:31:46 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2011-07-10 17:04:24 +00:00
|
|
|
|
int x = IsDuplicate(filename);
|
|
|
|
|
if (x == 0)
|
|
|
|
|
{
|
|
|
|
|
PreLoadMovieFile(file);
|
|
|
|
|
MovieView.ItemCount = MovieList.Count;
|
|
|
|
|
UpdateList();
|
|
|
|
|
|
|
|
|
|
sortReverse = false;
|
|
|
|
|
sortedCol = "";
|
|
|
|
|
x = MovieList.Count - 1;
|
|
|
|
|
}
|
|
|
|
|
return x;
|
2011-06-27 05:31:46 +00:00
|
|
|
|
}
|
2011-06-19 19:10:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-10 17:04:24 +00:00
|
|
|
|
private int IsDuplicate(string filename)
|
|
|
|
|
{
|
|
|
|
|
for (int x = 0; x < MovieList.Count; x++)
|
|
|
|
|
if (MovieList[x].GetFilePath() == filename)
|
|
|
|
|
return x;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-19 19:10:01 +00:00
|
|
|
|
private void PreLoadMovieFile(HawkFile path)
|
|
|
|
|
{
|
|
|
|
|
Movie m = new Movie(path.CanonicalFullPath, MOVIEMODE.INACTIVE);
|
|
|
|
|
m.PreLoadText();
|
|
|
|
|
//m.LoadMovie();
|
2011-07-10 04:54:18 +00:00
|
|
|
|
if (path.Extension == ".FM2")
|
2011-06-19 19:10:01 +00:00
|
|
|
|
m.SetHeaderLine(MovieHeader.PLATFORM, "NES");
|
2011-07-10 04:54:18 +00:00
|
|
|
|
else if (path.Extension == ".MC2")
|
2011-06-19 19:10:01 +00:00
|
|
|
|
m.SetHeaderLine(MovieHeader.PLATFORM, "PCE");
|
|
|
|
|
MovieList.Add(m);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateList()
|
|
|
|
|
{
|
|
|
|
|
MovieView.Refresh();
|
|
|
|
|
UpdateMovieCount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateMovieCount()
|
|
|
|
|
{
|
|
|
|
|
int x = MovieList.Count;
|
|
|
|
|
if (x == 1)
|
|
|
|
|
MovieCount.Text = x.ToString() + " movie";
|
|
|
|
|
else
|
|
|
|
|
MovieCount.Text = x.ToString() + " movies";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PlayMovie_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string d = PathManager.MakeAbsolutePath(Global.Config.MoviesPath, "");
|
|
|
|
|
if (!Directory.Exists(d))
|
|
|
|
|
Directory.CreateDirectory(d);
|
|
|
|
|
foreach (string f in Directory.GetFiles(d, "*.tas"))
|
|
|
|
|
AddMovieToList(f);
|
|
|
|
|
foreach (string f in Directory.GetFiles(d, "*.fm2"))
|
|
|
|
|
AddMovieToList(f);
|
|
|
|
|
foreach (string f in Directory.GetFiles(d, "*.mc2"))
|
|
|
|
|
AddMovieToList(f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MovieView_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DetailsView.Items.Clear();
|
2011-06-27 05:31:46 +00:00
|
|
|
|
if (MovieView.SelectedIndices.Count < 1) return;
|
|
|
|
|
|
2011-06-19 19:10:01 +00:00
|
|
|
|
int x = MovieView.SelectedIndices[0];
|
|
|
|
|
Dictionary<string, string> h = MovieList[x].GetHeaderInfo();
|
|
|
|
|
|
|
|
|
|
foreach (var kvp in h)
|
|
|
|
|
{
|
|
|
|
|
ListViewItem item = new ListViewItem(kvp.Key);
|
|
|
|
|
item.SubItems.Add(kvp.Value);
|
|
|
|
|
DetailsView.Items.Add(item);
|
|
|
|
|
}
|
2011-07-04 02:50:38 +00:00
|
|
|
|
if (MovieList[x].HasComments())
|
|
|
|
|
button1.Enabled = true;
|
|
|
|
|
else
|
|
|
|
|
button1.Enabled = false;
|
|
|
|
|
|
|
|
|
|
if (MovieList[x].Subtitles.Count() > 0)
|
|
|
|
|
button2.Enabled = true;
|
|
|
|
|
else
|
|
|
|
|
button2.Enabled = false;
|
2011-06-19 19:10:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-07-10 17:04:24 +00:00
|
|
|
|
ListView.SelectedIndexCollection indexes = MovieView.SelectedIndices;
|
|
|
|
|
if (indexes.Count == 0) return;
|
2011-07-04 02:50:38 +00:00
|
|
|
|
EditCommentsForm c = new EditCommentsForm();
|
|
|
|
|
c.ReadOnly = true;
|
|
|
|
|
c.GetMovie(MovieList[MovieView.SelectedIndices[0]]);
|
|
|
|
|
c.Show();
|
2011-06-19 19:10:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-07-10 17:04:24 +00:00
|
|
|
|
ListView.SelectedIndexCollection indexes = MovieView.SelectedIndices;
|
|
|
|
|
if (indexes.Count == 0) return;
|
2011-06-26 20:26:37 +00:00
|
|
|
|
EditSubtitlesForm s = new EditSubtitlesForm();
|
|
|
|
|
s.ReadOnly = true;
|
2011-06-26 21:11:12 +00:00
|
|
|
|
s.GetMovie(MovieList[MovieView.SelectedIndices[0]]);
|
2011-06-26 20:26:37 +00:00
|
|
|
|
s.Show();
|
2011-06-19 19:10:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MovieView_DoubleClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Run();
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MovieView_DragEnter(object sender, DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None; string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MovieView_DragDrop(object sender, DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
|
|
|
|
|
foreach (string path in filePaths)
|
|
|
|
|
{
|
|
|
|
|
if (Path.GetExtension(path) == ".tas" || Path.GetExtension(path) == ".fm2" ||
|
|
|
|
|
Path.GetExtension(path) == ".mc2")
|
|
|
|
|
AddMovieToList(path);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MovieView_ColumnClick(object sender, ColumnClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
OrderColumn(e.Column);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OrderColumn(int columnToOrder)
|
|
|
|
|
{
|
|
|
|
|
string columnName = MovieView.Columns[columnToOrder].Text;
|
|
|
|
|
if (sortedCol.CompareTo(columnName) != 0)
|
|
|
|
|
sortReverse = false;
|
|
|
|
|
MovieList.Sort((x, y) => x.CompareTo(y, columnName) * (sortReverse ? -1 : 1));
|
|
|
|
|
sortedCol = columnName;
|
|
|
|
|
sortReverse = !(sortReverse);
|
|
|
|
|
MovieView.Refresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2011-02-11 02:30:45 +00:00
|
|
|
|
}
|