Merge branch 'master' of somewhatlurker/PD-Loader into master
This commit is contained in:
@@ -19,6 +19,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DivaSound", "source\plugins
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DivaMovie", "source\plugins\DivaMovie\DivaMovie.vcxproj", "{1994C586-F73B-4EF2-BA3E-2A0FC3034B1A}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ShaderPatch", "source\plugins\ShaderPatch\ShaderPatch.vcxproj", "{C07E495E-A16F-48FA-80E4-0296B5234F0B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
@@ -87,6 +89,14 @@ Global
|
||||
{1994C586-F73B-4EF2-BA3E-2A0FC3034B1A}.Release|x64.ActiveCfg = Release|x64
|
||||
{1994C586-F73B-4EF2-BA3E-2A0FC3034B1A}.Release|x64.Build.0 = Release|x64
|
||||
{1994C586-F73B-4EF2-BA3E-2A0FC3034B1A}.Release|x86.ActiveCfg = Release|x64
|
||||
{C07E495E-A16F-48FA-80E4-0296B5234F0B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{C07E495E-A16F-48FA-80E4-0296B5234F0B}.Debug|x64.Build.0 = Debug|x64
|
||||
{C07E495E-A16F-48FA-80E4-0296B5234F0B}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{C07E495E-A16F-48FA-80E4-0296B5234F0B}.Debug|x86.Build.0 = Debug|Win32
|
||||
{C07E495E-A16F-48FA-80E4-0296B5234F0B}.Release|x64.ActiveCfg = Release|x64
|
||||
{C07E495E-A16F-48FA-80E4-0296B5234F0B}.Release|x64.Build.0 = Release|x64
|
||||
{C07E495E-A16F-48FA-80E4-0296B5234F0B}.Release|x86.ActiveCfg = Release|Win32
|
||||
{C07E495E-A16F-48FA-80E4-0296B5234F0B}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
[Config]
|
||||
# Patches to remove glitching with modern GPUs.
|
||||
# Appropriate patches will automatically be selected based on your GPU.
|
||||
Compat=1
|
||||
|
||||
# Lyb's toon shader improvements (24 sept 2019)
|
||||
# Toon: Adjusts toon shader lighting
|
||||
Toon=0
|
||||
# Specular Multiplier
|
||||
Toon_Val1=0.9
|
||||
# Specular Offset
|
||||
Toon_Val2=-0.5
|
||||
|
||||
# Lyb's toon shader improvements (24 sept 2019)
|
||||
# Toon_Eyes: Adjusts toon shader eyes
|
||||
Toon_Eyes=0
|
||||
|
||||
# Lyb's toon shader improvements (24 sept 2019)
|
||||
# Toon_Hair: Adjusts toon shader hair
|
||||
Toon_Hair=0
|
||||
# Diffuse Brightness
|
||||
Toon_Hair_Val1=1.25
|
||||
|
||||
# Lyb's toon shader improvements (24 sept 2019)
|
||||
# Toon_Lines: Adjusts toon shader outlines
|
||||
Toon_Lines=0
|
||||
# ???
|
||||
Toon_Lines_Val1=0.75
|
||||
# Thickness Multiplier(?)
|
||||
Toon_Lines_Val2=0.75
|
||||
# Thickness Offset(?)
|
||||
Toon_Lines_Val3=0.75
|
||||
|
||||
# Debug patches:
|
||||
# Nametags
|
||||
# Adds comments with the shader file name to the shader text. Useful for debugging issues.
|
||||
# `nametags_val1` and `nametags_val2` are a dirty hack to hide this in launcher (options ending in _val. must belong to a parent to be displayed)
|
||||
# `nametags_val2` is a bit faster, but the tags are placed at the end of the file and you may not like this
|
||||
Nametags_Val1=0
|
||||
Nametags_Val2=0
|
||||
|
||||
[Patches]
|
||||
# Compatibility patches:
|
||||
# Star Story (and etc.) stage corruption (Maxwell+)
|
||||
blinn_per_vert\.0010010[23]00[01]\.fp=arch:GP,TU,GV,GM||cfg:compat||from:TEX tex_col, a_tex_color0, texture\[0\], 2D; ALIAS||to:TEX tex_col, a_tex_color0, texture[0], 2D; MUL tex_col, 1, tex_col; ALIAS
|
||||
# Turing shading lines
|
||||
esm_gauss\.0\.fp=arch:TU||cfg:compat||from:RCP sum.y, sum.y;(\r?\n) MUL||to:RCP sum.y, sum.y; ADD sum.x, sum.x, 0.000300;$1 MUL
|
||||
# Turing NPR cloth noise
|
||||
cloth_npr1\.fp=arch:TU||cfg:compat||from:SSG _tmp0.yw, ybr.xxzz;||to:TEMP _tmpForSSG; SGE _tmpForSSG.xz, ybr.xxzz, 0; SUB _tmpForSSG.xz, _tmpForSSG.xxzz, 1; SGT _tmpForSSG.yw, ybr.xxzz, 0; ADD _tmp0.yw, _tmpForSSG.xxzz, _tmpForSSG.yyww;
|
||||
|
||||
# Lyb's toon shader improvements:
|
||||
.*cloth_npr.*=cfg:toon||from:MAD tmp.y, lc.z, 1.2, -0.5;||to:MAD tmp.y, lc.z, <val1>, <val2>;
|
||||
.*skin_default.*=cfg:toon||from:MAD diff.xyz, spec, spec_ratio, diff;||to:
|
||||
.*eye.*=cfg:toon_eyes||from:ADD o_color_f0.w, diff.x, diff.y;||to:
|
||||
.*hair_npr1.*=cfg:toon_hair||from:MUL spec.x, tmp.x, 0.7;||to:MUL spec.x, tmp.x, 0.7; MUL diff, diff, <val1>;
|
||||
.*tone_map_npr1.*=cfg:toon_lines||from:MUL density.y, density.y, 0.25;||to:MUL density.y, density.y, <val1>;
|
||||
.*tone_map_npr1.*=cfg:toon_lines||from:MAD density.w, density.x, 0.7, 0.25;||to:MAD density.w, density.x, <val2>, <val3>;
|
||||
|
||||
# Debug patches:
|
||||
# Nametags
|
||||
# Adds comments with the shader file name to the shader text. Useful for debugging issues
|
||||
# `nametags_val1` and `nametags_val2` are a dirty hack to hide this in launcher (options ending in _val. must belong to a parent to be displayed)
|
||||
# `nametags_val2` is a bit faster, but the tags are placed at the end of the file and you may not like this
|
||||
# Notes:
|
||||
# * `(\r?\n)` is used to capture the line ending type used and ensure we're at the start of a line
|
||||
# * `[^!]` ensures the comment is inserted after all start program lines (not sure if this even matters)
|
||||
# * `[\s\S]` matches all characters *including* new lines
|
||||
.*=cfg:nametags_val1||from:(\r?\n)([^!][\s\S]*)||to:$1#<fname>$1$2
|
||||
.*=cfg:nametags_val2||from:[\s\S]*?(\r?\n)[\s\S]*||to:$&$1#<fname>
|
||||
+8
@@ -165,4 +165,12 @@ namespace PluginConfig
|
||||
PluginConfigOption* options;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
// note: this is actually the build date of PluginConfigApi -- make sure this isn't cached for CI
|
||||
extern "C" __declspec(dllexport) LPCWSTR GetBuildDate(void)
|
||||
{
|
||||
WCHAR utf16buf[128];
|
||||
MultiByteToWideChar(CP_UTF8, 0, __DATE__, -1, utf16buf, 128);
|
||||
return _wcsdup(utf16buf);
|
||||
}
|
||||
}
|
||||
@@ -43,13 +43,9 @@
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);detours/include;miniaudio;bassasio</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;detours/lib;bassasio</LibraryPath>
|
||||
<TargetExt>.dva</TargetExt>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);detours/include;miniaudio;bassasio</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;detours/lib;bassasio</LibraryPath>
|
||||
<TargetExt>.dva</TargetExt>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
@@ -57,9 +53,11 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\..\..\dependencies\PluginConfigApi;..\..\..\dependencies\detours\include;miniaudio;bassasio</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>detours.lib;syelog.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>..\..\..\dependencies\detours\lib;bassasio</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -70,11 +68,13 @@
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalIncludeDirectories>..\..\..\dependencies\PluginConfigApi;..\..\..\dependencies\detours\include;miniaudio;bassasio</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>detours.lib;syelog.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>..\..\..\dependencies\detours\lib;bassasio</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
@@ -82,7 +82,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\framework.h" />
|
||||
<ClInclude Include="src\PluginConfigApi.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
||||
@@ -23,8 +23,5 @@
|
||||
<ClInclude Include="src\framework.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\PluginConfigApi.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,27 +0,0 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Common version parameters.
|
||||
//
|
||||
// Microsoft Research Detours Package, Version 4.0.1
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
|
||||
#define _USING_V110_SDK71_ 1
|
||||
#include "winver.h"
|
||||
#if 0
|
||||
#include <windows.h>
|
||||
#include <detours.h>
|
||||
#else
|
||||
#ifndef DETOURS_STRINGIFY
|
||||
#define DETOURS_STRINGIFY(x) DETOURS_STRINGIFY_(x)
|
||||
#define DETOURS_STRINGIFY_(x) #x
|
||||
#endif
|
||||
|
||||
#define VER_FILEFLAGSMASK 0x3fL
|
||||
#define VER_FILEFLAGS 0x0L
|
||||
#define VER_FILEOS 0x00040004L
|
||||
#define VER_FILETYPE 0x00000002L
|
||||
#define VER_FILESUBTYPE 0x00000000L
|
||||
#endif
|
||||
#define VER_DETOURS_BITS DETOUR_STRINGIFY(DETOURS_BITS)
|
||||
@@ -1,89 +0,0 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Detours Test Program (syelog.h of syelog.lib)
|
||||
//
|
||||
// Microsoft Research Detours Package
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
#pragma once
|
||||
#ifndef _SYELOGD_H_
|
||||
#define _SYELOGD_H_
|
||||
#include <stdarg.h>
|
||||
|
||||
#pragma pack(push, 1)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4200)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
#define SYELOG_PIPE_NAMEA "\\\\.\\pipe\\syelog"
|
||||
#define SYELOG_PIPE_NAMEW L"\\\\.\\pipe\\syelog"
|
||||
#ifdef UNICODE
|
||||
#define SYELOG_PIPE_NAME SYELOG_PIPE_NAMEW
|
||||
#else
|
||||
#define SYELOG_PIPE_NAME SYELOG_PIPE_NAMEA
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
#define SYELOG_MAXIMUM_MESSAGE 4086 // 4096 - sizeof(header stuff)
|
||||
|
||||
typedef struct _SYELOG_MESSAGE
|
||||
{
|
||||
USHORT nBytes;
|
||||
BYTE nFacility;
|
||||
BYTE nSeverity;
|
||||
DWORD nProcessId;
|
||||
FILETIME ftOccurance;
|
||||
BOOL fTerminate;
|
||||
CHAR szMessage[SYELOG_MAXIMUM_MESSAGE];
|
||||
} SYELOG_MESSAGE, *PSYELOG_MESSAGE;
|
||||
|
||||
|
||||
// Facility Codes.
|
||||
//
|
||||
#define SYELOG_FACILITY_KERNEL 0x10 // OS Kernel
|
||||
#define SYELOG_FACILITY_SECURITY 0x20 // OS Security
|
||||
#define SYELOG_FACILITY_LOGGING 0x30 // OS Logging-internal
|
||||
#define SYELOG_FACILITY_SERVICE 0x40 // User-mode system daemon
|
||||
#define SYELOG_FACILITY_APPLICATION 0x50 // User-mode application
|
||||
#define SYELOG_FACILITY_USER 0x60 // User self-generated.
|
||||
#define SYELOG_FACILITY_LOCAL0 0x70 // Locally defined.
|
||||
#define SYELOG_FACILITY_LOCAL1 0x71 // Locally defined.
|
||||
#define SYELOG_FACILITY_LOCAL2 0x72 // Locally defined.
|
||||
#define SYELOG_FACILITY_LOCAL3 0x73 // Locally defined.
|
||||
#define SYELOG_FACILITY_LOCAL4 0x74 // Locally defined.
|
||||
#define SYELOG_FACILITY_LOCAL5 0x75 // Locally defined.
|
||||
#define SYELOG_FACILITY_LOCAL6 0x76 // Locally defined.
|
||||
#define SYELOG_FACILITY_LOCAL7 0x77 // Locally defined.
|
||||
#define SYELOG_FACILITY_LOCAL8 0x78 // Locally defined.
|
||||
#define SYELOG_FACILITY_LOCAL9 0x79 // Locally defined.
|
||||
|
||||
// Severity Codes.
|
||||
//
|
||||
#define SYELOG_SEVERITY_FATAL 0x00 // System is dead.
|
||||
#define SYELOG_SEVERITY_ALERT 0x10 // Take action immediately.
|
||||
#define SYELOG_SEVERITY_CRITICAL 0x20 // Critical condition.
|
||||
#define SYELOG_SEVERITY_ERROR 0x30 // Error
|
||||
#define SYELOG_SEVERITY_WARNING 0x40 // Warning
|
||||
#define SYELOG_SEVERITY_NOTICE 0x50 // Significant condition.
|
||||
#define SYELOG_SEVERITY_INFORMATION 0x60 // Informational
|
||||
#define SYELOG_SEVERITY_AUDIT_FAIL 0x66 // Audit Failed
|
||||
#define SYELOG_SEVERITY_AUDIT_PASS 0x67 // Audit Succeeeded
|
||||
#define SYELOG_SEVERITY_DEBUG 0x70 // Debugging
|
||||
|
||||
// Logging Functions.
|
||||
//
|
||||
VOID SyelogOpen(PCSTR pszIdentifier, BYTE nFacility);
|
||||
VOID Syelog(BYTE nSeverity, PCSTR pszMsgf, ...);
|
||||
VOID SyelogV(BYTE nSeverity, PCSTR pszMsgf, va_list args);
|
||||
VOID SyelogClose(BOOL fTerminate);
|
||||
|
||||
#pragma warning(pop)
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif // _SYELOGD_H_
|
||||
//
|
||||
///////////////////////////////////////////////////////////////// End of File.
|
||||
Binary file not shown.
Binary file not shown.
@@ -151,7 +151,7 @@ ref class PluginConfigHandler
|
||||
public:
|
||||
Form^ form;
|
||||
|
||||
PluginConfigHandler(Panel^ optspanel, String^ title)
|
||||
PluginConfigHandler(Panel^ optspanel, String^ title, float btnScaleSize)
|
||||
{
|
||||
form = gcnew Form();
|
||||
|
||||
@@ -168,10 +168,13 @@ public:
|
||||
form->BackColor = Drawing::Color::FromArgb(64, 64, 64);
|
||||
form->ForeColor = Drawing::Color::White;
|
||||
|
||||
form->Font = optspanel->Font;
|
||||
|
||||
optspanel->Left = 0;
|
||||
optspanel->Top = 0;
|
||||
|
||||
Button^ OkBtn = gcnew Button();
|
||||
OkBtn->Scale(btnScaleSize);
|
||||
OkBtn->Text = L"OK";
|
||||
OkBtn->Left = 4;
|
||||
OkBtn->Top = optspanel->Bottom + 4;
|
||||
@@ -517,9 +520,9 @@ public:
|
||||
textbox->Scale(ScaleWidth, ScaleHeight);
|
||||
|
||||
// disable editing for utf8 mode because the ANSI hack used may not work correctly
|
||||
if (_useUtf8) {
|
||||
textbox->Enabled = false;
|
||||
}
|
||||
//if (_useUtf8) {
|
||||
// textbox->Enabled = false;
|
||||
//}
|
||||
|
||||
tooltip->SetToolTip(label, gcnew String(_description));
|
||||
tooltip->SetToolTip(textbox, gcnew String(_description));
|
||||
@@ -540,8 +543,8 @@ public:
|
||||
virtual void SaveOption()
|
||||
{
|
||||
// disable saving for utf8 mode because the ANSI hack used may not work correctly
|
||||
if (_useUtf8)
|
||||
return;
|
||||
//if (_useUtf8)
|
||||
// return;
|
||||
|
||||
System::String^ tempSysStr;
|
||||
std::wstring tempWStr;
|
||||
@@ -714,10 +717,10 @@ public:
|
||||
combobox->Scale(ScaleWidth, ScaleHeight);
|
||||
|
||||
// disable editing for utf8 mode because the ANSI hack used may not work correctly
|
||||
if (_useUtf8) {
|
||||
label->Enabled = false;
|
||||
combobox->Enabled = false;
|
||||
}
|
||||
//if (_useUtf8) {
|
||||
// label->Enabled = false;
|
||||
// combobox->Enabled = false;
|
||||
//}
|
||||
|
||||
tooltip->SetToolTip(label, gcnew String(_description));
|
||||
tooltip->SetToolTip(combobox, gcnew String(_description));
|
||||
@@ -741,8 +744,8 @@ public:
|
||||
virtual void SaveOption()
|
||||
{
|
||||
// disable saving for utf8 mode because the ANSI hack used may not work correctly
|
||||
if (_useUtf8)
|
||||
return;
|
||||
//if (_useUtf8)
|
||||
// return;
|
||||
|
||||
System::String^ tempSysStr;
|
||||
std::wstring tempWStr;
|
||||
@@ -1088,9 +1091,11 @@ public:
|
||||
if (_configopts.size() > 0)
|
||||
{
|
||||
ToolTip^ paneltooltip = gcnew ToolTip();
|
||||
Panel^ configPanel = MakePanel((Col2Left + Col2Width + 64), 250, _configopts, paneltooltip, hasChanged);
|
||||
Panel^ configPanel = MakePanel((Col2Left + Col2Width + 76), 250, _configopts, paneltooltip, hasChanged);
|
||||
configPanel->Scale(ScaleWidth, ScaleHeight);
|
||||
PluginConfigHandler^ confighandler = gcnew PluginConfigHandler(configPanel, gcnew String(_friendlyName) + " Options");
|
||||
if (RootForm)
|
||||
configPanel->Font = RootForm->Font;
|
||||
PluginConfigHandler^ confighandler = gcnew PluginConfigHandler(configPanel, gcnew String(_friendlyName) + " Options", ScaleHeight);
|
||||
button->Click += gcnew System::EventHandler(confighandler, &PluginConfigHandler::OpenForm);
|
||||
|
||||
panel->Controls->Add(button);
|
||||
@@ -1143,11 +1148,12 @@ Panel^ MakePanel(int width, int height, std::vector<ConfigOptionBase*> &cfg, Too
|
||||
{
|
||||
OptionMetaGroupStart* groupData = (OptionMetaGroupStart*)(cfg[i]);
|
||||
GroupBox^ groupbox = gcnew GroupBox();
|
||||
groupbox->Width = width - (ScaleWidth * 8);
|
||||
groupbox->Height = ScaleHeight * groupData->_height;
|
||||
groupbox->Width = width - (ScaleWidth * 28);
|
||||
groupbox->Height = ScaleHeight * (groupData->_height);
|
||||
groupbox->Left = ScaleWidth * 4;
|
||||
groupbox->Top = ScaleHeight * curY;
|
||||
groupbox->Text = gcnew String(groupData->_friendlyName);
|
||||
groupbox->ForeColor = Drawing::Color::White;
|
||||
|
||||
// find the end of this group by simple iteration keeping track of indent level
|
||||
int level = 1;
|
||||
@@ -1163,9 +1169,9 @@ Panel^ MakePanel(int width, int height, std::vector<ConfigOptionBase*> &cfg, Too
|
||||
break;
|
||||
}
|
||||
|
||||
Panel^ groupPanel = MakePanel(groupbox->Width - (ScaleWidth * 8), groupbox->Height - (ScaleHeight * 10), std::vector<ConfigOptionBase*>(&(cfg[i + 1]), &(cfg[endidx])), tooltip, hasChanged);
|
||||
groupPanel->Left = ScaleWidth * 12;
|
||||
groupPanel->Top = ScaleHeight * (curY + 8);
|
||||
Panel^ groupPanel = MakePanel(groupbox->Width - (ScaleWidth * 12), groupbox->Height - (ScaleHeight * 20), std::vector<ConfigOptionBase*>(&(cfg[i + 1]), &(cfg[endidx])), tooltip, hasChanged);
|
||||
groupPanel->Left = ScaleWidth * 2;
|
||||
groupPanel->Top = ScaleHeight * 14;
|
||||
|
||||
groupbox->Controls->Add(groupPanel);
|
||||
outpanel->Controls->Add(groupbox);
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\..\..\dependencies\detours\include;..\..\..\dependencies\freeglut\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\..\dependencies\PluginConfigApi;..\..\..\dependencies\detours\include;..\..\..\dependencies\freeglut\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
@@ -142,7 +142,7 @@
|
||||
</PrecompiledHeaderFile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..\..\..\dependencies\detours\include;..\..\..\dependencies\freeglut\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\..\dependencies\PluginConfigApi;..\..\..\dependencies\detours\include;..\..\..\dependencies\freeglut\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
@@ -168,7 +168,6 @@
|
||||
<ClInclude Include="ConfigOption.h" />
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="PluginConfig.h" />
|
||||
<ClInclude Include="PluginConfigApi.h" />
|
||||
<ClInclude Include="SkinnedMessageBox.h" />
|
||||
<ClInclude Include="TabPadding.h" />
|
||||
<ClInclude Include="ui.h">
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace PluginConfig
|
||||
for (int i = 0; i < in.len; i++)
|
||||
{
|
||||
// basic check for validity
|
||||
if (in.options[i].data == nullptr)
|
||||
if (in.options[i].data == nullptr && in.options[i].cfgType != CONFIG_GROUP_END)
|
||||
break;
|
||||
|
||||
outvec.push_back(GetConfigOption(in.options[i]));
|
||||
|
||||
@@ -1,168 +0,0 @@
|
||||
#pragma once
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#include <windows.h>
|
||||
#include <vector>
|
||||
|
||||
// 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
|
||||
{
|
||||
#pragma pack(push, 1)
|
||||
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,
|
||||
CONFIG_BUTTON,
|
||||
CONFIG_SPACER
|
||||
};
|
||||
|
||||
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<LPCWSTR> valueStrings;
|
||||
};
|
||||
|
||||
struct PluginConfigDropdownTextData {
|
||||
LPCWSTR iniVarName;
|
||||
LPCWSTR iniSectionName;
|
||||
LPCWSTR iniFilePath;
|
||||
LPCWSTR friendlyName;
|
||||
LPCWSTR description;
|
||||
LPCWSTR defaultVal;
|
||||
std::vector<LPCWSTR> valueStrings;
|
||||
bool editable;
|
||||
bool useUtf8;
|
||||
};
|
||||
|
||||
struct PluginConfigDropdownNumberData {
|
||||
LPCWSTR iniVarName;
|
||||
LPCWSTR iniSectionName;
|
||||
LPCWSTR iniFilePath;
|
||||
LPCWSTR friendlyName;
|
||||
LPCWSTR description;
|
||||
int defaultVal;
|
||||
std::vector<int> valueInts;
|
||||
bool editable;
|
||||
};
|
||||
|
||||
struct PluginConfigResolutionData {
|
||||
LPCWSTR iniVarName;
|
||||
LPCWSTR iniVarName2;
|
||||
LPCWSTR iniSectionName;
|
||||
LPCWSTR iniFilePath;
|
||||
LPCWSTR friendlyName;
|
||||
LPCWSTR description;
|
||||
resolution defaultVal;
|
||||
std::vector<resolution> valueResolutions;
|
||||
bool editable;
|
||||
};
|
||||
|
||||
struct PluginConfigGroupData
|
||||
{
|
||||
LPCWSTR name;
|
||||
int height;
|
||||
};
|
||||
|
||||
struct PluginConfigButtonData {
|
||||
LPCWSTR friendlyName;
|
||||
LPCWSTR description;
|
||||
void(*func)();
|
||||
};
|
||||
|
||||
struct PluginConfigSpacerData {
|
||||
int height;
|
||||
};
|
||||
|
||||
struct PluginConfigOption
|
||||
{
|
||||
ConfigType cfgType;
|
||||
void* data;
|
||||
};
|
||||
|
||||
struct PluginConfigArray
|
||||
{
|
||||
int len;
|
||||
PluginConfigOption* options;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
}
|
||||
@@ -311,6 +311,7 @@ struct PluginInfo {
|
||||
std::wstring filename;
|
||||
std::wstring name;
|
||||
std::wstring description;
|
||||
std::wstring builddate;
|
||||
std::vector<ConfigOptionBase*> configopts;
|
||||
};
|
||||
std::vector<PluginInfo> LoadPlugins()
|
||||
@@ -341,6 +342,7 @@ std::vector<PluginInfo> LoadPlugins()
|
||||
|
||||
auto nameFunc = (LPCWSTR(*)())GetProcAddress(thisplugin.handle, "GetPluginName");
|
||||
auto descFunc = (LPCWSTR(*)())GetProcAddress(thisplugin.handle, "GetPluginDescription");
|
||||
auto dateFunc = (LPCWSTR(*)())GetProcAddress(thisplugin.handle, "GetBuildDate");
|
||||
auto optsFunc = (PluginConfig::PluginConfigArray(*)())GetProcAddress(thisplugin.handle, "GetPluginOptions");
|
||||
|
||||
if (nameFunc != NULL)
|
||||
@@ -353,6 +355,13 @@ std::vector<PluginInfo> LoadPlugins()
|
||||
else
|
||||
thisplugin.description = (thisplugin.filename + L" Plugin").c_str();
|
||||
|
||||
if (dateFunc != NULL)
|
||||
thisplugin.builddate = dateFunc();
|
||||
else
|
||||
thisplugin.builddate = L"Unknown";
|
||||
|
||||
thisplugin.description += L"\n\nVersion: " + thisplugin.builddate;
|
||||
|
||||
if (optsFunc != NULL)
|
||||
thisplugin.configopts = PluginConfig::GetConfigOptionVec(optsFunc());
|
||||
|
||||
@@ -395,3 +404,16 @@ void(WINAPI * cuInit)(unsigned int flags) = (void(WINAPI*)(unsigned int flags))G
|
||||
// needed to close the OpenGL window (freeglut only)
|
||||
HMODULE glutModule = LoadLibraryW(L"glut32.dll");
|
||||
void(__stdcall * glutMainLoopEventDynamic)() = (void(__stdcall*)())GetProcAddress(glutModule, "glutMainLoopEvent");
|
||||
|
||||
|
||||
using namespace PluginConfig;
|
||||
|
||||
extern "C" __declspec(dllexport) LPCWSTR GetPluginName(void)
|
||||
{
|
||||
return L"Launcher";
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) LPCWSTR GetPluginDescription(void)
|
||||
{
|
||||
return L"PD Launcher is the window you currently have open.\nYou can disable it if you want, but you'll need to edit config.ini if you ever want to re-enable it.";
|
||||
}
|
||||
@@ -58,7 +58,7 @@ namespace Launcher {
|
||||
int screenresY = 3;
|
||||
for (ConfigOptionBase* option : screenResolutionArray)
|
||||
{
|
||||
option->hasChanged = ConfigHasChanged;
|
||||
option->hasChanged = ResolutionConfigChanged;
|
||||
screenresY += option->AddToPanel(panel_ScreenRes, 12, screenresY, toolTip1);
|
||||
}
|
||||
((ComboBox^)ComboBox::FromHandle(DisplayModeDropdown->mainControlHandle))->SelectedIndexChanged += gcnew System::EventHandler(this, &ui::DisplayTypeChangedHandler);
|
||||
@@ -74,7 +74,7 @@ namespace Launcher {
|
||||
int intresY = 3;
|
||||
for (ConfigOptionBase* option : internalResolutionArray)
|
||||
{
|
||||
option->hasChanged = ConfigHasChanged;
|
||||
option->hasChanged = ResolutionConfigChanged;
|
||||
intresY += option->AddToPanel(panel_IntRes, 12, intresY, toolTip1);
|
||||
}
|
||||
((CheckBox^)CheckBox::FromHandle(InternalResolutionCheckbox->mainControlHandle))->CheckedChanged += gcnew System::EventHandler(this, &ui::InternalResEnabledChangedHandler);
|
||||
@@ -90,7 +90,7 @@ namespace Launcher {
|
||||
int optionsY = 3;
|
||||
for (ConfigOptionBase* option : optionsArray)
|
||||
{
|
||||
option->hasChanged = ConfigHasChanged;
|
||||
option->hasChanged = OptionsConfigChanged;
|
||||
optionsY += option->AddToPanel(panel_Patches, 12, optionsY, toolTip1);
|
||||
}
|
||||
this->panel_Patches->ResumeLayout(false);
|
||||
@@ -105,7 +105,7 @@ namespace Launcher {
|
||||
int playerdataY = 3;
|
||||
for (ConfigOptionBase* option : playerdataArray)
|
||||
{
|
||||
option->hasChanged = ConfigHasChanged;
|
||||
option->hasChanged = PlayerdataConfigChanged;
|
||||
playerdataY += option->AddToPanel(panel_Playerdata, 12, playerdataY, toolTip1);
|
||||
}
|
||||
this->panel_Playerdata->ResumeLayout(false);
|
||||
@@ -119,7 +119,7 @@ namespace Launcher {
|
||||
int componentsY = 3;
|
||||
for (ConfigOptionBase* component : componentsArray)
|
||||
{
|
||||
component->hasChanged = ConfigHasChanged;
|
||||
component->hasChanged = ComponentsConfigChanged;
|
||||
componentsY += component->AddToPanel(panel_Components, 12, componentsY, toolTip1);
|
||||
}
|
||||
this->panel_Components->ResumeLayout(false);
|
||||
@@ -134,7 +134,7 @@ namespace Launcher {
|
||||
int pluginsY = 3;
|
||||
for (ConfigOptionBase* option : AllPluginOpts)
|
||||
{
|
||||
option->hasChanged = ConfigHasChanged;
|
||||
option->hasChanged = new bool(false);
|
||||
pluginsY += option->AddToPanel(panel_Plugins, 12, pluginsY, toolTip1);
|
||||
}
|
||||
this->panel_Plugins->ResumeLayout(false);
|
||||
@@ -559,38 +559,61 @@ namespace Launcher {
|
||||
|
||||
}
|
||||
#pragma endregion
|
||||
private: System::Void SaveSettings() {
|
||||
for (ConfigOptionBase* option : screenResolutionArray)
|
||||
private: System::Void SaveSettings() {
|
||||
if (*ResolutionConfigChanged)
|
||||
{
|
||||
option->SaveOption();
|
||||
for (ConfigOptionBase* option : screenResolutionArray)
|
||||
{
|
||||
option->SaveOption();
|
||||
}
|
||||
|
||||
for (ConfigOptionBase* option : internalResolutionArray)
|
||||
{
|
||||
option->SaveOption();
|
||||
}
|
||||
|
||||
*ResolutionConfigChanged = false;
|
||||
}
|
||||
|
||||
for (ConfigOptionBase* option : internalResolutionArray)
|
||||
if (*OptionsConfigChanged)
|
||||
{
|
||||
option->SaveOption();
|
||||
for (ConfigOptionBase* option : optionsArray)
|
||||
{
|
||||
option->SaveOption();
|
||||
}
|
||||
|
||||
*OptionsConfigChanged = false;
|
||||
}
|
||||
|
||||
for (ConfigOptionBase* option : optionsArray)
|
||||
if (*PlayerdataConfigChanged)
|
||||
{
|
||||
option->SaveOption();
|
||||
for (ConfigOptionBase* option : playerdataArray)
|
||||
{
|
||||
option->SaveOption();
|
||||
}
|
||||
|
||||
*PlayerdataConfigChanged = false;
|
||||
}
|
||||
|
||||
for (ConfigOptionBase* option : playerdataArray)
|
||||
if (*ComponentsConfigChanged)
|
||||
{
|
||||
option->SaveOption();
|
||||
}
|
||||
for (ConfigOptionBase* component : componentsArray)
|
||||
{
|
||||
component->SaveOption();
|
||||
}
|
||||
|
||||
for (ConfigOptionBase* component : componentsArray)
|
||||
{
|
||||
component->SaveOption();
|
||||
*ComponentsConfigChanged = false;
|
||||
}
|
||||
|
||||
for (ConfigOptionBase* option : AllPluginOpts)
|
||||
{
|
||||
option->SaveOption();
|
||||
}
|
||||
if (*(option->hasChanged))
|
||||
{
|
||||
option->SaveOption();
|
||||
}
|
||||
|
||||
*ConfigHasChanged = false;
|
||||
*(option->hasChanged) = false;
|
||||
}
|
||||
}
|
||||
private: System::Void Ui_Load(System::Object^ sender, System::EventArgs^ e){
|
||||
}
|
||||
@@ -655,7 +678,7 @@ private: System::Void DisplayTypeChangedHandler(System::Object^ sender, System::
|
||||
}
|
||||
}
|
||||
private: System::Void Ui_FormClosing(System::Object^ sender, System::Windows::Forms::FormClosingEventArgs^ e) {
|
||||
if (!*ConfigHasChanged)
|
||||
if (!AnyConfigChanged())
|
||||
return;
|
||||
|
||||
switch (SkinnedMessageBox::Show(this, "Do you want to save your settings?", "PD Launcher", MessageBoxButtons::YesNoCancel, MessageBoxIcon::Question))
|
||||
@@ -689,10 +712,21 @@ private: System::Void Ui_KeyDown(System::Object^ sender, System::Windows::Forms:
|
||||
if (e->KeyCode == Keys::Escape) this->Close();
|
||||
}
|
||||
|
||||
private: bool* ConfigHasChanged = new bool(false);/*
|
||||
private: bool* ResolutionConfigChanged = new bool(false);
|
||||
bool* OptionsConfigChanged = new bool(false);
|
||||
bool* PlayerdataConfigChanged = new bool(false);
|
||||
bool* ComponentsConfigChanged = new bool(false);
|
||||
|
||||
private: System::Void ConfigChanged(System::Object^ sender, System::EventArgs^ e) {
|
||||
*ConfigHasChanged = true;
|
||||
}*/
|
||||
private: bool AnyConfigChanged() {
|
||||
if (*ResolutionConfigChanged || *OptionsConfigChanged || *PlayerdataConfigChanged || *ComponentsConfigChanged)
|
||||
return true; // fast case
|
||||
|
||||
for (ConfigOptionBase* option : AllPluginOpts)
|
||||
{
|
||||
if (*(option->hasChanged)) return true; // slow case for iterating over individual plugins
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
@@ -96,7 +96,7 @@
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalIncludeDirectories>..\..\..\dependencies\freeglut\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\..\dependencies\PluginConfigApi;..\..\..\dependencies\freeglut\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -133,7 +133,7 @@
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeaderFile>
|
||||
</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>..\..\..\dependencies\freeglut\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\..\dependencies\PluginConfigApi;..\..\..\dependencies\freeglut\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <filesystem>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include "PluginConfigApi.h"
|
||||
|
||||
void InjectCode(void* address, const std::vector<uint8_t> data);
|
||||
void ApplyPatches();
|
||||
@@ -317,3 +318,16 @@ void InjectCode(void* address, const std::vector<uint8_t> data)
|
||||
memcpy(address, data.data(), byteCount);
|
||||
VirtualProtect(address, byteCount, oldProtect, nullptr);
|
||||
}
|
||||
|
||||
|
||||
using namespace PluginConfig;
|
||||
|
||||
extern "C" __declspec(dllexport) LPCWSTR GetPluginName(void)
|
||||
{
|
||||
return L"Patches";
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) LPCWSTR GetPluginDescription(void)
|
||||
{
|
||||
return L"Applies patches/tweaks to the game before it starts.\nThis plugin is required.";
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
@@ -96,7 +96,7 @@
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeaderFile>
|
||||
</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>..\..\..\dependencies\freeglut\include;..\..\..\dependencies\detours\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\..\dependencies\PluginConfigApi;..\..\..\dependencies\freeglut\include;..\..\..\dependencies\detours\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
@@ -135,7 +135,7 @@
|
||||
<PrecompiledHeaderFile>
|
||||
</PrecompiledHeaderFile>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalIncludeDirectories>..\..\..\dependencies\freeglut\include;..\..\..\dependencies\detours\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\..\dependencies\PluginConfigApi;..\..\..\dependencies\freeglut\include;..\..\..\dependencies\detours\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "PluginConfigApi.h"
|
||||
|
||||
using namespace std::chrono;
|
||||
|
||||
int hookedCreateWindow(const char* title, void(__cdecl* exit_function)(int))
|
||||
@@ -238,3 +240,15 @@ BOOL APIENTRY DllMain(HMODULE hModule,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
using namespace PluginConfig;
|
||||
|
||||
extern "C" __declspec(dllexport) LPCWSTR GetPluginName(void)
|
||||
{
|
||||
return L"Render";
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) LPCWSTR GetPluginDescription(void)
|
||||
{
|
||||
return L"Applies window mode/size and FPS limiting.";
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{C07E495E-A16F-48FA-80E4-0296B5234F0B}</ProjectGuid>
|
||||
<RootNamespace>ShaderPatch</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<TargetExt>.dva</TargetExt>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<TargetExt>.dva</TargetExt>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\..\..\dependencies\detours\include;..\..\..\dependencies\PluginConfigApi</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalLibraryDirectories>..\..\..\dependencies\detours\lib</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\..\..\dependencies\detours\include;..\..\..\dependencies\PluginConfigApi</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>..\..\..\dependencies\detours\lib</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\dllmain.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\framework.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\dllmain.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\framework.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,372 @@
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#include <windows.h>
|
||||
|
||||
#include "framework.h"
|
||||
#include "PluginConfigApi.h"
|
||||
#include "detours.h"
|
||||
#pragma comment(lib, "detours.lib")
|
||||
|
||||
#include <vector>
|
||||
#include <regex>
|
||||
|
||||
void InjectCode(void* address, const std::vector<uint8_t> data)
|
||||
{
|
||||
const size_t byteCount = data.size() * sizeof(uint8_t);
|
||||
|
||||
DWORD oldProtect;
|
||||
VirtualProtect(address, byteCount, PAGE_EXECUTE_READWRITE, &oldProtect);
|
||||
memcpy(address, data.data(), byteCount);
|
||||
VirtualProtect(address, byteCount, oldProtect, nullptr);
|
||||
}
|
||||
|
||||
void NopBytes(void* address, unsigned int num)
|
||||
{
|
||||
std::vector<uint8_t> newbytes = {};
|
||||
|
||||
for (unsigned int i = 0; i < num; ++i) newbytes.push_back(0x90);
|
||||
|
||||
InjectCode(address, newbytes);
|
||||
}
|
||||
|
||||
|
||||
void loadGpuName()
|
||||
{
|
||||
NvAPI_QueryInterface = (void*(*)(unsigned int offset))GetProcAddress(LoadLibrary("nvapi64.dll"), "nvapi_QueryInterface");
|
||||
|
||||
if (NvAPI_QueryInterface == nullptr)
|
||||
{
|
||||
gpuName = "Other";
|
||||
return;
|
||||
}
|
||||
|
||||
NvAPI_Initialize = (int(*)())NvAPI_QueryInterface(0x0150E828);
|
||||
NvAPI_Unload = (int(*)()) NvAPI_QueryInterface(0xD22BDD7E);
|
||||
NvAPI_EnumPhysicalGPUs = (int(*)(int64_t** handle, int* count))NvAPI_QueryInterface(0xE5AC921F);
|
||||
NvAPI_GPU_GetShortName = (int(*)(int64_t* handle, char* name))NvAPI_QueryInterface(0xD988F0F3);
|
||||
|
||||
if (NvAPI_Initialize == nullptr ||
|
||||
NvAPI_Unload == nullptr ||
|
||||
NvAPI_EnumPhysicalGPUs == nullptr ||
|
||||
NvAPI_GPU_GetShortName == nullptr)
|
||||
{
|
||||
gpuName = "Unknown";
|
||||
return;
|
||||
}
|
||||
|
||||
int64_t* hdlGpu[64] = { 0 };
|
||||
int nGpu = 0;
|
||||
|
||||
NvAPI_Initialize();
|
||||
NvAPI_EnumPhysicalGPUs(hdlGpu, &nGpu);
|
||||
|
||||
//printf("[ShaderPatch] nGpu: %d\n", nGpu);
|
||||
if (nGpu < 1)
|
||||
{
|
||||
gpuName = "Unknown";
|
||||
NvAPI_Unload();
|
||||
return;
|
||||
}
|
||||
|
||||
char nameBuf[64];
|
||||
NvAPI_GPU_GetShortName(hdlGpu[0], nameBuf);
|
||||
NvAPI_Unload();
|
||||
|
||||
gpuName = nameBuf;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void LoadConfig()
|
||||
{
|
||||
std::ifstream fileStream(CONFIG_FILE_STRING);
|
||||
|
||||
if (!fileStream.is_open())
|
||||
return;
|
||||
|
||||
std::string line;
|
||||
std::string section = "patches";
|
||||
std::string lastComment;
|
||||
bool isInComment = false;
|
||||
|
||||
// check for BOM
|
||||
std::getline(fileStream, line);
|
||||
if (line.size() >= 3 && line.rfind("\xEF\xBB\xBF", 0) == 0)
|
||||
fileStream.seekg(3);
|
||||
else
|
||||
fileStream.seekg(0);
|
||||
|
||||
while (std::getline(fileStream, line))
|
||||
{
|
||||
// detect comments first to make comment exit logic easier
|
||||
int commentStartPos;
|
||||
if ((commentStartPos = 1, line.size() >= 1 && line[0] == '#') || (commentStartPos = 2, line.size() >= 2 && line.rfind("//", 0) == 0))
|
||||
{
|
||||
line.erase(0, commentStartPos);
|
||||
line = TrimString(line, " \t");
|
||||
if (isInComment)
|
||||
{
|
||||
lastComment += "\n" + line;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastComment = line;
|
||||
isInComment = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
isInComment = false;
|
||||
|
||||
if (line.size() <= 0) // skip empty lines
|
||||
{
|
||||
lastComment = ""; // consume the last comment
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line[0] == '[') // section name
|
||||
{
|
||||
size_t endIdx = line.find(']');
|
||||
section = line.substr(1, endIdx - 1);
|
||||
std::transform(section.begin(), section.end(), section.begin(), ::tolower);
|
||||
lastComment = ""; // consume the last comment
|
||||
continue;
|
||||
}
|
||||
|
||||
std::vector<std::string> equalSplit = SplitString(line, "=");
|
||||
if (equalSplit.size() < 2)
|
||||
{
|
||||
lastComment = ""; // consume the last comment
|
||||
continue;
|
||||
}
|
||||
|
||||
if (section == "patches")
|
||||
{
|
||||
ShaderPatchInfo patch = ShaderPatchInfo();
|
||||
|
||||
patch.fileRegex = equalSplit[0];
|
||||
|
||||
std::vector<std::string> rules = SplitString(equalSplit[1], "||");
|
||||
if (rules.size() < 1) continue; // probably will never trigger but whatever
|
||||
|
||||
for (std::string &rule : rules)
|
||||
{
|
||||
if (rule.size() >= 5 && rule.rfind("arch:", 0) == 0)
|
||||
{
|
||||
rule.erase(0, 5);
|
||||
patch.archs = SplitString(rule, ",");
|
||||
}
|
||||
else if (rule.size() >= 4 && rule.rfind("cfg:", 0) == 0)
|
||||
{
|
||||
rule.erase(0, 4);
|
||||
// force cfg key to lower because ini shouldn't be case sensitive
|
||||
std::transform(rule.begin(), rule.end(), rule.begin(), ::tolower);
|
||||
patch.cfg = rule;
|
||||
}
|
||||
else if (rule.size() >= 5 && rule.rfind("from:", 0) == 0)
|
||||
{
|
||||
rule.erase(0, 5);
|
||||
patch.dataRegex = rule;
|
||||
}
|
||||
else if (rule.size() >= 3 && rule.rfind("to:", 0) == 0)
|
||||
{
|
||||
rule.erase(0, 3);
|
||||
patch.dataReplace = rule;
|
||||
}
|
||||
}
|
||||
lastComment = ""; // consume the last comment
|
||||
|
||||
patchesVec.push_back(patch);
|
||||
}
|
||||
else if (section == "config")
|
||||
{
|
||||
// force cfg key to lower because ini shouldn't be case sensitive
|
||||
std::transform(equalSplit[0].begin(), equalSplit[0].end(), equalSplit[0].begin(), ::tolower);
|
||||
equalSplit[1] = TrimString(equalSplit[1], " \t");
|
||||
|
||||
configMap.insert(std::pair<std::string, strpair>(equalSplit[0], strpair(equalSplit[1], lastComment)));
|
||||
lastComment = ""; // consume the last comment
|
||||
}
|
||||
}
|
||||
|
||||
fileStream.close();
|
||||
}
|
||||
|
||||
|
||||
void hookedLoadFromFarcThunk(FArchivedFile** ppFile)
|
||||
{
|
||||
loadFromFarcThunk(ppFile);
|
||||
|
||||
if (ppFile == nullptr || *ppFile == nullptr)
|
||||
return;
|
||||
|
||||
FArchivedFile &file = **ppFile;
|
||||
|
||||
if (file.notLoadedFlag != 0)
|
||||
return;
|
||||
|
||||
std::string modifiedStr = "";
|
||||
|
||||
for (ShaderPatchInfo &patch : patchesVec)
|
||||
{
|
||||
bool archMatches = false;
|
||||
if (patch.archs.size() > 0)
|
||||
{
|
||||
for (std::string &arch : patch.archs)
|
||||
{
|
||||
if (gpuName.size() >= arch.size() && gpuName.rfind(arch, 0) == 0)
|
||||
{
|
||||
archMatches = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
archMatches = true;
|
||||
}
|
||||
|
||||
bool cfgMatches = false;
|
||||
if (patch.cfg.length() == 0 || // patch has no config setting
|
||||
(configMap.find(patch.cfg) != configMap.end() && configMap[patch.cfg].first != "0")) // patch has a toggle and is not set to 0
|
||||
{
|
||||
cfgMatches = true;
|
||||
}
|
||||
|
||||
if (archMatches && cfgMatches && std::regex_match(file.fileName.GetCharBuf(), patch.fileRegex))
|
||||
{
|
||||
if (modifiedStr.length() == 0)
|
||||
modifiedStr = std::string(file.data, file.dataSize);
|
||||
|
||||
modifiedStr = std::regex_replace(modifiedStr, patch.dataRegex, patch.dataReplace);
|
||||
modifiedStr = StringReplace(modifiedStr, "<fname>", file.fileName.GetCharBuf());
|
||||
|
||||
if (patch.cfg.length() > 0) // patch has a config setting
|
||||
{
|
||||
int valNum = 0;
|
||||
std::string valKey;
|
||||
while (valNum++, valKey = patch.cfg + "_val" + std::to_string(valNum),
|
||||
configMap.find(valKey) != configMap.end()) // loop until there's no more config values set
|
||||
{
|
||||
modifiedStr = StringReplace(modifiedStr, "<val" + std::to_string(valNum) + ">", configMap[valKey].first);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (modifiedStr.length() > 0)
|
||||
{
|
||||
free(file.data);
|
||||
file.data = _strdup(modifiedStr.c_str());
|
||||
file.dataSize = modifiedStr.size();
|
||||
printf("[ShaderPatch] Patched %s\n", file.fileName.GetCharBuf());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOL APIENTRY DllMain(HMODULE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved
|
||||
)
|
||||
{
|
||||
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
// install a thunk to hook
|
||||
InjectCode((void*)0x1405e5991, { 0x48, 0x83, 0xec, 0x20 }); // SUB RSP, 0x20
|
||||
InjectCode((void*)0x1405e5995, { 0xe8, 0x56, 0xe8, 0xb9, 0xff }); // CALL 0x1401841f0
|
||||
InjectCode((void*)0x1405e599a, { 0x48, 0x83, 0xc4, 0x20 }); // ADD RSP, 0x20
|
||||
InjectCode((void*)0x1405e599e, { 0xc3 }); // RET
|
||||
InjectCode((void*)0x1405e534a, { 0xe8, 0x42, 0x06, 0x00, 0x00 }); // CALL 0x1405e5991
|
||||
|
||||
DisableThreadLibraryCalls(hModule);
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
DetourAttach(&(PVOID&)loadFromFarcThunk, (PVOID)hookedLoadFromFarcThunk);
|
||||
DetourTransactionCommit();
|
||||
|
||||
loadGpuName();
|
||||
printf("[ShaderPatch] Detected GPU: %s\n", gpuName.c_str());
|
||||
//Sleep(2000);
|
||||
|
||||
LoadConfig();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
using namespace PluginConfig;
|
||||
|
||||
extern "C" __declspec(dllexport) LPCWSTR GetPluginName(void)
|
||||
{
|
||||
return L"ShaderPatch";
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) LPCWSTR GetPluginDescription(void)
|
||||
{
|
||||
return L"Automatically patches shaders";
|
||||
}
|
||||
|
||||
std::vector<PluginConfigOption> configVec;
|
||||
extern "C" __declspec(dllexport) PluginConfigArray GetPluginOptions(void)
|
||||
{
|
||||
LoadConfig();
|
||||
|
||||
for (std::map<std::string, strpair>::iterator iter = configMap.begin(); iter != configMap.end(); ++iter)
|
||||
{
|
||||
std::string k = iter->first;
|
||||
std::string v = iter->second.first;
|
||||
std::string c = iter->second.second;
|
||||
|
||||
if (k.size() < 6 || k.substr(k.size() - 5, 4) != "_val")
|
||||
{
|
||||
WCHAR utf16key[128];
|
||||
WCHAR utf16val[128];
|
||||
WCHAR utf16comment[512];
|
||||
|
||||
// count values to approximate the group size
|
||||
int valNum = 0;
|
||||
int valCount = 0;
|
||||
std::string valKey;
|
||||
while (valNum++, valKey = k + "_val" + std::to_string(valNum),
|
||||
configMap.find(valKey) != configMap.end()) // loop until there's no more config values set
|
||||
{
|
||||
valCount++;
|
||||
}
|
||||
|
||||
|
||||
MultiByteToWideChar(CP_UTF8, 0, k.c_str(), -1, utf16key, 128);
|
||||
MultiByteToWideChar(CP_UTF8, 0, c.c_str(), -1, utf16comment, 512);
|
||||
LPCWSTR ttDup = _wcsdup(utf16comment);
|
||||
|
||||
configVec.push_back({ CONFIG_GROUP_START, new PluginConfigGroupData{ _wcsdup(utf16key), 45 + valCount * 25 } });
|
||||
configVec.push_back({ CONFIG_BOOLEAN, new PluginConfigBooleanData{ _wcsdup(utf16key), L"config", CONFIG_FILE, L"Enable", ttDup, false, false } });
|
||||
|
||||
|
||||
valNum = 0;
|
||||
while (valNum++, valKey = k + "_val" + std::to_string(valNum),
|
||||
configMap.find(valKey) != configMap.end()) // loop until there's no more config values set
|
||||
{
|
||||
MultiByteToWideChar(CP_UTF8, 0, valKey.c_str(), -1, utf16key, 128);
|
||||
MultiByteToWideChar(CP_UTF8, 0, configMap[valKey].first.c_str(), -1, utf16val, 128);
|
||||
|
||||
std::wstring name;
|
||||
if (configMap[valKey].second.size() > 0)
|
||||
{
|
||||
MultiByteToWideChar(CP_UTF8, 0, configMap[valKey].second.c_str(), -1, utf16comment, 512);
|
||||
name = utf16comment;
|
||||
name += L":";
|
||||
; }
|
||||
else
|
||||
{
|
||||
name = std::wstring(L"Value ") + std::to_wstring(valNum) + L":";
|
||||
}
|
||||
configVec.push_back({ CONFIG_STRING, new PluginConfigStringData{ _wcsdup(utf16key), L"config", CONFIG_FILE, _wcsdup(name.c_str()), ttDup, _wcsdup(utf16val), false } });
|
||||
}
|
||||
|
||||
|
||||
configVec.push_back({ CONFIG_GROUP_END, NULL });
|
||||
configVec.push_back({ CONFIG_SPACER, new PluginConfigSpacerData{ 10 } });
|
||||
}
|
||||
}
|
||||
|
||||
return PluginConfigArray{ (int)configVec.size(), &configVec[0] };
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
#pragma once
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#include <windows.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <regex>
|
||||
#include <stdint.h>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
struct ShaderPatchInfo {
|
||||
std::regex fileRegex;
|
||||
std::regex dataRegex;
|
||||
std::string dataReplace;
|
||||
std::vector<std::string> archs;
|
||||
std::string cfg;
|
||||
};
|
||||
|
||||
std::vector<ShaderPatchInfo> patchesVec;
|
||||
|
||||
typedef std::pair<std::string, std::string> strpair;
|
||||
std::map<std::string, strpair> configMap;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct MsString {
|
||||
union {
|
||||
char* string_ptr;
|
||||
char string_buf[16];
|
||||
};
|
||||
uint64_t unk;
|
||||
uint64_t size;
|
||||
|
||||
char* GetCharBuf()
|
||||
{
|
||||
if (size > 0xf && string_ptr != nullptr)
|
||||
return string_ptr;
|
||||
else
|
||||
return string_buf;
|
||||
};
|
||||
};
|
||||
|
||||
struct FArchivedFile {
|
||||
uint8_t padding00[0x10];
|
||||
uint8_t notLoadedFlag;
|
||||
uint8_t padding11[0x07];
|
||||
MsString farcPath;
|
||||
MsString fileName;
|
||||
uint8_t padding58[0x38];
|
||||
uint64_t dataSize;
|
||||
char* data;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
void (__stdcall* loadFromFarcThunk)(FArchivedFile** file) = (void(__stdcall*)(FArchivedFile** file))0x1405e5991;
|
||||
|
||||
|
||||
std::string gpuName;
|
||||
void*(*NvAPI_QueryInterface)(unsigned int offset) = NULL;
|
||||
int(*NvAPI_Initialize)() = NULL;
|
||||
int(*NvAPI_Unload)() = NULL;
|
||||
int(*NvAPI_EnumPhysicalGPUs)(int64_t** handle, int* count) = NULL;
|
||||
int(*NvAPI_GPU_GetShortName)(int64_t* handle, char* name) = NULL;
|
||||
|
||||
|
||||
|
||||
std::vector<std::string> SplitString(const std::string& str, const std::string& delim)
|
||||
{
|
||||
std::vector<std::string> tokens;
|
||||
size_t prev = 0, pos = 0;
|
||||
do
|
||||
{
|
||||
pos = str.find(delim, prev);
|
||||
if (pos == std::string::npos)
|
||||
pos = str.length();
|
||||
|
||||
std::string token = str.substr(prev, pos - prev);
|
||||
|
||||
if (!token.empty())
|
||||
tokens.push_back(token);
|
||||
|
||||
prev = pos + delim.length();
|
||||
} while (pos < str.length() && prev < str.length());
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
std::string TrimString(const std::string& str, const std::string& whitespace)
|
||||
{
|
||||
const size_t strBegin = str.find_first_not_of(whitespace);
|
||||
|
||||
if (strBegin == std::string::npos)
|
||||
return "";
|
||||
|
||||
const size_t strEnd = str.find_last_not_of(whitespace);
|
||||
const size_t strRange = strEnd - strBegin + 1;
|
||||
|
||||
return str.substr(strBegin, strRange);
|
||||
}
|
||||
|
||||
std::string StringReplace(const std::string& str, const std::string& srch, const std::string& repl)
|
||||
{
|
||||
size_t pos = 0;
|
||||
std::string outstr = str;
|
||||
|
||||
while (true)
|
||||
{
|
||||
pos = outstr.find(srch, pos);
|
||||
if (pos == std::string::npos)
|
||||
break;
|
||||
|
||||
outstr.replace(pos, srch.length(), repl);
|
||||
}
|
||||
|
||||
return outstr;
|
||||
}
|
||||
|
||||
|
||||
std::wstring ExePath() {
|
||||
WCHAR buffer[MAX_PATH];
|
||||
GetModuleFileNameW(NULL, buffer, MAX_PATH);
|
||||
return std::wstring(buffer);
|
||||
}
|
||||
|
||||
std::wstring DirPath() {
|
||||
std::wstring exepath = ExePath();
|
||||
std::wstring::size_type pos = exepath.find_last_of(L"\\/");
|
||||
return exepath.substr(0, pos);
|
||||
}
|
||||
|
||||
std::wstring CONFIG_FILE_STRING = DirPath() + L"\\plugins\\ShaderPatch.ini";
|
||||
LPCWSTR CONFIG_FILE = CONFIG_FILE_STRING.c_str();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "ScoreSaver.h"
|
||||
#include "GameState.h"
|
||||
#include "../Constants.h"
|
||||
#include "../framework.h"
|
||||
#include "../Utilities/Operations.h"
|
||||
@@ -22,11 +23,6 @@ namespace TLAC::Components
|
||||
|
||||
ScoreSaver::~ScoreSaver()
|
||||
{
|
||||
for (int diff = 0; diff < 4; diff++)
|
||||
{
|
||||
*(DivaScore**)(PLAYER_DATA_ADDRESS + diff * 0x18 + 0x5d0) = 0;
|
||||
*(DivaScore**)(PLAYER_DATA_ADDRESS + diff * 0x18 + 0x5d8) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
const char* ScoreSaver::GetDisplayName()
|
||||
@@ -34,14 +30,8 @@ namespace TLAC::Components
|
||||
return "score_saver";
|
||||
}
|
||||
|
||||
bool(__stdcall* ScoreSaver::divaInitResults)(void* cls) = (bool(__stdcall*)(void* cls))RESULTS_INIT_ADDRESS;
|
||||
void ScoreSaver::Initialize(ComponentsManager*)
|
||||
void ScoreSaver::initCache()
|
||||
{
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
DetourAttach(&(PVOID&)ScoreSaver::divaInitResults, (PVOID)(ScoreSaver::hookedInitResults));
|
||||
DetourTransactionCommit();
|
||||
|
||||
// build the score cache
|
||||
UpdateScoreCache();
|
||||
UpdateClearCounts();
|
||||
@@ -54,6 +44,18 @@ namespace TLAC::Components
|
||||
}
|
||||
}
|
||||
|
||||
bool(__stdcall* ScoreSaver::divaInitResults)(void* cls) = (bool(__stdcall*)(void* cls))RESULTS_INIT_ADDRESS;
|
||||
std::thread ScoreSaver::initThread;
|
||||
void ScoreSaver::Initialize(ComponentsManager*)
|
||||
{
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
DetourAttach(&(PVOID&)ScoreSaver::divaInitResults, (PVOID)(ScoreSaver::hookedInitResults));
|
||||
DetourTransactionCommit();
|
||||
|
||||
initThread = std::thread(initCache);
|
||||
}
|
||||
|
||||
bool ScoreSaver::checkExistingScoreValid(int pv, int difficulty, int isEx)
|
||||
{
|
||||
WCHAR keyBase[32]; // needs to be big enough to store pv.999.diff.3.ex
|
||||
@@ -313,7 +315,12 @@ namespace TLAC::Components
|
||||
|
||||
void ScoreSaver::Update()
|
||||
{
|
||||
return;
|
||||
if (*(GameState*)CURRENT_GAME_STATE_ADDRESS == GS_GAME && *(SubGameState*)CURRENT_GAME_SUB_STATE_ADDRESS == SUB_SELECTOR && initThread.joinable())
|
||||
{
|
||||
// it's actually fine to let the init happen in the background after reaching game state, but this is probably safer
|
||||
printf("[ScoreSaver] Waiting for initialisation...");
|
||||
initThread.join();
|
||||
}
|
||||
}
|
||||
|
||||
void ScoreSaver::UpdateInput()
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "../Constants.h"
|
||||
#include <windows.h>
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
|
||||
namespace TLAC::Components
|
||||
{
|
||||
@@ -109,10 +110,12 @@ namespace TLAC::Components
|
||||
static bool(__stdcall* divaInitResults)(void* cls);
|
||||
static bool hookedInitResults(void* cls);
|
||||
static void InjectCode(void* address, const std::vector<uint8_t> data);
|
||||
static void initCache();
|
||||
static bool checkExistingScoreValid(int pv, int difficulty, int isEx);
|
||||
static int calculateCheck(int score, int cntCools, int cntFines, int percent, int combo, int clearRank, int allTimeRank, int allTimeModifiers, int allTimePercent);
|
||||
|
||||
static WCHAR configPath[256];
|
||||
static WCHAR rival_configPath[256];
|
||||
static std::thread initThread;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
<PrecompiledHeaderFile>
|
||||
</PrecompiledHeaderFile>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalIncludeDirectories>..\..\..\dependencies\detours\include;..\..\..\dependencies\freeglut\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\..\dependencies\PluginConfigApi;..\..\..\dependencies\detours\include;..\..\..\dependencies\freeglut\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -139,7 +139,7 @@
|
||||
<PrecompiledHeaderFile>
|
||||
</PrecompiledHeaderFile>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalIncludeDirectories>..\..\..\dependencies\detours\include;..\..\..\dependencies\freeglut\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>..\..\..\dependencies\PluginConfigApi;..\..\..\dependencies\detours\include;..\..\..\dependencies\freeglut\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -225,6 +225,7 @@
|
||||
<ClInclude Include="Input\Mouse\MouseState.h" />
|
||||
<ClInclude Include="Input\Xinput\Xinput.h" />
|
||||
<ClInclude Include="Input\Xinput\XinputState.h" />
|
||||
<ClInclude Include="pluginconfig.h" />
|
||||
<ClInclude Include="Utilities\EnumBitwiseOperations.h" />
|
||||
<ClInclude Include="Utilities\Math.h" />
|
||||
<ClInclude Include="Utilities\Operations.h" />
|
||||
|
||||
@@ -195,6 +195,9 @@
|
||||
<ClInclude Include="Components\ScoreSaver.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="pluginconfig.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <stdio.h>
|
||||
#include "Constants.h"
|
||||
#include "framework.h"
|
||||
#include "pluginconfig.h"
|
||||
#include "Input/Mouse/Mouse.h"
|
||||
#include "Input/Xinput/Xinput.h"
|
||||
#include "Input/Keyboard/Keyboard.h"
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#include "PluginConfigApi.h"
|
||||
|
||||
using namespace PluginConfig;
|
||||
|
||||
extern "C" __declspec(dllexport) LPCWSTR GetPluginName(void)
|
||||
{
|
||||
return L"TLAC";
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) LPCWSTR GetPluginDescription(void)
|
||||
{
|
||||
return L"Provides keyboard/mouse/controller input, player data management, bug fixes for running on more PCs, etc.\nThis plugin is required.";
|
||||
}
|
||||
Reference in New Issue
Block a user