From da998025463c156009fd237f1c4c548f615dece4 Mon Sep 17 00:00:00 2001 From: EricPlayZ Date: Thu, 9 May 2024 18:42:06 +0300 Subject: [PATCH] - Added "Lens Distortion" slider (Camera) - Fixed options that make use of player variables not returning back to their original value after disabling them - Added tooltips to sliders as well --- EGameTools/source/ImGui/imguiex.cpp | 12 +++++++++ EGameTools/source/ImGui/imguiex.h | 2 ++ EGameTools/source/changelog.h | 12 +++++---- EGameTools/source/config/config.cpp | 5 ++-- .../source/game/GamePH/PlayerVariables.h | 20 +++++++++----- EGameTools/source/game/GamePH/game_hooks.cpp | 2 +- EGameTools/source/menu/camera.cpp | 26 +++++++++++++++++-- EGameTools/source/menu/camera.h | 2 ++ EGameTools/source/menu/player.cpp | 7 ----- EGameTools/source/menu/player.h | 1 - EGameTools/source/menu/world.cpp | 12 +++------ 11 files changed, 68 insertions(+), 33 deletions(-) diff --git a/EGameTools/source/ImGui/imguiex.cpp b/EGameTools/source/ImGui/imguiex.cpp index 6deb04b..a521434 100644 --- a/EGameTools/source/ImGui/imguiex.cpp +++ b/EGameTools/source/ImGui/imguiex.cpp @@ -119,6 +119,18 @@ namespace ImGui { Hotkey(std::string(label + std::string("##ToggleKey")), v); return checkbox; } + bool SliderInt(const char* label, const char* tooltip, int* v, int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0) { + const bool sliderInt = SliderInt(label, v, v_min, v_max, format, flags); + if (tooltip) + SetItemTooltip(tooltip); + return sliderInt; + } + bool SliderFloat(const char* label, const char* tooltip, float* v, float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0) { + const bool sliderFloat = SliderFloat(label, v, v_min, v_max, format, flags); + if (tooltip) + SetItemTooltip(tooltip); + return sliderFloat; + } static const float CalculateIndentation(const float window_width, const float text_width, const float min_indentation) { const float indentation = (window_width - text_width) * 0.5f; return (indentation > min_indentation ? indentation : min_indentation); diff --git a/EGameTools/source/ImGui/imguiex.h b/EGameTools/source/ImGui/imguiex.h index 7d07d4d..27892ef 100644 --- a/EGameTools/source/ImGui/imguiex.h +++ b/EGameTools/source/ImGui/imguiex.h @@ -10,6 +10,8 @@ namespace ImGui { extern bool Checkbox(const char* label, Option* v); extern bool Checkbox(const char* label, Option* v, const char* tooltip); extern bool CheckboxHotkey(const char* label, KeyBindOption* v, const char* tooltip = nullptr); + extern bool SliderInt(const char* label, const char* tooltip, int* v, int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0); + extern bool SliderFloat(const char* label, const char* tooltip, float* v, float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0); extern void TextCentered(const char* text, const bool calculateWithScrollbar = true); extern void TextCenteredColored(const char* text, const ImU32 col, const bool calculateWithScrollbar = true); extern bool ButtonCentered(const char* label, const ImVec2 size = ImVec2(0.0f, 0.0f)); diff --git a/EGameTools/source/changelog.h b/EGameTools/source/changelog.h index 6b4a0a0..64a6034 100644 --- a/EGameTools/source/changelog.h +++ b/EGameTools/source/changelog.h @@ -58,21 +58,23 @@ Thank you everyone for the support <3)" }, - Added "Unlimited Stamina" (Player) - Added "Invisible to Enemies" (Player) - Added "Disable Air Control" (Player) -- Added "Disable Head Correction" (Player) - disables centering of the player's hands to the screen while jumping - Added "Allow Grapple Hook in Safezone" (Player) +- Added "Lens Distortion" slider (Camera) +- Added "Disable Head Correction" (Player) - disables centering of the player's hands to the center of the camera - Added "Increase Data PAKs Limit" (Misc; requires game restart to apply) - you can now add more than 8 data PAKs, e.g. data8.pak, data9.pak, data10.pak, etc, up to 200 PAKs in total - Added "Disable Data PAKs CRC Check" (Misc; requires game restart to apply) - stops the game from scanning data PAKs, which allows you to use data PAK mods in multiplayer as well - Added "Disable Savegame CRC Check" (Misc; requires game restart to apply) - stops the game from falsely saying your savegame is corrupt whenever you modify it -- Added tooltips when hovering over buttons inside the mod menu +- Added tooltips when hovering over buttons and sliders inside the mod menu - Fixed "God Mode" (Player) staying enabled after toggling FreeCam off -- Fixed player variables saving and loading using old version of player_variables.scr (which made Max Health drop to negative infinite) -- Fixed long paths to mods inside UserModFiles causing a game crash or causing the mods to not load at all - Fixed "God Mode" (Player) not working properly or at all in multiplayer +- Fixed blood overlay still displaying after falling from a great height with "God Mode" (Player) enabled - Fixed volatiles still being able to kill you when they jump on top of you while "God Mode" (Player) is enabled - Fixed "Disable Out of Bounds Timer" (Player) not working in missions +- Fixed player variables saving and loading using old version of player_variables.scr (which made Max Health drop to negative infinite) +- Fixed options that make use of player variables not returning back to their original value after disabling them - Fixed immunity drastically being lowered while rapidly changing the time forward with the "Time" slider (World) at night or while in a dark zone -- Fixed blood overlay still displaying after falling from a great height with "God Mode" (Player) enabled +- Fixed long paths to mods inside UserModFiles causing a game crash or causing the mods to not load at all - Changed the config system to only write to the config file whenever there's a change in the mod menu - Changed the way the mod menu gets the list of player variables, meaning the player variables list should self-update, with no manual intervention required even after a game update diff --git a/EGameTools/source/config/config.cpp b/EGameTools/source/config/config.cpp index f2ed1a7..faf747e 100644 --- a/EGameTools/source/config/config.cpp +++ b/EGameTools/source/config/config.cpp @@ -4351,13 +4351,13 @@ namespace Config { { "Menu:Keybinds", "OneHandedModeToggleKey", std::string("VK_NONE"), &Menu::Player::oneHandedMode, String}, { "Menu:Keybinds", "AllowGrappleHookInSafezoneToggleKey", std::string("VK_NONE"), &Menu::Player::allowGrappleHookInSafezone, String}, { "Menu:Keybinds", "DisableAirControlToggleKey", std::string("VK_NONE"), &Menu::Player::disableAirControl, String }, - { "Menu:Keybinds", "DisableHeadCorrectionToggleKey", std::string("VK_NONE"), &Menu::Player::disableHeadCorrection, String }, { "Menu:Keybinds", "FreeCamToggleKey", std::string("VK_F3"), &Menu::Camera::freeCam, String}, { "Menu:Keybinds", "TeleportPlayerToCameraToggleKey", std::string("VK_F4"), &Menu::Camera::teleportPlayerToCamera, String}, { "Menu:Keybinds", "ThirdPersonToggleKey", std::string("VK_F1"), &Menu::Camera::thirdPersonCamera, String}, { "Menu:Keybinds", "UseTPPModelToggleKey", std::string("VK_F2"), &Menu::Camera::tpUseTPPModel, String}, { "Menu:Keybinds", "DisablePhotoModeLimits", std::string("VK_NONE"), &Menu::Camera::disablePhotoModeLimits, String}, { "Menu:Keybinds", "DisableSafezoneFOVReduction", std::string("VK_NONE"), &Menu::Camera::disableSafezoneFOVReduction, String}, + { "Menu:Keybinds", "DisableHeadCorrectionToggleKey", std::string("VK_NONE"), &Menu::Camera::disableHeadCorrection, String }, { "Menu:Keybinds", "DisableHUDToggleKey", std::string("VK_F8"), &Menu::Misc::disableHUD, String}, { "Menu:Keybinds", "DisableGamePauseWhileAFKToggleKey", std::string("VK_NONE"), &Menu::Misc::disableGamePauseWhileAFK, String}, { "Menu:Keybinds", "FreezeTimeToggleKey", std::string("VK_NONE"), &Menu::World::freezeTime, String}, @@ -4371,7 +4371,6 @@ namespace Config { { "Player:Misc", "OneHandedMode", false, &Menu::Player::oneHandedMode, OPTION }, { "Player:Misc", "AllowGrappleHookInSafezone", false, &Menu::Player::allowGrappleHookInSafezone, OPTION }, { "Player:PlayerJumpParameters", "DisableAirControl", false, &Menu::Player::disableAirControl, OPTION }, - { "Player:PlayerJumpParameters", "DisableHeadCorrection", false, &Menu::Player::disableHeadCorrection, OPTION }, { "Player:PlayerVariables", "Enabled", false, &Menu::Player::playerVariables, OPTION }, { "Player:PlayerVariables", "LastSaveSCRPath", std::string(), &Menu::Player::saveSCRPath, String }, { "Player:PlayerVariables", "LastLoadSCRFilePath", std::string(), &Menu::Player::loadSCRFilePath, String }, @@ -4382,8 +4381,10 @@ namespace Config { { "Camera:ThirdPerson", "DistanceBehindPlayer", 2.0f, &Menu::Camera::tpDistanceBehindPlayer, Float }, { "Camera:ThirdPerson", "HeightAbovePlayer", 1.35f, &Menu::Camera::tpHeightAbovePlayer, Float }, { "Camera:ThirdPerson", "HorizontalDistanceFromPlayer", 0.0f, &Menu::Camera::tpHorizontalDistanceFromPlayer, Float }, + { "Camera:Misc", "LensDistortion", 20.0f, &Menu::Camera::lensDistortion, Float }, { "Camera:Misc", "DisablePhotoModeLimits", true, &Menu::Camera::disablePhotoModeLimits, OPTION }, { "Camera:Misc", "DisableSafezoneFOVReduction", true, &Menu::Camera::disableSafezoneFOVReduction, OPTION }, + { "Camera:Misc", "DisableHeadCorrection", false, &Menu::Camera::disableHeadCorrection, OPTION }, { "Misc:Misc", "DisableGamePauseWhileAFK", true, &Menu::Misc::disableGamePauseWhileAFK, OPTION }, { "Misc:Misc", "DisableSavegameCRCCheck", true, &Menu::Misc::disableSavegameCRCCheck, OPTION }, { "Misc:Misc", "DisableDataPAKsCRCCheck", true, &Menu::Misc::disableDataPAKsCRCCheck, OPTION }, diff --git a/EGameTools/source/game/GamePH/PlayerVariables.h b/EGameTools/source/game/GamePH/PlayerVariables.h index 38cb65e..ad56168 100644 --- a/EGameTools/source/game/GamePH/PlayerVariables.h +++ b/EGameTools/source/game/GamePH/PlayerVariables.h @@ -85,17 +85,23 @@ namespace GamePH { if (!gotPlayerVars) return; - static T previousPlayerVarValue = GamePH::PlayerVariables::GetPlayerVar(playerVar); + static std::unordered_map prevPlayerVarValueMap; + static std::unordered_map prevOptionValueMap; + + if (prevPlayerVarValueMap.find(playerVar) == prevPlayerVarValueMap.end()) + prevPlayerVarValueMap[playerVar] = GamePH::PlayerVariables::GetPlayerVar(playerVar); + if (prevOptionValueMap.find(playerVar) == prevOptionValueMap.end()) + prevOptionValueMap[playerVar] = false; if (option->GetValue()) { - if (!option->GetPrevValue()) - previousPlayerVarValue = GamePH::PlayerVariables::GetPlayerVar(playerVar); + if (!prevOptionValueMap[playerVar]) + prevPlayerVarValueMap[playerVar] = GamePH::PlayerVariables::GetPlayerVar(playerVar); GamePH::PlayerVariables::ChangePlayerVar(playerVar, valueIfTrue); - option->SetPrevValue(true); - } else if (option->GetPrevValue()) { - option->SetPrevValue(false); - GamePH::PlayerVariables::ChangePlayerVar(playerVar, usePreviousVal ? previousPlayerVarValue : valueIfFalse); + prevOptionValueMap[playerVar] = true; + } else if (prevOptionValueMap[playerVar]) { + prevOptionValueMap[playerVar] = false; + GamePH::PlayerVariables::ChangePlayerVar(playerVar, usePreviousVal ? prevPlayerVarValueMap[playerVar] : valueIfFalse); } } diff --git a/EGameTools/source/game/GamePH/game_hooks.cpp b/EGameTools/source/game/GamePH/game_hooks.cpp index 1a68930..77478dd 100644 --- a/EGameTools/source/game/GamePH/game_hooks.cpp +++ b/EGameTools/source/game/GamePH/game_hooks.cpp @@ -247,7 +247,7 @@ namespace GamePH { if (Menu::Player::disableAirControl.GetValue()) *reinterpret_cast(a1 + Offsets::Get_allowVelocityMod_offset()) = false; - if (Menu::Player::disableHeadCorrection.GetValue()) + if (Menu::Camera::disableHeadCorrection.GetValue()) *reinterpret_cast(a1 + Offsets::Get_disableHeadCorrection_offset()) = true; return result; diff --git a/EGameTools/source/menu/camera.cpp b/EGameTools/source/menu/camera.cpp index f0ede3a..ecb1333 100644 --- a/EGameTools/source/menu/camera.cpp +++ b/EGameTools/source/menu/camera.cpp @@ -28,8 +28,11 @@ namespace Menu { float tpHeightAbovePlayer = 1.35f; float tpHorizontalDistanceFromPlayer = 0.0f; + float lensDistortion = 20.0f; KeyBindOption disablePhotoModeLimits{ VK_NONE }; KeyBindOption disableSafezoneFOVReduction{ VK_NONE }; + KeyBindOption disableHeadCorrection{ VK_NONE }; + float baseSprintHeadCorrectionFactor = 0.55f; static constexpr int baseFOV = 57; static constexpr float baseSafezoneFOVReduction = -10.0f; @@ -138,7 +141,17 @@ namespace Menu { if (!GamePH::PlayerVariables::gotPlayerVars) return; - GamePH::PlayerVariables::ManagePlayerVarOption("CameraDefaultFOVReduction", 0.0f, baseSafezoneFOVReduction, &disableSafezoneFOVReduction); + static bool gotDefaultVal = false; + if (!gotDefaultVal) { + lensDistortion = GamePH::PlayerVariables::GetPlayerVar("FOVCorrection") * 100.0f; + gotDefaultVal = true; + } + + GamePH::PlayerVariables::ManagePlayerVarOption("CameraDefaultFOVReduction", 0.0f, baseSafezoneFOVReduction, &disableSafezoneFOVReduction, true); + + GamePH::PlayerVariables::ChangePlayerVar("FOVCorrection", lensDistortion / 100.0f); + + GamePH::PlayerVariables::ManagePlayerVarOption("SprintHeadCorrectionFactor", 0.0f, baseSprintHeadCorrectionFactor, &disableHeadCorrection, true); } static void UpdateDisabledOptions() { GamePH::LevelDI* iLevel = GamePH::LevelDI::Get(); @@ -147,6 +160,12 @@ namespace Menu { thirdPersonCamera.SetChangesAreDisabled(freeCam.GetValue() || photoMode.GetValue()); tpUseTPPModel.SetChangesAreDisabled(freeCam.GetValue() || photoMode.GetValue()); } + static void HandleToggles() { + if (disableHeadCorrection.HasChanged()) { + disableHeadCorrection.SetPrevValue(disableHeadCorrection.GetValue()); + GamePH::ReloadJumps(); + } + } Tab Tab::instance{}; void Tab::Update() { @@ -155,6 +174,7 @@ namespace Menu { UpdateTPPModel(); UpdatePlayerVars(); UpdateDisabledOptions(); + HandleToggles(); } void Tab::Render() { ImGui::SeparatorText("Free Camera"); @@ -186,14 +206,16 @@ namespace Menu { ImGui::SeparatorText("Misc"); Engine::CVideoSettings* pCVideoSettings = Engine::CVideoSettings::Get(); ImGui::BeginDisabled(!pCVideoSettings); { - if (ImGui::SliderInt("FOV", &FOV, 20, 160) && pCVideoSettings) + if (ImGui::SliderInt("FOV", "Camera Field of View", &FOV, 20, 160) && pCVideoSettings) pCVideoSettings->extraFOV = static_cast(FOV - baseFOV); else if (pCVideoSettings) FOV = static_cast(pCVideoSettings->extraFOV) + baseFOV; ImGui::EndDisabled(); } + ImGui::SliderFloat("Lens Distortion", "Default game value is 20%", &lensDistortion, 0.0f, 100.0f, "%.1f%%"); ImGui::CheckboxHotkey("Disable Photo Mode Limits", &disablePhotoModeLimits, "Disables the invisible box while in Photo Mode"); ImGui::CheckboxHotkey("Disable Safezone FOV Reduction", &disableSafezoneFOVReduction, "Disables the FOV reduction that happens while you're in a safezone"); + ImGui::CheckboxHotkey("Disable Head Correction", &disableHeadCorrection, "Disables centering of the player's hands to the center of the camera"); } } } \ No newline at end of file diff --git a/EGameTools/source/menu/camera.h b/EGameTools/source/menu/camera.h index a281f5a..c9f1783 100644 --- a/EGameTools/source/menu/camera.h +++ b/EGameTools/source/menu/camera.h @@ -18,8 +18,10 @@ namespace Menu { extern float tpHeightAbovePlayer; extern float tpHorizontalDistanceFromPlayer; + extern float lensDistortion; extern KeyBindOption disablePhotoModeLimits; extern KeyBindOption disableSafezoneFOVReduction; + extern KeyBindOption disableHeadCorrection; class Tab : MenuTab { public: diff --git a/EGameTools/source/menu/player.cpp b/EGameTools/source/menu/player.cpp index c181da3..ce042ad 100644 --- a/EGameTools/source/menu/player.cpp +++ b/EGameTools/source/menu/player.cpp @@ -6445,7 +6445,6 @@ namespace Menu { KeyBindOption oneHandedMode{ VK_NONE }; KeyBindOption allowGrappleHookInSafezone{ VK_NONE }; KeyBindOption disableAirControl{ VK_NONE }; - KeyBindOption disableHeadCorrection{ VK_NONE }; Option playerVariables{}; std::string saveSCRPath{}; @@ -6599,10 +6598,6 @@ namespace Menu { disableAirControl.SetPrevValue(disableAirControl.GetValue()); GamePH::ReloadJumps(); } - if (disableHeadCorrection.HasChanged()) { - disableHeadCorrection.SetPrevValue(disableHeadCorrection.GetValue()); - GamePH::ReloadJumps(); - } } Tab Tab::instance{}; @@ -6934,8 +6929,6 @@ namespace Menu { ImGui::SeparatorText("Player Jump Parameters"); ImGui::CheckboxHotkey("Disable Air Control", &disableAirControl, "Disables the ability to change the player's direction of momentum while jumping (in-air)"); - ImGui::SameLine(); - ImGui::CheckboxHotkey("Disable Head Correction", &disableHeadCorrection, "Disables centering of the player's hands to the screen while jumping"); if (ImGui::Button("Reload Jump Params", "Reloads jump_parameters.scr from any mod located inside EGameTools\\UserModFiles")) { if (Utils::Files::FileExistsInDir("jump_parameters.scr", "EGameTools\\UserModFiles")) { GamePH::ReloadJumps(); diff --git a/EGameTools/source/menu/player.h b/EGameTools/source/menu/player.h index fba72ba..257247e 100644 --- a/EGameTools/source/menu/player.h +++ b/EGameTools/source/menu/player.h @@ -18,7 +18,6 @@ namespace Menu { extern KeyBindOption oneHandedMode; extern KeyBindOption allowGrappleHookInSafezone; extern KeyBindOption disableAirControl; - extern KeyBindOption disableHeadCorrection; extern Option playerVariables; extern std::string saveSCRPath; diff --git a/EGameTools/source/menu/world.cpp b/EGameTools/source/menu/world.cpp index 4bd4b09..0c0ec71 100644 --- a/EGameTools/source/menu/world.cpp +++ b/EGameTools/source/menu/world.cpp @@ -85,11 +85,11 @@ namespace Menu { } } - if (!menuToggle.GetValue()) { - time = dayNightCycle->time1 * 24.0f; - if (freezeTime.GetValue() && !Utils::Values::are_samef(time, timeBeforeFreeze, 0.0095f)) - dayNightCycle->SetDaytime(timeBeforeFreeze); + time = dayNightCycle->time1 * 24.0f; + if (freezeTime.GetValue() && !Utils::Values::are_samef(time, timeBeforeFreeze, 0.0095f)) + dayNightCycle->SetDaytime(timeBeforeFreeze); + if (!menuToggle.GetValue()) { if (!slowMotion.GetValue() && !slowMotion.HasChanged() && !Utils::Values::are_samef(gameSpeed, 1.0f)) iLevel->TimerSetSpeedUp(gameSpeed); actualGameSpeed = iLevel->TimerGetSpeedUp(); @@ -116,10 +116,6 @@ namespace Menu { GamePH::PlayerVariables::ChangePlayerVar("AntizinDrainBlocked", previousAntizinDrainBlocked); haveResetAntizinDrainBlocked = true; } - - time = dayNightCycle->time1 * 24.0f; - if (freezeTime.GetValue() && !Utils::Values::are_samef(time, timeBeforeFreeze, 0.0095f)) - dayNightCycle->SetDaytime(timeBeforeFreeze); } ImGui::BeginDisabled(slowMotion.GetValue()); {