diff --git a/reframework/autorun/MHR_Overlay/Damage_Meter/players.lua b/reframework/autorun/MHR_Overlay/Damage_Meter/players.lua index 4e388db..d64ca8d 100644 --- a/reframework/autorun/MHR_Overlay/Damage_Meter/players.lua +++ b/reframework/autorun/MHR_Overlay/Damage_Meter/players.lua @@ -135,6 +135,7 @@ function this.get_player(player_id) end function this.update_damage(player, damage_source_type, is_large_monster, damage_object) + if player == nil then return; end @@ -414,7 +415,7 @@ end function this.init() this.list = {}; 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 local lobby_manager_type_def = sdk.find_type_definition("snow.LobbyManager"); @@ -501,7 +502,10 @@ function this.update_player_list_(hunter_info_field_) end 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.list[myself_id] = this.myself; end diff --git a/reframework/autorun/MHR_Overlay/UI/Modules/damage_meter_UI.lua b/reframework/autorun/MHR_Overlay/UI/Modules/damage_meter_UI.lua index 79f954b..245f333 100644 --- a/reframework/autorun/MHR_Overlay/UI/Modules/damage_meter_UI.lua +++ b/reframework/autorun/MHR_Overlay/UI/Modules/damage_meter_UI.lua @@ -67,7 +67,7 @@ function this.update() this.displayed_players = {}; 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); end end @@ -94,12 +94,25 @@ function this.update() end end - this.calculate_top_damage_and_dps(); this.sort(); this.last_displayed_players = this.displayed_players; 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) cached_config = cached_config.settings; position = position or #(this.displayed_players) + 1; @@ -141,20 +154,6 @@ function this.add_to_displayed_players_list(player, cached_config, position) --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() 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 return; end + + this.calculate_top_damage_and_dps(); 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.total_damage_location == "First" + and not cached_config.settings.hide_total_damage then + if not (cached_config.settings.hide_total_if_total_damage_is_zero and players.total.display.total_damage == 0) then + 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 - return; - end - - players.draw(players.total, position_on_screen, 1, top_damage, top_dps); - - 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; + 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 @@ -251,20 +247,17 @@ function this.draw() end -- draw total damage - if cached_config.settings.total_damage_location == "Last" then - if cached_config.settings.hide_total_damage then - return; - end + if cached_config.settings.total_damage_location == "Last" + and not cached_config.settings.hide_total_damage then - if 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.hide_total_if_total_damage_is_zero and players.total.display.total_damage == 0) then - 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 - players.draw(players.total, position_on_screen, 1); + players.draw(players.total, position_on_screen, 1); + end end end diff --git a/reframework/autorun/MHR_Overlay/UI/UI_Entities/damage_UI_entity.lua b/reframework/autorun/MHR_Overlay/UI/UI_Entities/damage_UI_entity.lua index 26d694e..b1d1a1d 100644 --- a/reframework/autorun/MHR_Overlay/UI/UI_Entities/damage_UI_entity.lua +++ b/reframework/autorun/MHR_Overlay/UI/UI_Entities/damage_UI_entity.lua @@ -115,6 +115,9 @@ end function this.draw(player, position_on_screen, opacity_scale, top_damage, top_dps) 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; if player.damage_UI.name_label ~= nil then name_include = player.damage_UI.name_label.include; diff --git a/reframework/autorun/MHR_Overlay/UI/customization_menu.lua b/reframework/autorun/MHR_Overlay/UI/customization_menu.lua index 8723484..974c53b 100644 --- a/reframework/autorun/MHR_Overlay/UI/customization_menu.lua +++ b/reframework/autorun/MHR_Overlay/UI/customization_menu.lua @@ -2123,10 +2123,6 @@ function this.draw_damage_meter_UI() players.update_dps(true); end - if config_changed then - players.sort_players(); - end - imgui.tree_pop(); end