From de1eba2582de4c7c08dbc065f8e3c7638216d4ff Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Sat, 24 Aug 2019 08:35:35 +1000 Subject: [PATCH] launcher: make editable/not optional on dropdown text and numbers (+minor fixes) --- .../plugins/DivaSound/src/PluginConfigApi.h | 2 ++ .../source/plugins/DivaSound/src/dllmain.cpp | 6 ++--- .../source/plugins/Launcher/ConfigOption.h | 24 ++++++++++++++----- .../source/plugins/Launcher/PluginConfig.h | 4 ++-- .../source/plugins/Launcher/PluginConfigApi.h | 3 ++- .../source/plugins/Launcher/framework.h | 4 ++-- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/source-code/source/plugins/DivaSound/src/PluginConfigApi.h b/source-code/source/plugins/DivaSound/src/PluginConfigApi.h index aeb69ec..3f0923e 100644 --- a/source-code/source/plugins/DivaSound/src/PluginConfigApi.h +++ b/source-code/source/plugins/DivaSound/src/PluginConfigApi.h @@ -107,6 +107,7 @@ namespace PluginConfig LPCWSTR description; LPCWSTR defaultVal; std::vector valueStrings; + bool editable; bool useUtf8; }; @@ -118,6 +119,7 @@ namespace PluginConfig LPCWSTR description; int defaultVal; std::vector valueInts; + bool editable; }; struct PluginConfigResolutionData { diff --git a/source-code/source/plugins/DivaSound/src/dllmain.cpp b/source-code/source/plugins/DivaSound/src/dllmain.cpp index 70240fc..08356ad 100644 --- a/source-code/source/plugins/DivaSound/src/dllmain.cpp +++ b/source-code/source/plugins/DivaSound/src/dllmain.cpp @@ -415,9 +415,9 @@ BOOL APIENTRY DllMain(HMODULE hModule, using namespace PluginConfig; std::vector config = { - PluginConfigOption{ CONFIG_DROPDOWN_TEXT, new PluginConfigDropdownTextData{ L"backend", L"general", CONFIG_FILE, L"Backend:", L"Sets the audio output protocol.", L"WASAPI", std::vector({ L"WASAPI", L"WASAPI_Exclusive" }) } }, - PluginConfigOption{ CONFIG_DROPDOWN_NUMBER, new PluginConfigDropdownNumberData{ L"channels", L"general", CONFIG_FILE, L"Channels:", L"Sets the number of channels.", 2, std::vector({ 2, 4 }) } }, - PluginConfigOption{ CONFIG_DROPDOWN_NUMBER, new PluginConfigDropdownNumberData{ L"bit_depth", L"general", CONFIG_FILE, L"Bit Depth:", L"Sets the audio sample format.\n(32 uses floating point samples)", 16, std::vector({ 16, 24, 32 }) } }, + PluginConfigOption{ CONFIG_DROPDOWN_TEXT, new PluginConfigDropdownTextData{L"backend", L"general", CONFIG_FILE, L"Backend:", L"Sets the audio output protocol.", L"WASAPI", std::vector({ L"WASAPI", L"WASAPI_Exclusive" }), true, false } }, + PluginConfigOption{ CONFIG_DROPDOWN_NUMBER, new PluginConfigDropdownNumberData{ L"channels", L"general", CONFIG_FILE, L"Channels:", L"Sets the number of channels.", 2, std::vector({ 2, 4 }), false } }, + PluginConfigOption{ CONFIG_DROPDOWN_NUMBER, new PluginConfigDropdownNumberData{ L"bit_depth", L"general", CONFIG_FILE, L"Bit Depth:", L"Sets the audio sample format.\n(32 uses floating point samples)", 16, std::vector({ 16, 24, 32 }), false } }, PluginConfigOption{ CONFIG_NUMERIC, new PluginConfigNumericData{ L"buffer_size", L"buffer", CONFIG_FILE, L"Target Buffer Size:", L"Sets the target buffer size in ms.\nWASAPI will often ignore this and adapt to your hardware config automatically.", 10, 1, 100 } }, PluginConfigOption{ CONFIG_NUMERIC, new PluginConfigNumericData{ L"periods", L"buffer", CONFIG_FILE, L"Buffer Periods:", L"Sets how often the buffer should be filled.\nFewer periods usually allows for lower latency, but lowering this may cause issues.", 2, 1, 8 } }, PluginConfigOption{ CONFIG_BOOLEAN, new PluginConfigBooleanData{ L"alternate_init", L"general", CONFIG_FILE, L"Use new init", L"Use the full initialisation replacement.\nTry unchecking this if DivaSound seems to cause crashes.", true } }, diff --git a/source-code/source/plugins/Launcher/ConfigOption.h b/source-code/source/plugins/Launcher/ConfigOption.h index d35690a..3bb573b 100644 --- a/source-code/source/plugins/Launcher/ConfigOption.h +++ b/source-code/source/plugins/Launcher/ConfigOption.h @@ -533,14 +533,15 @@ public: }; -class EditableDropdownOption : public ConfigOptionBase +class DropdownTextOption : public ConfigOptionBase { public: LPCWSTR _defaultVal; std::vector _valueStrings; + bool _editable; bool _useUtf8; - EditableDropdownOption(LPCWSTR iniVarName, LPCWSTR iniSectionName, LPCWSTR iniFilePath, LPCWSTR friendlyName, LPCWSTR description, LPCWSTR defaultVal, std::vector valueStrings, bool useUtf8) + DropdownTextOption(LPCWSTR iniVarName, LPCWSTR iniSectionName, LPCWSTR iniFilePath, LPCWSTR friendlyName, LPCWSTR description, LPCWSTR defaultVal, std::vector valueStrings, bool editable, bool useUtf8) { _iniVarName = iniVarName; _iniSectionName = iniSectionName; @@ -549,6 +550,7 @@ public: _description = description; _defaultVal = defaultVal; _valueStrings = valueStrings; + _editable = editable; _useUtf8 = useUtf8; } @@ -583,7 +585,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; @@ -645,13 +651,14 @@ public: }; -class EditableDropdownNumberOption : public ConfigOptionBase +class DropdownNumberOption : public ConfigOptionBase { public: int _defaultVal; std::vector _valueInts; + bool _editable; - EditableDropdownNumberOption(LPCWSTR iniVarName, LPCWSTR iniSectionName, LPCWSTR iniFilePath, LPCWSTR friendlyName, LPCWSTR description, int defaultVal, std::vector valueInts) + DropdownNumberOption(LPCWSTR iniVarName, LPCWSTR iniSectionName, LPCWSTR iniFilePath, LPCWSTR friendlyName, LPCWSTR description, int defaultVal, std::vector valueInts, bool editable) { _iniVarName = iniVarName; _iniSectionName = iniSectionName; @@ -660,6 +667,7 @@ public: _description = description; _defaultVal = defaultVal; _valueInts = valueInts; + _editable = editable; } virtual int AddToPanel(Panel^ panel, unsigned int left, unsigned int top, ToolTip^ tooltip) @@ -688,7 +696,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; diff --git a/source-code/source/plugins/Launcher/PluginConfig.h b/source-code/source/plugins/Launcher/PluginConfig.h index ff0853f..5b8fe56 100644 --- a/source-code/source/plugins/Launcher/PluginConfig.h +++ b/source-code/source/plugins/Launcher/PluginConfig.h @@ -26,9 +26,9 @@ namespace PluginConfig case CONFIG_DROPDOWN_INDEX: return new DropdownOption(ddIdxData->iniVarName, ddIdxData->iniSectionName, ddIdxData->iniFilePath, ddIdxData->friendlyName, ddIdxData->description, ddIdxData->defaultVal, ddIdxData->valueStrings); case CONFIG_DROPDOWN_TEXT: - return new EditableDropdownOption(ddTextData->iniVarName, ddTextData->iniSectionName, ddTextData->iniFilePath, ddTextData->friendlyName, ddTextData->description, ddTextData->defaultVal, ddTextData->valueStrings, ddTextData->useUtf8); + return new DropdownTextOption(ddTextData->iniVarName, ddTextData->iniSectionName, ddTextData->iniFilePath, ddTextData->friendlyName, ddTextData->description, ddTextData->defaultVal, ddTextData->valueStrings, ddTextData->editable, ddTextData->useUtf8); case CONFIG_DROPDOWN_NUMBER: - return new EditableDropdownNumberOption(ddNumberData->iniVarName, ddNumberData->iniSectionName, ddNumberData->iniFilePath, ddNumberData->friendlyName, ddNumberData->description, ddNumberData->defaultVal, ddNumberData->valueInts); + 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); case CONFIG_GROUP_START: diff --git a/source-code/source/plugins/Launcher/PluginConfigApi.h b/source-code/source/plugins/Launcher/PluginConfigApi.h index 89ec3a0..3f0923e 100644 --- a/source-code/source/plugins/Launcher/PluginConfigApi.h +++ b/source-code/source/plugins/Launcher/PluginConfigApi.h @@ -2,7 +2,6 @@ #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #include #include -#include "framework.h" // resolution class to store and sort the width and height easily class resolution @@ -108,6 +107,7 @@ namespace PluginConfig LPCWSTR description; LPCWSTR defaultVal; std::vector valueStrings; + bool editable; bool useUtf8; }; @@ -119,6 +119,7 @@ namespace PluginConfig LPCWSTR description; int defaultVal; std::vector valueInts; + bool editable; }; struct PluginConfigResolutionData { diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index 9e22d71..aae10b1 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -132,8 +132,8 @@ ResolutionOption* DisplayResolutionOption = new ResolutionOption(L"width", L"hei ConfigOptionBase* screenResolutionArray[] = { DisplayModeDropdown, DisplayResolutionOption, - //new EditableDropdownNumberOption(L"bitdepth", RESOLUTION_SECTION, CONFIG_FILE, L"Bit Depth:", L"Sets the display bit depth.", 32, getScreenDepthsVec(screenModes)), - new EditableDropdownNumberOption(L"refreshrate", RESOLUTION_SECTION, CONFIG_FILE, L"Refresh Rate:", L"Sets the display refresh rate.", 60, getScreenRatesVec(screenModes)), + //new DropdownNumberOption(L"bitdepth", RESOLUTION_SECTION, CONFIG_FILE, L"Bit Depth:", L"Sets the display bit depth.", 32, getScreenDepthsVec(screenModes), true), + new DropdownNumberOption(L"refreshrate", RESOLUTION_SECTION, CONFIG_FILE, L"Refresh Rate:", L"Sets the display refresh rate.", 60, getScreenRatesVec(screenModes), true), }; BooleanOption* InternalResolutionCheckbox = new BooleanOption(L"r.enable", RESOLUTION_SECTION, CONFIG_FILE, L"Enable", L"Enable or disable custom internal resolution.", false, false);