Compare commits

...

3 Commits

3 changed files with 68 additions and 47 deletions

View File

@@ -36,7 +36,6 @@ void SetFixesEnabled(GameFixes fix, bool value) {
if (SetFixes) SetFixes(fix, value); if (SetFixes) SetFixes(fix, value);
} }
bool toto;
// Plugin variables for checkboxes and sliders // Plugin variables for checkboxes and sliders
static bool fov_fix_enabled = false; static bool fov_fix_enabled = false;
static bool Camera_fix_enabled = false; static bool Camera_fix_enabled = false;
@@ -63,18 +62,6 @@ static bool popup_Informations = false;
static bool show_log_overlay = false; static bool show_log_overlay = false;
static std::string log_content; static std::string log_content;
// 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 = {};
static reshade::api::effect_uniform_variable u_Stealth_show = {};
static reshade::api::effect_uniform_variable u_Stealth_enabled = {};
// Plugin settings // Plugin settings
const std::string SETTINGS_FILE = "./pluginsettings.ini"; const std::string SETTINGS_FILE = "./pluginsettings.ini";
const char* FIX_VERSION = "0.9.7"; const char* FIX_VERSION = "0.9.7";
@@ -88,7 +75,24 @@ float scale = (float)screenHeight / 1200;
extern "C" __declspec(dllexport) const char* NAME = "The Callisto Protocol"; 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, HUD, some effects and enable cheats."; 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 // 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 + 1 (top keyboard row) to toggle" },
{ "God mode", &GodMode_fix_enabled, GameFixes::GodMode, "ALT + 2 (top keyboard row) to toggle.\nJacob won't receive any damage." },
{ "Ignore hits", &Ignore_hits_fix_enabled, GameFixes::Invulnerable, "ALT + 3 (top keyboard row) to toggle.\nJacob can't be hit." },
{ "Stealth mode",&Stealth_fix_enabled, GameFixes::Stealth, "ALT + 4 (top keyboard row) to toggle.\nEnemies won't attack you" }
};
// Prepare array of sliders for ImGui
static SliderFix sliders[6]; static SliderFix sliders[6];
// Load and unload game core dll functions /!\ necessary // Load and unload game core dll functions /!\ necessary
@@ -225,23 +229,6 @@ static std::string read_log_file(const std::string& filename) {
log = ss.str(); log = ss.str();
return log; 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 + 1 (top keyboard row) to toggle" },
{ "God mode", &GodMode_fix_enabled, GameFixes::GodMode, "ALT + 2 (top keyboard row) to toggle.\nJacob won't receive any damage." },
{ "Ignore hits", &Ignore_hits_fix_enabled, GameFixes::Invulnerable, "ALT + 3 (top keyboard row) to toggle.\nJacob can't be hit." },
{ "Stealth mode",&Stealth_fix_enabled, GameFixes::Stealth, "ALT + 4 (top keyboard row) to toggle.\nEnemies won't attack you" }
};
// Initialize ImGui widgets for Reshade // 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) {
@@ -377,19 +364,9 @@ static void on_reshade_present(reshade::api::effect_runtime* runtime) {
static void on_reshade_begin_effects(reshade::api::effect_runtime* runtime, reshade::api::command_list* cmd_list, 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) { reshade::api::resource_view rtv, reshade::api::resource_view rtv_srgb) {
if (!runtime) return; if (!runtime) return;
u_td_show = runtime->find_uniform_variable(OSD_SHADER_NAME, "OSD_ShowTD"); FindAllUniformVariables(runtime, OSD_SHADER_NAME);
u_td_enabled = runtime->find_uniform_variable(OSD_SHADER_NAME, "TD_Enabled");
u_td_world = runtime->find_uniform_variable(OSD_SHADER_NAME, "TD_World");
u_td_AI = runtime->find_uniform_variable(OSD_SHADER_NAME, "TD_AI");
u_GodMode_show = runtime->find_uniform_variable(OSD_SHADER_NAME, "OSD_ShowGodMode");
u_GodMode_enabled = runtime->find_uniform_variable(OSD_SHADER_NAME, "GodMode_Enabled");
u_Invulnerability_show = runtime->find_uniform_variable(OSD_SHADER_NAME, "OSD_ShowInvuln");
u_Invulnerability_enabled = runtime->find_uniform_variable(OSD_SHADER_NAME, "Invulnerability_Enabled");
u_Stealth_show = runtime->find_uniform_variable(OSD_SHADER_NAME, "OSD_ShowStealth");
u_Stealth_enabled = runtime->find_uniform_variable(OSD_SHADER_NAME, "Stealth_Enabled");
if (InterlockedCompareExchange(&g_uniformReseted, 1, 0) != 0) return; // reset OSD uniforms once if (InterlockedCompareExchange(&g_uniformReseted, 1, 0) != 0) return; // reset OSD uniforms once
ResetAllUniformVariables(runtime, OSD_SHADER_NAME); ResetAllUniformVariables(runtime, OSD_SHADER_NAME);
runtime->save_current_preset(); // Save shader preset runtime->save_current_preset(); // Save shader preset
} }

