Skip to content

Commit

Permalink
Ultrawide: Add Constrain Child UI to 16:9
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Jul 2, 2024
1 parent 2939d57 commit 827a117
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/mods/Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -351,6 +354,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 Down
2 changes: 2 additions & 0 deletions src/mods/Graphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) };
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 827a117

Please sign in to comment.