move render resolution into render (from TLAC), change some internal resolution options, add "match window" internal resolution option, add "match screen" window resolution option

This commit is contained in:
somewhatlurker
2019-10-15 06:50:43 +11:00
parent fba0ce6d09
commit ca79d4aa87
6 changed files with 89 additions and 41 deletions
+2
View File
@@ -68,6 +68,7 @@ FRM.Motion.Rate=300
[Resolution]
# 0 = Windowed, 1 = Borderless (Forced to desktop resolution), 2 = Fullscreen
# For same as screen res: -1x-1
Display=1
Width=1280
Height=720
@@ -78,6 +79,7 @@ BitDepth=32
RefreshRate=60
# Set a custom internal render resolution
# Same as window: -1x-1
# HD : 1280x720
# FHD : 1920x1080
# WQHD : 2560x1440
@@ -49,6 +49,9 @@ class ConfigOptionBase;
Panel^ MakePanel(int width, int height, std::vector<ConfigOptionBase*> &cfg, ToolTip^ tooltip, bool* hasChanged);
#define RESOPT_MATCH_WINDOW_TEXT "Match Window"
#define RESOPT_MATCH_SCREEN_TEXT "Match Screen"
ref class ComboboxValidation
{
public:
@@ -96,22 +99,25 @@ public:
{
System::String^ text = cb->Text;
if (text == RESOPT_MATCH_WINDOW_TEXT || text == RESOPT_MATCH_SCREEN_TEXT)
return;
cli::array<Char>^ digitsarray = gcnew cli::array<Char>{ L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7', L'8', L'9' };
System::Collections::Generic::List<Char>^ digitslist = gcnew System::Collections::Generic::List<Char>(digitsarray);
int numX = 0;
while (text->Length > 0 && text[0] != L'x' && !digitslist->Contains(text[0]))
{
text = text->Remove(0, 1);
}
if (text->Length <= 0)
{
cb->Text = "x";
return;
}
while (text->Length > 0 && text[0] != L'x' && !digitslist->Contains(text[0]))
{
text = text->Remove(0, 1);
}
if (text[0] == L'x')
{
numX++;
@@ -865,6 +871,12 @@ public:
};
enum ResolutionOptionOpts
{
RESOPT_INCLUDE_MATCH_WINDOW = 1,
RESOPT_INCLUDE_MATCH_SCREEN = 2
};
class ResolutionOption : public ConfigOptionBase
{
public:
@@ -872,8 +884,9 @@ public:
resolution _defaultVal;
std::vector<resolution> _valueResolutions;
bool _editable;
ResolutionOptionOpts _opts;
ResolutionOption(LPCWSTR iniVarName, LPCWSTR iniVarName2, LPCWSTR iniSectionName, LPCWSTR iniFilePath, LPCWSTR friendlyName, LPCWSTR description, resolution defaultVal, std::vector<resolution> valueResolutions, bool editable)
ResolutionOption(LPCWSTR iniVarName, LPCWSTR iniVarName2, LPCWSTR iniSectionName, LPCWSTR iniFilePath, LPCWSTR friendlyName, LPCWSTR description, resolution defaultVal, std::vector<resolution> valueResolutions, bool editable, ResolutionOptionOpts opts)
{
_iniVarName = iniVarName;
_iniVarName2 = iniVarName2;
@@ -884,6 +897,7 @@ public:
_defaultVal = defaultVal;
_valueResolutions = valueResolutions;
_editable = editable;
_opts = opts;
}
virtual int AddToPanel(Panel^ panel, unsigned int left, unsigned int top, ToolTip^ tooltip)
@@ -900,17 +914,28 @@ public:
label->AutoSize = true;
label->FlatStyle = System::Windows::Forms::FlatStyle::Flat;
if (_opts & RESOPT_INCLUDE_MATCH_WINDOW)
combobox->Items->Add(RESOPT_MATCH_WINDOW_TEXT);
else if (_opts & RESOPT_INCLUDE_MATCH_SCREEN)
combobox->Items->Add(RESOPT_MATCH_SCREEN_TEXT);
for (resolution& choice : _valueResolutions) {
tempSysStr = Convert::ToInt32(choice.width).ToString() + L"x" + Convert::ToInt32(choice.height).ToString();
combobox->Items->Add(tempSysStr);
}
int width = GetPrivateProfileIntW(_iniSectionName, _iniVarName, -1, _iniFilePath);
int height = GetPrivateProfileIntW(_iniSectionName, _iniVarName2, -1, _iniFilePath);
if (width == -1 || height == -1) {
int width = GetPrivateProfileIntW(_iniSectionName, _iniVarName, -39, _iniFilePath);
int height = GetPrivateProfileIntW(_iniSectionName, _iniVarName2, -39, _iniFilePath);
if (width == -39 || height == -39) {
tempSysStr = Convert::ToInt32(_defaultVal.width).ToString() + L"x" + Convert::ToInt32(_defaultVal.height).ToString();
combobox->Text = tempSysStr;
}
else if (width == -1 || height == -1) { // -1 -> Match window/screen
if (_opts & RESOPT_INCLUDE_MATCH_WINDOW)
combobox->Text = RESOPT_MATCH_WINDOW_TEXT;
else if (_opts & RESOPT_INCLUDE_MATCH_SCREEN)
combobox->Text = RESOPT_MATCH_SCREEN_TEXT;
}
else {
tempSysStr = Convert::ToInt32(width).ToString() + L"x" + Convert::ToInt32(height).ToString();
combobox->Text = tempSysStr;
@@ -968,6 +993,11 @@ public:
cli::array<String^>^ resolutionArray;
tempSysStr = ((ComboBox^)ComboBox::FromHandle(mainControlHandle))->Text;
// Match window/screen -> -1x-1
if (tempSysStr == RESOPT_MATCH_WINDOW_TEXT || tempSysStr == RESOPT_MATCH_SCREEN_TEXT)
tempSysStr = "-1x-1";
resolutionArray = tempSysStr->Split('x');
tempSysStr = resolutionArray[0];
@@ -32,7 +32,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, resData->editable);
return new ResolutionOption(resData->iniVarName, resData->iniVarName2, resData->iniSectionName, resData->iniFilePath, resData->friendlyName, resData->description, resData->defaultVal, resData->valueResolutions, resData->editable, (ResolutionOptionOpts)0);
case CONFIG_GROUP_START:
return new OptionMetaGroupStart(groupData->name, groupData->height);
case CONFIG_GROUP_END:
@@ -61,6 +61,10 @@ int nSkipLauncher = GetPrivateProfileIntW(LAUNCHER_SECTION, L"skip", FALSE, CONF
int nNoGPUDialog = GetPrivateProfileIntW(LAUNCHER_SECTION, L"no_gpu_dialog", FALSE, CONFIG_FILE);
resolution getCurrentScreenResolution() {
return resolution(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
}
std::vector<DEVMODEW> getScreenModes() {
static std::vector<DEVMODEW> outVec = std::vector<DEVMODEW>();
@@ -132,7 +136,7 @@ std::vector<DEVMODEW> screenModes = getScreenModes();
DropdownOption* DisplayModeDropdown = new DropdownOption(L"display", RESOLUTION_SECTION, CONFIG_FILE, L"Display:", L"Sets the window/screen mode.", 0, std::vector<LPCWSTR>({ 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), true);
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, RESOPT_INCLUDE_MATCH_SCREEN);
ConfigOptionBase* screenResolutionArray[] = {
DisplayModeDropdown,
@@ -142,7 +146,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 (instead of 1280x720).", resolution(1920, 1080), std::vector<resolution>({ resolution(1,1), resolution(320,200), resolution(320,240), resolution(640,480), resolution(800,600), resolution(960,720), resolution(1360,768), resolution(1366,768), 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);
ResolutionOption* InternalResolutionOption = new ResolutionOption(L"r.width", L"r.height", RESOLUTION_SECTION, CONFIG_FILE, L"Resolution:", L"Sets the internal resolution (instead of 1280x720).", resolution(1920, 1080), std::vector<resolution>({ resolution(1,1), resolution(320,240), resolution(426,240), resolution(640,480), resolution(854,480), resolution(960,540), resolution(1280,720), resolution(1366,768), resolution(1600,900), resolution(1920,1080), resolution(2560,1440), resolution(3200,1800), resolution(3840,2160), resolution(5120,2880), resolution(7680,4320) }), true, RESOPT_INCLUDE_MATCH_WINDOW);
ConfigOptionBase* internalResolutionArray[] = {
InternalResolutionCheckbox,
+40 -1
View File
@@ -21,7 +21,7 @@ int hookedCreateWindow(const char* title, void(__cdecl* exit_function)(int))
// trick Optimus into switching to the NVIDIA GPU
if (cuInit != NULL) cuInit(0);
if (nDisplay == 2) // fullscreen
{
char GameModeString[24];
@@ -236,6 +236,45 @@ BOOL APIENTRY DllMain(HMODULE hModule,
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)divaEngineUpdate, hookedEngineUpdate);
DetourTransactionCommit();
// if window is set to screen res, process that now so it can be used for auto internal res
if (nWidth == -1 || nHeight == -1)
{
nWidth = GetSystemMetrics(SM_CXSCREEN);
nHeight = GetSystemMetrics(SM_CYSCREEN);
}
if (nIntRes)
{
// if -1 use window resolution
if (nIntResWidth == -1 || nIntResHeight == -1)
{
nIntResWidth = nWidth;
nIntResHeight = nHeight;
}
printf("[Render] Custom internal resolution enabled\n");
printf("[Render] X: %d Y: %d\n", nIntResWidth, nIntResHeight);
{
DWORD oldProtect, bck;
VirtualProtect((BYTE*)0x00000001409B8B68, 4, PAGE_EXECUTE_READWRITE, &oldProtect);
*((int*)0x00000001409B8B68) = nIntResWidth;
VirtualProtect((BYTE*)0x00000001409B8B68, 6, oldProtect, &bck);
}
{
DWORD oldProtect, bck;
VirtualProtect((BYTE*)0x00000001409B8B6C, 4, PAGE_EXECUTE_READWRITE, &oldProtect);
*((int*)0x00000001409B8B6C) = nIntResHeight;
VirtualProtect((BYTE*)0x00000001409B8B6C, 6, oldProtect, &bck);
}
//*((int*)0x00000001409B8B6C) = maxHeight;
//*((int*)0x00000001409B8B14) = maxWidth;
//*((int*)0x00000001409B8B18) = maxHeight;
//*((int*)0x00000001409B8B1C) = maxWidth; // No parameters width?
//*((int*)0x00000001409B8B20) = maxHeight; // No parameters height?
}
}
return TRUE;
}
+1 -28
View File
@@ -127,37 +127,10 @@ namespace TLAC
void InitializeExtraSettings()
{
const LPCTSTR RESOLUTION_CONFIG_FILE_NAME = _T(".\\config.ini");
auto nCustomRes = GetPrivateProfileIntW(L"resolution", L"r.enable", FALSE, RESOLUTION_CONFIG_FILE_NAME);
auto nCustomWidth = GetPrivateProfileIntW(L"resolution", L"r.width", NULL, RESOLUTION_CONFIG_FILE_NAME);
auto nCustomHeight = GetPrivateProfileIntW(L"resolution", L"r.height", NULL, RESOLUTION_CONFIG_FILE_NAME);
auto nTAA = GetPrivateProfileIntW(L"graphics", L"taa", TRUE, RESOLUTION_CONFIG_FILE_NAME);
auto nMLAA = GetPrivateProfileIntW(L"graphics", L"mlaa", TRUE, RESOLUTION_CONFIG_FILE_NAME);
if (nCustomRes)
{
printf("[TLAC] Custom internal resolution enabled\n");
printf("[TLAC] X: %d Y: %d\n", nCustomWidth, nCustomHeight);
// Requires -wqhd launch parameter or Render.dva plugin
{
DWORD oldProtect, bck;
VirtualProtect((BYTE*)0x00000001409B8B68, 4, PAGE_EXECUTE_READWRITE, &oldProtect);
*((int*)0x00000001409B8B68) = nCustomWidth;
VirtualProtect((BYTE*)0x00000001409B8B68, 6, oldProtect, &bck);
}
{
DWORD oldProtect, bck;
VirtualProtect((BYTE*)0x00000001409B8B6C, 4, PAGE_EXECUTE_READWRITE, &oldProtect);
*((int*)0x00000001409B8B6C) = nCustomHeight;
VirtualProtect((BYTE*)0x00000001409B8B6C, 6, oldProtect, &bck);
}
//*((int*)0x00000001409B8B6C) = maxHeight;
//*((int*)0x00000001409B8B14) = maxWidth;
//*((int*)0x00000001409B8B18) = maxHeight;
//*((int*)0x00000001409B8B1C) = maxWidth; // No parameters width?
//*((int*)0x00000001409B8B20) = maxHeight; // No parameters height?
}
if (!nTAA)
{
{