launcher: make editable/not optional on dropdown text and numbers (+minor fixes)

This commit is contained in:
somewhatlurker
2019-08-30 00:16:34 +10:00
parent 956fb8698f
commit 5a5cc70c90
6 changed files with 29 additions and 14 deletions
@@ -107,6 +107,7 @@ namespace PluginConfig
LPCWSTR description;
LPCWSTR defaultVal;
std::vector<LPCWSTR> valueStrings;
bool editable;
bool useUtf8;
};
@@ -118,6 +119,7 @@ namespace PluginConfig
LPCWSTR description;
int defaultVal;
std::vector<int> valueInts;
bool editable;
};
struct PluginConfigResolutionData {
@@ -415,9 +415,9 @@ BOOL APIENTRY DllMain(HMODULE hModule,
using namespace PluginConfig;
std::vector<PluginConfigOption> 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<LPCWSTR>({ 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<int>({ 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<int>({ 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<LPCWSTR>({ 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<int>({ 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<int>({ 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 } },
@@ -533,14 +533,15 @@ public:
};
class EditableDropdownOption : public ConfigOptionBase
class DropdownTextOption : public ConfigOptionBase
{
public:
LPCWSTR _defaultVal;
std::vector<LPCWSTR> _valueStrings;
bool _editable;
bool _useUtf8;
EditableDropdownOption(LPCWSTR iniVarName, LPCWSTR iniSectionName, LPCWSTR iniFilePath, LPCWSTR friendlyName, LPCWSTR description, LPCWSTR defaultVal, std::vector<LPCWSTR> valueStrings, bool useUtf8)
DropdownTextOption(LPCWSTR iniVarName, LPCWSTR iniSectionName, LPCWSTR iniFilePath, LPCWSTR friendlyName, LPCWSTR description, LPCWSTR defaultVal, std::vector<LPCWSTR> 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<int> _valueInts;
bool _editable;
EditableDropdownNumberOption(LPCWSTR iniVarName, LPCWSTR iniSectionName, LPCWSTR iniFilePath, LPCWSTR friendlyName, LPCWSTR description, int defaultVal, std::vector<int> valueInts)
DropdownNumberOption(LPCWSTR iniVarName, LPCWSTR iniSectionName, LPCWSTR iniFilePath, LPCWSTR friendlyName, LPCWSTR description, int defaultVal, std::vector<int> 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;
@@ -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:
@@ -2,7 +2,6 @@
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <vector>
#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<LPCWSTR> valueStrings;
bool editable;
bool useUtf8;
};
@@ -119,6 +119,7 @@ namespace PluginConfig
LPCWSTR description;
int defaultVal;
std::vector<int> valueInts;
bool editable;
};
struct PluginConfigResolutionData {
@@ -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);