From dbbfda1c852d31d0c4ced7ba45b9f580ee4d7ed2 Mon Sep 17 00:00:00 2001
From: zeromus <zeromus@zeromus.org>
Date: Tue, 17 Feb 2015 00:13:19 +0000
Subject: [PATCH] add (odd) resolution warning to choose a/v writer and make
 'autodetect' button apply CaptureOSD setting

---
 .../AVOut/VideoWriterChooserForm.Designer.cs  | 74 ++++++++++++++-----
 .../AVOut/VideoWriterChooserForm.cs           | 24 +++++-
 BizHawk.Client.EmuHawk/MainForm.cs            |  2 +-
 3 files changed, 79 insertions(+), 21 deletions(-)

diff --git a/BizHawk.Client.EmuHawk/AVOut/VideoWriterChooserForm.Designer.cs b/BizHawk.Client.EmuHawk/AVOut/VideoWriterChooserForm.Designer.cs
index e9dd9ca02e..923daaced3 100644
--- a/BizHawk.Client.EmuHawk/AVOut/VideoWriterChooserForm.Designer.cs
+++ b/BizHawk.Client.EmuHawk/AVOut/VideoWriterChooserForm.Designer.cs
@@ -41,18 +41,22 @@
 			this.buttonAuto = new System.Windows.Forms.Button();
 			this.panelSizeSelect = new System.Windows.Forms.Panel();
 			this.checkBoxPad = new System.Windows.Forms.CheckBox();
+			this.checkBoxASync = new System.Windows.Forms.CheckBox();
+			this.lblSize = new System.Windows.Forms.Label();
 			this.numericTextBoxW = new BizHawk.Client.EmuHawk.NumericTextBox();
 			this.numericTextBoxH = new BizHawk.Client.EmuHawk.NumericTextBox();
-			this.checkBoxASync = new System.Windows.Forms.CheckBox();
+			this.panel1 = new System.Windows.Forms.Panel();
+			this.lblResolutionWarning = new System.Windows.Forms.Label();
 			this.tableLayoutPanel4.SuspendLayout();
 			this.panelSizeSelect.SuspendLayout();
+			this.panel1.SuspendLayout();
 			this.SuspendLayout();
 			// 
 			// checkBoxResize
 			// 
 			this.checkBoxResize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
 			this.checkBoxResize.AutoSize = true;
-			this.checkBoxResize.Location = new System.Drawing.Point(347, 12);
+			this.checkBoxResize.Location = new System.Drawing.Point(347, 35);
 			this.checkBoxResize.Name = "checkBoxResize";
 			this.checkBoxResize.Size = new System.Drawing.Size(88, 17);
 			this.checkBoxResize.TabIndex = 9;
@@ -145,24 +149,24 @@
 			this.label4.AutoSize = true;
 			this.label4.Location = new System.Drawing.Point(3, 0);
 			this.label4.Name = "label4";
-			this.label4.Size = new System.Drawing.Size(30, 13);
+			this.label4.Size = new System.Drawing.Size(42, 13);
 			this.label4.TabIndex = 13;
-			this.label4.Text = "Size:";
+			this.label4.Text = "Resize:";
 			// 
 			// buttonAuto
 			// 
-			this.buttonAuto.Location = new System.Drawing.Point(0, 42);
+			this.buttonAuto.Location = new System.Drawing.Point(89, 42);
 			this.buttonAuto.Name = "buttonAuto";
-			this.buttonAuto.Size = new System.Drawing.Size(162, 23);
+			this.buttonAuto.Size = new System.Drawing.Size(70, 34);
 			this.buttonAuto.TabIndex = 14;
-			this.buttonAuto.Text = "Autodetect Size";
+			this.buttonAuto.Text = "/\\ Set As Resize";
 			this.buttonAuto.UseVisualStyleBackColor = true;
 			this.buttonAuto.Click += new System.EventHandler(this.buttonAuto_Click);
 			// 
 			// panelSizeSelect
 			// 
 			this.panelSizeSelect.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
