Add Followers to Damage Meter UI

This commit is contained in:
GreenComfyTea
2022-11-26 13:24:12 +02:00
parent a0e6974ad7
commit d4c4267c35
19 changed files with 624 additions and 210 deletions

View File

@@ -3,10 +3,12 @@ local singletons;
local config;
local customization_menu;
local player;
local non_players;
local quest_status;
local screen;
local drawing;
local language;
local table_helpers;
damage_meter_UI.last_displayed_players = {};
damage_meter_UI.freeze_displayed_players = false;
@@ -63,6 +65,12 @@ function damage_meter_UI.get_players(player_info_list)
::continue::
end
if cached_config.settings.show_followers_separately then
for id, non_player in pairs(non_players.servant_list) do
table.insert(quest_players, non_player);
end
end
return quest_players;
end
@@ -142,8 +150,32 @@ function damage_meter_UI.draw()
end
end
-- draw
local position_on_screen = screen.calculate_absolute_coordinates(cached_config.position);
-- draw total damage
if cached_config.settings.total_damage_location == "First" then
if cached_config.settings.hide_total_damage then
return;
end
if cached_config.settings.hide_total_if_total_damage_is_zero and player.total.display.total_damage == 0 then
return;
end
player.draw_total(position_on_screen, 1);
if cached_config.settings.orientation == "Horizontal" then
position_on_screen.x = position_on_screen.x + cached_config.spacing.x * global_scale_modifier;
else
position_on_screen.y = position_on_screen.y + cached_config.spacing.y * global_scale_modifier;
end
end
-- draw
if not cached_config.settings.total_damage_offset_is_relative then
position_on_screen = screen.calculate_absolute_coordinates(cached_config.position);
end
for _, _player in ipairs(quest_players) do
if _player.display.total_damage == 0 and cached_config.settings.hide_player_if_player_damage_is_zero then
goto continue
@@ -157,7 +189,12 @@ function damage_meter_UI.draw()
goto continue
end
player.draw(_player, position_on_screen, 1, top_damage, top_dps);
if _player.is_player then
player.draw(_player, position_on_screen, 1, top_damage, top_dps);
else
non_players.draw(_player, position_on_screen, 1, top_damage, top_dps);
end
if cached_config.settings.orientation == "Horizontal" then
position_on_screen.x = position_on_screen.x + cached_config.spacing.x * global_scale_modifier;
@@ -170,19 +207,21 @@ function damage_meter_UI.draw()
end
-- draw total damage
if cached_config.settings.hide_total_damage then
return;
end
if cached_config.settings.total_damage_location == "Last" then
if cached_config.settings.hide_total_damage then
return;
end
if cached_config.settings.hide_total_if_total_damage_is_zero and player.total.display.total_damage == 0 then
return;
end
if cached_config.settings.hide_total_if_total_damage_is_zero and player.total.display.total_damage == 0 then
return;
end
if not cached_config.settings.total_damage_offset_is_relative then
position_on_screen = screen.calculate_absolute_coordinates(cached_config.position);
end
if not cached_config.settings.total_damage_offset_is_relative then
position_on_screen = screen.calculate_absolute_coordinates(cached_config.position);
end
player.draw_total(position_on_screen, 1);
player.draw_total(position_on_screen, 1);
end
end
function damage_meter_UI.init_module()
@@ -190,10 +229,12 @@ function damage_meter_UI.init_module()
config = require("MHR_Overlay.Misc.config");
customization_menu = require("MHR_Overlay.UI.customization_menu");
player = require("MHR_Overlay.Damage_Meter.player");
non_players = require("MHR_Overlay.Damage_Meter.non_players");
quest_status = require("MHR_Overlay.Game_Handler.quest_status");
screen = require("MHR_Overlay.Game_Handler.screen");
drawing = require("MHR_Overlay.UI.drawing");
language = require("MHR_Overlay.Misc.language");
table_helpers = require("MHR_Overlay.Misc.table_helpers");
end
return damage_meter_UI;

View File

