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