From af1ed549f4eecb451da36fa3b393236d489cdb97 Mon Sep 17 00:00:00 2001 From: oddMLan Date: Tue, 21 Apr 2020 01:25:38 -0700 Subject: [PATCH] GLideNUI: Add custom windowed resolution by editable combobox Also fixed bug in which switching profiles would cause the Windowed resolution list to load more than once. --- src/GLideNUI-wtl/GLideNUI.rc | Bin 53050 -> 53042 bytes src/GLideNUI-wtl/config-video.cpp | 29 ++++++++++++++++++++++------- src/GLideNUI-wtl/config-video.h | 4 ++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/GLideNUI-wtl/GLideNUI.rc b/src/GLideNUI-wtl/GLideNUI.rc index 4c5afeffe4354cf20247cad7279a83b3bb05aade..45d1008d501522549cc91174c092233fb45e2cb7 100644 GIT binary patch delta 18 acmdlrk9pHP<_$NrCNENU*sP!}wFCfAK?k(} delta 22 ecmdlqk9pTT<_$NrCOd?BOg<;Ave`!a+hPE9LJA}R diff --git a/src/GLideNUI-wtl/config-video.cpp b/src/GLideNUI-wtl/config-video.cpp index 051015ef..3e04acf8 100644 --- a/src/GLideNUI-wtl/config-video.cpp +++ b/src/GLideNUI-wtl/config-video.cpp @@ -280,14 +280,18 @@ void CVideoTab::ShowOverScanTab(int nTab) { void CVideoTab::LoadSettings(bool /*blockCustomSettings*/) { CComboBox WindowedResolutionComboBox(GetDlgItem(IDC_CMB_WINDOWED_RESOLUTION)); - for (unsigned int i = 0; i < numWindowedModes; ++i) { - int index = WindowedResolutionComboBox.AddString(WindowedModes[i].description); - WindowedResolutionComboBox.SetItemData(index, i); - if (WindowedModes[i].width == config.video.windowedWidth && WindowedModes[i].height == config.video.windowedHeight) - WindowedResolutionComboBox.SetCurSel(index); + if (WindowedResolutionComboBox.GetCount() == 0) { + for (unsigned int i = 0; i < numWindowedModes; ++i) { + int index = WindowedResolutionComboBox.AddString(WindowedModes[i].description); + WindowedResolutionComboBox.SetItemData(index, i); + if (WindowedModes[i].width == config.video.windowedWidth && WindowedModes[i].height == config.video.windowedHeight) + WindowedResolutionComboBox.SetCurSel(index); + } + if (WindowedResolutionComboBox.GetCount() > 0 && WindowedResolutionComboBox.GetCurSel() < 0) { + WindowedResolutionComboBox.AddString(FormatStrW(L"%d x %d", config.video.windowedWidth, config.video.windowedHeight).c_str()); + WindowedResolutionComboBox.SetCurSel(numWindowedModes); + } } - if (WindowedResolutionComboBox.GetCount() > 0 && WindowedResolutionComboBox.GetCurSel() < 0) - WindowedResolutionComboBox.SetCurSel(0); CButton overscanCheckBox(GetDlgItem(IDC_CHK_OVERSCAN)); overscanCheckBox.SetCheck(config.frameBufferEmulation.enableOverscan != 0 ? BST_CHECKED : BST_UNCHECKED); @@ -377,6 +381,17 @@ void CVideoTab::SaveSettings() if (WindowResIndx >= 0 && WindowResIndx < numWindowedModes) { config.video.windowedWidth = WindowedModes[WindowResIndx].width; config.video.windowedHeight = WindowedModes[WindowResIndx].height; + } else { // custom resolution + CString WindowResStr; + WindowResCB.GetWindowText(WindowResStr); + std::string resolution(CW2A(WindowResStr.GetString())); + // matches w x h where w is 300-7999 and h is 200-3999, spaces around x optional + std::regex parseRes("([3-9][0-9]{2}|[1-7][0-9]{3}) ?x ?([2-9][0-9]{2}|[1-3][0-9]{3})"); + std::smatch tokens; + if (std::regex_search(resolution, tokens, parseRes) && tokens.size() > 1) { + config.video.windowedWidth = std::stoi(tokens[1]); + config.video.windowedHeight = std::stoi(tokens[2]); + } } int AspectIndx = CComboBox(GetDlgItem(IDC_CMB_ASPECT_RATIO)).GetCurSel(); diff --git a/src/GLideNUI-wtl/config-video.h b/src/GLideNUI-wtl/config-video.h index f710c2a7..853f5a4f 100644 --- a/src/GLideNUI-wtl/config-video.h +++ b/src/GLideNUI-wtl/config-video.h @@ -1,3 +1,5 @@ +#define _WTL_NO_CSTRING + #pragma once #include "config-tab.h" #include "config-overscan.h" @@ -5,7 +7,9 @@ #include "wtl-tooltip.h" #include "resource.h" #include "Language.h" +#include #include +#include class CConfigDlg;