@@ -0,0 +1,116 @@
local non_player_damage_UI_entity = {};
local table_helpers;
local drawing;
local config;
local player;
local language;
function non_player_damage_UI_entity.new(bar, highlighted_bar, name_label, dps_label, value_label, percentage_label)
local entity = {};
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
--entity.visibility = visibility;
entity.bar = table_helpers.deep_copy(bar);
entity.highlighted_bar = table_helpers.deep_copy(highlighted_bar);
entity.name_label = table_helpers.deep_copy(name_label);
entity.dps_label = table_helpers.deep_copy(dps_label);
entity.value_label = table_helpers.deep_copy(value_label);
entity.percentage_label = table_helpers.deep_copy(percentage_label);
entity.bar.offset.x = entity.bar.offset.x * global_scale_modifier;
entity.bar.offset.y = entity.bar.offset.y * global_scale_modifier;
entity.bar.size.width = entity.bar.size.width * global_scale_modifier;
entity.bar.size.height = entity.bar.size.height * global_scale_modifier;
entity.bar.outline.thickness = entity.bar.outline.thickness * global_scale_modifier;
entity.bar.outline.offset = entity.bar.outline.offset * global_scale_modifier;
entity.highlighted_bar.offset.x = entity.highlighted_bar.offset.x * global_scale_modifier;
entity.highlighted_bar.offset.y = entity.highlighted_bar.offset.y * global_scale_modifier;
entity.highlighted_bar.size.width = entity.highlighted_bar.size.width * global_scale_modifier;
entity.highlighted_bar.size.height = entity.highlighted_bar.size.height * global_scale_modifier;
entity.highlighted_bar.outline.thickness = entity.highlighted_bar.outline.thickness * global_scale_modifier;
entity.highlighted_bar.outline.offset = entity.highlighted_bar.outline.offset * global_scale_modifier;
entity.name_label.offset.x = entity.name_label.offset.x * global_scale_modifier;
entity.name_label.offset.y = entity.name_label.offset.y * global_scale_modifier;
entity.name_size_limit = config.current_config.damage_meter_UI.settings.player_name_size_limit * global_scale_modifier;
entity.dps_label.offset.x = entity.dps_label.offset.x * global_scale_modifier;
entity.dps_label.offset.y = entity.dps_label.offset.y * global_scale_modifier;
entity.value_label.offset.x = entity.value_label.offset.x * global_scale_modifier;
entity.value_label.offset.y = entity.value_label.offset.y * global_scale_modifier;
entity.percentage_label.offset.x = entity.percentage_label.offset.x * global_scale_modifier;
entity.percentage_label.offset.y = entity.percentage_label.offset.y * global_scale_modifier;
return entity;
end
function non_player_damage_UI_entity.draw(non_player, position_on_screen, opacity_scale, top_damage, top_dps)
local cached_config = config.current_config.damage_meter_UI;
local include = cached_config.player_name_label.include.others;
local name_text = "";
if include.type then
if non_player.is_otomo then
name_text = name_text .. language.current_language.UI.otomo .. " ";
else
name_text = name_text .. language.current_language.UI.servant .. " ";
end
end
if include.id then
name_text = name_text .. string.format("%d ", non_player.id);
end
if include.name then
name_text = name_text .. non_player.name;
end
local player_damage_percentage = 0;
if player.total.display.total_damage ~= 0 then
player_damage_percentage = non_player.display.total_damage / player.total.display.total_damage;
end
local player_damage_bar_percentage = 0;
if cached_config.settings.damage_bar_relative_to == "Total Damage" then
if player.total.display.total_damage ~= 0 then
player_damage_bar_percentage = non_player.display.total_damage / player.total.display.total_damage;
end
else
if top_damage ~= 0 then
player_damage_bar_percentage = non_player.display.total_damage / top_damage;
end
end
if cached_config.settings.highlighted_bar == "Top Damage" and non_player.display.total_damage == top_damage then
drawing.draw_bar(non_player.damage_UI.highlighted_bar, position_on_screen, opacity_scale, player_damage_bar_percentage);
elseif cached_config.settings.highlighted_bar == "Top DPS" and non_player.dps == top_dps then
drawing.draw_bar(non_player.damage_UI.highlighted_bar, position_on_screen, opacity_scale, player_damage_bar_percentage);
else
drawing.draw_bar(non_player.damage_UI.bar, position_on_screen, opacity_scale, player_damage_bar_percentage);
end
name_text = drawing.limit_text_size(name_text, non_player.damage_UI.name_size_limit);
drawing.draw_label(non_player.damage_UI.name_label, position_on_screen, opacity_scale, name_text);
drawing.draw_label(non_player.damage_UI.value_label, position_on_screen, opacity_scale, non_player.display.total_damage);
drawing.draw_label(non_player.damage_UI.percentage_label, position_on_screen, opacity_scale, 100 * player_damage_percentage);
drawing.draw_label(non_player.damage_UI.dps_label, position_on_screen, opacity_scale, non_player.dps);
end
function non_player_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");
language = require("MHR_Overlay.Misc.language");
end
return non_player_damage_UI_entity;

