Add console enabling option. Improved logs

This commit is contained in:
2025-11-29 22:09:41 +01:00
parent 237f185e81
commit 3c087d2d08

View File

@@ -27,6 +27,7 @@ std::shared_ptr<spdlog::logger> logger;
// Plugin states
static bool AOBScanDone = false;
static bool g_Console = false;
static bool g_fix_enabled = false;
static bool g_fov_fix_enabled = false;
static bool g_ultrawide_fix_enabled = false;
@@ -245,13 +246,13 @@ extern "C" __declspec(dllexport) void SetFixEnabled(bool enabled, bool init)
if (!init && Vignettingaddress) VignettingFixEnabled();
if (!init && Fogaddress) FogFixEnabled();
if (!init && VolumetricFogaddress) VolumetricFogFixEnabled();
HUDFixEnabled();
if (!init && GObjectsaddress && AppendStringaddress && ProcessEventaddress) EnableConsole();
}
// Setters for Reshade addon call
extern "C" __declspec(dllexport) void SetFixesEnabled(GameFixes fix, bool enabled)
{ // Set each fix individually
if (fix == GameFixes::DevConsole) EnableConsole();
if (fix == GameFixes::DevConsole) { g_Console = enabled; EnableConsole(); };
if (fix == GameFixes::FOV) { g_fov_fix_enabled = enabled; FOVFixEnabled(); }
if (fix == GameFixes::UltraWide) { g_ultrawide_fix_enabled = enabled; UltraWideFixEnabled(); }
if (fix == GameFixes::Camera) { g_Camera_fix_enabled = enabled; CameraFixEnabled(); }
@@ -457,20 +458,19 @@ static void VolumetricFogFixEnabled() {
// UE Console creation
static void EnableConsole()
{
logger->info("-------------- Console re-enabling --------------");
if (!GObjectsaddress || !AppendStringaddress || !ProcessEventaddress) {
//if (!GObjectsaddress || !GNamesaddress || !ProcessEventaddress) {
logger->warn("Could not re-enable console");
logger->info("------------------ User inputs ------------------");
if (g_Console_Enabled || !g_Console || !GObjectsaddress || !AppendStringaddress || !ProcessEventaddress) {
if (!g_Console && g_fix_enabled)
logger->info("------------------ User inputs ------------------");
return;
}
logger->info("-------------- Console re-enabling --------------");
std::thread([&]() {
auto start = std::chrono::high_resolution_clock::now(); // Measure the time to renable console
UEngine* Engine = nullptr;
for (int i = 0; i < 100; ++i) { // gives 10 seconds to find UE Engine
std::this_thread::sleep_for(std::chrono::milliseconds(100));
for (int i = 0; i < 10; ++i) { // gives 10 seconds to find UE Engine
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
Engine = UEngine::GetEngine();
if (Engine && Engine->ConsoleClass && Engine->GameViewport)
break;