Rewritten original project UI. Add cheats. Code refactoring.

This commit is contained in:
2026-03-12 15:09:59 +01:00
parent 2152147bb4
commit 34d3ce523f

View File

@@ -1,316 +1,376 @@
#define IMGUI_DISABLE_INCLUDE_IMCONFIG_H
#define IMGUI_HAS_DOCK 1
#include <imgui.h>
#include <reshade.hpp>
#include <fstream>
#include <string>
#include <Windows.h>
#include <thread>
#include "CommonHeaders.h"
#include "HotkeysManager.h"
#include "OSDManager.h"
#include <chrono>
// Screen informations
static int screenHeight = GetSystemMetrics(SM_CYSCREEN);
// Core game dll functions declarations
typedef void (*SetBoolFn)(bool, bool);
typedef void (*SetIntFn)(int);
typedef float (*GetFloatFn)();
typedef void (*InitDLL)();
typedef void (*SetFixesFn)(GameFixes, bool);
typedef void (*SetFloatFn)(GameSetting, float);
typedef void (*InitloggerFn)();
static HMODULE fixLib = nullptr;
static LONG g_coreInitialized = 0;
static LONG g_hotkeysInitialized = 0;
static LONG g_uniformReseted = 0;
static SetBoolFn SetFixEnabled = nullptr;
static SetBoolFn SetFOVFixEnabled = nullptr;
static SetBoolFn SetAspectRatioFixEnabled = nullptr;
static SetBoolFn SetDOFFixEnabled = nullptr;
static SetBoolFn SetVignettingFixEnabled = nullptr;
static SetBoolFn SetFogFixEnabled = nullptr;
static InitDLL InitializeLogger = nullptr;
static SetIntFn SetFOV = nullptr;
static GetFloatFn GetFOVIn = nullptr;
static GetFloatFn GetCompensadedFOV = nullptr;
static GetFloatFn GetFOVOut = nullptr;
static SetFixesFn SetFixes = nullptr;
static SetFloatFn SetValues = nullptr;
static InitloggerFn InitializeLogger = nullptr;
static GetGameInfosStruct GetGameInfos = nullptr;
void SetFixesEnabled(GameFixes fix, bool value) { if (SetFixes) SetFixes(fix, value); }
// Plugin variables for checkboxes and sliders
static bool fov_fix_enabled = false;
static bool aspect_ratio_fix_enabled = false;
static bool ultrawide_fix_enabled = false;
static bool camera_fix_enabled = false;
static bool DOF_fix_enabled = false;
static bool CA_fix_enabled = false;
static bool Vignetting_fix_enabled = false;
static bool Fog_fix_enabled = false;
static bool fix_enabled = false;
static bool Time_Dilation_fix_enabled = false;
static bool GodMode_fix_enabled = false;
static bool Stamina_fix_enabled = false;
static bool StealthMode_fix_enabled = false;
static bool console = true;
static int worldFOVvalue = 0;
static float cameraDistancevalue = 1.f;
static float worldTimeDilationValue = 1.f;
static float AITimeDilationValue = 1.f;
static float OSD_duration = 3.f;
// Overlays popups
static bool popup_Informations = false;
static bool show_log_overlay = false;
static std::string log_content;
// Plugin settings
const char* SETTINGS_FILE = "PluginSettings.ini";
const char* GENERAL_FIX_SETTING = "GeneralFIX=";
const char* FOV_FIX_SETTING = "FOVFIX=";
const char* ASPECT_FIX_SETTING = "AspectFIX=";
const char* DOF_FIX_SETTING = "DOFFIX=";
const char* VIGNETTING_FIX_SETTING = "VignettingFIX=";
const char* FOG_FIX_SETTING = "FogFIX=";
const char* WORLD_FOV_SETTING = "WorldFOV=";
const char* FIX_VERSION = "1.0.2";
const char* FIX_INFORMATIONS = "This fix allows to:\n - Control FOV.\n - Disable pillarboxing in cutscenes.\n - Disable depth of field.\n - Disable vignetting.\n - Disable fog.\n\nDisabling pillarboxing will compensate FOV for ultrawide.\nDisabling Fog will not entirely remove it.";
const char* FIX_VERSION = "1.0.3";
const char* FIX_INFORMATIONS = "This fix allows to:\n - Control FOV.\n - Control camera distance.\n - Enable ultrawide in cutscene.\n - Disable pillarboxing in cutscenes.\n - Disable depth of field.\n - Disable vignetting.\n - Disable fog.\n - Enable cheats.";
const char* DONATION_URL = "https://buymeacoffee.com/k4sh44";
// Ensure that our Core DLL will be called only once
bool IsAlreadyInitialized()
{
// Declare a lock
HANDLE hMap = OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, "Local\\WuchangFixSharedSection");
// Scaling factor based on screen resolution
float scale = (float)screenHeight / 1200;
// If lock is not yet initialized
if (hMap == nullptr)
{
// We create the lock only once
hMap = CreateFileMappingA(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, 1, "Local\\WuchangFixSharedSection");
// Prepare arrays of checkboxes for ImGui
static FixToggle individualFixes[] = {
{ "FOV", &fov_fix_enabled, GameFixes::FOV },
{ "Vignetting", &Vignetting_fix_enabled, GameFixes::Vignetting },
{ "Fog", &Fog_fix_enabled, GameFixes::Fog, "This fix will not remove all fogs."},
{ "Ultrawide", &ultrawide_fix_enabled, GameFixes::UltraWide },
{ "Camera distance", &camera_fix_enabled, GameFixes::Camera },
{ "Depth of field", &DOF_fix_enabled, GameFixes::DOF },
};
if (hMap == nullptr) // We ensure the lock is valid
return true;
static FixToggle cheatFixes[] = {
{ "Time dilation", &Time_Dilation_fix_enabled, GameFixes::TimeDilation, "ALT + 1 (top keyboard row) to toggle" },
{ "God mode", &GodMode_fix_enabled, GameFixes::GodMode, "ALT + 2 (top keyboard row) to toggle.\nPlayer health won't decrease." },
{ "Stamina", &Stamina_fix_enabled, GameFixes::Stamina, "ALT + 3 (top keyboard row) to toggle.\nPlayer stamina won't decrease." },
{ "Stealth mode", &StealthMode_fix_enabled, GameFixes::Stealth, "ALT + 4 (top keyboard row) to toggle.\nEnemies will ignore you unless you attack them.\nThey still detect your presence." }
};
return false; // First time created we return false
}
// Otherwise we return true
CloseHandle(hMap);
return true;
}
// Prepare array of sliders for ImGui
static SliderFix2 sliders[4];
static void InitializeHotkeys();
// Load and unload game core dll functions /!\ necessary
static void LoadFixDLL()
{
if (IsAlreadyInitialized())
return; // déjà lancé dans un autre chargement
static void LoadFixDLL(reshade::api::effect_runtime* runtime) {
if (InterlockedCompareExchange(&g_coreInitialized, 1, 0) != 0)
return;
std::thread([]() {
// Game process is not ready at launch and memory is not yet initialized
// We do want the core dll to be called and initialized a few seconds after game launch
std::this_thread::sleep_for(std::chrono::milliseconds(6000));
if (GetModuleHandleA("WuchangFFCore.dll") == nullptr) {
fixLib = LoadLibraryA("WuchangFFCore.dll");
if (GetModuleHandleA("WuchangFFCore.dll") == nullptr) {
fixLib = LoadLibraryA("WuchangFFCore.dll");
if (!fixLib) {
MessageBoxA(nullptr, "Impossible to load game core dll", "Erreur", MB_OK);
return;
}
SetFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFixEnabled");
SetFOVFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFOVFixEnabled");
SetAspectRatioFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetAspectRatioFixEnabled");
SetDOFFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetDOFFixEnabled");
SetVignettingFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetVignettingFixEnabled");
SetFogFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFogFixEnabled");
SetFOV = (SetIntFn)GetProcAddress(fixLib, "SetFOV");
GetFOVIn = (GetFloatFn)GetProcAddress(fixLib, "GetFOVIn");
GetCompensadedFOV = (GetFloatFn)GetProcAddress(fixLib, "GetCompensatedFOV");
GetFOVOut = (GetFloatFn)GetProcAddress(fixLib, "GetFOVOut");;
// Apply initial values loaded from settings
if (SetFOV) SetFOV(worldFOVvalue);
if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, true);
if (SetAspectRatioFixEnabled) SetAspectRatioFixEnabled(aspect_ratio_fix_enabled, true);
if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, true);
if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, true);
if (SetFogFixEnabled) SetFogFixEnabled(Fog_fix_enabled, true);
if (SetFixEnabled) SetFixEnabled(fix_enabled, true);
if (!fixLib) {
MessageBoxA(nullptr, "Impossible to load game core dll", "Erreur", MB_OK);
return;
}
}).detach(); // This thread will not block others
SetFixEnabled = (SetBoolFn)GetProcAddress(fixLib, "SetFixEnabled");
SetFixes = (SetFixesFn)GetProcAddress(fixLib, "SetFixesEnabled");
SetValues = (SetFloatFn)GetProcAddress(fixLib, "SetValues");
InitializeLogger = (InitloggerFn)GetProcAddress(fixLib, "InitLogger");
GetGameInfos = (GetGameInfosStruct)GetProcAddress(fixLib, "GetGameInfos");
if (InitializeLogger) InitializeLogger();
// Apply initial values loaded from settings
if (SetValues) {
SetValues(GameSetting::FOV, worldFOVvalue);
SetValues(GameSetting::WorldTimeDilation, worldTimeDilationValue);
SetValues(GameSetting::CameraDistance, cameraDistancevalue);
}
if (SetFixEnabled) SetFixEnabled(fix_enabled, true);
if (SetFixes) {
SetFixes(GameFixes::FOV, fov_fix_enabled);
SetFixes(GameFixes::UltraWide, ultrawide_fix_enabled);
SetFixes(GameFixes::Camera, camera_fix_enabled);
SetFixes(GameFixes::DOF, DOF_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::Stamina, Stamina_fix_enabled);
SetFixes(GameFixes::Stealth, StealthMode_fix_enabled);
SetFixes(GameFixes::DevConsole, console);
}
sliders[0] = { "In game additional FOV", "##FOVValue", SliderType::Int, &worldFOVvalue, -20, 50, GameSetting::FOV, SetValues };
sliders[1] = { "Camera distance (*)", "##CameraOffset", SliderType::Float, &cameraDistancevalue, 0, 4, GameSetting::CameraDistance, SetValues, "%.1f",
"Value is a multiplier." };
sliders[2] = { "World time dilation", "##WorldTimeDilationValue", SliderType::Float, &worldTimeDilationValue, 0.f, 3.f,GameSetting::WorldTimeDilation , SetValues, "%.1f",
"Will affect everything in the world.\nDefault value is 1." };
sliders[3] = { "AI time dilation", "##AITimeDilationValue", SliderType::Float, &AITimeDilationValue, 0.f, 3.f,GameSetting::AITimeDilation , SetValues, "%.1f",
"Will affect onmy ennemies.\nDefault value is 1." };
}
InitializeHotkeys();
}
// Addon functions
static void SaveSettings()
{
std::ofstream file(SETTINGS_FILE);
if (file.is_open())
{
file << GENERAL_FIX_SETTING << (fix_enabled ? "1" : "0") << "\n";
file << FOV_FIX_SETTING << (fov_fix_enabled ? "1" : "0") << "\n";
file << ASPECT_FIX_SETTING << (aspect_ratio_fix_enabled ? "1" : "0") << "\n";
file << DOF_FIX_SETTING << (DOF_fix_enabled ? "1" : "0") << "\n";
file << VIGNETTING_FIX_SETTING << (Vignetting_fix_enabled ? "1" : "0") << "\n";
file << FOG_FIX_SETTING << (Fog_fix_enabled ? "1" : "0") << "\n";
file << WORLD_FOV_SETTING << worldFOVvalue << "\n";
file.close();
}
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",
" ",
"Controls if fix mod (globally) is enabled",
"Set Console to false if you don't want to enable it" });
pluginIniFile["1#General fix"]["Enabled"] = fix_enabled;
pluginIniFile["1#General fix"]["Console"] = console;
pluginIniFile["2#Individual fix"].setComment("Controls each fix individually");
pluginIniFile["2#Individual fix"]["FOV"] = fov_fix_enabled;
pluginIniFile["2#Individual fix"]["UltraWide"] = ultrawide_fix_enabled;
pluginIniFile["2#Individual fix"]["Camera"] = camera_fix_enabled;
pluginIniFile["2#Individual fix"]["DOF"] = DOF_fix_enabled;
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"]["Stamina"] = Stamina_fix_enabled;
pluginIniFile["2#Individual fix"]["Stealth"] = StealthMode_fix_enabled;
pluginIniFile["3#Fixes tuning"].setComment("Individual fix fine tune");
pluginIniFile["3#Fixes tuning"]["World FOV"] = worldFOVvalue;
pluginIniFile["3#Fixes tuning"]["Camera distance"] = cameraDistancevalue;
pluginIniFile["3#Fixes tuning"]["World time dilation scale"] = worldTimeDilationValue;
pluginIniFile["3#Fixes tuning"]["AI time dilation scale"] = AITimeDilationValue;
pluginIniFile.save(SETTINGS_FILE);
}
static void LoadSettings()
{
std::ifstream file(SETTINGS_FILE);
if (file.is_open())
{
std::string line;
while (std::getline(file, line))
{
if (line.find(FOV_FIX_SETTING) == 0)
{
std::string val = line.substr(strlen(FOV_FIX_SETTING));
fov_fix_enabled = (val == "1" || val == "true");
}
if (line.find(GENERAL_FIX_SETTING) == 0)
{
std::string val = line.substr(strlen(GENERAL_FIX_SETTING));
fix_enabled = (val == "1" || val == "true");
}
else if (line.find(ASPECT_FIX_SETTING) == 0)
{
std::string val = line.substr(strlen(ASPECT_FIX_SETTING));
aspect_ratio_fix_enabled = (val == "1" || val == "true");
}
else if (line.find(DOF_FIX_SETTING) == 0)
{
std::string val = line.substr(strlen(DOF_FIX_SETTING));
DOF_fix_enabled = (val == "1" || val == "true");
}
else if (line.find(VIGNETTING_FIX_SETTING) == 0)
{
std::string val = line.substr(strlen(VIGNETTING_FIX_SETTING));
Vignetting_fix_enabled = (val == "1" || val == "true");
}
else if (line.find(FOG_FIX_SETTING) == 0)
{
std::string val = line.substr(strlen(FOG_FIX_SETTING));
Fog_fix_enabled = (val == "1" || val == "true");
}
else if (line.find(WORLD_FOV_SETTING) == 0)
worldFOVvalue = std::stoi(line.substr(strlen(WORLD_FOV_SETTING)));
}
file.close();
static void LoadSettings() {
ini::IniFile pluginIniFile;
try {
pluginIniFile.load(SETTINGS_FILE);
fix_enabled = pluginIniFile["1#General fix"]["Enabled"].as<bool>();
console = pluginIniFile["1#General fix"]["Console"].as<bool>();
fov_fix_enabled = pluginIniFile["2#Individual fix"]["FOV"].as<bool>();
ultrawide_fix_enabled = pluginIniFile["2#Individual fix"]["UltraWide"].as<bool>();
camera_fix_enabled = pluginIniFile["2#Individual fix"]["Camera"].as<bool>();
DOF_fix_enabled = pluginIniFile["2#Individual fix"]["DOF"].as<bool>();
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>();
Stamina_fix_enabled = pluginIniFile["2#Individual fix"]["Stamina"].as<bool>();
StealthMode_fix_enabled = pluginIniFile["2#Individual fix"]["Stealth"].as<bool>();
worldFOVvalue = pluginIniFile["3#Fixes tuning"]["World FOV"].as<int>();
cameraDistancevalue = pluginIniFile["3#Fixes tuning"]["Camera distance"].as<int>();
worldTimeDilationValue = pluginIniFile["3#Fixes tuning"]["World time dilation scale"].as<float>();
AITimeDilationValue = pluginIniFile["3#Fixes tuning"]["AI time dilation scale"].as<float>();
}
catch (const std::exception& e) {}
}
static void displayFixInformations() {
// Fix version
ImGui::SetNextWindowSize(ImVec2(420, 210), ImGuiCond_Once);
ImGui::Begin("Informations", &popup_Informations); //
ImGui::SetCursorPos(ImVec2(10, 36));
ImGui::Text("Version : %s", FIX_VERSION);
ImGui::SetCursorPos(ImVec2(10, 76));
ImGui::Text(FIX_INFORMATIONS);
ImGui::End();
// Read plugin log file
void read_log_file(const std::string& filename) {
std::ifstream file(filename);
if (!file.is_open()) {
log_content = "Impossible to open file : " + filename;
return;
}
std::ostringstream ss;
ss << file.rdbuf();
log_content = ss.str();
}
// Initialize ImGui widgets for Reshade
static void on_overlay_draw(reshade::api::effect_runtime* runtime)
{
ImGui::SetNextWindowPos(ImVec2(100, 200), ImGuiCond_Once);
ImGui::SetNextWindowSize(ImVec2(350, 150), ImGuiCond_Once);
static void on_overlay_draw(reshade::api::effect_runtime* runtime) {
ImGui::SetNextWindowSize(ImVec2(350 * scale, 150 * scale), ImGuiCond_Once);
// Donation ?
ImGui::SetCursorPos(ImVec2(10, 36));
ImGui::Text("Like my work ?");
ImGui::SetCursorPos(ImVec2(130, 33));
if (ImGui::Button("consider donation"))
{
ShellExecuteA(NULL, "open", DONATION_URL, NULL, NULL, SW_SHOWNORMAL);
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.84f, 0.12f, 0.51f, 1.0f)); // pink
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.84f, 0.12f, 0.51f, 1.0f)); // pink
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.84f, 0.2f, 0.51f, 1.0f)); // pink
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.8f, 1.f, 1.f, 1.f)); // white
if (ImGui::Button("Like my work ? Consider donation")) ShellExecuteA(NULL, "open", DONATION_URL, NULL, NULL, SW_SHOWNORMAL); // Donation
ImGui::PopStyleColor(4); // Restore color
ImGui::SameLine();
if (ImGui::Button("Fix informations")) popup_Informations = true; // Fix information
ImGui::SameLine();
if (ImGui::Button("View logs")) {
read_log_file("WuchangFF.log");
show_log_overlay = true; // Fix information
}
// Fix informations
ImGui::SetCursorPos(ImVec2(270, 33));
if (ImGui::Button("Fix informations"))
popup_Informations = true;
if (popup_Informations) {
ImGui::Begin("Informations", &popup_Informations, ImGuiWindowFlags_AlwaysAutoResize);
ImGui::Text("Version : %s", FIX_VERSION);
ImGui::Text(FIX_INFORMATIONS);
ImGui::End();
}
if (popup_Informations)
displayFixInformations();
if (show_log_overlay) {
ImGui::Begin("Game log", &show_log_overlay, ImGuiWindowFlags_AlwaysAutoResize);
ImGui::TextUnformatted(log_content.c_str());
ImGui::End();
}
// Generic fix
ImGui::SetCursorPos(ImVec2(10, 60));
ImGui::BeginChild("AllFixesHeader", ImVec2(220, 0), false); // true = border
if (ImGui::CollapsingHeader("Enable fixes", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::SetCursorPos(ImVec2(5, 30));
if (ImGui::Checkbox("Fix enabled", &fix_enabled)) {
if (SetFixEnabled) SetFixEnabled(fix_enabled, false);
SaveSettings();
if (ImGui::BeginTabBar("MainTabs")) {
if (ImGui::BeginTabItem("Fixes")) {
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(10 * scale, 10 * scale));
if (ImGui::BeginTable("FixesTable", 2, ImGuiTableFlags_SizingStretchSame)) {
ImGui::TableSetupColumn("LeftFix", ImGuiTableColumnFlags_WidthStretch, 0.4f);
ImGui::TableSetupColumn("RightFix", ImGuiTableColumnFlags_WidthStretch, 0.6f);
ImGui::TableNextRow();
// Drawing a left column with slider and general fix
ImGui::TableSetColumnIndex(0);
if (ImGui::CollapsingHeader("Enable fixes", ImGuiTreeNodeFlags_DefaultOpen))
if (ImGui::Checkbox("Fix enabled", &fix_enabled)) {
if (SetFixEnabled) SetFixEnabled(fix_enabled, false);
SaveSettings();
}
// Individual fixes
ImGui::TableSetColumnIndex(1);
if (ImGui::CollapsingHeader("Individual fixes", ImGuiTreeNodeFlags_DefaultOpen)) {
if (ImGui::BeginTable("IndividualFixesTable", 2, ImGuiTableFlags_SizingStretchSame)) {
ImGui::TableSetupColumn("IndFix1", ImGuiTableColumnFlags_WidthStretch, 0.4f);
ImGui::TableSetupColumn("IndFix2", ImGuiTableColumnFlags_WidthStretch, 0.6f);
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
for (int i = 0; i < 3; ++i) DrawFixCheckbox(individualFixes[i]);
ImGui::TableSetColumnIndex(1);
for (int i = 3; i < IM_ARRAYSIZE(individualFixes); ++i) DrawFixCheckbox(individualFixes[i]);
ImGui::EndTable();
}
}
ImGui::EndTable();
}
ImGui::SetCursorPosY(ImGui::GetCursorPosY() - 2);
if (ImGui::BeginTable("FixesSliders", 2, ImGuiTableFlags_SizingStretchSame)) {
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
DrawSlider2(sliders[0], 200);
ImGui::TableSetColumnIndex(1);
DrawSlider2(sliders[1], 200);
ImGui::EndTable();
}
ImGui::PopStyleVar();
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Cheats")) {
for (const auto& cheat : cheatFixes) DrawFixCheckbox(cheat);
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(10 * scale, 10 * scale));
if (ImGui::BeginTable("SlidersTable", 2, ImGuiTableFlags_SizingStretchSame)) {
ImGui::TableSetupColumn("LeftSliders", ImGuiTableColumnFlags_WidthStretch, 0.5f);
ImGui::TableSetupColumn("RightSliders", ImGuiTableColumnFlags_WidthStretch, 0.5f);
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
DrawSlider2(sliders[2], 220);
ImGui::TableSetColumnIndex(1);
DrawSlider2(sliders[3], 220);
ImGui::EndTable();
}
ImGui::PopStyleVar();
ImGui::EndTabItem();
if (ImGui::CollapsingHeader("Cheat informations", ImGuiTreeNodeFlags_DefaultOpen)) {
if (GetGameInfos) {
GameInfos infos{};
GetGameInfos(&infos);
ImGui::TextColored(ImColor(48, 179, 25), "Player health: %.f - Stamina: %.f", infos.Health, infos.Stamina);
}
}
}
ImGui::EndTabBar();
// Fix status
if (ImGui::CollapsingHeader("Fix informations", ImGuiTreeNodeFlags_DefaultOpen)) {
if (GetGameInfos) {
GameInfos infos{};
GetGameInfos(&infos);
ImGui::Text("Screen width: %d, height: %d, aspect ratio: %.2f", infos.screenWidth, infos.screenHeight, infos.aspectRatio);
if (infos.consoleEnabled)
ImGui::Text("Console enabled and bound to key F2");
ImGui::TextColored(ImColor(48, 179, 25), "FOV In: %.2f, Compensated: %.2f, Out: %.2f", infos.FOVIn, infos.CompensatedFOV, infos.FOVOut);
ImGui::TextColored(ImColor(48, 179, 25), "Camera distance In: %.2f, Out: %.2f", infos.cameraIn, infos.cameraOut);
}
}
}
ImGui::EndChild();
// FOV adjustment
ImGui::SetCursorPos(ImVec2(10, 120));
ImGui::BeginChild("FOVHeader", ImVec2(220, 0), false); // true = bordure
if (ImGui::CollapsingHeader("In game additional FOV", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::SetCursorPos(ImVec2(5, 30));
ImGui::SetNextItemWidth(150.0f);
if (ImGui::SliderInt("", &worldFOVvalue, -20, 50)) {}
if (ImGui::IsItemDeactivatedAfterEdit()) {
if (SetFOV) SetFOV(worldFOVvalue);
SaveSettings();
}
}
ImGui::EndChild();
// Individual fixes
ImGui::SetCursorPos(ImVec2(240, 60));
ImGui::BeginChild("IndividualFixesHeader", ImVec2(250, 0), false);
if (ImGui::CollapsingHeader("Individual fixes", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::SetCursorPos(ImVec2(5, 30));
if (ImGui::Checkbox("Enable FOV fix", &fov_fix_enabled)) {
if (SetFOVFixEnabled) SetFOVFixEnabled(fov_fix_enabled, false);
SaveSettings();
}
ImGui::SetCursorPos(ImVec2(5, 55));
if (ImGui::Checkbox("Enable aspect fix", &aspect_ratio_fix_enabled)) {
if (SetAspectRatioFixEnabled) SetAspectRatioFixEnabled(aspect_ratio_fix_enabled, false);
SaveSettings();
}
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::Text("Aspect ratio fix is only usefull for ultrawide displays.");
ImGui::Text("No need to enable it if you play at 16/9.");
ImGui::EndTooltip();
}
ImGui::SetCursorPos(ImVec2(5, 80));
if (ImGui::Checkbox("Depth of field Fix", &DOF_fix_enabled)) {
if (SetDOFFixEnabled) SetDOFFixEnabled(DOF_fix_enabled, false);
SaveSettings();
}
ImGui::SetCursorPos(ImVec2(5, 105));
if (ImGui::Checkbox("Vignetting Fix", &Vignetting_fix_enabled)) {
if (SetVignettingFixEnabled) SetVignettingFixEnabled(Vignetting_fix_enabled, false);
SaveSettings();
}
ImGui::SetCursorPos(ImVec2(145, 105));
if (ImGui::Checkbox("Fog Fix", &Fog_fix_enabled)) {
if (SetFogFixEnabled) SetFogFixEnabled(Fog_fix_enabled, false);
SaveSettings();
}
}
ImGui::EndChild();
// Fix status
ImGui::SetCursorPos(ImVec2(10, 220));
ImGui::BeginChild("INFOSHeader", ImVec2(480, 80), true); // true = border
if (ImGui::CollapsingHeader("Fix informations", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::SetCursorPos(ImVec2(5, 30));
if (GetFOVIn && GetCompensadedFOV && GetFOVOut)
ImGui::Text("FOV In: %.2f, Compensated : %.2f, Out : %.2f", GetFOVIn(), GetCompensadedFOV(), GetFOVOut());
}
ImGui::EndChild();
ImGui::PopStyleVar();
}
static void on_reshade_present(reshade::api::effect_runtime* runtime) {
static auto last = std::chrono::steady_clock::now();
auto now = std::chrono::steady_clock::now();
float dt = std::chrono::duration<float>(now - last).count();
last = now;
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) {
if (!runtime) return;
FindAllUniformVariables(runtime, OSD_SHADER_NAME); // Find all uniforms and set their handle
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() { // Initialize hotkeys for cheats
if (InterlockedCompareExchange(&g_hotkeysInitialized, 1, 0) != 0) return; // Initialize hotkeys once
RegisterHotkey('1', Modifier::Alt, [] {
ToggleOSD(Time_Dilation_fix_enabled, GameFixes::TimeDilation, u_td_show, u_td_enabled, OSD_duration,
{ {u_td_world, worldTimeDilationValue}, {u_td_AI, AITimeDilationValue} }); });
RegisterHotkey('2', Modifier::Alt, [] { ToggleOSD(GodMode_fix_enabled, GameFixes::GodMode, u_GodMode_show, u_GodMode_enabled, OSD_duration); });
RegisterHotkey('3', Modifier::Alt, [] { ToggleOSD(Stamina_fix_enabled, GameFixes::Stamina, u_Stamina_show, u_Stamina_enabled, OSD_duration); });
RegisterHotkey('4', Modifier::Alt, [] { ToggleOSD(StealthMode_fix_enabled, GameFixes::Stealth, u_Stealth_show, u_Stealth_enabled, OSD_duration); });
}
// Main dll intrance
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD ul_reason_for_call, LPVOID)
{
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD ul_reason_for_call, LPVOID) {
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
if (!reshade::register_addon(hinstDLL))
return FALSE;
LoadSettings();
case DLL_PROCESS_ATTACH:
if (!reshade::register_addon(hinstDLL))
return FALSE;
LoadSettings();
reshade::register_overlay("Wuchang Fallen Feathers", &on_overlay_draw);
reshade::register_event<reshade::addon_event::init_effect_runtime>(
[](reshade::api::effect_runtime* runtime) {
LoadFixDLL();
});
break;
case DLL_PROCESS_DETACH:
reshade::unregister_addon(hinstDLL);
break;
reshade::register_overlay("Wuchang Fallen Feathers", &on_overlay_draw);
reshade::register_event<reshade::addon_event::init_effect_runtime>(&LoadFixDLL);
reshade::register_event<reshade::addon_event::reshade_present>(&on_reshade_present);
reshade::register_event<reshade::addon_event::reshade_begin_effects>(&on_reshade_begin_effects);
break;
case DLL_PROCESS_DETACH:
reshade::unregister_overlay("Wuchang Fallen Feathers", &on_overlay_draw);
reshade::unregister_event<reshade::addon_event::init_effect_runtime>(&LoadFixDLL);
reshade::unregister_event<reshade::addon_event::reshade_present>(&on_reshade_present);
reshade::unregister_event<reshade::addon_event::reshade_begin_effects>(&on_reshade_begin_effects);
reshade::unregister_addon(hinstDLL);
break;
}
return TRUE;
}