From ef49abfc65f0d707ff0f41a213d8e74396fbdd1d Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Mon, 26 Aug 2019 13:48:44 +1000 Subject: [PATCH] launcher: add editable option for resolution dropdowns --- .../plugins/DivaSound/src/PluginConfigApi.h | 1 + .../source/plugins/Launcher/ConfigOption.h | 15 ++++++++++++--- .../source/plugins/Launcher/PluginConfig.h | 2 +- .../source/plugins/Launcher/PluginConfigApi.h | 1 + source-code/source/plugins/Launcher/framework.h | 4 ++-- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/source-code/source/plugins/DivaSound/src/PluginConfigApi.h b/source-code/source/plugins/DivaSound/src/PluginConfigApi.h index d9f6a66..f9535c8 100644 --- a/source-code/source/plugins/DivaSound/src/PluginConfigApi.h +++ b/source-code/source/plugins/DivaSound/src/PluginConfigApi.h @@ -131,6 +131,7 @@ namespace PluginConfig LPCWSTR description; resolution defaultVal; std::vector valueResolutions; + bool editable; }; struct PluginConfigGroupData diff --git a/source-code/source/plugins/Launcher/ConfigOption.h b/source-code/source/plugins/Launcher/ConfigOption.h index ba99518..88477b1 100644 --- a/source-code/source/plugins/Launcher/ConfigOption.h +++ b/source-code/source/plugins/Launcher/ConfigOption.h @@ -834,8 +834,9 @@ public: LPCWSTR _iniVarName2; resolution _defaultVal; std::vector _valueResolutions; + bool _editable; - ResolutionOption(LPCWSTR iniVarName, LPCWSTR iniVarName2, LPCWSTR iniSectionName, LPCWSTR iniFilePath, LPCWSTR friendlyName, LPCWSTR description, resolution defaultVal, std::vector valueResolutions) + ResolutionOption(LPCWSTR iniVarName, LPCWSTR iniVarName2, LPCWSTR iniSectionName, LPCWSTR iniFilePath, LPCWSTR friendlyName, LPCWSTR description, resolution defaultVal, std::vector valueResolutions, bool editable) { _iniVarName = iniVarName; _iniVarName2 = iniVarName2; @@ -845,6 +846,7 @@ public: _description = description; _defaultVal = defaultVal; _valueResolutions = valueResolutions; + _editable = editable; } virtual int AddToPanel(Panel^ panel, unsigned int left, unsigned int top, ToolTip^ tooltip) @@ -882,7 +884,11 @@ public: combobox->Width = Col2Width; combobox->AutoSize = true; combobox->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - combobox->DropDownStyle = ComboBoxStyle::DropDown; + + if (_editable) + combobox->DropDownStyle = ComboBoxStyle::DropDown; + else + combobox->DropDownStyle = ComboBoxStyle::DropDownList; Form^ RootForm = panel->FindForm(); float ScaleWidth = 1.0f; @@ -902,7 +908,10 @@ public: if (hasChanged == nullptr) hasChanged = new bool(false); ChangeHandler^ changehandler = gcnew ChangeHandler(hasChanged); - combobox->TextChanged += gcnew System::EventHandler(changehandler, &ChangeHandler::SetChanged); + if (_editable) + combobox->TextChanged += gcnew System::EventHandler(changehandler, &ChangeHandler::SetChanged); + else + combobox->SelectedIndexChanged += gcnew System::EventHandler(changehandler, &ChangeHandler::SetChanged); ComboboxValidation^ validation = gcnew ComboboxValidation(combobox); combobox->Leave += gcnew System::EventHandler(validation, &ComboboxValidation::CheckResolutionLeave); diff --git a/source-code/source/plugins/Launcher/PluginConfig.h b/source-code/source/plugins/Launcher/PluginConfig.h index 0a3170c..d365afe 100644 --- a/source-code/source/plugins/Launcher/PluginConfig.h +++ b/source-code/source/plugins/Launcher/PluginConfig.h @@ -30,7 +30,7 @@ namespace PluginConfig case CONFIG_DROPDOWN_NUMBER: return new DropdownNumberOption(ddNumberData->iniVarName, ddNumberData->iniSectionName, ddNumberData->iniFilePath, ddNumberData->friendlyName, ddNumberData->description, ddNumberData->defaultVal, ddNumberData->valueInts, ddNumberData->editable); case CONFIG_RESOLUTION: - return new ResolutionOption(resData->iniVarName, resData->iniVarName2, resData->iniSectionName, resData->iniFilePath, resData->friendlyName, resData->description, resData->defaultVal, resData->valueResolutions); + return new ResolutionOption(resData->iniVarName, resData->iniVarName2, resData->iniSectionName, resData->iniFilePath, resData->friendlyName, resData->description, resData->defaultVal, resData->valueResolutions, resData->editable); case CONFIG_GROUP_START: return new OptionMetaGroupStart(groupData->name, groupData->height); case CONFIG_GROUP_END: diff --git a/source-code/source/plugins/Launcher/PluginConfigApi.h b/source-code/source/plugins/Launcher/PluginConfigApi.h index d9f6a66..f9535c8 100644 --- a/source-code/source/plugins/Launcher/PluginConfigApi.h +++ b/source-code/source/plugins/Launcher/PluginConfigApi.h @@ -131,6 +131,7 @@ namespace PluginConfig LPCWSTR description; resolution defaultVal; std::vector valueResolutions; + bool editable; }; struct PluginConfigGroupData diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index c82d5cf..c5688d5 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -127,7 +127,7 @@ std::vector screenModes = getScreenModes(); DropdownOption* DisplayModeDropdown = new DropdownOption(L"display", RESOLUTION_SECTION, CONFIG_FILE, L"Display:", L"Sets the window/screen mode.", 0, std::vector({ L"Windowed", L"Borderless", L"Fullscreen" })); -ResolutionOption* DisplayResolutionOption = new ResolutionOption(L"width", L"height", RESOLUTION_SECTION, CONFIG_FILE, L"Resolution:", L"Sets the display resolution.", resolution(1280, 720), getScreenResolutionsVec(screenModes)); +ResolutionOption* DisplayResolutionOption = new ResolutionOption(L"width", L"height", RESOLUTION_SECTION, CONFIG_FILE, L"Resolution:", L"Sets the display resolution.", resolution(1280, 720), getScreenResolutionsVec(screenModes), true); ConfigOptionBase* screenResolutionArray[] = { DisplayModeDropdown, @@ -137,7 +137,7 @@ ConfigOptionBase* screenResolutionArray[] = { }; BooleanOption* InternalResolutionCheckbox = new BooleanOption(L"r.enable", RESOLUTION_SECTION, CONFIG_FILE, L"Enable", L"Enable or disable custom internal resolution.", false, false); -ResolutionOption* InternalResolutionOption = new ResolutionOption(L"r.width", L"r.height", RESOLUTION_SECTION, CONFIG_FILE, L"Resolution:", L"Sets the internal resolution.", resolution(1280, 720), std::vector({ resolution(640,480), resolution(800,600), resolution(960,720), resolution(1280,720), resolution(1600,900), resolution(1920,1080), resolution(2560,1440), resolution(3200,1800), resolution(3840,2160), resolution(5120,2880), resolution(6400,3600), resolution(7680,4320) })); +ResolutionOption* InternalResolutionOption = new ResolutionOption(L"r.width", L"r.height", RESOLUTION_SECTION, CONFIG_FILE, L"Resolution:", L"Sets the internal resolution.", resolution(1280, 720), std::vector({ resolution(640,480), resolution(800,600), resolution(960,720), resolution(1280,720), resolution(1600,900), resolution(1920,1080), resolution(2560,1440), resolution(3200,1800), resolution(3840,2160), resolution(5120,2880), resolution(6400,3600), resolution(7680,4320) }), true); ConfigOptionBase* internalResolutionArray[] = { InternalResolutionCheckbox,