2011-06-26 20:26:37 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
2011-07-16 02:11:51 +00:00
|
|
|
|
using System.Globalization;
|
2011-06-26 20:26:37 +00:00
|
|
|
|
|
2013-10-25 00:57:23 +00:00
|
|
|
|
using BizHawk.Client.Common;
|
|
|
|
|
|
2013-11-03 03:54:37 +00:00
|
|
|
|
namespace BizHawk.Client.EmuHawk
|
2011-06-26 20:26:37 +00:00
|
|
|
|
{
|
|
|
|
|
public partial class EditSubtitlesForm : Form
|
|
|
|
|
{
|
|
|
|
|
public bool ReadOnly;
|
2013-10-25 00:57:23 +00:00
|
|
|
|
private Movie selectedMovie;
|
2011-06-26 20:26:37 +00:00
|
|
|
|
|
|
|
|
|
public EditSubtitlesForm()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void EditSubtitlesForm_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (ReadOnly)
|
|
|
|
|
{
|
|
|
|
|
//Set all columns to read only
|
2011-06-26 21:11:12 +00:00
|
|
|
|
for (int x = 0; x < SubGrid.Columns.Count; x++)
|
|
|
|
|
SubGrid.Columns[x].ReadOnly = true;
|
|
|
|
|
Text = "View Subtitles";
|
2011-06-26 20:26:37 +00:00
|
|
|
|
}
|
2011-06-26 21:11:12 +00:00
|
|
|
|
|
|
|
|
|
if (SubGrid.Rows.Count > 8)
|
2011-07-10 18:36:10 +00:00
|
|
|
|
{
|
|
|
|
|
int x = Height + ((SubGrid.Rows.Count - 8) * 21);
|
|
|
|
|
if (x < 600)
|
2013-04-15 02:14:14 +00:00
|
|
|
|
Height = x;
|
2011-07-10 18:36:10 +00:00
|
|
|
|
else
|
2013-04-15 02:14:14 +00:00
|
|
|
|
Height = 600;
|
2011-07-10 18:36:10 +00:00
|
|
|
|
}
|
2011-06-26 20:26:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Cancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2013-04-15 02:14:14 +00:00
|
|
|
|
Close();
|
2011-06-26 20:26:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-07-04 20:34:53 +00:00
|
|
|
|
private void ShowError(int row, int column)
|
|
|
|
|
{
|
|
|
|
|
DataGridViewCell c = SubGrid.Rows[row].Cells[column];
|
2013-04-15 02:14:14 +00:00
|
|
|
|
string error = "Unable to parse value: " + c.Value;
|
2011-07-04 20:34:53 +00:00
|
|
|
|
string caption = "Parse Error Row " + row.ToString() + " Column " + column.ToString();
|
|
|
|
|
MessageBox.Show(error, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-26 20:26:37 +00:00
|
|
|
|
private void OK_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!ReadOnly)
|
|
|
|
|
{
|
2013-10-25 00:57:23 +00:00
|
|
|
|
selectedMovie.Subtitles.Clear();
|
2011-07-04 01:23:32 +00:00
|
|
|
|
for (int x = 0; x < SubGrid.Rows.Count - 1; x++)
|
|
|
|
|
{
|
|
|
|
|
Subtitle s = new Subtitle();
|
2011-07-04 20:34:53 +00:00
|
|
|
|
|
2011-07-04 01:23:32 +00:00
|
|
|
|
DataGridViewCell c = SubGrid.Rows[x].Cells[0];
|
2011-07-04 20:34:53 +00:00
|
|
|
|
try { s.Frame = int.Parse(c.Value.ToString()); }
|
|
|
|
|
catch { ShowError(x, 0); return; }
|
2011-07-04 01:23:32 +00:00
|
|
|
|
c = SubGrid.Rows[x].Cells[1];
|
2011-07-04 20:34:53 +00:00
|
|
|
|
try { s.X = int.Parse(c.Value.ToString()); }
|
|
|
|
|
catch { ShowError(x, 1); return; }
|
2011-07-04 01:23:32 +00:00
|
|
|
|
c = SubGrid.Rows[x].Cells[2];
|
2011-07-04 20:34:53 +00:00
|
|
|
|
try { s.Y = int.Parse(c.Value.ToString()); }
|
|
|
|
|
catch { ShowError(x, 2); return; }
|
2011-07-04 01:23:32 +00:00
|
|
|
|
c = SubGrid.Rows[x].Cells[3];
|
2011-07-04 20:34:53 +00:00
|
|
|
|
try { s.Duration = int.Parse(c.Value.ToString()); }
|
|
|
|
|
catch { ShowError(x, 3); return; }
|
2011-07-04 01:23:32 +00:00
|
|
|
|
c = SubGrid.Rows[x].Cells[4];
|
2011-07-16 02:11:51 +00:00
|
|
|
|
try { s.Color = uint.Parse(c.Value.ToString(), NumberStyles.HexNumber); }
|
2011-07-04 20:34:53 +00:00
|
|
|
|
catch { ShowError(x, 4); return; }
|
|
|
|
|
try { c = SubGrid.Rows[x].Cells[5]; }
|
|
|
|
|
catch { ShowError(x, 5); return; }
|
2011-07-04 01:23:32 +00:00
|
|
|
|
s.Message = c.Value.ToString();
|
2013-10-28 01:31:30 +00:00
|
|
|
|
selectedMovie.Subtitles.Add(s);
|
2011-07-04 01:23:32 +00:00
|
|
|
|
}
|
2011-07-04 02:50:38 +00:00
|
|
|
|
selectedMovie.WriteMovie();
|
2011-06-26 20:26:37 +00:00
|
|
|
|
}
|
2013-04-15 02:14:14 +00:00
|
|
|
|
Close();
|
2011-06-26 20:26:37 +00:00
|
|
|
|
}
|
2011-06-26 21:11:12 +00:00
|
|
|
|
|
|
|
|
|
public void GetMovie(Movie m)
|
|
|
|
|
{
|
2013-10-28 00:21:00 +00:00
|
|
|
|
selectedMovie = m;
|
2013-10-28 01:31:30 +00:00
|
|
|
|
SubtitleList subs = new SubtitleList();
|
|
|
|
|
subs.AddRange(m.Subtitles);
|
2011-06-26 21:11:12 +00:00
|
|
|
|
|
2013-04-15 02:14:14 +00:00
|
|
|
|
for (int x = 0; x < subs.Count; x++)
|
2011-06-26 21:11:12 +00:00
|
|
|
|
{
|
2013-10-25 00:57:23 +00:00
|
|
|
|
Subtitle s = subs[x];
|
2011-06-26 21:11:12 +00:00
|
|
|
|
SubGrid.Rows.Add();
|
|
|
|
|
DataGridViewCell c = SubGrid.Rows[x].Cells[0];
|
|
|
|
|
c.Value = s.Frame;
|
|
|
|
|
c = SubGrid.Rows[x].Cells[1];
|
|
|
|
|
c.Value = s.X;
|
|
|
|
|
c = SubGrid.Rows[x].Cells[2];
|
|
|
|
|
c.Value = s.Y;
|
|
|
|
|
c = SubGrid.Rows[x].Cells[3];
|
|
|
|
|
c.Value = s.Duration;
|
|
|
|
|
c = SubGrid.Rows[x].Cells[4];
|
2011-07-04 20:34:53 +00:00
|
|
|
|
c.Value = String.Format("{0:X8}", s.Color);
|
|
|
|
|
c.Style.BackColor = Color.FromArgb((int)s.Color);
|
2011-06-26 21:11:12 +00:00
|
|
|
|
c = SubGrid.Rows[x].Cells[5];
|
|
|
|
|
c.Value = s.Message;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-07-04 18:32:57 +00:00
|
|
|
|
|
2011-07-04 19:20:11 +00:00
|
|
|
|
private void ChangeRow(Subtitle s, int index)
|
|
|
|
|
{
|
|
|
|
|
if (index >= SubGrid.Rows.Count) return;
|
|
|
|
|
DataGridViewCell c = SubGrid.Rows[index].Cells[0];
|
|
|
|
|
c.Value = s.Frame;
|
|
|
|
|
c = SubGrid.Rows[index].Cells[1];
|
|
|
|
|
c.Value = s.X;
|
|
|
|
|
c = SubGrid.Rows[index].Cells[2];
|
|
|
|
|
c.Value = s.Y;
|
|
|
|
|
c = SubGrid.Rows[index].Cells[3];
|
|
|
|
|
c.Value = s.Duration;
|
|
|
|
|
c = SubGrid.Rows[index].Cells[4];
|
2011-07-04 20:34:53 +00:00
|
|
|
|
c.Value = String.Format("{0:X8}", s.Color);
|
|
|
|
|
c.Style.BackColor = Color.FromArgb((int)s.Color);
|
2011-07-04 19:20:11 +00:00
|
|
|
|
c = SubGrid.Rows[index].Cells[5];
|
|
|
|
|
c.Value = s.Message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Subtitle GetRow(int index)
|
|
|
|
|
{
|
|
|
|
|
if (index >= SubGrid.Rows.Count) return new Subtitle();
|
|
|
|
|
|
|
|
|
|
Subtitle s = new Subtitle();
|
|
|
|
|
DataGridViewCell c = SubGrid.Rows[index].Cells[0];
|
|
|
|
|
|
|
|
|
|
//Empty catch because it should default to subtitle default value
|
|
|
|
|
try { s.Frame = int.Parse(c.Value.ToString()); }
|
|
|
|
|
catch { }
|
|
|
|
|
c = SubGrid.Rows[index].Cells[1];
|
|
|
|
|
try { s.X = int.Parse(c.Value.ToString()); }
|
|
|
|
|
catch { }
|
|
|
|
|
c = SubGrid.Rows[index].Cells[2];
|
|
|
|
|
try { s.Y = int.Parse(c.Value.ToString()); }
|
|
|
|
|
catch { }
|
|
|
|
|
c = SubGrid.Rows[index].Cells[3];
|
|
|
|
|
try { s.Duration = int.Parse(c.Value.ToString()); }
|
|
|
|
|
catch { }
|
|
|
|
|
c = SubGrid.Rows[index].Cells[4];
|
|
|
|
|
try { s.Color = uint.Parse(c.Value.ToString()); }
|
|
|
|
|
catch { }
|
|
|
|
|
c = SubGrid.Rows[index].Cells[5];
|
|
|
|
|
try { s.Message = c.Value.ToString(); }
|
|
|
|
|
catch { }
|
2013-10-28 01:31:30 +00:00
|
|
|
|
selectedMovie.Subtitles.Add(s);
|
2011-07-04 19:20:11 +00:00
|
|
|
|
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-04 18:32:57 +00:00
|
|
|
|
private void SubGrid_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2011-07-16 13:31:36 +00:00
|
|
|
|
if (ReadOnly) return;
|
2011-07-04 19:20:11 +00:00
|
|
|
|
DataGridViewSelectedRowCollection c = SubGrid.SelectedRows;
|
|
|
|
|
if (c.Count == 0) return;
|
2011-07-04 18:32:57 +00:00
|
|
|
|
SubtitleMaker s = new SubtitleMaker();
|
2011-07-04 19:20:11 +00:00
|
|
|
|
s.sub = GetRow(c[0].Index);
|
2011-07-04 18:32:57 +00:00
|
|
|
|
if (s.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
2011-07-04 19:20:11 +00:00
|
|
|
|
ChangeRow(s.sub, SubGrid.SelectedRows[0].Index);
|
2011-07-16 13:31:36 +00:00
|
|
|
|
//if (SubGrid.Rows.Count == SubGrid.SelectedRows[0].Index + 1)
|
|
|
|
|
// SubGrid.Rows.Add(); //Why does this case ChangeRow to edit the new changed row?
|
2011-07-04 18:32:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-26 20:26:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|