diff --git a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj
index 4790981b13..3dc9de3b1f 100644
--- a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj
+++ b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj
@@ -242,9 +242,6 @@
Form
-
- AutofireConfig.cs
-
Form
@@ -561,6 +558,7 @@
CoreFeatureAnalysis.cs
+
diff --git a/BizHawk.Client.EmuHawk/CustomControls/AutosizedLabel.cs b/BizHawk.Client.EmuHawk/CustomControls/AutosizedLabel.cs
new file mode 100644
index 0000000000..270371e629
--- /dev/null
+++ b/BizHawk.Client.EmuHawk/CustomControls/AutosizedLabel.cs
@@ -0,0 +1,13 @@
+using System.Windows.Forms;
+
+namespace BizHawk.Client.EmuHawk.CustomControls
+{
+ public sealed class AutosizedLabel : Label
+ {
+ public AutosizedLabel(string labelText)
+ {
+ AutoSize = true;
+ Text = labelText;
+ }
+ }
+}
diff --git a/BizHawk.Client.EmuHawk/config/AutofireConfig.Designer.cs b/BizHawk.Client.EmuHawk/config/AutofireConfig.Designer.cs
deleted file mode 100644
index 8b07aca2ed..0000000000
--- a/BizHawk.Client.EmuHawk/config/AutofireConfig.Designer.cs
+++ /dev/null
@@ -1,192 +0,0 @@
-namespace BizHawk.Client.EmuHawk
-{
- partial class AutofireConfig
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AutofireConfig));
- this.Ok = new System.Windows.Forms.Button();
- this.Cancel = new System.Windows.Forms.Button();
- this.OnNumeric = new System.Windows.Forms.NumericUpDown();
- this.OffNumeric = new System.Windows.Forms.NumericUpDown();
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.LagFrameCheck = new System.Windows.Forms.CheckBox();
- ((System.ComponentModel.ISupportInitialize)(this.OnNumeric)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.OffNumeric)).BeginInit();
- this.groupBox1.SuspendLayout();
- this.SuspendLayout();
- //
- // Ok
- //
- this.Ok.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.Ok.Location = new System.Drawing.Point(108, 140);
- this.Ok.Name = "Ok";
- this.Ok.Size = new System.Drawing.Size(75, 23);
- this.Ok.TabIndex = 5;
- this.Ok.Text = "&OK";
- this.Ok.UseVisualStyleBackColor = true;
- this.Ok.Click += new System.EventHandler(this.Ok_Click);
- //
- // Cancel
- //
- this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.Cancel.Location = new System.Drawing.Point(189, 140);
- this.Cancel.Name = "Cancel";
- this.Cancel.Size = new System.Drawing.Size(75, 23);
- this.Cancel.TabIndex = 7;
- this.Cancel.Text = "&Cancel";
- this.Cancel.UseVisualStyleBackColor = true;
- this.Cancel.Click += new System.EventHandler(this.Cancel_Click);
- //
- // OnNumeric
- //
- this.OnNumeric.Location = new System.Drawing.Point(10, 32);
- this.OnNumeric.Maximum = new decimal(new int[] {
- 512,
- 0,
- 0,
- 0});
- this.OnNumeric.Minimum = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.OnNumeric.Name = "OnNumeric";
- this.OnNumeric.Size = new System.Drawing.Size(74, 20);
- this.OnNumeric.TabIndex = 2;
- this.OnNumeric.Value = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- //
- // OffNumeric
- //
- this.OffNumeric.Location = new System.Drawing.Point(101, 32);
- this.OffNumeric.Maximum = new decimal(new int[] {
- 512,
- 0,
- 0,
- 0});
- this.OffNumeric.Minimum = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.OffNumeric.Name = "OffNumeric";
- this.OffNumeric.Size = new System.Drawing.Size(74, 20);
- this.OffNumeric.TabIndex = 3;
- this.OffNumeric.Value = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(10, 16);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(21, 13);
- this.label1.TabIndex = 4;
- this.label1.Text = "On";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(101, 16);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(21, 13);
- this.label2.TabIndex = 5;
- this.label2.Text = "Off";
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.label1);
- this.groupBox1.Controls.Add(this.label2);
- this.groupBox1.Controls.Add(this.OnNumeric);
- this.groupBox1.Controls.Add(this.OffNumeric);
- this.groupBox1.Location = new System.Drawing.Point(13, 12);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(184, 70);
- this.groupBox1.TabIndex = 6;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "Autofire Pattern";
- //
- // LagFrameCheck
- //
- this.LagFrameCheck.AutoSize = true;
- this.LagFrameCheck.Location = new System.Drawing.Point(13, 100);
- this.LagFrameCheck.Name = "LagFrameCheck";
- this.LagFrameCheck.Size = new System.Drawing.Size(164, 17);
- this.LagFrameCheck.TabIndex = 8;
- this.LagFrameCheck.Text = "Take lag frames into account";
- this.LagFrameCheck.UseVisualStyleBackColor = true;
- //
- // AutofireConfig
- //
- this.AcceptButton = this.Ok;
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.CancelButton = this.Cancel;
- this.ClientSize = new System.Drawing.Size(276, 175);
- this.Controls.Add(this.LagFrameCheck);
- this.Controls.Add(this.groupBox1);
- this.Controls.Add(this.Cancel);
- this.Controls.Add(this.Ok);
- this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
- this.MaximizeBox = false;
- this.MaximumSize = new System.Drawing.Size(512, 512);
- this.MinimumSize = new System.Drawing.Size(218, 179);
- this.Name = "AutofireConfig";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
- this.Text = "Autofire Configuration";
- this.Load += new System.EventHandler(this.AutofireConfig_Load);
- ((System.ComponentModel.ISupportInitialize)(this.OnNumeric)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.OffNumeric)).EndInit();
- this.groupBox1.ResumeLayout(false);
- this.groupBox1.PerformLayout();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.Button Ok;
- private System.Windows.Forms.Button Cancel;
- private System.Windows.Forms.NumericUpDown OffNumeric;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.GroupBox groupBox1;
- public System.Windows.Forms.NumericUpDown OnNumeric;
- private System.Windows.Forms.CheckBox LagFrameCheck;
- }
-}
\ No newline at end of file
diff --git a/BizHawk.Client.EmuHawk/config/AutofireConfig.cs b/BizHawk.Client.EmuHawk/config/AutofireConfig.cs
index 7d23c15ead..009f6073a8 100644
--- a/BizHawk.Client.EmuHawk/config/AutofireConfig.cs
+++ b/BizHawk.Client.EmuHawk/config/AutofireConfig.cs
@@ -1,63 +1,115 @@
-using System;
+using System.ComponentModel;
+using System.Drawing;
using System.Windows.Forms;
using BizHawk.Client.Common;
+using BizHawk.Client.EmuHawk.CustomControls;
namespace BizHawk.Client.EmuHawk
{
- public partial class AutofireConfig : Form
+ public sealed class AutofireConfig : Form
{
+ private const decimal nudMaximum = 512.0M;
+ private const decimal nudMinimum = 1.0M;
+
+ private readonly NumericUpDown nudPatternOn;
+ private readonly NumericUpDown nudPatternOff;
+ private readonly CheckBox cbConsiderLagFrames;
+
public AutofireConfig()
{
- InitializeComponent();
+ static decimal ConstrainToNUDRange(decimal d) => d < nudMinimum ? nudMinimum : nudMaximum < d ? nudMaximum : d;
+ var nudSize = new Size(48, 19);
+ nudPatternOn = new NumericUpDown
+ {
+ Maximum = nudMaximum,
+ Minimum = nudMinimum,
+ Size = nudSize,
+ Value = ConstrainToNUDRange(Global.Config.AutofireOn)
+ };
+ nudPatternOff = new NumericUpDown
+ {
+ Maximum = nudMaximum,
+ Minimum = nudMinimum,
+ Size = nudSize,
+ Value = ConstrainToNUDRange(Global.Config.AutofireOff)
+ };
+ cbConsiderLagFrames = new CheckBox
+ {
+ AutoSize = true,
+ Checked = Global.Config.AutofireLagFrames,
+ Text = "Take lag frames into account",
+ UseVisualStyleBackColor = true
+ };
+ var labelAlignment = new Padding(0, 5, 0, 0);
+ var flpMain = new SingleColumnFLP
+ {
+ Anchor = AnchorStyles.Top | AnchorStyles.Left,
+ Controls =
+ {
+ new SingleRowFLP
+ {
+ Controls =
+ {
+ new AutosizedLabel("Pattern:") { Margin = labelAlignment },
+ nudPatternOn,
+ new AutosizedLabel("on,") { Margin = labelAlignment },
+ nudPatternOff,
+ new AutosizedLabel("off") { Margin = labelAlignment }
+ }
+ },
+ cbConsiderLagFrames
+ },
+ Location = new Point(12, 12)
+ };
+
+ var btnOk = new Button { Text = "&OK", UseVisualStyleBackColor = true };
+ btnOk.Click += (sender, e) =>
+ {
+ SaveControlsTo(Global.Config);
+ GlobalWin.OSD.AddMessage("Autofire settings saved");
+ Close();
+ };
+
+ var btnCancel = new Button { Text = "&Cancel", UseVisualStyleBackColor = true };
+ btnCancel.Click += (sender, e) =>
+ {
+ GlobalWin.OSD.AddMessage("Autofire config aborted");
+ Close();
+ };
+
+ SuspendLayout();
+ AcceptButton = btnOk;
+ AutoScaleDimensions = new SizeF(6F, 13F);
+ AutoScaleMode = AutoScaleMode.Font;
+ CancelButton = btnCancel;
+ ClientSize = new Size(276, 175);
+ Controls.AddRange(new Control[]
+ {
+ new SingleRowFLP
+ {
+ Anchor = AnchorStyles.Bottom | AnchorStyles.Right,
+ Controls = { btnOk, btnCancel },
+ Location = new Point(108, 140)
+ },
+ flpMain
+ });
+ Icon = (Icon) new ComponentResourceManager(typeof(AutofireConfig)).GetObject("$this.Icon");
+ MaximizeBox = false;
+ MaximumSize = new Size(512, 512);
+ MinimumSize = new Size(218, 179);
+ Name = "AutofireConfig";
+ StartPosition = FormStartPosition.CenterParent;
+ Text = "Autofire Configuration";
+ ResumeLayout();
}
- private void AutofireConfig_Load(object sender, EventArgs e)
+ private void SaveControlsTo(Config config)
{
- if (Global.Config.AutofireOn < OnNumeric.Minimum)
- {
- OnNumeric.Value = OnNumeric.Minimum;
- }
- else if (Global.Config.AutofireOn > OnNumeric.Maximum)
- {
- OnNumeric.Value = OnNumeric.Maximum;
- }
- else
- {
- OnNumeric.Value = Global.Config.AutofireOn;
- }
-
- if (Global.Config.AutofireOff < OffNumeric.Minimum)
- {
- OffNumeric.Value = OffNumeric.Minimum;
- }
- else if (Global.Config.AutofireOff > OffNumeric.Maximum)
- {
- OffNumeric.Value = OffNumeric.Maximum;
- }
- else
- {
- OffNumeric.Value = Global.Config.AutofireOff;
- }
-
- LagFrameCheck.Checked = Global.Config.AutofireLagFrames;
- }
-
- private void Ok_Click(object sender, EventArgs e)
- {
- Global.AutoFireController.On = Global.Config.AutofireOn = (int)OnNumeric.Value;
- Global.AutoFireController.Off = Global.Config.AutofireOff = (int)OffNumeric.Value;
- Global.Config.AutofireLagFrames = LagFrameCheck.Checked;
+ Global.AutoFireController.On = config.AutofireOn = (int) nudPatternOn.Value;
+ Global.AutoFireController.Off = config.AutofireOff = (int) nudPatternOff.Value;
+ config.AutofireLagFrames = cbConsiderLagFrames.Checked;
Global.AutofireStickyXORAdapter.SetOnOffPatternFromConfig();
-
- GlobalWin.OSD.AddMessage("Autofire settings saved");
- Close();
- }
-
- private void Cancel_Click(object sender, EventArgs e)
- {
- GlobalWin.OSD.AddMessage("Autofire config aborted");
- Close();
}
}
}
diff --git a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs
index 45a04a0e7e..20ea9d7681 100644
--- a/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs
+++ b/BizHawk.Client.EmuHawk/config/DisplayConfigLite.cs
@@ -116,7 +116,7 @@ namespace BizHawk.Client.EmuHawk
{
Controls =
{
- new Label { AutoSize = true, Text = "• Probably the best for older graphics cards\n• May cause issues with OpenGL-based cores (i.e. Mupen64Plus)" },
+ new AutosizedLabel("• Probably the best for older graphics cards\n• May cause issues with OpenGL-based cores (i.e. Mupen64Plus)"),
cbAlternateVsync,
new Label { Margin = indent, Size = new Size(320, 40), Text = Resources.GetString("lblD3DAltVSync.Text") }
},
@@ -125,9 +125,15 @@ namespace BizHawk.Client.EmuHawk
Size = new Size(392, 76)
},
rbOpenGL,
- new Label { AutoSize = true, Margin = indent, Text = "• May have reduced performance or even malfunction on some systems\n• May have increased performance with OpenGL-based emulation cores (i.e. Mupen64Plus)" },
+ new AutosizedLabel("• May have reduced performance or even malfunction on some systems\n• May have increased performance with OpenGL-based emulation cores (i.e. Mupen64Plus)")
+ {
+ Margin = indent
+ },
rbGDIPlus,
- new Label { AutoSize = true, Margin = indent, Text = "• Slow and missing features, kept in to maximise compatibility\n• Works better over MS' Remote Desktop Protocol" }
+ new AutosizedLabel("• Slow and missing features, kept in to maximise compatibility\n• Works better over MS' Remote Desktop Protocol")
+ {
+ Margin = indent
+ }
},
InnerFLP = { AutoSize = true, Padding = new Padding(3, 0, 3, 0) },
Size = new Size(480, 230)
@@ -151,7 +157,7 @@ namespace BizHawk.Client.EmuHawk
Controls =
{
grpDispMethodRadios,
- new Label { AutoSize = true, Text = "Changes require restart of program to take effect.\n\nPlease note that, for now, Mupen64Plus will use OpenGL regardless of this setting." }
+ new AutosizedLabel("Changes require restart of program to take effect.\n\nPlease note that, for now, Mupen64Plus will use OpenGL regardless of this setting.")
},
Size = new Size(416, 304)
}
@@ -202,7 +208,7 @@ namespace BizHawk.Client.EmuHawk
return new FLPInGroupBox
{
Controls = {
- new SingleRowFLP { Controls = { new Label { AutoSize = true, Text = "Frame:" }, lblFrameTypeWindowed } },
+ new SingleRowFLP { Controls = { new AutosizedLabel("Frame:"), lblFrameTypeWindowed } },
tbFrameSizeWindowed,
cbStatusBarWindowed,
cbCaptionWindowed,
@@ -424,7 +430,7 @@ namespace BizHawk.Client.EmuHawk
{
rbUseRaw = new RadioButton { AutoSize = true, Text = "Use 1:1 pixel size (for crispness or debugging)", UseVisualStyleBackColor = true };
- var lblNonSquareAR = new Label { AutoSize = true, Text = "Allowing pixel distortion (e.g. 2x1 pixels, for better AR fit):" };
+ var lblNonSquareAR = new AutosizedLabel("Allowing pixel distortion (e.g. 2x1 pixels, for better AR fit):");
rbUseSystem = new RadioButton { AutoSize = true, Text = "Use system's recommendation", UseVisualStyleBackColor = true };
@@ -433,7 +439,8 @@ namespace BizHawk.Client.EmuHawk
var textBoxSize = new Size(48, 19);
txtCustomARWidth = new TextBox { Size = textBoxSize };
- var lblWHSeparator = new Label { AutoSize = true, Margin = new Padding(0, 5, 0, 0), Text = "x" };
+ var labelAlignment = new Padding(0, 5, 0, 0);
+ var lblWHSeparator = new AutosizedLabel("x") { Margin = labelAlignment };
txtCustomARHeight = new TextBox { Size = textBoxSize };
@@ -441,7 +448,7 @@ namespace BizHawk.Client.EmuHawk
txtCustomARX = new TextBox { Size = textBoxSize };
- var lblXYSeparator = new Label { AutoSize = true, Margin = new Padding(0, 5, 0, 0), Text = ":" };
+ var lblXYSeparator = new AutosizedLabel(":") { Margin = labelAlignment };
txtCustomARY = new TextBox { Size = textBoxSize };
@@ -494,7 +501,7 @@ namespace BizHawk.Client.EmuHawk
SingleRowFLP CreateCropFLP(string labelText, Control textBox) => new SingleRowFLP
{
- Controls = { new Label { Anchor = AnchorStyles.None, AutoSize = true, Text = labelText }, textBox },
+ Controls = { new AutosizedLabel(labelText) { Anchor = AnchorStyles.None }, textBox },
Margin = Padding.Empty
};
return new FLPInGroupBox
@@ -607,9 +614,9 @@ namespace BizHawk.Client.EmuHawk
{
Controls =
{
- new Label { Anchor = AnchorStyles.None, AutoSize = true, Text = "User Prescale:" },
+ new AutosizedLabel("User Prescale:") { Anchor = AnchorStyles.None },
nudPrescale,
- new Label { Anchor = AnchorStyles.None, AutoSize = true, Text = "X" }
+ new AutosizedLabel("x") { Anchor = AnchorStyles.None }
},
Margin = new Padding(3, 0, 3, 0)
},
@@ -686,7 +693,10 @@ namespace BizHawk.Client.EmuHawk
Controls = {
grpDispFeatures,
cbNullHawkWhiteNoise,
- new Label { AutoSize = true, Margin = new Padding(24, 0, 0, 0), Text = "Some people think the white noise is a great idea, and some people don't.\nDisabling this displays black instead." }
+ new AutosizedLabel("Some people think the white noise is a great idea, and some people don't.\nDisabling this displays black instead.")
+ {
+ Margin = new Padding(24, 0, 0, 0)
+ }
}
}
},
diff --git a/BizHawk.Client.EmuHawk/config/SoundConfig.cs b/BizHawk.Client.EmuHawk/config/SoundConfig.cs
index 7d465cd120..bd97ba9d34 100644
--- a/BizHawk.Client.EmuHawk/config/SoundConfig.cs
+++ b/BizHawk.Client.EmuHawk/config/SoundConfig.cs
@@ -55,7 +55,7 @@ namespace BizHawk.Client.EmuHawk
var flpRWFFW = new SingleColumnFLP
{
- Controls = { new Label { AutoSize = true, Text = "RW/FFW" }, cbEnableRWFFW, tbRWFFW, nudRWFFW },
+ Controls = { new AutosizedLabel("RW/FFW"), cbEnableRWFFW, tbRWFFW, nudRWFFW },
Margin = Padding.Empty
};
cbEnableNormal.CheckedChanged += (sender, e) => flpRWFFW.Enabled = ((CheckBox) sender).Checked;
@@ -66,7 +66,7 @@ namespace BizHawk.Client.EmuHawk
Controls = {
new SingleColumnFLP
{
- Controls = { new Label { AutoSize = true, Text = "Normal" }, cbEnableNormal, tbNormal, nudNormal },
+ Controls = { new AutosizedLabel("Normal"), cbEnableNormal, tbNormal, nudNormal },
Margin = Padding.Empty
},
flpRWFFW
@@ -140,12 +140,13 @@ namespace BizHawk.Client.EmuHawk
var flpDeviceSelector = new SingleColumnFLP
{
AutoSize = false,
- Controls = { new Label { AutoSize = true, Text = "Sound Device:" }, lbSoundDevices },
+ Controls = { new AutosizedLabel("Sound Device:"), lbSoundDevices },
Size = new Size(254, 112)
};
nudBufferSize = new NumericUpDown { Maximum = 250.0M, Minimum = 30.0M, Size = nudSize, Value = Global.Config.SoundBufferSizeMs };
+ var labelAlignment = new Padding(0, 5, 0, 0);
var flpRHS = new FlowLayoutPanel
{
AutoSize = true,
@@ -156,7 +157,7 @@ namespace BizHawk.Client.EmuHawk
Controls =
{
cbEnableMaster,
- new Label { AutoSize = true, Margin = new Padding(24, 0, 0, 16), Text = "Controls whether cores\neven generate audio." },
+ new AutosizedLabel("Controls whether cores\neven generate audio.") { Margin = new Padding(24, 0, 0, 16) },
cbMuteFrameAdvance
}
},
@@ -166,9 +167,9 @@ namespace BizHawk.Client.EmuHawk
{
Controls =
{
- new Label { AutoSize = true, Margin = new Padding(0, 4, 0, 0), Text = "Buffer Size:" },
+ new AutosizedLabel("Buffer Size:") { Margin = labelAlignment },
nudBufferSize,
- new Label { AutoSize = true, Margin = new Padding(0, 4, 0, 0), Text = "milliseconds" }
+ new AutosizedLabel("milliseconds") { Margin = labelAlignment }
}
}
}