Skip to content

Commit

Permalink
Merge branch 'master' into csharp-api
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Sep 16, 2024
2 parents 07e96db + 84ad03d commit 18b301f
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/mods/APIProxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class APIProxy : public Mod {
using REFOnDeviceResetCb = std::function<std::remove_pointer<::REFOnDeviceResetCb>::type>;
using REFOnMessageCb = std::function<std::remove_pointer<::REFOnMessageCb>::type>;
using REFOnImGuiFrameCb = std::function<std::remove_pointer<::REFOnImGuiFrameCb>::type>;
using REFOnImGuiDrawUICb = std::function<std::remove_pointer<::REFOnImGuiDrawUICb>::type>;

bool add_on_lua_state_created(REFLuaStateCreatedCb cb);
bool add_on_lua_state_destroyed(REFLuaStateDestroyedCb cb);
Expand Down
7 changes: 7 additions & 0 deletions src/mods/Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,15 @@ void Graphics::on_view_get_size(REManagedObject* scene_view, float* result) {
return;
}

#if TDB_VER < 73
result[0] = (float)(*m_backbuffer_size)[0];
result[1] = (float)(*m_backbuffer_size)[1];
#else
auto regenny_view = (regenny::via::SceneView*)scene_view;

regenny_view->size.w = (float)(*m_backbuffer_size)[0];
regenny_view->size.h = (float)(*m_backbuffer_size)[1];
#endif
}

void Graphics::do_scope_tweaks(sdk::renderer::layer::Scene* layer) {
Expand Down
39 changes: 37 additions & 2 deletions src/mods/VR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2393,6 +2393,11 @@ bool VR::on_pre_gui_draw_element(REComponent* gui_element, void* primitive_conte
return false;
#endif

#if TDB_VER >= 73
case "ui0199"_fnv: // weird black bars in Kunitsu-Gami
return false;
#endif

default:
break;
};
Expand Down Expand Up @@ -2716,12 +2721,16 @@ bool VR::on_pre_gui_draw_element(REComponent* gui_element, void* primitive_conte
static auto mhrise_speech_balloon_typedef = sdk::find_type_definition(game_namespace("gui.GuiCommonNpcSpeechBalloon"));
static auto mhrise_head_message_typedef = sdk::find_type_definition(game_namespace("gui.GuiCommonHeadMessage"));
static auto mhrise_otomo_head_message_typedef = sdk::find_type_definition(game_namespace("gui.GuiCommonOtomoHeadMessage"));
static auto kg_float_icon_behavior = sdk::find_type_definition("app.FloatIconBehavior");
static auto kg_general_vital_gauge_behavior = sdk::find_type_definition("app.GeneralVitalGaugeBehavior");

static auto gameobject_elements_list = {
mhrise_npc_head_message_typedef,
mhrise_speech_balloon_typedef,
mhrise_head_message_typedef,
mhrise_otomo_head_message_typedef
mhrise_otomo_head_message_typedef,
kg_float_icon_behavior,
kg_general_vital_gauge_behavior
};

// Fix position of interaction icons
Expand Down Expand Up @@ -2764,6 +2773,8 @@ bool VR::on_pre_gui_draw_element(REComponent* gui_element, void* primitive_conte
if (parent != nullptr) {
Vector4f offset{};

std::optional<float> custom_ui_scale = std::nullopt;

if (element_type == mhrise_speech_balloon_typedef) {
static auto pos_data_field = mhrise_speech_balloon_typedef->get_field("posData");
static auto npc_message_pos = pos_data_field->get_type()->get_field("NpcMessagePos");
Expand Down Expand Up @@ -2795,9 +2806,33 @@ bool VR::on_pre_gui_draw_element(REComponent* gui_element, void* primitive_conte
offset = Vector4f{0.0f, y_offset, 0.0f, 0.0f};
} else if (element_type == mhrise_otomo_head_message_typedef) { //airou and dog
offset = Vector4f{0.0, 1.0f, 0.0f, 0.0f};
} else if (element_type == kg_float_icon_behavior) {
static auto param_field = kg_float_icon_behavior->get_field("_Param");
static auto world_pos_field = param_field != nullptr ? param_field->get_type()->get_field("WorldPos") : nullptr;

if (world_pos_field != nullptr) {
auto param = param_field->get_data<::REManagedObject*>(element_comp);

if (param != nullptr) {
offset = world_pos_field->get_data<Vector4f>(param);
custom_ui_scale = 5.0f;
}
}
} else if (element_type == kg_general_vital_gauge_behavior) {
static auto param_field = kg_general_vital_gauge_behavior->get_field("_OpenParam");
static auto world_pos_field = param_field != nullptr ? param_field->get_type()->get_field("WorldPos") : nullptr;

if (world_pos_field != nullptr) {
auto param = param_field->get_data<::REManagedObject*>(element_comp);

if (param != nullptr) {
offset = world_pos_field->get_data<Vector4f>(param);
custom_ui_scale = 5.0f;
}
}
}

fix_2d_position(sdk::get_transform_position(parent) + offset);
fix_2d_position(sdk::get_transform_position(parent) + offset, true, custom_ui_scale);
} else {
fix_2d_position(original_game_object_pos);
}
Expand Down
7 changes: 6 additions & 1 deletion src/mods/VR.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,12 @@ class VR : public Mod {
const ModToggle::Ptr m_allow_engine_overlays{ ModToggle::create(generate_name("AllowEngineOverlays"), true) };
const ModToggle::Ptr m_desktop_fix{ ModToggle::create(generate_name("DesktopRecordingFix"), true) };
const ModToggle::Ptr m_desktop_fix_skip_present{ ModToggle::create(generate_name("DesktopRecordingFixSkipPresent"), true) };
const ModToggle::Ptr m_enable_asynchronous_rendering{ ModToggle::create(generate_name("AsyncRendering_V2"), true) };

#if TDB_VER >= 73
const ModToggle::Ptr m_enable_asynchronous_rendering{ ModToggle::create(generate_name("AsyncRendering_V3"), false) };
#else
const ModToggle::Ptr m_enable_asynchronous_rendering{ ModToggle::create(generate_name("AsyncRendering_V3"), true) };
#endif

bool m_disable_projection_matrix_override{ false };
bool m_disable_gui_camera_projection_matrix_override{ false };
Expand Down

0 comments on commit 18b301f

Please sign in to comment.