mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-25 21:08:07 -08:00
...
This commit is contained in:
@@ -3,13 +3,9 @@ local config;
|
|||||||
local table_helpers;
|
local table_helpers;
|
||||||
local drawing;
|
local drawing;
|
||||||
|
|
||||||
function body_part_UI_entity.new(part_visibility, part_name_label,
|
function body_part_UI_entity.new(part_visibility, part_name_label, flinch_visibility, flinch_bar, flinch_text_label,
|
||||||
flinch_visibility, flinch_bar, flinch_text_label, flinch_value_label,
|
flinch_value_label, flinch_percentage_label, break_visibility, break_bar, break_text_label, break_value_label,
|
||||||
flinch_percentage_label,
|
break_percentage_label, loss_visibility, loss_bar, loss_text_label, loss_value_label, loss_health_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;
|
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
|
end
|
||||||
|
|
||||||
local health_string = string.format("%.0f/%.0f", part.health, part.max_health);
|
local health_string = string.format("%.0f/%.0f", part.health, part.max_health);
|
||||||
local break_health_string = string.format("%.0f/%.0f", part.break_health,
|
local break_health_string = string.format("%.0f/%.0f", part.break_health, part.break_max_health);
|
||||||
part.break_max_health);
|
|
||||||
local loss_health_string = string.format("%.0f/%.0f", part.loss_health, part.loss_max_health);
|
local loss_health_string = string.format("%.0f/%.0f", part.loss_health, part.loss_max_health);
|
||||||
|
|
||||||
local flinch_position_on_screen = {
|
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 = {
|
local loss_position_on_screen = {
|
||||||
x = position_on_screen.x + cached_config.part_loss.offset.x,
|
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
|
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
|
end
|
||||||
|
|
||||||
if part.body_part_dynamic_UI.break_visibility and part.break_max_health ~= -1 and
|
if part.body_part_dynamic_UI.break_visibility and part.break_max_health ~= -1 and part.break_count <
|
||||||
part.break_count < part.break_max_count then
|
part.break_max_count then
|
||||||
drawing.draw_bar(part.body_part_dynamic_UI.break_bar, break_position_on_screen, opacity_scale,
|
drawing.draw_bar(part.body_part_dynamic_UI.break_bar, break_position_on_screen, opacity_scale,
|
||||||
part.break_health_percentage);
|
part.break_health_percentage);
|
||||||
end
|
end
|
||||||
@@ -168,8 +163,8 @@ function body_part_UI_entity.draw_dynamic(part, position_on_screen, opacity_scal
|
|||||||
100 * part.health_percentage);
|
100 * part.health_percentage);
|
||||||
end
|
end
|
||||||
|
|
||||||
if part.body_part_dynamic_UI.break_visibility and part.break_max_health ~= -1 and
|
if part.body_part_dynamic_UI.break_visibility and part.break_max_health ~= -1 and part.break_count <
|
||||||
part.break_count < part.break_max_count then
|
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_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,
|
drawing.draw_label(part.body_part_dynamic_UI.break_value_label, break_position_on_screen, opacity_scale,
|
||||||
break_health_string);
|
break_health_string);
|
||||||
@@ -215,8 +210,7 @@ function body_part_UI_entity.draw_static(part, position_on_screen, opacity_scale
|
|||||||
end
|
end
|
||||||
|
|
||||||
local health_string = string.format("%.0f/%.0f", part.health, part.max_health);
|
local health_string = string.format("%.0f/%.0f", part.health, part.max_health);
|
||||||
local break_health_string = string.format("%.0f/%.0f", part.break_health,
|
local break_health_string = string.format("%.0f/%.0f", part.break_health, part.break_max_health);
|
||||||
part.break_max_health);
|
|
||||||
local loss_health_string = string.format("%.0f/%.0f", part.loss_health, part.loss_max_health);
|
local loss_health_string = string.format("%.0f/%.0f", part.loss_health, part.loss_max_health);
|
||||||
|
|
||||||
local flinch_position_on_screen = {
|
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 = {
|
local loss_position_on_screen = {
|
||||||
x = position_on_screen.x + cached_config.part_loss.offset.x,
|
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);
|
drawing.draw_bar(part.body_part_static_UI.flinch_bar, flinch_position_on_screen, opacity_scale, part.health_percentage);
|
||||||
end
|
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,
|
drawing.draw_bar(part.body_part_static_UI.break_bar, break_position_on_screen, opacity_scale,
|
||||||
part.break_health_percentage);
|
part.break_health_percentage);
|
||||||
end
|
end
|
||||||
|
|
||||||
if part.body_part_static_UI.loss_visibility and part.loss_max_health ~= -1 and not part.is_severed then
|
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
|
end
|
||||||
|
|
||||||
drawing.draw_label(part.body_part_static_UI.part_name_label, position_on_screen, opacity_scale, part_name);
|
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
|
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_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,
|
drawing.draw_label(part.body_part_static_UI.flinch_percentage_label, flinch_position_on_screen, opacity_scale,
|
||||||
100 * part.health_percentage);
|
100 * part.health_percentage);
|
||||||
end
|
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_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,
|
drawing.draw_label(part.body_part_static_UI.break_value_label, break_position_on_screen, opacity_scale,
|
||||||
break_health_string);
|
break_health_string);
|
||||||
@@ -306,8 +303,7 @@ function body_part_UI_entity.draw_highlighted(part, position_on_screen, opacity_
|
|||||||
end
|
end
|
||||||
|
|
||||||
local health_string = string.format("%.0f/%.0f", part.health, part.max_health);
|
local health_string = string.format("%.0f/%.0f", part.health, part.max_health);
|
||||||
local break_health_string = string.format("%.0f/%.0f", part.break_health,
|
local break_health_string = string.format("%.0f/%.0f", part.break_health, part.break_max_health);
|
||||||
part.break_max_health);
|
|
||||||
local loss_health_string = string.format("%.0f/%.0f", part.loss_health, part.loss_max_health);
|
local loss_health_string = string.format("%.0f/%.0f", part.loss_health, part.loss_max_health);
|
||||||
|
|
||||||
local flinch_position_on_screen = {
|
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 = {
|
local loss_position_on_screen = {
|
||||||
x = position_on_screen.x + cached_config.part_loss.offset.x,
|
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_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
|
local draw_break = part.body_part_highlighted_UI.break_visibility and part.break_max_health > 0 and part.break_count <
|
||||||
part.break_count < part.break_max_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;
|
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
|
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()
|
function drawing.init_font()
|
||||||
local cached_config = config.current_config.global_settings.UI_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,
|
drawing.font = d2d.Font.new(cached_config.family, cached_config.size, cached_config.bold, cached_config.italic);
|
||||||
cached_config.italic);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function drawing.argb_color_to_abgr_color(argb_color)
|
function drawing.argb_color_to_abgr_color(argb_color)
|
||||||
@@ -57,16 +56,18 @@ end
|
|||||||
function drawing.scale_color_opacity(color, scale)
|
function drawing.scale_color_opacity(color, scale)
|
||||||
local alpha, red, green, blue = drawing.color_to_argb(color);
|
local alpha, red, green, blue = drawing.color_to_argb(color);
|
||||||
local new_alpha = math.floor(alpha * scale);
|
local new_alpha = math.floor(alpha * scale);
|
||||||
if new_alpha < 0 then new_alpha = 0; end
|
if new_alpha < 0 then
|
||||||
if new_alpha > 255 then new_alpha = 255; end
|
new_alpha = 0;
|
||||||
|
end
|
||||||
|
if new_alpha > 255 then
|
||||||
|
new_alpha = 255;
|
||||||
|
end
|
||||||
|
|
||||||
return drawing.argb_to_color(new_alpha, red, green, blue);
|
return drawing.argb_to_color(new_alpha, red, green, blue);
|
||||||
end
|
end
|
||||||
|
|
||||||
function drawing.scale_bar_opacity(bar, scale)
|
function drawing.scale_bar_opacity(bar, scale)
|
||||||
if bar == nil
|
if bar == nil or scale == nil or not bar.visibility then
|
||||||
or scale == nil
|
|
||||||
or not bar.visibility then
|
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -75,9 +76,7 @@ function drawing.scale_bar_opacity(bar, scale)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function drawing.scale_label_opacity(label, scale)
|
function drawing.scale_label_opacity(label, scale)
|
||||||
if label == nil
|
if label == nil or scale == nil or not label.visibility then
|
||||||
or scale == nil
|
|
||||||
or not label.visibility then
|
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -86,12 +85,11 @@ function drawing.scale_label_opacity(label, scale)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function drawing.draw_label(label, position, opacity_scale, ...)
|
function drawing.draw_label(label, position, opacity_scale, ...)
|
||||||
if label == nil
|
if label == nil or not label.visibility then
|
||||||
or not label.visibility then
|
|
||||||
return;
|
return;
|
||||||
end
|
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_x = position.x + label.offset.x;
|
||||||
local position_y = position.y + label.offset.y;
|
local position_y = position.y + label.offset.y;
|
||||||
|
|
||||||
@@ -126,8 +124,7 @@ end
|
|||||||
|
|
||||||
function drawing.draw_bar(bar, position, opacity_scale, percentage)
|
function drawing.draw_bar(bar, position, opacity_scale, percentage)
|
||||||
|
|
||||||
if bar == nil
|
if bar == nil or not bar.visibility then
|
||||||
or not bar.visibility then
|
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -264,20 +261,13 @@ function drawing.draw_bar(bar, position, opacity_scale, percentage)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function drawing.draw_capture_line(health_UI, position, opacity_scale, percentage)
|
function drawing.draw_capture_line(health_UI, position, opacity_scale, percentage)
|
||||||
if health_UI == nil
|
if health_UI == nil or not health_UI.visibility or health_UI.bar == nil or not health_UI.bar.visibility or
|
||||||
or not health_UI.visibility
|
health_UI.bar.capture_line == nil or not health_UI.bar.capture_line.visibility or percentage >= 1 or percentage <= 0 then
|
||||||
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;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local position_x =
|
||||||
local position_x = position.x + health_UI.bar.offset.x + health_UI.bar.capture_line.offset.x +
|
position.x + health_UI.bar.offset.x + health_UI.bar.capture_line.offset.x + health_UI.bar.size.width * percentage;
|
||||||
health_UI.bar.size.width * percentage;
|
|
||||||
local position_y = position.y + health_UI.bar.offset.y + health_UI.bar.capture_line.offset.y;
|
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;
|
local color = health_UI.bar.capture_line.color;
|
||||||
@@ -291,8 +281,8 @@ function drawing.draw_capture_line(health_UI, position, opacity_scale, percentag
|
|||||||
color);
|
color);
|
||||||
else
|
else
|
||||||
color = drawing.argb_color_to_abgr_color(color);
|
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
|
draw.filled_rect(position_x, position_y, health_UI.bar.capture_line.size.width,
|
||||||
, color)
|
health_UI.bar.capture_line.size.height, color)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user