View File

@@ -8,6 +8,18 @@ constexpr auto OSD_SHADER_NAME = "OSD.fx";
using OSDUpdateFn = std::function<void(reshade::api::effect_runtime*)>; using OSDUpdateFn = std::function<void(reshade::api::effect_runtime*)>;
using OSDEndFn = std::function<void(reshade::api::effect_runtime*)>; using OSDEndFn = std::function<void(reshade::api::effect_runtime*)>;
// Reshade shader uniform variables
extern reshade::api::effect_uniform_variable u_td_show;
extern reshade::api::effect_uniform_variable u_td_enabled;
extern reshade::api::effect_uniform_variable u_td_world;
extern reshade::api::effect_uniform_variable u_td_AI;
extern reshade::api::effect_uniform_variable u_GodMode_show;
extern reshade::api::effect_uniform_variable u_GodMode_enabled;
extern reshade::api::effect_uniform_variable u_Invulnerability_show;
extern reshade::api::effect_uniform_variable u_Invulnerability_enabled;
extern reshade::api::effect_uniform_variable u_Stealth_show;
extern reshade::api::effect_uniform_variable u_Stealth_enabled;
extern void SetFixesEnabled(GameFixes fix, bool value); extern void SetFixesEnabled(GameFixes fix, bool value);
extern void SaveSettings(); extern void SaveSettings();
@@ -42,6 +54,15 @@ void ShowOSD(float duration, OSDUpdateFn onUpdate, OSDEndFn onEnd);
*/ */
void UpdateOSD(reshade::api::effect_runtime* runtime, float deltaTime); void UpdateOSD(reshade::api::effect_runtime* runtime, float deltaTime);
/**
* @brief Find all uniform variables enumerated.
*
* This function must be called typically in `on_reshade_begin_effects`,
* @param runtime Pointer to the current `reshade::api::effect_runtime` object.
* @param effect_name File name of the effect file to enumerate uniform variables from (eg. myfile.fx)
*/
void FindAllUniformVariables(reshade::api::effect_runtime* runtime, const char* effect_name);
/** /**
* @brief Reset all uniform variables enumerated. * @brief Reset all uniform variables enumerated.
* *
@@ -53,7 +74,7 @@ void UpdateOSD(reshade::api::effect_runtime* runtime, float deltaTime);
void ResetAllUniformVariables(reshade::api::effect_runtime* runtime, const char* effect_name); void ResetAllUniformVariables(reshade::api::effect_runtime* runtime, const char* effect_name);
/** /**
* @brief Toggle cheats. * @brief Toggle cheats & OSD display.
* *
* This function must be called once, typically in `init_effect_runtime`, * This function must be called once, typically in `init_effect_runtime`,
* using an atomic compare-and-exchange operation * using an atomic compare-and-exchange operation
@@ -91,5 +112,4 @@ void ToggleOSD(T& cheatEnabled, GameFixes fix,
[=](reshade::api::effect_runtime* rt) { [=](reshade::api::effect_runtime* rt) {
rt->set_uniform_value_bool(showUniform, false); rt->set_uniform_value_bool(showUniform, false);
}); });
} }

View File

@@ -4,6 +4,18 @@ static float g_timer = 0.0f;
static OSDUpdateFn g_onUpdate; static OSDUpdateFn g_onUpdate;
static OSDEndFn g_onEnd; static OSDEndFn g_onEnd;
// Reshade shader uniform variables
reshade::api::effect_uniform_variable u_td_show = {};
reshade::api::effect_uniform_variable u_td_enabled = {};
reshade::api::effect_uniform_variable u_td_world = {};
reshade::api::effect_uniform_variable u_td_AI = {};
reshade::api::effect_uniform_variable u_GodMode_show = {};
reshade::api::effect_uniform_variable u_GodMode_enabled = {};
reshade::api::effect_uniform_variable u_Invulnerability_show = {};
reshade::api::effect_uniform_variable u_Invulnerability_enabled = {};
reshade::api::effect_uniform_variable u_Stealth_show = {};
reshade::api::effect_uniform_variable u_Stealth_enabled = {};
void ShowOSD(float duration, OSDUpdateFn onUpdate, OSDEndFn onEnd) { void ShowOSD(float duration, OSDUpdateFn onUpdate, OSDEndFn onEnd) {
g_timer = duration; g_timer = duration;
g_onUpdate = std::move(onUpdate); g_onUpdate = std::move(onUpdate);
@@ -25,9 +37,21 @@ void UpdateOSD(reshade::api::effect_runtime* runtime, float deltaTime) {
} }
} }
void FindAllUniformVariables(reshade::api::effect_runtime* runtime, const char* effect_name) {
u_td_show = runtime->find_uniform_variable(OSD_SHADER_NAME, "OSD_ShowTD");
u_td_enabled = runtime->find_uniform_variable(OSD_SHADER_NAME, "TD_Enabled");
u_td_world = runtime->find_uniform_variable(OSD_SHADER_NAME, "TD_World");
u_td_AI = runtime->find_uniform_variable(OSD_SHADER_NAME, "TD_AI");
u_GodMode_show = runtime->find_uniform_variable(OSD_SHADER_NAME, "OSD_ShowGodMode");
u_GodMode_enabled = runtime->find_uniform_variable(OSD_SHADER_NAME, "GodMode_Enabled");
u_Invulnerability_show = runtime->find_uniform_variable(OSD_SHADER_NAME, "OSD_ShowInvuln");
u_Invulnerability_enabled = runtime->find_uniform_variable(OSD_SHADER_NAME, "Invulnerability_Enabled");
u_Stealth_show = runtime->find_uniform_variable(OSD_SHADER_NAME, "OSD_ShowStealth");
u_Stealth_enabled = runtime->find_uniform_variable(OSD_SHADER_NAME, "Stealth_Enabled");
}
void ResetAllUniformVariables(reshade::api::effect_runtime* runtime, const char* effect_name) { void ResetAllUniformVariables(reshade::api::effect_runtime* runtime, const char* effect_name) {
runtime->enumerate_uniform_variables(effect_name, [runtime](reshade::api::effect_runtime* rt, reshade::api::effect_uniform_variable OSDvar) { runtime->enumerate_uniform_variables(effect_name, [runtime](reshade::api::effect_runtime* rt, reshade::api::effect_uniform_variable OSDvar) {
runtime->reset_uniform_value(OSDvar); runtime->reset_uniform_value(OSDvar);
}); });
} }