Skip to content

Commit

Permalink
Merge branch 'master' into pd-upscaler
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Jul 2, 2024
2 parents cd3a433 + d4777c5 commit da39503
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
4 changes: 3 additions & 1 deletion shared/sdk/REContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
40 changes: 40 additions & 0 deletions src/mods/Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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<REComponent*>(game_object->transform, "via.gui.GUI");

if (gui_component == nullptr) {
Expand Down Expand Up @@ -350,6 +360,18 @@ void Graphics::fix_ui_element(REComponent* gui_element) {
set_res_adjust_scale->call<void>(sdk::get_thread_context(), view, (int32_t)via::gui::ResolutionAdjustScale::FitSmallRatioAxis);
set_res_adjust_anchor->call<void>(sdk::get_thread_context(), view, (int32_t)via::gui::ResolutionAdjustAnchor::CenterCenter);
set_resolution_adjust->call<void>(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<void>(sdk::get_thread_context(), child, (int32_t)via::gui::ResolutionAdjustScale::FitSmallRatioAxis);
set_res_adjust_anchor->call<void>(sdk::get_thread_context(), child, (int32_t)via::gui::ResolutionAdjustAnchor::CenterCenter);
set_resolution_adjust->call<void>(sdk::get_thread_context(), child, true); // Causes the options to be applied/used
}
}
}
}

Expand All @@ -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);
Expand All @@ -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<REComponent*>(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:
Expand Down
4 changes: 4 additions & 0 deletions src/mods/Graphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) };
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit da39503

Please sign in to comment.