-			this.panelSizeSelect.Controls.Add(this.checkBoxPad);
+			this.panelSizeSelect.Controls.Add(this.lblSize);
 			this.panelSizeSelect.Controls.Add(this.label4);
 			this.panelSizeSelect.Controls.Add(this.buttonAuto);
 			this.panelSizeSelect.Controls.Add(this.numericTextBoxW);
@@ -170,19 +174,38 @@
 			this.panelSizeSelect.Controls.Add(this.label3);
 			this.panelSizeSelect.Location = new System.Drawing.Point(347, 58);
 			this.panelSizeSelect.Name = "panelSizeSelect";
-			this.panelSizeSelect.Size = new System.Drawing.Size(162, 105);
+			this.panelSizeSelect.Size = new System.Drawing.Size(162, 84);
 			this.panelSizeSelect.TabIndex = 15;
 			// 
 			// checkBoxPad
 			// 
 			this.checkBoxPad.AutoSize = true;
-			this.checkBoxPad.Location = new System.Drawing.Point(0, 71);
+			this.checkBoxPad.Location = new System.Drawing.Point(444, 35);
 			this.checkBoxPad.Name = "checkBoxPad";
 			this.checkBoxPad.Size = new System.Drawing.Size(45, 17);
 			this.checkBoxPad.TabIndex = 15;
 			this.checkBoxPad.Text = "Pad";
 			this.checkBoxPad.UseVisualStyleBackColor = true;
 			// 
+			// checkBoxASync
+			// 
+			this.checkBoxASync.AutoSize = true;
+			this.checkBoxASync.Location = new System.Drawing.Point(347, 12);
+			this.checkBoxASync.Name = "checkBoxASync";
+			this.checkBoxASync.Size = new System.Drawing.Size(95, 17);
+			this.checkBoxASync.TabIndex = 16;
+			this.checkBoxASync.Text = "Alternate Sync";
+			this.checkBoxASync.UseVisualStyleBackColor = true;
+			// 
+			// lblSize
+			// 
+			this.lblSize.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
+			this.lblSize.Location = new System.Drawing.Point(3, 42);
+			this.lblSize.Name = "lblSize";
+			this.lblSize.Size = new System.Drawing.Size(80, 34);
+			this.lblSize.TabIndex = 16;
+			this.lblSize.Text = "Size:\r\nTestxTest";
+			// 
 			// numericTextBoxW
 			// 
 			this.numericTextBoxW.AllowDecimal = false;
@@ -203,15 +226,24 @@
 			this.numericTextBoxH.Size = new System.Drawing.Size(70, 20);
 			this.numericTextBoxH.TabIndex = 11;
 			// 
-			// checkBoxASync
+			// panel1
 			// 
-			this.checkBoxASync.AutoSize = true;
-			this.checkBoxASync.Location = new System.Drawing.Point(347, 35);
-			this.checkBoxASync.Name = "checkBoxASync";
-			this.checkBoxASync.Size = new System.Drawing.Size(95, 17);
-			this.checkBoxASync.TabIndex = 16;
-			this.checkBoxASync.Text = "Alternate Sync";
-			this.checkBoxASync.UseVisualStyleBackColor = true;
+			this.panel1.Controls.Add(this.lblResolutionWarning);
+			this.panel1.Location = new System.Drawing.Point(347, 148);
+			this.panel1.Name = "panel1";
+			this.panel1.Size = new System.Drawing.Size(162, 93);
+			this.panel1.TabIndex = 17;
+			// 
+			// lblResolutionWarning
+			// 
+			this.lblResolutionWarning.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+			this.lblResolutionWarning.Location = new System.Drawing.Point(4, 4);
+			this.lblResolutionWarning.Name = "lblResolutionWarning";
+			this.lblResolutionWarning.Size = new System.Drawing.Size(155, 98);
+			this.lblResolutionWarning.TabIndex = 0;
+			this.lblResolutionWarning.Text = "Resolution is not a multiple of 4! Odd or non-x4 resolutions breaks many codecs. " +
+    "Check your output carefully and adjust the window size or codec settings if need" +
+    "ed.";
 			// 
 			// VideoWriterChooserForm
 			// 
