diff --git a/MHR_Overlay.lua b/MHR_Overlay.lua index 74bdb60..8ac8e60 100644 --- a/MHR_Overlay.lua +++ b/MHR_Overlay.lua @@ -1,18 +1,43 @@ --------------------CUSTOMIZATION SECTION-------------------- ---#region -local config = { - font = { - family = "Consolas", - size = 13, - bold = true, - italic = false +-- #region +local default_config = { + global_settings = { + module_visibility = { + during_quest = { + small_monster_UI = true, + large_monster_UI = true, + time_UI = true, + damage_meter_UI = true + }, + + quest_summary_screen = { + time_UI = true, + damage_meter_UI = true + }, + + training_area = { + large_monster_UI = true, + damage_meter_UI = true + } + }, + + font = { + family = "Consolas", + size = 13, + bold = true, + italic = false + }, }, small_monster_UI = { enabled = true, - - settings = { - spacing = 110, + + spacing = { + x = 110, + y = 40 + }, + + settings = { orientation = "Horizontal" }, @@ -30,15 +55,15 @@ local config = { sorting = { type = "Normal", - reversed_order = false, + reversed_order = false }, - + position = { x = 0, y = 0, anchor = "Top-Left" }, - + monster_name_label = { visibility = true, text = "%s", @@ -48,7 +73,7 @@ local config = { y = 0 }, color = 0xFFCCF4E1, - + shadow = { visibility = true, offset = { @@ -58,7 +83,7 @@ local config = { color = 0xFF000000 } }, - + health_label = { visibility = false, text = "HP:", @@ -67,7 +92,7 @@ local config = { y = 12 }, color = 0xFFCCF4E1, - + shadow = { visibility = true, offset = { @@ -77,7 +102,7 @@ local config = { color = 0xFF000000 } }, - + health_value_label = { visibility = true, text = "%.0f/%.0f", -- current_health/max_health @@ -86,7 +111,7 @@ local config = { y = 25 }, color = 0xFFCCF4E1, - + shadow = { visibility = true, offset = { @@ -96,17 +121,17 @@ local config = { color = 0xFF000000 } }, - + health_percentage_label = { visibility = false, text = "%5.1f%%", - + offset = { x = 55, y = 0 }, - color = 0xFFFFFFFF, - + color = 0xFFCCF4E1, + shadow = { visibility = true, offset = { @@ -116,32 +141,36 @@ local config = { color = 0xFF000000 } }, - + health_bar = { visibility = true, offset = { x = 0, y = 17 }, - + size = { width = 100, height = 7 }, - + colors = { - foreground = 0xB9B2ff7E, + foreground = 0xB974A652, background = 0xB9000000, capture_health = 0xB9CCCC33 - }, + } } }, large_monster_UI = { enabled = true, - - settings = { - spacing = 220, + + spacing = { + x = 220, + y = 40, + }, + + settings = { orientation = "Horizontal" }, @@ -152,22 +181,22 @@ local config = { x = -100, y = -200 }, - + max_distance = 15000, opacity_falloff = true }, sorting = { type = "Normal", - reversed_order = false, + reversed_order = false }, - + position = { x = 525, y = 44, anchor = "Bottom-Left" }, - + monster_name_label = { visibility = true, text = "%s", @@ -176,8 +205,7 @@ local config = { monster_name = true, crown = true, size = true, - silver_crown_threshold = false, - gold_crown_threshold = false + crown_thresholds = false }, offset = { @@ -185,7 +213,7 @@ local config = { y = 0 }, color = 0xFFCCF4E1, - + shadow = { visibility = true, offset = { @@ -195,7 +223,7 @@ local config = { color = 0xFF000000 } }, - + health_label = { visibility = false, text = "HP:", @@ -204,7 +232,7 @@ local config = { y = 19 }, color = 0xFFCCF4E1, - + shadow = { visibility = true, offset = { @@ -214,7 +242,7 @@ local config = { color = 0xFF000000 } }, - + health_value_label = { visibility = true, text = "%.0f/%.0f", -- current_health/max_health @@ -223,7 +251,7 @@ local config = { y = 19 }, color = 0xFFFFFFFF, - + shadow = { visibility = true, offset = { @@ -233,17 +261,17 @@ local config = { color = 0xFF000000 } }, - + health_percentage_label = { visibility = true, text = "%5.1f%%", - + offset = { x = 150, y = 19 }, color = 0xFFFFFFFF, - + shadow = { visibility = true, offset = { @@ -253,36 +281,36 @@ local config = { color = 0xFF000000 } }, - + health_bar = { visibility = true, offset = { x = 0, y = 17 }, - + size = { width = 200, height = 20 }, - + colors = { - foreground = 0xB9B2ff7E, + foreground = 0xB974A652, background = 0xB9000000, capture_health = 0xB9CCCC33 - }, + } } }, time_UI = { enabled = true, - + position = { x = 65, y = 189, anchor = "Top-Left" }, - + time_label = { visibility = true, text = "%02d:%06.3f", @@ -291,7 +319,7 @@ local config = { y = 0 }, color = 0xFFCCF4E1, - + shadow = { visibility = true, offset = { @@ -305,12 +333,12 @@ local config = { damage_meter_UI = { enabled = true, - + tracked_monster_types = { small_monsters = true, large_monsters = true }, - + tracked_damage_types = { player_damage = true, bomb_damage = true, @@ -319,9 +347,13 @@ local config = { otomo_damage = true, monster_damage = true }, -- note that installations during narwa fight are counted as monster damage - + + spacing = { + x = 270, + y = 24 + }, + settings = { - spacing = 24, orientation = "Vertical", -- "Vertical" or "Horizontal" hide_module_if_total_damage_is_zero = false, @@ -330,21 +362,21 @@ local config = { highlighted_bar = "Me", damage_bar_relative_to = "Top Damage", -- "total damage" or "top damage" - my_damage_bar_location = "First", --"normal" or "first" or "last" + my_damage_bar_location = "First" -- "normal" or "first" or "last" }, - + sorting = { type = "Damage", -- "normal" or "damage" - reversed_order = false, + reversed_order = false }, - + position = { x = 525, y = 225, - --Possible values: "Top-Left", "Top-Right", "Bottom-Left", "Bottom-Right" + -- Possible values: "Top-Left", "Top-Right", "Bottom-Left", "Bottom-Right" anchor = "Bottom-Left" }, - + player_name_label = { visibility = true, @@ -370,7 +402,7 @@ local config = { y = 0 }, color = 0xFFCCF4E1, - + shadow = { visibility = true, offset = { @@ -380,7 +412,7 @@ local config = { color = 0xFF000000 } }, - + damage_value_label = { visibility = true, text = "%.0f", @@ -389,7 +421,7 @@ local config = { y = 0 }, color = 0xFFCCF4E1, - + shadow = { visibility = true, offset = { @@ -399,7 +431,7 @@ local config = { color = 0xFF000000 } }, - + damage_percentage_label = { visibility = true, text = "%5.1f%%", @@ -408,7 +440,7 @@ local config = { y = 0 }, color = 0xFFCCF4E1, - + shadow = { visibility = true, offset = { @@ -418,7 +450,7 @@ local config = { color = 0xFF000000 } }, - + total_damage_label = { visibility = true, text = "Total Damage", @@ -427,7 +459,7 @@ local config = { y = 0 }, color = 0xFFFF7373, - + shadow = { visibility = true, offset = { @@ -437,7 +469,7 @@ local config = { color = 0xFF000000 } }, - + total_damage_value_label = { visibility = true, text = "%.0f", @@ -446,7 +478,7 @@ local config = { y = 0 }, color = 0xFFFF7373, - + shadow = { visibility = true, offset = { @@ -456,101 +488,101 @@ local config = { color = 0xFF000000 } }, - + damage_bar = { visibility = true, offset = { x = 0, y = 17 }, - + size = { width = 250, height = 5 }, - + colors = { - foreground = 0xD2CCA3F4, - background = 0xB9000000 - }, + foreground = 0xA7CCA3F4, + background = 0xA7000000 + } }, - + highlighted_damage_bar = { visibility = true, offset = { x = 0, y = 17 }, - + size = { width = 250, height = 5 }, - + colors = { - foreground = 0xD2FFCD59, - background = 0xB9000000 - }, + foreground = 0xA7F4D5A3, + background = 0xA7000000 + } } } }; ---#endregion +-- #endregion ----------------------CUSTOMIZATION END---------------------- - - - - --------------------FUNCTION DEFINITIONS--------------------- ---#region +-- #region local init; local init_singletons; -local init_scene_manager; local init_message_manager; local init_enemy_manager; local init_lobby_manager; local init_progress_manager; local init_quest_manager; +local init_player_manager; +local init_village_area_manager; -local customization_ui; +local table_deep_copy; +local table_find_index; +local table_merge; local save_config; local load_config; +local customization_ui; + local get_window_size; local calculate_screen_coordinates; -local table_find_index; + +local is_in_training_area; local draw_label; local draw_bar; local old_draw_label; local old_draw_bar; +local init_monster; local update_monster; local small_monster_data; local large_monster_data; local quest_time; - local init_player; local merge_damage; local get_player; -local update_player; +local update_player_damage; +local update_player_display; local damage_meter; ---#endregion +-- #endregion --------------------FUNCTION DEFINITIONS--------------------- - - - - --------------------VARIABLE DEFINITIONS--------------------- ---#region +-- #region local config_file_name; +local config; local font; -local fonts = {}; +local fonts; local selected_font_index; local is_customization_window_opened; @@ -558,9 +590,7 @@ local is_customization_window_opened; local status; local x; -local screen_width; -local screen_height; -local scene_view; +local screen_size; local quest_status; @@ -570,33 +600,175 @@ local players; local total; local is_quest_online; local last_displayed_players; -local myself_player_id; +local master_player_id; +local master_player_position; ---Singletons -local scene_manager; +-- Singletons local message_manager; local enemy_manager; local lobby_manager; local progress_manager; local quest_manager; ---#endregion +local player_manager; +local village_area_manager; +-- #endregion --------------------VARIABLE DEFINITIONS--------------------- +-----------------------TABLE HELPERS------------------------- +-- #region +table_deep_copy = function(original, copies) + copies = copies or {}; + local original_type = type(original); + local copy; + if original_type == 'table' then + if copies[original] then + copy = copies[original]; + else + copy = {}; + copies[original] = copy; + for original_key, original_value in next, original, nil do + copy[table_deep_copy(original_key, copies)] = table_deep_copy(original_value, copies); + end + setmetatable(copy, table_deep_copy(getmetatable(original), copies)); + end + else -- number, string, boolean, etc + copy = original; + end + return copy; +end +table_find_index = function(table, value, nullable) + for i = 1, #table do + if table[i] == value then + return i; + end + end + if not nullable then + return 1; + end + return nil; +end + +table_merge = function(...) + local tables_to_merge = {...}; + assert(#tables_to_merge > 1, "There should be at least two tables to merge them"); + + for key, table in ipairs(tables_to_merge) do + assert(type(table) == "table", string.format("Expected a table as function parameter %d", key)); + end + + local result = table_deep_copy(tables_to_merge[1]); + + for i = 2, #tables_to_merge do + local from = tables_to_merge[i]; + for key, value in pairs(from) do + if type(value) == "table" then + result[key] = result[key] or {}; + assert(type(result[key]) == "table", string.format("Expected a table: '%s'", key)); + result[key] = table_merge(result[key], value); + else + result[key] = value; + end + end + end + + return result; +end + +table_tostring = function(table) + local cache, stack, output = {}, {}, {}; + local depth = 1; + local output_string = "{\n"; + + while true do + local size = 0; + for key, value in pairs(table) do + size = size + 1; + end + + local current_index = 1; + for key, value in pairs(table) do + if (cache[table] == nil) or (current_index >= cache[table]) then + + if (string.find(output_string, "}", output_string:len())) then + output_string = output_string .. ",\n"; + elseif not (string.find(output_string, "\n",output_stringr:len())) then + output_string = output_string .. "\n"; + end + + -- This is necessary for working with HUGE tables otherwise we run out of memory using concat on huge strings + table.insert(output, output_string); + output_string = ""; + + local key; + if (type(key) == "number" or type(key) == "boolean") then + key = "[" .. tostring(key) .. "]"; + else + key = "['" .. tostring(key) .. "']"; + end + + if (type(value) == "number" or type(value) == "boolean") then + output_string = output_string .. string.rep('\t', depth) .. key .. " = " .. tostring(value); + elseif (type(value) == "table") then + output_string = output_string .. string.rep('\t', depth) .. key .. " = {\n"; + table.insert(stack, table); + table.insert(stack, value); + cache[table] = current_index + 1; + break + else + output_string = output_string .. string.rep('\t', depth) .. key .. " = '" .. tostring(value) .. "'"; + end + + if (current_index == size) then + output_string = output_string .. "\n" .. string.rep('\t', depth - 1) .. "}"; + else + output_string = output_string .. ","; + end + else + -- close the table + if (current_index == size) then + output_string = output_string .. "\n" .. string.rep('\t', depth - 1) .. "}"; + end + end + + current_index = current_index + 1; + end + + if (size == 0) then + output_string = output_string .. "\n" .. string.rep('\t', depth - 1) .. "}"; + end + + if (#stack > 0) then + table = stack[#stack]; + stack[#stack] = nil; + depth = cache[table] == nil and depth + 1 or depth - 1; + else + break; + end + end + + -- This is necessary for working with HUGE tables otherwise we run out of memory using concat on huge strings + table.insert(output, output_string); + output_string = table.concat(output); + + return output_string; +end +-- #endregion +-----------------------TABLE HELPERS------------------------- ----------------------CONFIG LOAD/SAVE----------------------- ---#region +-- #region load_config = function() local loaded_config = json.load_file(config_file_name); if loaded_config ~= nil then log.info('[MHR Overlay] config.json loaded successfully'); - config = loaded_config; + config = table_merge(config, loaded_config); end end -save_config = function () +save_config = function() -- save current config to disk, replacing any existing file local success = json.dump_file(config_file_name, config); if success then @@ -605,19 +777,17 @@ save_config = function () log.error('[MHR Overlay] Failed to save config.json'); end end ---#endregion +-- #endregion ----------------------CONFIG LOAD/SAVE----------------------- - - - - ----------------------------INIT----------------------------- ---#region +-- #region config_file_name = 'MHR Overlay/config.json'; -load_config(); init = function() + config = table_deep_copy(default_config); + load_config(); + init_singletons(); status = "OK"; @@ -633,18 +803,15 @@ init = function() end end - screen_width = 0; - screen_height = 0; - if scene_manager ~= nil then - scene_view = sdk.call_native_func(scene_manager, sdk.find_type_definition("via.SceneManager"), "get_MainView"); + screen_size = { + width = 1920, + height = 1080 + }; - if scene_view == nil then - log.error("[MHR Overlay] No main view"); - return false; - else - get_window_size(); - end - end + master_player_position = { + x = 0, + y = 0 + } large_monsters = {}; small_monsters = {}; @@ -653,7 +820,7 @@ init = function() total = init_player(0, "Total", 0); is_quest_online = false; last_displayed_players = {}; - myself_player_id = 0; + master_player_id = 0; log.info("[MHR Overlay] loaded"); @@ -664,53 +831,56 @@ init = function() monster_UI_sort_types = {"Normal", "Health", "Health Percentage"}; monster_UI_sort_type_index = table_find_index(monster_UI_sort_types, config.large_monster_UI.sorting.type, false); - damage_meter_UI_orientation_index = table_find_index(orientation_types, config.damage_meter_UI.settings.orientation, false); + damage_meter_UI_orientation_index = table_find_index(orientation_types, config.damage_meter_UI.settings.orientation, + false); damage_meter_UI_highlighted_bar_types = {"Me", "Top Damage", "None"}; - damage_meter_UI_highlighted_bar_index = table_find_index(damage_meter_UI_highlighted_bar_types, config.damage_meter_UI.settings.highlighted_bar, false); + damage_meter_UI_highlighted_bar_index = table_find_index(damage_meter_UI_highlighted_bar_types, + config.damage_meter_UI.settings.highlighted_bar, false); damage_meter_UI_damage_bar_relative_types = {"Total Damage", "Top Damage"}; - damage_meter_UI_damage_bar_relative_index = table_find_index(damage_meter_UI_damage_bar_relative_types, config.damage_meter_UI.settings.damage_bar_relative_to, false); + damage_meter_UI_damage_bar_relative_index = table_find_index(damage_meter_UI_damage_bar_relative_types, + config.damage_meter_UI.settings.damage_bar_relative_to, false); damage_meter_UI_my_damage_bar_location_types = {"Normal", "First", "Last"}; - damage_meter_UI_my_damage_bar_location_index = table_find_index(damage_meter_UI_my_damage_bar_location_types, config.damage_meter_UI.settings.my_damage_bar_location, false); + damage_meter_UI_my_damage_bar_location_index = table_find_index(damage_meter_UI_my_damage_bar_location_types, + config.damage_meter_UI.settings.my_damage_bar_location, false); damage_meter_UI_sort_types = {"Normal", "Damage"}; - damage_meter_UI_sort_type_index = table_find_index(damage_meter_UI_sort_types, config.damage_meter_UI.sorting.type, false); + damage_meter_UI_sort_type_index = table_find_index(damage_meter_UI_sort_types, config.damage_meter_UI.sorting.type, + false); is_customization_window_opened = false; - 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", "Ink Free", "Javanese Text", "Leelawadee UI", "Lucida Console", "Lucida Sans Unicode", "Malgun Gothic", "Marlett", "Microsoft Himalaya", "Microsoft JhengHei", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Sans Serif", "Microsoft Tai Le", "Microsoft YaHei", "Microsoft Yi Baiti", "MingLiU-ExtB", "Mongolian Baiti", "MS Gothic", "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"}; - selected_font_index = table_find_index(fonts, config.font.family, false); + 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", "Ink Free", "Javanese Text", "Leelawadee UI", "Lucida Console", + "Lucida Sans Unicode", "Malgun Gothic", "Marlett", "Microsoft Himalaya", "Microsoft JhengHei", + "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Sans Serif", "Microsoft Tai Le", "Microsoft YaHei", + "Microsoft Yi Baiti", "MingLiU-ExtB", "Mongolian Baiti", "MS Gothic", "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"}; + selected_font_index = table_find_index(fonts, config.global_settings.font.family, false); return true; end init_singletons = function() - init_scene_manager(); init_message_manager(); init_enemy_manager(); init_lobby_manager() init_progress_manager(); init_quest_manager(); -end - -init_scene_manager = function() - if scene_manager ~= nil then - return; - end - - scene_manager = sdk.get_native_singleton("via.SceneManager"); - if scene_manager == nil then - log.error("[MHR Overlay] No scene manager"); - end + init_player_manager(); + init_village_area_manager(); end init_message_manager = function() if message_manager ~= nil then return; end - + message_manager = sdk.get_managed_singleton("snow.gui.MessageManager"); if message_manager == nil then log.error("[MHR Overlay] No message manager"); @@ -723,7 +893,7 @@ init_enemy_manager = function() end enemy_manager = sdk.get_managed_singleton("snow.enemy.EnemyManager"); - if enemy_manager == nil then + if enemy_manager == nil then log.error("[MHR Overlay] No enemy manager"); end end @@ -732,24 +902,24 @@ init_lobby_manager = function() if lobby_manager ~= nil then return; end - + lobby_manager = sdk.get_managed_singleton("snow.LobbyManager"); - if lobby_manager == nil then + if lobby_manager == nil then log.error("[MHR Overlay] No lobby manager"); - return false; - end + return false; + end end init_progress_manager = function() if progress_manager ~= nil then return; end - + progress_manager = sdk.get_managed_singleton("snow.progress.ProgressManager"); - if progress_manager == nil then - log.error("[MHR Overlay] No progress manager"); - return false; - end + if progress_manager == nil then + log.error("[MHR Overlay] No progress manager"); + return false; + end end init_quest_manager = function() @@ -758,96 +928,236 @@ init_quest_manager = function() end quest_manager = sdk.get_managed_singleton("snow.QuestManager"); - if quest_manager == nil then - log.error("[MHR Overlay] No quest manager"); - end + if quest_manager == nil then + log.error("[MHR Overlay] No quest manager"); + end end ---#endregion + +init_player_manager = function() + if player_manager ~= nil then + return; + end + + player_manager = sdk.get_managed_singleton("snow.player.PlayerManager"); + if player_manager == nil then + log.error("[MHR Overlay] No player manager"); + end +end + +init_village_area_manager = function() + if village_area_manager ~= nil then + return; + end + + village_area_manager = sdk.get_managed_singleton("snow.VillageAreaManager"); + if village_area_manager == nil then + log.error("[MHR Overlay] No village manager"); + end +end +-- #endregion ----------------------------INIT----------------------------- +--------------------------RE_IMGUI--------------------------- +-- #region +re.on_draw_ui(function() + if imgui.button('MHR Overlay') then + is_customization_window_opened = not is_customization_window_opened; + end +end); +re.on_frame(function() + if is_customization_window_opened then + customization_ui(); + end + --draw.text("x: " .. tostring(x), 450, 50, 0xFFFFFFFF); +end); +-- #endregion +--------------------------RE_IMGUI--------------------------- - ---------------------------D2D--------------------------- ---#region +----------------------------D2D------------------------------ +-- #region d2d.register(function() - font = d2d.create_font(config.font.family, config.font.size, config.font.bold, config.font.italic); -end, -function() + font = d2d.create_font(config.global_settings.font.family, config.global_settings.font.size, config.global_settings.font.bold, config.global_settings.font.italic); +end, function() status = "OK"; get_window_size(); init_singletons(); - if config.small_monster_UI.enabled then - small_monster_data(); + if quest_status < 2 then + if is_in_training_area() then + if config.large_monster_UI.enabled and config.global_settings.module_visibility.training_area.large_monster_UI then + large_monster_data(); + end + + if config.damage_meter_UI.enabled and config.global_settings.module_visibility.training_area.damage_meter_UI then + damage_meter(); + end + end + + elseif quest_status == 2 then + if config.small_monster_UI.enabled and config.global_settings.module_visibility.during_quest.small_monster_UI then + small_monster_data(); + end + + if config.large_monster_UI.enabled and config.global_settings.module_visibility.during_quest.large_monster_UI then + large_monster_data(); + end + + if config.time_UI.enabled and config.global_settings.module_visibility.during_quest.time_UI then + quest_time(); + end + + if config.damage_meter_UI.enabled and config.global_settings.module_visibility.during_quest.damage_meter_UI then + damage_meter(); + end + elseif quest_status > 2 then + if config.time_UI.enabled and config.global_settings.module_visibility.quest_summary_screen.time_UI then + quest_time(); + end + + if config.damage_meter_UI.enabled and config.global_settings.module_visibility.quest_summary_screen.damage_meter_UI then + damage_meter(); + end + end +end); + +calculate_screen_coordinates = function (position) + if position.anchor == "Top-Left" then + return {x = position.x, y = position.y}; end - if config.large_monster_UI.enabled then - large_monster_data(); + if position.anchor == "Top-Right" then + local screen_x = screen_size.width - position.x; + return {x = screen_x, y = position.y}; end - if config.time_UI.enabled then - quest_time(); + if position.anchor == "Bottom-Left" then + local screen_y = screen_size.height - position.y; + return {x = position.x, y = screen_y}; end - if config.damage_meter_UI.enabled then - damage_meter(); + if position.anchor == "Bottom-Right" then + local screen_x = screen_size.width - position.x; + local screen_y = screen_size.height - position.y; + return {x = screen_x, y = screen_y}; end - --d2d.text(font, "x: " .. tostring(x), 450, 50, 0xFFFFFFFF); -end) ---#endregion ---------------------------D2D--------------------------- + return {x = position.x, y = position.y}; +end +get_window_size = function() + local width, height = d2d.surface_size(); + if width ~= nil then + screen_size.width = width; + end + + if height ~= nil then + screen_size.height = height; + end +end +-- #endregion +----------------------------D2D------------------------------ ----------------------CUSTOMIZATION UI----------------------- ---#region +-- #region customization_ui = function() is_customization_window_opened = imgui.begin_window("MHR Overlay", is_customization_window_opened, 0x10120); if not is_customization_window_opened then return; end - + local config_changed = false; local changed; local status_string = tostring(status); imgui.text("Status: " .. status_string); - if imgui.tree_node("Font") then - imgui.text("Any changes to the font require script reload!"); + if imgui.tree_node("Modules") then + changed, config.small_monster_UI.enabled = imgui.checkbox("Small Monster UI", config.small_monster_UI.enabled); + config_changed = config_changed or changed; + imgui.same_line(); - changed, selected_font_index = imgui.combo("Family", selected_font_index, fonts); + changed, config.large_monster_UI.enabled = imgui.checkbox("Large Monster UI", config.large_monster_UI.enabled); config_changed = config_changed or changed; - if changed then - config.font.family = fonts[selected_font_index]; - end - changed, config.font.size = imgui.slider_int("Size", config.font.size, 1, 100); + changed, config.time_UI.enabled = imgui.checkbox("Time UI", config.time_UI.enabled); config_changed = config_changed or changed; - - changed, config.font.bold = imgui.checkbox("Bold", config.font.bold); - config_changed = config_changed or changed; - - changed, config.font.italic = imgui.checkbox("Italic", config.font.italic); + imgui.same_line(); + + changed, config.damage_meter_UI.enabled = imgui.checkbox("Damage Meter UI", config.damage_meter_UI.enabled); config_changed = config_changed or changed; imgui.tree_pop(); end - if imgui.tree_node("Modules") then - changed, config.large_monster_UI.enabled = imgui.checkbox("Monster UI", config.large_monster_UI.enabled); - config_changed = config_changed or changed; - imgui.same_line(); + if imgui.tree_node("Global Settings") then + if imgui.tree_node("Module Visibility on Different Screens") then + + if imgui.tree_node("During Quest") then + changed, config.global_settings.module_visibility.during_quest.small_monster_UI = imgui.checkbox("Small Monster UI", config.global_settings.module_visibility.during_quest.small_monster_UI); + config_changed = config_changed or changed; + imgui.same_line(); - changed, config.time_UI.enabled = imgui.checkbox("Time UI", config.time_UI.enabled); - config_changed = config_changed or changed; - imgui.same_line(); - - changed, config.damage_meter_UI.enabled = imgui.checkbox("Damage Meter UI", config.damage_meter_UI.enabled); - config_changed = config_changed or changed; + changed, config.global_settings.module_visibility.during_quest.large_monster_UI = imgui.checkbox("Large Monster UI", config.global_settings.module_visibility.during_quest.large_monster_UI); + config_changed = config_changed or changed; + + changed, config.global_settings.module_visibility.during_quest.time_UI = imgui.checkbox("Time UI", config.global_settings.module_visibility.during_quest.time_UI); + config_changed = config_changed or changed; + imgui.same_line(); + + changed, config.global_settings.module_visibility.during_quest.damage_meter_UI = imgui.checkbox("Damage Meter UI", config.global_settings.module_visibility.during_quest.damage_meter_UI); + config_changed = config_changed or changed; + + imgui.tree_pop(); + end + + if imgui.tree_node("Quest Summary Screen") then + changed, config.global_settings.module_visibility.quest_summary_screen.time_UI = imgui.checkbox("Time UI", config.global_settings.module_visibility.quest_summary_screen.time_UI); + config_changed = config_changed or changed; + imgui.same_line(); + + changed, config.global_settings.module_visibility.quest_summary_screen.damage_meter_UI = imgui.checkbox("Damage Meter UI", config.global_settings.module_visibility.quest_summary_screen.damage_meter_UI); + config_changed = config_changed or changed; + + imgui.tree_pop(); + end + + if imgui.tree_node("Training Area") then + changed, config.global_settings.module_visibility.training_area.large_monster_UI = imgui.checkbox("Large Monster UI", config.global_settings.module_visibility.training_area.large_monster_UI); + config_changed = config_changed or changed; + imgui.same_line(); + + changed, config.global_settings.module_visibility.training_area.damage_meter_UI = imgui.checkbox("Damage Meter UI", config.global_settings.module_visibility.training_area.damage_meter_UI); + config_changed = config_changed or changed; + + imgui.tree_pop(); + end + + imgui.tree_pop(); + end + + if imgui.tree_node("Font") then + imgui.text("Any changes to the font require script reload!"); + + changed, selected_font_index = imgui.combo("Family", selected_font_index, fonts); + config_changed = config_changed or changed; + if changed then + config.global_settings.font.family = fonts[selected_font_index]; + end + + changed, config.global_settings.font.size = imgui.slider_int("Size", config.global_settings.font.size, 1, 100); + config_changed = config_changed or changed; + + changed, config.global_settings.font.bold = imgui.checkbox("Bold", config.global_settings.font.bold); + config_changed = config_changed or changed; + + changed, config.global_settings.font.italic = imgui.checkbox("Italic", config.global_settings.font.italic); + config_changed = config_changed or changed; + + imgui.tree_pop(); + end imgui.tree_pop(); end @@ -856,10 +1166,19 @@ customization_ui = function() changed, config.small_monster_UI.enabled = imgui.checkbox("Enabled", config.small_monster_UI.enabled); config_changed = config_changed or changed; - if imgui.tree_node("Settings") then - changed, config.small_monster_UI.settings.spacing = imgui.drag_float("Spacing", config.small_monster_UI.settings.spacing, 0.1, 0, screen_width, "%.1f"); + if imgui.tree_node("Spacing") then + changed, config.small_monster_UI.spacing.y = imgui.drag_float("X", + config.small_monster_UI.spacing.y, 0.1, 0, screen_size.width, "%.1f"); config_changed = config_changed or changed; + changed, config.small_monster_UI.spacing.y = imgui.drag_float("Y", + config.small_monster_UI.spacing.y, 0.1, 0, screen_size.width, "%.1f"); + config_changed = config_changed or changed; + + imgui.tree_pop(); + end + + if imgui.tree_node("Settings") then changed, monster_UI_orientation_index = imgui.combo("Orientation", monster_UI_orientation_index, orientation_types); config_changed = config_changed or changed; if changed then @@ -870,16 +1189,19 @@ customization_ui = function() end if imgui.tree_node("Dynamic Positioning") then - changed, config.small_monster_UI.dynamic_positioning.enabled = imgui.checkbox("Enabled", config.small_monster_UI.dynamic_positioning.enabled); + changed, config.small_monster_UI.dynamic_positioning.enabled = + imgui.checkbox("Enabled", config.small_monster_UI.dynamic_positioning.enabled); config_changed = config_changed or changed; if imgui.tree_node("Viewport Offset") then - changed, config.small_monster_UI.dynamic_positioning.viewport_offset.x = imgui.drag_float("X", config.small_monster_UI.dynamic_positioning.viewport_offset.x, 0.1, 0, screen_width, "%.1f"); + changed, config.small_monster_UI.dynamic_positioning.viewport_offset.x = imgui.drag_float("X", + config.small_monster_UI.dynamic_positioning.viewport_offset.x, 0.1, 0, screen_size.width, "%.1f"); config_changed = config_changed or changed; - - changed, config.small_monster_UI.dynamic_positioning.viewport_offset.y = imgui.drag_float("Y", config.small_monster_UI.dynamic_positioning.viewport_offset.y, 0.1, 0, screen_height, "%.1f"); + + changed, config.small_monster_UI.dynamic_positioning.viewport_offset.y = imgui.drag_float("Y", + config.small_monster_UI.dynamic_positioning.viewport_offset.y, 0.1, 0, screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end @@ -887,60 +1209,71 @@ customization_ui = function() end if imgui.tree_node("Position") then - changed, config.small_monster_UI.position.x = imgui.drag_float("X", config.small_monster_UI.position.x, 0.1, 0, screen_width, "%.1f"); + changed, config.small_monster_UI.position.x = imgui.drag_float("X", config.small_monster_UI.position.x, 0.1, 0, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.small_monster_UI.position.y = imgui.drag_float("Y", config.small_monster_UI.position.y, 0.1, 0, screen_height, "%.1f"); + changed, config.small_monster_UI.position.y = imgui.drag_float("Y", config.small_monster_UI.position.y, 0.1, 0, + screen_size.height, "%.1f"); config_changed = config_changed or changed; imgui.tree_pop(); end - + if imgui.tree_node("Sorting") then changed, monster_UI_sort_type_index = imgui.combo("Type", monster_UI_sort_type_index, monster_UI_sort_types); config_changed = config_changed or changed; if changed then config.small_monster_UI.sorting.type = monster_UI_sort_types[monster_UI_sort_type_index]; end - - changed, config.small_monster_UI.reversed_order = imgui.checkbox("Reversed Order", config.small_monster_UI.reversed_order); + + changed, config.small_monster_UI.sorting.reversed_order = imgui.checkbox("Reversed Order", + config.small_monster_UI.sorting.reversed_order); config_changed = config_changed or changed; imgui.tree_pop(); end if imgui.tree_node("Monster Name Label") then - changed, config.small_monster_UI.monster_name_label.visibility = imgui.checkbox("Visible", config.small_monster_UI.monster_name_label.visibility); + changed, config.small_monster_UI.monster_name_label.visibility = + imgui.checkbox("Visible", config.small_monster_UI.monster_name_label.visibility); config_changed = config_changed or changed; if imgui.tree_node("Offset") then - changed, config.small_monster_UI.monster_name_label.offset.x = imgui.drag_float("X", config.small_monster_UI.monster_name_label.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.small_monster_UI.monster_name_label.offset.x = + imgui.drag_float("X", config.small_monster_UI.monster_name_label.offset.x, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.small_monster_UI.monster_name_label.offset.y = imgui.drag_float("Y", config.small_monster_UI.monster_name_label.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.small_monster_UI.monster_name_label.offset.y = + imgui.drag_float("Y", config.small_monster_UI.monster_name_label.offset.y, 0.1, -screen_size.height, + screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end - --color picker? + -- color picker? if imgui.tree_node("Shadow") then - changed, config.small_monster_UI.monster_name_label.shadow.visibility = imgui.checkbox("Enable", config.small_monster_UI.monster_name_label.shadow.visibility); + changed, config.small_monster_UI.monster_name_label.shadow.visibility = imgui.checkbox("Enable", + config.small_monster_UI.monster_name_label.shadow.visibility); config_changed = config_changed or changed; if imgui.tree_node("Offset") then - changed, config.small_monster_UI.monster_name_label.shadow.offset.x = imgui.drag_float("X", config.small_monster_UI.monster_name_label.shadow.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.small_monster_UI.monster_name_label.shadow.offset.x = imgui.drag_float("X", + config.small_monster_UI.monster_name_label.shadow.offset.x, 0.1, -screen_size.width, screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.small_monster_UI.monster_name_label.shadow.offset.y = imgui.drag_float("Y", config.small_monster_UI.monster_name_label.shadow.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.small_monster_UI.monster_name_label.shadow.offset.y = imgui.drag_float("Y", + config.small_monster_UI.monster_name_label.shadow.offset.y, 0.1, -screen_size.height, screen_size.height, "%.1f"); config_changed = config_changed or changed; imgui.tree_pop(); end - --color picker - + -- color picker + imgui.tree_pop(); end @@ -948,37 +1281,47 @@ customization_ui = function() end if imgui.tree_node("Health Label") then - changed, config.small_monster_UI.health_label.visibility = imgui.checkbox("Visible", config.small_monster_UI.health_label.visibility); + changed, config.small_monster_UI.health_label.visibility = + imgui.checkbox("Visible", config.small_monster_UI.health_label.visibility); config_changed = config_changed or changed; -- add text format if imgui.tree_node("Offset") then - changed, config.small_monster_UI.health_label.offset.x = imgui.drag_float("X", config.small_monster_UI.health_label.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.small_monster_UI.health_label.offset.x = + imgui.drag_float("X", config.small_monster_UI.health_label.offset.x, 0.1, -screen_size.width, screen_size.width, + "%.1f"); config_changed = config_changed or changed; - changed, config.small_monster_UI.health_label.offset.y = imgui.drag_float("Y", config.small_monster_UI.health_label.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.small_monster_UI.health_label.offset.y = + imgui.drag_float("Y", config.small_monster_UI.health_label.offset.y, 0.1, -screen_size.height, screen_size.height, + "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end - --color picker? + -- color picker? if imgui.tree_node("Shadow") then - changed, config.small_monster_UI.health_label.shadow.visibility = imgui.checkbox("Enable", config.small_monster_UI.health_label.shadow.visibility); + changed, config.small_monster_UI.health_label.shadow.visibility = + imgui.checkbox("Enable", config.small_monster_UI.health_label.shadow.visibility); config_changed = config_changed or changed; if imgui.tree_node("Offset") then - changed, config.small_monster_UI.health_label.shadow.offset.x = imgui.drag_float("X", config.small_monster_UI.health_label.shadow.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.small_monster_UI.health_label.shadow.offset.x = + imgui.drag_float("X", config.small_monster_UI.health_label.shadow.offset.x, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.small_monster_UI.health_label.shadow.offset.y = imgui.drag_float("Y", config.small_monster_UI.health_label.shadow.offset.y, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.small_monster_UI.health_label.shadow.offset.y = + imgui.drag_float("Y", config.small_monster_UI.health_label.shadow.offset.y, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; imgui.tree_pop(); end - + imgui.tree_pop(); end @@ -986,37 +1329,45 @@ customization_ui = function() end if imgui.tree_node("Health Value Label") then - changed, config.small_monster_UI.health_value_label.visibility = imgui.checkbox("Visible", config.small_monster_UI.health_value_label.visibility); + changed, config.small_monster_UI.health_value_label.visibility = + imgui.checkbox("Visible", config.small_monster_UI.health_value_label.visibility); config_changed = config_changed or changed; -- add text format if imgui.tree_node("Offset") then - changed, config.small_monster_UI.health_value_label.offset.x = imgui.drag_float("X", config.small_monster_UI.health_value_label.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.small_monster_UI.health_value_label.offset.x = + imgui.drag_float("X", config.small_monster_UI.health_value_label.offset.x, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.small_monster_UI.health_value_label.offset.y = imgui.drag_float("Y", config.small_monster_UI.health_value_label.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.small_monster_UI.health_value_label.offset.y = + imgui.drag_float("Y", config.small_monster_UI.health_value_label.offset.y, 0.1, -screen_size.height, + screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end - --color picker? + -- color picker? if imgui.tree_node("Shadow") then - changed, config.small_monster_UI.health_value_label.shadow.visibility = imgui.checkbox("Enable", config.small_monster_UI.health_value_label.shadow.visibility); + changed, config.small_monster_UI.health_value_label.shadow.visibility = imgui.checkbox("Enable", + config.small_monster_UI.health_value_label.shadow.visibility); config_changed = config_changed or changed; if imgui.tree_node("Offset") then - changed, config.small_monster_UI.health_value_label.shadow.offset.x = imgui.drag_float("X", config.small_monster_UI.health_value_label.shadow.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.small_monster_UI.health_value_label.shadow.offset.x = imgui.drag_float("X", + config.small_monster_UI.health_value_label.shadow.offset.x, 0.1, -screen_size.width, screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.small_monster_UI.health_value_label.shadow.offset.y = imgui.drag_float("Y", config.small_monster_UI.health_value_label.shadow.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.small_monster_UI.health_value_label.shadow.offset.y = imgui.drag_float("Y", + config.small_monster_UI.health_value_label.shadow.offset.y, 0.1, -screen_size.height, screen_size.height, "%.1f"); config_changed = config_changed or changed; imgui.tree_pop(); end - + imgui.tree_pop(); end @@ -1024,37 +1375,47 @@ customization_ui = function() end if imgui.tree_node("Health Percentage Label") then - changed, config.small_monster_UI.health_percentage_label.visibility = imgui.checkbox("Visible", config.small_monster_UI.health_percentage_label.visibility); + changed, config.small_monster_UI.health_percentage_label.visibility = imgui.checkbox("Visible", + config.small_monster_UI.health_percentage_label.visibility); config_changed = config_changed or changed; -- add text format if imgui.tree_node("Offset") then - changed, config.small_monster_UI.health_percentage_label.offset.x = imgui.drag_float("X", config.small_monster_UI.health_percentage_label.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.small_monster_UI.health_percentage_label.offset.x = + imgui.drag_float("X", config.small_monster_UI.health_percentage_label.offset.x, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.small_monster_UI.health_percentage_label.offset.y = imgui.drag_float("Y", config.small_monster_UI.health_percentage_label.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.small_monster_UI.health_percentage_label.offset.y = + imgui.drag_float("Y", config.small_monster_UI.health_percentage_label.offset.y, 0.1, -screen_size.height, + screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end - --color picker? + -- color picker? if imgui.tree_node("Shadow") then - changed, config.small_monster_UI.health_percentage_label.shadow.visibility = imgui.checkbox("Enable", config.small_monster_UI.health_percentage_label.shadow.visibility); + changed, config.small_monster_UI.health_percentage_label.shadow.visibility = imgui.checkbox("Enable", + config.small_monster_UI.health_percentage_label.shadow.visibility); config_changed = config_changed or changed; if imgui.tree_node("Offset") then - changed, config.small_monster_UI.health_percentage_label.shadow.offset.x = imgui.drag_float("X", config.small_monster_UI.health_percentage_label.shadow.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.small_monster_UI.health_percentage_label.shadow.offset.x = imgui.drag_float("X", + config.small_monster_UI.health_percentage_label.shadow.offset.x, 0.1, -screen_size.width, screen_size.width, + "%.1f"); config_changed = config_changed or changed; - changed, config.small_monster_UI.health_percentage_label.shadow.offset.y = imgui.drag_float("Y", config.small_monster_UI.health_percentage_label.shadow.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.small_monster_UI.health_percentage_label.shadow.offset.y = imgui.drag_float("Y", + config.small_monster_UI.health_percentage_label.shadow.offset.y, 0.1, -screen_size.height, screen_size.height, + "%.1f"); config_changed = config_changed or changed; imgui.tree_pop(); end - + imgui.tree_pop(); end @@ -1062,32 +1423,39 @@ customization_ui = function() end if imgui.tree_node("Health Bar") then - changed, config.small_monster_UI.health_bar.visibility = imgui.checkbox("Visible", config.small_monster_UI.health_bar.visibility); + changed, config.small_monster_UI.health_bar.visibility = imgui.checkbox("Visible", config.small_monster_UI.health_bar + .visibility); config_changed = config_changed or changed; if imgui.tree_node("Offset") then - changed, config.small_monster_UI.health_bar.offset.x = imgui.drag_float("X", config.small_monster_UI.health_bar.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.small_monster_UI.health_bar.offset.x = imgui.drag_float("X", config.small_monster_UI.health_bar + .offset.x, 0.1, -screen_size.width, screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.small_monster_UI.health_bar.offset.y = imgui.drag_float("Y", config.small_monster_UI.health_bar.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.small_monster_UI.health_bar.offset.y = imgui.drag_float("Y", config.small_monster_UI.health_bar + .offset.y, 0.1, -screen_size.height, screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end if imgui.tree_node("Size") then - changed, config.small_monster_UI.health_bar.size.width = imgui.drag_float("Width", config.small_monster_UI.health_bar.size.width, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.small_monster_UI.health_bar.size.width = + imgui.drag_float("Width", config.small_monster_UI.health_bar.size.width, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.small_monster_UI.health_bar.size.height = imgui.drag_float("Height", config.small_monster_UI.health_bar.size.height, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.small_monster_UI.health_bar.size.height = + imgui.drag_float("Height", config.small_monster_UI.health_bar.size.height, 0.1, -screen_size.height, + screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end if imgui.tree_node("Colors") then -- color pickers? - + imgui.tree_pop(); end @@ -1101,10 +1469,19 @@ customization_ui = function() changed, config.large_monster_UI.enabled = imgui.checkbox("Enabled", config.large_monster_UI.enabled); config_changed = config_changed or changed; - if imgui.tree_node("Settings") then - changed, config.large_monster_UI.settings.spacing = imgui.drag_float("Spacing", config.large_monster_UI.settings.spacing, 0.1, 0, screen_width, "%.1f"); + if imgui.tree_node("Spacing") then + changed, config.large_monster_UI.spacing.x = imgui.drag_float("X", + config.large_monster_UI.spacing.x, 0.1, 0, screen_size.width, "%.1f"); config_changed = config_changed or changed; + changed, config.large_monster_UI.spacing.y = imgui.drag_float("Y", + config.large_monster_UI.spacing.y, 0.1, 0, screen_size.width, "%.1f"); + config_changed = config_changed or changed; + + imgui.tree_pop(); + end + + if imgui.tree_node("Settings") then changed, monster_UI_orientation_index = imgui.combo("Orientation", monster_UI_orientation_index, orientation_types); config_changed = config_changed or changed; if changed then @@ -1115,16 +1492,19 @@ customization_ui = function() end if imgui.tree_node("Dynamic Positioning") then - changed, config.large_monster_UI.dynamic_positioning.enabled = imgui.checkbox("Enabled", config.large_monster_UI.dynamic_positioning.enabled); + changed, config.large_monster_UI.dynamic_positioning.enabled = + imgui.checkbox("Enabled", config.large_monster_UI.dynamic_positioning.enabled); config_changed = config_changed or changed; if imgui.tree_node("Viewport Offset") then - changed, config.large_monster_UI.dynamic_positioning.viewport_offset.x = imgui.drag_float("X", config.large_monster_UI.dynamic_positioning.viewport_offset.x, 0.1, 0, screen_width, "%.1f"); + changed, config.large_monster_UI.dynamic_positioning.viewport_offset.x = imgui.drag_float("X", + config.large_monster_UI.dynamic_positioning.viewport_offset.x, 0.1, 0, screen_size.width, "%.1f"); config_changed = config_changed or changed; - - changed, config.large_monster_UI.dynamic_positioning.viewport_offset.y = imgui.drag_float("Y", config.large_monster_UI.dynamic_positioning.viewport_offset.y, 0.1, 0, screen_height, "%.1f"); + + changed, config.large_monster_UI.dynamic_positioning.viewport_offset.y = imgui.drag_float("Y", + config.large_monster_UI.dynamic_positioning.viewport_offset.y, 0.1, 0, screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end @@ -1132,79 +1512,91 @@ customization_ui = function() end if imgui.tree_node("Position") then - changed, config.large_monster_UI.position.x = imgui.drag_float("X", config.large_monster_UI.position.x, 0.1, 0, screen_width, "%.1f"); + changed, config.large_monster_UI.position.x = imgui.drag_float("X", config.large_monster_UI.position.x, 0.1, 0, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.large_monster_UI.position.y = imgui.drag_float("Y", config.large_monster_UI.position.y, 0.1, 0, screen_height, "%.1f"); + changed, config.large_monster_UI.position.y = imgui.drag_float("Y", config.large_monster_UI.position.y, 0.1, 0, + screen_size.height, "%.1f"); config_changed = config_changed or changed; imgui.tree_pop(); end - + if imgui.tree_node("Sorting") then changed, monster_UI_sort_type_index = imgui.combo("Type", monster_UI_sort_type_index, monster_UI_sort_types); config_changed = config_changed or changed; if changed then config.large_monster_UI.sorting.type = monster_UI_sort_types[monster_UI_sort_type_index]; end - - changed, config.large_monster_UI.reversed_order = imgui.checkbox("Reversed Order", config.large_monster_UI.reversed_order); + + changed, config.large_monster_UI.sorting.reversed_order = imgui.checkbox("Reversed Order", + config.large_monster_UI.sorting.reversed_order); config_changed = config_changed or changed; imgui.tree_pop(); end if imgui.tree_node("Monster Name Label") then - changed, config.large_monster_UI.monster_name_label.visibility = imgui.checkbox("Visible", config.large_monster_UI.monster_name_label.visibility); + changed, config.large_monster_UI.monster_name_label.visibility = + imgui.checkbox("Visible", config.large_monster_UI.monster_name_label.visibility); config_changed = config_changed or changed; if imgui.tree_node("Include") then - changed, config.large_monster_UI.monster_name_label.include.monster_name = imgui.checkbox("Monster Name", config.large_monster_UI.monster_name_label.include.monster_name); + changed, config.large_monster_UI.monster_name_label.include.monster_name = + imgui.checkbox("Monster Name", config.large_monster_UI.monster_name_label.include.monster_name); config_changed = config_changed or changed; - changed, config.large_monster_UI.monster_name_label.include.crown = imgui.checkbox("Crown", config.large_monster_UI.monster_name_label.include.crown); + changed, config.large_monster_UI.monster_name_label.include.crown = + imgui.checkbox("Crown", config.large_monster_UI.monster_name_label.include.crown); config_changed = config_changed or changed; - changed, config.large_monster_UI.monster_name_label.include.size = imgui.checkbox("Size", config.large_monster_UI.monster_name_label.include.size); + changed, config.large_monster_UI.monster_name_label.include.size = + imgui.checkbox("Size", config.large_monster_UI.monster_name_label.include.size); config_changed = config_changed or changed; - changed, config.large_monster_UI.monster_name_label.include.silver_crown_threshold = imgui.checkbox("Silver Crown Threshold", config.large_monster_UI.monster_name_label.include.silver_crown_threshold); + changed, config.large_monster_UI.monster_name_label.include.scrown_thresholds = imgui.checkbox( + "Crown Thresholds", config.large_monster_UI.monster_name_label.include.scrown_thresholds); config_changed = config_changed or changed; - changed, config.large_monster_UI.monster_name_label.include.gold_crown_threshold = imgui.checkbox("Gold Crown Threshold", config.large_monster_UI.monster_name_label.include.gold_crown_threshold); - config_changed = config_changed or changed; - imgui.tree_pop(); end if imgui.tree_node("Offset") then - changed, config.large_monster_UI.monster_name_label.offset.x = imgui.drag_float("X", config.large_monster_UI.monster_name_label.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.large_monster_UI.monster_name_label.offset.x = + imgui.drag_float("X", config.large_monster_UI.monster_name_label.offset.x, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.large_monster_UI.monster_name_label.offset.y = imgui.drag_float("Y", config.large_monster_UI.monster_name_label.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.large_monster_UI.monster_name_label.offset.y = + imgui.drag_float("Y", config.large_monster_UI.monster_name_label.offset.y, 0.1, -screen_size.height, + screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end - --color picker? + -- color picker? if imgui.tree_node("Shadow") then - changed, config.large_monster_UI.monster_name_label.shadow.visibility = imgui.checkbox("Enable", config.large_monster_UI.monster_name_label.shadow.visibility); + changed, config.large_monster_UI.monster_name_label.shadow.visibility = imgui.checkbox("Enable", + config.large_monster_UI.monster_name_label.shadow.visibility); config_changed = config_changed or changed; if imgui.tree_node("Offset") then - changed, config.large_monster_UI.monster_name_label.shadow.offset.x = imgui.drag_float("X", config.large_monster_UI.monster_name_label.shadow.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.large_monster_UI.monster_name_label.shadow.offset.x = imgui.drag_float("X", + config.large_monster_UI.monster_name_label.shadow.offset.x, 0.1, -screen_size.width, screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.large_monster_UI.monster_name_label.shadow.offset.y = imgui.drag_float("Y", config.large_monster_UI.monster_name_label.shadow.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.large_monster_UI.monster_name_label.shadow.offset.y = imgui.drag_float("Y", + config.large_monster_UI.monster_name_label.shadow.offset.y, 0.1, -screen_size.height, screen_size.height, "%.1f"); config_changed = config_changed or changed; imgui.tree_pop(); end - --color picker - + -- color picker + imgui.tree_pop(); end @@ -1212,37 +1604,47 @@ customization_ui = function() end if imgui.tree_node("Health Label") then - changed, config.large_monster_UI.health_label.visibility = imgui.checkbox("Visible", config.large_monster_UI.health_label.visibility); + changed, config.large_monster_UI.health_label.visibility = + imgui.checkbox("Visible", config.large_monster_UI.health_label.visibility); config_changed = config_changed or changed; -- add text format if imgui.tree_node("Offset") then - changed, config.large_monster_UI.health_label.offset.x = imgui.drag_float("X", config.large_monster_UI.health_label.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.large_monster_UI.health_label.offset.x = + imgui.drag_float("X", config.large_monster_UI.health_label.offset.x, 0.1, -screen_size.width, screen_size.width, + "%.1f"); config_changed = config_changed or changed; - changed, config.large_monster_UI.health_label.offset.y = imgui.drag_float("Y", config.large_monster_UI.health_label.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.large_monster_UI.health_label.offset.y = + imgui.drag_float("Y", config.large_monster_UI.health_label.offset.y, 0.1, -screen_size.height, screen_size.height, + "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end - --color picker? + -- color picker? if imgui.tree_node("Shadow") then - changed, config.large_monster_UI.health_label.shadow.visibility = imgui.checkbox("Enable", config.large_monster_UI.health_label.shadow.visibility); + changed, config.large_monster_UI.health_label.shadow.visibility = + imgui.checkbox("Enable", config.large_monster_UI.health_label.shadow.visibility); config_changed = config_changed or changed; if imgui.tree_node("Offset") then - changed, config.large_monster_UI.health_label.shadow.offset.x = imgui.drag_float("X", config.large_monster_UI.health_label.shadow.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.large_monster_UI.health_label.shadow.offset.x = + imgui.drag_float("X", config.large_monster_UI.health_label.shadow.offset.x, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.large_monster_UI.health_label.shadow.offset.y = imgui.drag_float("Y", config.large_monster_UI.health_label.shadow.offset.y, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.large_monster_UI.health_label.shadow.offset.y = + imgui.drag_float("Y", config.large_monster_UI.health_label.shadow.offset.y, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; imgui.tree_pop(); end - + imgui.tree_pop(); end @@ -1250,37 +1652,45 @@ customization_ui = function() end if imgui.tree_node("Health Value Label") then - changed, config.large_monster_UI.health_value_label.visibility = imgui.checkbox("Visible", config.large_monster_UI.health_value_label.visibility); + changed, config.large_monster_UI.health_value_label.visibility = + imgui.checkbox("Visible", config.large_monster_UI.health_value_label.visibility); config_changed = config_changed or changed; -- add text format if imgui.tree_node("Offset") then - changed, config.large_monster_UI.health_value_label.offset.x = imgui.drag_float("X", config.large_monster_UI.health_value_label.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.large_monster_UI.health_value_label.offset.x = + imgui.drag_float("X", config.large_monster_UI.health_value_label.offset.x, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.large_monster_UI.health_value_label.offset.y = imgui.drag_float("Y", config.large_monster_UI.health_value_label.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.large_monster_UI.health_value_label.offset.y = + imgui.drag_float("Y", config.large_monster_UI.health_value_label.offset.y, 0.1, -screen_size.height, + screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end - --color picker? + -- color picker? if imgui.tree_node("Shadow") then - changed, config.large_monster_UI.health_value_label.shadow.visibility = imgui.checkbox("Enable", config.large_monster_UI.health_value_label.shadow.visibility); + changed, config.large_monster_UI.health_value_label.shadow.visibility = imgui.checkbox("Enable", + config.large_monster_UI.health_value_label.shadow.visibility); config_changed = config_changed or changed; if imgui.tree_node("Offset") then - changed, config.large_monster_UI.health_value_label.shadow.offset.x = imgui.drag_float("X", config.large_monster_UI.health_value_label.shadow.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.large_monster_UI.health_value_label.shadow.offset.x = imgui.drag_float("X", + config.large_monster_UI.health_value_label.shadow.offset.x, 0.1, -screen_size.width, screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.large_monster_UI.health_value_label.shadow.offset.y = imgui.drag_float("Y", config.large_monster_UI.health_value_label.shadow.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.large_monster_UI.health_value_label.shadow.offset.y = imgui.drag_float("Y", + config.large_monster_UI.health_value_label.shadow.offset.y, 0.1, -screen_size.height, screen_size.height, "%.1f"); config_changed = config_changed or changed; imgui.tree_pop(); end - + imgui.tree_pop(); end @@ -1288,37 +1698,47 @@ customization_ui = function() end if imgui.tree_node("Health Percentage Label") then - changed, config.large_monster_UI.health_percentage_label.visibility = imgui.checkbox("Visible", config.large_monster_UI.health_percentage_label.visibility); + changed, config.large_monster_UI.health_percentage_label.visibility = imgui.checkbox("Visible", + config.large_monster_UI.health_percentage_label.visibility); config_changed = config_changed or changed; -- add text format if imgui.tree_node("Offset") then - changed, config.large_monster_UI.health_percentage_label.offset.x = imgui.drag_float("X", config.large_monster_UI.health_percentage_label.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.large_monster_UI.health_percentage_label.offset.x = + imgui.drag_float("X", config.large_monster_UI.health_percentage_label.offset.x, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.large_monster_UI.health_percentage_label.offset.y = imgui.drag_float("Y", config.large_monster_UI.health_percentage_label.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.large_monster_UI.health_percentage_label.offset.y = + imgui.drag_float("Y", config.large_monster_UI.health_percentage_label.offset.y, 0.1, -screen_size.height, + screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end - --color picker? + -- color picker? if imgui.tree_node("Shadow") then - changed, config.large_monster_UI.health_percentage_label.shadow.visibility = imgui.checkbox("Enable", config.large_monster_UI.health_percentage_label.shadow.visibility); + changed, config.large_monster_UI.health_percentage_label.shadow.visibility = imgui.checkbox("Enable", + config.large_monster_UI.health_percentage_label.shadow.visibility); config_changed = config_changed or changed; if imgui.tree_node("Offset") then - changed, config.large_monster_UI.health_percentage_label.shadow.offset.x = imgui.drag_float("X", config.large_monster_UI.health_percentage_label.shadow.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.large_monster_UI.health_percentage_label.shadow.offset.x = imgui.drag_float("X", + config.large_monster_UI.health_percentage_label.shadow.offset.x, 0.1, -screen_size.width, screen_size.width, + "%.1f"); config_changed = config_changed or changed; - changed, config.large_monster_UI.health_percentage_label.shadow.offset.y = imgui.drag_float("Y", config.large_monster_UI.health_percentage_label.shadow.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.large_monster_UI.health_percentage_label.shadow.offset.y = imgui.drag_float("Y", + config.large_monster_UI.health_percentage_label.shadow.offset.y, 0.1, -screen_size.height, screen_size.height, + "%.1f"); config_changed = config_changed or changed; imgui.tree_pop(); end - + imgui.tree_pop(); end @@ -1326,32 +1746,37 @@ customization_ui = function() end if imgui.tree_node("Health Bar") then - changed, config.large_monster_UI.health_bar.visibility = imgui.checkbox("Visible", config.large_monster_UI.health_bar.visibility); + changed, config.large_monster_UI.health_bar.visibility = imgui.checkbox("Visible", config.large_monster_UI.health_bar + .visibility); config_changed = config_changed or changed; if imgui.tree_node("Offset") then - changed, config.large_monster_UI.health_bar.offset.x = imgui.drag_float("X", config.large_monster_UI.health_bar.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.large_monster_UI.health_bar.offset.x = imgui.drag_float("X", config.large_monster_UI.health_bar + .offset.x, 0.1, -screen_size.width, screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.large_monster_UI.health_bar.offset.y = imgui.drag_float("Y", config.large_monster_UI.health_bar.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.large_monster_UI.health_bar.offset.y = imgui.drag_float("Y", config.large_monster_UI.health_bar + .offset.y, 0.1, -screen_size.height, screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end if imgui.tree_node("Size") then - changed, config.large_monster_UI.health_bar.size.width = imgui.drag_float("Width", config.large_monster_UI.health_bar.size.width, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.large_monster_UI.health_bar.size.width = + imgui.drag_float("Width", config.large_monster_UI.health_bar.size.width, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.large_monster_UI.health_bar.size.height = imgui.drag_float("Height", config.large_monster_UI.health_bar.size.height, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.large_monster_UI.health_bar.size.height = + imgui.drag_float("Height", config.large_monster_UI.health_bar.size.height, 0.1, -screen_size.height, + screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end if imgui.tree_node("Colors") then - -- color pickers? - imgui.tree_pop(); end @@ -1366,16 +1791,17 @@ customization_ui = function() config_changed = config_changed or changed; if imgui.tree_node("Position") then - changed, config.time_UI.position.x = imgui.drag_float("X", config.time_UI.position.x, 0.1, 0, screen_width, "%.1f"); + changed, config.time_UI.position.x = imgui.drag_float("X", config.time_UI.position.x, 0.1, 0, screen_size.width, + "%.1f"); config_changed = config_changed or changed; - changed, config.time_UI.position.y = imgui.drag_float("Y", config.time_UI.position.y, 0.1, 0, screen_height, "%.1f"); + changed, config.time_UI.position.y = imgui.drag_float("Y", config.time_UI.position.y, 0.1, 0, screen_size.height, + "%.1f"); config_changed = config_changed or changed; imgui.tree_pop(); end - if imgui.tree_node("Time Label") then changed, config.time_UI.time_label.visibility = imgui.checkbox("Visible", config.time_UI.time_label.visibility); config_changed = config_changed or changed; @@ -1383,26 +1809,31 @@ customization_ui = function() -- add text format if imgui.tree_node("Offset") then - changed, config.time_UI.time_label.offset.x = imgui.drag_float("X", config.time_UI.time_label.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.time_UI.time_label.offset.x = imgui.drag_float("X", config.time_UI.time_label.offset.x, 0.1, + -screen_size.width, screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.time_UI.time_label.offset.y = imgui.drag_float("Y", config.time_UI.time_label.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.time_UI.time_label.offset.y = imgui.drag_float("Y", config.time_UI.time_label.offset.y, 0.1, + -screen_size.height, screen_size.height, "%.1f"); config_changed = config_changed or changed; imgui.tree_pop(); end - --color picker? + -- color picker? if imgui.tree_node("Shadow") then - changed, config.time_UI.time_label.shadow.visibility = imgui.checkbox("Enable", config.time_UI.time_label.shadow.visibility); + changed, config.time_UI.time_label.shadow.visibility = imgui.checkbox("Enable", + config.time_UI.time_label.shadow.visibility); config_changed = config_changed or changed; if imgui.tree_node("Offset") then - changed, config.time_UI.time_label.shadow.offset.x = imgui.drag_float("X", config.time_UI.time_label.shadow.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.time_UI.time_label.shadow.offset.x = imgui.drag_float("X", + config.time_UI.time_label.shadow.offset.x, 0.1, -screen_size.width, screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.time_UI.time_label.shadow.offset.y = imgui.drag_float("Y", config.time_UI.time_label.shadow.offset.y, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.time_UI.time_label.shadow.offset.y = imgui.drag_float("Y", + config.time_UI.time_label.shadow.offset.y, 0.1, -screen_size.width, screen_size.width, "%.1f"); config_changed = config_changed or changed; imgui.tree_pop(); @@ -1421,170 +1852,231 @@ customization_ui = function() config_changed = config_changed or changed; if imgui.tree_node("Settings") then - changed, config.damage_meter_UI.settings.hide_module_if_total_damage_is_zero = imgui.checkbox("Hide Module if Total Damage is 0", config.damage_meter_UI.settings.hide_module_if_total_damage_is_zero); + changed, config.damage_meter_UI.settings.hide_module_if_total_damage_is_zero = imgui.checkbox( + "Hide Module if Total Damage is 0", config.damage_meter_UI.settings.hide_module_if_total_damage_is_zero); config_changed = config_changed or changed; - changed, config.damage_meter_UI.settings.hide_player_if_player_damage_is_zero = imgui.checkbox("Hide Player if Player Damage is 0", config.damage_meter_UI.settings.hide_player_if_player_damage_is_zero); + changed, config.damage_meter_UI.settings.hide_player_if_player_damage_is_zero = imgui.checkbox( + "Hide Player if Player Damage is 0", config.damage_meter_UI.settings.hide_player_if_player_damage_is_zero); config_changed = config_changed or changed; - changed, config.damage_meter_UI.settings.total_damage_offset_is_relative = imgui.checkbox("Total Damage Offset is Relative", config.damage_meter_UI.settings.total_damage_offset_is_relative); + changed, config.damage_meter_UI.settings.total_damage_offset_is_relative = imgui.checkbox( + "Total Damage Offset is Relative", config.damage_meter_UI.settings.total_damage_offset_is_relative); config_changed = config_changed or changed; - changed, config.damage_meter_UI.settings.spacing = imgui.drag_float("Spacing", config.damage_meter_UI.settings.spacing, 0.1, 0, screen_width, "%.1f"); - config_changed = config_changed or changed; - - changed, damage_meter_UI_orientation_index = imgui.combo("Orientation", damage_meter_UI_orientation_index, orientation_types); + changed, damage_meter_UI_orientation_index = imgui.combo("Orientation", damage_meter_UI_orientation_index, + orientation_types); config_changed = config_changed or changed; if changed then config.damage_meter_UI.settings.orientation = orientation_types[damage_meter_UI_orientation_index]; end - changed, damage_meter_UI_highlighted_bar_index = imgui.combo("Highlighted Bar", damage_meter_UI_highlighted_bar_index, damage_meter_UI_highlighted_bar_types); + changed, damage_meter_UI_highlighted_bar_index = imgui.combo("Highlighted Bar", + damage_meter_UI_highlighted_bar_index, damage_meter_UI_highlighted_bar_types); config_changed = config_changed or changed; if changed then - config.damage_meter_UI.settings.highlighted_bar = damage_meter_UI_highlighted_bar_types[damage_meter_UI_highlighted_bar_index]; + config.damage_meter_UI.settings.highlighted_bar = + damage_meter_UI_highlighted_bar_types[damage_meter_UI_highlighted_bar_index]; end - changed, damage_meter_UI_damage_bar_relative_index = imgui.combo("Damage Bars are Relative to", damage_meter_UI_damage_bar_relative_index, damage_meter_UI_damage_bar_relative_types); + changed, damage_meter_UI_damage_bar_relative_index = imgui.combo("Damage Bars are Relative to", + damage_meter_UI_damage_bar_relative_index, damage_meter_UI_damage_bar_relative_types); config_changed = config_changed or changed; if changed then - config.damage_meter_UI.settings.damage_bar_relative_to = damage_meter_UI_damage_bar_relative_types[damage_meter_UI_damage_bar_relative_index]; + config.damage_meter_UI.settings.damage_bar_relative_to = + damage_meter_UI_damage_bar_relative_types[damage_meter_UI_damage_bar_relative_index]; end - changed, damage_meter_UI_my_damage_bar_location_index = imgui.combo("My Damage Bar Location", damage_meter_UI_my_damage_bar_location_index, damage_meter_UI_my_damage_bar_location_types); + changed, damage_meter_UI_my_damage_bar_location_index = imgui.combo("My Damage Bar Location", + damage_meter_UI_my_damage_bar_location_index, damage_meter_UI_my_damage_bar_location_types); config_changed = config_changed or changed; if changed then - config.damage_meter_UI.settings.my_damage_bar_location = damage_meter_UI_my_damage_bar_location_types[damage_meter_UI_my_damage_bar_location_index]; + config.damage_meter_UI.settings.my_damage_bar_location = + damage_meter_UI_my_damage_bar_location_types[damage_meter_UI_my_damage_bar_location_index]; end imgui.tree_pop(); end if imgui.tree_node("Tracked Monster Types") then - changed, config.damage_meter_UI.tracked_monster_types.small_monsters = imgui.checkbox("Small Monsters", config.damage_meter_UI.tracked_monster_types.small_monsters); + changed, config.damage_meter_UI.tracked_monster_types.small_monsters = + imgui.checkbox("Small Monsters", config.damage_meter_UI.tracked_monster_types.small_monsters); config_changed = config_changed or changed; - changed, config.damage_meter_UI.tracked_monster_types.large_monsters = imgui.checkbox("Large Monsters", config.damage_meter_UI.tracked_monster_types.large_monsters); + changed, config.damage_meter_UI.tracked_monster_types.large_monsters = + imgui.checkbox("Large Monsters", config.damage_meter_UI.tracked_monster_types.large_monsters); config_changed = config_changed or changed; imgui.tree_pop(); end if imgui.tree_node("Tracked Damage Types") then - changed, config.damage_meter_UI.tracked_damage_types.player_damage = imgui.checkbox("Player Damage", config.damage_meter_UI.tracked_damage_types.player_damage); + local tracked_damage_changed = false; + changed, config.damage_meter_UI.tracked_damage_types.player_damage = + imgui.checkbox("Player Damage", config.damage_meter_UI.tracked_damage_types.player_damage); + config_changed = config_changed or changed; + tracked_damage_changed = tracked_damage_changed or changed; + + changed, config.damage_meter_UI.tracked_damage_types.bomb_damage = imgui.checkbox("Bomb Damage", + config.damage_meter_UI.tracked_damage_types.bomb_damage); + config_changed = config_changed or changed; + tracked_damage_changed = tracked_damage_changed or changed; + + changed, config.damage_meter_UI.tracked_damage_types.kunai_damage = + imgui.checkbox("Kunai Damage", config.damage_meter_UI.tracked_damage_types.kunai_damage); + config_changed = config_changed or changed; + tracked_damage_changed = tracked_damage_changed or changed; + + changed, config.damage_meter_UI.tracked_damage_types.installation_damage = + imgui.checkbox("Installation Damage", config.damage_meter_UI.tracked_damage_types.installation_damage); + config_changed = config_changed or changed; + tracked_damage_changed = tracked_damage_changed or changed; + + changed, config.damage_meter_UI.tracked_damage_types.otomo_damage = + imgui.checkbox("Otomo Damage", config.damage_meter_UI.tracked_damage_types.otomo_damage); + config_changed = config_changed or changed; + tracked_damage_changed = tracked_damage_changed or changed; + + changed, config.damage_meter_UI.tracked_damage_types.monster_damage = + imgui.checkbox("Monster Damage", config.damage_meter_UI.tracked_damage_types.monster_damage); + config_changed = config_changed or changed; + tracked_damage_changed = tracked_damage_changed or changed; + + if tracked_damage_changed then + for player_id, player in pairs(players) do + update_player_display(player); + end + update_player_display(total); + end + + imgui.tree_pop(); + end + + if imgui.tree_node("Spacing") then + changed, config.damage_meter_UI.spacing.x = imgui.drag_float("X", + config.damage_meter_UI.spacing.x, 0.1, 0, screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.damage_meter_UI.tracked_damage_types.bomb_damage = imgui.checkbox("Bomb Damage", config.damage_meter_UI.tracked_damage_types.bomb_damage); - config_changed = config_changed or changed; - - changed, config.damage_meter_UI.tracked_damage_types.kunai_damage = imgui.checkbox("Kunai Damage", config.damage_meter_UI.tracked_damage_types.kunai_damage); - config_changed = config_changed or changed; - - changed, config.damage_meter_UI.tracked_damage_types.installation_damage = imgui.checkbox("Installation Damage", config.damage_meter_UI.tracked_damage_types.installation_damage); - config_changed = config_changed or changed; - - changed, config.damage_meter_UI.tracked_damage_types.otomo_damage = imgui.checkbox("Otomo Damage", config.damage_meter_UI.tracked_damage_types.otomo_damage); - config_changed = config_changed or changed; - - changed, config.damage_meter_UI.tracked_damage_types.monster_damage = imgui.checkbox("Monster Damage", config.damage_meter_UI.tracked_damage_types.monster_damage); + changed, config.damage_meter_UI.spacing.y = imgui.drag_float("Y", + config.damage_meter_UI.spacing.y, 0.1, 0, screen_size.width, "%.1f"); config_changed = config_changed or changed; imgui.tree_pop(); end if imgui.tree_node("Position") then - changed, config.damage_meter_UI.position.x = imgui.drag_float("X", config.damage_meter_UI.position.x, 0.1, 0, screen_width, "%.1f"); + changed, config.damage_meter_UI.position.x = imgui.drag_float("X", config.damage_meter_UI.position.x, 0.1, 0, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.damage_meter_UI.position.y = imgui.drag_float("Y", config.damage_meter_UI.position.y, 0.1, 0, screen_height, "%.1f"); + changed, config.damage_meter_UI.position.y = imgui.drag_float("Y", config.damage_meter_UI.position.y, 0.1, 0, + screen_size.height, "%.1f"); config_changed = config_changed or changed; imgui.tree_pop(); end - + if imgui.tree_node("Sorting") then - changed, damage_meter_UI_sort_type_index = imgui.combo("Type", damage_meter_UI_sort_type_index, damage_meter_UI_sort_types); + changed, damage_meter_UI_sort_type_index = imgui.combo("Type", damage_meter_UI_sort_type_index, + damage_meter_UI_sort_types); config_changed = config_changed or changed; if changed then config.damage_meter_UI.sorting.type = damage_meter_UI_sort_types[damage_meter_UI_sort_type_index]; end - - changed, config.damage_meter_UI.reversed_order = imgui.checkbox("Reversed Order", config.damage_meter_UI.reversed_order); + + changed, config.damage_meter_UI.sorting.reversed_order = imgui.checkbox("Reversed Order", + config.damage_meter_UI.sorting.reversed_order); config_changed = config_changed or changed; imgui.tree_pop(); end if imgui.tree_node("Player Name Label") then - changed, config.damage_meter_UI.player_name_label.visibility = imgui.checkbox("Visible", config.damage_meter_UI.player_name_label.visibility); + changed, config.damage_meter_UI.player_name_label.visibility = + imgui.checkbox("Visible", config.damage_meter_UI.player_name_label.visibility); config_changed = config_changed or changed; if imgui.tree_node("Include") then if imgui.tree_node("Me") then - changed, config.damage_meter_UI.player_name_label.include.myself.hunter_rank = imgui.checkbox("Hunter Rank", config.damage_meter_UI.player_name_label.include.myself.hunter_rank); + changed, config.damage_meter_UI.player_name_label.include.myself.hunter_rank = imgui.checkbox("Hunter Rank", + config.damage_meter_UI.player_name_label.include.myself.hunter_rank); config_changed = config_changed or changed; - - changed, config.damage_meter_UI.player_name_label.include.myself.word_player = imgui.checkbox("Word \"Player\"", config.damage_meter_UI.player_name_label.include.myself.word_player); + + changed, config.damage_meter_UI.player_name_label.include.myself.word_player = + imgui.checkbox("Word \"Player\"", config.damage_meter_UI.player_name_label.include.myself.word_player); config_changed = config_changed or changed; - - changed, config.damage_meter_UI.player_name_label.include.myself.player_id = imgui.checkbox("Player ID", config.damage_meter_UI.player_name_label.include.myself.player_id); + + changed, config.damage_meter_UI.player_name_label.include.myself.player_id = imgui.checkbox("Player ID", + config.damage_meter_UI.player_name_label.include.myself.player_id); config_changed = config_changed or changed; - - changed, config.damage_meter_UI.player_name_label.include.myself.player_name = imgui.checkbox("Player Name", config.damage_meter_UI.player_name_label.include.myself.player_name); + + changed, config.damage_meter_UI.player_name_label.include.myself.player_name = imgui.checkbox("Player Name", + config.damage_meter_UI.player_name_label.include.myself.player_name); config_changed = config_changed or changed; - + imgui.tree_pop(); end if imgui.tree_node("Other Players") then - changed, config.damage_meter_UI.player_name_label.include.others.hunter_rank = imgui.checkbox("Hunter Rank", config.damage_meter_UI.player_name_label.include.others.hunter_rank); + changed, config.damage_meter_UI.player_name_label.include.others.hunter_rank = imgui.checkbox("Hunter Rank", + config.damage_meter_UI.player_name_label.include.others.hunter_rank); config_changed = config_changed or changed; - - changed, config.damage_meter_UI.player_name_label.include.others.word_player = imgui.checkbox("Word \"Player\"", config.damage_meter_UI.player_name_label.include.others.word_player); + + changed, config.damage_meter_UI.player_name_label.include.others.word_player = + imgui.checkbox("Word \"Player\"", config.damage_meter_UI.player_name_label.include.others.word_player); config_changed = config_changed or changed; - - changed, config.damage_meter_UI.player_name_label.include.others.player_id = imgui.checkbox("Player ID", config.damage_meter_UI.player_name_label.include.others.player_id); + + changed, config.damage_meter_UI.player_name_label.include.others.player_id = imgui.checkbox("Player ID", + config.damage_meter_UI.player_name_label.include.others.player_id); config_changed = config_changed or changed; - - changed, config.damage_meter_UI.player_name_label.include.others.player_name = imgui.checkbox("Player Name", config.damage_meter_UI.player_name_label.include.others.player_name); + + changed, config.damage_meter_UI.player_name_label.include.others.player_name = imgui.checkbox("Player Name", + config.damage_meter_UI.player_name_label.include.others.player_name); config_changed = config_changed or changed; - + imgui.tree_pop(); end - + imgui.tree_pop(); end - - if imgui.tree_node("Offset") then - changed, config.damage_meter_UI.player_name_label.offset.x = imgui.drag_float("X", config.damage_meter_UI.player_name_label.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.damage_meter_UI.player_name_label.offset.x = + imgui.drag_float("X", config.damage_meter_UI.player_name_label.offset.x, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.damage_meter_UI.player_name_label.offset.y = imgui.drag_float("Y", config.damage_meter_UI.player_name_label.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.damage_meter_UI.player_name_label.offset.y = + imgui.drag_float("Y", config.damage_meter_UI.player_name_label.offset.y, 0.1, -screen_size.height, + screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end - --color picker? + -- color picker? if imgui.tree_node("Shadow") then - changed, config.damage_meter_UI.player_name_label.shadow.visibility = imgui.checkbox("Enable", config.damage_meter_UI.player_name_label.shadow.visibility); + changed, config.damage_meter_UI.player_name_label.shadow.visibility = imgui.checkbox("Enable", + config.damage_meter_UI.player_name_label.shadow.visibility); config_changed = config_changed or changed; if imgui.tree_node("Offset") then - changed, config.damage_meter_UI.player_name_label.shadow.offset.x = imgui.drag_float("X", config.damage_meter_UI.player_name_label.shadow.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.damage_meter_UI.player_name_label.shadow.offset.x = + imgui.drag_float("X", config.damage_meter_UI.player_name_label.shadow.offset.x, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.damage_meter_UI.player_name_label.shadow.offset.y = imgui.drag_float("Y", config.damage_meter_UI.player_name_label.shadow.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.damage_meter_UI.player_name_label.shadow.offset.y = + imgui.drag_float("Y", config.damage_meter_UI.player_name_label.shadow.offset.y, 0.1, -screen_size.height, + screen_size.height, "%.1f"); config_changed = config_changed or changed; imgui.tree_pop(); end - --color picker - + -- color picker + imgui.tree_pop(); end @@ -1592,37 +2084,47 @@ customization_ui = function() end if imgui.tree_node("Damage Value Label") then - changed, config.damage_meter_UI.damage_value_label.visibility = imgui.checkbox("Visible", config.damage_meter_UI.damage_value_label.visibility); + changed, config.damage_meter_UI.damage_value_label.visibility = + imgui.checkbox("Visible", config.damage_meter_UI.damage_value_label.visibility); config_changed = config_changed or changed; -- add text format if imgui.tree_node("Offset") then - changed, config.damage_meter_UI.damage_value_label.offset.x = imgui.drag_float("X", config.damage_meter_UI.damage_value_label.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.damage_meter_UI.damage_value_label.offset.x = + imgui.drag_float("X", config.damage_meter_UI.damage_value_label.offset.x, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.damage_meter_UI.damage_value_label.offset.y = imgui.drag_float("Y", config.damage_meter_UI.damage_value_label.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.damage_meter_UI.damage_value_label.offset.y = + imgui.drag_float("Y", config.damage_meter_UI.damage_value_label.offset.y, 0.1, -screen_size.height, + screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end - --color picker? + -- color picker? if imgui.tree_node("Shadow") then - changed, config.damage_meter_UI.damage_value_label.shadow.visibility = imgui.checkbox("Enable", config.damage_meter_UI.damage_value_label.shadow.visibility); + changed, config.damage_meter_UI.damage_value_label.shadow.visibility = imgui.checkbox("Enable", + config.damage_meter_UI.damage_value_label.shadow.visibility); config_changed = config_changed or changed; if imgui.tree_node("Offset") then - changed, config.damage_meter_UI.damage_value_label.shadow.offset.x = imgui.drag_float("X", config.damage_meter_UI.damage_value_label.shadow.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.damage_meter_UI.damage_value_label.shadow.offset.x = + imgui.drag_float("X", config.damage_meter_UI.damage_value_label.shadow.offset.x, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.damage_meter_UI.damage_value_label.shadow.offset.y = imgui.drag_float("Y", config.damage_meter_UI.damage_value_label.shadow.offset.y, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.damage_meter_UI.damage_value_label.shadow.offset.y = + imgui.drag_float("Y", config.damage_meter_UI.damage_value_label.shadow.offset.y, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; imgui.tree_pop(); end - + imgui.tree_pop(); end @@ -1630,37 +2132,46 @@ customization_ui = function() end if imgui.tree_node("Damage Percentage Label") then - changed, config.damage_meter_UI.damage_percentage_label.visibility = imgui.checkbox("Visible", config.damage_meter_UI.damage_percentage_label.visibility); + changed, config.damage_meter_UI.damage_percentage_label.visibility = + imgui.checkbox("Visible", config.damage_meter_UI.damage_percentage_label.visibility); config_changed = config_changed or changed; -- add text format if imgui.tree_node("Offset") then - changed, config.damage_meter_UI.damage_percentage_label.offset.x = imgui.drag_float("X", config.damage_meter_UI.damage_percentage_label.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.damage_meter_UI.damage_percentage_label.offset.x = + imgui.drag_float("X", config.damage_meter_UI.damage_percentage_label.offset.x, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.damage_meter_UI.damage_percentage_label.offset.y = imgui.drag_float("Y", config.damage_meter_UI.damage_percentage_label.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.damage_meter_UI.damage_percentage_label.offset.y = + imgui.drag_float("Y", config.damage_meter_UI.damage_percentage_label.offset.y, 0.1, -screen_size.height, + screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end - --color picker? + -- color picker? if imgui.tree_node("Shadow") then - changed, config.damage_meter_UI.damage_percentage_label.shadow.visibility = imgui.checkbox("Enable", config.damage_meter_UI.damage_percentage_label.shadow.visibility); + changed, config.damage_meter_UI.damage_percentage_label.shadow.visibility = imgui.checkbox("Enable", + config.damage_meter_UI.damage_percentage_label.shadow.visibility); config_changed = config_changed or changed; if imgui.tree_node("Offset") then - changed, config.damage_meter_UI.damage_percentage_label.shadow.offset.x = imgui.drag_float("X", config.damage_meter_UI.damage_percentage_label.shadow.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.damage_meter_UI.damage_percentage_label.shadow.offset.x = imgui.drag_float("X", + config.damage_meter_UI.damage_percentage_label.shadow.offset.x, 0.1, -screen_size.width, screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.damage_meter_UI.damage_percentage_label.shadow.offset.y = imgui.drag_float("Y", config.damage_meter_UI.damage_percentage_label.shadow.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.damage_meter_UI.damage_percentage_label.shadow.offset.y = imgui.drag_float("Y", + config.damage_meter_UI.damage_percentage_label.shadow.offset.y, 0.1, -screen_size.height, screen_size.height, + "%.1f"); config_changed = config_changed or changed; imgui.tree_pop(); end - + imgui.tree_pop(); end @@ -1668,37 +2179,47 @@ customization_ui = function() end if imgui.tree_node("Total Damage Label") then - changed, config.damage_meter_UI.total_damage_label.visibility = imgui.checkbox("Visible", config.damage_meter_UI.total_damage_label.visibility); + changed, config.damage_meter_UI.total_damage_label.visibility = + imgui.checkbox("Visible", config.damage_meter_UI.total_damage_label.visibility); config_changed = config_changed or changed; -- add text format if imgui.tree_node("Offset") then - changed, config.damage_meter_UI.total_damage_label.offset.x = imgui.drag_float("X", config.damage_meter_UI.total_damage_label.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.damage_meter_UI.total_damage_label.offset.x = + imgui.drag_float("X", config.damage_meter_UI.total_damage_label.offset.x, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.damage_meter_UI.total_damage_label.offset.y = imgui.drag_float("Y", config.damage_meter_UI.total_damage_label.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.damage_meter_UI.total_damage_label.offset.y = + imgui.drag_float("Y", config.damage_meter_UI.total_damage_label.offset.y, 0.1, -screen_size.height, + screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end - --color picker? + -- color picker? if imgui.tree_node("Shadow") then - changed, config.damage_meter_UI.total_damage_label.shadow.visibility = imgui.checkbox("Enable", config.damage_meter_UI.total_damage_label.shadow.visibility); + changed, config.damage_meter_UI.total_damage_label.shadow.visibility = imgui.checkbox("Enable", + config.damage_meter_UI.total_damage_label.shadow.visibility); config_changed = config_changed or changed; if imgui.tree_node("Offset") then - changed, config.damage_meter_UI.total_damage_label.shadow.offset.x = imgui.drag_float("X", config.damage_meter_UI.total_damage_label.shadow.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.damage_meter_UI.total_damage_label.shadow.offset.x = + imgui.drag_float("X", config.damage_meter_UI.total_damage_label.shadow.offset.x, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.damage_meter_UI.total_damage_label.shadow.offset.y = imgui.drag_float("Y", config.damage_meter_UI.total_damage_label.shadow.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.damage_meter_UI.total_damage_label.shadow.offset.y = + imgui.drag_float("Y", config.damage_meter_UI.total_damage_label.shadow.offset.y, 0.1, -screen_size.height, + screen_size.height, "%.1f"); config_changed = config_changed or changed; imgui.tree_pop(); end - + imgui.tree_pop(); end @@ -1706,37 +2227,47 @@ customization_ui = function() end if imgui.tree_node("Total Damage Value Label") then - changed, config.damage_meter_UI.total_damage_value_label.visibility = imgui.checkbox("Visible", config.damage_meter_UI.total_damage_value_label.visibility); + changed, config.damage_meter_UI.total_damage_value_label.visibility = imgui.checkbox("Visible", + config.damage_meter_UI.total_damage_value_label.visibility); config_changed = config_changed or changed; -- add text format if imgui.tree_node("Offset") then - changed, config.damage_meter_UI.total_damage_value_label.offset.x = imgui.drag_float("X", config.damage_meter_UI.total_damage_value_label.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.damage_meter_UI.total_damage_value_label.offset.x = + imgui.drag_float("X", config.damage_meter_UI.total_damage_value_label.offset.x, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.damage_meter_UI.total_damage_value_label.offset.y = imgui.drag_float("Y", config.damage_meter_UI.total_damage_value_label.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.damage_meter_UI.total_damage_value_label.offset.y = + imgui.drag_float("Y", config.damage_meter_UI.total_damage_value_label.offset.y, 0.1, -screen_size.height, + screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end - --color picker? + -- color picker? if imgui.tree_node("Shadow") then - changed, config.damage_meter_UI.total_damage_value_label.shadow.visibility = imgui.checkbox("Enable", config.damage_meter_UI.total_damage_value_label.shadow.visibility); + changed, config.damage_meter_UI.total_damage_value_label.shadow.visibility = imgui.checkbox("Enable", + config.damage_meter_UI.total_damage_value_label.shadow.visibility); config_changed = config_changed or changed; if imgui.tree_node("Offset") then - changed, config.damage_meter_UI.total_damage_value_label.shadow.offset.x = imgui.drag_float("X", config.damage_meter_UI.total_damage_value_label.shadow.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.damage_meter_UI.total_damage_value_label.shadow.offset.x = imgui.drag_float("X", + config.damage_meter_UI.total_damage_value_label.shadow.offset.x, 0.1, -screen_size.width, screen_size.width, + "%.1f"); config_changed = config_changed or changed; - changed, config.damage_meter_UI.total_damage_value_label.shadow.offset.y = imgui.drag_float("Y", config.damage_meter_UI.total_damage_value_label.shadow.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.damage_meter_UI.total_damage_value_label.shadow.offset.y = imgui.drag_float("Y", + config.damage_meter_UI.total_damage_value_label.shadow.offset.y, 0.1, -screen_size.height, screen_size.height, + "%.1f"); config_changed = config_changed or changed; imgui.tree_pop(); end - + imgui.tree_pop(); end @@ -1744,32 +2275,38 @@ customization_ui = function() end if imgui.tree_node("Damage Bar") then - changed, config.damage_meter_UI.damage_bar.visibility = imgui.checkbox("Visible", config.damage_meter_UI.damage_bar.visibility); + changed, config.damage_meter_UI.damage_bar.visibility = imgui.checkbox("Visible", + config.damage_meter_UI.damage_bar.visibility); config_changed = config_changed or changed; if imgui.tree_node("Offset") then - changed, config.damage_meter_UI.damage_bar.offset.x = imgui.drag_float("X", config.damage_meter_UI.damage_bar.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.damage_meter_UI.damage_bar.offset.x = imgui.drag_float("X", + config.damage_meter_UI.damage_bar.offset.x, 0.1, -screen_size.width, screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.damage_meter_UI.damage_bar.offset.y = imgui.drag_float("Y", config.damage_meter_UI.damage_bar.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.damage_meter_UI.damage_bar.offset.y = imgui.drag_float("Y", + config.damage_meter_UI.damage_bar.offset.y, 0.1, -screen_size.height, screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end if imgui.tree_node("Size") then - changed, config.damage_meter_UI.damage_bar.size.width = imgui.drag_float("Width", config.damage_meter_UI.damage_bar.size.width, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.damage_meter_UI.damage_bar.size.width = imgui.drag_float("Width", config.damage_meter_UI.damage_bar + .size.width, 0.1, -screen_size.width, screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.damage_meter_UI.damage_bar.size.height = imgui.drag_float("Height", config.damage_meter_UI.damage_bar.size.height, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.damage_meter_UI.damage_bar.size.height = + imgui.drag_float("Height", config.damage_meter_UI.damage_bar.size.height, 0.1, -screen_size.height, + screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end if imgui.tree_node("Colors") then -- color pickers? - + imgui.tree_pop(); end @@ -1777,32 +2314,40 @@ customization_ui = function() end if imgui.tree_node("Highlighted Damage Bar") then - changed, config.damage_meter_UI.highlighted_damage_bar.visibility = imgui.checkbox("Visible", config.damage_meter_UI.highlighted_damage_bar.visibility); + changed, config.damage_meter_UI.highlighted_damage_bar.visibility = + imgui.checkbox("Visible", config.damage_meter_UI.highlighted_damage_bar.visibility); config_changed = config_changed or changed; if imgui.tree_node("Offset") then - changed, config.damage_meter_UI.highlighted_damage_bar.offset.x = imgui.drag_float("X", config.damage_meter_UI.highlighted_damage_bar.offset.x, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.damage_meter_UI.highlighted_damage_bar.offset.x = + imgui.drag_float("X", config.damage_meter_UI.highlighted_damage_bar.offset.x, 0.1, -screen_size.width, + screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.damage_meter_UI.highlighted_damage_bar.offset.y = imgui.drag_float("Y", config.damage_meter_UI.highlighted_damage_bar.offset.y, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.damage_meter_UI.highlighted_damage_bar.offset.y = + imgui.drag_float("Y", config.damage_meter_UI.highlighted_damage_bar.offset.y, 0.1, -screen_size.height, + screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end if imgui.tree_node("Size") then - changed, config.damage_meter_UI.damage_bar.size.width = imgui.drag_float("Width", config.damage_meter_UI.damage_bar.size.width, 0.1, -screen_width, screen_width, "%.1f"); + changed, config.damage_meter_UI.highlighted_damage_bar.size.width = imgui.drag_float("Width", config.damage_meter_UI.highlighted_damage_bar + .size.width, 0.1, -screen_size.width, screen_size.width, "%.1f"); config_changed = config_changed or changed; - changed, config.damage_meter_UI.damage_bar.size.height = imgui.drag_float("Height", config.damage_meter_UI.damage_bar.size.height, 0.1, -screen_height, screen_height, "%.1f"); + changed, config.damage_meter_UI.highlighted_damage_bar.size.height = + imgui.drag_float("Height", config.damage_meter_UI.highlighted_damage_bar.size.height, 0.1, -screen_size.height, + screen_size.height, "%.1f"); config_changed = config_changed or changed; - + imgui.tree_pop(); end if imgui.tree_node("Colors") then -- color pickers? - + imgui.tree_pop(); end @@ -1818,95 +2363,11 @@ customization_ui = function() save_config(); end end ---#endregion +-- #endregion ----------------------CUSTOMIZATION UI----------------------- - - - - ----------------------------GLOBAL---------------------------- ---#region -re.on_draw_ui(function() - if imgui.button('MHR Overlay') then - is_customization_window_opened = not is_customization_window_opened; - end -end); - -re.on_frame(function() - if is_customization_window_opened then - customization_ui(); - end - - --monster_health(); -end); - -get_window_size = function () - local size = scene_view:call("get_Size"); - if size == nil then - log.error("[MHR Overlay] No scene view size"); - return - end - - screen_width = size:get_field("w"); - if screen_width == nil then - log.error("[MHR Overlay] No screen width"); - return - end - - screen_height = size:get_field("h"); - if screen_height == nil then - log.error("[MHR Overlay] No screen height"); - return - end -end - -calculate_screen_coordinates = function (position) - if position.anchor == "Top-Left" then - return {x = position.x, y = position.y}; - end - - if position.anchor == "Top-Right" then - local screen_x = screen_width - position.x; - return {x = screen_x, y = position.y}; - end - - if position.anchor == "Bottom-Left" then - local screen_y = screen_height - position.y; - return {x = position.x, y = screen_y}; - end - - if position.anchor == "Bottom-Right" then - local screen_x = screen_width - position.x; - local screen_y = screen_height - position.y; - return {x = screen_x, y = screen_y}; - end - - return {x = position.x, y = position.y}; -end - -table_find_index = function (table, value, nullable) - for i = 1, #table do - if table[i] == value then - return i; - end - end - - if not nullable then - return 1; - end - - return nil; -end ---#endregion ----------------------------GLOBAL---------------------------- - - - - - ------------------------DRAW HELPERS------------------------- ---#region +-- #region draw_label = function(label, position, ...) if label == nil then return; @@ -1915,15 +2376,16 @@ draw_label = function(label, position, ...) if not label.visibility then return; end - + local text = string.format(label.text, table.unpack({...})); if label.shadow.visibility then - d2d.text(font, text, position.x + label.offset.x + label.shadow.offset.x, position.y + label.offset.y + label.shadow.offset.y, label.shadow.color); + d2d.text(font, text, position.x + label.offset.x + label.shadow.offset.x, + position.y + label.offset.y + label.shadow.offset.y, label.shadow.color); end d2d.text(font, text, position.x + label.offset.x, position.y + label.offset.y, label.color); end -draw_bar = function (bar, position, percentage) +draw_bar = function(bar, position, percentage) if bar == nil then return; end @@ -1935,11 +2397,13 @@ draw_bar = function (bar, position, percentage) local foreground_width = bar.size.width * percentage; local background_width = bar.size.width - foreground_width; - --foreground - d2d.fill_rect(position.x + bar.offset.x, position.y + bar.offset.y, foreground_width, bar.size.height, bar.colors.foreground); + -- foreground + d2d.fill_rect(position.x + bar.offset.x, position.y + bar.offset.y, foreground_width, bar.size.height, + bar.colors.foreground); - --background - d2d.fill_rect(position.x + foreground_width + bar.offset.x, position.y + bar.offset.y, background_width, bar.size.height, bar.colors.background); + -- background + d2d.fill_rect(position.x + foreground_width + bar.offset.x, position.y + bar.offset.y, background_width, + bar.size.height, bar.colors.background); end old_draw_label = function(label, position, ...) @@ -1953,12 +2417,13 @@ old_draw_label = function(label, position, ...) local text = string.format(label.text, table.unpack({...})); if label.shadow.visibility then - draw.text(text, position.x + label.offset.x + label.shadow.offset.x, position.y + label.offset.y + label.shadow.offset.y, label.shadow.color); + draw.text(text, position.x + label.offset.x + label.shadow.offset.x, + position.y + label.offset.y + label.shadow.offset.y, label.shadow.color); end draw.text(text, position.x + label.offset.x, position.y + label.offset.y, label.color); end -old_draw_bar = function (bar, position, percentage) +old_draw_bar = function(bar, position, percentage) if bar == nil then return; end @@ -1970,48 +2435,130 @@ old_draw_bar = function (bar, position, percentage) local foreground_width = bar.size.width * percentage; local background_width = bar.size.width - foreground_width; - --foreground - draw.filled_rect(position.x + bar.offset.x, position.y + bar.offset.y, foreground_width, bar.size.height, bar.colors.foreground); + -- foreground + draw.filled_rect(position.x + bar.offset.x, position.y + bar.offset.y, foreground_width, bar.size.height, + bar.colors.foreground); - --background - draw.filled_rect(position.x + foreground_width + bar.offset.x, position.y + bar.offset.y, background_width, bar.size.height, bar.colors.background); + -- background + draw.filled_rect(position.x + foreground_width + bar.offset.x, position.y + bar.offset.y, background_width, + bar.size.height, bar.colors.background); end ---#endregion +-- #endregion ------------------------DRAW HELPERS------------------------- - - - - ------------------------QUEST STATUS------------------------- ---#region +-- #region local quest_manager_type_definition = sdk.find_type_definition("snow.QuestManager"); local on_changed_game_status = quest_manager_type_definition:get_method("onChangedGameStatus"); sdk.hook(on_changed_game_status, function(args) - local status = sdk.to_int64(args[3]); - if status ~= nil then - quest_status = status; + local new_quest_status = sdk.to_int64(args[3]); + if new_quest_status ~= nil then + if (quest_status < 2 and new_quest_status == 2) or + new_quest_status <2 then + players = {}; + total = init_player(0, "Total", 0); + small_monsters = {}; + large_monsters = {}; + end + + quest_status = new_quest_status; end -end, function(retval) return retval; end); ---#endregion +end, function(retval) + return retval; +end); +-- #endregion ------------------------QUEST STATUS------------------------- +------------------------VILLAGE AREA------------------------- +-- #region +is_in_training_area = function() + if village_area_manager == nil then + status = "No village area manager"; + return false; + end + local is_training_area = village_area_manager:call("checkCurrentArea_TrainingArea"); + if is_training_area ~= nil then + return is_training_area; + end + return false; +end +-- #endregion +------------------------VILLAGE AREA------------------------- +----------------------PLAYER POSITION------------------------ +-- #region +local update_player_position = function() + if player_manager == nil then + status = "No player manager"; + return; + end + + local master_player = player_manager:call("findMasterPlayer") + if master_player == nil then + status = "No master player"; + return; + end + + local master_player_game_object = master_player:call("get_GameObject") + if master_player_game_object == nil then + status = "No master player game object"; + return; + end + + local master_player_transform = master_player_game_object:call("get_Transform") + if not master_player_transform then + status = "No master player transform"; + return; + end + + local _master_player_position = master_player_transform:call("get_Position") + if _master_player_position == nil then + status = "No masterplayer position"; + return; + end + + master_player_position = _master_player_position; +end +-- #endregion +----------------------PLAYER POSITION------------------------ ------------------------MONSTER HOOK------------------------- ---#region +-- #region local enemy_character_base_type_def = sdk.find_type_definition("snow.enemy.EnemyCharacterBase"); local enemy_character_base_type_def_update_method = enemy_character_base_type_def:get_method("update"); sdk.hook(enemy_character_base_type_def_update_method, function(args) - update_monster(sdk.to_managed_object(args[2])); -end, function(retval) return retval; end); + update_monster(sdk.to_managed_object(args[2])); +end, function(retval) + return retval; +end); -update_monster = function (enemy) +init_monster = function(is_large) + monster = {}; + monster.is_large = is_large; + monster.health = 0; + monster.max_health = 999999; + monster.health_percentage = 0; + monster.missing_health = 0; + monster.capture_health = 0; + monster.position = { + x = 0, + y = 0 + }; + monster.name = ""; + monster.size = 1; + monster.small_border = 0; + monster.big_border = 999; + monster.crown = ""; + + return monster; +end + +update_monster = function(enemy) if enemy == nil then return; end @@ -2021,29 +2568,22 @@ update_monster = function (enemy) return; end - - local physical_param = enemy:get_field("k__BackingField"); - if physical_param == nil then - status = "No physical param"; - return; - end - - local vital_param = physical_param:call("getVital", 0, 0); - if vital_param == nil then - status = "No vital param"; - return; - end - - local health = vital_param:call("get_Current"); - local max_health = vital_param:call("get_Max"); - local missing_health = max_health - health; - local capture_health = physical_param:call("get_CaptureHpVital"); - - local health_percentage = 1; - if max_health ~= 0 then - health_percentage = health / max_health; + local physical_param = enemy:get_field("k__BackingField"); + if physical_param == nil then + status = "No physical param"; + return; end + local vital_param = physical_param:call("getVital", 0, 0); + if vital_param == nil then + status = "No vital param"; + return; + end + + local health = vital_param:call("get_Current"); + local max_health = vital_param:call("get_Max"); + local capture_health = physical_param:call("get_CaptureHpVital"); + local enemy_game_object = enemy:call("get_GameObject"); if enemy_game_object == nil then status = "No enemy game object"; @@ -2067,54 +2607,89 @@ update_monster = function (enemy) monster_list = small_monsters; end - local monster = monster_list[enemy]; + local monster = monster_list[enemy]; + + if monster == nil then + monster = init_monster(is_boss_enemy); - if monster == nil then - monster = {}; monster_list[enemy] = monster; - local enemy_type = enemy:get_field("k__BackingField"); - if enemy_type == nil then - status = "No enemy type"; - return; - end + local enemy_type = enemy:get_field("k__BackingField"); + if enemy_type == nil then + status = "No enemy type"; + return; + end - local enemy_name = message_manager:call("getEnemyNameMessage", enemy_type); - monster.name = enemy_name; + local enemy_name = message_manager:call("getEnemyNameMessage", enemy_type); + if enemy_name ~= nil then + monster.name = enemy_name; + end if is_boss_enemy then local size_info = enemy_manager:call("findEnemySizeInfo", enemy_type); - monster.small_border = size_info:call("get_SmallBorder"); - monster.big_border = size_info:call("get_KingBorder"); - monster.size = enemy:call("get_MonsterListRegisterScale"); + if size_info ~= nil then + local small_border = size_info:call("get_SmallBorder"); + local big_border = size_info:call("get_BigBorder"); + local king_border = size_info:call("get_KingBorder"); - if monster.size < monster.small_border then - monster.crown = "Silver"; - elseif monster.size > monster.big_border then - monster.crown = "Gold"; - else - monster.crown = ""; + local size = enemy:call("get_MonsterListRegisterScale"); + + if small_border ~= nil then + monster.small_border = small_border; + end + + if big_border ~= nil then + monster.big_border = big_border; + end + + if king_border ~= nil then + monster.king_border = king_border; + end + + + if size ~= nil then + monster.size = size; + end + + if monster.size <= monster.small_border then + monster.crown = "Silver"; + elseif monster.size >= monster.king_border then + monster.crown = "Gold"; + elseif monster.size >= monster.big_border then + monster.crown = "Mini"; + end end end - end + end - monster.health = health; - monster.max_health = max_health; - monster.health_percentage = health_percentage; - monster.missing_health = missing_health; - monster.capture_health = capture_health; - monster.position = position; + if health ~= nil then + monster.health = health; + end + if max_health ~= nil then + monster.max_health = max_health; + end + + if capture_health ~= nil then + monster.capture_health = capture_health; + end + + if max_health ~= nil and health ~= nil then + monster.missing_health = max_health - health; + if max_health ~= 0 then + monster.health_percentage = health / max_health; + end + end + + if position ~= nil then + monster.position = position; + end end ---#endregion +-- #endregion ------------------------MONSTER HOOK------------------------- - - - - ----------------------SMALL MONSTER UI----------------------- ---#region +-- #region small_monster_data = function() if enemy_manager == nil then status = "No enemy manager"; @@ -2129,64 +2704,65 @@ small_monster_data = function() return; end - for i = 0, enemy_count - 1 do - local enemy = enemy_manager:call("getZakoEnemy", i); - if enemy == nil then + for i = 0, enemy_count - 1 do + local enemy = enemy_manager:call("getZakoEnemy", i); + if enemy == nil then status = "No enemy"; - break; - end + break + end - local monster = small_monsters[enemy]; - if monster == nil then - status = "No monster hp entry"; - break; + local monster = small_monsters[enemy]; + if monster == nil then + status = "No monster hp entry"; + break end table.insert(displayed_monsters, monster); - end + end if not config.small_monster_UI.dynamic_positioning.enabled then - --sort here + -- sort here if config.small_monster_UI.sorting.type == "Normal" and config.small_monster_UI.sorting.reversed_order then local reversed_monsters = {}; - for i = #displayed_monsters, 1, -1 do - table.insert(reversed_monsters, large_monsters[i]); + table.insert(reversed_monsters, displayed_monsters[i]); end displayed_monsters = reversed_monsters; elseif config.small_monster_UI.sorting.type == "Health" then - table.sort(displayed_monsters, function(left, right) - local result = left.health > right.health; + if config.small_monster_UI.sorting.reversed_order then + table.sort(displayed_monsters, function(left, right) + return left.health > right.health; + end); + else + table.sort(displayed_monsters, function(left, right) + return left.health < right.health; + end); + end - if config.small_monster_UI.sorting.reversed_order then - result = not result; - end - - return result; - end); elseif config.small_monster_UI.sorting.type == "Health Percentage" then - table.sort(displayed_monsters, function(left, right) - local result = left.health_percentage < right.health_percentage; - - if config.small_monster_UI.sorting.reversed_order then - result = not result; - end - - return result; - end); + if config.small_monster_UI.sorting.reversed_order then + table.sort(displayed_monsters, function(left, right) + return left.health_percentage > right.health_percentage; + end); + else + table.sort(displayed_monsters, function(left, right) + return left.health_percentage < right.health_percentage; + end); + end end end + local i = 0; for _, monster in ipairs(displayed_monsters) do local position_on_screen; if config.small_monster_UI.dynamic_positioning.enabled then position_on_screen = draw.world_to_screen(monster.position); - + if position_on_screen == nil then - goto continue; + goto continue end position_on_screen.x = position_on_screen.x + config.small_monster_UI.dynamic_positioning.viewport_offset.x; @@ -2194,14 +2770,14 @@ small_monster_data = function() else position_on_screen = calculate_screen_coordinates(config.small_monster_UI.position); if config.small_monster_UI.settings.orientation == "Horizontal" then - position_on_screen.x = position_on_screen.x + config.small_monster_UI.settings.spacing * i; + position_on_screen.x = position_on_screen.x + config.small_monster_UI.spacing.x * i; else - position_on_screen.y = position_on_screen.y + config.small_monster_UI.settings.spacing * i; + position_on_screen.y = position_on_screen.y + config.small_monster_UI.spacing.y * i; end end - --do return end; - --remaining health + -- do return end; + -- remaining health --[[ if monster.health <= monster.capture_health then remaining_health_color = monster_UI.colors.health_bar.capture_health @@ -2221,22 +2797,17 @@ small_monster_data = function() ::continue:: end end ---#endregion +-- #endregion ----------------------SMALL MONSTER UI----------------------- - - - - ----------------------LARGE MONSTER UI----------------------- ---#region +-- #region large_monster_data = function() if enemy_manager == nil then status = "No enemy manager"; return; end - local displayed_monsters = {}; local enemy_count = enemy_manager:call("getBossEnemyCount"); @@ -2245,78 +2816,81 @@ large_monster_data = function() return; end - for i = 0, enemy_count - 1 do - local enemy = enemy_manager:call("getBossEnemy", i); - if enemy == nil then + for i = 0, enemy_count - 1 do + local enemy = enemy_manager:call("getBossEnemy", i); + if enemy == nil then status = "No enemy"; - break; - end + break + end - local monster = large_monsters[enemy]; - if monster == nil then - status = "No monster hp entry"; - break; + local monster = large_monsters[enemy]; + if monster == nil then + status = "No monster hp entry"; + break end table.insert(displayed_monsters, monster); - end + end if not config.large_monster_UI.dynamic_positioning.enabled then - --sort here + -- sort here + if config.large_monster_UI.sorting.type == "Normal" and config.large_monster_UI.sorting.reversed_order then local reversed_monsters = {}; - for i = #displayed_monsters, 1, -1 do - table.insert(reversed_monsters, large_monsters[i]); + table.insert(reversed_monsters, displayed_monsters[i]); end + displayed_monsters = reversed_monsters; elseif config.large_monster_UI.sorting.type == "Health" then - table.sort(displayed_monsters, function(left, right) - local result = left.health > right.health; - - if config.large_monster_UI.sorting.reversed_order then - result = not result; - end - - return result; - end); + if config.large_monster_UI.sorting.reversed_order then + table.sort(displayed_monsters, function(left, right) + return left.health > right.health; + end); + else + table.sort(displayed_monsters, function(left, right) + return left.health < right.health; + end); + end elseif config.large_monster_UI.sorting.type == "Health Percentage" then - table.sort(displayed_monsters, function(left, right) - local result = left.health_percentage < right.health_percentage; - - if config.large_monster_UI.sorting.reversed_order then - result = not result; - end - - return result; - end); + if config.large_monster_UI.sorting.reversed_order then + table.sort(displayed_monsters, function(left, right) + return left.health_percentage > right.health_percentage; + end); + else + table.sort(displayed_monsters, function(left, right) + return left.health_percentage < right.health_percentage; + end); + end end end local i = 0; for _, monster in ipairs(displayed_monsters) do local position_on_screen; - + if config.large_monster_UI.dynamic_positioning.enabled then position_on_screen = draw.world_to_screen(monster.position); - + if position_on_screen == nil then - goto continue; + goto continue end position_on_screen.x = position_on_screen.x + config.large_monster_UI.dynamic_positioning.viewport_offset.x; position_on_screen.y = position_on_screen.y + config.large_monster_UI.dynamic_positioning.viewport_offset.y; else position_on_screen = calculate_screen_coordinates(config.large_monster_UI.position); + if config.large_monster_UI.settings.orientation == "Horizontal" then - position_on_screen.x = position_on_screen.x + config.large_monster_UI.settings.spacing * i; + position_on_screen.x = position_on_screen.x + config.large_monster_UI.spacing.x * i; else - position_on_screen.y = position_on_screen.y + config.large_monster_UI.settings.spacing * i; + position_on_screen.y = position_on_screen.y + config.large_monster_UI.spacing.y * i; end + end - --remaining health + -- remaining health --[[ if monster.health <= monster.capture_health then remaining_health_color = monster_UI.colors.health_bar.capture_health @@ -2331,6 +2905,7 @@ large_monster_data = function() if config.large_monster_UI.monster_name_label.include.monster_name then monster_name_text = string.format("%s ", monster.name); end + if config.large_monster_UI.monster_name_label.include.crown and monster.crown ~= "" then monster_name_text = monster_name_text .. string.format("%s ", monster.crown); end @@ -2338,12 +2913,10 @@ large_monster_data = function() monster_name_text = monster_name_text .. string.format("#%.0f ", 100 * monster.size); end - if config.large_monster_UI.monster_name_label.include.silver_crown_threshold and config.large_monster_UI.monster_name_label.include.gold_crown_threshold then - monster_name_text = monster_name_text .. string.format("(Silver: <%.0f, Gold: >%.0f)", 100 * monster.small_border, 100 * monster.big_border); - elseif config.large_monster_UI.monster_name_label.include.silver_crown_threshold then - monster_name_text = monster_name_text .. string.format("(Silver: <%.0f)", 100 * monster.small_border); - elseif config.large_monster_UI.monster_name_label.include.gold_crown_threshold then - monster_name_text = monster_name_text .. string.format("(Gold: >%.0f)", 100 * monster.big_border); + if config.large_monster_UI.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 draw_label(config.large_monster_UI.monster_name_label, position_on_screen, monster_name_text); @@ -2355,54 +2928,46 @@ large_monster_data = function() ::continue:: end end ---#endregion +-- #endregion ----------------------LARGE MONSTER UI----------------------- - - - - ---------------------------TIME UI--------------------------- ---#region +-- #region quest_time = function() if quest_manager == nil then status = "No quest manager"; return; end - local quest_time_elapsed_minutes = quest_manager:call("getQuestElapsedTimeMin"); - if quest_time_elapsed_minutes == nil then - status = "No quest time elapsed minutes"; - return; - end + local quest_time_elapsed_minutes = quest_manager:call("getQuestElapsedTimeMin"); + if quest_time_elapsed_minutes == nil then + status = "No quest time elapsed minutes"; + return; + end - local quest_time_total_elapsed_seconds = quest_manager:call("getQuestElapsedTimeSec"); - if quest_time_total_elapsed_seconds == nil then - status = "No quest time total elapsed seconds"; - return; - end + local quest_time_total_elapsed_seconds = quest_manager:call("getQuestElapsedTimeSec"); + if quest_time_total_elapsed_seconds == nil then + status = "No quest time total elapsed seconds"; + return; + end - if quest_time_total_elapsed_seconds == 0 then - return; - end + if quest_time_total_elapsed_seconds == 0 then + return; + end - local quest_time_elapsed_seconds = quest_time_total_elapsed_seconds - quest_time_elapsed_minutes * 60; + local quest_time_elapsed_seconds = quest_time_total_elapsed_seconds - quest_time_elapsed_minutes * 60; local position_on_screen = calculate_screen_coordinates(config.time_UI.position); draw_label(config.time_UI.time_label, position_on_screen, quest_time_elapsed_minutes, quest_time_elapsed_seconds); end ---#endregion +-- #endregion ---------------------------TIME UI--------------------------- - - - - ------------------------DAMAGE METER UI----------------------- ---#region -local enemy_character_base_type_def = sdk.find_type_definition("snow.enemy.EnemyCharacterBase"); -local enemy_character_base_after_calc_damage_damage_side = enemy_character_base_type_def:get_method("afterCalcDamage_DamageSide"); +-------------------------DAMAGE HOOK------------------------- +-- #region +local enemy_character_base_after_calc_damage_damage_side = enemy_character_base_type_def:get_method( + "afterCalcDamage_DamageSide"); sdk.hook(enemy_character_base_after_calc_damage_damage_side, function(args) local enemy = sdk.to_managed_object(args[2]); @@ -2442,11 +3007,11 @@ sdk.hook(enemy_character_base_after_calc_damage_damage_side, function(args) -- 4 is virtual player in singleplayer that 'owns' 2nd otomo if not is_quest_online and attacker_id == 4 then - attacker_id = myself_player_id; + attacker_id = master_player_id; end local damage_object = {} - damage_object.total_damage = enemy_calc_damage_info:call("get_TotalDamage");; + damage_object.total_damage = enemy_calc_damage_info:call("get_TotalDamage"); damage_object.physical_damage = enemy_calc_damage_info:call("get_PhysicalDamage"); damage_object.elemental_damage = enemy_calc_damage_info:call("get_ElementDamage"); damage_object.ailment_damage = enemy_calc_damage_info:call("get_ConditionDamage"); @@ -2486,14 +3051,16 @@ sdk.hook(enemy_character_base_after_calc_damage_damage_side, function(args) return; end - --x = x.. string.format("[attacker] %d [type] %s [dmg] %d", attacker_id, damage_source_type, damage_object.total_damage); + -- x = x.. string.format("[attacker] %d [type] %s [dmg] %d", attacker_id, damage_source_type, damage_object.total_damage); - update_player(total, damage_source_type, damage_object); - update_player(player, damage_source_type, damage_object); -end, function(retval) return retval; end); + update_player_damage(total, damage_source_type, damage_object); + update_player_damage(player, damage_source_type, damage_object); +end, function(retval) + return retval; +end); init_player = function(player_id, player_name, player_hunter_rank) - player = {}; + local player = {}; player.id = player_id; player.name = player_name; player.hunter_rank = player_hunter_rank; @@ -2550,7 +3117,7 @@ get_player = function(player_id) return players[player_id]; end -update_player = function(player, damage_source_type, damage_object) +update_player_damage = function(player, damage_source_type, damage_object) if player == nil then return; end @@ -2573,6 +3140,14 @@ update_player = function(player, damage_source_type, damage_object) merge_damage(player, damage_object); end + update_player_display(player); +end + +update_player_display = function(player) + if player == nil then + return; + end + player.display.total_damage = 0; player.display.physical_damage = 0; player.display.elemental_damage = 0; @@ -2606,18 +3181,16 @@ end merge_damage = function(first, second) first.total_damage = first.total_damage + second.total_damage; - first.physical_damage = first.physical_damage + second.physical_damage; + first.physical_damage = first.physical_damage + second.physical_damage; first.elemental_damage = first.elemental_damage + second.elemental_damage; first.ailment_damage = first.ailment_damage + second.ailment_damage; end +-- #endregion +-------------------------DAMAGE HOOK------------------------- +-----------------------DAMAGE METER UI----------------------- +-- #region damage_meter = function() - if quest_status < 2 then - players = {}; - total = init_player(0, "Total", 0); - return; - end - if total.display.total_damage == 0 and config.damage_meter_UI.settings.hide_module_if_total_damage_is_zero then return; end @@ -2626,7 +3199,7 @@ damage_meter = function() status = "No lobby manager"; return; end - + if progress_manager == nil then status = "No progress manager"; return; @@ -2637,12 +3210,12 @@ damage_meter = function() is_quest_online = false; end - --myself player + -- myself player local myself_player_info = lobby_manager:get_field("_myHunterInfo"); - if myself_player_info == nil then - status = "No myself player info list"; + if myself_player_info == nil then + status = "No myself player info list"; return; - end + end local myself_player_name = myself_player_info:get_field("_name"); if myself_player_name == nil then @@ -2650,16 +3223,16 @@ damage_meter = function() return; end - myself_player_id = 0; + master_player_id = 0; if is_quest_online then - myself_player_id = lobby_manager:get_field("_myselfQuestIndex"); - if myself_player_id == nil then + master_player_id = lobby_manager:get_field("_myselfQuestIndex"); + if master_player_id == nil then status = "No myself player id"; return; end else - myself_player_id = lobby_manager:get_field("_myselfIndex"); - if myself_player_id == nil then + master_player_id = lobby_manager:get_field("_myselfIndex"); + if master_player_id == nil then status = "No myself player id"; return; end @@ -2667,19 +3240,19 @@ damage_meter = function() local myself_hunter_rank = progress_manager:call("get_HunterRank"); if myself_hunter_rank == nil then - status = "No myself hunter rank"; + status = "No myself hunter rank"; myself_hunter_rank = 0; - end + end - if players[myself_player_id] == nil then - players[myself_player_id] = init_player(myself_player_id, myself_player_name, myself_hunter_rank); + if players[master_player_id] == nil then + players[master_player_id] = init_player(master_player_id, myself_player_name, myself_hunter_rank); end local quest_players = {}; if quest_status > 2 then quest_players = last_displayed_players; else - --other players + -- other players local player_info_list = lobby_manager:get_field("_questHunterInfo"); if player_info_list == nil then status = "No player info list"; @@ -2695,28 +3268,28 @@ damage_meter = function() local player_info = player_info_list:call("get_Item", i); if player_info == nil then - goto continue; + goto continue end local player_id = player_info:get_field("_memberIndex"); if player_id == nil then - - goto continue; - end - - local player_hunter_rank = player_info:get_field("_hunterRank"); - if player_hunter_rank == nil then - goto continue; + + goto continue end - if player_id == myself_player_id and config.damage_meter_UI.settings.my_damage_bar_location ~= "Normal" then - players[myself_player_id].hunter_rank = player_hunter_rank; - goto continue; + local player_hunter_rank = player_info:get_field("_hunterRank"); + if player_hunter_rank == nil then + goto continue + end + + if player_id == master_player_id and config.damage_meter_UI.settings.my_damage_bar_location ~= "Normal" then + players[master_player_id].hunter_rank = player_hunter_rank; + goto continue end local player_name = player_info:get_field("_name"); if player_name == nil then - goto continue; + goto continue end if players[player_id] == nil then @@ -2730,32 +3303,32 @@ damage_meter = function() ::continue:: end - --sort here - if config.damage_meter_UI.sort_type == "normal" and config.damage_meter_UI.reverse_order then - local reversed_quest_players = {}; + -- sort here + if config.damage_meter_UI.sorting.type == "Normal" and config.damage_meter_UI.sorting.reversed_order then + local reversed_quest_players = {}; for i = #quest_players, 1, -1 do table.insert(reversed_quest_players, quest_players[i]); end quest_players = reversed_quest_players; - - elseif config.damage_meter_UI.sort_type == "damage" then - table.sort(quest_players, function(left, right) - local result = left.display.total_damage > right.display.total_damage; - if config.damage_meter_UI.reverse_order then - result = not result; - end - - return result; - end); + elseif config.damage_meter_UI.sorting.type == "Damage" then + if config.damage_meter_UI.sorting.reversed_order then + table.sort(quest_players, function(left, right) + return left.display.total_damage < right.display.total_damage; + end); + else + table.sort(quest_players, function(left, right) + return left.display.total_damage > right.display.total_damage; + end); + end end if config.damage_meter_UI.settings.my_damage_bar_location == "First" then - table.insert(quest_players, 1, players[myself_player_id]); + table.insert(quest_players, 1, players[master_player_id]); elseif config.damage_meter_UI.settings.my_damage_bar_location == "Last" then - table.insert(quest_players, #quest_players + 1, players[myself_player_id]); + table.insert(quest_players, #quest_players + 1, players[master_player_id]); elseif #quest_players == 0 then - table.insert(quest_players, 1, players[myself_player_id]); + table.insert(quest_players, 1, players[master_player_id]); end last_displayed_players = quest_players; @@ -2768,30 +3341,41 @@ damage_meter = function() end end - --draw + -- draw local position_on_screen = calculate_screen_coordinates(config.damage_meter_UI.position); for _, player in ipairs(quest_players) do - + if player.display.total_damage == 0 and config.damage_meter_UI.settings.hide_player_if_player_damage_is_zero then - goto continue1; - end - + goto continue1 + end + local player_damage_percentage = 0; if total.display.total_damage ~= 0 then player_damage_percentage = player.display.total_damage / total.display.total_damage; end - if player.id == myself_player_id and config.damage_meter_UI.settings.highlighted_bar == "Me" then - draw_bar(config.damage_meter_UI.highlighted_damage_bar, position_on_screen, player_damage_percentage); - elseif config.damage_meter_UI.settings.highlighted_bar == "Top Damage" and player.display.total_damage == top_damage then - draw_bar(config.damage_meter_UI.highlighted_damage_bar, position_on_screen, player_damage_percentage); + local player_damage_bar_percentage = 0; + if config.damage_meter_UI.settings.damage_bar_relative_to == "Total Damage" then + if total.display.total_damage ~= 0 then + player_damage_bar_percentage = player.display.total_damage / total.display.total_damage; + end else - draw_bar(config.damage_meter_UI.damage_bar, position_on_screen, player_damage_percentage); + if top_damage ~= 0 then + player_damage_bar_percentage = player.display.total_damage / top_damage; + end + end + + if player.id == master_player_id and config.damage_meter_UI.settings.highlighted_bar == "Me" then + draw_bar(config.damage_meter_UI.highlighted_damage_bar, position_on_screen, player_damage_bar_percentage); + elseif config.damage_meter_UI.settings.highlighted_bar == "Top Damage" and player.display.total_damage == top_damage then + draw_bar(config.damage_meter_UI.highlighted_damage_bar, position_on_screen, player_damage_bar_percentage); + else + draw_bar(config.damage_meter_UI.damage_bar, position_on_screen, player_damage_bar_percentage); end local player_name_text = ""; local player_include = config.damage_meter_UI.player_name_label.include.others; - if player.id == myself_player_id then + if player.id == master_player_id then player_include = config.damage_meter_UI.player_name_label.include.myself; end @@ -2811,29 +3395,33 @@ damage_meter = function() player_name_text = player_name_text .. player.name; end - draw_label(config.damage_meter_UI.player_name_label, position_on_screen, player_name_text) + draw_label(config.damage_meter_UI.player_name_label, position_on_screen, player_name_text); draw_label(config.damage_meter_UI.damage_value_label, position_on_screen, player.display.total_damage); draw_label(config.damage_meter_UI.damage_percentage_label, position_on_screen, 100 * player_damage_percentage); if config.damage_meter_UI.settings.orientation == "Horizontal" then - position_on_screen.x = position_on_screen.x + config.damage_meter_UI.settings.spacing; + position_on_screen.x = position_on_screen.x + config.damage_meter_UI.spacing.x; else - position_on_screen.y = position_on_screen.y + config.damage_meter_UI.settings.spacing; + position_on_screen.y = position_on_screen.y + config.damage_meter_UI.spacing.y; end ::continue1:: end - --draw total damage + -- draw total damage + if not config.damage_meter_UI.settings.total_damage_offset_is_relative then + position_on_screen = calculate_screen_coordinates(config.damage_meter_UI.position); + end + draw_label(config.damage_meter_UI.total_damage_label, position_on_screen); draw_label(config.damage_meter_UI.total_damage_value_label, position_on_screen, total.display.total_damage); end ---#endregion +-- #endregion -----------------------DAMAGE METER UI----------------------- ---#region +-- #region if not init() then return; end ---#endregion \ No newline at end of file +-- #endregion