From 5e900992d09825f60acb7a3e2369fe4460cb3848 Mon Sep 17 00:00:00 2001 From: Sour Date: Sat, 28 Dec 2019 10:44:13 -0500 Subject: [PATCH] Video: Option to select exclusive fullscreen resolution --- Core/SettingTypes.h | 2 + UI/Config/VideoConfig.cs | 2 + UI/Dependencies/resources.en.xml | 1 + UI/Emulation/DisplayManager.cs | 29 +++-- UI/Forms/Config/frmVideoConfig.Designer.cs | 126 ++++++++++++++++----- UI/Forms/Config/frmVideoConfig.cs | 31 +++++ Windows/Renderer.cpp | 11 ++ 7 files changed, 167 insertions(+), 35 deletions(-) diff --git a/Core/SettingTypes.h b/Core/SettingTypes.h index 838854a..576e71c 100644 --- a/Core/SettingTypes.h +++ b/Core/SettingTypes.h @@ -105,6 +105,8 @@ struct VideoConfig bool FullscreenForceIntegerScale = false; bool UseExclusiveFullscreen = false; uint32_t ExclusiveFullscreenRefreshRate = 60; + uint32_t FullscreenResWidth = 0; + uint32_t FullscreenResHeight = 0; }; struct AudioConfig diff --git a/UI/Config/VideoConfig.cs b/UI/Config/VideoConfig.cs index 9ddca31..6477679 100644 --- a/UI/Config/VideoConfig.cs +++ b/UI/Config/VideoConfig.cs @@ -49,6 +49,8 @@ namespace Mesen.GUI.Config [MarshalAs(UnmanagedType.I1)] public bool FullscreenForceIntegerScale = false; [MarshalAs(UnmanagedType.I1)] public bool UseExclusiveFullscreen = false; public UInt32 ExclusiveFullscreenRefreshRate = 60; + public UInt32 FullscreenResWidth = 0; + public UInt32 FullscreenResHeight = 0; public void ApplyConfig() { diff --git a/UI/Dependencies/resources.en.xml b/UI/Dependencies/resources.en.xml index ac7e1bb..9ec0bd3 100644 --- a/UI/Dependencies/resources.en.xml +++ b/UI/Dependencies/resources.en.xml @@ -702,6 +702,7 @@ Expansion Device Press {0} to exit fullscreen + Default {0} roms found diff --git a/UI/Emulation/DisplayManager.cs b/UI/Emulation/DisplayManager.cs index aab06db..9ee2797 100644 --- a/UI/Emulation/DisplayManager.cs +++ b/UI/Emulation/DisplayManager.cs @@ -107,6 +107,9 @@ namespace Mesen.GUI.Emulation public void UpdateViewerSize() { + if(_frmFullscreenRenderer != null) { + return; + } if(HideMenuStrip) { _menu.Visible = false; } @@ -144,11 +147,6 @@ namespace Mesen.GUI.Emulation SetScaleBasedOnDimensions(_panel.ClientSize); } - private void SetScaleBasedOnScreenSize() - { - SetScaleBasedOnDimensions(Screen.FromControl(_frm).Bounds.Size); - } - public void SetScale(double scale, bool resizeForm) { _resizeForm = resizeForm; @@ -223,27 +221,44 @@ namespace Mesen.GUI.Emulation _fullscreenMode = false; } + private Size GetFullscreenResolution() + { + if(ConfigManager.Config.Video.FullscreenResWidth > 0 && ConfigManager.Config.Video.FullscreenResHeight > 0) { + return new Size((int)ConfigManager.Config.Video.FullscreenResWidth, (int)ConfigManager.Config.Video.FullscreenResHeight); + } + return Screen.FromControl(_frm).Bounds.Size; + } + private void StartExclusiveFullscreenMode() { - Size screenSize = Screen.FromControl(_frm).Bounds.Size; + Size screenSize = GetFullscreenResolution(); + Size originalWindowSize = _frm.Size; + double originalScale = ConfigManager.Config.Video.VideoScale; + _frm.Resize -= frmMain_Resize; + _frmFullscreenRenderer = new frmFullscreenRenderer(); _frmFullscreenRenderer.Shown += (object sender, EventArgs e) => { _renderer.Visible = false; - SetScaleBasedOnScreenSize(); + SetScaleBasedOnDimensions(screenSize); EmuApi.SetFullscreenMode(true, _frmFullscreenRenderer.Handle, (UInt32)screenSize.Width, (UInt32)screenSize.Height); }; _frmFullscreenRenderer.FormClosing += (object sender, FormClosingEventArgs e) => { EmuApi.SetFullscreenMode(false, _renderer.Handle, (UInt32)screenSize.Width, (UInt32)screenSize.Height); + _frm.Resize += frmMain_Resize; _frmFullscreenRenderer = null; _renderer.Visible = true; _fullscreenMode = false; frmMain_Resize(null, EventArgs.Empty); + + SetScale(originalScale, false); + _frm.Size = originalWindowSize; }; Screen currentScreen = Screen.FromHandle(_frm.Handle); _frmFullscreenRenderer.StartPosition = FormStartPosition.Manual; _frmFullscreenRenderer.Top = currentScreen.Bounds.Top; _frmFullscreenRenderer.Left = currentScreen.Bounds.Left; + _frmFullscreenRenderer.Size = screenSize; _frmFullscreenRenderer.Show(); } } diff --git a/UI/Forms/Config/frmVideoConfig.Designer.cs b/UI/Forms/Config/frmVideoConfig.Designer.cs index dbb2f6d..1fc34ef 100644 --- a/UI/Forms/Config/frmVideoConfig.Designer.cs +++ b/UI/Forms/Config/frmVideoConfig.Designer.cs @@ -61,6 +61,7 @@ this.trkSharpness = new Mesen.GUI.Controls.ctrlHorizontalTrackbar(); this.grpCommon = new System.Windows.Forms.GroupBox(); this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel(); + this.chkBlendHighResolutionModes = new System.Windows.Forms.CheckBox(); this.chkBilinearInterpolation = new System.Windows.Forms.CheckBox(); this.trkBrightness = new Mesen.GUI.Controls.ctrlHorizontalTrackbar(); this.trkContrast = new Mesen.GUI.Controls.ctrlHorizontalTrackbar(); @@ -99,7 +100,9 @@ this.mnuPresetSVideo = new System.Windows.Forms.ToolStripMenuItem(); this.mnuPresetRgb = new System.Windows.Forms.ToolStripMenuItem(); this.mnuPresetMonochrome = new System.Windows.Forms.ToolStripMenuItem(); - this.chkBlendHighResolutionModes = new System.Windows.Forms.CheckBox(); + this.flpResolution = new System.Windows.Forms.FlowLayoutPanel(); + this.lblFullscreenResolution = new System.Windows.Forms.Label(); + this.cboFullscreenResolution = new System.Windows.Forms.ComboBox(); this.tabMain.SuspendLayout(); this.tpgGeneral.SuspendLayout(); this.tlpMain.SuspendLayout(); @@ -124,6 +127,7 @@ this.tpgAdvanced.SuspendLayout(); this.tableLayoutPanel2.SuspendLayout(); this.ctxPicturePresets.SuspendLayout(); + this.flpResolution.SuspendLayout(); this.SuspendLayout(); // // baseConfigPanel @@ -161,20 +165,22 @@ this.tlpMain.ColumnCount = 2; this.tlpMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tlpMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tlpMain.Controls.Add(this.flpResolution, 0, 5); this.tlpMain.Controls.Add(this.chkUseExclusiveFullscreen, 0, 4); this.tlpMain.Controls.Add(this.lblVideoScale, 0, 0); this.tlpMain.Controls.Add(this.chkVerticalSync, 0, 3); this.tlpMain.Controls.Add(this.lblDisplayRatio, 0, 1); this.tlpMain.Controls.Add(this.nudScale, 1, 0); this.tlpMain.Controls.Add(this.flowLayoutPanel6, 1, 1); - this.tlpMain.Controls.Add(this.chkFullscreenForceIntegerScale, 0, 6); + this.tlpMain.Controls.Add(this.chkFullscreenForceIntegerScale, 0, 7); this.tlpMain.Controls.Add(this.chkIntegerFpsMode, 0, 2); - this.tlpMain.Controls.Add(this.flpRefreshRate, 0, 5); + this.tlpMain.Controls.Add(this.flpRefreshRate, 0, 6); this.tlpMain.Dock = System.Windows.Forms.DockStyle.Fill; this.tlpMain.Location = new System.Drawing.Point(3, 3); this.tlpMain.Margin = new System.Windows.Forms.Padding(0); this.tlpMain.Name = "tlpMain"; - this.tlpMain.RowCount = 8; + this.tlpMain.RowCount = 9; + this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); @@ -183,7 +189,6 @@ this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); this.tlpMain.Size = new System.Drawing.Size(560, 395); this.tlpMain.TabIndex = 1; // @@ -240,6 +245,7 @@ 0, 0, 0}); + this.nudScale.IsHex = false; this.nudScale.Location = new System.Drawing.Point(77, 0); this.nudScale.Margin = new System.Windows.Forms.Padding(0); this.nudScale.Maximum = new decimal(new int[] { @@ -310,6 +316,7 @@ 0, 0, 65536}); + this.nudCustomRatio.IsHex = false; this.nudCustomRatio.Location = new System.Drawing.Point(285, 3); this.nudCustomRatio.Margin = new System.Windows.Forms.Padding(0); this.nudCustomRatio.Maximum = new decimal(new int[] { @@ -339,7 +346,7 @@ this.chkFullscreenForceIntegerScale.Anchor = System.Windows.Forms.AnchorStyles.Left; this.chkFullscreenForceIntegerScale.AutoSize = true; this.tlpMain.SetColumnSpan(this.chkFullscreenForceIntegerScale, 2); - this.chkFullscreenForceIntegerScale.Location = new System.Drawing.Point(3, 146); + this.chkFullscreenForceIntegerScale.Location = new System.Drawing.Point(3, 173); this.chkFullscreenForceIntegerScale.Name = "chkFullscreenForceIntegerScale"; this.chkFullscreenForceIntegerScale.Size = new System.Drawing.Size(289, 17); this.chkFullscreenForceIntegerScale.TabIndex = 23; @@ -364,7 +371,7 @@ this.flpRefreshRate.Controls.Add(this.lblRequestedRefreshRate); this.flpRefreshRate.Controls.Add(this.cboRefreshRate); this.flpRefreshRate.Dock = System.Windows.Forms.DockStyle.Fill; - this.flpRefreshRate.Location = new System.Drawing.Point(30, 116); + this.flpRefreshRate.Location = new System.Drawing.Point(30, 143); this.flpRefreshRate.Margin = new System.Windows.Forms.Padding(30, 0, 0, 0); this.flpRefreshRate.Name = "flpRefreshRate"; this.flpRefreshRate.Size = new System.Drawing.Size(530, 27); @@ -651,6 +658,17 @@ this.tableLayoutPanel4.Size = new System.Drawing.Size(272, 249); this.tableLayoutPanel4.TabIndex = 4; // + // chkBlendHighResolutionModes + // + this.chkBlendHighResolutionModes.AutoSize = true; + this.tableLayoutPanel4.SetColumnSpan(this.chkBlendHighResolutionModes, 2); + this.chkBlendHighResolutionModes.Location = new System.Drawing.Point(3, 226); + this.chkBlendHighResolutionModes.Name = "chkBlendHighResolutionModes"; + this.chkBlendHighResolutionModes.Size = new System.Drawing.Size(158, 17); + this.chkBlendHighResolutionModes.TabIndex = 29; + this.chkBlendHighResolutionModes.Text = "Blend high resolution modes"; + this.chkBlendHighResolutionModes.UseVisualStyleBackColor = true; + // // chkBilinearInterpolation // this.chkBilinearInterpolation.AutoSize = true; @@ -796,7 +814,7 @@ this.tpgOverscan.Location = new System.Drawing.Point(4, 22); this.tpgOverscan.Name = "tpgOverscan"; this.tpgOverscan.Padding = new System.Windows.Forms.Padding(3); - this.tpgOverscan.Size = new System.Drawing.Size(566, 397); + this.tpgOverscan.Size = new System.Drawing.Size(566, 401); this.tpgOverscan.TabIndex = 6; this.tpgOverscan.Text = "Overscan"; this.tpgOverscan.UseVisualStyleBackColor = true; @@ -820,14 +838,14 @@ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 246F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(560, 391); + this.tableLayoutPanel1.Size = new System.Drawing.Size(560, 395); this.tableLayoutPanel1.TabIndex = 1; // // picOverscan // this.picOverscan.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.picOverscan.Dock = System.Windows.Forms.DockStyle.Fill; - this.picOverscan.Location = new System.Drawing.Point(152, 75); + this.picOverscan.Location = new System.Drawing.Point(152, 77); this.picOverscan.Name = "picOverscan"; this.picOverscan.Size = new System.Drawing.Size(256, 240); this.picOverscan.TabIndex = 1; @@ -846,7 +864,7 @@ this.tableLayoutPanel11.RowCount = 2; this.tableLayoutPanel11.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel11.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel11.Size = new System.Drawing.Size(262, 72); + this.tableLayoutPanel11.Size = new System.Drawing.Size(262, 74); this.tableLayoutPanel11.TabIndex = 4; // // nudOverscanTop @@ -858,7 +876,8 @@ 0, 0, 0}); - this.nudOverscanTop.Location = new System.Drawing.Point(110, 51); + this.nudOverscanTop.IsHex = false; + this.nudOverscanTop.Location = new System.Drawing.Point(110, 53); this.nudOverscanTop.Margin = new System.Windows.Forms.Padding(0); this.nudOverscanTop.Maximum = new decimal(new int[] { 100, @@ -886,7 +905,7 @@ // this.lblTop.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.lblTop.AutoSize = true; - this.lblTop.Location = new System.Drawing.Point(118, 38); + this.lblTop.Location = new System.Drawing.Point(118, 40); this.lblTop.Name = "lblTop"; this.lblTop.Size = new System.Drawing.Size(26, 13); this.lblTop.TabIndex = 0; @@ -899,7 +918,7 @@ this.tableLayoutPanel12.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel12.Controls.Add(this.nudOverscanBottom, 0, 1); this.tableLayoutPanel12.Controls.Add(this.lblBottom, 0, 0); - this.tableLayoutPanel12.Location = new System.Drawing.Point(149, 318); + this.tableLayoutPanel12.Location = new System.Drawing.Point(149, 320); this.tableLayoutPanel12.Margin = new System.Windows.Forms.Padding(0); this.tableLayoutPanel12.Name = "tableLayoutPanel12"; this.tableLayoutPanel12.RowCount = 2; @@ -917,6 +936,7 @@ 0, 0, 0}); + this.nudOverscanBottom.IsHex = false; this.nudOverscanBottom.Location = new System.Drawing.Point(110, 13); this.nudOverscanBottom.Margin = new System.Windows.Forms.Padding(0); this.nudOverscanBottom.Maximum = new decimal(new int[] { @@ -960,7 +980,7 @@ this.tableLayoutPanel13.Controls.Add(this.nudOverscanRight, 0, 2); this.tableLayoutPanel13.Controls.Add(this.lblRight, 0, 1); this.tableLayoutPanel13.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel13.Location = new System.Drawing.Point(411, 72); + this.tableLayoutPanel13.Location = new System.Drawing.Point(411, 74); this.tableLayoutPanel13.Margin = new System.Windows.Forms.Padding(0); this.tableLayoutPanel13.Name = "tableLayoutPanel13"; this.tableLayoutPanel13.RowCount = 4; @@ -980,6 +1000,7 @@ 0, 0, 0}); + this.nudOverscanRight.IsHex = false; this.nudOverscanRight.Location = new System.Drawing.Point(0, 119); this.nudOverscanRight.Margin = new System.Windows.Forms.Padding(0); this.nudOverscanRight.Maximum = new decimal(new int[] { @@ -1023,7 +1044,7 @@ this.tableLayoutPanel14.Controls.Add(this.nudOverscanLeft, 1, 2); this.tableLayoutPanel14.Controls.Add(this.lblLeft, 1, 1); this.tableLayoutPanel14.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel14.Location = new System.Drawing.Point(0, 72); + this.tableLayoutPanel14.Location = new System.Drawing.Point(0, 74); this.tableLayoutPanel14.Margin = new System.Windows.Forms.Padding(0); this.tableLayoutPanel14.Name = "tableLayoutPanel14"; this.tableLayoutPanel14.RowCount = 4; @@ -1043,6 +1064,7 @@ 0, 0, 0}); + this.nudOverscanLeft.IsHex = false; this.nudOverscanLeft.Location = new System.Drawing.Point(108, 119); this.nudOverscanLeft.Margin = new System.Windows.Forms.Padding(0); this.nudOverscanLeft.Maximum = new decimal(new int[] { @@ -1084,7 +1106,7 @@ this.tpgAdvanced.Location = new System.Drawing.Point(4, 22); this.tpgAdvanced.Name = "tpgAdvanced"; this.tpgAdvanced.Padding = new System.Windows.Forms.Padding(3); - this.tpgAdvanced.Size = new System.Drawing.Size(566, 397); + this.tpgAdvanced.Size = new System.Drawing.Size(566, 401); this.tpgAdvanced.TabIndex = 7; this.tpgAdvanced.Text = "Advanced"; this.tpgAdvanced.UseVisualStyleBackColor = true; @@ -1110,7 +1132,7 @@ this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel2.Size = new System.Drawing.Size(560, 391); + this.tableLayoutPanel2.Size = new System.Drawing.Size(560, 395); this.tableLayoutPanel2.TabIndex = 0; // // chkDisableFrameSkipping @@ -1211,16 +1233,59 @@ this.mnuPresetMonochrome.Text = "Monochrome"; this.mnuPresetMonochrome.Click += new System.EventHandler(this.mnuPresetMonochrome_Click); // - // chkBlendHighResolutionModes + // flpResolution // - this.chkBlendHighResolutionModes.AutoSize = true; - this.tableLayoutPanel4.SetColumnSpan(this.chkBlendHighResolutionModes, 2); - this.chkBlendHighResolutionModes.Location = new System.Drawing.Point(3, 226); - this.chkBlendHighResolutionModes.Name = "chkBlendHighResolutionModes"; - this.chkBlendHighResolutionModes.Size = new System.Drawing.Size(158, 17); - this.chkBlendHighResolutionModes.TabIndex = 29; - this.chkBlendHighResolutionModes.Text = "Blend high resolution modes"; - this.chkBlendHighResolutionModes.UseVisualStyleBackColor = true; + this.tlpMain.SetColumnSpan(this.flpResolution, 2); + this.flpResolution.Controls.Add(this.lblFullscreenResolution); + this.flpResolution.Controls.Add(this.cboFullscreenResolution); + this.flpResolution.Dock = System.Windows.Forms.DockStyle.Fill; + this.flpResolution.Location = new System.Drawing.Point(30, 116); + this.flpResolution.Margin = new System.Windows.Forms.Padding(30, 0, 0, 0); + this.flpResolution.Name = "flpResolution"; + this.flpResolution.Size = new System.Drawing.Size(530, 27); + this.flpResolution.TabIndex = 28; + this.flpResolution.Visible = false; + // + // lblFullscreenResolution + // + this.lblFullscreenResolution.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.lblFullscreenResolution.AutoSize = true; + this.lblFullscreenResolution.Location = new System.Drawing.Point(3, 7); + this.lblFullscreenResolution.Name = "lblFullscreenResolution"; + this.lblFullscreenResolution.Size = new System.Drawing.Size(111, 13); + this.lblFullscreenResolution.TabIndex = 17; + this.lblFullscreenResolution.Text = "Fullscreen Resolution:"; + // + // cboFullscreenResolution + // + this.cboFullscreenResolution.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cboFullscreenResolution.FormattingEnabled = true; + this.cboFullscreenResolution.Items.AddRange(new object[] { + "3840x2160", + "2560x1440", + "2160x1200", + "1920x1440", + "1920x1200", + "1920x1080", + "1680x1050", + "1600x1200", + "1600x1024", + "1600x900", + "1366x768", + "1360x768", + "1280x1024", + "1280x960", + "1280x800", + "1280x768", + "1280x720", + "1152x864", + "1024x768", + "800x600", + "640x480"}); + this.cboFullscreenResolution.Location = new System.Drawing.Point(120, 3); + this.cboFullscreenResolution.Name = "cboFullscreenResolution"; + this.cboFullscreenResolution.Size = new System.Drawing.Size(85, 21); + this.cboFullscreenResolution.TabIndex = 25; // // frmVideoConfig // @@ -1271,6 +1336,8 @@ this.tpgAdvanced.ResumeLayout(false); this.tableLayoutPanel2.ResumeLayout(false); this.ctxPicturePresets.ResumeLayout(false); + this.flpResolution.ResumeLayout(false); + this.flpResolution.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -1350,5 +1417,8 @@ private Controls.ctrlRiskyOption chkHideSprites; private Controls.ctrlRiskyOption chkDisableFrameSkipping; private System.Windows.Forms.CheckBox chkBlendHighResolutionModes; - } + private System.Windows.Forms.FlowLayoutPanel flpResolution; + private System.Windows.Forms.Label lblFullscreenResolution; + private System.Windows.Forms.ComboBox cboFullscreenResolution; + } } \ No newline at end of file diff --git a/UI/Forms/Config/frmVideoConfig.cs b/UI/Forms/Config/frmVideoConfig.cs index acdcbd6..0e4896d 100644 --- a/UI/Forms/Config/frmVideoConfig.cs +++ b/UI/Forms/Config/frmVideoConfig.cs @@ -63,6 +63,19 @@ namespace Mesen.GUI.Forms.Config AddBinding(nameof(VideoConfig.DisableFrameSkipping), chkDisableFrameSkipping); UpdateOverscanImage(picOverscan, 0, 0, 0, 0); + + if(Program.IsMono) { + //Not available in the linux build (for now) + chkUseExclusiveFullscreen.Visible = false; + } else { + cboFullscreenResolution.Items.Insert(0, ResourceHelper.GetMessage("DefaultResolution")); + string res = ConfigManager.Config.Video.FullscreenResWidth.ToString() + "x" + ConfigManager.Config.Video.FullscreenResHeight; + if(cboFullscreenResolution.Items.Contains(res)) { + cboFullscreenResolution.SelectedItem = res; + } else { + cboFullscreenResolution.SelectedIndex = 0; + } + } } protected override bool ValidateInput() @@ -80,6 +93,23 @@ namespace Mesen.GUI.Forms.Config protected override void OnApply() { + VideoConfig cfg = (VideoConfig)this.Entity; + if(cboFullscreenResolution.SelectedIndex > 0) { + string resolution = cboFullscreenResolution.SelectedItem.ToString(); + if(!string.IsNullOrWhiteSpace(resolution)) { + string[] resData = resolution.Split('x'); + uint width; + uint height; + if(uint.TryParse(resData[0], out width) && uint.TryParse(resData[1], out height)) { + cfg.FullscreenResWidth = width; + cfg.FullscreenResHeight = height; + } + } + } else { + cfg.FullscreenResWidth = 0; + cfg.FullscreenResHeight = 0; + } + ConfigManager.Config.Video = (VideoConfig)this.Entity; ConfigManager.ApplyChanges(); } @@ -162,6 +192,7 @@ namespace Mesen.GUI.Forms.Config private void chkUseExclusiveFullscreen_CheckedChanged(object sender, EventArgs e) { flpRefreshRate.Visible = chkUseExclusiveFullscreen.Checked; + flpResolution.Visible = chkUseExclusiveFullscreen.Checked; } } } diff --git a/Windows/Renderer.cpp b/Windows/Renderer.cpp index e00819e..65273ff 100644 --- a/Windows/Renderer.cpp +++ b/Windows/Renderer.cpp @@ -70,6 +70,17 @@ void Renderer::SetScreenSize(uint32_t width, uint32_t height) if(_fullscreen) { _realScreenHeight = _monitorHeight; _realScreenWidth = _monitorWidth; + + //Ensure the screen width/height is smaller or equal to the fullscreen resolution, no matter the requested scale + if(_monitorHeight < _screenHeight || _monitorWidth < _screenWidth) { + double scale = (double)screenSize.Width / (double)screenSize.Height; + _screenHeight = _monitorHeight; + _screenWidth = (uint32_t)(scale * _screenHeight); + if(_monitorWidth < _screenWidth) { + _screenWidth = _monitorWidth; + _screenHeight = (uint32_t)(_screenWidth / scale); + } + } } else { _realScreenHeight = screenSize.Height; _realScreenWidth = screenSize.Width;