support custom AR selection in addition to custom exact-specified resolution

This commit is contained in:
zeromus 2015-10-25 02:15:59 -05:00
parent 84be5d211c
commit 4fe51a1364
4 changed files with 140 additions and 37 deletions

View File

@ -116,7 +116,11 @@ namespace BizHawk.Client.Common
public enum ESoundOutputMethod { DirectSound, XAudio2, OpenAL, Dummy };
public enum EDispManagerAR { None, System, Custom };
public enum EDispManagerAR { None, System,
//actually, custom SIZE (fixme on major release)
Custom,
CustomRatio
};
public enum SaveStateTypeE { Default, Binary, Text };
@ -273,9 +277,14 @@ namespace BizHawk.Client.Common
public bool DispChrome_Fullscreen_AutohideMouse = true;
public bool DispChrome_AllowDoubleClickFullscreen = true;
public EDispManagerAR DispManagerAR = EDispManagerAR.System;
public int DispCustomUserARWidth = 1;
public int DispCustomUserARHeight = 1;
public EDispManagerAR DispManagerAR = EDispManagerAR.System;
//these are misnomers. they're actually a fixed size (fixme on major release)
public int DispCustomUserARWidth = -1;
public int DispCustomUserARHeight = -1;
//these are more like the actual AR ratio (i.e. 4:3) (fixme on major release)
public float DispCustomUserARX = -1;
public float DispCustomUserARY = -1;
// Sound options
#if WINDOWS

View File

@ -379,6 +379,24 @@ namespace BizHawk.Client.EmuHawk
public int BackgroundColor { get; set; }
}
void FixRatio(float x, float y, int inw, int inh, out int outw, out int outh)
{
float ratio = x / y;
if (ratio <= 1)
{
//taller. weird. expand height.
outw = inw;
outh = (int)((float)inw / ratio);
}
else
{
//wider. normal. expand width.
outw = (int)((float)inh * ratio);
outh = inh;
}
}
/// <summary>
/// Attempts to calculate a good client size with the given zoom factor, considering the user's DisplayManager preferences
/// TODO - this needs to be redone with a concept different from zoom factor.
@ -389,7 +407,8 @@ namespace BizHawk.Client.EmuHawk
bool ar_active = Global.Config.DispFixAspectRatio;
bool ar_system = Global.Config.DispManagerAR == Config.EDispManagerAR.System;
bool ar_custom = Global.Config.DispManagerAR == Config.EDispManagerAR.Custom;
bool ar_correct = ar_system || ar_custom;
bool ar_customRatio = Global.Config.DispManagerAR == Config.EDispManagerAR.CustomRatio;
bool ar_correct = ar_system || ar_custom || ar_customRatio;
bool ar_unity = !ar_correct;
bool ar_integer = Global.Config.DispFixScaleInteger;
@ -403,6 +422,11 @@ namespace BizHawk.Client.EmuHawk
virtualWidth = Global.Config.DispCustomUserARWidth;
virtualHeight = Global.Config.DispCustomUserARHeight;
}
if (ar_customRatio)
{
FixRatio(Global.Config.DispCustomUserARX, Global.Config.DispCustomUserARY, videoProvider.BufferWidth, videoProvider.BufferHeight, out virtualWidth, out virtualHeight);
}
var padding = CalculateCompleteContentPadding(true, false);
virtualWidth += padding.Horizontal;
@ -557,6 +581,10 @@ namespace BizHawk.Client.EmuHawk
vw = Global.Config.DispCustomUserARWidth;
vh = Global.Config.DispCustomUserARHeight;
}
if (Global.Config.DispManagerAR == Config.EDispManagerAR.CustomRatio)
{
FixRatio(Global.Config.DispCustomUserARX, Global.Config.DispCustomUserARY, videoProvider.BufferWidth, videoProvider.BufferHeight, out vw, out vh);
}
}
var padding = CalculateCompleteContentPadding(true,false);

View File

