From 1f64981356040ed76353af94dd408a0788d04bed Mon Sep 17 00:00:00 2001 From: praydog Date: Mon, 1 Jul 2024 20:09:41 -0700 Subject: [PATCH 1/6] Ultrawide: Add Constrain UI to 16:9 option --- src/mods/Graphics.cpp | 5 +++++ src/mods/Graphics.hpp | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/mods/Graphics.cpp b/src/mods/Graphics.cpp index 5ca19ec0..614e7863 100644 --- a/src/mods/Graphics.cpp +++ b/src/mods/Graphics.cpp @@ -98,6 +98,7 @@ void Graphics::on_draw_ui() { } if (m_ultrawide_fix->value()) { + m_ultrawide_constrain_ui->draw("Ultrawide: Constrain UI to 16:9"); m_ultrawide_vertical_fov->draw("Ultrawide: Enable Vertical FOV"); m_ultrawide_custom_fov->draw("Ultrawide: Override FOV"); m_ultrawide_fov_multiplier->draw("Ultrawide: FOV Multiplier"); @@ -365,6 +366,10 @@ bool Graphics::on_pre_gui_draw_element(REComponent* gui_element, void* primitive // TODO: Check how this interacts with the other games, could be useful for them too. #if defined(SF6) fix_ui_element(gui_element); +#else + if (m_ultrawide_constrain_ui->value()) { + fix_ui_element(gui_element); + } #endif auto game_object = utility::re_component::get_game_object(gui_element); diff --git a/src/mods/Graphics.hpp b/src/mods/Graphics.hpp index 1f14fb4f..89c9a1df 100644 --- a/src/mods/Graphics.hpp +++ b/src/mods/Graphics.hpp @@ -166,6 +166,7 @@ class Graphics : public Mod { const ModToggle::Ptr m_ultrawide_fix{ ModToggle::create(generate_name("UltrawideFix"), false) }; const ModToggle::Ptr m_ultrawide_vertical_fov{ ModToggle::create(generate_name("UltrawideFixVerticalFOV_V2"), false) }; const ModToggle::Ptr m_ultrawide_custom_fov{ModToggle::create(generate_name("UltrawideCustomFOV"), false)}; + const ModToggle::Ptr m_ultrawide_constrain_ui{ModToggle::create(generate_name("UltrawideConstrainUI"), false)}; const ModSlider::Ptr m_ultrawide_fov_multiplier{ ModSlider::create(generate_name("UltrawideFOVMultiplier_V2"), 0.01f, 3.0f, 1.0f) }; const ModToggle::Ptr m_disable_gui{ ModToggle::create(generate_name("DisableGUI"), false) }; const ModToggle::Ptr m_force_render_res_to_window{ ModToggle::create(generate_name("ForceRenderResToWindow"), false) }; @@ -234,6 +235,7 @@ class Graphics : public Mod { *m_ultrawide_fix, *m_ultrawide_vertical_fov, *m_ultrawide_custom_fov, + *m_ultrawide_constrain_ui, *m_ultrawide_fov_multiplier, *m_disable_gui, *m_force_render_res_to_window, From 2939d576229acd67eacf85e961f123ed55d3ea3e Mon Sep 17 00:00:00 2001 From: praydog Date: Mon, 1 Jul 2024 20:20:59 -0700 Subject: [PATCH 2/6] Kunitsu-Gami: Fix static table locator/heuristic --- shared/sdk/REContext.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shared/sdk/REContext.cpp b/shared/sdk/REContext.cpp index 48a113ad..3b40883f 100644 --- a/shared/sdk/REContext.cpp +++ b/shared/sdk/REContext.cpp @@ -208,7 +208,9 @@ namespace sdk { if (s_global_context != nullptr && *s_global_context != nullptr) { auto static_tbl = (REStaticTbl**)((uintptr_t)*s_global_context + s_static_tbl_offset); bool found_static_tbl_offset = false; - if (IsBadReadPtr(*static_tbl, sizeof(void*)) || ((uintptr_t)*static_tbl & (sizeof(void*) - 1)) != 0) { + const auto before_static_tbl_size = *(uint32_t*)((uintptr_t)static_tbl + sizeof(void*)); + spdlog::info("[VM::update_pointers] Static table size (before): {}", *(uint32_t*)((uintptr_t)static_tbl + sizeof(void*))); + if (IsBadReadPtr(*static_tbl, sizeof(void*)) || ((uintptr_t)*static_tbl & (sizeof(void*) - 1)) != 0 || before_static_tbl_size > 9999999 || before_static_tbl_size < 2000) { spdlog::info("[VM::update_pointers] Static table offset is bad, correcting..."); // We are looking for the two arrays, the static field table, and the static field "initialized table" From 827a117ef7a23cf5075c9f3d9fc7f10957fba81b Mon Sep 17 00:00:00 2001 From: praydog Date: Mon, 1 Jul 2024 21:09:00 -0700 Subject: [PATCH 3/6] Ultrawide: Add Constrain Child UI to 16:9 --- src/mods/Graphics.cpp | 15 +++++++++++++++ src/mods/Graphics.hpp | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/mods/Graphics.cpp b/src/mods/Graphics.cpp index 614e7863..213cd974 100644 --- a/src/mods/Graphics.cpp +++ b/src/mods/Graphics.cpp @@ -99,6 +99,9 @@ void Graphics::on_draw_ui() { if (m_ultrawide_fix->value()) { m_ultrawide_constrain_ui->draw("Ultrawide: Constrain UI to 16:9"); + if (m_ultrawide_constrain_ui->value()) { + m_ultrawide_constrain_child_ui->draw("Ultrawide: Constrain Child UI to 16:9"); + } m_ultrawide_vertical_fov->draw("Ultrawide: Enable Vertical FOV"); m_ultrawide_custom_fov->draw("Ultrawide: Override FOV"); m_ultrawide_fov_multiplier->draw("Ultrawide: FOV Multiplier"); @@ -351,6 +354,18 @@ void Graphics::fix_ui_element(REComponent* gui_element) { set_res_adjust_scale->call(sdk::get_thread_context(), view, (int32_t)via::gui::ResolutionAdjustScale::FitSmallRatioAxis); set_res_adjust_anchor->call(sdk::get_thread_context(), view, (int32_t)via::gui::ResolutionAdjustAnchor::CenterCenter); set_resolution_adjust->call(sdk::get_thread_context(), view, true); // Causes the options to be applied/used + + static const auto get_child = view_t->get_method("get_Child"); + + if (get_child != nullptr && m_ultrawide_constrain_child_ui->value()) { + const auto child = get_child->call<::REManagedObject*>(sdk::get_thread_context(), view); + + if (child != nullptr) { + set_res_adjust_scale->call(sdk::get_thread_context(), child, (int32_t)via::gui::ResolutionAdjustScale::FitSmallRatioAxis); + set_res_adjust_anchor->call(sdk::get_thread_context(), child, (int32_t)via::gui::ResolutionAdjustAnchor::CenterCenter); + set_resolution_adjust->call(sdk::get_thread_context(), child, true); // Causes the options to be applied/used + } + } } } diff --git a/src/mods/Graphics.hpp b/src/mods/Graphics.hpp index 89c9a1df..3c425f40 100644 --- a/src/mods/Graphics.hpp +++ b/src/mods/Graphics.hpp @@ -167,6 +167,7 @@ class Graphics : public Mod { const ModToggle::Ptr m_ultrawide_vertical_fov{ ModToggle::create(generate_name("UltrawideFixVerticalFOV_V2"), false) }; const ModToggle::Ptr m_ultrawide_custom_fov{ModToggle::create(generate_name("UltrawideCustomFOV"), false)}; const ModToggle::Ptr m_ultrawide_constrain_ui{ModToggle::create(generate_name("UltrawideConstrainUI"), false)}; + const ModToggle::Ptr m_ultrawide_constrain_child_ui{ModToggle::create(generate_name("UltrawideConstrainChildUI"), false)}; const ModSlider::Ptr m_ultrawide_fov_multiplier{ ModSlider::create(generate_name("UltrawideFOVMultiplier_V2"), 0.01f, 3.0f, 1.0f) }; const ModToggle::Ptr m_disable_gui{ ModToggle::create(generate_name("DisableGUI"), false) }; const ModToggle::Ptr m_force_render_res_to_window{ ModToggle::create(generate_name("ForceRenderResToWindow"), false) }; @@ -236,6 +237,7 @@ class Graphics : public Mod { *m_ultrawide_vertical_fov, *m_ultrawide_custom_fov, *m_ultrawide_constrain_ui, + *m_ultrawide_constrain_child_ui, *m_ultrawide_fov_multiplier, *m_disable_gui, *m_force_render_res_to_window, From 63f03f0c4831fc0c4a973e440222d4e97f85b3fa Mon Sep 17 00:00:00 2001 From: praydog Date: Mon, 1 Jul 2024 23:41:40 -0700 Subject: [PATCH 4/6] Ultrawide (Kunitsu-Gami): Hide pillarbox/letterbox in cutscenes --- src/mods/Graphics.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/mods/Graphics.cpp b/src/mods/Graphics.cpp index 213cd974..245af349 100644 --- a/src/mods/Graphics.cpp +++ b/src/mods/Graphics.cpp @@ -388,6 +388,8 @@ bool Graphics::on_pre_gui_draw_element(REComponent* gui_element, void* primitive #endif auto game_object = utility::re_component::get_game_object(gui_element); + static auto letter_box_behavior_t = sdk::find_type_definition("app.LetterBoxBehavior"); + static auto letter_box_behavior_retype = letter_box_behavior_t != nullptr ? letter_box_behavior_t->get_type() : nullptr; if (game_object != nullptr && game_object->transform != nullptr) { const auto name = utility::re_string::get_string(game_object->name); @@ -399,6 +401,18 @@ bool Graphics::on_pre_gui_draw_element(REComponent* gui_element, void* primitive case "GUIEventPillar"_fnv: game_object->shouldDraw = false; return false; + + case "Gui_ui0211"_fnv: // Kunitsu-Gami + if (letter_box_behavior_t != nullptr) { + auto letter_box_behavior = utility::re_component::find(game_object->transform, letter_box_behavior_retype); + + if (letter_box_behavior != nullptr) { + game_object->shouldDraw = false; + return false; + } + } + + break; #if defined(DD2) case "ui012203"_fnv: From d4777c5e6fdcc35066dccf192c1a37f79aa26428 Mon Sep 17 00:00:00 2001 From: praydog Date: Tue, 2 Jul 2024 00:13:15 -0700 Subject: [PATCH 5/6] Ultrawide: Fix fade-to-black bugs --- src/mods/Graphics.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mods/Graphics.cpp b/src/mods/Graphics.cpp index 245af349..9ecd5832 100644 --- a/src/mods/Graphics.cpp +++ b/src/mods/Graphics.cpp @@ -313,6 +313,12 @@ void Graphics::fix_ui_element(REComponent* gui_element) { return; } + const auto go_name = utility::re_string::get_view(game_object->name); + + if (go_name == L"BlackFade") { + return; // Don't do anything with the black fade, it should be taking over the whole screen + } + const auto gui_component = utility::re_component::find(game_object->transform, "via.gui.GUI"); if (gui_component == nullptr) { From dcc84bae86527e7dcb0db1623c1fb6a603ce5e6b Mon Sep 17 00:00:00 2001 From: praydog Date: Wed, 3 Jul 2024 05:14:47 -0700 Subject: [PATCH 6/6] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index ea5a844b..9fbd84ff 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,9 @@ Supports both DirectX 11 and DirectX 12. * Street Fighter 6 * Monster Hunter Rise * Dragon's Dogma 2 +* Ghosts 'n Goblins Resurrection (Using RE8 build) +* Apollo Justice: Ace Attorney Trilogy (Using DD2 build) +* Kunitsu-Gami: Path of the Goddess (Using DD2 build) ## Thanks [SkacikPL](https://github.com/SkacikPL) for originally creating the Manual Flashlight mod.