Add console creation and improved ultrawide

This commit is contained in:
2025-09-03 12:10:43 +02:00
parent 8c8fce42cf
commit 9239cec550

View File

@@ -5,6 +5,7 @@
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
#include <spdlog/sinks/rotating_file_sink.h> #include <spdlog/sinks/rotating_file_sink.h>
#include <filesystem> #include <filesystem>
#include <thread>
#include <safetyhook.hpp> #include <safetyhook.hpp>
#include "SDK/Basic.hpp" #include "SDK/Basic.hpp"
#include "SDK/Engine_classes.hpp" #include "SDK/Engine_classes.hpp"
@@ -20,6 +21,9 @@ const float baseAspect = 1.777777791;
// Logger // Logger
std::shared_ptr<spdlog::logger> logger; std::shared_ptr<spdlog::logger> logger;
// UE console
static bool consoleCreated = false;
// Screen informations // Screen informations
static int screenWidth = GetSystemMetrics(SM_CXSCREEN); static int screenWidth = GetSystemMetrics(SM_CXSCREEN);
static int screenHeight = GetSystemMetrics(SM_CYSCREEN); static int screenHeight = GetSystemMetrics(SM_CYSCREEN);
@@ -77,6 +81,7 @@ static void DOFFixEnabled(bool fix_enabled);
static void CAFixEnabled(bool fix_enabled); static void CAFixEnabled(bool fix_enabled);
static void VignettingFixEnabled(bool fix_enabled); static void VignettingFixEnabled(bool fix_enabled);
static void FogFixEnabled(bool fix_enabled); static void FogFixEnabled(bool fix_enabled);
static void EnableConsole();
uint8_t* basePtr = reinterpret_cast<uint8_t*>(GetModuleHandleA(nullptr)); uint8_t* basePtr = reinterpret_cast<uint8_t*>(GetModuleHandleA(nullptr));
@@ -266,6 +271,8 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
if (Fogaddress) FogFixEnabled(false); if (Fogaddress) FogFixEnabled(false);
logger->info("All fixes disabled."); logger->info("All fixes disabled.");
} }
if (AOBScanDone)
EnableConsole();
} }
// Setters for Reshade addon calls // Setters for Reshade addon calls
@@ -350,6 +357,7 @@ static void FOVFixEnabled(bool fix_enabled) {
}); });
} }
else FOVHook.enable(); else FOVHook.enable();
logger->info("FOV fix enabled"); logger->info("FOV fix enabled");
} }
if (!fix_enabled) { if (!fix_enabled) {
@@ -413,9 +421,11 @@ static void AspectFixEnabled(bool fix_enabled) {
auto obj = reinterpret_cast<UObject*>(ctx.rbx); auto obj = reinterpret_cast<UObject*>(ctx.rbx);
constexpr auto PauseBackScreenStringObfuscated = make_obfuscated<0x4A>("WP_PauseBackScreen"); constexpr auto PauseBackScreenStringObfuscated = make_obfuscated<0x4A>("WP_PauseBackScreen");
const char* pauseBackScreen = PauseBackScreenStringObfuscated.decrypt().c_str(); auto decrypted = PauseBackScreenStringObfuscated.decrypt();
if (!decrypted.empty() && decrypted.back() == '\0')
decrypted.pop_back();
if (obj->GetName().contains(pauseBackScreen)) if (obj->GetName().find(decrypted) != std::string::npos)
ctx.xmm0.f64[0] = static_cast<double>(aspectRatio); ctx.xmm0.f64[0] = static_cast<double>(aspectRatio);
}); });
} }
@@ -475,6 +485,38 @@ static void FogFixEnabled(bool fix_enabled) {
} }
} }
// UE Console creation
static void EnableConsole()
{
std::thread([&]() {
UEngine* Engine = nullptr;
for (int i = 0; i < 100; ++i) { // gives 10 seconds to recreate console
std::this_thread::sleep_for(std::chrono::milliseconds(100));
Engine = UEngine::GetEngine();
if (Engine && Engine->ConsoleClass && Engine->GameViewport)
break;
}
if (!Engine || !Engine->ConsoleClass || !Engine->GameViewport)
return;
/* Creates a new UObject of class-type specified by Engine->ConsoleClass */
UObject* NewObject = UGameplayStatics::SpawnObject(Engine->ConsoleClass, Engine->GameViewport);
if (NewObject)
{
// Set the console viewport so that it will be displayed
Engine->GameViewport->ViewportConsole = static_cast<UConsole*>(NewObject);
// Set the all the console shortkey to F8
for (int i = 0; i < UInputSettings::GetDefaultObj()->ConsoleKeys.Num(); i++)
{
UInputSettings::GetDefaultObj()->ConsoleKeys[i].KeyName = UKismetStringLibrary::Conv_StringToName(L"F8");
}
}
}).detach();
}
// Logging
static void InitializeLogger() static void InitializeLogger()
{ {
try try