mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-24 04:18:11 -08:00
Static and dynamic positioning of large monster UI are now separated.
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
x = "1";
|
||||
|
||||
local damage_hook = require("MHR_Overlay.Damage_Meter.damage_hook");
|
||||
local player = require("MHR_Overlay.Damage_Meter.player");
|
||||
x = "";
|
||||
|
||||
local quest_status = require("MHR_Overlay.Game_Handler.quest_status");
|
||||
local screen = require("MHR_Overlay.Game_Handler.screen");
|
||||
@@ -10,40 +7,60 @@ local singletons = require("MHR_Overlay.Game_Handler.singletons");
|
||||
local config = require("MHR_Overlay.Misc.config");
|
||||
local table_helpers = require("MHR_Overlay.Misc.table_helpers");
|
||||
|
||||
local player = require("MHR_Overlay.Damage_Meter.player");
|
||||
local damage_hook = require("MHR_Overlay.Damage_Meter.damage_hook");
|
||||
|
||||
local body_part = require("MHR_Overlay.Monsters.body_part");
|
||||
local large_monster = require("MHR_Overlay.Monsters.large_monster");
|
||||
local monster_hook = require("MHR_Overlay.Monsters.monster_hook");
|
||||
local small_monster = require("MHR_Overlay.Monsters.small_monster");
|
||||
|
||||
local damage_meter_UI = require("MHR_Overlay.UI.Modules.damage_meter_UI");
|
||||
local large_monster_UI = require("MHR_Overlay.UI.Modules.large_monster_UI");
|
||||
local small_monster_UI = require("MHR_Overlay.UI.Modules.small_monster_UI");
|
||||
local time_UI = require("MHR_Overlay.UI.Modules.time_UI");
|
||||
|
||||
local body_part_UI_entity = require("MHR_Overlay.UI.UI_Entities.body_part_UI_entity");
|
||||
local damage_UI_entity = require("MHR_Overlay.UI.UI_Entities.damage_UI_entity");
|
||||
local health_UI_entity = require("MHR_Overlay.UI.UI_Entities.health_UI_entity");
|
||||
local stamina_UI_entity = require("MHR_Overlay.UI.UI_Entities.stamina_UI_entity");
|
||||
local rage_UI_entity = require("MHR_Overlay.UI.UI_Entities.rage_UI_entity");
|
||||
|
||||
local customization_menu = require("MHR_Overlay.UI.customization_menu");
|
||||
local damage_meter_UI = require("MHR_Overlay.UI.damage_meter_UI");
|
||||
local drawing = require("MHR_Overlay.UI.drawing");
|
||||
local large_monster_UI = require("MHR_Overlay.UI.large_monster_UI");
|
||||
local small_monster_UI = require("MHR_Overlay.UI.small_monster_UI");
|
||||
local time_UI = require("MHR_Overlay.UI.time_UI");
|
||||
|
||||
------------------------INIT MODULES-------------------------
|
||||
-- #region
|
||||
screen.init_module();
|
||||
singletons.init_module();
|
||||
table_helpers.init_module();
|
||||
|
||||
config.init_module();
|
||||
quest_status.init_module();
|
||||
|
||||
damage_UI_entity.init_module();
|
||||
health_UI_entity.init_module();
|
||||
stamina_UI_entity.init_module();
|
||||
rage_UI_entity.init_module();
|
||||
|
||||
damage_hook.init_module();
|
||||
player.init_module();
|
||||
|
||||
screen.init_module();
|
||||
singletons.init_module();
|
||||
quest_status.init_module();
|
||||
|
||||
config.init_module();
|
||||
table_helpers.init_module();
|
||||
|
||||
body_part.init_module();
|
||||
large_monster.init_module();
|
||||
monster_hook.init_module();
|
||||
small_monster.init_module();
|
||||
|
||||
customization_menu.init_module();
|
||||
body_part_UI_entity.init_module();
|
||||
damage_meter_UI.init_module();
|
||||
drawing.init_module();
|
||||
large_monster_UI.init_module();
|
||||
small_monster_UI.init_module();
|
||||
time_UI.init_module();
|
||||
|
||||
|
||||
|
||||
log.info("[MHR Overlay] loaded");
|
||||
-- #endregion
|
||||
------------------------INIT MODULES-------------------------
|
||||
@@ -84,13 +101,12 @@ end, function()
|
||||
singletons.init();
|
||||
player.update_myself_position();
|
||||
quest_status.update_is_online();
|
||||
|
||||
|
||||
if quest_status.index < 2 then
|
||||
quest_status.update_is_training_area();
|
||||
|
||||
if quest_status.is_training_area then
|
||||
if config.current_config.large_monster_UI.enabled and config.current_config.global_settings.module_visibility.training_area.large_monster_UI then
|
||||
if (config.current_config.large_monster_UI.dynamic.enabled or config.current_config.large_monster_UI.static.enabled) and config.current_config.global_settings.module_visibility.training_area.large_monster_UI then
|
||||
large_monster_UI.draw();
|
||||
end
|
||||
|
||||
@@ -104,7 +120,7 @@ end, function()
|
||||
small_monster_UI.draw();
|
||||
end
|
||||
|
||||
if config.current_config.large_monster_UI.enabled and config.current_config.global_settings.module_visibility.during_quest.large_monster_UI then
|
||||
if (config.current_config.large_monster_UI.dynamic.enabled or config.current_config.large_monster_UI.static.enabled) and config.current_config.global_settings.module_visibility.during_quest.large_monster_UI then
|
||||
large_monster_UI.draw();
|
||||
end
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
local player = {};
|
||||
local config = require("MHR_Overlay.Misc.config");
|
||||
local table_helpers = require("MHR_Overlay.Misc.table_helpers");
|
||||
local singletons = require("MHR_Overlay.Game_Handler.singletons");
|
||||
local customization_menu = require("MHR_Overlay.UI.customization_menu");
|
||||
local config;
|
||||
local table_helpers;
|
||||
local singletons;
|
||||
local customization_menu;
|
||||
local damage_UI_entity;
|
||||
|
||||
player.list = {};
|
||||
player.myself = nil;
|
||||
@@ -96,6 +97,8 @@ function player.new(player_id, player_name, player_hunter_rank)
|
||||
new_player.display.elemental_damage = 0;
|
||||
new_player.display.ailment_damage = 0;
|
||||
|
||||
player.init_UI(new_player);
|
||||
|
||||
return new_player;
|
||||
end
|
||||
|
||||
@@ -249,11 +252,26 @@ function player.init_total()
|
||||
player.total = player.new(0, "Total", 0);
|
||||
end
|
||||
|
||||
function player.init_UI(_player)
|
||||
_player.damage_UI = damage_UI_entity.new(
|
||||
config.current_config.damage_meter_UI.damage_bar,
|
||||
config.current_config.damage_meter_UI.highlighted_damage_bar,
|
||||
config.current_config.damage_meter_UI.player_name_label,
|
||||
config.current_config.damage_meter_UI.damage_value_label,
|
||||
config.current_config.damage_meter_UI.damage_percentage_label
|
||||
);
|
||||
end
|
||||
|
||||
function player.draw(_player, position_on_screen, opacity_scale, top_damage)
|
||||
damage_UI_entity.draw(_player, position_on_screen, opacity_scale, top_damage);
|
||||
end
|
||||
|
||||
function player.init_module()
|
||||
config = require("MHR_Overlay.Misc.config");
|
||||
table_helpers = require("MHR_Overlay.Misc.table_helpers");
|
||||
singletons = require("MHR_Overlay.Game_Handler.singletons");
|
||||
customization_menu = require("MHR_Overlay.UI.customization_menu");
|
||||
damage_UI_entity = require("MHR_Overlay.UI.UI_Entities.damage_UI_entity");
|
||||
|
||||
player.init_total();
|
||||
end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
93
MHR_Overlay/Monsters/body_part.lua
Normal file
93
MHR_Overlay/Monsters/body_part.lua
Normal file
@@ -0,0 +1,93 @@
|
||||
local body_part = {};
|
||||
local singletons;
|
||||
local customization_menu;
|
||||
local config;
|
||||
local table_helpers;
|
||||
local health_UI_entity;
|
||||
local stamina_UI_entity;
|
||||
local rage_UI_entity;
|
||||
local body_part_UI_entity;
|
||||
local screen;
|
||||
local drawing;
|
||||
|
||||
body_part.list = {};
|
||||
|
||||
function body_part.new(REpart, id)
|
||||
local part = {};
|
||||
|
||||
part.REpart = REpart;
|
||||
part.id = id;
|
||||
|
||||
part.health = 99999;
|
||||
part.max_health = 99999;
|
||||
part.health_percentage = 0;
|
||||
|
||||
part.name = "??";
|
||||
part.break_count = 0;
|
||||
|
||||
body_part.init_dynamic_UI(part);
|
||||
body_part.init_static_UI(part);
|
||||
|
||||
return part;
|
||||
end
|
||||
|
||||
|
||||
function body_part.init_dynamic_UI(part)
|
||||
part.body_part_dynamic_UI = body_part_UI_entity.new(
|
||||
config.current_config.large_monster_UI.dynamic.parts.bar,
|
||||
config.current_config.large_monster_UI.dynamic.parts.part_name_label,
|
||||
config.current_config.large_monster_UI.dynamic.parts.text_label,
|
||||
config.current_config.large_monster_UI.dynamic.parts.value_label,
|
||||
config.current_config.large_monster_UI.dynamic.parts.percentage_label
|
||||
);
|
||||
end
|
||||
|
||||
function body_part.init_static_UI(part)
|
||||
part.body_part_static_UI = body_part_UI_entity.new(
|
||||
config.current_config.large_monster_UI.static.parts.bar,
|
||||
config.current_config.large_monster_UI.static.parts.part_name_label,
|
||||
config.current_config.large_monster_UI.static.parts.text_label,
|
||||
config.current_config.large_monster_UI.static.parts.value_label,
|
||||
config.current_config.large_monster_UI.static.parts.percentage_label
|
||||
);
|
||||
end
|
||||
|
||||
function body_part.update(part, new_health, new_max_health)
|
||||
if part == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
if new_health > part.health then
|
||||
part.break_count = part.break_count + 1;
|
||||
end
|
||||
|
||||
part.health = new_health;
|
||||
part.max_health = new_max_health;
|
||||
|
||||
if part.max_health ~= 0 then
|
||||
part.health_percentage = part.health / part.max_health;
|
||||
end
|
||||
end
|
||||
|
||||
function body_part.draw_dynamic(part, position_on_screen, opacity_scale)
|
||||
body_part_UI_entity.draw_dynamic(part, position_on_screen, opacity_scale);
|
||||
end
|
||||
|
||||
function body_part.draw_static(part, position_on_screen, opacity_scale)
|
||||
body_part_UI_entity.draw_static(part, position_on_screen, opacity_scale);
|
||||
end
|
||||
|
||||
function body_part.init_module()
|
||||
singletons = require("MHR_Overlay.Game_Handler.singletons");
|
||||
customization_menu = require("MHR_Overlay.UI.customization_menu");
|
||||
config = require("MHR_Overlay.Misc.config");
|
||||
table_helpers = require("MHR_Overlay.Misc.table_helpers");
|
||||
health_UI_entity = require("MHR_Overlay.UI.UI_Entities.health_UI_entity");
|
||||
stamina_UI_entity = require("MHR_Overlay.UI.UI_Entities.stamina_UI_entity");
|
||||
rage_UI_entity = require("MHR_Overlay.UI.UI_Entities.rage_UI_entity");
|
||||
body_part_UI_entity = require("MHR_Overlay.UI.UI_Entities.body_part_UI_entity");
|
||||
screen = require("MHR_Overlay.Game_Handler.screen");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
end
|
||||
|
||||
return body_part;
|
||||
@@ -1,60 +1,72 @@
|
||||
local large_monster = {};
|
||||
local singletons;
|
||||
local customization_menu;
|
||||
local config;
|
||||
local table_helpers;
|
||||
local health_UI_entity;
|
||||
local stamina_UI_entity;
|
||||
local rage_UI_entity;
|
||||
local screen;
|
||||
local drawing;
|
||||
local body_part;
|
||||
|
||||
large_monster.list = {};
|
||||
|
||||
function large_monster.new(enemy)
|
||||
local new_monster = {};
|
||||
new_monster.is_large = true;
|
||||
local monster = {};
|
||||
monster.is_large = true;
|
||||
monster.id = 0;
|
||||
|
||||
new_monster.health = 0;
|
||||
new_monster.max_health = 999999;
|
||||
new_monster.health_percentage = 0;
|
||||
new_monster.missing_health = 0;
|
||||
new_monster.capture_health = 0;
|
||||
monster.health = 0;
|
||||
monster.max_health = 999999;
|
||||
monster.health_percentage = 0;
|
||||
monster.missing_health = 0;
|
||||
monster.capture_health = 0;
|
||||
|
||||
new_monster.stamina = 0;
|
||||
new_monster.max_stamina = 1000;
|
||||
new_monster.stamina_percentage = 0;
|
||||
new_monster.missing_stamina = 0;
|
||||
monster.stamina = 0;
|
||||
monster.max_stamina = 1000;
|
||||
monster.stamina_percentage = 0;
|
||||
monster.missing_stamina = 0;
|
||||
|
||||
new_monster.is_in_rage = false;
|
||||
new_monster.rage_point = 0;
|
||||
new_monster.rage_limit = 2001;
|
||||
new_monster.rage_timer = 0;
|
||||
new_monster.rage_duration = 600;
|
||||
new_monster.rage_count = 0;
|
||||
new_monster.rage_percentage = 0;
|
||||
monster.is_in_rage = false;
|
||||
monster.rage_point = 0;
|
||||
monster.rage_limit = 3000;
|
||||
monster.rage_timer = 0;
|
||||
monster.rage_duration = 600;
|
||||
monster.rage_count = 0;
|
||||
monster.rage_percentage = 0;
|
||||
|
||||
new_monster.rage_total_seconds_left = 0;
|
||||
new_monster.rage_minutes_left = 0;
|
||||
new_monster.rage_seconds_left = 0;
|
||||
new_monster.rage_timer_percentage = 0;
|
||||
monster.rage_total_seconds_left = 0;
|
||||
monster.rage_minutes_left = 0;
|
||||
monster.rage_seconds_left = 0;
|
||||
monster.rage_timer_percentage = 0;
|
||||
|
||||
new_monster.position = Vector3f.new(0, 0, 0);
|
||||
monster.position = Vector3f.new(0, 0, 0);
|
||||
|
||||
new_monster.name = "Large Monster";
|
||||
new_monster.size = 1;
|
||||
new_monster.small_border = 0;
|
||||
new_monster.big_border = 5;
|
||||
new_monster.king_border = 10;
|
||||
new_monster.crown = "";
|
||||
|
||||
large_monster.init(new_monster, enemy);
|
||||
monster.name = "Large Monster";
|
||||
monster.size = 1;
|
||||
monster.small_border = 0;
|
||||
monster.big_border = 5;
|
||||
monster.king_border = 10;
|
||||
monster.crown = "";
|
||||
|
||||
monster.parts = {};
|
||||
|
||||
large_monster.init(monster, enemy);
|
||||
large_monster.init_static_UI(monster);
|
||||
large_monster.init_dynamic_UI(monster);
|
||||
|
||||
if large_monster.list[enemy] == nil then
|
||||
large_monster.list[enemy] = new_monster;
|
||||
large_monster.list[enemy] = monster;
|
||||
end
|
||||
|
||||
return new_monster;
|
||||
return monster;
|
||||
end
|
||||
|
||||
function large_monster.get_monster(enemy)
|
||||
if large_monster.list[enemy] == nil then
|
||||
large_monster.list[enemy] = large_monster.new(enemy);
|
||||
return large_monster.new(enemy);
|
||||
|
||||
end
|
||||
|
||||
return large_monster.list[enemy];
|
||||
end
|
||||
|
||||
@@ -65,6 +77,8 @@ function large_monster.init(monster, enemy)
|
||||
return;
|
||||
end
|
||||
|
||||
monster.id = enemy_type;
|
||||
|
||||
local enemy_name = singletons.message_manager:call("getEnemyNameMessage", enemy_type);
|
||||
if enemy_name ~= nil then
|
||||
monster.name = enemy_name;
|
||||
@@ -105,35 +119,77 @@ function large_monster.init(monster, enemy)
|
||||
end
|
||||
end
|
||||
|
||||
function large_monster.init_static_UI(monster)
|
||||
monster.static_name_label = table_helpers.deep_copy(config.current_config.large_monster_UI.static.monster_name_label);
|
||||
|
||||
monster.health_static_UI = health_UI_entity.new(
|
||||
config.current_config.large_monster_UI.static.health.bar,
|
||||
config.current_config.large_monster_UI.static.health.text_label,
|
||||
config.current_config.large_monster_UI.static.health.value_label,
|
||||
config.current_config.large_monster_UI.static.health.percentage_label
|
||||
);
|
||||
|
||||
monster.stamina_static_UI = stamina_UI_entity.new(
|
||||
config.current_config.large_monster_UI.static.stamina.bar,
|
||||
config.current_config.large_monster_UI.static.stamina.text_label,
|
||||
config.current_config.large_monster_UI.static.stamina.value_label,
|
||||
config.current_config.large_monster_UI.static.stamina.percentage_label
|
||||
);
|
||||
|
||||
monster.rage_static_UI = rage_UI_entity.new(
|
||||
config.current_config.large_monster_UI.static.rage.bar,
|
||||
config.current_config.large_monster_UI.static.rage.text_label,
|
||||
config.current_config.large_monster_UI.static.rage.value_label,
|
||||
config.current_config.large_monster_UI.static.rage.percentage_label
|
||||
);
|
||||
|
||||
for REpart, part in pairs(monster.parts) do
|
||||
body_part.init_static_UI(part);
|
||||
end
|
||||
end
|
||||
|
||||
function large_monster.init_dynamic_UI(monster)
|
||||
monster.dynamic_name_label = table_helpers.deep_copy(config.current_config.large_monster_UI.dynamic.monster_name_label);
|
||||
|
||||
monster.health_dynamic_UI = health_UI_entity.new(
|
||||
config.current_config.large_monster_UI.dynamic.health.bar,
|
||||
config.current_config.large_monster_UI.dynamic.health.text_label,
|
||||
config.current_config.large_monster_UI.dynamic.health.value_label,
|
||||
config.current_config.large_monster_UI.dynamic.health.percentage_label
|
||||
);
|
||||
|
||||
monster.stamina_dynamic_UI = stamina_UI_entity.new(
|
||||
config.current_config.large_monster_UI.dynamic.stamina.bar,
|
||||
config.current_config.large_monster_UI.dynamic.stamina.text_label,
|
||||
config.current_config.large_monster_UI.dynamic.stamina.value_label,
|
||||
config.current_config.large_monster_UI.dynamic.stamina.percentage_label
|
||||
);
|
||||
|
||||
monster.rage_dynamic_UI = rage_UI_entity.new(
|
||||
config.current_config.large_monster_UI.dynamic.rage.bar,
|
||||
config.current_config.large_monster_UI.dynamic.rage.text_label,
|
||||
config.current_config.large_monster_UI.dynamic.rage.value_label,
|
||||
config.current_config.large_monster_UI.dynamic.rage.percentage_label
|
||||
);
|
||||
|
||||
for REpart, part in pairs(monster.parts) do
|
||||
body_part.init_dynamic_UI(part);
|
||||
end
|
||||
end
|
||||
|
||||
function large_monster.update(enemy)
|
||||
if enemy == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
|
||||
local monster = large_monster.get_monster(enemy);
|
||||
|
||||
local physical_param = enemy:get_field("<PhysicalParam>k__BackingField");
|
||||
if physical_param == nil then
|
||||
customization_menu.status = "No physical param";
|
||||
return;
|
||||
end
|
||||
|
||||
local status_param = enemy:get_field("<StatusParam>k__BackingField");
|
||||
if status_param == nil then
|
||||
customization_menu.status = "No status param";
|
||||
return;
|
||||
end
|
||||
|
||||
local anger_param = enemy:get_field("<AngerParam>k__BackingField");
|
||||
if anger_param == nil then
|
||||
customization_menu.status = "No anger param";
|
||||
return;
|
||||
end
|
||||
|
||||
local stamina_param = enemy:get_field("<StaminaParam>k__BackingField");
|
||||
if stamina_param == nil then
|
||||
customization_menu.status = "No stamina param";
|
||||
return;
|
||||
end
|
||||
|
||||
local vital_param = physical_param:call("getVital", 0, 0);
|
||||
if vital_param == nil then
|
||||
customization_menu.status = "No vital param";
|
||||
@@ -144,9 +200,21 @@ function large_monster.update(enemy)
|
||||
local max_health = vital_param:call("get_Max");
|
||||
local capture_health = physical_param:call("get_CaptureHpVital");
|
||||
|
||||
local stamina_param = enemy:get_field("<StaminaParam>k__BackingField");
|
||||
if stamina_param == nil then
|
||||
customization_menu.status = "No stamina param";
|
||||
return;
|
||||
end
|
||||
|
||||
local stamina = stamina_param:call("getStamina");
|
||||
local max_stamina = stamina_param:call("getMaxStamina");
|
||||
|
||||
local anger_param = enemy:get_field("<AngerParam>k__BackingField");
|
||||
if anger_param == nil then
|
||||
customization_menu.status = "No anger param";
|
||||
return;
|
||||
end
|
||||
|
||||
local is_in_rage = anger_param:call("isAnger");
|
||||
local rage_point = anger_param:call("get_AngerPoint");
|
||||
local rage_limit = anger_param:call("get_LimitAnger");
|
||||
@@ -154,6 +222,74 @@ function large_monster.update(enemy)
|
||||
local rage_duration = anger_param:call("get_TimerAnger");
|
||||
local rage_count = anger_param:call("get_CountAnger");
|
||||
|
||||
local vital_list = physical_param:get_field("_VitalList");
|
||||
if vital_list == nil then
|
||||
customization_menu.status = "No vital list";
|
||||
return;
|
||||
end
|
||||
|
||||
local vital_list_count = vital_list:call("get_Count");
|
||||
if vital_list_count == nil or vital_list_count < 2 then
|
||||
customization_menu.status = "No vital list count";
|
||||
return;
|
||||
end
|
||||
|
||||
local part_list = vital_list:call("get_Item", 1);
|
||||
if part_list == nil then
|
||||
customization_menu.status = "No part list";
|
||||
return;
|
||||
end
|
||||
|
||||
local part_list_count = part_list:call("get_Count");
|
||||
if part_list_count == nil then
|
||||
customization_menu.status = "No part list count";
|
||||
return;
|
||||
end
|
||||
|
||||
|
||||
local last_REpart = part_list:call("get_Item", part_list_count - 1);
|
||||
local last_REpart_health = 9999999;
|
||||
if last_REpart ~= nil then
|
||||
local _last_REpart_health = last_REpart:call("get_Current");
|
||||
if last_REpart_health ~= nil then
|
||||
last_REpart_health = _last_REpart_health;
|
||||
end
|
||||
end
|
||||
|
||||
local part_id = 1;
|
||||
for i = 0, part_list_count - 1 do
|
||||
|
||||
local REpart = part_list:call("get_Item", i);
|
||||
if REpart == nil then
|
||||
goto continue;
|
||||
end
|
||||
|
||||
local part_health = REpart:call("get_Current");
|
||||
if part_health == nil then
|
||||
goto continue;
|
||||
end
|
||||
|
||||
if part_health == last_REpart_health then
|
||||
break;
|
||||
end
|
||||
|
||||
local part_max_health = REpart:call("get_Max");
|
||||
if part_max_health == nil or part_max_health <= 0 then
|
||||
goto continue;
|
||||
end
|
||||
|
||||
local part = monster.parts[REpart];
|
||||
if part == nil then
|
||||
part = body_part.new(REpart, part_id);
|
||||
monster.parts[REpart] = part;
|
||||
end
|
||||
|
||||
body_part.update(part, part_health, part_max_health);
|
||||
|
||||
part_id = part_id + 1;
|
||||
::continue::
|
||||
end
|
||||
|
||||
local enemy_game_object = enemy:call("get_GameObject");
|
||||
if enemy_game_object == nil then
|
||||
customization_menu.status = "No enemy game object";
|
||||
@@ -171,9 +307,7 @@ function large_monster.update(enemy)
|
||||
customization_menu.status = "No enemy position";
|
||||
return;
|
||||
end
|
||||
|
||||
local monster = large_monster.get_monster(enemy);
|
||||
|
||||
|
||||
if health ~= nil then
|
||||
monster.health = health;
|
||||
end
|
||||
@@ -256,6 +390,80 @@ function large_monster.update(enemy)
|
||||
end
|
||||
end
|
||||
|
||||
function large_monster.draw_dynamic(monster, position_on_screen, opacity_scale)
|
||||
local monster_name_text = "";
|
||||
if config.current_config.large_monster_UI.dynamic.monster_name_label.include.monster_name then
|
||||
monster_name_text = string.format("%s ", monster.name);
|
||||
end
|
||||
|
||||
if config.current_config.large_monster_UI.dynamic.monster_name_label.include.crown and monster.crown ~= "" then
|
||||
monster_name_text = monster_name_text .. string.format("%s ", monster.crown);
|
||||
end
|
||||
if config.current_config.large_monster_UI.dynamic.monster_name_label.include.size then
|
||||
monster_name_text = monster_name_text .. string.format("#%.0f ", 100 * monster.size);
|
||||
end
|
||||
|
||||
if config.current_config.large_monster_UI.dynamic.monster_name_label.include.scrown_thresholds then
|
||||
monster_name_text = monster_name_text .. string.format("<=%.0f >=%.0f >=%.0f", 100 * monster.small_border,
|
||||
100 * monster.big_border, 100 * monster.king_border);
|
||||
end
|
||||
|
||||
drawing.draw_label(monster.dynamic_name_label, position_on_screen, opacity_scale, monster_name_text .. " " .. tostring(monster.id));
|
||||
|
||||
health_UI_entity.draw(monster, monster.health_dynamic_UI, position_on_screen, opacity_scale);
|
||||
stamina_UI_entity.draw(monster, monster.stamina_dynamic_UI, position_on_screen, opacity_scale);
|
||||
rage_UI_entity.draw(monster, monster.rage_dynamic_UI, position_on_screen, opacity_scale);
|
||||
|
||||
local j = 0;
|
||||
for REpart, part in pairs(monster.parts) do
|
||||
local part_position_on_screen = {
|
||||
x = position_on_screen.x + config.current_config.large_monster_UI.dynamic.parts.offset.x + config.current_config.large_monster_UI.dynamic.parts.spacing.x * j,
|
||||
y = position_on_screen.y + config.current_config.large_monster_UI.dynamic.parts.offset.y + config.current_config.large_monster_UI.dynamic.parts.spacing.y * j;
|
||||
}
|
||||
|
||||
body_part.draw_dynamic(part, part_position_on_screen, opacity_scale);
|
||||
|
||||
j = j + 1;
|
||||
end
|
||||
end
|
||||
|
||||
function large_monster.draw_static(monster, position_on_screen, opacity_scale)
|
||||
local monster_name_text = "";
|
||||
if config.current_config.large_monster_UI.static.monster_name_label.include.monster_name then
|
||||
monster_name_text = string.format("%s ", monster.name);
|
||||
end
|
||||
|
||||
if config.current_config.large_monster_UI.static.monster_name_label.include.crown and monster.crown ~= "" then
|
||||
monster_name_text = monster_name_text .. string.format("%s ", monster.crown);
|
||||
end
|
||||
if config.current_config.large_monster_UI.static.monster_name_label.include.size then
|
||||
monster_name_text = monster_name_text .. string.format("#%.0f ", 100 * monster.size);
|
||||
end
|
||||
|
||||
if config.current_config.large_monster_UI.static.monster_name_label.include.scrown_thresholds then
|
||||
monster_name_text = monster_name_text .. string.format("<=%.0f >=%.0f >=%.0f", 100 * monster.small_border,
|
||||
100 * monster.big_border, 100 * monster.king_border);
|
||||
end
|
||||
|
||||
drawing.draw_label(monster.static_name_label, position_on_screen, opacity_scale, monster_name_text .. " " .. tostring(monster.id));
|
||||
|
||||
health_UI_entity.draw(monster, monster.health_static_UI, position_on_screen, opacity_scale);
|
||||
stamina_UI_entity.draw(monster, monster.stamina_static_UI, position_on_screen, opacity_scale);
|
||||
rage_UI_entity.draw(monster, monster.rage_static_UI, position_on_screen, opacity_scale);
|
||||
|
||||
local j = 0;
|
||||
for REpart, part in pairs(monster.parts) do
|
||||
local part_position_on_screen = {
|
||||
x = position_on_screen.x + config.current_config.large_monster_UI.static.parts.offset.x + config.current_config.large_monster_UI.static.parts.spacing.x * j,
|
||||
y = position_on_screen.y + config.current_config.large_monster_UI.static.parts.offset.y + config.current_config.large_monster_UI.static.parts.spacing.y * j;
|
||||
}
|
||||
|
||||
body_part.draw_static(part, part_position_on_screen, opacity_scale);
|
||||
|
||||
j = j + 1;
|
||||
end
|
||||
end
|
||||
|
||||
function large_monster.init_list()
|
||||
large_monster.list = {};
|
||||
end
|
||||
@@ -263,6 +471,14 @@ end
|
||||
function large_monster.init_module()
|
||||
singletons = require("MHR_Overlay.Game_Handler.singletons");
|
||||
customization_menu = require("MHR_Overlay.UI.customization_menu");
|
||||
config = require("MHR_Overlay.Misc.config");
|
||||
table_helpers = require("MHR_Overlay.Misc.table_helpers");
|
||||
body_part = require("MHR_Overlay.Monsters.body_part");
|
||||
health_UI_entity = require("MHR_Overlay.UI.UI_Entities.health_UI_entity");
|
||||
stamina_UI_entity = require("MHR_Overlay.UI.UI_Entities.stamina_UI_entity");
|
||||
rage_UI_entity = require("MHR_Overlay.UI.UI_Entities.rage_UI_entity");
|
||||
screen = require("MHR_Overlay.Game_Handler.screen");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
end
|
||||
|
||||
return large_monster;
|
||||
@@ -1,33 +1,41 @@
|
||||
local small_monster = {};
|
||||
local singletons;
|
||||
local customization_menu;
|
||||
local customization_menu;
|
||||
local config;
|
||||
local table_helpers;
|
||||
local health_UI_entity;
|
||||
local stamina_UI_entity;
|
||||
local screen;
|
||||
local drawing;
|
||||
|
||||
small_monster.list = {};
|
||||
|
||||
function small_monster.new(enemy)
|
||||
local new_monster = {};
|
||||
new_monster.is_large = false;
|
||||
local monster = {};
|
||||
monster.is_large = false;
|
||||
|
||||
new_monster.health = 0;
|
||||
new_monster.max_health = 999999;
|
||||
new_monster.health_percentage = 0;
|
||||
new_monster.missing_health = 0;
|
||||
new_monster.capture_health = 0;
|
||||
monster.health = 0;
|
||||
monster.max_health = 999999;
|
||||
monster.health_percentage = 0;
|
||||
monster.missing_health = 0;
|
||||
monster.capture_health = 0;
|
||||
|
||||
new_monster.stamina = 0;
|
||||
new_monster.max_stamina = 1000;
|
||||
new_monster.stamina_percentage = 0;
|
||||
new_monster.missing_stamina = 0;
|
||||
monster.stamina = 0;
|
||||
monster.max_stamina = 1000;
|
||||
monster.stamina_percentage = 0;
|
||||
monster.missing_stamina = 0;
|
||||
|
||||
new_monster.position = Vector3f.new(0, 0, 0);
|
||||
new_monster.name = "Small Monster";
|
||||
monster.position = Vector3f.new(0, 0, 0);
|
||||
monster.name = "Small Monster";
|
||||
|
||||
small_monster.init(new_monster, enemy);
|
||||
small_monster.init(monster, enemy);
|
||||
small_monster.init_UI(monster);
|
||||
|
||||
if small_monster.list[enemy] == nil then
|
||||
small_monster.list[enemy] = new_monster;
|
||||
small_monster.list[enemy] = monster;
|
||||
end
|
||||
|
||||
return new_monster;
|
||||
return monster;
|
||||
end
|
||||
|
||||
function small_monster.get_monster(enemy)
|
||||
@@ -51,6 +59,24 @@ function small_monster.init(monster, enemy)
|
||||
end
|
||||
end
|
||||
|
||||
function small_monster.init_UI(monster)
|
||||
monster.name_label = table_helpers.deep_copy(config.current_config.small_monster_UI.monster_name_label);
|
||||
|
||||
monster.health_UI = health_UI_entity.new(
|
||||
config.current_config.small_monster_UI.health.bar,
|
||||
config.current_config.small_monster_UI.health.text_label,
|
||||
config.current_config.small_monster_UI.health.value_label,
|
||||
config.current_config.small_monster_UI.health.percentage_label
|
||||
);
|
||||
|
||||
monster.stamina_UI = stamina_UI_entity.new(
|
||||
config.current_config.small_monster_UI.stamina.bar,
|
||||
config.current_config.small_monster_UI.stamina.text_label,
|
||||
config.current_config.small_monster_UI.stamina.value_label,
|
||||
config.current_config.small_monster_UI.stamina.percentage_label
|
||||
);
|
||||
end
|
||||
|
||||
function small_monster.update(enemy)
|
||||
if enemy == nil then
|
||||
return;
|
||||
@@ -147,6 +173,13 @@ function small_monster.update(enemy)
|
||||
end
|
||||
end
|
||||
|
||||
function small_monster.draw(monster, position_on_screen, opacity_scale)
|
||||
drawing.draw_label(monster.name_label, position_on_screen, opacity_scale, monster.name);
|
||||
|
||||
health_UI_entity.draw(monster, monster.health_UI, position_on_screen, opacity_scale);
|
||||
stamina_UI_entity.draw(monster, monster.stamina_UI, position_on_screen, opacity_scale);
|
||||
end
|
||||
|
||||
function small_monster.init_list()
|
||||
small_monster.list = {};
|
||||
end
|
||||
@@ -154,6 +187,12 @@ end
|
||||
function small_monster.init_module()
|
||||
singletons = require("MHR_Overlay.Game_Handler.singletons");
|
||||
customization_menu = require("MHR_Overlay.UI.customization_menu");
|
||||
config = require("MHR_Overlay.Misc.config");
|
||||
table_helpers = require("MHR_Overlay.Misc.table_helpers");
|
||||
health_UI_entity = require("MHR_Overlay.UI.UI_Entities.health_UI_entity");
|
||||
stamina_UI_entity = require("MHR_Overlay.UI.UI_Entities.stamina_UI_entity");
|
||||
screen = require("MHR_Overlay.Game_Handler.screen");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
end
|
||||
|
||||
return small_monster;
|
||||
198
MHR_Overlay/UI/Modules/damage_meter_UI.lua
Normal file
198
MHR_Overlay/UI/Modules/damage_meter_UI.lua
Normal file
@@ -0,0 +1,198 @@
|
||||
local damage_meter_UI = {};
|
||||
local singletons;
|
||||
local config;
|
||||
local customization_menu;
|
||||
local player;
|
||||
local quest_status;
|
||||
local screen;
|
||||
local drawing;
|
||||
|
||||
damage_meter_UI.last_displayed_players = {};
|
||||
|
||||
function damage_meter_UI.draw()
|
||||
|
||||
if player.total.display.total_damage == 0 and config.current_config.damage_meter_UI.settings.hide_module_if_total_damage_is_zero then
|
||||
return;
|
||||
end
|
||||
|
||||
if singletons.lobby_manager == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
if singletons.progress_manager == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
-- myself player
|
||||
local myself_player_info = singletons.lobby_manager:get_field("_myHunterInfo");
|
||||
if myself_player_info == nil then
|
||||
customization_menu.status = "No myself player info list";
|
||||
return;
|
||||
end
|
||||
|
||||
local myself_player_name = myself_player_info:get_field("_name");
|
||||
if myself_player_name == nil then
|
||||
customization_menu.status = "No myself player name";
|
||||
return;
|
||||
end
|
||||
|
||||
if quest_status.is_online then
|
||||
player.myself_id = singletons.lobby_manager:get_field("_myselfQuestIndex");
|
||||
if player.myself_id == nil then
|
||||
customization_menu.status = "No myself player id";
|
||||
return;
|
||||
end
|
||||
else
|
||||
player.myself_id = singletons.lobby_manager:get_field("_myselfIndex");
|
||||
if player.myself_id == nil then
|
||||
customization_menu.status = "No myself player id";
|
||||
return;
|
||||
end
|
||||
end
|
||||
|
||||
local myself_hunter_rank = singletons.progress_manager:call("get_HunterRank");
|
||||
if myself_hunter_rank == nil then
|
||||
customization_menu.status = "No myself hunter rank";
|
||||
myself_hunter_rank = 0;
|
||||
end
|
||||
|
||||
if player.list[player.myself_id] == nil then
|
||||
player.list[player.myself_id] = player.new(player.myself_id, myself_player_name, myself_hunter_rank);
|
||||
player.myself = player.list[player.myself_id];
|
||||
end
|
||||
|
||||
local quest_players = {};
|
||||
|
||||
if quest_status.index > 2 then
|
||||
quest_players = damage_meter_UI.last_displayed_players;
|
||||
else
|
||||
-- other players
|
||||
local player_info_list = singletons.lobby_manager:get_field("_questHunterInfo");
|
||||
if player_info_list == nil then
|
||||
customization_menu.status = "No player info list";
|
||||
end
|
||||
|
||||
local count = player_info_list:call("get_Count");
|
||||
if count == nil then
|
||||
customization_menu.status = "No player info list count";
|
||||
return;
|
||||
end
|
||||
|
||||
for i = 0, count - 1 do
|
||||
|
||||
local player_info = player_info_list:call("get_Item", i);
|
||||
if player_info == nil then
|
||||
goto continue
|
||||
end
|
||||
|
||||
local player_id = player_info:get_field("_memberIndex");
|
||||
if player_id == nil then
|
||||
|
||||
goto continue
|
||||
end
|
||||
|
||||
local player_hunter_rank = player_info:get_field("_hunterRank");
|
||||
if player_hunter_rank == nil then
|
||||
goto continue
|
||||
end
|
||||
|
||||
if player_id == player.myself_id and config.current_config.damage_meter_UI.settings.my_damage_bar_location ~= "Normal" then
|
||||
player.list[player.myself_id].hunter_rank = player_hunter_rank;
|
||||
goto continue
|
||||
end
|
||||
|
||||
local player_name = player_info:get_field("_name");
|
||||
if player_name == nil then
|
||||
goto continue
|
||||
end
|
||||
|
||||
if player.list[player_id] == nil then
|
||||
player.list[player_id] = player.new(player_id, player_name, player_hunter_rank);
|
||||
elseif player.list[player_id].name ~= player_name then
|
||||
player.list[player_id] = player.new(player_id, player_name, player_hunter_rank);
|
||||
end
|
||||
|
||||
table.insert(quest_players, player.list[player_id]);
|
||||
|
||||
::continue::
|
||||
end
|
||||
|
||||
-- sort here
|
||||
if config.current_config.damage_meter_UI.sorting.type == "Normal" and config.current_config.damage_meter_UI.sorting.reversed_order then
|
||||
|
||||
local reversed_quest_players = {};
|
||||
for i = #quest_players, 1, -1 do
|
||||
table.insert(reversed_quest_players, quest_players[i]);
|
||||
end
|
||||
quest_players = reversed_quest_players;
|
||||
elseif config.current_config.damage_meter_UI.sorting.type == "Damage" then
|
||||
if config.current_config.damage_meter_UI.sorting.reversed_order then
|
||||
table.sort(quest_players, function(left, right)
|
||||
return left.display.total_damage < right.display.total_damage;
|
||||
end);
|
||||
else
|
||||
table.sort(quest_players, function(left, right)
|
||||
return left.display.total_damage > right.display.total_damage;
|
||||
end);
|
||||
end
|
||||
end
|
||||
|
||||
if config.current_config.damage_meter_UI.settings.my_damage_bar_location == "First" then
|
||||
table.insert(quest_players, 1, player.list[player.myself_id]);
|
||||
elseif config.current_config.damage_meter_UI.settings.my_damage_bar_location == "Last" then
|
||||
table.insert(quest_players, #quest_players + 1, player.list[player.myself_id]);
|
||||
elseif #quest_players == 0 then
|
||||
table.insert(quest_players, 1, player.list[player.myself_id]);
|
||||
end
|
||||
|
||||
damage_meter_UI.last_displayed_players = quest_players;
|
||||
end
|
||||
|
||||
local top_damage = 0;
|
||||
for _, _player in ipairs(quest_players) do
|
||||
if _player.display.total_damage > top_damage then
|
||||
top_damage = _player.display.total_damage;
|
||||
end
|
||||
end
|
||||
|
||||
-- draw
|
||||
local position_on_screen = screen.calculate_absolute_coordinates(config.current_config.damage_meter_UI.position);
|
||||
for _, _player in ipairs(quest_players) do
|
||||
|
||||
if _player.display.total_damage == 0 and config.current_config.damage_meter_UI.settings.hide_player_if_player_damage_is_zero then
|
||||
goto continue1
|
||||
end
|
||||
|
||||
player.draw(_player, position_on_screen, 1, top_damage);
|
||||
|
||||
if config.current_config.damage_meter_UI.settings.orientation == "Horizontal" then
|
||||
position_on_screen.x = position_on_screen.x + config.current_config.damage_meter_UI.spacing.x;
|
||||
else
|
||||
position_on_screen.y = position_on_screen.y + config.current_config.damage_meter_UI.spacing.y;
|
||||
end
|
||||
|
||||
::continue1::
|
||||
|
||||
end
|
||||
|
||||
-- draw total damage
|
||||
if not config.current_config.damage_meter_UI.settings.total_damage_offset_is_relative then
|
||||
position_on_screen = screen.calculate_absolute_coordinates(config.current_config.damage_meter_UI.position);
|
||||
end
|
||||
|
||||
drawing.draw_label(config.current_config.damage_meter_UI.total_damage_label, position_on_screen, 1);
|
||||
drawing.draw_label(config.current_config.damage_meter_UI.total_damage_value_label, position_on_screen, 1, player.total.display.total_damage);
|
||||
|
||||
end
|
||||
|
||||
function damage_meter_UI.init_module()
|
||||
singletons = require("MHR_Overlay.Game_Handler.singletons");
|
||||
config = require("MHR_Overlay.Misc.config");
|
||||
customization_menu = require("MHR_Overlay.UI.customization_menu");
|
||||
player = require("MHR_Overlay.Damage_Meter.player");
|
||||
quest_status = require("MHR_Overlay.Game_Handler.quest_status");
|
||||
screen = require("MHR_Overlay.Game_Handler.screen");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
end
|
||||
|
||||
return damage_meter_UI;
|
||||
148
MHR_Overlay/UI/Modules/large_monster_UI.lua
Normal file
148
MHR_Overlay/UI/Modules/large_monster_UI.lua
Normal file
@@ -0,0 +1,148 @@
|
||||
local large_monster_UI = {};
|
||||
local singletons;
|
||||
local config;
|
||||
local customization_menu;
|
||||
local large_monster;
|
||||
local screen;
|
||||
local player;
|
||||
local drawing;
|
||||
local table_helpers;
|
||||
local health_UI_entity;
|
||||
local stamina_UI_entity;
|
||||
local rage_UI_entity;
|
||||
|
||||
function large_monster_UI.draw()
|
||||
if singletons.enemy_manager == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
local displayed_monsters = {};
|
||||
|
||||
local enemy_count = singletons.enemy_manager:call("getBossEnemyCount");
|
||||
if enemy_count == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
for i = 0, enemy_count - 1 do
|
||||
local enemy = singletons.enemy_manager:call("getBossEnemy", i);
|
||||
if enemy == nil then
|
||||
customization_menu.status = "No enemy";
|
||||
break
|
||||
end
|
||||
|
||||
local monster = large_monster.list[enemy];
|
||||
if monster == nil then
|
||||
customization_menu.status = "No monster hp entry";
|
||||
break
|
||||
end
|
||||
|
||||
table.insert(displayed_monsters, monster);
|
||||
end
|
||||
|
||||
if config.current_config.large_monster_UI.dynamic.enabled then
|
||||
local i = 0;
|
||||
for _, monster in ipairs(displayed_monsters) do
|
||||
|
||||
if config.current_config.large_monster_UI.dynamic.settings.max_distance == 0 then
|
||||
break;
|
||||
end
|
||||
|
||||
local position_on_screen = {};
|
||||
|
||||
local world_offset = Vector3f.new(config.current_config.large_monster_UI.dynamic.world_offset.x, config.current_config.large_monster_UI.dynamic.world_offset.y, config.current_config.large_monster_UI.dynamic.world_offset.z);
|
||||
|
||||
position_on_screen = draw.world_to_screen(monster.position + world_offset);
|
||||
|
||||
if position_on_screen == nil then
|
||||
goto continue;
|
||||
end
|
||||
|
||||
position_on_screen.x = position_on_screen.x + config.current_config.large_monster_UI.dynamic.viewport_offset.x;
|
||||
position_on_screen.y = position_on_screen.y + config.current_config.large_monster_UI.dynamic.viewport_offset.y;
|
||||
|
||||
local opacity_scale = 1;
|
||||
local distance = (player.myself_position - monster.position):length();
|
||||
if distance > config.current_config.large_monster_UI.dynamic.settings.max_distance then
|
||||
goto continue;
|
||||
end
|
||||
|
||||
if config.current_config.large_monster_UI.dynamic.settings.opacity_falloff then
|
||||
opacity_scale = 1 - (distance / config.current_config.large_monster_UI.dynamic.settings.max_distance);
|
||||
end
|
||||
|
||||
large_monster.draw_dynamic(monster, position_on_screen, opacity_scale);
|
||||
|
||||
i = i + 1;
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
|
||||
if config.current_config.large_monster_UI.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
|
||||
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
|
||||
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;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function large_monster_UI.init_module()
|
||||
singletons = require("MHR_Overlay.Game_Handler.singletons");
|
||||
config = require("MHR_Overlay.Misc.config");
|
||||
customization_menu = require("MHR_Overlay.UI.customization_menu");
|
||||
large_monster = require("MHR_Overlay.Monsters.large_monster");
|
||||
screen = require("MHR_Overlay.Game_Handler.screen");
|
||||
player = require("MHR_Overlay.Damage_Meter.player");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
table_helpers = require("MHR_Overlay.Misc.table_helpers");
|
||||
health_UI_entity = require("MHR_Overlay.UI.UI_Entities.health_UI_entity");
|
||||
stamina_UI_entity = require("MHR_Overlay.UI.UI_Entities.stamina_UI_entity");
|
||||
rage_UI_entity = require("MHR_Overlay.UI.UI_Entities.rage_UI_entity");
|
||||
end
|
||||
|
||||
return large_monster_UI;
|
||||
140
MHR_Overlay/UI/Modules/small_monster_UI.lua
Normal file
140
MHR_Overlay/UI/Modules/small_monster_UI.lua
Normal file
@@ -0,0 +1,140 @@
|
||||
local small_monster_UI = {};
|
||||
local singletons;
|
||||
local config;
|
||||
local small_monster;
|
||||
local customization_menu;
|
||||
local screen;
|
||||
local player;
|
||||
local drawing;
|
||||
local table_helpers;
|
||||
local health_UI_entity;
|
||||
local stamina_UI_entity;
|
||||
|
||||
function small_monster_UI.draw()
|
||||
if singletons.enemy_manager == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
local displayed_monsters = {};
|
||||
|
||||
local enemy_count = singletons.enemy_manager:call("getZakoEnemyCount");
|
||||
if enemy_count == nil then
|
||||
customization_menu.status = "No enemy count";
|
||||
return;
|
||||
end
|
||||
|
||||
for i = 0, enemy_count - 1 do
|
||||
local enemy = singletons.enemy_manager:call("getZakoEnemy", i);
|
||||
if enemy == nil then
|
||||
customization_menu.status = "No enemy";
|
||||
break
|
||||
end
|
||||
|
||||
local monster = small_monster.list[enemy];
|
||||
if monster == nil then
|
||||
customization_menu.status = "No monster hp entry";
|
||||
break
|
||||
end
|
||||
|
||||
table.insert(displayed_monsters, monster);
|
||||
end
|
||||
|
||||
if not config.current_config.small_monster_UI.dynamic_positioning.enabled then
|
||||
-- sort here
|
||||
|
||||
if config.current_config.small_monster_UI.static_sorting.type == "Normal" and config.current_config.small_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.small_monster_UI.static_sorting.type == "Health" then
|
||||
if config.current_config.small_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.small_monster_UI.static_sorting.type == "Health Percentage" then
|
||||
if config.current_config.small_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
|
||||
end
|
||||
end
|
||||
|
||||
local i = 0;
|
||||
for _, monster in ipairs(displayed_monsters) do
|
||||
local position_on_screen;
|
||||
|
||||
if config.current_config.small_monster_UI.dynamic_positioning.enabled then
|
||||
local world_offset = Vector3f.new(config.current_config.small_monster_UI.dynamic_positioning.world_offset.x, config.current_config.small_monster_UI.dynamic_positioning.world_offset.y, config.current_config.small_monster_UI.dynamic_positioning.world_offset.z);
|
||||
|
||||
position_on_screen = draw.world_to_screen(monster.position + world_offset);
|
||||
|
||||
if position_on_screen == nil then
|
||||
goto continue
|
||||
end
|
||||
|
||||
position_on_screen.x = position_on_screen.x + config.current_config.small_monster_UI.dynamic_positioning.viewport_offset.x;
|
||||
position_on_screen.y = position_on_screen.y + config.current_config.small_monster_UI.dynamic_positioning.viewport_offset.y;
|
||||
else
|
||||
position_on_screen = screen.calculate_absolute_coordinates(config.current_config.small_monster_UI.static_position);
|
||||
if config.current_config.small_monster_UI.settings.orientation == "Horizontal" then
|
||||
position_on_screen.x = position_on_screen.x + config.current_config.small_monster_UI.static_spacing.x * i;
|
||||
|
||||
else
|
||||
position_on_screen.y = position_on_screen.y + config.current_config.small_monster_UI.static_spacing.y * i;
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local opacity_scale = 1;
|
||||
if config.current_config.small_monster_UI.dynamic_positioning.enabled then
|
||||
if config.current_config.small_monster_UI.dynamic_positioning.max_distance == 0 then
|
||||
return;
|
||||
end
|
||||
|
||||
local distance = (player.myself_position - monster.position):length();
|
||||
|
||||
if distance > config.current_config.small_monster_UI.dynamic_positioning.max_distance then
|
||||
goto continue;
|
||||
end
|
||||
|
||||
if config.current_config.small_monster_UI.dynamic_positioning.opacity_falloff then
|
||||
opacity_scale = 1 - (distance / config.current_config.small_monster_UI.dynamic_positioning.max_distance);
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
small_monster.draw(monster, position_on_screen, opacity_scale);
|
||||
|
||||
i = i + 1;
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
|
||||
function small_monster_UI.init_module()
|
||||
singletons = require("MHR_Overlay.Game_Handler.singletons");
|
||||
config = require("MHR_Overlay.Misc.config");
|
||||
customization_menu = require("MHR_Overlay.UI.customization_menu");
|
||||
small_monster = require("MHR_Overlay.Monsters.small_monster");
|
||||
screen = require("MHR_Overlay.Game_Handler.screen");
|
||||
player = require("MHR_Overlay.Damage_Meter.player");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
table_helpers = require("MHR_Overlay.Misc.table_helpers");
|
||||
health_UI_entity = require("MHR_Overlay.UI.UI_Entities.health_UI_entity");
|
||||
stamina_UI_entity = require("MHR_Overlay.UI.UI_Entities.stamina_UI_entity");
|
||||
end
|
||||
|
||||
return small_monster_UI;
|
||||
46
MHR_Overlay/UI/Modules/time_UI.lua
Normal file
46
MHR_Overlay/UI/Modules/time_UI.lua
Normal file
@@ -0,0 +1,46 @@
|
||||
local time_UI = {};
|
||||
local singletons;
|
||||
local customization_menu;
|
||||
local screen;
|
||||
local config;
|
||||
local drawing;
|
||||
|
||||
function time_UI.draw()
|
||||
if singletons.quest_manager == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
|
||||
|
||||
local quest_time_elapsed_minutes = singletons.quest_manager:call("getQuestElapsedTimeMin");
|
||||
if quest_time_elapsed_minutes == nil then
|
||||
customization_menu.status = "No quest time elapsed minutes";
|
||||
return;
|
||||
end
|
||||
|
||||
local quest_time_total_elapsed_seconds = singletons.quest_manager:call("getQuestElapsedTimeSec");
|
||||
if quest_time_total_elapsed_seconds == nil then
|
||||
customization_menu.status = "No quest time total elapsed seconds";
|
||||
return;
|
||||
end
|
||||
|
||||
if quest_time_total_elapsed_seconds == 0 then
|
||||
return;
|
||||
end
|
||||
|
||||
local quest_time_elapsed_seconds = quest_time_total_elapsed_seconds - quest_time_elapsed_minutes * 60;
|
||||
|
||||
local position_on_screen = screen.calculate_absolute_coordinates(config.current_config.time_UI.position);
|
||||
|
||||
drawing.draw_label(config.current_config.time_UI.time_label, position_on_screen, 1, quest_time_elapsed_minutes, quest_time_elapsed_seconds);
|
||||
end
|
||||
|
||||
function time_UI.init_module()
|
||||
singletons = require("MHR_Overlay.Game_Handler.singletons");
|
||||
customization_menu = require("MHR_Overlay.UI.customization_menu");
|
||||
screen = require("MHR_Overlay.Game_Handler.screen");
|
||||
config = require("MHR_Overlay.Misc.config");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
end
|
||||
|
||||
return time_UI;
|
||||
60
MHR_Overlay/UI/UI_Entities/body_part_UI_entity.lua
Normal file
60
MHR_Overlay/UI/UI_Entities/body_part_UI_entity.lua
Normal file
@@ -0,0 +1,60 @@
|
||||
local body_part_UI_entity = {};
|
||||
local config;
|
||||
local table_helpers;
|
||||
local drawing;
|
||||
|
||||
function body_part_UI_entity.new(bar, name_label, text_label, value_label, percentage_label)
|
||||
local entity = {};
|
||||
|
||||
entity.bar = table_helpers.deep_copy(bar);
|
||||
entity.name_label = table_helpers.deep_copy(name_label);
|
||||
entity.text_label = table_helpers.deep_copy(text_label);
|
||||
entity.value_label = table_helpers.deep_copy(value_label);
|
||||
entity.percentage_label = table_helpers.deep_copy(percentage_label);
|
||||
|
||||
return entity;
|
||||
end
|
||||
|
||||
function body_part_UI_entity.draw_dynamic(part, position_on_screen, opacity_scale)
|
||||
|
||||
local part_name = "";
|
||||
if config.current_config.large_monster_UI.dynamic.parts.part_name_label.include.part_name then
|
||||
part_name = part.name .. " ";
|
||||
end
|
||||
if config.current_config.large_monster_UI.dynamic.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_dynamic_UI.bar, position_on_screen, opacity_scale, part.health_percentage);
|
||||
|
||||
drawing.draw_label(part.body_part_dynamic_UI.name_label, position_on_screen, opacity_scale, part_name);
|
||||
drawing.draw_label(part.body_part_dynamic_UI.text_label, position_on_screen, opacity_scale);
|
||||
drawing.draw_label(part.body_part_dynamic_UI.value_label, position_on_screen, opacity_scale, part.health, part.max_health);
|
||||
drawing.draw_label(part.body_part_dynamic_UI.percentage_label, position_on_screen, opacity_scale, 100 * part.health_percentage);
|
||||
end
|
||||
|
||||
function body_part_UI_entity.draw_static(part, position_on_screen, opacity_scale)
|
||||
|
||||
local part_name = "";
|
||||
if config.current_config.large_monster_UI.static.parts.part_name_label.include.part_name then
|
||||
part_name = part.name .. " ";
|
||||
end
|
||||
if config.current_config.large_monster_UI.static.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_static_UI.bar, position_on_screen, opacity_scale, part.health_percentage);
|
||||
|
||||
drawing.draw_label(part.body_part_static_UI.name_label, position_on_screen, opacity_scale, part_name);
|
||||
drawing.draw_label(part.body_part_static_UI.text_label, position_on_screen, opacity_scale);
|
||||
drawing.draw_label(part.body_part_static_UI.value_label, position_on_screen, opacity_scale, part.health, part.max_health);
|
||||
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.init_module()
|
||||
table_helpers = require("MHR_Overlay.Misc.table_helpers");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
config = require("MHR_Overlay.Misc.config");
|
||||
end
|
||||
|
||||
return body_part_UI_entity;
|
||||
78
MHR_Overlay/UI/UI_Entities/damage_UI_entity.lua
Normal file
78
MHR_Overlay/UI/UI_Entities/damage_UI_entity.lua
Normal file
@@ -0,0 +1,78 @@
|
||||
local damage_UI_entity = {};
|
||||
local table_helpers;
|
||||
local drawing;
|
||||
local config;
|
||||
local player;
|
||||
|
||||
function damage_UI_entity.new(bar, highlighted_bar, player_name_label, value_label, percentage_label)
|
||||
local entity = {};
|
||||
|
||||
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.value_label = table_helpers.deep_copy(value_label);
|
||||
entity.percentage_label = table_helpers.deep_copy(percentage_label);
|
||||
|
||||
return entity;
|
||||
end
|
||||
|
||||
function damage_UI_entity.draw(_player, position_on_screen, opacity_scale, top_damage)
|
||||
local player_include = config.current_config.damage_meter_UI.player_name_label.include.others;
|
||||
if _player.id == _player.myself_id then
|
||||
player_include = config.current_config.damage_meter_UI.player_name_label.include.myself;
|
||||
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 .. "Player ";
|
||||
end
|
||||
|
||||
if player_include.player_id then
|
||||
player_name_text = player_name_text .. string.format("%d ", _player.id);
|
||||
end
|
||||
|
||||
if player_include.player_name then
|
||||
player_name_text = player_name_text .. _player.name;
|
||||
end
|
||||
|
||||
local player_damage_percentage = 0;
|
||||
if player.total.display.total_damage ~= 0 then
|
||||
player_damage_percentage = _player.display.total_damage / player.total.display.total_damage;
|
||||
end
|
||||
|
||||
local player_damage_bar_percentage = 0;
|
||||
if config.current_config.damage_meter_UI.settings.damage_bar_relative_to == "Total Damage" then
|
||||
if _player.total.display.total_damage ~= 0 then
|
||||
player_damage_bar_percentage = _player.display.total_damage / player.total.display.total_damage;
|
||||
end
|
||||
else
|
||||
if top_damage ~= 0 then
|
||||
player_damage_bar_percentage = _player.display.total_damage / top_damage;
|
||||
end
|
||||
end
|
||||
|
||||
if _player.id == player.myself_id and config.current_config.damage_meter_UI.settings.highlighted_bar == "Me" then
|
||||
drawing.draw_bar(_player.damage_UI.highlighted_bar, position_on_screen, opacity_scale, player_damage_bar_percentage);
|
||||
elseif config.current_config.damage_meter_UI.settings.highlighted_bar == "Top Damage" and _player.display.total_damage == top_damage then
|
||||
drawing.draw_bar(_player.damage_UI.highlighted_bar, position_on_screen, opacity_scale, player_damage_bar_percentage);
|
||||
else
|
||||
drawing.draw_bar(_player.damage_UI.bar, position_on_screen, opacity_scale, player_damage_bar_percentage);
|
||||
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);
|
||||
end
|
||||
|
||||
function damage_UI_entity.init_module()
|
||||
table_helpers = require("MHR_Overlay.Misc.table_helpers");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
config = require("MHR_Overlay.Misc.config");
|
||||
player = require("MHR_Overlay.Damage_Meter.player");
|
||||
end
|
||||
|
||||
return damage_UI_entity;
|
||||
30
MHR_Overlay/UI/UI_Entities/health_UI_entity.lua
Normal file
30
MHR_Overlay/UI/UI_Entities/health_UI_entity.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
local health_UI_entity = {};
|
||||
local table_helpers;
|
||||
local drawing;
|
||||
|
||||
function health_UI_entity.new(bar, text_label, value_label, percentage_label)
|
||||
local entity = {};
|
||||
|
||||
entity.bar = table_helpers.deep_copy(bar);
|
||||
entity.text_label = table_helpers.deep_copy(text_label);
|
||||
entity.value_label = table_helpers.deep_copy(value_label);
|
||||
entity.percentage_label = table_helpers.deep_copy(percentage_label);
|
||||
|
||||
return entity;
|
||||
end
|
||||
|
||||
function health_UI_entity.draw(monster, health_UI, position_on_screen, opacity_scale)
|
||||
|
||||
drawing.draw_bar(health_UI.bar, position_on_screen, opacity_scale, monster.health_percentage);
|
||||
|
||||
drawing.draw_label(health_UI.text_label, position_on_screen, opacity_scale);
|
||||
drawing.draw_label(health_UI.value_label, position_on_screen, opacity_scale, monster.health, monster.max_health);
|
||||
drawing.draw_label(health_UI.percentage_label, position_on_screen, opacity_scale, 100 * monster.health_percentage);
|
||||
end
|
||||
|
||||
function health_UI_entity.init_module()
|
||||
table_helpers = require("MHR_Overlay.Misc.table_helpers");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
end
|
||||
|
||||
return health_UI_entity;
|
||||
39
MHR_Overlay/UI/UI_Entities/rage_UI_entity.lua
Normal file
39
MHR_Overlay/UI/UI_Entities/rage_UI_entity.lua
Normal file
@@ -0,0 +1,39 @@
|
||||
local rage_UI_entity = {};
|
||||
local table_helpers;
|
||||
local drawing;
|
||||
|
||||
function rage_UI_entity.new(bar, text_label, value_label, percentage_label)
|
||||
local entity = {};
|
||||
|
||||
entity.bar = table_helpers.deep_copy(bar);
|
||||
entity.text_label = table_helpers.deep_copy(text_label);
|
||||
entity.value_label = table_helpers.deep_copy(value_label);
|
||||
entity.percentage_label = table_helpers.deep_copy(percentage_label);
|
||||
entity.timer_label = table_helpers.deep_copy(percentage_label);
|
||||
|
||||
entity.timer_label.text = "%.0f:%04.1f";
|
||||
return entity;
|
||||
end
|
||||
|
||||
function rage_UI_entity.draw(monster, rage_UI, position_on_screen, opacity_scale)
|
||||
if monster.is_in_rage then
|
||||
drawing.draw_bar(rage_UI.bar, position_on_screen, opacity_scale, monster.rage_timer_percentage);
|
||||
|
||||
drawing.draw_label(rage_UI.text_label, position_on_screen, opacity_scale);
|
||||
drawing.draw_label(rage_UI.value_label, position_on_screen, opacity_scale, monster.rage_point, monster.rage_limit);
|
||||
drawing.draw_label(rage_UI.timer_label, position_on_screen, opacity_scale, monster.rage_minutes_left, monster.rage_seconds_left);
|
||||
else
|
||||
drawing.draw_bar(rage_UI.bar, position_on_screen, opacity_scale, monster.rage_percentage);
|
||||
|
||||
drawing.draw_label(rage_UI.text_label, position_on_screen, opacity_scale);
|
||||
drawing.draw_label(rage_UI.value_label, position_on_screen, opacity_scale, monster.rage_point, monster.rage_limit);
|
||||
drawing.draw_label(rage_UI.percentage_label, position_on_screen, opacity_scale, 100 * monster.rage_percentage);
|
||||
end
|
||||
end
|
||||
|
||||
function rage_UI_entity.init_module()
|
||||
table_helpers = require("MHR_Overlay.Misc.table_helpers");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
end
|
||||
|
||||
return rage_UI_entity;
|
||||
29
MHR_Overlay/UI/UI_Entities/stamina_UI_entity.lua
Normal file
29
MHR_Overlay/UI/UI_Entities/stamina_UI_entity.lua
Normal file
@@ -0,0 +1,29 @@
|
||||
local stamina_UI_entity = {};
|
||||
local table_helpers;
|
||||
local drawing;
|
||||
|
||||
function stamina_UI_entity.new(bar, text_label, value_label, percentage_label)
|
||||
local entity = {};
|
||||
|
||||
entity.bar = table_helpers.deep_copy(bar);
|
||||
entity.text_label = table_helpers.deep_copy(text_label);
|
||||
entity.value_label = table_helpers.deep_copy(value_label);
|
||||
entity.percentage_label = table_helpers.deep_copy(percentage_label);
|
||||
|
||||
return entity;
|
||||
end
|
||||
|
||||
function stamina_UI_entity.draw(monster, stamina_UI, position_on_screen, opacity_scale)
|
||||
drawing.draw_bar(stamina_UI.bar, position_on_screen, opacity_scale, monster.stamina_percentage);
|
||||
|
||||
drawing.draw_label(stamina_UI.text_label, position_on_screen, opacity_scale);
|
||||
drawing.draw_label(stamina_UI.value_label, position_on_screen, opacity_scale, monster.stamina, monster.max_stamina);
|
||||
drawing.draw_label(stamina_UI.percentage_label, position_on_screen, opacity_scale, 100 * monster.stamina_percentage);
|
||||
end
|
||||
|
||||
function stamina_UI_entity.init_module()
|
||||
table_helpers = require("MHR_Overlay.Misc.table_helpers");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
end
|
||||
|
||||
return stamina_UI_entity;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -55,20 +55,33 @@ function drawing.scale_label_opacity(label, scale)
|
||||
label.shadow.color = drawing.scale_color_opacity(label.shadow.color, scale);
|
||||
end
|
||||
|
||||
function drawing.draw_label(label, position, ...)
|
||||
function drawing.draw_label(label, position, opacity_scale, ...)
|
||||
if label == nil or not label.visibility then
|
||||
return;
|
||||
end
|
||||
|
||||
local text = string.format(label.text, table.unpack({...}));
|
||||
local position_x = position.x + label.offset.x;
|
||||
local position_y = position.y + label.offset.y;
|
||||
|
||||
if label.shadow.visibility then
|
||||
d2d.text(drawing.font, text, position.x + label.offset.x + label.shadow.offset.x,
|
||||
position.y + label.offset.y + label.shadow.offset.y, label.shadow.color);
|
||||
local new_shadow_color = label.shadow.color;
|
||||
|
||||
if opacity_scale < 1 then
|
||||
new_shadow_color = drawing.scale_color_opacity(new_shadow_color, opacity_scale);
|
||||
end
|
||||
|
||||
d2d.text(drawing.font, text, position_x + label.shadow.offset.x, position_y + label.shadow.offset.y, new_shadow_color);
|
||||
end
|
||||
d2d.text(drawing.font, text, position.x + label.offset.x, position.y + label.offset.y, label.color);
|
||||
|
||||
local new_color = label.color;
|
||||
if opacity_scale < 1 then
|
||||
new_color = drawing.scale_color_opacity(new_color, opacity_scale);
|
||||
end
|
||||
d2d.text(drawing.font, text, position_x, position_y, new_color);
|
||||
end
|
||||
|
||||
function drawing.draw_bar(bar, position, percentage)
|
||||
function drawing.draw_bar(bar, position, opacity_scale, percentage)
|
||||
if bar == nil then
|
||||
return;
|
||||
end
|
||||
@@ -77,20 +90,27 @@ function drawing.draw_bar(bar, position, percentage)
|
||||
return;
|
||||
end
|
||||
|
||||
if percentage > 1 then
|
||||
if percentage > 1 then
|
||||
percentage = 1;
|
||||
end
|
||||
|
||||
local position_x = position.x + bar.offset.x;
|
||||
local position_y = position.y + bar.offset.y;
|
||||
local foreground_width = bar.size.width * percentage;
|
||||
local background_width = bar.size.width - foreground_width;
|
||||
|
||||
-- foreground
|
||||
d2d.fill_rect(position.x + bar.offset.x, position.y + bar.offset.y, foreground_width, bar.size.height,
|
||||
bar.colors.foreground);
|
||||
local new_foreground_color = bar.colors.foreground;
|
||||
local new_background_color = bar.colors.background;
|
||||
|
||||
if opacity_scale < 1 then
|
||||
new_foreground_color = drawing.scale_color_opacity(new_foreground_color, opacity_scale);
|
||||
new_background_color = drawing.scale_color_opacity(new_background_color, opacity_scale);
|
||||
end
|
||||
|
||||
-- foreground
|
||||
d2d.fill_rect(position_x, position_y, foreground_width, bar.size.height, new_foreground_color);
|
||||
-- background
|
||||
d2d.fill_rect(position.x + foreground_width + bar.offset.x, position.y + bar.offset.y, background_width,
|
||||
bar.size.height, bar.colors.background);
|
||||
d2d.fill_rect(position_x + foreground_width, position_y, background_width, bar.size.height, new_background_color);
|
||||
end
|
||||
|
||||
function drawing.init_module()
|
||||
|
||||
Reference in New Issue
Block a user