mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-24 04:18:11 -08:00
Fix Damage Meter UI bugs
when Hide Total Damage was hiding whole module instead
This commit is contained in:
@@ -135,6 +135,7 @@ function this.get_player(player_id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function this.update_damage(player, damage_source_type, is_large_monster, damage_object)
|
function this.update_damage(player, damage_source_type, is_large_monster, damage_object)
|
||||||
|
|
||||||
if player == nil then
|
if player == nil then
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
@@ -414,7 +415,7 @@ end
|
|||||||
function this.init()
|
function this.init()
|
||||||
this.list = {};
|
this.list = {};
|
||||||
this.total = this.new(0, "Total", 0, 0, this.types.total);
|
this.total = this.new(0, "Total", 0, 0, this.types.total);
|
||||||
this.myself = this.new(-1, "DummyMHROverlay", -1, -1, this.types.myself);
|
this.myself = nil;
|
||||||
end
|
end
|
||||||
|
|
||||||
local lobby_manager_type_def = sdk.find_type_definition("snow.LobbyManager");
|
local lobby_manager_type_def = sdk.find_type_definition("snow.LobbyManager");
|
||||||
@@ -501,7 +502,10 @@ function this.update_player_list_(hunter_info_field_)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if this.myself == nil or myself_id ~= this.myself.id then
|
if this.myself == nil or myself_id ~= this.myself.id then
|
||||||
this.list[this.myself.id] = nil;
|
if this.myself ~= nil then
|
||||||
|
this.list[this.myself.id] = nil;
|
||||||
|
end
|
||||||
|
|
||||||
this.myself = this.new(myself_id, myself_player_name, myself_master_rank, myself_hunter_rank, this.types.myself);
|
this.myself = this.new(myself_id, myself_player_name, myself_master_rank, myself_hunter_rank, this.types.myself);
|
||||||
this.list[myself_id] = this.myself;
|
this.list[myself_id] = this.myself;
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ function this.update()
|
|||||||
this.displayed_players = {};
|
this.displayed_players = {};
|
||||||
|
|
||||||
for id, player in pairs(players.list) do
|
for id, player in pairs(players.list) do
|
||||||
if player ~= players.myself then
|
if player ~= players.myself or cached_config.settings.my_damage_bar_location == "Normal" then
|
||||||
this.add_to_displayed_players_list(player, cached_config);
|
this.add_to_displayed_players_list(player, cached_config);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -94,12 +94,25 @@ function this.update()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
this.calculate_top_damage_and_dps();
|
|
||||||
this.sort();
|
this.sort();
|
||||||
|
|
||||||
this.last_displayed_players = this.displayed_players;
|
this.last_displayed_players = this.displayed_players;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function this.calculate_top_damage_and_dps()
|
||||||
|
top_damage = 0;
|
||||||
|
top_dps = 0;
|
||||||
|
for _, player in ipairs(this.displayed_players) do
|
||||||
|
if player.display.total_damage > top_damage then
|
||||||
|
top_damage = player.display.total_damage;
|
||||||
|
end
|
||||||
|
|
||||||
|
if player.dps > top_dps then
|
||||||
|
top_dps = player.dps;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function this.add_to_displayed_players_list(player, cached_config, position)
|
function this.add_to_displayed_players_list(player, cached_config, position)
|
||||||
cached_config = cached_config.settings;
|
cached_config = cached_config.settings;
|
||||||
position = position or #(this.displayed_players) + 1;
|
position = position or #(this.displayed_players) + 1;
|
||||||
@@ -141,20 +154,6 @@ function this.add_to_displayed_players_list(player, cached_config, position)
|
|||||||
--end
|
--end
|
||||||
end
|
end
|
||||||
|
|
||||||
function this.calculate_top_damage_and_dps()
|
|
||||||
top_damage = 0;
|
|
||||||
top_dps = 0;
|
|
||||||
for _, player in ipairs(this.displayed_players) do
|
|
||||||
if player.display.total_damage > top_damage then
|
|
||||||
top_damage = player.display.total_damage;
|
|
||||||
end
|
|
||||||
|
|
||||||
if player.dps > top_dps then
|
|
||||||
top_dps = player.dps;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function this.sort()
|
function this.sort()
|
||||||
local cached_config = config.current_config.damage_meter_UI;
|
local cached_config = config.current_config.damage_meter_UI;
|
||||||
|
|
||||||
@@ -210,25 +209,22 @@ function this.draw()
|
|||||||
if players.total.display.total_damage == 0 and cached_config.settings.hide_module_if_total_damage_is_zero then
|
if players.total.display.total_damage == 0 and cached_config.settings.hide_module_if_total_damage_is_zero then
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
this.calculate_top_damage_and_dps();
|
||||||
|
|
||||||
local position_on_screen = screen.calculate_absolute_coordinates(cached_config.position);
|
local position_on_screen = screen.calculate_absolute_coordinates(cached_config.position);
|
||||||
|
|
||||||
-- draw total damage
|
-- draw total damage
|
||||||
if cached_config.settings.total_damage_location == "First" then
|
if cached_config.settings.total_damage_location == "First"
|
||||||
if cached_config.settings.hide_total_damage then
|
and not cached_config.settings.hide_total_damage then
|
||||||
return;
|
if not (cached_config.settings.hide_total_if_total_damage_is_zero and players.total.display.total_damage == 0) then
|
||||||
end
|
players.draw(players.total, position_on_screen, 1);
|
||||||
|
|
||||||
if cached_config.settings.hide_total_if_total_damage_is_zero and players.total.display.total_damage == 0 then
|
if cached_config.settings.orientation == "Horizontal" then
|
||||||
return;
|
position_on_screen.x = position_on_screen.x + cached_config.spacing.x * global_scale_modifier;
|
||||||
end
|
else
|
||||||
|
position_on_screen.y = position_on_screen.y + cached_config.spacing.y * global_scale_modifier;
|
||||||
players.draw(players.total, 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;
|
|
||||||
else
|
|
||||||
position_on_screen.y = position_on_screen.y + cached_config.spacing.y * global_scale_modifier;
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -251,20 +247,17 @@ function this.draw()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- draw total damage
|
-- draw total damage
|
||||||
if cached_config.settings.total_damage_location == "Last" then
|
if cached_config.settings.total_damage_location == "Last"
|
||||||
if cached_config.settings.hide_total_damage then
|
and not cached_config.settings.hide_total_damage then
|
||||||
return;
|
|
||||||
end
|
|
||||||
|
|
||||||
if cached_config.settings.hide_total_if_total_damage_is_zero and players.total.display.total_damage == 0 then
|
if not (cached_config.settings.hide_total_if_total_damage_is_zero and players.total.display.total_damage == 0) then
|
||||||
return;
|
|
||||||
end
|
|
||||||
|
|
||||||
if not cached_config.settings.total_damage_offset_is_relative then
|
if not cached_config.settings.total_damage_offset_is_relative then
|
||||||
position_on_screen = screen.calculate_absolute_coordinates(cached_config.position);
|
position_on_screen = screen.calculate_absolute_coordinates(cached_config.position);
|
||||||
end
|
end
|
||||||
|
|
||||||
players.draw(players.total, position_on_screen, 1);
|
players.draw(players.total, position_on_screen, 1);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -115,6 +115,9 @@ end
|
|||||||
function this.draw(player, position_on_screen, opacity_scale, top_damage, top_dps)
|
function this.draw(player, position_on_screen, opacity_scale, top_damage, top_dps)
|
||||||
local cached_config = config.current_config.damage_meter_UI;
|
local cached_config = config.current_config.damage_meter_UI;
|
||||||
|
|
||||||
|
top_damage = top_damage or 0;
|
||||||
|
top_dps = top_dps or 0;
|
||||||
|
|
||||||
local name_include = nil;
|
local name_include = nil;
|
||||||
if player.damage_UI.name_label ~= nil then
|
if player.damage_UI.name_label ~= nil then
|
||||||
name_include = player.damage_UI.name_label.include;
|
name_include = player.damage_UI.name_label.include;
|
||||||
|
|||||||
@@ -2123,10 +2123,6 @@ function this.draw_damage_meter_UI()
|
|||||||
players.update_dps(true);
|
players.update_dps(true);
|
||||||
end
|
end
|
||||||
|
|
||||||
if config_changed then
|
|
||||||
players.sort_players();
|
|
||||||
end
|
|
||||||
|
|
||||||
imgui.tree_pop();
|
imgui.tree_pop();
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user