@@ -220,6 +252,8 @@
 			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
 			this.CancelButton = this.buttonCancel;
 			this.ClientSize = new System.Drawing.Size(521, 440);
+			this.Controls.Add(this.panel1);
+			this.Controls.Add(this.checkBoxPad);
 			this.Controls.Add(this.checkBoxASync);
 			this.Controls.Add(this.panelSizeSelect);
 			this.Controls.Add(this.tableLayoutPanel4);
@@ -235,6 +269,7 @@
 			this.tableLayoutPanel4.PerformLayout();
 			this.panelSizeSelect.ResumeLayout(false);
 			this.panelSizeSelect.PerformLayout();
+			this.panel1.ResumeLayout(false);
 			this.ResumeLayout(false);
 			this.PerformLayout();
 
@@ -257,5 +292,8 @@
 		private System.Windows.Forms.Panel panelSizeSelect;
 		private System.Windows.Forms.CheckBox checkBoxPad;
 		private System.Windows.Forms.CheckBox checkBoxASync;
+		private System.Windows.Forms.Label lblSize;
+		private System.Windows.Forms.Panel panel1;
+		private System.Windows.Forms.Label lblResolutionWarning;
 	}
 }
\ No newline at end of file
diff --git a/BizHawk.Client.EmuHawk/AVOut/VideoWriterChooserForm.cs b/BizHawk.Client.EmuHawk/AVOut/VideoWriterChooserForm.cs
index ce826f7ea8..f30af669f8 100644
--- a/BizHawk.Client.EmuHawk/AVOut/VideoWriterChooserForm.cs
+++ b/BizHawk.Client.EmuHawk/AVOut/VideoWriterChooserForm.cs
@@ -19,8 +19,28 @@ namespace BizHawk.Client.EmuHawk
 		VideoWriterChooserForm()
 		{
 			InitializeComponent();
+
+			CaptureWidth = Global.Emulator.CoreComm.NominalWidth;
+			CaptureHeight = Global.Emulator.CoreComm.NominalHeight;
+
+			if (Global.Config.AVI_CaptureOSD)
+			{
+				using (var bb = GlobalWin.MainForm.CaptureOSD())
+				{
+					CaptureWidth = bb.Width;
+					CaptureHeight = bb.Height;
+				}
+			}
+
+			lblSize.Text = string.Format("Size:\r\n{0}x{1}", CaptureWidth, CaptureHeight);
+
+			if (CaptureWidth % 4 != 0 || CaptureHeight % 4 != 0)
+				lblResolutionWarning.Visible = true;
+			else lblResolutionWarning.Visible = false;
 		}
 
+		int CaptureWidth, CaptureHeight;
+
 		/// <summary>
 		/// chose an IVideoWriter
 		/// </summary>
@@ -100,8 +120,8 @@ namespace BizHawk.Client.EmuHawk
 
 		private void buttonAuto_Click(object sender, EventArgs e)
 		{
-			numericTextBoxW.Text = Global.Emulator.CoreComm.NominalWidth.ToString();
-			numericTextBoxH.Text = Global.Emulator.CoreComm.NominalHeight.ToString();
+			numericTextBoxW.Text = CaptureWidth.ToString();
+			numericTextBoxH.Text = CaptureHeight.ToString();
 		}
 
 		private void buttonOK_Click(object sender, EventArgs e)
diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs
index f4174faf1c..54e7cb046c 100644
--- a/BizHawk.Client.EmuHawk/MainForm.cs
+++ b/BizHawk.Client.EmuHawk/MainForm.cs
@@ -2206,7 +2206,7 @@ namespace BizHawk.Client.EmuHawk
 				Global.Emulator.HasSavestates();
 		}
 
-		private BitmapBuffer CaptureOSD()
+		public BitmapBuffer CaptureOSD()
 		{
 			var bb = GlobalWin.DisplayManager.RenderOffscreen(Global.Emulator.VideoProvider(), true);
 			bb.Normalize(true);