Skip to content

Commit

Permalink
VR (Kunitsu-Gami): Fix some world space icons
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Jul 21, 2024
1 parent e3a7af0 commit f7179fb
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions src/mods/VR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2721,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 @@ -2769,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 @@ -2800,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

0 comments on commit f7179fb

Please sign in to comment.