mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-24 12:28:03 -08:00
Added highlighted large monster UI.
This commit is contained in:
@@ -15,18 +15,33 @@ local enemy_manager_type_def = sdk.find_type_definition("snow.enemy.EnemyManager
|
||||
local get_boss_enemy_count_method = enemy_manager_type_def:get_method("getBossEnemyCount");
|
||||
local get_boss_enemy_method = enemy_manager_type_def:get_method("getBossEnemy");
|
||||
|
||||
function large_monster_UI.draw(dynamic_enabled, static_enabled)
|
||||
function large_monster_UI.draw(dynamic_enabled, static_enabled, highlighted_enabled)
|
||||
if singletons.enemy_manager == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
local displayed_monsters = {};
|
||||
|
||||
local highlighted_id = -1;
|
||||
local highlighted_monster = nil;
|
||||
|
||||
if singletons.gui_manager ~= nil then
|
||||
local gui_hud_target_camera = singletons.gui_manager:call("get_refGuiHud_TgCamera");
|
||||
if gui_hud_target_camera ~= nil then
|
||||
highlighted_id = gui_hud_target_camera:get_field("OldTargetingEmIndex");
|
||||
|
||||
if highlighted_id == nil then
|
||||
highlighted_id = -1;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local enemy_count = get_boss_enemy_count_method:call(singletons.enemy_manager);
|
||||
if enemy_count == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
|
||||
for i = 0, enemy_count - 1 do
|
||||
local enemy = get_boss_enemy_method:call(singletons.enemy_manager, i);
|
||||
if enemy == nil then
|
||||
@@ -40,6 +55,10 @@ function large_monster_UI.draw(dynamic_enabled, static_enabled)
|
||||
goto continue;
|
||||
end
|
||||
|
||||
if i == highlighted_id then
|
||||
highlighted_monster = monster;
|
||||
end
|
||||
|
||||
table.insert(displayed_monsters, monster);
|
||||
::continue::
|
||||
end
|
||||
@@ -51,7 +70,21 @@ function large_monster_UI.draw(dynamic_enabled, static_enabled)
|
||||
end
|
||||
|
||||
if dynamic_enabled then
|
||||
local i = 0;
|
||||
large_monster_UI.draw_dynamic(displayed_monsters);
|
||||
end
|
||||
|
||||
if highlighted_enabled then
|
||||
large_monster_UI.draw_highlighted(highlighted_monster);
|
||||
end
|
||||
|
||||
if static_enabled then
|
||||
large_monster_UI.draw_static(displayed_monsters);
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function large_monster_UI.draw_dynamic(displayed_monsters)
|
||||
local i = 0;
|
||||
for _, monster in ipairs(displayed_monsters) do
|
||||
if config.current_config.large_monster_UI.dynamic.settings.max_distance == 0 then
|
||||
break;
|
||||
@@ -88,75 +121,88 @@ function large_monster_UI.draw(dynamic_enabled, static_enabled)
|
||||
i = i + 1;
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if static_enabled then
|
||||
-- sort here
|
||||
if config.current_config.large_monster_UI.static.sorting.type == "Normal" and config.current_config.large_monster_UI.static.sorting.reversed_order then
|
||||
local reversed_monsters = {};
|
||||
for i = #displayed_monsters, 1, -1 do
|
||||
table.insert(reversed_monsters, displayed_monsters[i]);
|
||||
end
|
||||
|
||||
displayed_monsters = reversed_monsters;
|
||||
|
||||
elseif config.current_config.large_monster_UI.static.sorting.type == "Health" then
|
||||
if config.current_config.large_monster_UI.static.sorting.reversed_order then
|
||||
table.sort(displayed_monsters, function(left, right)
|
||||
return left.health > right.health;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_monsters, function(left, right)
|
||||
return left.health < right.health;
|
||||
end);
|
||||
end
|
||||
elseif config.current_config.large_monster_UI.static.sorting.type == "Health Percentage" then
|
||||
if config.current_config.large_monster_UI.static.sorting.reversed_order then
|
||||
table.sort(displayed_monsters, function(left, right)
|
||||
return left.health_percentage > right.health_percentage;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_monsters, function(left, right)
|
||||
return left.health_percentage < right.health_percentage;
|
||||
end);
|
||||
end
|
||||
elseif config.current_config.large_monster_UI.static.sorting.type == "Distance" then
|
||||
if config.current_config.large_monster_UI.static.sorting.reversed_order then
|
||||
table.sort(displayed_monsters, function(left, right)
|
||||
return left.distance > right.distance;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_monsters, function(left, right)
|
||||
return left.distance < right.distance;
|
||||
end);
|
||||
end
|
||||
function large_monster_UI.draw_static(displayed_monsters)
|
||||
-- sort here
|
||||
if config.current_config.large_monster_UI.static.sorting.type == "Normal" and config.current_config.large_monster_UI.static.sorting.reversed_order then
|
||||
local reversed_monsters = {};
|
||||
for i = #displayed_monsters, 1, -1 do
|
||||
table.insert(reversed_monsters, displayed_monsters[i]);
|
||||
end
|
||||
|
||||
displayed_monsters = reversed_monsters;
|
||||
|
||||
local position_on_screen = screen.calculate_absolute_coordinates(config.current_config.large_monster_UI.static.position);
|
||||
|
||||
local i = 0;
|
||||
for _, monster in ipairs(displayed_monsters) do
|
||||
if monster.dead_or_captured and config.current_config.large_monster_UI.static.settings.hide_dead_or_captured then
|
||||
goto continue;
|
||||
end
|
||||
|
||||
local monster_position_on_screen = {
|
||||
x = position_on_screen.x,
|
||||
y = position_on_screen.y
|
||||
}
|
||||
|
||||
if config.current_config.large_monster_UI.static.settings.orientation == "Horizontal" then
|
||||
monster_position_on_screen.x = monster_position_on_screen.x + config.current_config.large_monster_UI.static.spacing.x * i;
|
||||
else
|
||||
monster_position_on_screen.y = monster_position_on_screen.y + config.current_config.large_monster_UI.static.spacing.y * i;
|
||||
end
|
||||
|
||||
large_monster.draw_static(monster, monster_position_on_screen, 1);
|
||||
|
||||
i = i + 1;
|
||||
::continue::
|
||||
elseif config.current_config.large_monster_UI.static.sorting.type == "Health" then
|
||||
if config.current_config.large_monster_UI.static.sorting.reversed_order then
|
||||
table.sort(displayed_monsters, function(left, right)
|
||||
return left.health > right.health;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_monsters, function(left, right)
|
||||
return left.health < right.health;
|
||||
end);
|
||||
end
|
||||
elseif config.current_config.large_monster_UI.static.sorting.type == "Health Percentage" then
|
||||
if config.current_config.large_monster_UI.static.sorting.reversed_order then
|
||||
table.sort(displayed_monsters, function(left, right)
|
||||
return left.health_percentage > right.health_percentage;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_monsters, function(left, right)
|
||||
return left.health_percentage < right.health_percentage;
|
||||
end);
|
||||
end
|
||||
elseif config.current_config.large_monster_UI.static.sorting.type == "Distance" then
|
||||
if config.current_config.large_monster_UI.static.sorting.reversed_order then
|
||||
table.sort(displayed_monsters, function(left, right)
|
||||
return left.distance > right.distance;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_monsters, function(left, right)
|
||||
return left.distance < right.distance;
|
||||
end);
|
||||
end
|
||||
end
|
||||
|
||||
local position_on_screen = screen.calculate_absolute_coordinates(config.current_config.large_monster_UI.static.position);
|
||||
|
||||
local i = 0;
|
||||
for _, monster in ipairs(displayed_monsters) do
|
||||
if monster.dead_or_captured and config.current_config.large_monster_UI.static.settings.hide_dead_or_captured then
|
||||
goto continue;
|
||||
end
|
||||
|
||||
local monster_position_on_screen = {
|
||||
x = position_on_screen.x,
|
||||
y = position_on_screen.y
|
||||
}
|
||||
|
||||
if config.current_config.large_monster_UI.static.settings.orientation == "Horizontal" then
|
||||
monster_position_on_screen.x = monster_position_on_screen.x + config.current_config.large_monster_UI.static.spacing.x * i;
|
||||
else
|
||||
monster_position_on_screen.y = monster_position_on_screen.y + config.current_config.large_monster_UI.static.spacing.y * i;
|
||||
end
|
||||
|
||||
large_monster.draw_static(monster, monster_position_on_screen, 1);
|
||||
|
||||
i = i + 1;
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
|
||||
function large_monster_UI.draw_highlighted(monster)
|
||||
if monster == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
local position_on_screen = screen.calculate_absolute_coordinates(config.current_config.large_monster_UI.highlighted.position);
|
||||
|
||||
if monster.dead_or_captured and config.current_config.large_monster_UI.highlighted.settings.hide_dead_or_captured then
|
||||
return;
|
||||
end
|
||||
|
||||
large_monster.draw_highlighted(monster, position_on_screen, 1);
|
||||
end
|
||||
|
||||
function large_monster_UI.init_module()
|
||||
|
||||
@@ -58,6 +58,27 @@ function body_part_UI_entity.draw_static(part, position_on_screen, opacity_scale
|
||||
drawing.draw_label(part.body_part_static_UI.percentage_label, position_on_screen, opacity_scale, 100 * part.health_percentage);
|
||||
end
|
||||
|
||||
function body_part_UI_entity.draw_highlighted(part, position_on_screen, opacity_scale)
|
||||
if not part.body_part_highlighted_UI.visibility then
|
||||
return;
|
||||
end
|
||||
|
||||
local part_name = "";
|
||||
if config.current_config.large_monster_UI.highlighted.parts.part_name_label.include.part_name then
|
||||
part_name = part.name .. " ";
|
||||
end
|
||||
if config.current_config.large_monster_UI.highlighted.parts.part_name_label.include.break_count and part.break_count ~= 0 then
|
||||
part_name = part_name .. "x" .. tostring(part.break_count);
|
||||
end
|
||||
|
||||
drawing.draw_bar(part.body_part_highlighted_UI.bar, position_on_screen, opacity_scale, part.health_percentage);
|
||||
|
||||
drawing.draw_label(part.body_part_highlighted_UI.name_label, position_on_screen, opacity_scale, part_name);
|
||||
drawing.draw_label(part.body_part_highlighted_UI.text_label, position_on_screen, opacity_scale);
|
||||
drawing.draw_label(part.body_part_highlighted_UI.value_label, position_on_screen, opacity_scale, part.health, part.max_health);
|
||||
drawing.draw_label(part.body_part_highlighted_UI.percentage_label, position_on_screen, opacity_scale, 100 * part.health_percentage);
|
||||
end
|
||||
|
||||
function body_part_UI_entity.init_module()
|
||||
table_helpers = require("MHR_Overlay.Misc.table_helpers");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
|
||||
@@ -5,13 +5,14 @@ local config;
|
||||
local player;
|
||||
local language;
|
||||
|
||||
function damage_UI_entity.new(bar, highlighted_bar, player_name_label, value_label, percentage_label)
|
||||
function damage_UI_entity.new(bar, highlighted_bar, player_name_label, hunter_rank_label, value_label, percentage_label)
|
||||
local entity = {};
|
||||
|
||||
--entity.visibility = visibility;
|
||||
entity.bar = table_helpers.deep_copy(bar);
|
||||
entity.highlighted_bar = table_helpers.deep_copy(highlighted_bar);
|
||||
entity.player_name_label = table_helpers.deep_copy(player_name_label);
|
||||
entity.hunter_rank_label = table_helpers.deep_copy(hunter_rank_label);
|
||||
entity.value_label = table_helpers.deep_copy(value_label);
|
||||
entity.percentage_label = table_helpers.deep_copy(percentage_label);
|
||||
|
||||
@@ -26,12 +27,9 @@ function damage_UI_entity.draw(_player, position_on_screen, opacity_scale, top_d
|
||||
end
|
||||
|
||||
local player_name_text = "";
|
||||
if player_include.hunter_rank then
|
||||
player_name_text = string.format("[%d] ", _player.hunter_rank);
|
||||
end
|
||||
|
||||
if player_include.word_player then
|
||||
player_name_text = player_name_text .. language.current_config.UI.player .. " ";
|
||||
player_name_text = language.current_language.UI.player .. " ";
|
||||
end
|
||||
|
||||
if player_include.player_id then
|
||||
@@ -66,6 +64,14 @@ function damage_UI_entity.draw(_player, position_on_screen, opacity_scale, top_d
|
||||
drawing.draw_bar(_player.damage_UI.bar, position_on_screen, opacity_scale, player_damage_bar_percentage);
|
||||
end
|
||||
|
||||
if _player.id == player.myself_id then
|
||||
if _player.damage_UI.hunter_rank_label.enable_for.me then
|
||||
drawing.draw_label(_player.damage_UI.hunter_rank_label, position_on_screen, opacity_scale, _player.hunter_rank);
|
||||
end
|
||||
elseif _player.damage_UI.hunter_rank_label.enable_for.other_players then
|
||||
drawing.draw_label(_player.damage_UI.hunter_rank_label, position_on_screen, opacity_scale, _player.hunter_rank);
|
||||
end
|
||||
|
||||
drawing.draw_label(_player.damage_UI.player_name_label, position_on_screen, opacity_scale, player_name_text);
|
||||
drawing.draw_label(_player.damage_UI.value_label, position_on_screen, opacity_scale, _player.display.total_damage);
|
||||
drawing.draw_label(_player.damage_UI.percentage_label, position_on_screen, opacity_scale, 100 * player_damage_percentage);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user