@ -36,6 +36,7 @@
this.lblUserFilterName = new System.Windows.Forms.Label();
this.btnSelectUserFilter = new System.Windows.Forms.Button();
this.rbUser = new System.Windows.Forms.RadioButton();
this.tbScanlineIntensity = new BizHawk.Client.EmuHawk.TransparentTrackBar();
this.rbNone = new System.Windows.Forms.RadioButton();
this.rbScanlines = new System.Windows.Forms.RadioButton();
this.rbHq2x = new System.Windows.Forms.RadioButton();
@ -87,11 +88,15 @@
this.cbStatusBarWindowed = new System.Windows.Forms.CheckBox();
this.label9 = new System.Windows.Forms.Label();
this.cbMenuWindowed = new System.Windows.Forms.CheckBox();
this.trackbarFrameSizeWindowed = new BizHawk.Client.EmuHawk.TransparentTrackBar();
this.cbCaptionWindowed = new System.Windows.Forms.CheckBox();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.tbScanlineIntensity = new BizHawk.Client.EmuHawk.TransparentTrackBar();
this.trackbarFrameSizeWindowed = new BizHawk.Client.EmuHawk.TransparentTrackBar();
this.rbUseCustomRatio = new System.Windows.Forms.RadioButton();
this.txtCustomARY = new System.Windows.Forms.TextBox();
this.label12 = new System.Windows.Forms.Label();
this.txtCustomARX = new System.Windows.Forms.TextBox();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.tbScanlineIntensity)).BeginInit();
this.grpFinalFilter.SuspendLayout();
this.grpARSelection.SuspendLayout();
this.tabControl1.SuspendLayout();
@ -104,7 +109,6 @@
this.tabPage1.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.tbScanlineIntensity)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trackbarFrameSizeWindowed)).BeginInit();
this.SuspendLayout();
//
@ -186,6 +190,19 @@
this.rbUser.Text = "User";
this.rbUser.UseVisualStyleBackColor = true;
//
// tbScanlineIntensity
//
this.tbScanlineIntensity.LargeChange = 32;
this.tbScanlineIntensity.Location = new System.Drawing.Point(83, 55);
this.tbScanlineIntensity.Maximum = 256;
this.tbScanlineIntensity.Name = "tbScanlineIntensity";
this.tbScanlineIntensity.Size = new System.Drawing.Size(70, 42);
this.tbScanlineIntensity.TabIndex = 3;
this.tbScanlineIntensity.TickFrequency = 32;
this.tbScanlineIntensity.TickStyle = System.Windows.Forms.TickStyle.TopLeft;
this.tbScanlineIntensity.Scroll += new System.EventHandler(this.tbScanlineIntensity_Scroll);
this.tbScanlineIntensity.ValueChanged += new System.EventHandler(this.tbScanlineIntensity_Scroll);
//
// rbNone
//
this.rbNone.AutoSize = true;
@ -233,7 +250,7 @@
// checkPadInteger
//
this.checkPadInteger.AutoSize = true;
this.checkPadInteger.Location = new System.Drawing.Point(15, 284);
this.checkPadInteger.Location = new System.Drawing.Point(15, 307);
this.checkPadInteger.Name = "checkPadInteger";
this.checkPadInteger.Size = new System.Drawing.Size(248, 17);
this.checkPadInteger.TabIndex = 9;
@ -312,6 +329,10 @@
//
// grpARSelection
//
this.grpARSelection.Controls.Add(this.txtCustomARY);
this.grpARSelection.Controls.Add(this.label12);
this.grpARSelection.Controls.Add(this.txtCustomARX);
this.grpARSelection.Controls.Add(this.rbUseCustomRatio);
this.grpARSelection.Controls.Add(this.label4);
this.grpARSelection.Controls.Add(this.txtCustomARHeight);
this.grpARSelection.Controls.Add(this.label3);
@ -321,7 +342,7 @@
this.grpARSelection.Controls.Add(this.rbUseSystem);
this.grpARSelection.Location = new System.Drawing.Point(15, 171);
this.grpARSelection.Name = "grpARSelection";
this.grpARSelection.Size = new System.Drawing.Size(377, 107);
this.grpARSelection.Size = new System.Drawing.Size(377, 130);
this.grpARSelection.TabIndex = 13;
this.grpARSelection.TabStop = false;
this.grpARSelection.Text = "Aspect Ratio Selection";
@ -363,10 +384,10 @@
this.rbUseCustom.AutoSize = true;
this.rbUseCustom.Location = new System.Drawing.Point(26, 80);
this.rbUseCustom.Name = "rbUseCustom";
this.rbUseCustom.Size = new System.Drawing.Size(107, 17);
this.rbUseCustom.Size = new System.Drawing.Size(105, 17);
this.rbUseCustom.TabIndex = 13;
this.rbUseCustom.TabStop = true;
this.rbUseCustom.Text = "Use custom Size:";
this.rbUseCustom.Text = "Use custom size:";
this.rbUseCustom.UseVisualStyleBackColor = true;
//
// label2
@ -753,6 +774,17 @@
this.cbMenuWindowed.Text = "Menu";
this.cbMenuWindowed.UseVisualStyleBackColor = true;
//
// trackbarFrameSizeWindowed
//
this.trackbarFrameSizeWindowed.LargeChange = 1;
this.trackbarFrameSizeWindowed.Location = new System.Drawing.Point(6, 33);
this.trackbarFrameSizeWindowed.Maximum = 2;
this.trackbarFrameSizeWindowed.Name = "trackbarFrameSizeWindowed";
this.trackbarFrameSizeWindowed.Size = new System.Drawing.Size(99, 42);
this.trackbarFrameSizeWindowed.TabIndex = 21;
this.trackbarFrameSizeWindowed.Value = 1;
this.trackbarFrameSizeWindowed.ValueChanged += new System.EventHandler(this.trackbarFrameSizeWindowed_ValueChanged);
//
// cbCaptionWindowed
//
this.cbCaptionWindowed.AutoSize = true;
@ -774,29 +806,39 @@
this.linkLabel1.Text = "Documentation";
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
//
// tbScanlineIntensity
// rbUseCustomRatio
//
this.tbScanlineIntensity.LargeChange = 32;
this.tbScanlineIntensity.Location = new System.Drawing.Point(83, 55);
this.tbScanlineIntensity.Maximum = 256;
this.tbScanlineIntensity.Name = "tbScanlineIntensity";
this.tbScanlineIntensity.Size = new System.Drawing.Size(70, 42);
this.tbScanlineIntensity.TabIndex = 3;
this.tbScanlineIntensity.TickFrequency = 32;
this.tbScanlineIntensity.TickStyle = System.Windows.Forms.TickStyle.TopLeft;
this.tbScanlineIntensity.Scroll += new System.EventHandler(this.tbScanlineIntensity_Scroll);
this.tbScanlineIntensity.ValueChanged += new System.EventHandler(this.tbScanlineIntensity_Scroll);
this.rbUseCustomRatio.AutoSize = true;
this.rbUseCustomRatio.Location = new System.Drawing.Point(26, 103);
this.rbUseCustomRatio.Name = "rbUseCustomRatio";
this.rbUseCustomRatio.Size = new System.Drawing.Size(102, 17);
this.rbUseCustomRatio.TabIndex = 16;
this.rbUseCustomRatio.TabStop = true;
this.rbUseCustomRatio.Text = "Use custom AR:";
this.rbUseCustomRatio.UseVisualStyleBackColor = true;
//
// trackbarFrameSizeWindowed
// txtCustomARY
//
this.trackbarFrameSizeWindowed.LargeChange = 1;
this.trackbarFrameSizeWindowed.Location = new System.Drawing.Point(6, 33);
this.trackbarFrameSizeWindowed.Maximum = 2;
this.trackbarFrameSizeWindowed.Name = "trackbarFrameSizeWindowed";
this.trackbarFrameSizeWindowed.Size = new System.Drawing.Size(99, 42);
this.trackbarFrameSizeWindowed.TabIndex = 21;
this.trackbarFrameSizeWindowed.Value = 1;
this.trackbarFrameSizeWindowed.ValueChanged += new System.EventHandler(this.trackbarFrameSizeWindowed_ValueChanged);
this.txtCustomARY.Location = new System.Drawing.Point(230, 102);
this.txtCustomARY.Name = "txtCustomARY";
this.txtCustomARY.Size = new System.Drawing.Size(72, 20);
this.txtCustomARY.TabIndex = 19;
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(212, 107);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(10, 13);
this.label12.TabIndex = 17;
this.label12.Text = ":";
//
// txtCustomARX
//
this.txtCustomARX.Location = new System.Drawing.Point(134, 102);
this.txtCustomARX.Name = "txtCustomARX";
this.txtCustomARX.Size = new System.Drawing.Size(72, 20);
this.txtCustomARX.TabIndex = 18;
//
// DisplayConfigLite
//
@ -815,6 +857,7 @@
this.Text = "Display Configuration";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.tbScanlineIntensity)).EndInit();
this.grpFinalFilter.ResumeLayout(false);
this.grpFinalFilter.PerformLayout();
this.grpARSelection.ResumeLayout(false);
@ -836,7 +879,6 @@
this.groupBox4.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.tbScanlineIntensity)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.trackbarFrameSizeWindowed)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@ -907,5 +949,9 @@
private System.Windows.Forms.RadioButton rbDisplayFull;
private System.Windows.Forms.CheckBox cbAllowDoubleclickFullscreen;
private System.Windows.Forms.LinkLabel linkLabel1;
private System.Windows.Forms.RadioButton rbUseCustomRatio;
private System.Windows.Forms.TextBox txtCustomARY;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.TextBox txtCustomARX;
}
}

