Add new cheats. Code refactoring
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
#define IMGUI_DISABLE_INCLUDE_IMCONFIG_H
|
||||
#define IMGUI_HAS_DOCK 1
|
||||
|
||||
#include "ImGuiWidgets.h"
|
||||
#include "GameInformations.h"
|
||||
#include "GameFixes.h"
|
||||
#include "HotkeysManager.h"
|
||||
#include "OSDManager.h"
|
||||
#include "inicpp.h"
|
||||
#include <imgui.h>
|
||||
#include <reshade.hpp>
|
||||
@@ -23,8 +26,10 @@ typedef void (*SetFloatFn)(float);
|
||||
|
||||
static HMODULE fixLib = nullptr;
|
||||
static LONG g_coreInitialized = 0;
|
||||
static LONG g_hotkeysInitialized = 0;
|
||||
static LONG g_uniformReseted = 0;
|
||||
static SetBoolFn SetFixEnabled = nullptr;
|
||||
static SetFixesFn SetFixesEnabled = nullptr;
|
||||
static SetFixesFn SetFixes = nullptr;
|
||||
static SetIntFn SetFOV = nullptr;
|
||||
static SetIntFn SetHUDScale = nullptr;
|
||||
static SetIntFn SetCameraOffset = nullptr;
|
||||
@@ -33,6 +38,11 @@ static SetFloatFn SetAITimeDilation = nullptr;
|
||||
static SetFloatFn SetCameraSmoothness = nullptr;
|
||||
static GetGameInfosStruct GetGameInfos = nullptr;
|
||||
|
||||
void SetFixesEnabled(GameFixes fix, bool value) {
|
||||
if (SetFixes) SetFixes(fix, value);
|
||||
}
|
||||
|
||||
bool toto;
|
||||
// Plugin variables for checkboxes and sliders
|
||||
static bool fov_fix_enabled = false;
|
||||
static bool Camera_fix_enabled = false;
|
||||
@@ -41,6 +51,8 @@ static bool CA_fix_enabled = false;
|
||||
static bool Vignetting_fix_enabled = false;
|
||||
static bool Fog_fix_enabled = false;
|
||||
static bool Time_Dilation_fix_enabled = false;
|
||||
static bool GodMode_fix_enabled = false;
|
||||
static bool Ignore_hits_fix_enabled = false;
|
||||
static bool fix_enabled = false;
|
||||
static bool console = true;
|
||||
static int worldFOVValue = 0;
|
||||
@@ -56,16 +68,21 @@ static bool popup_Informations = false;
|
||||
static bool show_log_overlay = false;
|
||||
static std::string log_content;
|
||||
|
||||
// Shader toggles
|
||||
// Shader toggles and variables
|
||||
static reshade::api::effect_uniform_variable u_td_show = {};
|
||||
static reshade::api::effect_uniform_variable u_td_enabled = {};
|
||||
static reshade::api::effect_uniform_variable u_td_world = {};
|
||||
static reshade::api::effect_uniform_variable u_td_AI = {};
|
||||
static reshade::api::effect_uniform_variable u_GodMode_show = {};
|
||||
static reshade::api::effect_uniform_variable u_GodMode_enabled = {};
|
||||
static reshade::api::effect_uniform_variable u_Invulnerability_show = {};
|
||||
static reshade::api::effect_uniform_variable u_Invulnerability_enabled = {};
|
||||
constexpr auto OSD_SHADER_NAME = "OSD.fx";
|
||||
|
||||
// Plugin settings
|
||||
const std::string SETTINGS_FILE = "./pluginsettings.ini";
|
||||
const char* FIX_VERSION = "0.9.5";
|
||||
const char* FIX_INFORMATIONS = "This fix allows to:\n - Control FOV in game.\n - Control camera distance.\n - Control HUD scaling.\n - Control time dilation.\n - Disable chromatic aberrations.\n - Disable vignetting.\n - Disable fog.\n - Re enable dev console.";
|
||||
const char* FIX_VERSION = "0.9.6";
|
||||
const char* FIX_INFORMATIONS = "This fix allows to:\n - Control FOV in game.\n - Control camera distance.\n - Control HUD scaling.\n - Enable cheats.\n - Disable chromatic aberrations.\n - Disable vignetting.\n - Disable fog.\n - Re enable dev console.";
|
||||
const char* DONATION_URL = "https://buymeacoffee.com/k4sh44";
|
||||
|
||||
// Scaling factor based on screen resolution
|
||||
@@ -73,7 +90,10 @@ float scale = (float)screenHeight / 1200;
|
||||
|
||||
// Plugin sig
|
||||
extern "C" __declspec(dllexport) const char* NAME = "The Callisto Protocol";
|
||||
extern "C" __declspec(dllexport) const char* DESCRIPTION = "Reshade addon to re-enable console, control FOV, camera distance, time dilation, HUD and some effects.";
|
||||
extern "C" __declspec(dllexport) const char* DESCRIPTION = "Reshade addon to re-enable console, control FOV, camera distance, HUD, some effects and enable cheats.";
|
||||
|
||||
// UI sliders
|
||||
static SliderFix sliders[6];
|
||||
|
||||
// Load and unload game core dll functions /!\ necessary
|
||||
static void LoadFixDLL()
|
||||
@@ -91,7 +111,7 @@ static void LoadFixDLL()
|
||||
}
|
||||
|
||||
SetFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFixEnabled");
|
||||
SetFixesEnabled = (SetFixesFn)GetProcAddress(fixLib, "SetFixesEnabled");
|
||||
SetFixes = (SetFixesFn)GetProcAddress(fixLib, "SetFixesEnabled");
|
||||
SetFOV = (SetIntFn)GetProcAddress(fixLib, "SetFOV");
|
||||
SetHUDScale = (SetIntFn)GetProcAddress(fixLib, "SetHUDScale");
|
||||
SetCameraOffset = (SetIntFn)GetProcAddress(fixLib, "SetCameraOffset");
|
||||
@@ -108,22 +128,34 @@ static void LoadFixDLL()
|
||||
if (SetAITimeDilation) SetAITimeDilation(AITimeDilationValue);
|
||||
if (SetCameraSmoothness) SetCameraSmoothness(cameraSmoothnessValue);
|
||||
if (SetFixEnabled) SetFixEnabled(fix_enabled, true);
|
||||
if (SetFixesEnabled) {
|
||||
SetFixesEnabled(GameFixes::FOV, fov_fix_enabled);
|
||||
SetFixesEnabled(GameFixes::Camera, Camera_fix_enabled);
|
||||
SetFixesEnabled(GameFixes::HUD, HUD_fix_enabled);
|
||||
SetFixesEnabled(GameFixes::ChromaticAberrations, CA_fix_enabled);
|
||||
SetFixesEnabled(GameFixes::Vignetting, Vignetting_fix_enabled);
|
||||
SetFixesEnabled(GameFixes::Fog, Fog_fix_enabled);
|
||||
SetFixesEnabled(GameFixes::WorldTimeDilation, Time_Dilation_fix_enabled);
|
||||
SetFixesEnabled(GameFixes::DevConsole, console);
|
||||
if (SetFixes) {
|
||||
SetFixes(GameFixes::FOV, fov_fix_enabled);
|
||||
SetFixes(GameFixes::Camera, Camera_fix_enabled);
|
||||
SetFixes(GameFixes::HUD, HUD_fix_enabled);
|
||||
SetFixes(GameFixes::ChromaticAberrations, CA_fix_enabled);
|
||||
SetFixes(GameFixes::Vignetting, Vignetting_fix_enabled);
|
||||
SetFixes(GameFixes::Fog, Fog_fix_enabled);
|
||||
SetFixes(GameFixes::TimeDilation, Time_Dilation_fix_enabled);
|
||||
SetFixes(GameFixes::GodMode, GodMode_fix_enabled);
|
||||
SetFixes(GameFixes::Invulnerable, Ignore_hits_fix_enabled);
|
||||
SetFixes(GameFixes::DevConsole, console);
|
||||
}
|
||||
|
||||
// Declare sliders only when function pointers are initilized (SetFOV ...)
|
||||
sliders[0] = { "In game additional FOV", "##FOVValue", SliderType::Int, &worldFOVValue, -20, 50, SetFOV };
|
||||
sliders[1] = { "Camera offset (*)", "##CameraOffset", SliderType::Int, &cameraOffsetValue, 0, 200, SetCameraOffset, nullptr, "Value is in cms." };
|
||||
sliders[2] = { "HUD scaling", "##HUDScale", SliderType::Int, &HUDScaleValue, 0, 40, SetHUDScale };
|
||||
sliders[3] = { "Camera smoothness (*)", "##CameraSmoothnessValue", SliderType::Float, &cameraSmoothnessValue, 2.f, 10.f, SetCameraSmoothness, "%.2f",
|
||||
"The higher the value, the quicker the camera transition is." };
|
||||
sliders[4] = { "World time dilation", "##WorldTimeDilationValue", SliderType::Float, &worldTimeDilationValue, 0.f, 2.f, SetWorldTimeDilation, nullptr,
|
||||
"Will affect everything in the world.\nDefault value is 1." };
|
||||
sliders[5] = { "AI time dilation", "##AITimeDilationValue", SliderType::Float, &AITimeDilationValue, 0.f, 2.f, SetAITimeDilation, nullptr,
|
||||
"Will affect only enemies in the world.\nDefault value is 1." };
|
||||
}
|
||||
}
|
||||
|
||||
// Settings functions
|
||||
static void SaveSettings()
|
||||
{
|
||||
static void SaveSettings() {
|
||||
ini::IniFile pluginIniFile;
|
||||
pluginIniFile["1#General fix"].setComment(std::vector<std::string>{ "The following sections are saved by plugin",
|
||||
"You should not need to modify them",
|
||||
@@ -141,6 +173,8 @@ static void SaveSettings()
|
||||
pluginIniFile["2#Individual fix"]["Vignetting"] = Vignetting_fix_enabled;
|
||||
pluginIniFile["2#Individual fix"]["Fog"] = Fog_fix_enabled;
|
||||
pluginIniFile["2#Individual fix"]["Time dilation"] = Time_Dilation_fix_enabled;
|
||||
pluginIniFile["2#Individual fix"]["God Mode"] = GodMode_fix_enabled;
|
||||
pluginIniFile["2#Individual fix"]["Ignore hits"] = Ignore_hits_fix_enabled;
|
||||
pluginIniFile["3#Fixes tuning"].setComment("Individual fix fine tune");
|
||||
pluginIniFile["3#Fixes tuning"]["World FOV"] = worldFOVValue;
|
||||
pluginIniFile["3#Fixes tuning"]["HUD scale"] = HUDScaleValue;
|
||||
@@ -152,8 +186,7 @@ static void SaveSettings()
|
||||
pluginIniFile.save(SETTINGS_FILE);
|
||||
}
|
||||
|
||||
static void LoadSettings()
|
||||
{
|
||||
static void LoadSettings() {
|
||||
ini::IniFile pluginIniFile;
|
||||
try {
|
||||
pluginIniFile.load(SETTINGS_FILE);
|
||||
@@ -167,6 +200,8 @@ static void LoadSettings()
|
||||
Vignetting_fix_enabled = pluginIniFile["2#Individual fix"]["Vignetting"].as<bool>();
|
||||
Fog_fix_enabled = pluginIniFile["2#Individual fix"]["Fog"].as<bool>();
|
||||
Time_Dilation_fix_enabled = pluginIniFile["2#Individual fix"]["Time dilation"].as<bool>();
|
||||
GodMode_fix_enabled = pluginIniFile["2#Individual fix"]["God Mode"].as<bool>();
|
||||
Ignore_hits_fix_enabled = pluginIniFile["2#Individual fix"]["Ignore hits"].as<bool>();
|
||||
worldFOVValue = pluginIniFile["3#Fixes tuning"]["World FOV"].as<int>();
|
||||
HUDScaleValue = pluginIniFile["3#Fixes tuning"]["HUD scale"].as<int>();
|
||||
cameraOffsetValue = pluginIniFile["3#Fixes tuning"]["Camera offset"].as<float>();
|
||||
@@ -191,10 +226,25 @@ static std::string read_log_file(const std::string& filename) {
|
||||
log = ss.str();
|
||||
return log;
|
||||
}
|
||||
// Prepare arrays of checkboxes for ImGui
|
||||
static FixToggle individualFixes[] = {
|
||||
{ "FOV", &fov_fix_enabled, GameFixes::FOV },
|
||||
{ "Fog", &Fog_fix_enabled, GameFixes::Fog },
|
||||
{ "Vignetting", &Vignetting_fix_enabled, GameFixes::Vignetting },
|
||||
{ "Camera distance", &Camera_fix_enabled, GameFixes::Camera,
|
||||
"Experimental fix. Use at your own risk." },
|
||||
{ "HUD scaling", &HUD_fix_enabled, GameFixes::HUD },
|
||||
{ "Chromatic aberrations", &CA_fix_enabled, GameFixes::ChromaticAberrations }
|
||||
};
|
||||
|
||||
static FixToggle cheatFixes[] = {
|
||||
{ "Time dilation", &Time_Dilation_fix_enabled, GameFixes::TimeDilation, "ALT + F1 to toggle" },
|
||||
{ "God mode", &GodMode_fix_enabled, GameFixes::GodMode, "ALT + F2 to toggle.\nJacob won't receive any damage." },
|
||||
{ "Ignore hits", &Ignore_hits_fix_enabled, GameFixes::Invulnerable, "ALT + F3 to toggle.\nJacob can't be hit." }
|
||||
};
|
||||
|
||||
// Initialize ImGui widgets for Reshade
|
||||
static void on_overlay_draw(reshade::api::effect_runtime* runtime)
|
||||
{
|
||||
static void on_overlay_draw(reshade::api::effect_runtime* runtime) {
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
style.ItemSpacing = ImVec2(8 * scale, 8 * scale); // Spacing between widgets
|
||||
style.FramePadding = ImVec2(3 * scale, 3 * scale); // Widgets padding
|
||||
@@ -217,16 +267,14 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
|
||||
show_log_overlay = true; // Fix information
|
||||
}
|
||||
|
||||
if (popup_Informations)
|
||||
{
|
||||
if (popup_Informations) {
|
||||
ImGui::Begin("Informations", &popup_Informations, ImGuiWindowFlags_AlwaysAutoResize);
|
||||
ImGui::Text("Version : %s", FIX_VERSION);
|
||||
ImGui::Text(FIX_INFORMATIONS);
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
if (show_log_overlay)
|
||||
{
|
||||
if (show_log_overlay) {
|
||||
ImGui::Begin("Game log", &show_log_overlay, ImGuiWindowFlags_AlwaysAutoResize);
|
||||
ImGui::TextUnformatted(log_content.c_str());
|
||||
ImGui::End();
|
||||
@@ -257,41 +305,9 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
|
||||
ImGui::TableNextRow();
|
||||
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
if (ImGui::Checkbox("FOV", &fov_fix_enabled)) {
|
||||
if (SetFixesEnabled) SetFixesEnabled(GameFixes::FOV, fov_fix_enabled);
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox("Fog", &Fog_fix_enabled)) {
|
||||
if (SetFixesEnabled) SetFixesEnabled(GameFixes::Fog, Fog_fix_enabled);
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox("Vignetting", &Vignetting_fix_enabled)) {
|
||||
if (SetFixesEnabled) SetFixesEnabled(GameFixes::Vignetting, Vignetting_fix_enabled);
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; ++i) DrawFixCheckbox(individualFixes[i]);
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
if (ImGui::Checkbox("Camera distance", &Camera_fix_enabled)) {
|
||||
if (SetFixesEnabled) SetFixesEnabled(GameFixes::Camera, Camera_fix_enabled);
|
||||
SaveSettings();
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Text("Experimental fix. Use at your own risk.");
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox("HUD scaling", &HUD_fix_enabled)) {
|
||||
if (SetFixesEnabled) SetFixesEnabled(GameFixes::HUD, HUD_fix_enabled);
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox("Chromatic aberrations", &CA_fix_enabled)) {
|
||||
if (SetFixesEnabled) SetFixesEnabled(GameFixes::ChromaticAberrations, CA_fix_enabled);
|
||||
SaveSettings();
|
||||
}
|
||||
for (int i = 3; i < IM_ARRAYSIZE(individualFixes); ++i) DrawFixCheckbox(individualFixes[i]);
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
@@ -305,50 +321,9 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
|
||||
ImGui::TableNextRow();
|
||||
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
if (ImGui::CollapsingHeader("In game additional FOV", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
ImGui::SetNextItemWidth(180 * scale);
|
||||
if (ImGui::SliderInt("##FOVValue", &worldFOVValue, -20, 50)) {
|
||||
if (SetFOV) SetFOV(worldFOVValue);
|
||||
SaveSettings();
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::CollapsingHeader("Camera offset (*)", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
ImGui::SetNextItemWidth(200 * scale);
|
||||
if (ImGui::SliderInt("##CameraOffset", &cameraOffsetValue, 0, 200)) {
|
||||
if (SetCameraOffset) SetCameraOffset(cameraOffsetValue); SaveSettings();
|
||||
}
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Text("Value is in cms.");
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; ++i) DrawSlider(sliders[i], 200);
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
if (ImGui::CollapsingHeader("HUD scaling", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
ImGui::SetNextItemWidth(180 * scale);
|
||||
if (ImGui::SliderInt("##HUDScale", &HUDScaleValue, 0, 40)) {
|
||||
if (SetHUDScale) SetHUDScale(HUDScaleValue); SaveSettings();
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::CollapsingHeader("Camera smoothness (*)", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
ImGui::SetNextItemWidth(180 * scale);
|
||||
if (ImGui::SliderFloat("##CameraSmoothnessValue", &cameraSmoothnessValue, 2, 10, "%.2f")) {
|
||||
if (SetCameraSmoothness) SetCameraSmoothness(cameraSmoothnessValue); SaveSettings();
|
||||
}
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Text("The higher the value, the quicker the camera transition is.");
|
||||
ImGui::Text("Used in combination with camera distance fix.");
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
for (int i = 2; i < 4; ++i) DrawSlider(sliders[i], 180);
|
||||
ImGui::EndTable();
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
@@ -356,15 +331,7 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
|
||||
|
||||
if (ImGui::BeginTabItem("Cheats"))
|
||||
{
|
||||
if (ImGui::Checkbox("Time dilation", &Time_Dilation_fix_enabled)) {
|
||||
if (SetFixesEnabled) SetFixesEnabled(GameFixes::WorldTimeDilation, Time_Dilation_fix_enabled);
|
||||
SaveSettings();
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Text("Use ALT + F1 shortcut to de/activate.");
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
for (const auto& cheat : cheatFixes) DrawFixCheckbox(cheat);
|
||||
|
||||
if (ImGui::BeginTable("SlidersTable", 2, ImGuiTableFlags_SizingStretchSame)) {
|
||||
ImGui::TableSetupColumn("LeftSliders", ImGuiTableColumnFlags_WidthStretch, 0.5f);
|
||||
@@ -372,34 +339,9 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
|
||||
ImGui::TableNextRow();
|
||||
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
if (ImGui::CollapsingHeader("World time dilation", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
ImGui::SetNextItemWidth(180 * scale);
|
||||
if (ImGui::SliderFloat("##WorldTimeDilationValue", &worldTimeDilationValue, 0, 2, "%.2f")) {
|
||||
if (SetWorldTimeDilation) SetWorldTimeDilation(worldTimeDilationValue); SaveSettings();
|
||||
}
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Text("Will affect everything in the world.");
|
||||
ImGui::Text("Default value is 1.");
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
DrawSlider(sliders[4], 180);
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
|
||||
if (ImGui::CollapsingHeader("AI time dilation", ImGuiTreeNodeFlags_DefaultOpen))
|
||||
{
|
||||
ImGui::SetNextItemWidth(180 * scale);
|
||||
if (ImGui::SliderFloat("##AITimeDilationValue", &AITimeDilationValue, 0, 2, "%.2f")) {
|
||||
if (SetAITimeDilation) SetAITimeDilation(AITimeDilationValue); SaveSettings();
|
||||
}
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Text("Will affect only enemies in the world.");
|
||||
ImGui::Text("Default value is 1.");
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
DrawSlider(sliders[5], 180);
|
||||
ImGui::EndTable();
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
@@ -414,62 +356,88 @@ static void on_overlay_draw(reshade::api::effect_runtime* runtime)
|
||||
if (GetGameInfos) {
|
||||
GameInfos infos{};
|
||||
GetGameInfos(&infos);
|
||||
if (infos.consoleEnabled)
|
||||
ImGui::Text("Console enabled and bound to key F2");
|
||||
if (infos.consoleEnabled) ImGui::Text("Console enabled and bound to key F2");
|
||||
ImGui::TextColored(ImColor(48, 179, 25), "FOV In: %.2f, Out: %.2f, Pawn camera offset: %.2f", infos.FOVIn, infos.FOVOut, infos.CompensatedFOV);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void on_reshade_present(reshade::api::effect_runtime* runtime) {
|
||||
if (!runtime) return; // Ensure runtime is valid
|
||||
|
||||
static bool wasTimeDilationInvoked = false;
|
||||
static float OSD_local_duration = OSD_duration;
|
||||
static auto last_time = std::chrono::steady_clock::now();
|
||||
|
||||
// ---- Delta time ----
|
||||
static auto last = std::chrono::steady_clock::now();
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
float delta_time = std::chrono::duration<float>(now - last_time).count();
|
||||
last_time = now;
|
||||
|
||||
// ---- ALT+F1 toggle ----
|
||||
bool timeDilationInvoked = runtime->is_key_down(VK_MENU) && runtime->is_key_down(VK_F1);
|
||||
if (timeDilationInvoked && !wasTimeDilationInvoked)
|
||||
{
|
||||
Time_Dilation_fix_enabled = !Time_Dilation_fix_enabled;
|
||||
OSD_local_duration = OSD_duration;
|
||||
float dt = std::chrono::duration<float>(now - last).count();
|
||||
last = now;
|
||||
|
||||
// Apply values in the shader
|
||||
if (u_td_show.handle && u_td_enabled.handle && u_td_world.handle && u_td_AI.handle) {
|
||||
runtime->set_uniform_value_bool(u_td_enabled, Time_Dilation_fix_enabled);
|
||||
runtime->set_uniform_value_bool(u_td_show, true);
|
||||
runtime->set_uniform_value_float(u_td_world, worldTimeDilationValue);
|
||||
runtime->set_uniform_value_float(u_td_AI, AITimeDilationValue);
|
||||
}
|
||||
|
||||
if (SetFixesEnabled) SetFixesEnabled(GameFixes::WorldTimeDilation, Time_Dilation_fix_enabled);
|
||||
SaveSettings();
|
||||
}
|
||||
wasTimeDilationInvoked = timeDilationInvoked;
|
||||
|
||||
if (OSD_local_duration > 0.0f) { // ---- Timer to hide OSD ----
|
||||
OSD_local_duration -= delta_time;
|
||||
if (OSD_local_duration <= 0.0f) {
|
||||
if (u_td_show.handle) runtime->set_uniform_value_bool(u_td_show, false);
|
||||
|
||||
OSD_local_duration = 0.0f;
|
||||
}
|
||||
}
|
||||
ProcessHotkeys(runtime);
|
||||
UpdateOSD(runtime, dt);
|
||||
}
|
||||
|
||||
// Retrieve all shader uniform variables
|
||||
static void on_reshade_begin_effects(reshade::api::effect_runtime* runtime, reshade::api::command_list* cmd_list,
|
||||
reshade::api::resource_view rtv, reshade::api::resource_view rtv_srgb) {
|
||||
u_td_show = runtime->find_uniform_variable(nullptr, "TD_Show");
|
||||
if (!runtime) return;
|
||||
u_td_show = runtime->find_uniform_variable(nullptr, "OSD_ShowTD");
|
||||
u_td_enabled = runtime->find_uniform_variable(nullptr, "TD_Enabled");
|
||||
u_td_world = runtime->find_uniform_variable(nullptr, "TD_World");
|
||||
u_td_AI = runtime->find_uniform_variable(nullptr, "TD_AI");
|
||||
u_GodMode_show = runtime->find_uniform_variable(nullptr, "OSD_ShowGodMode");
|
||||
u_GodMode_enabled = runtime->find_uniform_variable(nullptr, "GodMode_Enabled");
|
||||
u_Invulnerability_show = runtime->find_uniform_variable(nullptr, "OSD_ShowInvuln");
|
||||
u_Invulnerability_enabled = runtime->find_uniform_variable(nullptr, "Invulnerability_Enabled");
|
||||
|
||||
if (InterlockedCompareExchange(&g_uniformReseted, 1, 0) != 0) return; // reset OSD uniforms once
|
||||
|
||||
ResetAllUniformVariables(runtime, OSD_SHADER_NAME);
|
||||
runtime->save_current_preset(); // Save shader preset
|
||||
}
|
||||
|
||||
static void InitializeHotkeys() {
|
||||
if (InterlockedCompareExchange(&g_hotkeysInitialized, 1, 0) != 0) return; // Initialize hotkeys once
|
||||
|
||||
RegisterHotkey(VK_F1, Modifier::Alt, [] {
|
||||
Time_Dilation_fix_enabled = !Time_Dilation_fix_enabled;
|
||||
SetFixesEnabled(GameFixes::TimeDilation, Time_Dilation_fix_enabled);
|
||||
SaveSettings();
|
||||
|
||||
ShowOSD(OSD_duration,
|
||||
[](reshade::api::effect_runtime* rt) {
|
||||
ResetAllUniformVariables(rt, OSD_SHADER_NAME);
|
||||
rt->set_uniform_value_bool(u_td_show, true);
|
||||
rt->set_uniform_value_bool(u_td_enabled, Time_Dilation_fix_enabled);
|
||||
rt->set_uniform_value_float(u_td_world, worldTimeDilationValue);
|
||||
rt->set_uniform_value_float(u_td_AI, AITimeDilationValue);
|
||||
},
|
||||
[](reshade::api::effect_runtime* rt) { rt->set_uniform_value_bool(u_td_show, false); });
|
||||
});
|
||||
|
||||
RegisterHotkey(VK_F2, Modifier::Alt, [] {
|
||||
GodMode_fix_enabled = !GodMode_fix_enabled;
|
||||
SetFixesEnabled(GameFixes::GodMode, GodMode_fix_enabled);
|
||||
SaveSettings();
|
||||
|
||||
ShowOSD(OSD_duration,
|
||||
[](reshade::api::effect_runtime* rt) {
|
||||
ResetAllUniformVariables(rt, OSD_SHADER_NAME);
|
||||
rt->set_uniform_value_bool(u_GodMode_show, true);
|
||||
rt->set_uniform_value_bool(u_GodMode_enabled, GodMode_fix_enabled);
|
||||
},
|
||||
[](reshade::api::effect_runtime* rt) { rt->set_uniform_value_bool(u_GodMode_show, false); });
|
||||
});
|
||||
|
||||
RegisterHotkey(VK_F3, Modifier::Alt, [] {
|
||||
Ignore_hits_fix_enabled = !Ignore_hits_fix_enabled;
|
||||
SetFixesEnabled(GameFixes::Invulnerable, Ignore_hits_fix_enabled);
|
||||
SaveSettings();
|
||||
|
||||
ShowOSD(OSD_duration,
|
||||
[](reshade::api::effect_runtime* rt) {
|
||||
ResetAllUniformVariables(rt, OSD_SHADER_NAME);
|
||||
rt->set_uniform_value_bool(u_Invulnerability_show, true);
|
||||
rt->set_uniform_value_bool(u_Invulnerability_enabled, Ignore_hits_fix_enabled);
|
||||
},
|
||||
[](reshade::api::effect_runtime* rt) { rt->set_uniform_value_bool(u_Invulnerability_show, false); });
|
||||
});
|
||||
}
|
||||
|
||||
// Main dll intrance
|
||||
@@ -486,6 +454,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD ul_reason_for_call, LPVOID)
|
||||
reshade::register_event<reshade::addon_event::init_effect_runtime>(
|
||||
[](reshade::api::effect_runtime* runtime) {
|
||||
LoadFixDLL();
|
||||
InitializeHotkeys();
|
||||
});
|
||||
reshade::register_event<reshade::addon_event::reshade_present>(&on_reshade_present);
|
||||
reshade::register_event<reshade::addon_event::reshade_begin_effects>(&on_reshade_begin_effects);
|
||||
|
||||
Reference in New Issue
Block a user