mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-24 04:18:11 -08:00
...
This commit is contained in:
@@ -3,13 +3,9 @@ local config;
|
||||
local table_helpers;
|
||||
local drawing;
|
||||
|
||||
function body_part_UI_entity.new(part_visibility, part_name_label,
|
||||
flinch_visibility, flinch_bar, flinch_text_label, flinch_value_label,
|
||||
flinch_percentage_label,
|
||||
break_visibility, break_bar, break_text_label, break_value_label, break_percentage_label
|
||||
,
|
||||
loss_visibility, loss_bar, loss_text_label, loss_value_label,
|
||||
loss_health_percentage_label)
|
||||
function body_part_UI_entity.new(part_visibility, part_name_label, flinch_visibility, flinch_bar, flinch_text_label,
|
||||
flinch_value_label, flinch_percentage_label, break_visibility, break_bar, break_text_label, break_value_label,
|
||||
break_percentage_label, loss_visibility, loss_bar, loss_text_label, loss_value_label, loss_health_percentage_label)
|
||||
|
||||
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
|
||||
|
||||
@@ -120,8 +116,7 @@ function body_part_UI_entity.draw_dynamic(part, position_on_screen, opacity_scal
|
||||
end
|
||||
|
||||
local health_string = string.format("%.0f/%.0f", part.health, part.max_health);
|
||||
local break_health_string = string.format("%.0f/%.0f", part.break_health,
|
||||
part.break_max_health);
|
||||
local break_health_string = string.format("%.0f/%.0f", part.break_health, part.break_max_health);
|
||||
local loss_health_string = string.format("%.0f/%.0f", part.loss_health, part.loss_max_health);
|
||||
|
||||
local flinch_position_on_screen = {
|
||||
@@ -138,17 +133,17 @@ function body_part_UI_entity.draw_dynamic(part, position_on_screen, opacity_scal
|
||||
|
||||
local loss_position_on_screen = {
|
||||
x = position_on_screen.x + cached_config.part_loss.offset.x,
|
||||
y = position_on_screen.y + cached_config.part_loss.offset.y,
|
||||
|
||||
y = position_on_screen.y + cached_config.part_loss.offset.y
|
||||
|
||||
};
|
||||
|
||||
if part.body_part_dynamic_UI.flinch_visibility then
|
||||
drawing.draw_bar(part.body_part_dynamic_UI.flinch_bar, flinch_position_on_screen, opacity_scale, part.health_percentage);
|
||||
drawing.draw_bar(part.body_part_dynamic_UI.flinch_bar, flinch_position_on_screen, opacity_scale,
|
||||
part.health_percentage);
|
||||
end
|
||||
|
||||
if part.body_part_dynamic_UI.break_visibility and part.break_max_health ~= -1 and
|
||||
part.break_count < part.break_max_count then
|
||||
if part.body_part_dynamic_UI.break_visibility and part.break_max_health ~= -1 and part.break_count <
|
||||
part.break_max_count then
|
||||
drawing.draw_bar(part.body_part_dynamic_UI.break_bar, break_position_on_screen, opacity_scale,
|
||||
part.break_health_percentage);
|
||||
end
|
||||
@@ -168,8 +163,8 @@ function body_part_UI_entity.draw_dynamic(part, position_on_screen, opacity_scal
|
||||
100 * part.health_percentage);
|
||||
end
|
||||
|
||||
if part.body_part_dynamic_UI.break_visibility and part.break_max_health ~= -1 and
|
||||
part.break_count < part.break_max_count then
|
||||
if part.body_part_dynamic_UI.break_visibility and part.break_max_health ~= -1 and part.break_count <
|
||||
part.break_max_count then
|
||||
drawing.draw_label(part.body_part_dynamic_UI.break_text_label, break_position_on_screen, opacity_scale);
|
||||
drawing.draw_label(part.body_part_dynamic_UI.break_value_label, break_position_on_screen, opacity_scale,
|
||||
break_health_string);
|
||||
@@ -215,8 +210,7 @@ function body_part_UI_entity.draw_static(part, position_on_screen, opacity_scale
|
||||
end
|
||||
|
||||
local health_string = string.format("%.0f/%.0f", part.health, part.max_health);
|
||||
local break_health_string = string.format("%.0f/%.0f", part.break_health,
|
||||
part.break_max_health);
|
||||
local break_health_string = string.format("%.0f/%.0f", part.break_health, part.break_max_health);
|
||||
local loss_health_string = string.format("%.0f/%.0f", part.loss_health, part.loss_max_health);
|
||||
|
||||
local flinch_position_on_screen = {
|
||||
@@ -233,8 +227,7 @@ function body_part_UI_entity.draw_static(part, position_on_screen, opacity_scale
|
||||
|
||||
local loss_position_on_screen = {
|
||||
x = position_on_screen.x + cached_config.part_loss.offset.x,
|
||||
y = position_on_screen.y + cached_config.part_loss.offset.y,
|
||||
|
||||
y = position_on_screen.y + cached_config.part_loss.offset.y
|
||||
|
||||
};
|
||||
|
||||
@@ -242,25 +235,29 @@ function body_part_UI_entity.draw_static(part, position_on_screen, opacity_scale
|
||||
drawing.draw_bar(part.body_part_static_UI.flinch_bar, flinch_position_on_screen, opacity_scale, part.health_percentage);
|
||||
end
|
||||
|
||||
if part.body_part_static_UI.break_visibility and part.break_max_health ~= -1 and part.break_count < part.break_max_count then
|
||||
if part.body_part_static_UI.break_visibility and part.break_max_health ~= -1 and part.break_count <
|
||||
part.break_max_count then
|
||||
drawing.draw_bar(part.body_part_static_UI.break_bar, break_position_on_screen, opacity_scale,
|
||||
part.break_health_percentage);
|
||||
end
|
||||
|
||||
if part.body_part_static_UI.loss_visibility and part.loss_max_health ~= -1 and not part.is_severed then
|
||||
drawing.draw_bar(part.body_part_static_UI.loss_bar, loss_position_on_screen, opacity_scale, part.loss_health_percentage);
|
||||
drawing.draw_bar(part.body_part_static_UI.loss_bar, loss_position_on_screen, opacity_scale,
|
||||
part.loss_health_percentage);
|
||||
end
|
||||
|
||||
drawing.draw_label(part.body_part_static_UI.part_name_label, position_on_screen, opacity_scale, part_name);
|
||||
|
||||
if part.body_part_static_UI.flinch_visibility then
|
||||
drawing.draw_label(part.body_part_static_UI.flinch_text_label, flinch_position_on_screen, opacity_scale);
|
||||
drawing.draw_label(part.body_part_static_UI.flinch_value_label, flinch_position_on_screen, opacity_scale, health_string);
|
||||
drawing.draw_label(part.body_part_static_UI.flinch_value_label, flinch_position_on_screen, opacity_scale,
|
||||
health_string);
|
||||
drawing.draw_label(part.body_part_static_UI.flinch_percentage_label, flinch_position_on_screen, opacity_scale,
|
||||
100 * part.health_percentage);
|
||||
end
|
||||
|
||||
if part.body_part_static_UI.break_visibility and part.break_max_health ~= -1 and part.break_count < part.break_max_count then
|
||||
if part.body_part_static_UI.break_visibility and part.break_max_health ~= -1 and part.break_count <
|
||||
part.break_max_count then
|
||||
drawing.draw_label(part.body_part_static_UI.break_text_label, break_position_on_screen, opacity_scale);
|
||||
drawing.draw_label(part.body_part_static_UI.break_value_label, break_position_on_screen, opacity_scale,
|
||||
break_health_string);
|
||||
@@ -306,8 +303,7 @@ function body_part_UI_entity.draw_highlighted(part, position_on_screen, opacity_
|
||||
end
|
||||
|
||||
local health_string = string.format("%.0f/%.0f", part.health, part.max_health);
|
||||
local break_health_string = string.format("%.0f/%.0f", part.break_health,
|
||||
part.break_max_health);
|
||||
local break_health_string = string.format("%.0f/%.0f", part.break_health, part.break_max_health);
|
||||
local loss_health_string = string.format("%.0f/%.0f", part.loss_health, part.loss_max_health);
|
||||
|
||||
local flinch_position_on_screen = {
|
||||
@@ -324,14 +320,13 @@ function body_part_UI_entity.draw_highlighted(part, position_on_screen, opacity_
|
||||
|
||||
local loss_position_on_screen = {
|
||||
x = position_on_screen.x + cached_config.part_loss.offset.x,
|
||||
y = position_on_screen.y + cached_config.part_loss.offset.y,
|
||||
|
||||
y = position_on_screen.y + cached_config.part_loss.offset.y
|
||||
|
||||
};
|
||||
|
||||
local draw_health = part.body_part_highlighted_UI.flinch_visibility and part.max_health > 0;
|
||||
local draw_break = part.body_part_highlighted_UI.break_visibility and part.break_max_health > 0 and
|
||||
part.break_count < part.break_max_count;
|
||||
local draw_break = part.body_part_highlighted_UI.break_visibility and part.break_max_health > 0 and part.break_count <
|
||||
part.break_max_count;
|
||||
local draw_loss = part.body_part_highlighted_UI.loss_visibility and part.loss_max_health > 0 and not part.is_severed;
|
||||
|
||||
if draw_health then
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,8 +7,7 @@ drawing.font = nil;
|
||||
|
||||
function drawing.init_font()
|
||||
local cached_config = config.current_config.global_settings.UI_font;
|
||||
drawing.font = d2d.Font.new(cached_config.family, cached_config.size, cached_config.bold,
|
||||
cached_config.italic);
|
||||
drawing.font = d2d.Font.new(cached_config.family, cached_config.size, cached_config.bold, cached_config.italic);
|
||||
end
|
||||
|
||||
function drawing.argb_color_to_abgr_color(argb_color)
|
||||
@@ -57,16 +56,18 @@ end
|
||||
function drawing.scale_color_opacity(color, scale)
|
||||
local alpha, red, green, blue = drawing.color_to_argb(color);
|
||||
local new_alpha = math.floor(alpha * scale);
|
||||
if new_alpha < 0 then new_alpha = 0; end
|
||||
if new_alpha > 255 then new_alpha = 255; end
|
||||
if new_alpha < 0 then
|
||||
new_alpha = 0;
|
||||
end
|
||||
if new_alpha > 255 then
|
||||
new_alpha = 255;
|
||||
end
|
||||
|
||||
return drawing.argb_to_color(new_alpha, red, green, blue);
|
||||
end
|
||||
|
||||
function drawing.scale_bar_opacity(bar, scale)
|
||||
if bar == nil
|
||||
or scale == nil
|
||||
or not bar.visibility then
|
||||
if bar == nil or scale == nil or not bar.visibility then
|
||||
return;
|
||||
end
|
||||
|
||||
@@ -75,9 +76,7 @@ function drawing.scale_bar_opacity(bar, scale)
|
||||
end
|
||||
|
||||
function drawing.scale_label_opacity(label, scale)
|
||||
if label == nil
|
||||
or scale == nil
|
||||
or not label.visibility then
|
||||
if label == nil or scale == nil or not label.visibility then
|
||||
return;
|
||||
end
|
||||
|
||||
@@ -86,12 +85,11 @@ function drawing.scale_label_opacity(label, scale)
|
||||
end
|
||||
|
||||
function drawing.draw_label(label, position, opacity_scale, ...)
|
||||
if label == nil
|
||||
or not label.visibility then
|
||||
if label == nil or not label.visibility then
|
||||
return;
|
||||
end
|
||||
|
||||
local text = string.format(label.text, table.unpack({ ... }));
|
||||
local text = string.format(label.text, table.unpack({...}));
|
||||
local position_x = position.x + label.offset.x;
|
||||
local position_y = position.y + label.offset.y;
|
||||
|
||||
@@ -126,8 +124,7 @@ end
|
||||
|
||||
function drawing.draw_bar(bar, position, opacity_scale, percentage)
|
||||
|
||||
if bar == nil
|
||||
or not bar.visibility then
|
||||
if bar == nil or not bar.visibility then
|
||||
return;
|
||||
end
|
||||
|
||||
@@ -140,7 +137,7 @@ function drawing.draw_bar(bar, position, opacity_scale, percentage)
|
||||
end
|
||||
|
||||
local outline_visibility = bar.outline.visibility;
|
||||
local style = bar.outline.style; -- Inside/Center/Outside
|
||||
local style = bar.outline.style; -- Inside/Center/Outside
|
||||
|
||||
local outline_thickness = bar.outline.thickness;
|
||||
if not outline_visibility then
|
||||
@@ -264,20 +261,13 @@ function drawing.draw_bar(bar, position, opacity_scale, percentage)
|
||||
end
|
||||
|
||||
function drawing.draw_capture_line(health_UI, position, opacity_scale, percentage)
|
||||
if health_UI == nil
|
||||
or not health_UI.visibility
|
||||
or health_UI.bar == nil
|
||||
or not health_UI.bar.visibility
|
||||
or health_UI.bar.capture_line == nil
|
||||
or not health_UI.bar.capture_line.visibility
|
||||
or percentage >= 1
|
||||
or percentage <= 0 then
|
||||
if health_UI == nil or not health_UI.visibility or health_UI.bar == nil or not health_UI.bar.visibility or
|
||||
health_UI.bar.capture_line == nil or not health_UI.bar.capture_line.visibility or percentage >= 1 or percentage <= 0 then
|
||||
return;
|
||||
end
|
||||
|
||||
|
||||
local position_x = position.x + health_UI.bar.offset.x + health_UI.bar.capture_line.offset.x +
|
||||
health_UI.bar.size.width * percentage;
|
||||
local position_x =
|
||||
position.x + health_UI.bar.offset.x + health_UI.bar.capture_line.offset.x + health_UI.bar.size.width * percentage;
|
||||
local position_y = position.y + health_UI.bar.offset.y + health_UI.bar.capture_line.offset.y;
|
||||
|
||||
local color = health_UI.bar.capture_line.color;
|
||||
@@ -291,8 +281,8 @@ function drawing.draw_capture_line(health_UI, position, opacity_scale, percentag
|
||||
color);
|
||||
else
|
||||
color = drawing.argb_color_to_abgr_color(color);
|
||||
draw.filled_rect(position_x, position_y, health_UI.bar.capture_line.size.width, health_UI.bar.capture_line.size.height
|
||||
, color)
|
||||
draw.filled_rect(position_x, position_y, health_UI.bar.capture_line.size.width,
|
||||
health_UI.bar.capture_line.size.height, color)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user