mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-24 04:18:11 -08:00
More refactoring
This commit is contained in:
@@ -38,84 +38,9 @@ function body_part.new(id, name)
|
||||
|
||||
part.last_change_time = time.total_elapsed_script_seconds;
|
||||
|
||||
body_part.init_dynamic_UI(part);
|
||||
body_part.init_static_UI(part);
|
||||
body_part.init_highlighted_UI(part);
|
||||
return part;
|
||||
end
|
||||
|
||||
function body_part.init_dynamic_UI(part)
|
||||
local cached_config = config.current_config.large_monster_UI.dynamic.body_parts;
|
||||
|
||||
part.body_part_dynamic_UI = body_part_UI_entity.new(
|
||||
cached_config.visibility,
|
||||
cached_config.part_name_label,
|
||||
cached_config.part_health.visibility,
|
||||
cached_config.part_health.bar,
|
||||
cached_config.part_health.text_label,
|
||||
cached_config.part_health.value_label,
|
||||
cached_config.part_health.percentage_label,
|
||||
cached_config.part_break.visibility,
|
||||
cached_config.part_break.bar,
|
||||
cached_config.part_break.text_label,
|
||||
cached_config.part_break.value_label,
|
||||
cached_config.part_break.percentage_label,
|
||||
cached_config.part_loss.visibility,
|
||||
cached_config.part_loss.bar,
|
||||
cached_config.part_loss.text_label,
|
||||
cached_config.part_loss.value_label,
|
||||
cached_config.part_loss.percentage_label
|
||||
);
|
||||
end
|
||||
|
||||
function body_part.init_static_UI(part)
|
||||
local cached_config = config.current_config.large_monster_UI.static.body_parts;
|
||||
|
||||
part.body_part_static_UI = body_part_UI_entity.new(
|
||||
cached_config.visibility,
|
||||
cached_config.part_name_label,
|
||||
cached_config.part_health.visibility,
|
||||
cached_config.part_health.bar,
|
||||
cached_config.part_health.text_label,
|
||||
cached_config.part_health.value_label,
|
||||
cached_config.part_health.percentage_label,
|
||||
cached_config.part_break.visibility,
|
||||
cached_config.part_break.bar,
|
||||
cached_config.part_break.text_label,
|
||||
cached_config.part_break.value_label,
|
||||
cached_config.part_break.percentage_label,
|
||||
cached_config.part_loss.visibility,
|
||||
cached_config.part_loss.bar,
|
||||
cached_config.part_loss.text_label,
|
||||
cached_config.part_loss.value_label,
|
||||
cached_config.part_loss.percentage_label
|
||||
);
|
||||
end
|
||||
|
||||
function body_part.init_highlighted_UI(part)
|
||||
local cached_config = config.current_config.large_monster_UI.highlighted.body_parts;
|
||||
|
||||
part.body_part_highlighted_UI = body_part_UI_entity.new(
|
||||
cached_config.visibility,
|
||||
cached_config.part_name_label,
|
||||
cached_config.part_health.visibility,
|
||||
cached_config.part_health.bar,
|
||||
cached_config.part_health.text_label,
|
||||
cached_config.part_health.value_label,
|
||||
cached_config.part_health.percentage_label,
|
||||
cached_config.part_break.visibility,
|
||||
cached_config.part_break.bar,
|
||||
cached_config.part_break.text_label,
|
||||
cached_config.part_break.value_label,
|
||||
cached_config.part_break.percentage_label,
|
||||
cached_config.part_loss.visibility,
|
||||
cached_config.part_loss.bar,
|
||||
cached_config.part_loss.text_label,
|
||||
cached_config.part_loss.value_label,
|
||||
cached_config.part_loss.percentage_label
|
||||
);
|
||||
end
|
||||
|
||||
function body_part.update_flinch(part, part_current, part_max)
|
||||
if part_current > part.health then
|
||||
part.flinch_count = part.flinch_count + 1;
|
||||
@@ -190,8 +115,8 @@ function body_part.update_loss(part, part_loss_current, part_loss_max, is_severe
|
||||
|
||||
end
|
||||
|
||||
function body_part.draw_dynamic(monster, parts_position_on_screen, opacity_scale)
|
||||
local cached_config = config.current_config.large_monster_UI.dynamic.body_parts;
|
||||
function body_part.draw(monster, part_UI, cached_config, parts_position_on_screen, opacity_scale)
|
||||
local cached_config = cached_config.body_parts;
|
||||
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
|
||||
|
||||
local displayed_parts = {};
|
||||
@@ -251,382 +176,9 @@ function body_part.draw_dynamic(monster, parts_position_on_screen, opacity_scale
|
||||
goto continue
|
||||
end
|
||||
|
||||
if (not part.body_part_dynamic_UI.flinch_visibility or not health_supported)
|
||||
and
|
||||
(not part.body_part_dynamic_UI.break_visibility or not break_supported or part.break_count >= part.break_max_count
|
||||
)
|
||||
and (not part.body_part_dynamic_UI.loss_visibility or not severe_supported or part.is_severed) then
|
||||
goto continue
|
||||
end
|
||||
|
||||
if cached_config.settings.time_limit ~= 0 and
|
||||
time.total_elapsed_script_seconds - part.last_change_time > cached_config.settings.time_limit then
|
||||
goto continue
|
||||
end
|
||||
|
||||
table.insert(displayed_parts, part);
|
||||
::continue::
|
||||
end
|
||||
|
||||
if cached_config.sorting.type == "Normal" then
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.id > right.id;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.id < right.id;
|
||||
end);
|
||||
end
|
||||
elseif cached_config.sorting.type == "Health" then
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.health > right.health;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.health < right.health;
|
||||
end);
|
||||
end
|
||||
elseif cached_config.sorting.type == "Health Percentage" then
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.health_percentage > right.health_percentage;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.health_percentage < right.health_percentage;
|
||||
end);
|
||||
end
|
||||
elseif cached_config.sorting.type == "Flinch Count" then
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.flinch_count > right.flinch_count;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.flinch_count < right.flinch_count;
|
||||
end);
|
||||
end
|
||||
elseif cached_config.sorting.type == "Break Health" then
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.break_health > right.break_health;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.break_health < right.break_health;
|
||||
end);
|
||||
end
|
||||
elseif cached_config.sorting.type == "Break Health Percentage" then
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.break_health_percentage > right.break_health_percentage;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.break_health_percentage < right.break_health_percentage;
|
||||
end);
|
||||
end
|
||||
elseif cached_config.sorting.type == "Break Count" then
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.break_count > right.break_count;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.break_count < right.break_count;
|
||||
end);
|
||||
end
|
||||
elseif cached_config.sorting.type == "Sever Health" then
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.loss_health > right.loss_health;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.loss_health < right.loss_health;
|
||||
end);
|
||||
end
|
||||
elseif cached_config.sorting.type == "Sever Health Percentage" then
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.loss_health_percentage > right.loss_health_percentage;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.loss_health_percentage < right.loss_health_percentage;
|
||||
end);
|
||||
end
|
||||
end
|
||||
|
||||
local last_part_position_on_screen;
|
||||
|
||||
for j, part in ipairs(displayed_parts) do
|
||||
local part_position_on_screen = {
|
||||
x = parts_position_on_screen.x + cached_config.spacing.x * (j - 1) * global_scale_modifier,
|
||||
y = parts_position_on_screen.y + cached_config.spacing.y * (j - 1) * global_scale_modifier;
|
||||
}
|
||||
|
||||
body_part_UI_entity.draw_dynamic(part, part_position_on_screen, opacity_scale);
|
||||
last_part_position_on_screen = part_position_on_screen;
|
||||
end
|
||||
|
||||
return last_part_position_on_screen;
|
||||
end
|
||||
|
||||
function body_part.draw_static(monster, parts_position_on_screen, opacity_scale)
|
||||
local cached_config = config.current_config.large_monster_UI.static.body_parts;
|
||||
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
|
||||
|
||||
local displayed_parts = {};
|
||||
for REpart, part in pairs(monster.parts) do
|
||||
local health_supported = part.max_health >= 0;
|
||||
local break_supported = part.break_max_health >= 0;
|
||||
local severe_supported = part.loss_max_health >= 0;
|
||||
|
||||
if health_supported then
|
||||
if break_supported then
|
||||
if severe_supported then
|
||||
if not cached_config.filter.health_break_severe then
|
||||
goto continue
|
||||
end
|
||||
else
|
||||
if not cached_config.filter.health_break then
|
||||
goto continue
|
||||
end
|
||||
end
|
||||
else
|
||||
if severe_supported then
|
||||
if not cached_config.filter.health_severe then
|
||||
goto continue
|
||||
end
|
||||
else
|
||||
if not cached_config.filter.health then
|
||||
goto continue
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if break_supported then
|
||||
if severe_supported then
|
||||
if not cached_config.filter.break_severe then
|
||||
goto continue
|
||||
end
|
||||
else
|
||||
if not cached_config.filter.break_ then
|
||||
goto continue
|
||||
end
|
||||
end
|
||||
else
|
||||
if severe_supported then
|
||||
if not cached_config.filter.severe then
|
||||
goto continue
|
||||
end
|
||||
else
|
||||
goto continue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if cached_config.settings.hide_undamaged_parts
|
||||
and ((part.health == part.max_health and part.flinch_count == 0) or not health_supported)
|
||||
and ((part.break_health == part.break_max_health and part.break_count == 0) or not break_supported)
|
||||
and ((part.loss_health == part.loss_max_health and not part.is_severed) or not severe_supported) then
|
||||
goto continue
|
||||
end
|
||||
|
||||
if (not part.body_part_static_UI.flinch_visibility or not health_supported)
|
||||
and
|
||||
(not part.body_part_static_UI.break_visibility or not break_supported or part.break_count >= part.break_max_count
|
||||
)
|
||||
and (not part.body_part_static_UI.loss_visibility or not severe_supported or part.is_severed) then
|
||||
goto continue
|
||||
end
|
||||
|
||||
if cached_config.settings.time_limit ~= 0 and
|
||||
time.total_elapsed_script_seconds - part.last_change_time > cached_config.settings.time_limit then
|
||||
goto continue
|
||||
end
|
||||
|
||||
|
||||
table.insert(displayed_parts, part);
|
||||
::continue::
|
||||
end
|
||||
|
||||
if cached_config.sorting.type == "Normal" then
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.id > right.id;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.id < right.id;
|
||||
end);
|
||||
end
|
||||
elseif cached_config.sorting.type == "Health" then
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.health > right.health;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.health < right.health;
|
||||
end);
|
||||
end
|
||||
elseif cached_config.sorting.type == "Health Percentage" then
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.health_percentage > right.health_percentage;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.health_percentage < right.health_percentage;
|
||||
end);
|
||||
end
|
||||
elseif cached_config.sorting.type == "Flinch Count" then
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.flinch_count > right.flinch_count;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.flinch_count < right.flinch_count;
|
||||
end);
|
||||
end
|
||||
elseif cached_config.sorting.type == "Break Health" then
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.break_health > right.break_health;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.break_health < right.break_health;
|
||||
end);
|
||||
end
|
||||
elseif cached_config.sorting.type == "Break Health Percentage" then
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.break_health_percentage > right.break_health_percentage;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.break_health_percentage < right.break_health_percentage;
|
||||
end);
|
||||
end
|
||||
elseif cached_config.sorting.type == "Break Count" then
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.break_count > right.break_count;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.break_count < right.break_count;
|
||||
end);
|
||||
end
|
||||
elseif cached_config.sorting.type == "Sever Health" then
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.loss_health > right.loss_health;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.loss_health < right.loss_health;
|
||||
end);
|
||||
end
|
||||
elseif cached_config.sorting.type == "Sever Health Percentage" then
|
||||
if cached_config.sorting.reversed_order then
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.loss_health_percentage > right.loss_health_percentage;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_parts, function(left, right)
|
||||
return left.loss_health_percentage < right.loss_health_percentage;
|
||||
end);
|
||||
end
|
||||
end
|
||||
|
||||
local last_part_position_on_screen;
|
||||
|
||||
for j, part in ipairs(displayed_parts) do
|
||||
local part_position_on_screen = {
|
||||
x = parts_position_on_screen.x + cached_config.spacing.x * (j - 1) * global_scale_modifier,
|
||||
y = parts_position_on_screen.y + cached_config.spacing.y * (j - 1) * global_scale_modifier;
|
||||
}
|
||||
|
||||
body_part_UI_entity.draw_static(part, part_position_on_screen, opacity_scale);
|
||||
last_part_position_on_screen = part_position_on_screen;
|
||||
end
|
||||
|
||||
return last_part_position_on_screen;
|
||||
end
|
||||
|
||||
function body_part.draw_highlighted(monster, parts_position_on_screen, opacity_scale)
|
||||
local cached_config = config.current_config.large_monster_UI.highlighted.body_parts;
|
||||
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
|
||||
|
||||
local displayed_parts = {};
|
||||
for REpart, part in pairs(monster.parts) do
|
||||
local health_supported = part.max_health >= 0;
|
||||
local break_supported = part.break_max_health >= 0;
|
||||
local severe_supported = part.loss_max_health >= 0;
|
||||
|
||||
if health_supported then
|
||||
if break_supported then
|
||||
if severe_supported then
|
||||
if not cached_config.filter.health_break_severe then
|
||||
goto continue
|
||||
end
|
||||
else
|
||||
if not cached_config.filter.health_break then
|
||||
goto continue
|
||||
end
|
||||
end
|
||||
else
|
||||
if severe_supported then
|
||||
if not cached_config.filter.health_severe then
|
||||
goto continue
|
||||
end
|
||||
else
|
||||
if not cached_config.filter.health then
|
||||
goto continue
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if break_supported then
|
||||
if severe_supported then
|
||||
if not cached_config.filter.break_severe then
|
||||
goto continue
|
||||
end
|
||||
else
|
||||
if not cached_config.filter.break_ then
|
||||
goto continue
|
||||
end
|
||||
end
|
||||
else
|
||||
if severe_supported then
|
||||
if not cached_config.filter.severe then
|
||||
goto continue
|
||||
end
|
||||
else
|
||||
goto continue
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if cached_config.settings.hide_undamaged_parts
|
||||
and ((part.health == part.max_health and part.flinch_count == 0) or not health_supported)
|
||||
and ((part.break_health == part.break_max_health and part.break_count == 0) or not break_supported)
|
||||
and ((part.loss_health == part.loss_max_health and not part.is_severed) or not severe_supported) then
|
||||
goto continue
|
||||
end
|
||||
|
||||
if (not part.body_part_highlighted_UI.flinch_visibility or not health_supported)
|
||||
and (
|
||||
not part.body_part_highlighted_UI.break_visibility or not break_supported or part.break_count >= part.break_max_count
|
||||
)
|
||||
and (not part.body_part_highlighted_UI.loss_visibility or not severe_supported or part.is_severed) then
|
||||
if (not part_UI.flinch_visibility or not health_supported)
|
||||
and (not part_UI.break_visibility or not break_supported or part.break_count >= part.break_max_count)
|
||||
and (not part_UI.loss_visibility or not severe_supported or part.is_severed) then
|
||||
goto continue
|
||||
end
|
||||
|
||||
@@ -739,7 +291,7 @@ function body_part.draw_highlighted(monster, parts_position_on_screen, opacity_s
|
||||
y = parts_position_on_screen.y + cached_config.spacing.y * (j - 1) * global_scale_modifier;
|
||||
};
|
||||
|
||||
body_part_UI_entity.draw_highlighted(part, part_position_on_screen, opacity_scale);
|
||||
body_part_UI_entity.draw(part, part_UI, cached_config, part_position_on_screen, opacity_scale);
|
||||
last_part_position_on_screen = part_position_on_screen;
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user