Add Auto-Highlight Option to Large Monster UI

This commit is contained in:
GreenComfyTea
2022-07-28 16:27:58 +03:00
parent 90fba51cd5
commit a66ff49c49
13 changed files with 184 additions and 57 deletions

View File

@@ -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;

View File

@@ -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

View File

@@ -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;