From fed74b17b29dd48e383fd943046bb64cae22a62f Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Mon, 4 Jul 2011 20:34:53 +0000 Subject: [PATCH] Subtitle editor touchups - Make color cells the color they are representing, display color in hex, put try/catches + error messages if trying to parse erroneous data, tooltips for columns --- .../movie/EditSubtitlesForm.Designer.cs | 22 +++++++---- .../movie/EditSubtitlesForm.cs | 37 +++++++++++++------ .../movie/EditSubtitlesForm.resx | 2 +- .../movie/SubtitleMaker.Designer.cs | 5 --- 4 files changed, 40 insertions(+), 26 deletions(-) diff --git a/BizHawk.MultiClient/movie/EditSubtitlesForm.Designer.cs b/BizHawk.MultiClient/movie/EditSubtitlesForm.Designer.cs index 0ef26326a5..8cc14d5813 100644 --- a/BizHawk.MultiClient/movie/EditSubtitlesForm.Designer.cs +++ b/BizHawk.MultiClient/movie/EditSubtitlesForm.Designer.cs @@ -36,7 +36,7 @@ this.X = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Y = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Length = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Color = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.DispColor = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Message = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.SubGrid)).BeginInit(); this.SuspendLayout(); @@ -76,7 +76,7 @@ this.X, this.Y, this.Length, - this.Color, + this.DispColor, this.Message}); this.SubGrid.Location = new System.Drawing.Point(12, 12); this.SubGrid.Name = "SubGrid"; @@ -89,6 +89,7 @@ this.Frame.HeaderText = "Frame"; this.Frame.MaxInputLength = 7; this.Frame.Name = "Frame"; + this.Frame.ToolTipText = "The first frame the subtitle will be displayed (integer)"; this.Frame.Width = 75; // // X @@ -96,6 +97,7 @@ this.X.HeaderText = "X"; this.X.MaxInputLength = 3; this.X.Name = "X"; + this.X.ToolTipText = "Screen coordinate (absolute)"; this.X.Width = 30; // // Y @@ -103,6 +105,7 @@ this.Y.HeaderText = "Y"; this.Y.MaxInputLength = 3; this.Y.Name = "Y"; + this.Y.ToolTipText = "Screen coordinate (absolute)"; this.Y.Width = 30; // // Length @@ -110,14 +113,16 @@ this.Length.HeaderText = "Length"; this.Length.MaxInputLength = 5; this.Length.Name = "Length"; + this.Length.ToolTipText = "How long subtitle will be displayed"; this.Length.Width = 50; // - // Color + // DispColor // - this.Color.HeaderText = "Color"; - this.Color.MaxInputLength = 8; - this.Color.Name = "Color"; - this.Color.Width = 60; + this.DispColor.HeaderText = "Color"; + this.DispColor.MaxInputLength = 8; + this.DispColor.Name = "DispColor"; + this.DispColor.ToolTipText = "Color of subtitle text"; + this.DispColor.Width = 60; // // Message // @@ -126,6 +131,7 @@ this.Message.MaxInputLength = 255; this.Message.MinimumWidth = 25; this.Message.Name = "Message"; + this.Message.ToolTipText = "What will be displayed"; // // EditSubtitlesForm // @@ -155,7 +161,7 @@ private System.Windows.Forms.DataGridViewTextBoxColumn X; private System.Windows.Forms.DataGridViewTextBoxColumn Y; private System.Windows.Forms.DataGridViewTextBoxColumn Length; - private System.Windows.Forms.DataGridViewTextBoxColumn Color; + private System.Windows.Forms.DataGridViewTextBoxColumn DispColor; private System.Windows.Forms.DataGridViewTextBoxColumn Message; } } \ No newline at end of file diff --git a/BizHawk.MultiClient/movie/EditSubtitlesForm.cs b/BizHawk.MultiClient/movie/EditSubtitlesForm.cs index cd2352cafd..3673c2b11d 100644 --- a/BizHawk.MultiClient/movie/EditSubtitlesForm.cs +++ b/BizHawk.MultiClient/movie/EditSubtitlesForm.cs @@ -14,10 +14,7 @@ namespace BizHawk.MultiClient public bool ReadOnly; private Movie selectedMovie = new Movie(); - //TODO: Tooltips on cells explaining format //TODO: Parse hex on color when saving - //TODO: try/catch on parsing int - //TODO: display color in hex when loading from movie //TODO: color if color cell = value of color cell public EditSubtitlesForm() @@ -44,6 +41,14 @@ namespace BizHawk.MultiClient this.Close(); } + private void ShowError(int row, int column) + { + DataGridViewCell c = SubGrid.Rows[row].Cells[column]; + string error = "Unable to parse value: " + c.Value.ToString(); + string caption = "Parse Error Row " + row.ToString() + " Column " + column.ToString(); + MessageBox.Show(error, caption, MessageBoxButtons.OK, MessageBoxIcon.Error); + } + private void OK_Click(object sender, EventArgs e) { if (!ReadOnly) @@ -52,18 +57,24 @@ namespace BizHawk.MultiClient for (int x = 0; x < SubGrid.Rows.Count - 1; x++) { Subtitle s = new Subtitle(); + DataGridViewCell c = SubGrid.Rows[x].Cells[0]; - //TODO: try/catch parsing - s.Frame = int.Parse(c.Value.ToString()); + try { s.Frame = int.Parse(c.Value.ToString()); } + catch { ShowError(x, 0); return; } c = SubGrid.Rows[x].Cells[1]; - s.X = int.Parse(c.Value.ToString()); + try { s.X = int.Parse(c.Value.ToString()); } + catch { ShowError(x, 1); return; } c = SubGrid.Rows[x].Cells[2]; - s.Y = int.Parse(c.Value.ToString()); + try { s.Y = int.Parse(c.Value.ToString()); } + catch { ShowError(x, 2); return; } c = SubGrid.Rows[x].Cells[3]; - s.Duration = int.Parse(c.Value.ToString()); + try { s.Duration = int.Parse(c.Value.ToString()); } + catch { ShowError(x, 3); return; } c = SubGrid.Rows[x].Cells[4]; - s.Color = uint.Parse(c.Value.ToString()); - c = SubGrid.Rows[x].Cells[5]; + try { s.Color = uint.Parse(c.Value.ToString()); } + catch { ShowError(x, 4); return; } + try { c = SubGrid.Rows[x].Cells[5]; } + catch { ShowError(x, 5); return; } s.Message = c.Value.ToString(); selectedMovie.Subtitles.AddSubtitle(s); } @@ -91,7 +102,8 @@ namespace BizHawk.MultiClient c = SubGrid.Rows[x].Cells[3]; c.Value = s.Duration; c = SubGrid.Rows[x].Cells[4]; - c.Value = s.Color; //TODO: view in hex + c.Value = String.Format("{0:X8}", s.Color); + c.Style.BackColor = Color.FromArgb((int)s.Color); c = SubGrid.Rows[x].Cells[5]; c.Value = s.Message; } @@ -109,7 +121,8 @@ namespace BizHawk.MultiClient c = SubGrid.Rows[index].Cells[3]; c.Value = s.Duration; c = SubGrid.Rows[index].Cells[4]; - c.Value = s.Color; //TODO: view in hex + c.Value = String.Format("{0:X8}", s.Color); + c.Style.BackColor = Color.FromArgb((int)s.Color); c = SubGrid.Rows[index].Cells[5]; c.Value = s.Message; } diff --git a/BizHawk.MultiClient/movie/EditSubtitlesForm.resx b/BizHawk.MultiClient/movie/EditSubtitlesForm.resx index 2b04ed0989..8511bc658d 100644 --- a/BizHawk.MultiClient/movie/EditSubtitlesForm.resx +++ b/BizHawk.MultiClient/movie/EditSubtitlesForm.resx @@ -129,7 +129,7 @@ True - + True diff --git a/BizHawk.MultiClient/movie/SubtitleMaker.Designer.cs b/BizHawk.MultiClient/movie/SubtitleMaker.Designer.cs index bd75981958..b0cd494ab1 100644 --- a/BizHawk.MultiClient/movie/SubtitleMaker.Designer.cs +++ b/BizHawk.MultiClient/movie/SubtitleMaker.Designer.cs @@ -145,11 +145,6 @@ this.DurationNumeric.Name = "DurationNumeric"; this.DurationNumeric.Size = new System.Drawing.Size(56, 20); this.DurationNumeric.TabIndex = 30; - this.DurationNumeric.Value = new decimal(new int[] { - 9999, - 0, - 0, - 0}); // // label4 //