View File

@@ -1,11 +1,12 @@
local damage_UI_entity = {};
local player_damage_UI_entity = {};
local table_helpers;
local drawing;
local config;
local player;
local language;
local quest_status;
function damage_UI_entity.new(bar, highlighted_bar, player_name_label, dps_label, hunter_rank_label, value_label,
function player_damage_UI_entity.new(bar, highlighted_bar, player_name_label, dps_label, hunter_rank_label, value_label,
percentage_label, cart_count_label)
local entity = {};
@@ -59,7 +60,7 @@ function damage_UI_entity.new(bar, highlighted_bar, player_name_label, dps_label
return entity;
end
function damage_UI_entity.draw(_player, position_on_screen, opacity_scale, top_damage, top_dps)
function player_damage_UI_entity.draw(_player, position_on_screen, opacity_scale, top_damage, top_dps)
local cached_config = config.current_config.damage_meter_UI;
local player_include = cached_config.player_name_label.include.others;
@@ -77,20 +78,19 @@ function damage_UI_entity.draw(_player, position_on_screen, opacity_scale, top_d
player_name_text = string.format("[%d] ", _player.hunter_rank);
end
if player_include.cart_count then
if player_include.cart_count and quest_status.flow_state ~= quest_status.flow_states.IN_LOBBY and quest_status.flow_state ~= quest_status.flow_states.IN_TRAINING_AREA then
player_name_text = player_name_text .. string.format("x%d ", _player.cart_count);
end
if player_include.word_player then
if player_include.type then
player_name_text = player_name_text .. language.current_language.UI.player .. " ";
end
if player_include.player_id then
if player_include.id then
player_name_text = player_name_text .. string.format("%d ", _player.id);
end
if player_include.player_name then
if player_include.name then
player_name_text = player_name_text .. _player.name;
end
@@ -150,20 +150,23 @@ function damage_UI_entity.draw(_player, position_on_screen, opacity_scale, top_d
player_name_text = drawing.limit_text_size(player_name_text, _player.damage_UI.player_name_size_limit);
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);
drawing.draw_label(_player.damage_UI.dps_label, position_on_screen, opacity_scale, _player.dps);
drawing.draw_label(_player.damage_UI.cart_count_label, position_on_screen, opacity_scale, _player.cart_count);
if quest_status.flow_state ~= quest_status.flow_states.IN_LOBBY and quest_status.flow_state ~= quest_status.flow_states.IN_TRAINING_AREA then
drawing.draw_label(_player.damage_UI.cart_count_label, position_on_screen, opacity_scale, _player.cart_count);
end
end
function damage_UI_entity.init_module()
function player_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");
language = require("MHR_Overlay.Misc.language");
quest_status = require("MHR_Overlay.Game_Handler.quest_status");
end
return damage_UI_entity;
return player_damage_UI_entity;

View File

@@ -11,6 +11,8 @@ local language;
local part_names;
local time_UI;
local keyboard;
local non_players;
local label_customization;
local bar_customization;
local large_monster_UI_customization;
@@ -51,6 +53,7 @@ customization_menu.displayed_buildup_bar_relative_types = {};
customization_menu.displayed_damage_meter_UI_highlighted_bar_types = {};
customization_menu.displayed_damage_meter_UI_damage_bar_relative_types = {};
customization_menu.displayed_damage_meter_UI_my_damage_bar_location_types = {};
customization_menu.displayed_damage_meter_UI_total_damage_location_types = {};
customization_menu.displayed_damage_meter_UI_sorting_types = {};
customization_menu.displayed_damage_meter_UI_dps_modes = {};
@@ -69,6 +72,7 @@ customization_menu.buildup_bar_relative_types = {};
customization_menu.damage_meter_UI_highlighted_bar_types = {};
customization_menu.damage_meter_UI_damage_bar_relative_types = {};
customization_menu.damage_meter_UI_my_damage_bar_location_types = {};
customization_menu.damage_meter_UI_total_damage_location_types = {};
customization_menu.damage_meter_UI_sorting_types = {};
customization_menu.damage_meter_UI_dps_modes = {};
@@ -150,10 +154,16 @@ function customization_menu.init()
customization_menu.displayed_damage_meter_UI_damage_bar_relative_types =
{language.current_language.customization_menu.total_damage, language.current_language.customization_menu.top_damage};
customization_menu.displayed_damage_meter_UI_my_damage_bar_location_types = {language.current_language
customization_menu.displayed_damage_meter_UI_my_damage_bar_location_types = {language.current_language
.customization_menu.normal, language.current_language.customization_menu.first,
language.current_language
.customization_menu.last};
customization_menu.displayed_damage_meter_UI_total_damage_location_types = {
language.current_language.customization_menu.first,
language.current_language.customization_menu.last};
customization_menu.displayed_damage_meter_UI_sorting_types =
{language.current_language.customization_menu.normal, language.current_language.customization_menu.damage,
language.current_language.customization_menu.dps};
@@ -216,6 +226,11 @@ function customization_menu.init()
customization_menu.damage_meter_UI_my_damage_bar_location_types =
{language.default_language.customization_menu.normal, language.default_language.customization_menu.first,
language.default_language.customization_menu.last};
customization_menu.damage_meter_UI_total_damage_location_types = {
language.current_language.customization_menu.first,
language.current_language.customization_menu.last};
customization_menu.damage_meter_UI_sorting_types = {language.default_language.customization_menu.normal,
language.default_language.customization_menu.damage,
language.default_language.customization_menu.dps};
@@ -543,6 +558,11 @@ function customization_menu.draw()
if damage_meter_UI_changed or modifiers_changed then
for _, _player in pairs(player.list) do
player.init_UI(_player);
end
for _, servant in pairs(non_players.servant_list) do
non_players.init_UI(servant);
end
player.init_total_UI(player.total);
@@ -640,6 +660,10 @@ function customization_menu.draw_global_settings()
for _, _player in pairs(player.list) do
player.init_UI(_player);
end
for _, servant in pairs(non_players.servant_list) do
non_players.init_UI(servant);
end
end
if imgui.tree_node(language.current_language.customization_menu.menu_font) then
@@ -1418,6 +1442,21 @@ function customization_menu.draw_damage_meter_UI()
config_changed = config_changed or changed;
changed, cached_config.settings.show_my_otomos_separately = imgui.checkbox(
language.current_language.customization_menu.show_my_otomos_separately, cached_config.settings.show_my_otomos_separately);
config_changed = config_changed or changed;
changed, cached_config.settings.show_other_otomos_separately = imgui.checkbox(
language.current_language.customization_menu.show_other_otomos_separately, cached_config.settings.show_other_otomos_separately);
config_changed = config_changed or changed;
changed, cached_config.settings.show_followers_separately = imgui.checkbox(
language.current_language.customization_menu.show_followers_separately, cached_config.settings.show_followers_separately);
config_changed = config_changed or changed;
changed, index = imgui.combo(
language.current_language.customization_menu.orientation,
table_helpers.find_index(customization_menu.orientation_types, cached_config.settings.orientation),
@@ -1462,6 +1501,17 @@ function customization_menu.draw_damage_meter_UI()
cached_config.settings.my_damage_bar_location = customization_menu.damage_meter_UI_my_damage_bar_location_types[index];
end
changed, index = imgui.combo(
language.current_language.customization_menu.total_damage_location,
table_helpers.find_index(customization_menu.damage_meter_UI_total_damage_location_types, cached_config.settings.total_damage_location),
customization_menu.displayed_damage_meter_UI_total_damage_location_types);
config_changed = config_changed or changed;
if changed then
cached_config.settings.total_damage_location = customization_menu.damage_meter_UI_total_damage_location_types[index];
end
changed, index = imgui.combo(language.current_language.customization_menu.dps_mode,
table_helpers.find_index(customization_menu.damage_meter_UI_dps_modes, cached_config.settings.dps_mode),
customization_menu.displayed_damage_meter_UI_dps_modes);
@@ -1570,10 +1620,14 @@ function customization_menu.draw_damage_meter_UI()
tracked_damage_types_changed = tracked_damage_types_changed or changed;
if tracked_damage_types_changed then
for player_id, _player in pairs(player.list) do
for _, _player in pairs(player.list) do
player.update_display(_player);
end
for _, servant in pairs(non_players.servant_list) do
player.update_display(servant);
end
player.update_display(player.total);
end
@@ -1662,18 +1716,18 @@ function customization_menu.draw_damage_meter_UI()
config_changed = config_changed or changed;
changed, cached_config.player_name_label.include.myself.word_player = imgui.checkbox(
language.current_language.customization_menu.word_player, cached_config.player_name_label.include.myself.word_player);
changed, cached_config.player_name_label.include.myself.type = imgui.checkbox(
language.current_language.customization_menu.type, cached_config.player_name_label.include.myself.type);
config_changed = config_changed or changed;
changed, cached_config.player_name_label.include.myself.player_id = imgui.checkbox(
language.current_language.customization_menu.player_id, cached_config.player_name_label.include.myself.player_id);
changed, cached_config.player_name_label.include.myself.id = imgui.checkbox(
language.current_language.customization_menu.id, cached_config.player_name_label.include.myself.id);
config_changed = config_changed or changed;
changed, cached_config.player_name_label.include.myself.player_name = imgui.checkbox(
language.current_language.customization_menu.player_name, cached_config.player_name_label.include.myself.player_name);
changed, cached_config.player_name_label.include.myself.name = imgui.checkbox(
language.current_language.customization_menu.name, cached_config.player_name_label.include.myself.name);
config_changed = config_changed or changed;
@@ -1696,18 +1750,18 @@ function customization_menu.draw_damage_meter_UI()
config_changed = config_changed or changed;
changed, cached_config.player_name_label.include.others.word_player = imgui.checkbox(
language.current_language.customization_menu.word_player, cached_config.player_name_label.include.others.word_player);
changed, cached_config.player_name_label.include.others.type = imgui.checkbox(
language.current_language.customization_menu.type, cached_config.player_name_label.include.others.type);
config_changed = config_changed or changed;
changed, cached_config.player_name_label.include.others.player_id = imgui.checkbox(
language.current_language.customization_menu.player_id, cached_config.player_name_label.include.others.player_id);
changed, cached_config.player_name_label.include.others.id = imgui.checkbox(
language.current_language.customization_menu.id, cached_config.player_name_label.include.others.id);
config_changed = config_changed or changed;
changed, cached_config.player_name_label.include.others.player_name = imgui.checkbox(
language.current_language.customization_menu.player_name, cached_config.player_name_label.include.others.player_name);
changed, cached_config.player_name_label.include.others.name = imgui.checkbox(
language.current_language.customization_menu.name, cached_config.player_name_label.include.others.name);
config_changed = config_changed or changed;
@@ -1996,6 +2050,8 @@ function customization_menu.init_module()
part_names = require("MHR_Overlay.Misc.part_names");
time_UI = require("MHR_Overlay.UI.Modules.time_UI");
keyboard = require("MHR_Overlay.Game_Handler.keyboard");
non_players = require("MHR_Overlay.Damage_Meter.non_players");
label_customization = require("MHR_Overlay.UI.Customizations.label_customization");
bar_customization = require("MHR_Overlay.UI.Customizations.bar_customization");
large_monster_UI_customization = require("MHR_Overlay.UI.Customizations.large_monster_UI_customization");