mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-24 12:28:03 -08:00
Add Small and Large Monster Head Tracking
This commit is contained in:
@@ -65,7 +65,7 @@ function this.update(dynamic_enabled, static_enabled, highlighted_enabled)
|
||||
local cached_config = config.current_config.large_monster_UI;
|
||||
|
||||
if singletons.enemy_manager == nil then
|
||||
error_handler.report("large_monster_UI.update", "Failed to access Data: enemy_manager");
|
||||
error_handler.report("large_monster_UI.update", "Failed to Access Data: enemy_manager");
|
||||
return;
|
||||
end
|
||||
|
||||
@@ -73,7 +73,7 @@ function this.update(dynamic_enabled, static_enabled, highlighted_enabled)
|
||||
|
||||
local enemy_count = get_boss_enemy_count_method:call(singletons.enemy_manager);
|
||||
if enemy_count == nil then
|
||||
error_handler.report("large_monster_UI.update", "Failed to access Data: enemy_count");
|
||||
error_handler.report("large_monster_UI.update", "Failed to Access Data: enemy_count");
|
||||
return;
|
||||
end
|
||||
|
||||
@@ -81,7 +81,7 @@ function this.update(dynamic_enabled, static_enabled, highlighted_enabled)
|
||||
for i = 0, enemy_count - 1 do
|
||||
local enemy = get_boss_enemy_method:call(singletons.enemy_manager, i);
|
||||
if enemy == nil then
|
||||
error_handler.report("large_monster_UI.update", "Failed to access Data: enemy No. " .. tostring(i));
|
||||
error_handler.report("large_monster_UI.update", "Failed to Access Data: enemy No. " .. tostring(i));
|
||||
goto continue;
|
||||
end
|
||||
|
||||
@@ -337,7 +337,13 @@ function this.draw_dynamic(cached_config)
|
||||
local i = 0;
|
||||
for _, monster in ipairs(displayed_dynamic_monsters) do
|
||||
local world_offset = Vector3f.new(cached_config.world_offset.x, cached_config.world_offset.y, cached_config.world_offset.z);
|
||||
local position_on_screen = draw.world_to_screen(monster.position + world_offset);
|
||||
|
||||
local position_on_screen;
|
||||
if cached_config.settings.head_tracking then
|
||||
position_on_screen = draw.world_to_screen(monster.head_position + world_offset);
|
||||
else
|
||||
position_on_screen = draw.world_to_screen(monster.position + world_offset);
|
||||
end
|
||||
|
||||
if position_on_screen == nil then
|
||||
goto continue;
|
||||
|
||||
@@ -126,7 +126,8 @@ end
|
||||
function this.draw()
|
||||
local cached_config = config.current_config.small_monster_UI;
|
||||
|
||||
local is_dynamic_positioning_enabled = cached_config.dynamic_positioning.enabled;
|
||||
local dynamic_positioning_config = cached_config.dynamic_positioning;
|
||||
local is_dynamic_positioning_enabled = dynamic_positioning_config.enabled;
|
||||
|
||||
local i = 0;
|
||||
for _, monster in ipairs(displayed_monsters) do
|
||||
@@ -134,19 +135,23 @@ function this.draw()
|
||||
|
||||
if is_dynamic_positioning_enabled then
|
||||
local world_offset = Vector3f.new(
|
||||
cached_config.dynamic_positioning.world_offset.x,
|
||||
cached_config.dynamic_positioning.world_offset.y,
|
||||
cached_config.dynamic_positioning.world_offset.z
|
||||
dynamic_positioning_config.world_offset.x,
|
||||
dynamic_positioning_config.world_offset.y,
|
||||
dynamic_positioning_config.world_offset.z
|
||||
);
|
||||
|
||||
position_on_screen = draw.world_to_screen(monster.position + world_offset);
|
||||
if dynamic_positioning_config.head_tracking then
|
||||
position_on_screen = draw.world_to_screen(monster.head_position + world_offset);
|
||||
else
|
||||
position_on_screen = draw.world_to_screen(monster.position + world_offset);
|
||||
end
|
||||
|
||||
if position_on_screen == nil then
|
||||
goto continue;
|
||||
end
|
||||
|
||||
position_on_screen.x = position_on_screen.x + cached_config.dynamic_positioning.viewport_offset.x;
|
||||
position_on_screen.y = position_on_screen.y + cached_config.dynamic_positioning.viewport_offset.y;
|
||||
position_on_screen.x = position_on_screen.x + dynamic_positioning_config.viewport_offset.x;
|
||||
position_on_screen.y = position_on_screen.y + dynamic_positioning_config.viewport_offset.y;
|
||||
else
|
||||
position_on_screen = screen.calculate_absolute_coordinates(cached_config.static_position);
|
||||
if cached_config.settings.orientation == "Horizontal" then
|
||||
@@ -157,9 +162,9 @@ function this.draw()
|
||||
end
|
||||
|
||||
local opacity_scale = 1;
|
||||
if is_dynamic_positioning_enabled and cached_config.dynamic_positioning.opacity_falloff then
|
||||
if is_dynamic_positioning_enabled and dynamic_positioning_config.opacity_falloff then
|
||||
monster.distance = (players.myself_position - monster.position):length();
|
||||
opacity_scale = 1 - (monster.distance / cached_config.dynamic_positioning.max_distance);
|
||||
opacity_scale = 1 - (monster.distance / dynamic_positioning_config.max_distance);
|
||||
end
|
||||
|
||||
small_monster.draw(monster, cached_config, position_on_screen, opacity_scale);
|
||||
|
||||
@@ -1338,6 +1338,11 @@ function this.draw_small_monster_UI()
|
||||
|
||||
config_changed = config_changed or changed;
|
||||
|
||||
changed, cached_config.dynamic_positioning.head_tracking = imgui.checkbox(
|
||||
language.current_language.customization_menu.head_tracking, cached_config.dynamic_positioning.head_tracking);
|
||||
|
||||
config_changed = config_changed or changed;
|
||||
|
||||
changed, cached_config.dynamic_positioning.opacity_falloff =
|
||||
imgui.checkbox(language.current_language.customization_menu.opacity_falloff,
|
||||
cached_config.dynamic_positioning.opacity_falloff);
|
||||
@@ -1479,6 +1484,11 @@ function this.draw_large_monster_dynamic_UI()
|
||||
config_changed = config_changed or changed;
|
||||
|
||||
if imgui.tree_node(language.current_language.customization_menu.settings) then
|
||||
changed, cached_config.settings.head_tracking = imgui.checkbox(
|
||||
language.current_language.customization_menu.head_tracking, cached_config.settings.head_tracking);
|
||||
|
||||
config_changed = config_changed or changed;
|
||||
|
||||
changed, cached_config.settings.hide_dead_or_captured = imgui.checkbox(
|
||||
language.current_language.customization_menu.hide_dead_or_captured, cached_config.settings.hide_dead_or_captured);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user