View File

@ -76,9 +76,17 @@ namespace BizHawk.Client.EmuHawk.config
rbUseSystem.Checked = true;
else if (Global.Config.DispManagerAR == Config.EDispManagerAR.Custom)
rbUseCustom.Checked = true;
else if (Global.Config.DispManagerAR == Config.EDispManagerAR.CustomRatio)
rbUseCustomRatio.Checked = true;
txtCustomARWidth.Text = Global.Config.DispCustomUserARWidth.ToString();
txtCustomARHeight.Text = Global.Config.DispCustomUserARHeight.ToString();
if(Global.Config.DispCustomUserARWidth != -1)
txtCustomARWidth.Text = Global.Config.DispCustomUserARWidth.ToString();
if (Global.Config.DispCustomUserARHeight != -1)
txtCustomARHeight.Text = Global.Config.DispCustomUserARHeight.ToString();
if (Global.Config.DispCustomUserARX != -1)
txtCustomARX.Text = Global.Config.DispCustomUserARX.ToString();
if (Global.Config.DispCustomUserARY != -1)
txtCustomARY.Text = Global.Config.DispCustomUserARY.ToString();
RefreshAspectRatioOptions();
}
@ -141,9 +149,21 @@ namespace BizHawk.Client.EmuHawk.config
Global.Config.DispManagerAR = Config.EDispManagerAR.System;
else if (rbUseCustom.Checked)
Global.Config.DispManagerAR = Config.EDispManagerAR.Custom;
else if (rbUseCustomRatio.Checked)
Global.Config.DispManagerAR = Config.EDispManagerAR.CustomRatio;
int.TryParse(txtCustomARWidth.Text, out Global.Config.DispCustomUserARWidth);
int.TryParse(txtCustomARHeight.Text, out Global.Config.DispCustomUserARHeight);
if (txtCustomARWidth.Text != "")
int.TryParse(txtCustomARWidth.Text, out Global.Config.DispCustomUserARWidth);
else Global.Config.DispCustomUserARWidth = -1;
if (txtCustomARHeight.Text != "")
int.TryParse(txtCustomARHeight.Text, out Global.Config.DispCustomUserARHeight);
else Global.Config.DispCustomUserARHeight = -1;
if (txtCustomARX.Text != "")
float.TryParse(txtCustomARX.Text, out Global.Config.DispCustomUserARX);
else Global.Config.DispCustomUserARX = -1;
if (txtCustomARY.Text != "")
float.TryParse(txtCustomARY.Text, out Global.Config.DispCustomUserARY);
else Global.Config.DispCustomUserARY = -1;
var oldDisplayMethod = Global.Config.DispMethod;
if(rbOpenGL.Checked)