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" diff --git a/src/mods/Graphics.cpp b/src/mods/Graphics.cpp index 5ca19ec0..9ecd5832 100644 --- a/src/mods/Graphics.cpp +++ b/src/mods/Graphics.cpp @@ -98,6 +98,10 @@ 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"); @@ -309,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) { @@ -350,6 +360,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 + } + } } } @@ -365,9 +387,15 @@ 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); + 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); @@ -379,6 +407,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: diff --git a/src/mods/Graphics.hpp b/src/mods/Graphics.hpp index 1f14fb4f..3c425f40 100644 --- a/src/mods/Graphics.hpp +++ b/src/mods/Graphics.hpp @@ -166,6 +166,8 @@ 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 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) }; @@ -234,6 +236,8 @@ class Graphics : public Mod { *m_ultrawide_fix, *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,