From f46f6a4d178556636459943f895aa493322e733b Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Wed, 21 Aug 2019 03:38:25 +1000 Subject: [PATCH 01/19] launcher: start work on plugin config --- .../source/plugins/Launcher/ConfigOption.h | 170 +++++++++++++++--- .../source/plugins/Launcher/PluginConfig.h | 158 ++++++++++++++++ source-code/source/plugins/Launcher/ui.h | 11 +- 3 files changed, 314 insertions(+), 25 deletions(-) create mode 100644 source-code/source/plugins/Launcher/PluginConfig.h diff --git a/source-code/source/plugins/Launcher/ConfigOption.h b/source-code/source/plugins/Launcher/ConfigOption.h index d1d0304..601b8c7 100644 --- a/source-code/source/plugins/Launcher/ConfigOption.h +++ b/source-code/source/plugins/Launcher/ConfigOption.h @@ -178,7 +178,7 @@ public: }; -static ref class ChangeHandler +ref class ChangeHandler { public: bool* changebool; @@ -220,6 +220,26 @@ public: }; +class OptionMetaGroupStart : public ConfigOptionBase +{ +public: + int _height; + + OptionMetaGroupStart(LPCWSTR friendlyName, int height) + { + _friendlyName = friendlyName; + _height = height; + } +}; +class OptionMetaGroupEnd : public ConfigOptionBase +{ +public: + OptionMetaGroupEnd() + { + } +}; + + class BooleanOption : public ConfigOptionBase { public: @@ -252,9 +272,14 @@ public: cb->BackColor = System::Drawing::Color::FromArgb(0, 0, 0, 0); Form^ RootForm = panel->FindForm(); - Drawing::SizeF CurrentScaleSize = RootForm->CurrentAutoScaleDimensions; - float ScaleWidth = CurrentScaleSize.Width / BaseScaleSize; - float ScaleHeight = CurrentScaleSize.Height / BaseScaleSize; + float ScaleWidth = 1.0f; + float ScaleHeight = 1.0f; + if (RootForm) + { + Drawing::SizeF CurrentScaleSize = RootForm->CurrentAutoScaleDimensions; + ScaleWidth = CurrentScaleSize.Width / BaseScaleSize; + ScaleHeight = CurrentScaleSize.Height / BaseScaleSize; + } cb->Scale(ScaleWidth, ScaleHeight); tooltip->SetToolTip(cb, gcnew String(_description)); @@ -325,9 +350,14 @@ public: numberbox->AutoSize = true; Form^ RootForm = panel->FindForm(); - Drawing::SizeF CurrentScaleSize = RootForm->CurrentAutoScaleDimensions; - float ScaleWidth = CurrentScaleSize.Width / BaseScaleSize; - float ScaleHeight = CurrentScaleSize.Height / BaseScaleSize; + float ScaleWidth = 1.0f; + float ScaleHeight = 1.0f; + if (RootForm) + { + Drawing::SizeF CurrentScaleSize = RootForm->CurrentAutoScaleDimensions; + ScaleWidth = CurrentScaleSize.Width / BaseScaleSize; + ScaleHeight = CurrentScaleSize.Height / BaseScaleSize; + } label->Scale(ScaleWidth, ScaleHeight); numberbox->Scale(ScaleWidth, ScaleHeight); @@ -404,9 +434,14 @@ public: textbox->AutoSize = true; Form^ RootForm = panel->FindForm(); - Drawing::SizeF CurrentScaleSize = RootForm->CurrentAutoScaleDimensions; - float ScaleWidth = CurrentScaleSize.Width / BaseScaleSize; - float ScaleHeight = CurrentScaleSize.Height / BaseScaleSize; + float ScaleWidth = 1.0f; + float ScaleHeight = 1.0f; + if (RootForm) + { + Drawing::SizeF CurrentScaleSize = RootForm->CurrentAutoScaleDimensions; + ScaleWidth = CurrentScaleSize.Width / BaseScaleSize; + ScaleHeight = CurrentScaleSize.Height / BaseScaleSize; + } label->Scale(ScaleWidth, ScaleHeight); textbox->Scale(ScaleWidth, ScaleHeight); @@ -498,9 +533,14 @@ public: combobox->DropDownStyle = ComboBoxStyle::DropDownList; Form^ RootForm = panel->FindForm(); - Drawing::SizeF CurrentScaleSize = RootForm->CurrentAutoScaleDimensions; - float ScaleWidth = CurrentScaleSize.Width / BaseScaleSize; - float ScaleHeight = CurrentScaleSize.Height / BaseScaleSize; + float ScaleWidth = 1.0f; + float ScaleHeight = 1.0f; + if (RootForm) + { + Drawing::SizeF CurrentScaleSize = RootForm->CurrentAutoScaleDimensions; + ScaleWidth = CurrentScaleSize.Width / BaseScaleSize; + ScaleHeight = CurrentScaleSize.Height / BaseScaleSize; + } label->Scale(ScaleWidth, ScaleHeight); combobox->Scale(ScaleWidth, ScaleHeight); @@ -585,9 +625,14 @@ public: combobox->DropDownStyle = ComboBoxStyle::DropDown; Form^ RootForm = panel->FindForm(); - Drawing::SizeF CurrentScaleSize = RootForm->CurrentAutoScaleDimensions; - float ScaleWidth = CurrentScaleSize.Width / BaseScaleSize; - float ScaleHeight = CurrentScaleSize.Height / BaseScaleSize; + float ScaleWidth = 1.0f; + float ScaleHeight = 1.0f; + if (RootForm) + { + Drawing::SizeF CurrentScaleSize = RootForm->CurrentAutoScaleDimensions; + ScaleWidth = CurrentScaleSize.Width / BaseScaleSize; + ScaleHeight = CurrentScaleSize.Height / BaseScaleSize; + } label->Scale(ScaleWidth, ScaleHeight); combobox->Scale(ScaleWidth, ScaleHeight); @@ -685,9 +730,14 @@ public: combobox->DropDownStyle = ComboBoxStyle::DropDown; Form^ RootForm = panel->FindForm(); - Drawing::SizeF CurrentScaleSize = RootForm->CurrentAutoScaleDimensions; - float ScaleWidth = CurrentScaleSize.Width / BaseScaleSize; - float ScaleHeight = CurrentScaleSize.Height / BaseScaleSize; + float ScaleWidth = 1.0f; + float ScaleHeight = 1.0f; + if (RootForm) + { + Drawing::SizeF CurrentScaleSize = RootForm->CurrentAutoScaleDimensions; + ScaleWidth = CurrentScaleSize.Width / BaseScaleSize; + ScaleHeight = CurrentScaleSize.Height / BaseScaleSize; + } label->Scale(ScaleWidth, ScaleHeight); combobox->Scale(ScaleWidth, ScaleHeight); @@ -780,9 +830,14 @@ public: combobox->DropDownStyle = ComboBoxStyle::DropDown; Form^ RootForm = panel->FindForm(); - Drawing::SizeF CurrentScaleSize = RootForm->CurrentAutoScaleDimensions; - float ScaleWidth = CurrentScaleSize.Width / BaseScaleSize; - float ScaleHeight = CurrentScaleSize.Height / BaseScaleSize; + float ScaleWidth = 1.0f; + float ScaleHeight = 1.0f; + if (RootForm) + { + Drawing::SizeF CurrentScaleSize = RootForm->CurrentAutoScaleDimensions; + ScaleWidth = CurrentScaleSize.Width / BaseScaleSize; + ScaleHeight = CurrentScaleSize.Height / BaseScaleSize; + } label->Scale(ScaleWidth, ScaleHeight); combobox->Scale(ScaleWidth, ScaleHeight); @@ -823,4 +878,73 @@ public: WritePrivateProfileStringW(_iniSectionName, _iniVarName2, tempWStr.c_str(), _iniFilePath); } -}; \ No newline at end of file +}; + + +Panel^ MakePanel(int width, int height, std::vector cfg, ToolTip^ tooltip) +{ + Panel^ outpanel = gcnew Panel(); + outpanel->Width = width; + outpanel->Height = height; + outpanel->AutoScroll = true; + + Form^ RootForm = outpanel->FindForm(); + float ScaleWidth = 1.0f; + float ScaleHeight = 1.0f; + if (RootForm) + { + Drawing::SizeF CurrentScaleSize = RootForm->CurrentAutoScaleDimensions; + ScaleWidth = CurrentScaleSize.Width / BaseScaleSize; + ScaleHeight = CurrentScaleSize.Height / BaseScaleSize; + } + + int curX = 12; + int curY = 3; + + for (int i = 0; i < cfg.size(); i++) + { + if (typeid(cfg[i]).hash_code() == typeid(OptionMetaGroupEnd).hash_code()) + continue; + + if (typeid(cfg[i]).hash_code() == typeid(OptionMetaGroupStart).hash_code()) + { + OptionMetaGroupStart* groupData = (OptionMetaGroupStart*)(cfg[i]); + GroupBox^ groupbox = gcnew GroupBox(); + groupbox->Width = width - (ScaleWidth * 8); + groupbox->Height = ScaleHeight * groupData->_height; + groupbox->Left = ScaleWidth * 4; + groupbox->Top = ScaleHeight * curY; + groupbox->Text = gcnew String(groupData->_friendlyName); + + // find the end of this group by simple iteration keeping track of indent level + int level = 1; + int endidx; + for (endidx = i + 1; endidx < cfg.size(); endidx++) + { + if (typeid(&cfg[endidx]).hash_code() == typeid(OptionMetaGroupStart).hash_code()) + level++; + if (typeid(&cfg[endidx]).hash_code() == typeid(OptionMetaGroupEnd).hash_code()) + level--; + + if (level == 0) + break; + } + + Panel^ groupPanel = MakePanel(groupbox->Width - (ScaleWidth * 8), groupbox->Height - (ScaleHeight * 10), std::vector(&(cfg[i + 1]), &(cfg[endidx])), tooltip); + groupPanel->Left = ScaleWidth * 12; + groupPanel->Top = ScaleHeight * (curY + 8); + + groupbox->Controls->Add(groupPanel); + outpanel->Controls->Add(groupbox); + + i = endidx; + curY += groupData->_height; + } + else + { + curY += cfg[i]->AddToPanel(outpanel, curX, curY, tooltip); + } + } + + return outpanel; +} \ No newline at end of file diff --git a/source-code/source/plugins/Launcher/PluginConfig.h b/source-code/source/plugins/Launcher/PluginConfig.h new file mode 100644 index 0000000..76badf0 --- /dev/null +++ b/source-code/source/plugins/Launcher/PluginConfig.h @@ -0,0 +1,158 @@ +#pragma once +#include "ConfigOption.h" +#include "framework.h" + +namespace PluginConfig +{ + enum ConfigType { + CONFIG_BOOLEAN, + CONFIG_NUMERIC, + CONFIG_STRING, + CONFIG_DROPDOWN_INDEX, + CONFIG_DROPDOWN_TEXT, + CONFIG_DROPDOWN_NUMBER, + CONFIG_RESOLUTION, + CONFIG_GROUP_START, + CONFIG_GROUP_END + }; + + struct PluginConfigBooleanData { + LPCWSTR iniVarName; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + bool defaultVal; + bool saveAsString; + }; + + struct PluginConfigNumericData { + LPCWSTR iniVarName; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + int defaultVal; + int minVal; + int maxVal; + }; + + struct PluginConfigStringData { + LPCWSTR iniVarName; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + LPCWSTR defaultVal; + bool useUtf8; + }; + + struct PluginConfigDropdownIndexData { + LPCWSTR iniVarName; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + int defaultVal; + std::vector valueStrings; + }; + + struct PluginConfigDropdownTextData { + LPCWSTR iniVarName; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + LPCWSTR defaultVal; + std::vector valueStrings; + bool useUtf8; + }; + + struct PluginConfigDropdownNumberData { + LPCWSTR iniVarName; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + int defaultVal; + std::vector valueInts; + }; + + struct PluginConfigResolutionData { + LPCWSTR iniVarName; + LPCWSTR iniVarName2; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + resolution defaultVal; + std::vector valueResolutions; + }; + + struct PluginConfigGroupData + { + LPCWSTR name; + int height; + }; + + struct PluginConfigOption + { + ConfigType cfgType; + void* data; + }; + + ConfigOptionBase* GetConfigOption(PluginConfigOption cfg) + { + PluginConfigBooleanData* boolData = (PluginConfigBooleanData*)(cfg.data); + PluginConfigNumericData* numericData = (PluginConfigNumericData*)(cfg.data); + PluginConfigStringData* stringData = (PluginConfigStringData*)(cfg.data); + PluginConfigDropdownIndexData* ddIdxData = (PluginConfigDropdownIndexData*)(cfg.data); + PluginConfigDropdownTextData* ddTextData = (PluginConfigDropdownTextData*)(cfg.data); + PluginConfigDropdownNumberData* ddNumberData = (PluginConfigDropdownNumberData*)(cfg.data); + PluginConfigResolutionData* resData = (PluginConfigResolutionData*)(cfg.data); + PluginConfigGroupData* groupData = (PluginConfigGroupData*)(cfg.data); + + switch (cfg.cfgType) + { + case CONFIG_BOOLEAN: + return new BooleanOption(boolData->iniVarName, boolData->iniSectionName, boolData->iniFilePath, boolData->friendlyName, boolData->description, boolData->defaultVal, boolData->saveAsString); + case CONFIG_NUMERIC: + return new NumericOption(numericData->iniVarName, numericData->iniSectionName, numericData->iniFilePath, numericData->friendlyName, numericData->description, numericData->defaultVal, numericData->minVal, numericData->maxVal); + case CONFIG_STRING: + return new StringOption(stringData->iniVarName, stringData->iniSectionName, stringData->iniFilePath, stringData->friendlyName, stringData->description, stringData->defaultVal, stringData->useUtf8); + 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); + case CONFIG_DROPDOWN_NUMBER: + return new EditableDropdownNumberOption(ddNumberData->iniVarName, ddNumberData->iniSectionName, ddNumberData->iniFilePath, ddNumberData->friendlyName, ddNumberData->description, ddNumberData->defaultVal, ddNumberData->valueInts); + 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: + return new OptionMetaGroupStart(groupData->name, groupData->height); + case CONFIG_GROUP_END: + return new OptionMetaGroupEnd(); + default: + return new ConfigOptionBase(); + } + } + + std::vector GetConfigOptionVec(std::vector in) + { + std::vector outvec; + for (PluginConfigOption &opt : in) + { + outvec.push_back(GetConfigOption(opt)); + } + return outvec; + } + + std::vector testcfg = + { + PluginConfigOption{ CONFIG_GROUP_START, new PluginConfigGroupData{L"Screen Resolution", 400 } }, + PluginConfigOption{ CONFIG_DROPDOWN_INDEX, new PluginConfigDropdownIndexData{ L"display", RESOLUTION_SECTION, CONFIG_FILE, L"Display:", L"Sets the window/screen mode.", 0, std::vector({ L"Windowed", L"Borderless", L"Fullscreen" }) } }, + PluginConfigOption{ CONFIG_RESOLUTION, new PluginConfigResolutionData{ L"width", L"height", RESOLUTION_SECTION, CONFIG_FILE, L"Resolution:", L"Sets the display resolution.", resolution(1280, 720), getScreenResolutionsVec(screenModes) } } + }; + + std::vector testcfgconfigopts = GetConfigOptionVec(testcfg); +}; \ No newline at end of file diff --git a/source-code/source/plugins/Launcher/ui.h b/source-code/source/plugins/Launcher/ui.h index 42b2d81..955dee7 100644 --- a/source-code/source/plugins/Launcher/ui.h +++ b/source-code/source/plugins/Launcher/ui.h @@ -6,6 +6,7 @@ #include #include #include "SkinnedMessageBox.h" +#include "PluginConfig.h" namespace Launcher { @@ -90,6 +91,7 @@ namespace Launcher { this->panel_Patches->PerformLayout(); + this->panel_Playerdata->SuspendLayout(); // populate playerdata options from array in framework @@ -112,13 +114,18 @@ namespace Launcher { for (ConfigOptionBase* component : componentsArray) { component->hasChanged = ConfigHasChanged; - componentsY += component->AddToPanel(panel_Components, 12, componentsY, toolTip1); + //componentsY += component->AddToPanel(panel_Components, 12, componentsY, toolTip1); } this->panel_Components->ResumeLayout(false); this->panel_Components->PerformLayout(); + using namespace PluginConfig; + //tabPage_Components->Controls->Add(MakePanel(256, 800, testcfg, toolTip1)); + tabPage_Components->Controls->Add(MakePanel(256, 100, std::vector(&componentsArray[0], &componentsArray[12]), toolTip1)); + + // trick Optimus into switching to the NVIDIA GPU if (cuInit != NULL) cuInit(0); @@ -402,7 +409,7 @@ namespace Launcher { // this->tabPage_Components->BackColor = System::Drawing::Color::FromArgb(static_cast(static_cast(64)), static_cast(static_cast(64)), static_cast(static_cast(64))); - this->tabPage_Components->Controls->Add(this->panel_Components); + //this->tabPage_Components->Controls->Add(this->panel_Components); this->tabPage_Components->Location = System::Drawing::Point(4, 32); this->tabPage_Components->Margin = System::Windows::Forms::Padding(4); this->tabPage_Components->Name = L"tabPage_Components"; From bb6f857d462c56bbc3acde6a2fe109edb7f19443 Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Wed, 21 Aug 2019 03:47:08 +1000 Subject: [PATCH 02/19] launcher: fix typeid checks --- source-code/source/plugins/Launcher/ConfigOption.h | 8 ++++---- source-code/source/plugins/Launcher/ui.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source-code/source/plugins/Launcher/ConfigOption.h b/source-code/source/plugins/Launcher/ConfigOption.h index 601b8c7..386a1e5 100644 --- a/source-code/source/plugins/Launcher/ConfigOption.h +++ b/source-code/source/plugins/Launcher/ConfigOption.h @@ -903,10 +903,10 @@ Panel^ MakePanel(int width, int height, std::vector cfg, Tool for (int i = 0; i < cfg.size(); i++) { - if (typeid(cfg[i]).hash_code() == typeid(OptionMetaGroupEnd).hash_code()) + if (typeid(*cfg[i]).hash_code() == typeid(OptionMetaGroupEnd).hash_code()) continue; - if (typeid(cfg[i]).hash_code() == typeid(OptionMetaGroupStart).hash_code()) + if (typeid(*cfg[i]).hash_code() == typeid(OptionMetaGroupStart).hash_code()) { OptionMetaGroupStart* groupData = (OptionMetaGroupStart*)(cfg[i]); GroupBox^ groupbox = gcnew GroupBox(); @@ -921,9 +921,9 @@ Panel^ MakePanel(int width, int height, std::vector cfg, Tool int endidx; for (endidx = i + 1; endidx < cfg.size(); endidx++) { - if (typeid(&cfg[endidx]).hash_code() == typeid(OptionMetaGroupStart).hash_code()) + if (typeid(*cfg[endidx]).hash_code() == typeid(OptionMetaGroupStart).hash_code()) level++; - if (typeid(&cfg[endidx]).hash_code() == typeid(OptionMetaGroupEnd).hash_code()) + if (typeid(*cfg[endidx]).hash_code() == typeid(OptionMetaGroupEnd).hash_code()) level--; if (level == 0) diff --git a/source-code/source/plugins/Launcher/ui.h b/source-code/source/plugins/Launcher/ui.h index 955dee7..2251521 100644 --- a/source-code/source/plugins/Launcher/ui.h +++ b/source-code/source/plugins/Launcher/ui.h @@ -122,7 +122,7 @@ namespace Launcher { using namespace PluginConfig; - //tabPage_Components->Controls->Add(MakePanel(256, 800, testcfg, toolTip1)); + //tabPage_Components->Controls->Add(MakePanel(256, 256, testcfgconfigopts, toolTip1)); tabPage_Components->Controls->Add(MakePanel(256, 100, std::vector(&componentsArray[0], &componentsArray[12]), toolTip1)); From 2e2ecb954336f447ab26e58a9c720da571b7a76d Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Thu, 22 Aug 2019 04:17:59 +1000 Subject: [PATCH 03/19] launcher: work on plugin enumeration --- .../source/plugins/Launcher/ConfigOption.h | 45 +----- .../source/plugins/Launcher/Launcher.vcxproj | 2 + .../source/plugins/Launcher/PluginConfig.h | 107 +------------ .../source/plugins/Launcher/PluginConfigApi.h | 145 ++++++++++++++++++ .../source/plugins/Launcher/framework.h | 73 ++++++++- source-code/source/plugins/Launcher/ui.h | 53 ++++++- 6 files changed, 275 insertions(+), 150 deletions(-) create mode 100644 source-code/source/plugins/Launcher/PluginConfigApi.h diff --git a/source-code/source/plugins/Launcher/ConfigOption.h b/source-code/source/plugins/Launcher/ConfigOption.h index 386a1e5..d35690a 100644 --- a/source-code/source/plugins/Launcher/ConfigOption.h +++ b/source-code/source/plugins/Launcher/ConfigOption.h @@ -9,6 +9,8 @@ #include +#include "PluginConfigApi.h" + using namespace System; using namespace System::Windows::Forms; @@ -39,47 +41,6 @@ bool GetPrivateProfileBoolW(LPCWSTR lpAppName, LPCWSTR lpKeyName, bool default, return out; } -// resolution class to store and sort the width and height easily -class resolution -{ -public: - unsigned int width; - unsigned int height; - - resolution() - { - width = 0; - height = 0; - } - - resolution(unsigned int width, unsigned int height) - { - resolution::width = width; - resolution::height = height; - } - - bool operator ==(const resolution &res2) - { - return width == res2.width && height == res2.height; - } - - // in comparisons width takes priority because it's usually displayed first - bool operator <(const resolution &res2) - { - if (width == res2.width) - return height < res2.height; - else - return width < res2.width; - } - bool operator >(const resolution &res2) - { - if (width == res2.width) - return height > res2.height; - else - return width > res2.width; - } -}; - ref class ComboboxValidation { @@ -881,7 +842,7 @@ public: }; -Panel^ MakePanel(int width, int height, std::vector cfg, ToolTip^ tooltip) +Panel^ MakePanel(int width, int height, std::vector &cfg, ToolTip^ tooltip) { Panel^ outpanel = gcnew Panel(); outpanel->Width = width; diff --git a/source-code/source/plugins/Launcher/Launcher.vcxproj b/source-code/source/plugins/Launcher/Launcher.vcxproj index d4e6170..f8c2f87 100644 --- a/source-code/source/plugins/Launcher/Launcher.vcxproj +++ b/source-code/source/plugins/Launcher/Launcher.vcxproj @@ -167,6 +167,8 @@ + + diff --git a/source-code/source/plugins/Launcher/PluginConfig.h b/source-code/source/plugins/Launcher/PluginConfig.h index 76badf0..ff0853f 100644 --- a/source-code/source/plugins/Launcher/PluginConfig.h +++ b/source-code/source/plugins/Launcher/PluginConfig.h @@ -1,106 +1,9 @@ #pragma once #include "ConfigOption.h" -#include "framework.h" +#include "PluginConfigApi.h" namespace PluginConfig { - enum ConfigType { - CONFIG_BOOLEAN, - CONFIG_NUMERIC, - CONFIG_STRING, - CONFIG_DROPDOWN_INDEX, - CONFIG_DROPDOWN_TEXT, - CONFIG_DROPDOWN_NUMBER, - CONFIG_RESOLUTION, - CONFIG_GROUP_START, - CONFIG_GROUP_END - }; - - struct PluginConfigBooleanData { - LPCWSTR iniVarName; - LPCWSTR iniSectionName; - LPCWSTR iniFilePath; - LPCWSTR friendlyName; - LPCWSTR description; - bool defaultVal; - bool saveAsString; - }; - - struct PluginConfigNumericData { - LPCWSTR iniVarName; - LPCWSTR iniSectionName; - LPCWSTR iniFilePath; - LPCWSTR friendlyName; - LPCWSTR description; - int defaultVal; - int minVal; - int maxVal; - }; - - struct PluginConfigStringData { - LPCWSTR iniVarName; - LPCWSTR iniSectionName; - LPCWSTR iniFilePath; - LPCWSTR friendlyName; - LPCWSTR description; - LPCWSTR defaultVal; - bool useUtf8; - }; - - struct PluginConfigDropdownIndexData { - LPCWSTR iniVarName; - LPCWSTR iniSectionName; - LPCWSTR iniFilePath; - LPCWSTR friendlyName; - LPCWSTR description; - int defaultVal; - std::vector valueStrings; - }; - - struct PluginConfigDropdownTextData { - LPCWSTR iniVarName; - LPCWSTR iniSectionName; - LPCWSTR iniFilePath; - LPCWSTR friendlyName; - LPCWSTR description; - LPCWSTR defaultVal; - std::vector valueStrings; - bool useUtf8; - }; - - struct PluginConfigDropdownNumberData { - LPCWSTR iniVarName; - LPCWSTR iniSectionName; - LPCWSTR iniFilePath; - LPCWSTR friendlyName; - LPCWSTR description; - int defaultVal; - std::vector valueInts; - }; - - struct PluginConfigResolutionData { - LPCWSTR iniVarName; - LPCWSTR iniVarName2; - LPCWSTR iniSectionName; - LPCWSTR iniFilePath; - LPCWSTR friendlyName; - LPCWSTR description; - resolution defaultVal; - std::vector valueResolutions; - }; - - struct PluginConfigGroupData - { - LPCWSTR name; - int height; - }; - - struct PluginConfigOption - { - ConfigType cfgType; - void* data; - }; - ConfigOptionBase* GetConfigOption(PluginConfigOption cfg) { PluginConfigBooleanData* boolData = (PluginConfigBooleanData*)(cfg.data); @@ -137,7 +40,7 @@ namespace PluginConfig } } - std::vector GetConfigOptionVec(std::vector in) + std::vector GetConfigOptionVec(std::vector &in) { std::vector outvec; for (PluginConfigOption &opt : in) @@ -147,12 +50,12 @@ namespace PluginConfig return outvec; } - std::vector testcfg = + /*std::vector testcfg = { PluginConfigOption{ CONFIG_GROUP_START, new PluginConfigGroupData{L"Screen Resolution", 400 } }, PluginConfigOption{ CONFIG_DROPDOWN_INDEX, new PluginConfigDropdownIndexData{ L"display", RESOLUTION_SECTION, CONFIG_FILE, L"Display:", L"Sets the window/screen mode.", 0, std::vector({ L"Windowed", L"Borderless", L"Fullscreen" }) } }, PluginConfigOption{ CONFIG_RESOLUTION, new PluginConfigResolutionData{ L"width", L"height", RESOLUTION_SECTION, CONFIG_FILE, L"Resolution:", L"Sets the display resolution.", resolution(1280, 720), getScreenResolutionsVec(screenModes) } } - }; + };*/ - std::vector testcfgconfigopts = GetConfigOptionVec(testcfg); + //std::vector testcfgconfigopts = GetConfigOptionVec(testcfg); }; \ No newline at end of file diff --git a/source-code/source/plugins/Launcher/PluginConfigApi.h b/source-code/source/plugins/Launcher/PluginConfigApi.h new file mode 100644 index 0000000..aeb69ec --- /dev/null +++ b/source-code/source/plugins/Launcher/PluginConfigApi.h @@ -0,0 +1,145 @@ +#pragma once +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include + +// resolution class to store and sort the width and height easily +class resolution +{ +public: + unsigned int width; + unsigned int height; + + resolution() + { + width = 0; + height = 0; + } + + resolution(unsigned int width, unsigned int height) + { + resolution::width = width; + resolution::height = height; + } + + bool operator ==(const resolution &res2) + { + return width == res2.width && height == res2.height; + } + + // in comparisons width takes priority because it's usually displayed first + bool operator <(const resolution &res2) + { + if (width == res2.width) + return height < res2.height; + else + return width < res2.width; + } + bool operator >(const resolution &res2) + { + if (width == res2.width) + return height > res2.height; + else + return width > res2.width; + } +}; + +namespace PluginConfig +{ + enum ConfigType { + CONFIG_BOOLEAN, + CONFIG_NUMERIC, + CONFIG_STRING, + CONFIG_DROPDOWN_INDEX, + CONFIG_DROPDOWN_TEXT, + CONFIG_DROPDOWN_NUMBER, + CONFIG_RESOLUTION, + CONFIG_GROUP_START, + CONFIG_GROUP_END + }; + + struct PluginConfigBooleanData { + LPCWSTR iniVarName; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + bool defaultVal; + bool saveAsString; + }; + + struct PluginConfigNumericData { + LPCWSTR iniVarName; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + int defaultVal; + int minVal; + int maxVal; + }; + + struct PluginConfigStringData { + LPCWSTR iniVarName; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + LPCWSTR defaultVal; + bool useUtf8; + }; + + struct PluginConfigDropdownIndexData { + LPCWSTR iniVarName; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + int defaultVal; + std::vector valueStrings; + }; + + struct PluginConfigDropdownTextData { + LPCWSTR iniVarName; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + LPCWSTR defaultVal; + std::vector valueStrings; + bool useUtf8; + }; + + struct PluginConfigDropdownNumberData { + LPCWSTR iniVarName; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + int defaultVal; + std::vector valueInts; + }; + + struct PluginConfigResolutionData { + LPCWSTR iniVarName; + LPCWSTR iniVarName2; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + resolution defaultVal; + std::vector valueResolutions; + }; + + struct PluginConfigGroupData + { + LPCWSTR name; + int height; + }; + + struct PluginConfigOption + { + ConfigType cfgType; + void* data; + }; +} \ No newline at end of file diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index 4d575e3..84bb05d 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -9,6 +9,7 @@ #include #include "ConfigOption.h" +#include "PluginConfig.h" int (__cdecl* divaMain)(int argc, const char** argv, const char** envp) = (int(__cdecl*)(int argc, const char** argv, const char** envp))0x140194D90; @@ -34,13 +35,15 @@ LPCWSTR DIVA_EXECUTABLE = DIVA_EXECUTABLE_STRING.c_str(); wstring DIVA_EXECUTABLE_LAUNCH_STRING = DIVA_EXECUTABLE_STRING + L" --launch"; LPWSTR DIVA_EXECUTABLE_LAUNCH = const_cast(DIVA_EXECUTABLE_LAUNCH_STRING.c_str()); -wstring CONFIG_FILE_STRING = DirPath() + L"\\plugins\\config.ini"; +wstring PLUGINS_DIR = DirPath() + L"\\plugins"; + +wstring CONFIG_FILE_STRING = PLUGINS_DIR + L"\\config.ini"; LPCWSTR CONFIG_FILE = CONFIG_FILE_STRING.c_str(); -wstring COMPONENTS_FILE_STRING = DirPath() + L"\\plugins\\components.ini"; +wstring COMPONENTS_FILE_STRING = PLUGINS_DIR + L"\\components.ini"; LPCWSTR COMPONENTS_FILE = COMPONENTS_FILE_STRING.c_str(); -wstring PLAYERDATA_FILE_STRING = DirPath() + L"\\plugins\\playerdata.ini"; +wstring PLAYERDATA_FILE_STRING = PLUGINS_DIR + L"\\playerdata.ini"; LPCWSTR PLAYERDATA_FILE = PLAYERDATA_FILE_STRING.c_str(); LPCWSTR PATCHES_SECTION = L"patches"; @@ -265,6 +268,70 @@ void PrependFile(LPCSTR newStr, LPCWSTR fileName) } +struct PluginInfo { + HMODULE handle; + std::wstring filename; + std::wstring name; + std::wstring description; + std::vector configopts; +}; +std::vector LoadPlugins() +{ + std::vector outvec; + + HANDLE hFind; + WIN32_FIND_DATAW ffd; + + hFind = FindFirstFileW((PLUGINS_DIR + L"\\*.dva").c_str(), &ffd); + if (hFind != INVALID_HANDLE_VALUE) { + do { + if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + { + auto pos = wcslen(ffd.cFileName); + + if (ffd.cFileName[pos - 4] == '.' && + (ffd.cFileName[pos - 3] == 'd' || ffd.cFileName[pos - 3] == 'D') && + (ffd.cFileName[pos - 2] == 'v' || ffd.cFileName[pos - 2] == 'V') && + (ffd.cFileName[pos - 1] == 'a' || ffd.cFileName[pos - 1] == 'A')) + { + PluginInfo thisplugin; + thisplugin.handle = LoadLibraryW(ffd.cFileName); + thisplugin.filename = ffd.cFileName; + + if (thisplugin.handle == NULL) + continue; + + auto nameFunc = (LPCWSTR(*)())GetProcAddress(thisplugin.handle, "GetPluginName"); + auto descFunc = (LPCWSTR(*)())GetProcAddress(thisplugin.handle, "GetPluginDescription"); + auto optsFunc = (std::vector(*)())GetProcAddress(thisplugin.handle, "GetPluginOptions"); + + if (nameFunc != NULL) + thisplugin.name = nameFunc(); + else + thisplugin.name = thisplugin.filename; + + if (descFunc != NULL) + thisplugin.description = descFunc(); + else + thisplugin.description = (thisplugin.filename + L" plugin").c_str(); + + if (optsFunc != NULL) + thisplugin.configopts = optsFunc(); + + FreeLibrary(thisplugin.handle); + + outvec.push_back(thisplugin); + } + } + } while (FindNextFileW(hFind, &ffd)); + FindClose(hFind); + } + + return outvec; +} +std::vector AllPlugins = LoadPlugins(); + + // used to trick Optimus into switching to the NVIDIA GPU HMODULE nvcudaModule = LoadLibraryW(L"nvcuda.dll"); // cuInit actually returns a CUresult, but we don't really care about it diff --git a/source-code/source/plugins/Launcher/ui.h b/source-code/source/plugins/Launcher/ui.h index 2251521..f764e41 100644 --- a/source-code/source/plugins/Launcher/ui.h +++ b/source-code/source/plugins/Launcher/ui.h @@ -114,16 +114,34 @@ namespace Launcher { for (ConfigOptionBase* component : componentsArray) { component->hasChanged = ConfigHasChanged; - //componentsY += component->AddToPanel(panel_Components, 12, componentsY, toolTip1); + componentsY += component->AddToPanel(panel_Components, 12, componentsY, toolTip1); } this->panel_Components->ResumeLayout(false); this->panel_Components->PerformLayout(); + this->panel_Plugins->SuspendLayout(); + + int pluginsY = 3; + for (PluginInfo &plugin : AllPlugins) + { + Label^ lbl = gcnew Label; + lbl->AutoSize = true; + lbl->Text = gcnew String(plugin.name.c_str()); + lbl->Left = 12; + lbl->Top = pluginsY; + panel_Plugins->Controls->Add(lbl); + toolTip1->SetToolTip(lbl, gcnew String(plugin.description.c_str())); + pluginsY += lbl->Font->Height + 6; + } + this->panel_Plugins->ResumeLayout(false); + this->panel_Plugins->PerformLayout(); + + using namespace PluginConfig; //tabPage_Components->Controls->Add(MakePanel(256, 256, testcfgconfigopts, toolTip1)); - tabPage_Components->Controls->Add(MakePanel(256, 100, std::vector(&componentsArray[0], &componentsArray[12]), toolTip1)); + //tabPage_Components->Controls->Add(MakePanel(256, 100, std::vector(&componentsArray[0], &componentsArray[13]), toolTip1)); // trick Optimus into switching to the NVIDIA GPU @@ -183,6 +201,8 @@ namespace Launcher { private: System::Windows::Forms::Panel^ panel_Components; private: System::Windows::Forms::TabPage^ tabPage_Patches; private: System::Windows::Forms::Panel^ panel_Patches; + private: System::Windows::Forms::TabPage^ tabPage_Plugins; + private: System::Windows::Forms::Panel^ panel_Plugins; private: System::Windows::Forms::Button^ button_Discord; private: System::Windows::Forms::Button^ button_github; private: System::Windows::Forms::TabPage^ tabPage_Playerdata; @@ -238,6 +258,8 @@ namespace Launcher { this->panel_Playerdata = (gcnew System::Windows::Forms::Panel()); this->tabPage_Components = (gcnew System::Windows::Forms::TabPage()); this->panel_Components = (gcnew System::Windows::Forms::Panel()); + this->tabPage_Plugins = (gcnew System::Windows::Forms::TabPage()); + this->panel_Plugins = (gcnew System::Windows::Forms::Panel()); this->button_Discord = (gcnew System::Windows::Forms::Button()); this->button_github = (gcnew System::Windows::Forms::Button()); this->toolTip1 = (gcnew System::Windows::Forms::ToolTip(this->components)); @@ -249,6 +271,7 @@ namespace Launcher { this->tabPage_Patches->SuspendLayout(); this->tabPage_Playerdata->SuspendLayout(); this->tabPage_Components->SuspendLayout(); + this->tabPage_Plugins->SuspendLayout(); this->SuspendLayout(); // // button_Launch @@ -306,6 +329,7 @@ namespace Launcher { this->tabControl->Controls->Add(this->tabPage_Patches); this->tabControl->Controls->Add(this->tabPage_Playerdata); this->tabControl->Controls->Add(this->tabPage_Components); + this->tabControl->Controls->Add(this->tabPage_Plugins); this->tabControl->Location = System::Drawing::Point(0, 0); this->tabControl->Margin = System::Windows::Forms::Padding(4); this->tabControl->Name = L"tabControl"; @@ -409,7 +433,7 @@ namespace Launcher { // this->tabPage_Components->BackColor = System::Drawing::Color::FromArgb(static_cast(static_cast(64)), static_cast(static_cast(64)), static_cast(static_cast(64))); - //this->tabPage_Components->Controls->Add(this->panel_Components); + this->tabPage_Components->Controls->Add(this->panel_Components); this->tabPage_Components->Location = System::Drawing::Point(4, 32); this->tabPage_Components->Margin = System::Windows::Forms::Padding(4); this->tabPage_Components->Name = L"tabPage_Components"; @@ -427,6 +451,28 @@ namespace Launcher { this->panel_Components->Size = System::Drawing::Size(429, 425); this->panel_Components->TabIndex = 0; // + // tabPage_Plugins + // + this->tabPage_Plugins->BackColor = System::Drawing::Color::FromArgb(static_cast(static_cast(64)), + static_cast(static_cast(64)), static_cast(static_cast(64))); + this->tabPage_Plugins->Controls->Add(this->panel_Plugins); + this->tabPage_Plugins->Location = System::Drawing::Point(4, 32); + this->tabPage_Plugins->Margin = System::Windows::Forms::Padding(4); + this->tabPage_Plugins->Name = L"tabPage_Plugins"; + this->tabPage_Plugins->Padding = System::Windows::Forms::Padding(4); + this->tabPage_Plugins->Size = System::Drawing::Size(433, 429); + this->tabPage_Plugins->TabIndex = 3; + this->tabPage_Plugins->Text = L"Plugins"; + // + // panel_Plugins + // + this->panel_Plugins->AutoScroll = true; + this->panel_Plugins->Location = System::Drawing::Point(0, 0); + this->panel_Plugins->Margin = System::Windows::Forms::Padding(4); + this->panel_Plugins->Name = L"panel_Plugins"; + this->panel_Plugins->Size = System::Drawing::Size(429, 425); + this->panel_Plugins->TabIndex = 0; + // // button_Discord // this->button_Discord->BackColor = System::Drawing::Color::Transparent; @@ -511,6 +557,7 @@ namespace Launcher { this->tabPage_Patches->ResumeLayout(false); this->tabPage_Playerdata->ResumeLayout(false); this->tabPage_Components->ResumeLayout(false); + this->tabPage_Plugins->ResumeLayout(false); this->ResumeLayout(false); } From b8e6e7b59a298a3779b83a5672a06aef3753fbf4 Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Thu, 22 Aug 2019 06:25:52 +1000 Subject: [PATCH 04/19] launcher: fix crashing --- source-code/source/plugins/Launcher/PluginConfigApi.h | 1 + source-code/source/plugins/Launcher/framework.h | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source-code/source/plugins/Launcher/PluginConfigApi.h b/source-code/source/plugins/Launcher/PluginConfigApi.h index aeb69ec..89ec3a0 100644 --- a/source-code/source/plugins/Launcher/PluginConfigApi.h +++ b/source-code/source/plugins/Launcher/PluginConfigApi.h @@ -2,6 +2,7 @@ #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 diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index 84bb05d..9e22d71 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -313,12 +313,13 @@ std::vector LoadPlugins() if (descFunc != NULL) thisplugin.description = descFunc(); else - thisplugin.description = (thisplugin.filename + L" plugin").c_str(); + thisplugin.description = (thisplugin.filename + L" Plugin").c_str(); if (optsFunc != NULL) thisplugin.configopts = optsFunc(); - FreeLibrary(thisplugin.handle); + // afaik FreeLibrary should be fine because of ref counting, but it isn't. whatever. + // FreeLibrary(thisplugin.handle); outvec.push_back(thisplugin); } From ce1e90434d84099fb825937f13020afc8f790d87 Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Thu, 22 Aug 2019 06:27:08 +1000 Subject: [PATCH 05/19] divasound: add plugin config api support for testing --- .../plugins/DivaSound/DivaSound.vcxproj | 1 + .../DivaSound/DivaSound.vcxproj.filters | 3 + .../plugins/DivaSound/src/PluginConfigApi.h | 145 ++++++++++++++++++ .../source/plugins/DivaSound/src/dllmain.cpp | 27 ++++ 4 files changed, 176 insertions(+) create mode 100644 source-code/source/plugins/DivaSound/src/PluginConfigApi.h diff --git a/source-code/source/plugins/DivaSound/DivaSound.vcxproj b/source-code/source/plugins/DivaSound/DivaSound.vcxproj index 1813284..d49c39a 100644 --- a/source-code/source/plugins/DivaSound/DivaSound.vcxproj +++ b/source-code/source/plugins/DivaSound/DivaSound.vcxproj @@ -82,6 +82,7 @@ + diff --git a/source-code/source/plugins/DivaSound/DivaSound.vcxproj.filters b/source-code/source/plugins/DivaSound/DivaSound.vcxproj.filters index 3d3bf67..99a4edb 100644 --- a/source-code/source/plugins/DivaSound/DivaSound.vcxproj.filters +++ b/source-code/source/plugins/DivaSound/DivaSound.vcxproj.filters @@ -23,5 +23,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/source-code/source/plugins/DivaSound/src/PluginConfigApi.h b/source-code/source/plugins/DivaSound/src/PluginConfigApi.h new file mode 100644 index 0000000..aeb69ec --- /dev/null +++ b/source-code/source/plugins/DivaSound/src/PluginConfigApi.h @@ -0,0 +1,145 @@ +#pragma once +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include + +// resolution class to store and sort the width and height easily +class resolution +{ +public: + unsigned int width; + unsigned int height; + + resolution() + { + width = 0; + height = 0; + } + + resolution(unsigned int width, unsigned int height) + { + resolution::width = width; + resolution::height = height; + } + + bool operator ==(const resolution &res2) + { + return width == res2.width && height == res2.height; + } + + // in comparisons width takes priority because it's usually displayed first + bool operator <(const resolution &res2) + { + if (width == res2.width) + return height < res2.height; + else + return width < res2.width; + } + bool operator >(const resolution &res2) + { + if (width == res2.width) + return height > res2.height; + else + return width > res2.width; + } +}; + +namespace PluginConfig +{ + enum ConfigType { + CONFIG_BOOLEAN, + CONFIG_NUMERIC, + CONFIG_STRING, + CONFIG_DROPDOWN_INDEX, + CONFIG_DROPDOWN_TEXT, + CONFIG_DROPDOWN_NUMBER, + CONFIG_RESOLUTION, + CONFIG_GROUP_START, + CONFIG_GROUP_END + }; + + struct PluginConfigBooleanData { + LPCWSTR iniVarName; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + bool defaultVal; + bool saveAsString; + }; + + struct PluginConfigNumericData { + LPCWSTR iniVarName; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + int defaultVal; + int minVal; + int maxVal; + }; + + struct PluginConfigStringData { + LPCWSTR iniVarName; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + LPCWSTR defaultVal; + bool useUtf8; + }; + + struct PluginConfigDropdownIndexData { + LPCWSTR iniVarName; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + int defaultVal; + std::vector valueStrings; + }; + + struct PluginConfigDropdownTextData { + LPCWSTR iniVarName; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + LPCWSTR defaultVal; + std::vector valueStrings; + bool useUtf8; + }; + + struct PluginConfigDropdownNumberData { + LPCWSTR iniVarName; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + int defaultVal; + std::vector valueInts; + }; + + struct PluginConfigResolutionData { + LPCWSTR iniVarName; + LPCWSTR iniVarName2; + LPCWSTR iniSectionName; + LPCWSTR iniFilePath; + LPCWSTR friendlyName; + LPCWSTR description; + resolution defaultVal; + std::vector valueResolutions; + }; + + struct PluginConfigGroupData + { + LPCWSTR name; + int height; + }; + + struct PluginConfigOption + { + ConfigType cfgType; + void* data; + }; +} \ No newline at end of file diff --git a/source-code/source/plugins/DivaSound/src/dllmain.cpp b/source-code/source/plugins/DivaSound/src/dllmain.cpp index 350b118..70240fc 100644 --- a/source-code/source/plugins/DivaSound/src/dllmain.cpp +++ b/source-code/source/plugins/DivaSound/src/dllmain.cpp @@ -1,4 +1,5 @@ #include "framework.h" +#include "PluginConfigApi.h" #include #pragma comment(lib, "detours.lib") @@ -410,3 +411,29 @@ BOOL APIENTRY DllMain(HMODULE hModule, return TRUE; } + +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_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 } }, +}; + +extern "C" __declspec(dllexport) LPCWSTR GetPluginName(void) +{ + return L"DivaSound"; +} + +extern "C" __declspec(dllexport) LPCWSTR GetPluginDescription(void) +{ + return L"DivaSound Plugin by somewhatlurker\n\nDivaSound replaces the game's original audio output,\nimproving device support and adding configurable options."; +} + +extern "C" __declspec(dllexport) std::vector GetPluginOptions(void) +{ + return config; +} \ No newline at end of file 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 06/19] 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); From 066208bcda8e747cc75cb04dca46b431bf2f9140 Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Sat, 24 Aug 2019 09:37:18 +1000 Subject: [PATCH 07/19] launcher: get viewing config options for plugins working (no saving yet, but they do trigger the save prompt) --- .../source/plugins/Launcher/ConfigOption.h | 136 +++++++++++++++++- .../source/plugins/Launcher/framework.h | 18 ++- source-code/source/plugins/Launcher/ui.h | 12 +- 3 files changed, 153 insertions(+), 13 deletions(-) diff --git a/source-code/source/plugins/Launcher/ConfigOption.h b/source-code/source/plugins/Launcher/ConfigOption.h index 3bb573b..3354576 100644 --- a/source-code/source/plugins/Launcher/ConfigOption.h +++ b/source-code/source/plugins/Launcher/ConfigOption.h @@ -18,6 +18,7 @@ float BaseScaleSize = 96; int Col1Width = 110; int Col2Left = 114; int Col2Width = 110; +int ConfigBtnLeft = 160; int ControlSpacing = 6; // Custom function. Works like GetPrivateProfileIntW but returns bool. Can detect a numeric value or string. @@ -41,6 +42,10 @@ bool GetPrivateProfileBoolW(LPCWSTR lpAppName, LPCWSTR lpKeyName, bool default, return out; } +// declare this early (actual definitions below) +class ConfigOptionBase; +Panel^ MakePanel(int width, int height, std::vector &cfg, ToolTip^ tooltip, bool* hasChanged); + ref class ComboboxValidation { @@ -139,6 +144,49 @@ public: }; +ref class PluginConfigHandler +{ +public: + Panel^ opts; + + PluginConfigHandler(Panel^ optspanel) + { + opts = optspanel; + } + + System::Void OpenForm(System::Object^ sender, System::EventArgs^ e) + { + Form^ OptsForm = gcnew Form(); + + OptsForm->FormBorderStyle = FormBorderStyle::FixedDialog; + OptsForm->StartPosition = FormStartPosition::CenterScreen; + OptsForm->MaximizeBox = false; + OptsForm->MinimizeBox = false; + OptsForm->ShowInTaskbar = false; + OptsForm->ShowIcon = false; + + OptsForm->BackColor = Drawing::Color::FromArgb(64, 64, 64); + OptsForm->ForeColor = Drawing::Color::White; + + opts->Left = 0; + opts->Top = 0; + + Button^ OkBtn = gcnew Button(); + OkBtn->Text = L"OK"; + OkBtn->Left = 4; + OkBtn->Top = opts->Bottom + 4; + OkBtn->AutoSize = true; + OkBtn->FlatStyle = System::Windows::Forms::FlatStyle::Flat; + + OptsForm->ClientSize = Drawing::Size(opts->Width, OkBtn->Bottom + 4); + + OptsForm->Controls->Add(opts); + OptsForm->Controls->Add(OkBtn); + + OptsForm->ShowDialog(); + } +}; + ref class ChangeHandler { public: @@ -854,7 +902,90 @@ public: }; -Panel^ MakePanel(int width, int height, std::vector &cfg, ToolTip^ tooltip) +class PluginOption : public ConfigOptionBase +{ +public: + bool _defaultVal; + std::vector _configopts; + + PluginOption(LPCWSTR iniVarName, LPCWSTR iniSectionName, LPCWSTR iniFilePath, LPCWSTR friendlyName, LPCWSTR description, bool defaultVal, std::vector configopts) + { + _iniVarName = iniVarName; + _iniSectionName = iniSectionName; + _iniFilePath = iniFilePath; + _friendlyName = friendlyName; + _description = description; + _defaultVal = defaultVal; + _configopts = configopts; + } + + virtual int AddToPanel(Panel^ panel, unsigned int left, unsigned int top, ToolTip^ tooltip) + { + CheckBox^ cb = gcnew CheckBox(); + Button^ button = gcnew Button(); + + cb->Text = gcnew String(_friendlyName); + cb->Checked = GetPrivateProfileBoolW(_iniSectionName, _iniVarName, _defaultVal, _iniFilePath); + cb->Left = left + 2; + cb->Top = top + 3; + cb->AutoSize = true; + cb->FlatStyle = System::Windows::Forms::FlatStyle::Flat; + + // hack to ensure high contrast + cb->BackColor = System::Drawing::Color::FromArgb(0, 0, 0, 0); + + button->Text = L"Config"; + button->Left = left + ConfigBtnLeft; + button->Top = top; + button->AutoSize = true; + button->FlatStyle = System::Windows::Forms::FlatStyle::Flat; + + Form^ RootForm = panel->FindForm(); + float ScaleWidth = 1.0f; + float ScaleHeight = 1.0f; + if (RootForm) + { + Drawing::SizeF CurrentScaleSize = RootForm->CurrentAutoScaleDimensions; + ScaleWidth = CurrentScaleSize.Width / BaseScaleSize; + ScaleHeight = CurrentScaleSize.Height / BaseScaleSize; + } + cb->Scale(ScaleWidth, ScaleHeight); + button->Scale(ScaleWidth, ScaleHeight); + + tooltip->SetToolTip(cb, gcnew String(_description)); + + if (hasChanged == nullptr) + hasChanged = new bool; + ChangeHandler^ changehandler = gcnew ChangeHandler(hasChanged); + cb->CheckedChanged += gcnew System::EventHandler(changehandler, &ChangeHandler::SetChanged); + + panel->Controls->Add(cb); + mainControlHandle = cb->Handle; + + if (_configopts.size() > 0) + { + Panel^ configPanel = MakePanel((Col2Left + Col2Width + 64), 250, _configopts, tooltip, hasChanged); + configPanel->Scale(ScaleWidth, ScaleHeight); + PluginConfigHandler^ confighandler = gcnew PluginConfigHandler(configPanel); + button->Click += gcnew System::EventHandler(confighandler, &PluginConfigHandler::OpenForm); + + panel->Controls->Add(button); + } + + int ControlHeight = button->Height / ScaleHeight; + return ControlHeight + ControlSpacing; + } + + virtual void SaveOption() + { + bool boolEnabled = ((CheckBox^)CheckBox::FromHandle(mainControlHandle))->Checked; + + WritePrivateProfileStringW(_iniSectionName, _iniVarName, boolEnabled ? L"1" : L"0", _iniFilePath); + } +}; + + +Panel^ MakePanel(int width, int height, std::vector &cfg, ToolTip^ tooltip, bool* hasChanged) { Panel^ outpanel = gcnew Panel(); outpanel->Width = width; @@ -903,7 +1034,7 @@ Panel^ MakePanel(int width, int height, std::vector &cfg, Too break; } - Panel^ groupPanel = MakePanel(groupbox->Width - (ScaleWidth * 8), groupbox->Height - (ScaleHeight * 10), std::vector(&(cfg[i + 1]), &(cfg[endidx])), tooltip); + Panel^ groupPanel = MakePanel(groupbox->Width - (ScaleWidth * 8), groupbox->Height - (ScaleHeight * 10), std::vector(&(cfg[i + 1]), &(cfg[endidx])), tooltip, hasChanged); groupPanel->Left = ScaleWidth * 12; groupPanel->Top = ScaleHeight * (curY + 8); @@ -915,6 +1046,7 @@ Panel^ MakePanel(int width, int height, std::vector &cfg, Too } else { + cfg[i]->hasChanged = hasChanged; curY += cfg[i]->AddToPanel(outpanel, curX, curY, tooltip); } } diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index aae10b1..a39444e 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -273,7 +273,7 @@ struct PluginInfo { std::wstring filename; std::wstring name; std::wstring description; - std::vector configopts; + std::vector configopts; }; std::vector LoadPlugins() { @@ -316,7 +316,7 @@ std::vector LoadPlugins() thisplugin.description = (thisplugin.filename + L" Plugin").c_str(); if (optsFunc != NULL) - thisplugin.configopts = optsFunc(); + thisplugin.configopts = PluginConfig::GetConfigOptionVec(optsFunc()); // afaik FreeLibrary should be fine because of ref counting, but it isn't. whatever. // FreeLibrary(thisplugin.handle); @@ -332,6 +332,20 @@ std::vector LoadPlugins() } std::vector AllPlugins = LoadPlugins(); +std::vector GetPluginOptions(std::vector* plugins) +{ + std::vector outvec; + + for (PluginInfo &pi : *plugins) + { + PluginOption* opt = new PluginOption(pi.filename.c_str(), L"plugins", CONFIG_FILE, pi.name.c_str(), pi.description.c_str(), true, pi.configopts); + outvec.push_back(opt); + } + + return outvec; +} +std::vector AllPluginOpts = GetPluginOptions(&AllPlugins); + // used to trick Optimus into switching to the NVIDIA GPU HMODULE nvcudaModule = LoadLibraryW(L"nvcuda.dll"); diff --git a/source-code/source/plugins/Launcher/ui.h b/source-code/source/plugins/Launcher/ui.h index f764e41..b0a61d0 100644 --- a/source-code/source/plugins/Launcher/ui.h +++ b/source-code/source/plugins/Launcher/ui.h @@ -123,16 +123,10 @@ namespace Launcher { this->panel_Plugins->SuspendLayout(); int pluginsY = 3; - for (PluginInfo &plugin : AllPlugins) + for (ConfigOptionBase* option : AllPluginOpts) { - Label^ lbl = gcnew Label; - lbl->AutoSize = true; - lbl->Text = gcnew String(plugin.name.c_str()); - lbl->Left = 12; - lbl->Top = pluginsY; - panel_Plugins->Controls->Add(lbl); - toolTip1->SetToolTip(lbl, gcnew String(plugin.description.c_str())); - pluginsY += lbl->Font->Height + 6; + option->hasChanged = ConfigHasChanged; + pluginsY += option->AddToPanel(panel_Plugins, 12, pluginsY, toolTip1); } this->panel_Plugins->ResumeLayout(false); this->panel_Plugins->PerformLayout(); From c2e243852f96317325a1e4e0c379f5fc14a60b58 Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Sat, 24 Aug 2019 11:33:05 +1000 Subject: [PATCH 08/19] launcher: implement saving of plugin config + minor tweaks --- .../source/plugins/Launcher/ConfigOption.h | 88 ++++++++++++------- source-code/source/plugins/Launcher/ui.h | 11 ++- 2 files changed, 62 insertions(+), 37 deletions(-) diff --git a/source-code/source/plugins/Launcher/ConfigOption.h b/source-code/source/plugins/Launcher/ConfigOption.h index 3354576..fa35082 100644 --- a/source-code/source/plugins/Launcher/ConfigOption.h +++ b/source-code/source/plugins/Launcher/ConfigOption.h @@ -147,43 +147,64 @@ public: ref class PluginConfigHandler { public: - Panel^ opts; + Form^ form; - PluginConfigHandler(Panel^ optspanel) + PluginConfigHandler(Panel^ optspanel, String^ title) { - opts = optspanel; - } + form = gcnew Form(); - System::Void OpenForm(System::Object^ sender, System::EventArgs^ e) - { - Form^ OptsForm = gcnew Form(); + form->Text = title; - OptsForm->FormBorderStyle = FormBorderStyle::FixedDialog; - OptsForm->StartPosition = FormStartPosition::CenterScreen; - OptsForm->MaximizeBox = false; - OptsForm->MinimizeBox = false; - OptsForm->ShowInTaskbar = false; - OptsForm->ShowIcon = false; + form->FormBorderStyle = FormBorderStyle::FixedDialog; + form->StartPosition = FormStartPosition::CenterScreen; + form->MaximizeBox = false; + form->MinimizeBox = false; + form->ShowInTaskbar = false; + form->ShowIcon = false; - OptsForm->BackColor = Drawing::Color::FromArgb(64, 64, 64); - OptsForm->ForeColor = Drawing::Color::White; + form->BackColor = Drawing::Color::FromArgb(64, 64, 64); + form->ForeColor = Drawing::Color::White; - opts->Left = 0; - opts->Top = 0; + optspanel->Left = 0; + optspanel->Top = 0; Button^ OkBtn = gcnew Button(); OkBtn->Text = L"OK"; OkBtn->Left = 4; - OkBtn->Top = opts->Bottom + 4; + OkBtn->Top = optspanel->Bottom + 4; OkBtn->AutoSize = true; OkBtn->FlatStyle = System::Windows::Forms::FlatStyle::Flat; - OptsForm->ClientSize = Drawing::Size(opts->Width, OkBtn->Bottom + 4); + form->ClientSize = Drawing::Size(optspanel->Width, OkBtn->Bottom + 4); - OptsForm->Controls->Add(opts); - OptsForm->Controls->Add(OkBtn); + form->Controls->Add(optspanel); + form->Controls->Add(OkBtn); + form->AcceptButton = OkBtn; - OptsForm->ShowDialog(); + form->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &PluginConfigHandler::FormClosing); + OkBtn->Click += gcnew EventHandler(this, &PluginConfigHandler::OkClick); + } + + System::Void OpenForm(System::Object^ sender, System::EventArgs^ e) + { + // ShowDialog seems to prevent disposal by copying the panel... + // which would be fine if I didn't rely on using the control handles + // MessageBox::Show(form->Controls[0]->Handle.ToString()); + + //Application::OpenForms[0]->Enabled = false; + form->Show(); + } + + System::Void FormClosing(System::Object^ sender, FormClosingEventArgs^ e) + { + form->Hide(); + //Application::OpenForms[0]->Enabled = true; + e->Cancel = true; + } + + System::Void OkClick(System::Object^ sender, System::EventArgs^ e) + { + form->Close(); } }; @@ -294,7 +315,7 @@ public: tooltip->SetToolTip(cb, gcnew String(_description)); if (hasChanged == nullptr) - hasChanged = new bool; + hasChanged = new bool(false); ChangeHandler^ changehandler = gcnew ChangeHandler(hasChanged); cb->CheckedChanged += gcnew System::EventHandler(changehandler, &ChangeHandler::SetChanged); @@ -374,7 +395,7 @@ public: tooltip->SetToolTip(numberbox, gcnew String(_description)); if (hasChanged == nullptr) - hasChanged = new bool; + hasChanged = new bool(false); ChangeHandler^ changehandler = gcnew ChangeHandler(hasChanged); numberbox->ValueChanged += gcnew System::EventHandler(changehandler, &ChangeHandler::SetChanged); @@ -463,7 +484,7 @@ public: tooltip->SetToolTip(textbox, gcnew String(_description)); if (hasChanged == nullptr) - hasChanged = new bool; + hasChanged = new bool(false); ChangeHandler^ changehandler = gcnew ChangeHandler(hasChanged); textbox->TextChanged += gcnew System::EventHandler(changehandler, &ChangeHandler::SetChanged); @@ -557,7 +578,7 @@ public: tooltip->SetToolTip(combobox, gcnew String(_description)); if (hasChanged == nullptr) - hasChanged = new bool; + hasChanged = new bool(false); ChangeHandler^ changehandler = gcnew ChangeHandler(hasChanged); combobox->SelectedIndexChanged += gcnew System::EventHandler(changehandler, &ChangeHandler::SetChanged); @@ -661,7 +682,7 @@ public: tooltip->SetToolTip(combobox, gcnew String(_description)); if (hasChanged == nullptr) - hasChanged = new bool; + hasChanged = new bool(false); ChangeHandler^ changehandler = gcnew ChangeHandler(hasChanged); combobox->TextChanged += gcnew System::EventHandler(changehandler, &ChangeHandler::SetChanged); @@ -769,7 +790,7 @@ public: combobox->Leave += gcnew System::EventHandler(validation, &ComboboxValidation::CheckNumberLeave); if (hasChanged == nullptr) - hasChanged = new bool; + hasChanged = new bool(false); ChangeHandler^ changehandler = gcnew ChangeHandler(hasChanged); combobox->TextChanged += gcnew System::EventHandler(changehandler, &ChangeHandler::SetChanged); @@ -866,7 +887,7 @@ public: tooltip->SetToolTip(combobox, gcnew String(_description)); if (hasChanged == nullptr) - hasChanged = new bool; + hasChanged = new bool(false); ChangeHandler^ changehandler = gcnew ChangeHandler(hasChanged); combobox->TextChanged += gcnew System::EventHandler(changehandler, &ChangeHandler::SetChanged); @@ -955,7 +976,7 @@ public: tooltip->SetToolTip(cb, gcnew String(_description)); if (hasChanged == nullptr) - hasChanged = new bool; + hasChanged = new bool(false); ChangeHandler^ changehandler = gcnew ChangeHandler(hasChanged); cb->CheckedChanged += gcnew System::EventHandler(changehandler, &ChangeHandler::SetChanged); @@ -966,7 +987,7 @@ public: { Panel^ configPanel = MakePanel((Col2Left + Col2Width + 64), 250, _configopts, tooltip, hasChanged); configPanel->Scale(ScaleWidth, ScaleHeight); - PluginConfigHandler^ confighandler = gcnew PluginConfigHandler(configPanel); + PluginConfigHandler^ confighandler = gcnew PluginConfigHandler(configPanel, gcnew String(_friendlyName) + " Options"); button->Click += gcnew System::EventHandler(confighandler, &PluginConfigHandler::OpenForm); panel->Controls->Add(button); @@ -981,6 +1002,11 @@ public: bool boolEnabled = ((CheckBox^)CheckBox::FromHandle(mainControlHandle))->Checked; WritePrivateProfileStringW(_iniSectionName, _iniVarName, boolEnabled ? L"1" : L"0", _iniFilePath); + + for (ConfigOptionBase* opt : _configopts) + { + opt->SaveOption(); + } } }; diff --git a/source-code/source/plugins/Launcher/ui.h b/source-code/source/plugins/Launcher/ui.h index b0a61d0..f8a4c47 100644 --- a/source-code/source/plugins/Launcher/ui.h +++ b/source-code/source/plugins/Launcher/ui.h @@ -132,12 +132,6 @@ namespace Launcher { this->panel_Plugins->PerformLayout(); - - using namespace PluginConfig; - //tabPage_Components->Controls->Add(MakePanel(256, 256, testcfgconfigopts, toolTip1)); - //tabPage_Components->Controls->Add(MakePanel(256, 100, std::vector(&componentsArray[0], &componentsArray[13]), toolTip1)); - - // trick Optimus into switching to the NVIDIA GPU if (cuInit != NULL) cuInit(0); @@ -581,6 +575,11 @@ private: System::Void SaveSettings() { { component->SaveOption(); } + + for (ConfigOptionBase* option : AllPluginOpts) + { + option->SaveOption(); + } } private: System::Void Ui_Load(System::Object^ sender, System::EventArgs^ e){ } From fd76400e7265fa60eec3253c9ba105dec8ec5775 Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Sun, 25 Aug 2019 17:07:55 +1000 Subject: [PATCH 09/19] launcher: fix plugins being loaded when not wanted --- source-code/source/plugins/Launcher/framework.h | 9 +++++---- source-code/source/plugins/Launcher/ui.h | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index a39444e..95a4613 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -318,8 +318,7 @@ std::vector LoadPlugins() if (optsFunc != NULL) thisplugin.configopts = PluginConfig::GetConfigOptionVec(optsFunc()); - // afaik FreeLibrary should be fine because of ref counting, but it isn't. whatever. - // FreeLibrary(thisplugin.handle); + FreeLibrary(thisplugin.handle); outvec.push_back(thisplugin); } @@ -330,7 +329,8 @@ std::vector LoadPlugins() return outvec; } -std::vector AllPlugins = LoadPlugins(); +// don't load until actually needed to avoid loading disabled plugins +std::vector AllPlugins; // = LoadPlugins(); std::vector GetPluginOptions(std::vector* plugins) { @@ -344,7 +344,8 @@ std::vector GetPluginOptions(std::vector* plugins) return outvec; } -std::vector AllPluginOpts = GetPluginOptions(&AllPlugins); +// don't load until actually needed to avoid loading disabled plugins +std::vector AllPluginOpts; // = GetPluginOptions(&AllPlugins); // used to trick Optimus into switching to the NVIDIA GPU diff --git a/source-code/source/plugins/Launcher/ui.h b/source-code/source/plugins/Launcher/ui.h index f8a4c47..d49e2da 100644 --- a/source-code/source/plugins/Launcher/ui.h +++ b/source-code/source/plugins/Launcher/ui.h @@ -120,6 +120,9 @@ namespace Launcher { this->panel_Components->PerformLayout(); + AllPlugins = LoadPlugins(); + AllPluginOpts = GetPluginOptions(&AllPlugins); + this->panel_Plugins->SuspendLayout(); int pluginsY = 3; From be8572d20c81e886fbc921723429701d59b77a8a Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Sun, 25 Aug 2019 17:17:40 +1000 Subject: [PATCH 10/19] launcher: set config window owner to existing form (improves window management) --- source-code/source/plugins/Launcher/ConfigOption.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/source-code/source/plugins/Launcher/ConfigOption.h b/source-code/source/plugins/Launcher/ConfigOption.h index fa35082..8cd1589 100644 --- a/source-code/source/plugins/Launcher/ConfigOption.h +++ b/source-code/source/plugins/Launcher/ConfigOption.h @@ -161,6 +161,7 @@ public: form->MinimizeBox = false; form->ShowInTaskbar = false; form->ShowIcon = false; + //form->TopMost = true; form->BackColor = Drawing::Color::FromArgb(64, 64, 64); form->ForeColor = Drawing::Color::White; @@ -192,14 +193,20 @@ public: // MessageBox::Show(form->Controls[0]->Handle.ToString()); //Application::OpenForms[0]->Enabled = false; + form->Owner = Application::OpenForms[0]; + if (form->Visible) + form->Hide(); form->Show(); } System::Void FormClosing(System::Object^ sender, FormClosingEventArgs^ e) { - form->Hide(); - //Application::OpenForms[0]->Enabled = true; - e->Cancel = true; + if (e->CloseReason == CloseReason::UserClosing) + { + form->Hide(); + //Application::OpenForms[0]->Enabled = true; + e->Cancel = true; + } } System::Void OkClick(System::Object^ sender, System::EventArgs^ e) From 38f17ce692c8b8f13024ef8c0a1b5e41e2a4572d Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Mon, 26 Aug 2019 13:33:08 +1000 Subject: [PATCH 11/19] don't use vector for GetPluginOptions (usable with other languages now) --- .../plugins/DivaSound/src/PluginConfigApi.h | 6 ++++++ .../source/plugins/DivaSound/src/dllmain.cpp | 18 +++++++++--------- .../source/plugins/Launcher/PluginConfig.h | 10 +++++++--- .../source/plugins/Launcher/PluginConfigApi.h | 6 ++++++ .../source/plugins/Launcher/framework.h | 2 +- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/source-code/source/plugins/DivaSound/src/PluginConfigApi.h b/source-code/source/plugins/DivaSound/src/PluginConfigApi.h index 3f0923e..d9f6a66 100644 --- a/source-code/source/plugins/DivaSound/src/PluginConfigApi.h +++ b/source-code/source/plugins/DivaSound/src/PluginConfigApi.h @@ -144,4 +144,10 @@ namespace PluginConfig ConfigType cfgType; void* data; }; + + struct PluginConfigArray + { + int len; + PluginConfigOption* options; + }; } \ No newline at end of file diff --git a/source-code/source/plugins/DivaSound/src/dllmain.cpp b/source-code/source/plugins/DivaSound/src/dllmain.cpp index 08356ad..1ab0c2e 100644 --- a/source-code/source/plugins/DivaSound/src/dllmain.cpp +++ b/source-code/source/plugins/DivaSound/src/dllmain.cpp @@ -414,13 +414,13 @@ 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" }), 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 } }, +PluginConfigOption config[] = { + { 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 } }, + { 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 } }, + { 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 } }, + { 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 } }, + { 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 } }, + { 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 } }, }; extern "C" __declspec(dllexport) LPCWSTR GetPluginName(void) @@ -433,7 +433,7 @@ extern "C" __declspec(dllexport) LPCWSTR GetPluginDescription(void) return L"DivaSound Plugin by somewhatlurker\n\nDivaSound replaces the game's original audio output,\nimproving device support and adding configurable options."; } -extern "C" __declspec(dllexport) std::vector GetPluginOptions(void) +extern "C" __declspec(dllexport) PluginConfigArray GetPluginOptions(void) { - return config; + return PluginConfigArray{ _countof(config), config }; } \ No newline at end of file diff --git a/source-code/source/plugins/Launcher/PluginConfig.h b/source-code/source/plugins/Launcher/PluginConfig.h index 5b8fe56..0a3170c 100644 --- a/source-code/source/plugins/Launcher/PluginConfig.h +++ b/source-code/source/plugins/Launcher/PluginConfig.h @@ -40,12 +40,16 @@ namespace PluginConfig } } - std::vector GetConfigOptionVec(std::vector &in) + std::vector GetConfigOptionVec(PluginConfigArray &in) { std::vector outvec; - for (PluginConfigOption &opt : in) + for (int i = 0; i < in.len; i++) { - outvec.push_back(GetConfigOption(opt)); + // basic check for validity + if (in.options[i].data == nullptr) + break; + + outvec.push_back(GetConfigOption(in.options[i])); } return outvec; } diff --git a/source-code/source/plugins/Launcher/PluginConfigApi.h b/source-code/source/plugins/Launcher/PluginConfigApi.h index 3f0923e..d9f6a66 100644 --- a/source-code/source/plugins/Launcher/PluginConfigApi.h +++ b/source-code/source/plugins/Launcher/PluginConfigApi.h @@ -144,4 +144,10 @@ namespace PluginConfig ConfigType cfgType; void* data; }; + + struct PluginConfigArray + { + int len; + PluginConfigOption* options; + }; } \ No newline at end of file diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index 95a4613..c82d5cf 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -303,7 +303,7 @@ std::vector LoadPlugins() auto nameFunc = (LPCWSTR(*)())GetProcAddress(thisplugin.handle, "GetPluginName"); auto descFunc = (LPCWSTR(*)())GetProcAddress(thisplugin.handle, "GetPluginDescription"); - auto optsFunc = (std::vector(*)())GetProcAddress(thisplugin.handle, "GetPluginOptions"); + auto optsFunc = (PluginConfig::PluginConfigArray(*)())GetProcAddress(thisplugin.handle, "GetPluginOptions"); if (nameFunc != NULL) thisplugin.name = nameFunc(); From fb7e51f38dc637c11721204c5704469d07f16f44 Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Mon, 26 Aug 2019 13:42:42 +1000 Subject: [PATCH 12/19] launcher: fix change detection for non-editable dropdowns --- source-code/source/plugins/Launcher/ConfigOption.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source-code/source/plugins/Launcher/ConfigOption.h b/source-code/source/plugins/Launcher/ConfigOption.h index 8cd1589..ba99518 100644 --- a/source-code/source/plugins/Launcher/ConfigOption.h +++ b/source-code/source/plugins/Launcher/ConfigOption.h @@ -691,7 +691,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); panel->Controls->Add(label); panel->Controls->Add(combobox); @@ -799,7 +802,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); panel->Controls->Add(label); panel->Controls->Add(combobox); 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 13/19] 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, From f5989b74ac0f82f43d4626eae3179c607326666f Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Tue, 27 Aug 2019 10:17:13 +1000 Subject: [PATCH 14/19] launcher: pack plugin config structs to ensure matching alignments --- source-code/source/plugins/DivaSound/src/PluginConfigApi.h | 2 ++ source-code/source/plugins/Launcher/PluginConfigApi.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/source-code/source/plugins/DivaSound/src/PluginConfigApi.h b/source-code/source/plugins/DivaSound/src/PluginConfigApi.h index f9535c8..f053d5c 100644 --- a/source-code/source/plugins/DivaSound/src/PluginConfigApi.h +++ b/source-code/source/plugins/DivaSound/src/PluginConfigApi.h @@ -46,6 +46,7 @@ public: namespace PluginConfig { +#pragma pack(push, 1) enum ConfigType { CONFIG_BOOLEAN, CONFIG_NUMERIC, @@ -151,4 +152,5 @@ namespace PluginConfig int len; PluginConfigOption* options; }; +#pragma pack(pop) } \ No newline at end of file diff --git a/source-code/source/plugins/Launcher/PluginConfigApi.h b/source-code/source/plugins/Launcher/PluginConfigApi.h index f9535c8..f053d5c 100644 --- a/source-code/source/plugins/Launcher/PluginConfigApi.h +++ b/source-code/source/plugins/Launcher/PluginConfigApi.h @@ -46,6 +46,7 @@ public: namespace PluginConfig { +#pragma pack(push, 1) enum ConfigType { CONFIG_BOOLEAN, CONFIG_NUMERIC, @@ -151,4 +152,5 @@ namespace PluginConfig int len; PluginConfigOption* options; }; +#pragma pack(pop) } \ No newline at end of file From b70fd18dd35ea88175efa684dee58f0aaf2dfa29 Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Tue, 27 Aug 2019 12:16:45 +1000 Subject: [PATCH 15/19] launcher: add custom button and spacer plugin config options --- .../plugins/DivaSound/src/PluginConfigApi.h | 14 +++- .../source/plugins/DivaSound/src/dllmain.cpp | 9 +++ .../source/plugins/Launcher/ConfigOption.h | 78 +++++++++++++++++++ .../source/plugins/Launcher/PluginConfig.h | 6 ++ .../source/plugins/Launcher/PluginConfigApi.h | 14 +++- 5 files changed, 119 insertions(+), 2 deletions(-) diff --git a/source-code/source/plugins/DivaSound/src/PluginConfigApi.h b/source-code/source/plugins/DivaSound/src/PluginConfigApi.h index f053d5c..d0ffd94 100644 --- a/source-code/source/plugins/DivaSound/src/PluginConfigApi.h +++ b/source-code/source/plugins/DivaSound/src/PluginConfigApi.h @@ -56,7 +56,9 @@ namespace PluginConfig CONFIG_DROPDOWN_NUMBER, CONFIG_RESOLUTION, CONFIG_GROUP_START, - CONFIG_GROUP_END + CONFIG_GROUP_END, + CONFIG_BUTTON, + CONFIG_SPACER }; struct PluginConfigBooleanData { @@ -141,6 +143,16 @@ namespace PluginConfig int height; }; + struct PluginConfigButtonData { + LPCWSTR friendlyName; + LPCWSTR description; + void(*func)(); + }; + + struct PluginConfigSpacerData { + int height; + }; + struct PluginConfigOption { ConfigType cfgType; diff --git a/source-code/source/plugins/DivaSound/src/dllmain.cpp b/source-code/source/plugins/DivaSound/src/dllmain.cpp index 1ab0c2e..a22837f 100644 --- a/source-code/source/plugins/DivaSound/src/dllmain.cpp +++ b/source-code/source/plugins/DivaSound/src/dllmain.cpp @@ -8,6 +8,7 @@ #include #include #include +#include void InjectCode(void* address, const std::vector data) { @@ -414,6 +415,11 @@ BOOL APIENTRY DllMain(HMODULE hModule, using namespace PluginConfig; +void OpenWiki() +{ + ShellExecuteW(NULL, L"open", L"https://github.com/somewhatlurker/DivaSound/wiki", NULL, NULL, SW_SHOW); +} + PluginConfigOption config[] = { { 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 } }, { 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 } }, @@ -421,6 +427,9 @@ PluginConfigOption config[] = { { 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 } }, { 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 } }, { 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 } }, + { CONFIG_SPACER, new PluginConfigSpacerData{ 8 } }, + { CONFIG_BUTTON, new PluginConfigButtonData{ L"Help", L"Get help on the DivaSound wiki.", OpenWiki } }, + { CONFIG_SPACER, new PluginConfigSpacerData{ 8 } }, }; extern "C" __declspec(dllexport) LPCWSTR GetPluginName(void) diff --git a/source-code/source/plugins/Launcher/ConfigOption.h b/source-code/source/plugins/Launcher/ConfigOption.h index 88477b1..ea48108 100644 --- a/source-code/source/plugins/Launcher/ConfigOption.h +++ b/source-code/source/plugins/Launcher/ConfigOption.h @@ -231,6 +231,22 @@ public: } }; +ref class CustomFuncHandler +{ +public: + void(*_func)(); + + CustomFuncHandler(void(*func)()) + { + _func = func; + } + + System::Void RunFunc(System::Object^ sender, System::EventArgs^ e) + { + _func(); + } +}; + class ConfigOptionBase { @@ -276,6 +292,22 @@ public: } }; +class OptionMetaSpacer : public ConfigOptionBase +{ +public: + int _height; + + OptionMetaSpacer(int height) + { + _height = height; + } + + virtual int AddToPanel(Panel^ panel, unsigned int left, unsigned int top, ToolTip^ tooltip) + { + return _height; + } +}; + class BooleanOption : public ConfigOptionBase { @@ -945,6 +977,52 @@ public: }; +class ButtonOption : public ConfigOptionBase +{ +public: + void(*_func)(); + + ButtonOption(LPCWSTR friendlyName, LPCWSTR description, void(*func)()) + { + _friendlyName = friendlyName; + _description = description; + _func = func; + } + + virtual int AddToPanel(Panel^ panel, unsigned int left, unsigned int top, ToolTip^ tooltip) + { + Button^ button = gcnew Button(); + + button->Text = gcnew String(_friendlyName); + button->Left = left; + button->Top = top; + button->AutoSize = true; + button->FlatStyle = System::Windows::Forms::FlatStyle::Flat; + + Form^ RootForm = panel->FindForm(); + float ScaleWidth = 1.0f; + float ScaleHeight = 1.0f; + if (RootForm) + { + Drawing::SizeF CurrentScaleSize = RootForm->CurrentAutoScaleDimensions; + ScaleWidth = CurrentScaleSize.Width / BaseScaleSize; + ScaleHeight = CurrentScaleSize.Height / BaseScaleSize; + } + button->Scale(ScaleWidth, ScaleHeight); + + tooltip->SetToolTip(button, gcnew String(_description)); + + CustomFuncHandler^ funchandler = gcnew CustomFuncHandler(_func); + button->Click += gcnew System::EventHandler(funchandler, &CustomFuncHandler::RunFunc); + + panel->Controls->Add(button); + + int ControlHeight = button->Height / ScaleHeight; + return ControlHeight + ControlSpacing; + } +}; + + class PluginOption : public ConfigOptionBase { public: diff --git a/source-code/source/plugins/Launcher/PluginConfig.h b/source-code/source/plugins/Launcher/PluginConfig.h index d365afe..b2d3e35 100644 --- a/source-code/source/plugins/Launcher/PluginConfig.h +++ b/source-code/source/plugins/Launcher/PluginConfig.h @@ -14,6 +14,8 @@ namespace PluginConfig PluginConfigDropdownNumberData* ddNumberData = (PluginConfigDropdownNumberData*)(cfg.data); PluginConfigResolutionData* resData = (PluginConfigResolutionData*)(cfg.data); PluginConfigGroupData* groupData = (PluginConfigGroupData*)(cfg.data); + PluginConfigButtonData* btnData = (PluginConfigButtonData*)(cfg.data); + PluginConfigSpacerData* spacerData = (PluginConfigSpacerData*)(cfg.data); switch (cfg.cfgType) { @@ -35,6 +37,10 @@ namespace PluginConfig return new OptionMetaGroupStart(groupData->name, groupData->height); case CONFIG_GROUP_END: return new OptionMetaGroupEnd(); + case CONFIG_BUTTON: + return new ButtonOption(btnData->friendlyName, btnData->description, btnData->func); + case CONFIG_SPACER: + return new OptionMetaSpacer(spacerData->height); default: return new ConfigOptionBase(); } diff --git a/source-code/source/plugins/Launcher/PluginConfigApi.h b/source-code/source/plugins/Launcher/PluginConfigApi.h index f053d5c..d0ffd94 100644 --- a/source-code/source/plugins/Launcher/PluginConfigApi.h +++ b/source-code/source/plugins/Launcher/PluginConfigApi.h @@ -56,7 +56,9 @@ namespace PluginConfig CONFIG_DROPDOWN_NUMBER, CONFIG_RESOLUTION, CONFIG_GROUP_START, - CONFIG_GROUP_END + CONFIG_GROUP_END, + CONFIG_BUTTON, + CONFIG_SPACER }; struct PluginConfigBooleanData { @@ -141,6 +143,16 @@ namespace PluginConfig int height; }; + struct PluginConfigButtonData { + LPCWSTR friendlyName; + LPCWSTR description; + void(*func)(); + }; + + struct PluginConfigSpacerData { + int height; + }; + struct PluginConfigOption { ConfigType cfgType; From 6b9921d95da2a439a1fa8cd8f1aea1668a6bd39f Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Tue, 27 Aug 2019 12:22:27 +1000 Subject: [PATCH 16/19] launcher: fix plugin config tooltips --- source-code/source/plugins/Launcher/ConfigOption.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source-code/source/plugins/Launcher/ConfigOption.h b/source-code/source/plugins/Launcher/ConfigOption.h index ea48108..47888f2 100644 --- a/source-code/source/plugins/Launcher/ConfigOption.h +++ b/source-code/source/plugins/Launcher/ConfigOption.h @@ -1085,7 +1085,8 @@ public: if (_configopts.size() > 0) { - Panel^ configPanel = MakePanel((Col2Left + Col2Width + 64), 250, _configopts, tooltip, hasChanged); + ToolTip^ paneltooltip = gcnew ToolTip(); + Panel^ configPanel = MakePanel((Col2Left + Col2Width + 64), 250, _configopts, paneltooltip, hasChanged); configPanel->Scale(ScaleWidth, ScaleHeight); PluginConfigHandler^ confighandler = gcnew PluginConfigHandler(configPanel, gcnew String(_friendlyName) + " Options"); button->Click += gcnew System::EventHandler(confighandler, &PluginConfigHandler::OpenForm); From 81ea9d0000b813361c28227a1b21b9fe966229b3 Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Tue, 27 Aug 2019 16:55:23 +1000 Subject: [PATCH 17/19] make dnsapi read plugin config + a bug fix for launcher --- source-code/source/PD-Loader/dllmain.cpp | 3 ++- source-code/source/plugins/Launcher/framework.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source-code/source/PD-Loader/dllmain.cpp b/source-code/source/PD-Loader/dllmain.cpp index e26843a..d6a4bba 100644 --- a/source-code/source/PD-Loader/dllmain.cpp +++ b/source-code/source/PD-Loader/dllmain.cpp @@ -158,7 +158,8 @@ void FindFiles(WIN32_FIND_DATAW* fd) if (fd->cFileName[pos - 4] == '.' && (fd->cFileName[pos - 3] == 'd' || fd->cFileName[pos - 3] == 'D') && (fd->cFileName[pos - 2] == 'v' || fd->cFileName[pos - 2] == 'V') && - (fd->cFileName[pos - 1] == 'a' || fd->cFileName[pos - 1] == 'A')) + (fd->cFileName[pos - 1] == 'a' || fd->cFileName[pos - 1] == 'A') && + GetPrivateProfileIntW(L"plugins", fd->cFileName, TRUE, iniPaths)) { auto path = dir + L'\\' + fd->cFileName; diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index c5688d5..d5dfad4 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -295,7 +295,7 @@ std::vector LoadPlugins() (ffd.cFileName[pos - 1] == 'a' || ffd.cFileName[pos - 1] == 'A')) { PluginInfo thisplugin; - thisplugin.handle = LoadLibraryW(ffd.cFileName); + thisplugin.handle = LoadLibraryW((PLUGINS_DIR + L"\\" + ffd.cFileName).c_str()); thisplugin.filename = ffd.cFileName; if (thisplugin.handle == NULL) From a19d7eea95720973f010a0843320c0b6d7c648d3 Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Wed, 28 Aug 2019 01:02:57 +1000 Subject: [PATCH 18/19] add act_toggle config to playerdata --- source-code/data/plugins/playerdata.ini | 3 +++ source-code/source/plugins/Launcher/framework.h | 1 + .../source/plugins/TLAC/Components/CustomPlayerData.h | 1 + .../source/plugins/TLAC/Components/PlayerDataManager.cpp | 8 ++++---- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/source-code/data/plugins/playerdata.ini b/source-code/data/plugins/playerdata.ini index 41bb174..53a22b1 100644 --- a/source-code/data/plugins/playerdata.ini +++ b/source-code/data/plugins/playerdata.ini @@ -20,6 +20,9 @@ slide_se_equip = -1 # IDs defined in rom/gm_chainslide_se_tbl.farc/gm_chainslide_se_id.bin chainslide_se_equip = -1 +# Enable button/slider sounds +act_toggle = true + # Show clear borders on Progress Bar for: # Great border_great = true diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index d5dfad4..d166c1f 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -184,6 +184,7 @@ ConfigOptionBase* playerdataArray[] = { new NumericOption(L"btn_se_equip", PLAYERDATA_SECTION, PLAYERDATA_FILE, L"Button Sound:", L"Sets the sound effect for buttons.\n-1 = song default", -1, -1, INT_MAX), new NumericOption(L"slide_se_equip", PLAYERDATA_SECTION, PLAYERDATA_FILE, L"Slide Sound:", L"Sets the sound effect for slides.\n-1 = song default", -1, -1, INT_MAX), new NumericOption(L"chainslide_se_equip", PLAYERDATA_SECTION, PLAYERDATA_FILE, L"Chainslide Sound:", L"Sets the sound effect for chain slides.\n-1 = song default", -1, -1, INT_MAX), + new BooleanOption(L"act_toggle", PLAYERDATA_SECTION, PLAYERDATA_FILE, L"Button SE", L"Enables button/slider sounds.", true, true), new BooleanOption(L"border_great", PLAYERDATA_SECTION, PLAYERDATA_FILE, L"Clear Border (Great)", L"Shows the clear border for a great rating on the progress bar.", true, true), new BooleanOption(L"border_excellent", PLAYERDATA_SECTION, PLAYERDATA_FILE, L"Clear Border (Excellent)", L"Shows the clear border for an excellent rating on the progress bar.", true, true), diff --git a/source-code/source/plugins/TLAC/Components/CustomPlayerData.h b/source-code/source/plugins/TLAC/Components/CustomPlayerData.h index c8a156e..cd5efbf 100644 --- a/source-code/source/plugins/TLAC/Components/CustomPlayerData.h +++ b/source-code/source/plugins/TLAC/Components/CustomPlayerData.h @@ -16,5 +16,6 @@ namespace TLAC::Components bool ShowExcellentClearBorder; bool UseCard; bool GameModifierOptions; + bool ActionSE; }; } diff --git a/source-code/source/plugins/TLAC/Components/PlayerDataManager.cpp b/source-code/source/plugins/TLAC/Components/PlayerDataManager.cpp index 5154382..0ed96e8 100644 --- a/source-code/source/plugins/TLAC/Components/PlayerDataManager.cpp +++ b/source-code/source/plugins/TLAC/Components/PlayerDataManager.cpp @@ -237,6 +237,7 @@ namespace TLAC::Components customPlayerData->ShowGreatClearBorder = config.GetBooleanValue("border_great"); customPlayerData->UseCard = config.GetBooleanValue("use_card"); customPlayerData->GameModifierOptions = config.GetBooleanValue("gamemode_options"); + customPlayerData->ActionSE = config.GetBooleanValue("act_toggle"); moduleCardWorkaround = config.GetBooleanValue("module_card_workaround"); if (moduleCardWorkaround) { @@ -313,15 +314,14 @@ namespace TLAC::Components setIfNotEqual(&playerData->btn_se_equip, customPlayerData->BtnSeEquip, -1); setIfNotEqual(&playerData->slide_se_equip, customPlayerData->SlideSeEquip, -1); setIfNotEqual(&playerData->chainslide_se_equip, customPlayerData->ChainslideSeEquip, -1); + setIfNotEqual(&playerData->act_toggle, customPlayerData->ActionSE, 1); // Display clear borders on the progress bar *(byte*)(PLAYER_DATA_ADDRESS + 0xD94) = (customPlayerData->ShowExcellentClearBorder << 1) | (customPlayerData->ShowGreatClearBorder); - if (customPlayerData->UseCard) - playerData->use_card = 1; // required to allow for module selection + playerData->use_card = customPlayerData->UseCard; // required to allow for module selection - if (customPlayerData->GameModifierOptions) - playerData->game_opts = 1; // hi-speed, etc.. + playerData->game_opts = customPlayerData->GameModifierOptions; // hi-speed, etc.. memset((void*)MODULE_TABLE_START, 0xFF, 128); memset((void*)ITEM_TABLE_START, 0xFF, 128); From e2d276253e23bfab930ef8643f0109d25c16848c Mon Sep 17 00:00:00 2001 From: somewhatlurker <52014015+somewhatlurker@users.noreply.github.com> Date: Wed, 28 Aug 2019 01:08:38 +1000 Subject: [PATCH 19/19] launcher: bugfix --- source-code/source/plugins/Launcher/framework.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source-code/source/plugins/Launcher/framework.h b/source-code/source/plugins/Launcher/framework.h index d166c1f..1579fc2 100644 --- a/source-code/source/plugins/Launcher/framework.h +++ b/source-code/source/plugins/Launcher/framework.h @@ -319,7 +319,8 @@ std::vector LoadPlugins() if (optsFunc != NULL) thisplugin.configopts = PluginConfig::GetConfigOptionVec(optsFunc()); - FreeLibrary(thisplugin.handle); + // sometimes this might screw with custom button config, so let's just not free stuff + // FreeLibrary(thisplugin.handle); outvec.push_back(thisplugin); }