mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-24 04:18:11 -08:00
Add Auto-Highlight Option to Large Monster UI
This commit is contained in:
@@ -319,9 +319,8 @@ end
|
||||
local player_manager_type_def = sdk.find_type_definition("snow.player.PlayerManager");
|
||||
local find_master_player_method = player_manager_type_def:get_method("findMasterPlayer");
|
||||
|
||||
local get_game_object_method = sdk.find_type_definition("via.Component"):get_method("get_GameObject");
|
||||
local get_transform_method = sdk.find_type_definition("via.GameObject"):get_method("get_Transform");
|
||||
local get_position_method = sdk.find_type_definition("via.Transform"):get_method("get_Position");
|
||||
local player_base_type_def = sdk.find_type_definition("snow.player.PlayerBase");
|
||||
local get_pos_field = player_base_type_def:get_method("get_Pos");
|
||||
|
||||
function player.update_myself_position()
|
||||
if singletons.player_manager == nil then
|
||||
@@ -335,25 +334,10 @@ function player.update_myself_position()
|
||||
return;
|
||||
end
|
||||
|
||||
local master_player_game_object = get_game_object_method:call(master_player);
|
||||
if master_player_game_object == nil then
|
||||
customization_menu.status = "No master player game object";
|
||||
return;
|
||||
local position = get_pos_field:call(master_player);
|
||||
if position ~= nil then
|
||||
player.myself_position = position;
|
||||
end
|
||||
|
||||
local master_player_transform = get_transform_method:call(master_player_game_object);
|
||||
if not master_player_transform then
|
||||
customization_menu.status = "No master player transform";
|
||||
return;
|
||||
end
|
||||
|
||||
local master_player_position = get_position_method:call(master_player_transform);
|
||||
if master_player_position == nil then
|
||||
customization_menu.status = "No master player position";
|
||||
return;
|
||||
end
|
||||
|
||||
player.myself_position = master_player_position;
|
||||
end
|
||||
|
||||
function player.init()
|
||||
|
||||
@@ -2952,6 +2952,11 @@ function config.init()
|
||||
anchor = "Top-Right"
|
||||
},
|
||||
|
||||
auto_highlight = {
|
||||
enabled = false,
|
||||
mode = "Closest"
|
||||
},
|
||||
|
||||
monster_name_label = {
|
||||
visibility = true,
|
||||
text = "%s",
|
||||
@@ -4487,4 +4492,4 @@ function config.init_module()
|
||||
|
||||
end
|
||||
|
||||
return config;
|
||||
return config;
|
||||
@@ -399,7 +399,16 @@ language.default_language = {
|
||||
style = "Style",
|
||||
inside = "Inside",
|
||||
outside = "Outside",
|
||||
center = "Center"
|
||||
center = "Center",
|
||||
|
||||
auto_highlight = "Auto-highlight",
|
||||
mode = "Mode",
|
||||
closest = "Closest",
|
||||
farthest = "Farthest",
|
||||
lowest_health = "Lowest Health",
|
||||
highest_health = "Highest Health",
|
||||
lowest_health_percentage = "Lowest Health Percentage",
|
||||
highest_health_percentage = "Highest Health Percentage"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -695,7 +695,7 @@ end
|
||||
|
||||
function large_monster.draw(monster, type, cached_config, position_on_screen, opacity_scale)
|
||||
local monster_UI;
|
||||
xy = 1;
|
||||
|
||||
if type == "dynamic" then
|
||||
monster_UI = monster.dynamic_UI;
|
||||
elseif type == "static" then
|
||||
@@ -703,37 +703,37 @@ function large_monster.draw(monster, type, cached_config, position_on_screen, op
|
||||
else
|
||||
monster_UI = monster.highlighted_UI;
|
||||
end
|
||||
xy = 2;
|
||||
|
||||
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
|
||||
xy = 2.01;
|
||||
|
||||
local monster_name_text = "";
|
||||
if cached_config.monster_name_label.include.monster_name then
|
||||
monster_name_text = string.format("%s ", monster.name);
|
||||
monster_name_text = string.format("%s %s ", monster.name, tostring(monster.distance));
|
||||
end
|
||||
xy = 2.02;
|
||||
|
||||
if cached_config.monster_name_label.include.monster_id then
|
||||
monster_name_text = monster_name_text .. tostring(monster.id) .. " ";
|
||||
end
|
||||
xy = 2.03;
|
||||
|
||||
if cached_config.monster_name_label.include.crown and monster.crown ~= "" then
|
||||
monster_name_text = monster_name_text .. string.format("%s ", monster.crown);
|
||||
end
|
||||
xy = 2.04;
|
||||
|
||||
if cached_config.monster_name_label.include.size then
|
||||
monster_name_text = monster_name_text .. string.format("#%.0f ", 100 * monster.size);
|
||||
end
|
||||
xy = 2.05;
|
||||
|
||||
if cached_config.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
|
||||
xy = table_helpers.tostring(monster_UI);
|
||||
|
||||
if monster.health < monster.capture_health then
|
||||
monster_UI.health_UI.bar.colors = monster_UI.health_UI.bar.capture_colors;
|
||||
else
|
||||
monster_UI.health_UI.bar.colors = monster_UI.health_UI.bar.normal_colors;
|
||||
end
|
||||
xy = 2.1;
|
||||
|
||||
drawing.draw_label(monster_UI.monster_name_label, position_on_screen, opacity_scale, monster_name_text);
|
||||
|
||||
local health_position_on_screen = {
|
||||
@@ -766,7 +766,6 @@ function large_monster.draw(monster, type, cached_config, position_on_screen, op
|
||||
y = position_on_screen.y + cached_config.ailment_buildups.offset.y * global_scale_modifier
|
||||
};
|
||||
|
||||
|
||||
health_UI_entity.draw(monster, monster_UI.health_UI, health_position_on_screen, opacity_scale);
|
||||
drawing.draw_capture_line(monster_UI.health_UI, health_position_on_screen, opacity_scale, monster.capture_percentage);
|
||||
stamina_UI_entity.draw(monster, monster_UI.stamina_UI, stamina_position_on_screen, opacity_scale);
|
||||
|
||||
@@ -22,17 +22,25 @@ local tg_camera_type_def = get_tg_camera_method:get_return_type();
|
||||
local get_targeting_enemy_index_field = tg_camera_type_def:get_field("OldTargetingEmIndex");
|
||||
|
||||
function large_monster_UI.draw(dynamic_enabled, static_enabled, highlighted_enabled)
|
||||
local cached_config = config.current_config.large_monster_UI;
|
||||
|
||||
if singletons.enemy_manager == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
local displayed_monsters = {};
|
||||
|
||||
local update_distance =
|
||||
dynamic_enabled or cached_config.static.sorting.type == "Distance"
|
||||
or (cached_config.highlighted.auto_highlight.enabled
|
||||
and (cached_config.highlighted.auto_highlight.mode == "Closest" or cached_config.highlighted.auto_highlight.mode == "Furthest")
|
||||
);
|
||||
|
||||
local highlighted_id = -1;
|
||||
local monster_id_shift = 0;
|
||||
local highlighted_monster = nil;
|
||||
|
||||
if singletons.gui_manager ~= nil then
|
||||
if not cached_config.highlighted.auto_highlight.enabled and singletons.gui_manager ~= nil then
|
||||
local gui_hud_target_camera = get_tg_camera_method:call(singletons.gui_manager);
|
||||
if gui_hud_target_camera ~= nil then
|
||||
highlighted_id = get_targeting_enemy_index_field:get_data(gui_hud_target_camera);
|
||||
@@ -57,41 +65,76 @@ function large_monster_UI.draw(dynamic_enabled, static_enabled, highlighted_enab
|
||||
|
||||
local monster = large_monster.list[enemy];
|
||||
if monster == nil then
|
||||
customization_menu.status = "No large monster hp entry";
|
||||
customization_menu.status = "No large monster entry";
|
||||
goto continue
|
||||
end
|
||||
|
||||
if monster.dead_or_captured or not monster.is_disp_icon_mini_map then
|
||||
monster_id_shift = monster_id_shift + 1;
|
||||
elseif i == highlighted_id + monster_id_shift then
|
||||
highlighted_monster = monster;
|
||||
if update_distance then
|
||||
monster.distance = (player.myself_position - monster.position):length();
|
||||
end
|
||||
|
||||
if cached_config.highlighted.auto_highlight.enabled then
|
||||
if highlighted_monster == nil then
|
||||
highlighted_monster = monster;
|
||||
|
||||
elseif cached_config.highlighted.auto_highlight.mode == "Farthest" then
|
||||
if monster.distance > highlighted_monster.distance then
|
||||
highlighted_monster = monster;
|
||||
end
|
||||
|
||||
elseif cached_config.highlighted.auto_highlight.mode == "Lowest Health" then
|
||||
if monster.health < highlighted_monster.health then
|
||||
highlighted_monster = monster;
|
||||
end
|
||||
|
||||
elseif cached_config.highlighted.auto_highlight.mode == "Highest Health" then
|
||||
if monster.health > highlighted_monster.health then
|
||||
highlighted_monster = monster;
|
||||
end
|
||||
|
||||
elseif cached_config.highlighted.auto_highlight.mode == "Lowest Health Percentage" then
|
||||
if monster.health_percentage < highlighted_monster.health_percentage then
|
||||
highlighted_monster = monster;
|
||||
end
|
||||
|
||||
elseif cached_config.highlighted.auto_highlight.mode == "Highest Health Percentage" then
|
||||
if monster.health_percentage > highlighted_monster.health_percentage then
|
||||
highlighted_monster = monster;
|
||||
end
|
||||
|
||||
else
|
||||
if monster.distance < highlighted_monster.distance then
|
||||
highlighted_monster = monster;
|
||||
end
|
||||
end
|
||||
else
|
||||
if monster.dead_or_captured or not monster.is_disp_icon_mini_map then
|
||||
monster_id_shift = monster_id_shift + 1;
|
||||
|
||||
elseif i == highlighted_id + monster_id_shift then
|
||||
highlighted_monster = monster;
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(displayed_monsters, monster);
|
||||
::continue::
|
||||
end
|
||||
|
||||
if dynamic_enabled or config.current_config.large_monster_UI.static.sorting.type == "Distance" then
|
||||
for _, monster in ipairs(displayed_monsters) do
|
||||
monster.distance = (player.myself_position - monster.position):length();
|
||||
end
|
||||
end
|
||||
|
||||
if dynamic_enabled then
|
||||
large_monster_UI.draw_dynamic(displayed_monsters, highlighted_monster);
|
||||
large_monster_UI.draw_dynamic(displayed_monsters, highlighted_monster, cached_config);
|
||||
end
|
||||
|
||||
if highlighted_enabled then
|
||||
large_monster_UI.draw_highlighted(highlighted_monster);
|
||||
large_monster_UI.draw_highlighted(highlighted_monster, cached_config);
|
||||
end
|
||||
|
||||
if static_enabled then
|
||||
large_monster_UI.draw_static(displayed_monsters, highlighted_monster);
|
||||
large_monster_UI.draw_static(displayed_monsters, highlighted_monster, cached_config);
|
||||
end
|
||||
end
|
||||
|
||||
function large_monster_UI.draw_dynamic(displayed_monsters, highlighted_monster)
|
||||
local cached_config = config.current_config.large_monster_UI.dynamic;
|
||||
function large_monster_UI.draw_dynamic(displayed_monsters, highlighted_monster, cached_config)
|
||||
cached_config = cached_config.dynamic;
|
||||
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
|
||||
|
||||
local i = 0;
|
||||
@@ -144,8 +187,8 @@ function large_monster_UI.draw_dynamic(displayed_monsters, highlighted_monster)
|
||||
end
|
||||
end
|
||||
|
||||
function large_monster_UI.draw_static(displayed_monsters, highlighted_monster)
|
||||
local cached_config = config.current_config.large_monster_UI.static;
|
||||
function large_monster_UI.draw_static(displayed_monsters, highlighted_monster, cached_config)
|
||||
cached_config = cached_config.static;
|
||||
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
|
||||
|
||||
-- sort here
|
||||
@@ -225,8 +268,8 @@ function large_monster_UI.draw_static(displayed_monsters, highlighted_monster)
|
||||
end
|
||||
end
|
||||
|
||||
function large_monster_UI.draw_highlighted(monster)
|
||||
local cached_config = config.current_config.large_monster_UI.highlighted;
|
||||
function large_monster_UI.draw_highlighted(monster, cached_config)
|
||||
cached_config = cached_config.highlighted;
|
||||
|
||||
if monster == nil then
|
||||
return;
|
||||
|
||||
@@ -38,7 +38,7 @@ function small_monster_UI.draw()
|
||||
|
||||
local monster = small_monster.list[enemy];
|
||||
if monster == nil then
|
||||
customization_menu.status = "No small monster hp entry";
|
||||
customization_menu.status = "No small monster entry";
|
||||
goto continue
|
||||
end
|
||||
|
||||
|
||||
@@ -53,6 +53,8 @@ customization_menu.displayed_damage_meter_UI_my_damage_bar_location_types = {};
|
||||
customization_menu.displayed_damage_meter_UI_sorting_types = {};
|
||||
customization_menu.displayed_damage_meter_UI_dps_modes = {};
|
||||
|
||||
customization_menu.displayed_auto_highlight_modes = {};
|
||||
|
||||
customization_menu.orientation_types = {};
|
||||
customization_menu.anchor_types = {};
|
||||
customization_menu.outline_styles = {};
|
||||
@@ -69,6 +71,8 @@ customization_menu.damage_meter_UI_my_damage_bar_location_types = {};
|
||||
customization_menu.damage_meter_UI_sorting_types = {};
|
||||
customization_menu.damage_meter_UI_dps_modes = {};
|
||||
|
||||
customization_menu.auto_highlight_modes = {};
|
||||
|
||||
customization_menu.fonts = {"Arial", "Arial Black", "Bahnschrift", "Calibri", "Cambria", "Cambria Math", "Candara",
|
||||
"Comic Sans MS", "Consolas", "Constantia", "Corbel", "Courier New", "Ebrima",
|
||||
"Franklin Gothic Medium", "Gabriola", "Gadugi", "Georgia", "HoloLens MDL2 Assets", "Impact",
|
||||
@@ -79,7 +83,8 @@ customization_menu.fonts = {"Arial", "Arial Black", "Bahnschrift", "Calibri", "C
|
||||
"MV Boli", "Myanmar Text", "Nirmala UI", "Palatino Linotype", "Segoe MDL2 Assets",
|
||||
"Segoe Print", "Segoe Script", "Segoe UI", "Segoe UI Historic", "Segoe UI Emoji",
|
||||
"Segoe UI Symbol", "SimSun", "Sitka", "Sylfaen", "Symbol", "Tahoma", "Times New Roman",
|
||||
"Trebuchet MS", "Verdana", "Webdings", "Wingdings", "Yu Gothic"};
|
||||
"Trebuchet MS", "Verdana", "Webdings", "Wingdings", "Yu Gothic"
|
||||
};
|
||||
|
||||
customization_menu.all_UI_waiting_for_key = false;
|
||||
customization_menu.small_monster_UI_waiting_for_key = false;
|
||||
@@ -155,6 +160,13 @@ function customization_menu.init()
|
||||
language.current_language.customization_menu.quest_time,
|
||||
language.current_language.customization_menu.join_time};
|
||||
|
||||
customization_menu.displayed_auto_highlight_modes = {language.current_language.customization_menu.closest,
|
||||
language.current_language.customization_menu.farthest,
|
||||
language.current_language.customization_menu.lowest_health,
|
||||
language.current_language.customization_menu.highest_health,
|
||||
language.current_language.customization_menu.lowest_health_percentage,
|
||||
language.current_language.customization_menu.highest_health_percentage};
|
||||
|
||||
customization_menu.orientation_types = {language.default_language.customization_menu.horizontal,
|
||||
language.default_language.customization_menu.vertical};
|
||||
customization_menu.anchor_types = {language.default_language.customization_menu.top_left,
|
||||
@@ -209,6 +221,13 @@ function customization_menu.init()
|
||||
customization_menu.damage_meter_UI_dps_modes = {language.default_language.customization_menu.first_hit,
|
||||
language.default_language.customization_menu.quest_time,
|
||||
language.default_language.customization_menu.join_time};
|
||||
|
||||
customization_menu.auto_highlight_modes = {language.default_language.customization_menu.closest,
|
||||
language.default_language.customization_menu.farthest,
|
||||
language.default_language.customization_menu.lowest_health,
|
||||
language.default_language.customization_menu.highest_health,
|
||||
language.default_language.customization_menu.lowest_health_percentage,
|
||||
language.default_language.customization_menu.highest_health_percentage};
|
||||
end
|
||||
|
||||
function customization_menu.draw()
|
||||
@@ -1285,6 +1304,26 @@ function customization_menu.draw_large_monster_highlighted_UI()
|
||||
imgui.tree_pop();
|
||||
end
|
||||
|
||||
if imgui.tree_node(language.current_language.customization_menu.auto_highlight) then
|
||||
changed, cached_config.auto_highlight.enabled = imgui.checkbox(
|
||||
language.current_language.customization_menu.enabled, cached_config.auto_highlight.enabled);
|
||||
|
||||
config_changed = config_changed or changed;
|
||||
|
||||
changed, index = imgui.combo(
|
||||
language.current_language.customization_menu.mode,
|
||||
table_helpers.find_index(customization_menu.auto_highlight_modes, cached_config.auto_highlight.mode),
|
||||
customization_menu.displayed_auto_highlight_modes);
|
||||
|
||||
config_changed = config_changed or changed;
|
||||
|
||||
if changed then
|
||||
cached_config.auto_highlight.mode = customization_menu.auto_highlight_modes[index];
|
||||
end
|
||||
|
||||
imgui.tree_pop();
|
||||
end
|
||||
|
||||
changed = large_monster_UI_customization.draw(cached_config);
|
||||
config_changed = config_changed or changed;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user