Synced changes for X Pack specific stuff between repos №2

This commit is contained in:
korenkonder
2025-01-06 21:18:15 +03:00
parent 802f992c4a
commit e0b5ffd9a2
11 changed files with 516 additions and 180 deletions
+60
View File
@@ -11,6 +11,7 @@
#include <intrin.h>
#include <knownfolders.h>
#include <shlobj_core.h>
#include <PluginConfigApi/PluginConfigApi.h>
size_t diva_handle;
size_t glut_handle;
@@ -19,6 +20,13 @@ size_t dll_handle;
bool cpu_caps_aes_ni;
bool cpu_caps_f16c;
bool config_reflect_full = true;
int32_t config_reflect_res_scale = 100;
static std::wstring GetDirPath();
std::wstring CONFIG_FILE_STRING = GetDirPath() + L"\\plugins\\DivaGL.ini";
LPCWSTR CONFIG_FILE = CONFIG_FILE_STRING.c_str();
void FASTCALL divagl_main() {
int32_t cpuid_data[4] = {};
@@ -47,6 +55,10 @@ void FASTCALL divagl_main() {
bool APIENTRY DllMain(HMODULE handle, DWORD ul_reason_for_call, LPVOID lpReserved) {
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
config_reflect_full = GetPrivateProfileIntW(L"general", L"reflect_full", 0, CONFIG_FILE) > 0 ? true : false;
config_reflect_res_scale = GetPrivateProfileIntW(L"general", L"reflect_res_scale", 1, CONFIG_FILE);
config_reflect_res_scale = config_reflect_res_scale ? clamp_def(config_reflect_res_scale, 25, 100) : 100;
dll_handle = (size_t)handle;
printf_divagl("Current version - v0.7.2.2");
printf_divagl("Attach");
@@ -67,3 +79,51 @@ extern "C" __declspec(dllexport) LPCWSTR GetPluginDescription(void) {
extern "C" __declspec(dllexport) LPCWSTR GetBuildDate(void) {
return L"v0.7.2.2";
}
static std::wstring GetDirPath() {
wchar_t dll_file_path[MAX_PATH];
GetModuleFileNameW((HMODULE)dll_handle, dll_file_path, MAX_PATH);
wchar_t* dll_file_name = wcsrchr(dll_file_path, '\\');
if (!dll_file_name)
dll_file_name = wcsrchr(dll_file_path, '/');
if (!dll_file_name)
return L"";
WCHAR buffer[MAX_PATH];
GetModuleFileNameW(NULL, buffer, MAX_PATH);
return std::wstring(dll_file_path, dll_file_name - dll_file_path);
}
PluginConfig::PluginConfigOption config[] = {
{
PluginConfig::CONFIG_BOOLEAN,
new PluginConfig::PluginConfigBooleanData {
L"reflect_full",
L"general",
CONFIG_FILE,
L"Full Reflect",
L"Enables Full Reflect for PVs from X Pack (MPFX).",
false,
false,
}
},
{
PluginConfig::CONFIG_NUMERIC,
new PluginConfig::PluginConfigNumericData {
L"reflect_res_scale",
L"general",
CONFIG_FILE,
L"Reflect Resolution Scale",
L"Sets resolution for Full Reflect as a percentage relative to the Internal Resolution values.\nImportant note! Scale doesn't apply can't go lower than 256x144 or Internal Resolution.",
100,
25,
100,
}
},
};
extern "C" __declspec(dllexport) PluginConfig::PluginConfigArray GetPluginOptions(void) {
return PluginConfig::PluginConfigArray{ _countof(config), config };
}