mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-24 12:28:03 -08:00
Move logic out from REF D2D loop callback
This commit is contained in:
@@ -249,11 +249,47 @@ log.info("[MHR Overlay] Loaded.");
|
|||||||
----------------------------LOOP-----------------------------
|
----------------------------LOOP-----------------------------
|
||||||
-- #region
|
-- #region
|
||||||
|
|
||||||
|
local function update_modules(module_visibility_config, flow_state_name)
|
||||||
|
if module_visibility_config.small_monster_UI and config.current_config.small_monster_UI.enabled then
|
||||||
|
local success = pcall(small_monster_UI.update);
|
||||||
|
if not success then
|
||||||
|
error_handler.report("MHR_Overlay.update_modules", string.format("[%s] Small Monster UI Update Function threw an Exception", flow_state_name));
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local large_monster_UI_config = config.current_config.large_monster_UI;
|
||||||
|
|
||||||
|
local dynamic_enabled = large_monster_UI_config.dynamic.enabled and module_visibility_config.large_monster_dynamic_UI;
|
||||||
|
local static_enabled = large_monster_UI_config.static.enabled and module_visibility_config.large_monster_static_UI;
|
||||||
|
local highlighted_enabled = large_monster_UI_config.highlighted.enabled and module_visibility_config.large_monster_highlighted_UI;
|
||||||
|
|
||||||
|
if dynamic_enabled or static_enabled or highlighted_enabled then
|
||||||
|
local success = pcall(large_monster_UI.update, dynamic_enabled, static_enabled, highlighted_enabled);
|
||||||
|
if not success then
|
||||||
|
error_handler.report("MHR_Overlay.update_modules", string.format("[%s] Large Monster UI Update Function threw an Exception", flow_state_name));
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if config.current_config.endemic_life_UI.enabled and module_visibility_config.endemic_life_UI then
|
||||||
|
local success = pcall(env_creature_UI.update);
|
||||||
|
if not success then
|
||||||
|
error_handler.report("MHR_Overlay.update_modules", string.format("[%s] Endemic Life UI Update Function threw an Exception", flow_state_name));
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if config.current_config.buff_UI.enabled and module_visibility_config.buff_UI then
|
||||||
|
local success = pcall(buff_UI.update);
|
||||||
|
if not success then
|
||||||
|
error_handler.report("MHR_Overlay.update_modules", string.format("[%s] Buff UI Update Function threw an Exception", flow_state_name));
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function draw_modules(module_visibility_config, flow_state_name)
|
local function draw_modules(module_visibility_config, flow_state_name)
|
||||||
if module_visibility_config.small_monster_UI and config.current_config.small_monster_UI.enabled then
|
if module_visibility_config.small_monster_UI and config.current_config.small_monster_UI.enabled then
|
||||||
local success = pcall(small_monster_UI.draw);
|
local success = pcall(small_monster_UI.draw);
|
||||||
if not success then
|
if not success then
|
||||||
error_handler.report("MHR_Overlay.draw_modules", string.format("[%s] Small Monster UI Drawing Function threw an Exception", flow_state_name));
|
error_handler.report("MHR_Overlay.draw_modules", string.format("[%s] Small Monster UI Draw Function threw an Exception", flow_state_name));
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -266,42 +302,94 @@ local function draw_modules(module_visibility_config, flow_state_name)
|
|||||||
if dynamic_enabled or static_enabled or highlighted_enabled then
|
if dynamic_enabled or static_enabled or highlighted_enabled then
|
||||||
local success = pcall(large_monster_UI.draw, dynamic_enabled, static_enabled, highlighted_enabled);
|
local success = pcall(large_monster_UI.draw, dynamic_enabled, static_enabled, highlighted_enabled);
|
||||||
if not success then
|
if not success then
|
||||||
error_handler.report("MHR_Overlay.draw_modules", string.format("[%s] Large Monster UI Drawing Function threw an Exception", flow_state_name));
|
error_handler.report("MHR_Overlay.draw_modules", string.format("[%s] Large Monster UI Draw Function threw an Exception", flow_state_name));
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if config.current_config.time_UI.enabled and module_visibility_config.time_UI then
|
if config.current_config.time_UI.enabled and module_visibility_config.time_UI then
|
||||||
local success = pcall(time_UI.draw);
|
local success = pcall(time_UI.draw);
|
||||||
if not success then
|
if not success then
|
||||||
error_handler.report("MHR_Overlay.draw_modules", string.format("[%s] Time UI Drawing Function threw an Exception", flow_state_name));
|
error_handler.report("MHR_Overlay.draw_modules", string.format("[%s] Time UI Draw Function threw an Exception", flow_state_name));
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if config.current_config.damage_meter_UI.enabled and module_visibility_config.damage_meter_UI then
|
if config.current_config.damage_meter_UI.enabled and module_visibility_config.damage_meter_UI then
|
||||||
local success = pcall(damage_meter_UI.draw);
|
local success = pcall(damage_meter_UI.draw);
|
||||||
if not success then
|
if not success then
|
||||||
error_handler.report("MHR_Overlay.draw_modules", string.format("[%s] Damage Meter UI Drawing Function threw an Exception", flow_state_name));
|
error_handler.report("MHR_Overlay.draw_modules", string.format("[%s] Damage Meter UI Draw Function threw an Exception", flow_state_name));
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if config.current_config.endemic_life_UI.enabled and module_visibility_config.endemic_life_UI then
|
if config.current_config.endemic_life_UI.enabled and module_visibility_config.endemic_life_UI then
|
||||||
local success = pcall(env_creature_UI.draw);
|
local success = pcall(env_creature_UI.draw);
|
||||||
if not success then
|
if not success then
|
||||||
error_handler.report("MHR_Overlay.draw_modules", string.format("[%s] Endemic Life UI Drawing Function threw an Exception", flow_state_name));
|
error_handler.report("MHR_Overlay.draw_modules", string.format("[%s] Endemic Life UI Draw Function threw an Exception", flow_state_name));
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if config.current_config.buff_UI.enabled and module_visibility_config.buff_UI then
|
if config.current_config.buff_UI.enabled and module_visibility_config.buff_UI then
|
||||||
local success = pcall(buff_UI.draw);
|
local success = pcall(buff_UI.draw);
|
||||||
if not success then
|
if not success then
|
||||||
error_handler.report("MHR_Overlay.draw_modules", string.format("[%s] Buff UI Drawing Function threw an Exception", flow_state_name));
|
error_handler.report("MHR_Overlay.draw_modules", string.format("[%s] Buff UI Draw Function threw an Exception", flow_state_name));
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function main_loop()
|
local function update_UI()
|
||||||
time.update_timers();
|
if quest_status.flow_state == quest_status.flow_states.IN_TRAINING_AREA then
|
||||||
|
|
||||||
|
local large_monster_UI_config = config.current_config.large_monster_UI;
|
||||||
|
local module_visibility_config = config.current_config.global_settings.module_visibility.in_training_area;
|
||||||
|
|
||||||
|
local dynamic_enabled = large_monster_UI_config.dynamic.enabled and module_visibility_config.large_monster_dynamic_UI;
|
||||||
|
local static_enabled = large_monster_UI_config.static.enabled and module_visibility_config.large_monster_static_UI;
|
||||||
|
local highlighted_enabled = large_monster_UI_config.highlighted.enabled and module_visibility_config.large_monster_highlighted_UI;
|
||||||
|
|
||||||
|
if dynamic_enabled or static_enabled or highlighted_enabled then
|
||||||
|
local success = pcall(large_monster_UI.update, dynamic_enabled, static_enabled, highlighted_enabled);
|
||||||
|
if not success then
|
||||||
|
error_handler.report("MHR_Overlay.update_loop", "[In Training Area] Large Monster UI Update Function threw an Exception");
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if config.current_config.endemic_life_UI.enabled and module_visibility_config.endemic_life_UI then
|
||||||
|
local success = pcall(env_creature_UI.update);
|
||||||
|
if not success then
|
||||||
|
error_handler.report("MHR_Overlay.update_loop", "[In Training Area] Endemic Life UI Update Function threw an Exception");
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if config.current_config.buff_UI.enabled and module_visibility_config.buff_UI then
|
||||||
|
local success = pcall(buff_UI.update);
|
||||||
|
if not success then
|
||||||
|
error_handler.report("MHR_Overlay.update_loop", "[In Training Area] Buff UI Update Function threw an Exception");
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
elseif quest_status.flow_state == quest_status.flow_states.CUTSCENE then
|
||||||
|
update_modules(config.current_config.global_settings.module_visibility.cutscene, "Cutscene");
|
||||||
|
elseif quest_status.flow_state == quest_status.flow_states.LOADING_QUEST then
|
||||||
|
update_modules(config.current_config.global_settings.module_visibility.loading_quest, "Loading Quest");
|
||||||
|
elseif quest_status.flow_state == quest_status.flow_states.QUEST_START_ANIMATION then
|
||||||
|
update_modules(config.current_config.global_settings.module_visibility.quest_start_animation, "Quest Start Animation");
|
||||||
|
elseif quest_status.flow_state >= quest_status.flow_states.PLAYING_QUEST and quest_status.flow_state <= quest_status.flow_states.WYVERN_RIDING_START_ANIMATION then
|
||||||
|
update_modules(config.current_config.global_settings.module_visibility.playing_quest, "Playing Quest");
|
||||||
|
elseif quest_status.flow_state == quest_status.flow_states.KILLCAM then
|
||||||
|
update_modules(config.current_config.global_settings.module_visibility.killcam, "Killcam");
|
||||||
|
elseif quest_status.flow_state == quest_status.flow_states.QUEST_END_TIMER then
|
||||||
|
update_modules(config.current_config.global_settings.module_visibility.quest_end_timer, "Quest End Timer");
|
||||||
|
elseif quest_status.flow_state == quest_status.flow_states.QUEST_END_ANIMATION then
|
||||||
|
update_modules(config.current_config.global_settings.module_visibility.quest_end_animation, "Quest End Animation");
|
||||||
|
elseif quest_status.flow_state == quest_status.flow_states.QUEST_END_SCREEN then
|
||||||
|
update_modules(config.current_config.global_settings.module_visibility.quest_end_screen, "Quest End Screen");
|
||||||
|
elseif quest_status.flow_state == quest_status.flow_states.REWARD_SCREEN then
|
||||||
|
update_modules(config.current_config.global_settings.module_visibility.reward_screen, "Reward Screen");
|
||||||
|
elseif quest_status.flow_state == quest_status.flow_states.SUMMARY_SCREEN then
|
||||||
|
update_modules(config.current_config.global_settings.module_visibility.summary_screen, "Summary Screen");
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function draw_loop()
|
||||||
if quest_status.flow_state == quest_status.flow_states.IN_TRAINING_AREA then
|
if quest_status.flow_state == quest_status.flow_states.IN_TRAINING_AREA then
|
||||||
|
|
||||||
local large_monster_UI_config = config.current_config.large_monster_UI;
|
local large_monster_UI_config = config.current_config.large_monster_UI;
|
||||||
@@ -314,28 +402,28 @@ local function main_loop()
|
|||||||
if dynamic_enabled or static_enabled or highlighted_enabled then
|
if dynamic_enabled or static_enabled or highlighted_enabled then
|
||||||
local success = pcall(large_monster_UI.draw, dynamic_enabled, static_enabled, highlighted_enabled);
|
local success = pcall(large_monster_UI.draw, dynamic_enabled, static_enabled, highlighted_enabled);
|
||||||
if not success then
|
if not success then
|
||||||
error_handler.report("MHR_Overlay.main_loop", "[In Training Area] Large Monster UI Drawing Function threw an Exception");
|
error_handler.report("MHR_Overlay.main_loop", "[In Training Area] Large Monster UI Draw Function threw an Exception");
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if config.current_config.damage_meter_UI.enabled and module_visibility_config.damage_meter_UI then
|
if config.current_config.damage_meter_UI.enabled and module_visibility_config.damage_meter_UI then
|
||||||
local success = pcall(damage_meter_UI.draw);
|
local success = pcall(damage_meter_UI.draw);
|
||||||
if not success then
|
if not success then
|
||||||
error_handler.report("MHR_Overlay.main_loop", "[In Training Area] Damage Meter UI Drawing Function threw an Exception");
|
error_handler.report("MHR_Overlay.main_loop", "[In Training Area] Damage Meter UI Draw Function threw an Exception");
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if config.current_config.endemic_life_UI.enabled and module_visibility_config.endemic_life_UI then
|
if config.current_config.endemic_life_UI.enabled and module_visibility_config.endemic_life_UI then
|
||||||
local success = pcall(env_creature_UI.draw);
|
local success = pcall(env_creature_UI.draw);
|
||||||
if not success then
|
if not success then
|
||||||
error_handler.report("MHR_Overlay.main_loop", "[In Training Area] Endemic Life UI Drawing Function threw an Exception");
|
error_handler.report("MHR_Overlay.main_loop", "[In Training Area] Endemic Life UI Draw Function threw an Exception");
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if config.current_config.buff_UI.enabled and module_visibility_config.buff_UI then
|
if config.current_config.buff_UI.enabled and module_visibility_config.buff_UI then
|
||||||
local success = pcall(buff_UI.draw);
|
local success = pcall(buff_UI.draw);
|
||||||
if not success then
|
if not success then
|
||||||
error_handler.report("MHR_Overlay.main_loop", "[In Training Area] Buff UI Drawing Function threw an Exception");
|
error_handler.report("MHR_Overlay.main_loop", "[In Training Area] Buff UI Draw Function threw an Exception");
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -380,32 +468,35 @@ re.on_frame(function()
|
|||||||
if reframework:is_drawing_ui() then
|
if reframework:is_drawing_ui() then
|
||||||
pcall(customization_menu.draw);
|
pcall(customization_menu.draw);
|
||||||
end
|
end
|
||||||
|
|
||||||
keyboard.update();
|
|
||||||
end);
|
end);
|
||||||
-- #endregion
|
-- #endregion
|
||||||
--------------------------RE_IMGUI---------------------------
|
--------------------------RE_IMGUI---------------------------
|
||||||
|
|
||||||
----------------------------D2D------------------------------
|
-----------------------Loop Callbacks------------------------
|
||||||
-- #region
|
-- #region
|
||||||
if d2d ~= nil then
|
if d2d ~= nil then
|
||||||
d2d.register(function()
|
d2d.register(function()
|
||||||
drawing.init_font();
|
drawing.init_font();
|
||||||
end, function()
|
end, function()
|
||||||
if config.current_config.global_settings.renderer.use_d2d_if_available then
|
if config.current_config.global_settings.renderer.use_d2d_if_available then
|
||||||
main_loop();
|
draw_loop();
|
||||||
end
|
end
|
||||||
end);
|
end);
|
||||||
end
|
end
|
||||||
|
|
||||||
re.on_frame(function()
|
re.on_frame(function()
|
||||||
|
time.update_timers();
|
||||||
|
keyboard.update();
|
||||||
|
|
||||||
if d2d == nil or not config.current_config.global_settings.renderer.use_d2d_if_available then
|
if d2d == nil or not config.current_config.global_settings.renderer.use_d2d_if_available then
|
||||||
main_loop();
|
draw_loop();
|
||||||
end
|
end
|
||||||
end);
|
end);
|
||||||
-- #endregion
|
-- #endregion
|
||||||
----------------------------D2D------------------------------
|
-----------------------Loop Callbacks------------------------
|
||||||
|
|
||||||
if imgui.begin_table == nil then
|
if imgui.begin_table == nil then
|
||||||
re.msg(language.current_language.customization_menu.reframework_outdated);
|
re.msg(language.current_language.customization_menu.reframework_outdated);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
time.new_timer(update_UI, 0.5);
|
||||||
@@ -151,7 +151,7 @@ function this.update()
|
|||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
abnormal_statuses.update(master_player);
|
|
||||||
|
|
||||||
local master_player_data = get_player_data_method:call(master_player);
|
local master_player_data = get_player_data_method:call(master_player);
|
||||||
if master_player_data ~= nil then
|
if master_player_data ~= nil then
|
||||||
@@ -159,6 +159,7 @@ function this.update()
|
|||||||
endemic_life_buffs.update(master_player_data);
|
endemic_life_buffs.update(master_player_data);
|
||||||
skills.update(master_player, master_player_data);
|
skills.update(master_player, master_player_data);
|
||||||
dangos.update(master_player_data);
|
dangos.update(master_player_data);
|
||||||
|
abnormal_statuses.update(master_player, master_player_data);
|
||||||
else
|
else
|
||||||
error_handler.report("buffs.update", "Failed to access Data: master_player_data");
|
error_handler.report("buffs.update", "Failed to access Data: master_player_data");
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1171,15 +1171,7 @@ function this.update_highlighted_id()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function this.draw(monster, type, cached_config, position_on_screen, opacity_scale)
|
function this.draw(monster, type, cached_config, position_on_screen, opacity_scale)
|
||||||
local monster_UI;
|
local monster_UI = monster[type];
|
||||||
|
|
||||||
if type == "dynamic" then
|
|
||||||
monster_UI = monster.dynamic_UI;
|
|
||||||
elseif type == "static" then
|
|
||||||
monster_UI = monster.static_UI;
|
|
||||||
else
|
|
||||||
monster_UI = monster.highlighted_UI;
|
|
||||||
end
|
|
||||||
|
|
||||||
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
|
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
|
||||||
|
|
||||||
@@ -1307,7 +1299,6 @@ function this.init_dependencies()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function this.init_module()
|
function this.init_module()
|
||||||
time.new_timer(this.update_highlighted_id, 1/30);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
@@ -45,11 +45,12 @@ local os = os;
|
|||||||
local ValueType = ValueType;
|
local ValueType = ValueType;
|
||||||
local package = package;
|
local package = package;
|
||||||
|
|
||||||
function this.draw()
|
local displayed_buffs = {};
|
||||||
local cached_config = config.current_config.buff_UI;
|
|
||||||
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
|
|
||||||
|
|
||||||
local displayed_buffs = {};
|
function this.update()
|
||||||
|
local cached_config = config.current_config.buff_UI;
|
||||||
|
|
||||||
|
local _displayed_buffs = {};
|
||||||
|
|
||||||
for key, consumable in pairs(consumables.list) do
|
for key, consumable in pairs(consumables.list) do
|
||||||
|
|
||||||
@@ -57,7 +58,7 @@ function this.draw()
|
|||||||
goto continue;
|
goto continue;
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(displayed_buffs, consumable);
|
table.insert(_displayed_buffs, consumable);
|
||||||
|
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
@@ -68,7 +69,7 @@ function this.draw()
|
|||||||
goto continue2;
|
goto continue2;
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(displayed_buffs, melody_effect);
|
table.insert(_displayed_buffs, melody_effect);
|
||||||
|
|
||||||
::continue2::
|
::continue2::
|
||||||
end
|
end
|
||||||
@@ -78,7 +79,7 @@ function this.draw()
|
|||||||
goto continue3;
|
goto continue3;
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(displayed_buffs, endemic_life_buff);
|
table.insert(_displayed_buffs, endemic_life_buff);
|
||||||
|
|
||||||
::continue3::
|
::continue3::
|
||||||
end
|
end
|
||||||
@@ -88,7 +89,7 @@ function this.draw()
|
|||||||
goto continue4;
|
goto continue4;
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(displayed_buffs, skill);
|
table.insert(_displayed_buffs, skill);
|
||||||
|
|
||||||
::continue4::
|
::continue4::
|
||||||
end
|
end
|
||||||
@@ -98,64 +99,71 @@ function this.draw()
|
|||||||
goto continue5;
|
goto continue5;
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(displayed_buffs, dango_buff);
|
table.insert(_displayed_buffs, dango_buff);
|
||||||
|
|
||||||
::continue5::
|
::continue5::
|
||||||
end
|
end
|
||||||
|
|
||||||
for key, abnormal_status in pairs(abnormal_statuses.list) do
|
for key, abnormal_status in pairs(abnormal_statuses.list) do
|
||||||
if not abnormal_status.is_active then
|
if not abnormal_status.is_active then
|
||||||
goto continue5;
|
goto continue6;
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(displayed_buffs, abnormal_status);
|
table.insert(_displayed_buffs, abnormal_status);
|
||||||
|
|
||||||
::continue5::
|
::continue6::
|
||||||
end
|
end
|
||||||
|
|
||||||
|
displayed_buffs = this.sort_buffs(_displayed_buffs, cached_config);
|
||||||
|
end
|
||||||
|
|
||||||
-- sort
|
function this.sort_buffs(_displayed_buffs, cached_config)
|
||||||
if cached_config.sorting.type == "Name" then
|
cached_config = cached_config.sorting;
|
||||||
if cached_config.sorting.reversed_order then
|
|
||||||
table.sort(displayed_buffs, function(left, right)
|
if cached_config.type == "Name" then
|
||||||
|
if cached_config.reversed_order then
|
||||||
|
table.sort(_displayed_buffs, function(left, right)
|
||||||
return left.name > right.name;
|
return left.name > right.name;
|
||||||
end);
|
end);
|
||||||
else
|
else
|
||||||
table.sort(displayed_buffs, function(left, right)
|
table.sort(_displayed_buffs, function(left, right)
|
||||||
return left.name < right.name;
|
return left.name < right.name;
|
||||||
end);
|
end);
|
||||||
end
|
end
|
||||||
elseif cached_config.sorting.type == "Timer" then
|
elseif cached_config.type == "Timer" then
|
||||||
if cached_config.sorting.reversed_order then
|
if cached_config.reversed_order then
|
||||||
table.sort(displayed_buffs, function(left, right)
|
table.sort(_displayed_buffs, function(left, right)
|
||||||
return left.timer > right.timer;
|
return left.timer > right.timer;
|
||||||
end);
|
end);
|
||||||
else
|
else
|
||||||
table.sort(displayed_buffs, function(left, right)
|
table.sort(_displayed_buffs, function(left, right)
|
||||||
return left.timer < right.timer;
|
return left.timer < right.timer;
|
||||||
end);
|
end);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if cached_config.sorting.reversed_order then
|
if cached_config.reversed_order then
|
||||||
table.sort(displayed_buffs, function(left, right)
|
table.sort(_displayed_buffs, function(left, right)
|
||||||
return left.duration > right.duration;
|
return left.duration > right.duration;
|
||||||
end);
|
end);
|
||||||
else
|
else
|
||||||
table.sort(displayed_buffs, function(left, right)
|
table.sort(_displayed_buffs, function(left, right)
|
||||||
return left.duration < right.duration;
|
return left.duration < right.duration;
|
||||||
end);
|
end);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return _displayed_buffs;
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.draw()
|
||||||
|
local cached_config = config.current_config.buff_UI;
|
||||||
|
|
||||||
|
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
|
||||||
|
|
||||||
local position_on_screen = screen.calculate_absolute_coordinates(cached_config.position);
|
local position_on_screen = screen.calculate_absolute_coordinates(cached_config.position);
|
||||||
|
|
||||||
-- draw
|
-- draw
|
||||||
for _, buff in ipairs(displayed_buffs) do
|
for _, buff in ipairs(displayed_buffs) do
|
||||||
|
|
||||||
if not buff.is_active then
|
|
||||||
goto continue3;
|
|
||||||
end
|
|
||||||
|
|
||||||
buffs.draw(buff, buff.buff_UI, position_on_screen, 1);
|
buffs.draw(buff, buff.buff_UI, position_on_screen, 1);
|
||||||
|
|
||||||
if cached_config.settings.orientation == "Horizontal" then
|
if cached_config.settings.orientation == "Horizontal" then
|
||||||
@@ -164,7 +172,7 @@ function this.draw()
|
|||||||
position_on_screen.y = position_on_screen.y + cached_config.spacing.y * global_scale_modifier;
|
position_on_screen.y = position_on_screen.y + cached_config.spacing.y * global_scale_modifier;
|
||||||
end
|
end
|
||||||
|
|
||||||
::continue3::
|
::continue::
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -45,29 +45,45 @@ local os = os;
|
|||||||
local ValueType = ValueType;
|
local ValueType = ValueType;
|
||||||
local package = package;
|
local package = package;
|
||||||
|
|
||||||
function this.draw()
|
local displayed_creatures = {};
|
||||||
if singletons.enemy_manager == nil then
|
|
||||||
|
function this.update()
|
||||||
|
local cached_config = config.current_config.endemic_life_UI;
|
||||||
|
|
||||||
|
local _displayed_creatures = {};
|
||||||
|
|
||||||
|
if cached_config.settings.max_distance == 0 then
|
||||||
|
displayed_creatures = {};
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
local cached_config = config.current_config.endemic_life_UI;
|
|
||||||
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
|
|
||||||
|
|
||||||
for REcreature, creature in pairs(env_creature.list) do
|
for REcreature, creature in pairs(env_creature.list) do
|
||||||
if cached_config.settings.max_distance == 0 then
|
|
||||||
break;
|
|
||||||
end
|
|
||||||
|
|
||||||
if cached_config.settings.hide_inactive_creatures and creature.is_inactive then
|
if cached_config.settings.hide_inactive_creatures and creature.is_inactive then
|
||||||
goto continue;
|
goto continue;
|
||||||
end
|
end
|
||||||
|
|
||||||
local position_on_screen = {};
|
creature.distance = (players.myself_position - creature.position):length();
|
||||||
|
if creature.distance > cached_config.settings.max_distance then
|
||||||
|
goto continue;
|
||||||
|
end
|
||||||
|
|
||||||
local world_offset = Vector3f.new(cached_config.world_offset.x, cached_config.world_offset.y,
|
table.insert(_displayed_creatures, creature);
|
||||||
cached_config.world_offset.z);
|
::continue::
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
position_on_screen = draw.world_to_screen(creature.position + world_offset);
|
function this.draw()
|
||||||
|
local cached_config = config.current_config.endemic_life_UI;
|
||||||
|
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
|
||||||
|
|
||||||
|
for i, creature in ipairs(displayed_creatures) do
|
||||||
|
local world_offset = Vector3f.new(
|
||||||
|
cached_config.world_offset.x,
|
||||||
|
cached_config.world_offset.y,
|
||||||
|
cached_config.world_offset.z
|
||||||
|
);
|
||||||
|
|
||||||
|
local position_on_screen = draw.world_to_screen(creature.position + world_offset);
|
||||||
|
|
||||||
if position_on_screen == nil then
|
if position_on_screen == nil then
|
||||||
goto continue;
|
goto continue;
|
||||||
@@ -76,14 +92,9 @@ function this.draw()
|
|||||||
position_on_screen.x = position_on_screen.x + cached_config.viewport_offset.x * global_scale_modifier;
|
position_on_screen.x = position_on_screen.x + cached_config.viewport_offset.x * global_scale_modifier;
|
||||||
position_on_screen.y = position_on_screen.y + cached_config.viewport_offset.y * global_scale_modifier;
|
position_on_screen.y = position_on_screen.y + cached_config.viewport_offset.y * global_scale_modifier;
|
||||||
|
|
||||||
creature.distance = (players.myself_position - creature.position):length();
|
|
||||||
|
|
||||||
local opacity_scale = 1;
|
local opacity_scale = 1;
|
||||||
if creature.distance > cached_config.settings.max_distance then
|
|
||||||
goto continue;
|
|
||||||
end
|
|
||||||
|
|
||||||
if cached_config.settings.opacity_falloff then
|
if cached_config.settings.opacity_falloff then
|
||||||
|
creature.distance = (players.myself_position - creature.position):length();
|
||||||
opacity_scale = 1 - (creature.distance / cached_config.settings.max_distance);
|
opacity_scale = 1 - (creature.distance / cached_config.settings.max_distance);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -54,148 +54,287 @@ local get_tg_camera_method = gui_manager_type_def:get_method("get_refGuiHud_TgCa
|
|||||||
local tg_camera_type_def = get_tg_camera_method:get_return_type();
|
local tg_camera_type_def = get_tg_camera_method:get_return_type();
|
||||||
local get_targeting_enemy_index_field = tg_camera_type_def:get_field("OldTargetingEmIndex");
|
local get_targeting_enemy_index_field = tg_camera_type_def:get_field("OldTargetingEmIndex");
|
||||||
|
|
||||||
function this.draw(dynamic_enabled, static_enabled, highlighted_enabled)
|
local displayed_dynamic_monsters = {};
|
||||||
|
local displayed_static_monsters = {};
|
||||||
|
local highlighted_monster = nil;
|
||||||
|
|
||||||
|
function this.update(dynamic_enabled, static_enabled, highlighted_enabled)
|
||||||
local cached_config = config.current_config.large_monster_UI;
|
local cached_config = config.current_config.large_monster_UI;
|
||||||
|
|
||||||
if singletons.enemy_manager == nil then
|
if singletons.enemy_manager == nil then
|
||||||
|
error_handler.report("large_monster_UI.update", "Failed to access Data: enemy_manager");
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
local displayed_monsters = {};
|
local large_monster_list = {};
|
||||||
|
|
||||||
local update_distance =
|
|
||||||
dynamic_enabled or cached_config.static.sorting.type == "Distance"
|
|
||||||
or (cached_config.highlighted.auto_highlight.enabled
|
|
||||||
and (cached_config.highlighted.auto_highlight.mode == "Closest" or cached_config.highlighted.auto_highlight.mode == "Furthest")
|
|
||||||
);
|
|
||||||
|
|
||||||
local monster_id_shift = 0;
|
|
||||||
local highlighted_monster = nil;
|
|
||||||
|
|
||||||
local enemy_count = get_boss_enemy_count_method:call(singletons.enemy_manager);
|
local enemy_count = get_boss_enemy_count_method:call(singletons.enemy_manager);
|
||||||
if enemy_count == nil then
|
if enemy_count == nil then
|
||||||
error_handler.report("large_monster_UI.draw", "Failed to access Data: enemy_count");
|
error_handler.report("large_monster_UI.update", "Failed to access Data: enemy_count");
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
for i = 0, enemy_count - 1 do
|
for i = 0, enemy_count - 1 do
|
||||||
local enemy = get_boss_enemy_method:call(singletons.enemy_manager, i);
|
local enemy = get_boss_enemy_method:call(singletons.enemy_manager, i);
|
||||||
if enemy == nil then
|
if enemy == nil then
|
||||||
error_handler.report("large_monster_UI.draw", "Failed to access Data: enemy No. " .. tostring(i));
|
error_handler.report("large_monster_UI.update", "Failed to access Data: enemy No. " .. tostring(i));
|
||||||
goto continue;
|
goto continue;
|
||||||
end
|
end
|
||||||
|
|
||||||
local monster = large_monster.get_monster(enemy);
|
local monster = large_monster.get_monster(enemy);
|
||||||
if monster == nil then
|
if monster == nil then
|
||||||
error_handler.report("large_monster_UI.draw", "Failed to create Large Monster Entry No. " .. tostring(i));
|
error_handler.report("large_monster_UI.update", "Failed to create Large Monster Entry No. " .. tostring(i));
|
||||||
goto continue;
|
goto continue;
|
||||||
end
|
end
|
||||||
|
|
||||||
if update_distance then
|
monster.distance = (players.myself_position - monster.position):length();
|
||||||
monster.distance = (players.myself_position - monster.position):length();
|
|
||||||
end
|
|
||||||
|
|
||||||
if cached_config.highlighted.auto_highlight.enabled then
|
table.insert(large_monster_list, monster);
|
||||||
if highlighted_monster == nil then
|
|
||||||
highlighted_monster = monster;
|
|
||||||
|
|
||||||
elseif cached_config.highlighted.auto_highlight.mode == "Farthest" then
|
|
||||||
if monster.distance > highlighted_monster.distance then
|
|
||||||
highlighted_monster = monster;
|
|
||||||
end
|
|
||||||
|
|
||||||
elseif cached_config.highlighted.auto_highlight.mode == "Lowest Health" then
|
|
||||||
if monster.health < highlighted_monster.health then
|
|
||||||
highlighted_monster = monster;
|
|
||||||
end
|
|
||||||
|
|
||||||
elseif cached_config.highlighted.auto_highlight.mode == "Highest Health" then
|
|
||||||
if monster.health > highlighted_monster.health then
|
|
||||||
highlighted_monster = monster;
|
|
||||||
end
|
|
||||||
|
|
||||||
elseif cached_config.highlighted.auto_highlight.mode == "Lowest Health Percentage" then
|
|
||||||
if monster.health_percentage < highlighted_monster.health_percentage then
|
|
||||||
highlighted_monster = monster;
|
|
||||||
end
|
|
||||||
|
|
||||||
elseif cached_config.highlighted.auto_highlight.mode == "Highest Health Percentage" then
|
|
||||||
if monster.health_percentage > highlighted_monster.health_percentage then
|
|
||||||
highlighted_monster = monster;
|
|
||||||
end
|
|
||||||
|
|
||||||
else
|
|
||||||
if monster.distance < highlighted_monster.distance then
|
|
||||||
highlighted_monster = monster;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if monster.dead_or_captured or not monster.is_disp_icon_mini_map then
|
|
||||||
monster_id_shift = monster_id_shift + 1;
|
|
||||||
|
|
||||||
elseif i == large_monster.highlighted_id + monster_id_shift then
|
|
||||||
highlighted_monster = monster;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
table.insert(displayed_monsters, monster);
|
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
|
|
||||||
if dynamic_enabled then
|
this.update_highlighted_monster(large_monster_list, cached_config.highlighted.auto_highlight);
|
||||||
local success = pcall(this.draw_dynamic, displayed_monsters, highlighted_monster, cached_config);
|
|
||||||
if not success then
|
|
||||||
error_handler.report("large_monster_UI.draw", "Dynamic Large Monster drawing function threw an exception");
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if highlighted_enabled then
|
if dynamic_enabled then
|
||||||
local success = pcall(this.draw_highlighted, highlighted_monster, cached_config);
|
this.update_dynamic_monsters(large_monster_list, cached_config);
|
||||||
if not success then
|
|
||||||
error_handler.report("large_monster_UI.draw", "Highlighted Large Monster drawing function threw an exception");
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if static_enabled then
|
if static_enabled then
|
||||||
local success = pcall(this.draw_static, displayed_monsters, highlighted_monster, cached_config);
|
this.update_static_monsters(large_monster_list, cached_config);
|
||||||
if not success then
|
|
||||||
error_handler.report("large_monster_UI.draw", "Static Large Monster drawing function threw an exception");
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function this.draw_dynamic(displayed_monsters, highlighted_monster, cached_config)
|
function this.update_dynamic_monsters(large_monster_list, cached_config)
|
||||||
cached_config = cached_config.dynamic;
|
if not cached_config.dynamic.enabled then
|
||||||
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
|
displayed_dynamic_monsters = {};
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
local i = 0;
|
local dynamic_cached_config = cached_config.dynamic.settings;
|
||||||
for _, monster in ipairs(displayed_monsters) do
|
|
||||||
if cached_config.settings.max_distance == 0 then
|
local _displayed_dynamic_monsters = {};
|
||||||
break;
|
|
||||||
|
if dynamic_cached_config.max_distance == 0 then
|
||||||
|
displayed_dynamic_monsters = {};
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
|
for i, monster in ipairs(large_monster_list) do
|
||||||
|
if monster.distance > dynamic_cached_config.max_distance then
|
||||||
|
goto continue;
|
||||||
end
|
end
|
||||||
|
|
||||||
if monster.is_stealth then
|
if monster.is_stealth then
|
||||||
goto continue;
|
goto continue;
|
||||||
end
|
end
|
||||||
|
|
||||||
if monster.dead_or_captured and cached_config.settings.hide_dead_or_captured then
|
if monster.dead_or_captured and dynamic_cached_config.hide_dead_or_captured then
|
||||||
goto continue;
|
goto continue;
|
||||||
end
|
end
|
||||||
|
|
||||||
if monster == highlighted_monster then
|
if monster == highlighted_monster then
|
||||||
if not cached_config.settings.render_highlighted_monster then
|
if not dynamic_cached_config.render_highlighted_monster then
|
||||||
goto continue;
|
goto continue;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if not cached_config.settings.render_not_highlighted_monsters then
|
if not dynamic_cached_config.render_not_highlighted_monsters then
|
||||||
goto continue;
|
goto continue;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local position_on_screen = {};
|
table.insert(_displayed_dynamic_monsters, monster);
|
||||||
|
|
||||||
|
::continue::
|
||||||
|
end
|
||||||
|
|
||||||
|
displayed_dynamic_monsters = _displayed_dynamic_monsters;
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.update_static_monsters(large_monster_list, cached_config)
|
||||||
|
if not cached_config.static.enabled then
|
||||||
|
displayed_static_monsters = {};
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
|
local static_cached_config = cached_config.static.settings;
|
||||||
|
|
||||||
|
local _displayed_static_monsters = {};
|
||||||
|
|
||||||
|
for i, monster in ipairs(large_monster_list) do
|
||||||
|
if monster.is_stealth then
|
||||||
|
goto continue;
|
||||||
|
end
|
||||||
|
|
||||||
|
if monster.dead_or_captured and static_cached_config.hide_dead_or_captured then
|
||||||
|
goto continue;
|
||||||
|
end
|
||||||
|
|
||||||
|
if monster == highlighted_monster then
|
||||||
|
if not static_cached_config.render_highlighted_monster then
|
||||||
|
goto continue;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if not static_cached_config.render_not_highlighted_monsters then
|
||||||
|
goto continue;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(_displayed_static_monsters, monster);
|
||||||
|
::continue::
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
displayed_static_monsters = this.sort_static_monsters(_displayed_static_monsters, cached_config);
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.sort_static_monsters(_displayed_static_monsters, cached_config)
|
||||||
|
cached_config = cached_config.static.sorting;
|
||||||
|
|
||||||
|
-- sort here
|
||||||
|
if cached_config.type == "Normal" and cached_config.reversed_order then
|
||||||
|
local reversed_monsters = {};
|
||||||
|
for i = #_displayed_static_monsters, 1, -1 do
|
||||||
|
table.insert(reversed_monsters, _displayed_static_monsters[i]);
|
||||||
|
end
|
||||||
|
|
||||||
|
_displayed_static_monsters = reversed_monsters;
|
||||||
|
|
||||||
|
elseif cached_config.type == "Health" then
|
||||||
|
if cached_config.reversed_order then
|
||||||
|
table.sort(_displayed_static_monsters, function(left, right)
|
||||||
|
return left.health > right.health;
|
||||||
|
end);
|
||||||
|
else
|
||||||
|
table.sort(_displayed_static_monsters, function(left, right)
|
||||||
|
return left.health < right.health;
|
||||||
|
end);
|
||||||
|
end
|
||||||
|
elseif cached_config.type == "Health Percentage" then
|
||||||
|
if cached_config.reversed_order then
|
||||||
|
table.sort(_displayed_static_monsters, function(left, right)
|
||||||
|
return left.health_percentage > right.health_percentage;
|
||||||
|
end);
|
||||||
|
else
|
||||||
|
table.sort(_displayed_static_monsters, function(left, right)
|
||||||
|
return left.health_percentage < right.health_percentage;
|
||||||
|
end);
|
||||||
|
end
|
||||||
|
elseif cached_config.type == "Distance" then
|
||||||
|
if cached_config.reversed_order then
|
||||||
|
table.sort(_displayed_static_monsters, function(left, right)
|
||||||
|
return left.distance > right.distance;
|
||||||
|
end);
|
||||||
|
else
|
||||||
|
table.sort(_displayed_static_monsters, function(left, right)
|
||||||
|
return left.distance < right.distance;
|
||||||
|
end);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return _displayed_static_monsters;
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.update_highlighted_monster(large_monster_list, autohighlight_config)
|
||||||
|
local monster_id_shift = 0;
|
||||||
|
local _highlighted_monster = nil;
|
||||||
|
|
||||||
|
large_monster.update_highlighted_id();
|
||||||
|
|
||||||
|
if large_monster.highlighted_id == -1 then
|
||||||
|
highlighted_monster = nil;
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
|
for i, monster in ipairs(large_monster_list) do
|
||||||
|
if monster.dead_or_captured or not monster.is_disp_icon_mini_map then
|
||||||
|
monster_id_shift = monster_id_shift + 1;
|
||||||
|
goto continue;
|
||||||
|
end
|
||||||
|
|
||||||
|
if not autohighlight_config.enabled then
|
||||||
|
if i - 1 == large_monster.highlighted_id + monster_id_shift then
|
||||||
|
_highlighted_monster = monster;
|
||||||
|
goto continue;
|
||||||
|
end
|
||||||
|
|
||||||
|
goto continue;
|
||||||
|
end
|
||||||
|
|
||||||
|
if _highlighted_monster == nil then
|
||||||
|
_highlighted_monster = monster;
|
||||||
|
goto continue;
|
||||||
|
end
|
||||||
|
|
||||||
|
if autohighlight_config.mode == "Farthest" and monster.distance > _highlighted_monster.distance then
|
||||||
|
_highlighted_monster = monster;
|
||||||
|
goto continue;
|
||||||
|
end
|
||||||
|
|
||||||
|
if autohighlight_config.mode == "Lowest Health" and monster.health < _highlighted_monster.health then
|
||||||
|
_highlighted_monster = monster;
|
||||||
|
goto continue;
|
||||||
|
end
|
||||||
|
|
||||||
|
if autohighlight_config.mode == "Highest Health" and monster.health > _highlighted_monster.health then
|
||||||
|
_highlighted_monster = monster;
|
||||||
|
goto continue;
|
||||||
|
end
|
||||||
|
|
||||||
|
if autohighlight_config.mode == "Lowest Health Percentage" and monster.health_percentage < _highlighted_monster.health_percentage then
|
||||||
|
_highlighted_monster = monster;
|
||||||
|
goto continue;
|
||||||
|
end
|
||||||
|
|
||||||
|
if autohighlight_config.mode == "Highest Health Percentage" and monster.health_percentage > _highlighted_monster.health_percentage then
|
||||||
|
_highlighted_monster = monster;
|
||||||
|
goto continue;
|
||||||
|
end
|
||||||
|
|
||||||
|
if monster.distance < _highlighted_monster.distance then
|
||||||
|
_highlighted_monster = monster;
|
||||||
|
end
|
||||||
|
|
||||||
|
::continue::
|
||||||
|
end
|
||||||
|
|
||||||
|
highlighted_monster = _highlighted_monster;
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.draw(dynamic_enabled, static_enabled, highlighted_enabled)
|
||||||
|
local cached_config = config.current_config.large_monster_UI;
|
||||||
|
|
||||||
|
if dynamic_enabled then
|
||||||
|
local success = pcall(this.draw_dynamic, cached_config);
|
||||||
|
if not success then
|
||||||
|
error_handler.report("large_monster_UI.draw", "Dynamic Large Monster drawing function threw an exception");
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if highlighted_enabled then
|
||||||
|
local success = pcall(this.draw_highlighted, cached_config);
|
||||||
|
if not success then
|
||||||
|
error_handler.report("large_monster_UI.draw", "Highlighted Large Monster drawing function threw an exception");
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if static_enabled then
|
||||||
|
local success = pcall(this.draw_static, cached_config);
|
||||||
|
if not success then
|
||||||
|
error_handler.report("large_monster_UI.draw", "Static Large Monster drawing function threw an exception");
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.draw_dynamic(cached_config)
|
||||||
|
cached_config = cached_config.dynamic;
|
||||||
|
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
|
||||||
|
|
||||||
|
local i = 0;
|
||||||
|
for _, monster in ipairs(displayed_dynamic_monsters) do
|
||||||
local world_offset = Vector3f.new(cached_config.world_offset.x, cached_config.world_offset.y, cached_config.world_offset.z);
|
local world_offset = Vector3f.new(cached_config.world_offset.x, cached_config.world_offset.y, cached_config.world_offset.z);
|
||||||
|
local position_on_screen = draw.world_to_screen(monster.position + world_offset);
|
||||||
position_on_screen = draw.world_to_screen(monster.position + world_offset);
|
|
||||||
|
|
||||||
if position_on_screen == nil then
|
if position_on_screen == nil then
|
||||||
goto continue;
|
goto continue;
|
||||||
@@ -205,84 +344,27 @@ function this.draw_dynamic(displayed_monsters, highlighted_monster, cached_confi
|
|||||||
position_on_screen.y = position_on_screen.y + cached_config.viewport_offset.y * global_scale_modifier;
|
position_on_screen.y = position_on_screen.y + cached_config.viewport_offset.y * global_scale_modifier;
|
||||||
|
|
||||||
local opacity_scale = 1;
|
local opacity_scale = 1;
|
||||||
if monster.distance > cached_config.settings.max_distance then
|
|
||||||
goto continue;
|
|
||||||
end
|
|
||||||
|
|
||||||
if cached_config.settings.opacity_falloff then
|
if cached_config.settings.opacity_falloff then
|
||||||
|
monster.distance = (players.myself_position - monster.position):length();
|
||||||
opacity_scale = 1 - (monster.distance / cached_config.settings.max_distance);
|
opacity_scale = 1 - (monster.distance / cached_config.settings.max_distance);
|
||||||
end
|
end
|
||||||
|
|
||||||
large_monster.draw(monster, "dynamic", cached_config, position_on_screen, opacity_scale);
|
large_monster.draw(monster, "dynamic_UI", cached_config, position_on_screen, opacity_scale);
|
||||||
|
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function this.draw_static(displayed_monsters, highlighted_monster, cached_config)
|
function this.draw_static(cached_config)
|
||||||
cached_config = cached_config.static;
|
cached_config = cached_config.static;
|
||||||
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
|
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
|
||||||
|
|
||||||
-- sort here
|
|
||||||
if cached_config.sorting.type == "Normal" and cached_config.sorting.reversed_order then
|
|
||||||
local reversed_monsters = {};
|
|
||||||
for i = #displayed_monsters, 1, -1 do
|
|
||||||
table.insert(reversed_monsters, displayed_monsters[i]);
|
|
||||||
end
|
|
||||||
|
|
||||||
displayed_monsters = reversed_monsters;
|
|
||||||
|
|
||||||
elseif cached_config.sorting.type == "Health" then
|
|
||||||
if cached_config.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 cached_config.sorting.type == "Health Percentage" then
|
|
||||||
if cached_config.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
|
|
||||||
elseif cached_config.sorting.type == "Distance" then
|
|
||||||
if cached_config.sorting.reversed_order then
|
|
||||||
table.sort(displayed_monsters, function(left, right)
|
|
||||||
return left.distance > right.distance;
|
|
||||||
end);
|
|
||||||
else
|
|
||||||
table.sort(displayed_monsters, function(left, right)
|
|
||||||
return left.distance < right.distance;
|
|
||||||
end);
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local position_on_screen = screen.calculate_absolute_coordinates(cached_config.position);
|
local position_on_screen = screen.calculate_absolute_coordinates(cached_config.position);
|
||||||
|
|
||||||
local i = 0;
|
local i = 0;
|
||||||
for _, monster in ipairs(displayed_monsters) do
|
for _, monster in ipairs(displayed_static_monsters) do
|
||||||
if monster.dead_or_captured and cached_config.settings.hide_dead_or_captured then
|
|
||||||
goto continue;
|
|
||||||
end
|
|
||||||
|
|
||||||
if monster == highlighted_monster then
|
|
||||||
if not cached_config.settings.render_highlighted_monster then
|
|
||||||
goto continue;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if not cached_config.settings.render_not_highlighted_monsters then
|
|
||||||
goto continue;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local monster_position_on_screen = {
|
local monster_position_on_screen = {
|
||||||
x = position_on_screen.x,
|
x = position_on_screen.x,
|
||||||
y = position_on_screen.y
|
y = position_on_screen.y
|
||||||
@@ -294,27 +376,23 @@ function this.draw_static(displayed_monsters, highlighted_monster, cached_config
|
|||||||
monster_position_on_screen.y = monster_position_on_screen.y + cached_config.spacing.y * i * global_scale_modifier;
|
monster_position_on_screen.y = monster_position_on_screen.y + cached_config.spacing.y * i * global_scale_modifier;
|
||||||
end
|
end
|
||||||
|
|
||||||
large_monster.draw(monster, "static", cached_config, monster_position_on_screen, 1);
|
large_monster.draw(monster, "static_UI", cached_config, monster_position_on_screen, 1);
|
||||||
|
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function this.draw_highlighted(monster, cached_config)
|
function this.draw_highlighted(cached_config)
|
||||||
cached_config = cached_config.highlighted;
|
if highlighted_monster == nil then
|
||||||
|
|
||||||
if monster == nil then
|
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
cached_config = cached_config.highlighted;
|
||||||
|
|
||||||
local position_on_screen = screen.calculate_absolute_coordinates(cached_config.position);
|
local position_on_screen = screen.calculate_absolute_coordinates(cached_config.position);
|
||||||
|
|
||||||
if monster.dead_or_captured then
|
large_monster.draw(highlighted_monster, "highlighted_UI", cached_config, position_on_screen, 1);
|
||||||
return;
|
|
||||||
end
|
|
||||||
|
|
||||||
large_monster.draw(monster, "highlighted", cached_config, position_on_screen, 1);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function this.init_dependencies()
|
function this.init_dependencies()
|
||||||
|
|||||||
@@ -47,82 +47,96 @@ local enemy_manager_type_def = sdk.find_type_definition("snow.enemy.EnemyManager
|
|||||||
local get_zako_enemy_count_method = enemy_manager_type_def:get_method("getZakoEnemyCount");
|
local get_zako_enemy_count_method = enemy_manager_type_def:get_method("getZakoEnemyCount");
|
||||||
local get_zako_enemy_method = enemy_manager_type_def:get_method("getZakoEnemy");
|
local get_zako_enemy_method = enemy_manager_type_def:get_method("getZakoEnemy");
|
||||||
|
|
||||||
function this.draw()
|
local displayed_monsters = {};
|
||||||
if singletons.enemy_manager == nil then
|
|
||||||
|
function this.update()
|
||||||
|
local cached_config = config.current_config.small_monster_UI;
|
||||||
|
|
||||||
|
if cached_config.dynamic_positioning.enabled and cached_config.dynamic_positioning.max_distance == 0 then
|
||||||
|
displayed_monsters = {};
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
local cached_config = config.current_config.small_monster_UI;
|
local _displayed_monsters = {};
|
||||||
|
|
||||||
local displayed_monsters = {};
|
|
||||||
|
|
||||||
for enemy, monster in pairs(small_monster.list) do
|
for enemy, monster in pairs(small_monster.list) do
|
||||||
|
|
||||||
if monster.dead_or_captured and cached_config.settings.hide_dead_or_captured then
|
if monster.dead_or_captured and cached_config.settings.hide_dead_or_captured then
|
||||||
goto continue;
|
goto continue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
table.insert(displayed_monsters, monster);
|
monster.distance = (players.myself_position - monster.position):length();
|
||||||
|
if monster.distance > cached_config.dynamic_positioning.max_distance then
|
||||||
|
goto continue;
|
||||||
|
end
|
||||||
|
table.insert(_displayed_monsters, monster);
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
|
|
||||||
if cached_config.dynamic_positioning.enabled
|
displayed_monsters = this.sort_monsters(_displayed_monsters, cached_config);
|
||||||
or (not cached_config.dynamic_positioning.enabled and cached_config.static_sorting.type == "Distance") then
|
end
|
||||||
for _, monster in ipairs(displayed_monsters) do
|
|
||||||
monster.distance = (players.myself_position - monster.position):length();
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
function this.sort_monsters(_displayed_monsters, cached_config)
|
||||||
if not cached_config.dynamic_positioning.enabled then
|
if not cached_config.dynamic_positioning.enabled then
|
||||||
-- sort here
|
|
||||||
if cached_config.static_sorting.type == "Normal" and cached_config.static_sorting.reversed_order then
|
if cached_config.static_sorting.type == "Normal" and cached_config.static_sorting.reversed_order then
|
||||||
local reversed_monsters = {};
|
local reversed_monsters = {};
|
||||||
for i = #displayed_monsters, 1, -1 do
|
for i = #_displayed_monsters, 1, -1 do
|
||||||
table.insert(reversed_monsters, displayed_monsters[i]);
|
table.insert(reversed_monsters, _displayed_monsters[i]);
|
||||||
end
|
end
|
||||||
displayed_monsters = reversed_monsters;
|
_displayed_monsters = reversed_monsters;
|
||||||
|
|
||||||
elseif cached_config.static_sorting.type == "Health" then
|
elseif cached_config.static_sorting.type == "Health" then
|
||||||
if cached_config.static_sorting.reversed_order then
|
if cached_config.static_sorting.reversed_order then
|
||||||
table.sort(displayed_monsters, function(left, right)
|
table.sort(_displayed_monsters, function(left, right)
|
||||||
return left.health > right.health;
|
return left.health > right.health;
|
||||||
end);
|
end);
|
||||||
else
|
else
|
||||||
table.sort(displayed_monsters, function(left, right)
|
table.sort(_displayed_monsters, function(left, right)
|
||||||
return left.health < right.health;
|
return left.health < right.health;
|
||||||
end);
|
end);
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif cached_config.static_sorting.type == "Health Percentage" then
|
elseif cached_config.static_sorting.type == "Health Percentage" then
|
||||||
if cached_config.static_sorting.reversed_order then
|
if cached_config.static_sorting.reversed_order then
|
||||||
table.sort(displayed_monsters, function(left, right)
|
table.sort(_displayed_monsters, function(left, right)
|
||||||
return left.health_percentage > right.health_percentage;
|
return left.health_percentage > right.health_percentage;
|
||||||
end);
|
end);
|
||||||
else
|
else
|
||||||
table.sort(displayed_monsters, function(left, right)
|
table.sort(_displayed_monsters, function(left, right)
|
||||||
return left.health_percentage < right.health_percentage;
|
return left.health_percentage < right.health_percentage;
|
||||||
end);
|
end);
|
||||||
end
|
end
|
||||||
elseif cached_config.static_sorting.type == "Distance" then
|
elseif cached_config.static_sorting.type == "Distance" then
|
||||||
if cached_config.static_sorting.reversed_order then
|
if cached_config.static_sorting.reversed_order then
|
||||||
table.sort(displayed_monsters, function(left, right)
|
table.sort(_displayed_monsters, function(left, right)
|
||||||
return left.distance > right.distance;
|
return left.distance > right.distance;
|
||||||
end);
|
end);
|
||||||
else
|
else
|
||||||
table.sort(displayed_monsters, function(left, right)
|
table.sort(_displayed_monsters, function(left, right)
|
||||||
return left.distance < right.distance;
|
return left.distance < right.distance;
|
||||||
end);
|
end);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return _displayed_monsters;
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.draw()
|
||||||
|
local cached_config = config.current_config.small_monster_UI;
|
||||||
|
|
||||||
|
local is_dynamic_positioning_enabled = cached_config.dynamic_positioning.enabled;
|
||||||
|
|
||||||
local i = 0;
|
local i = 0;
|
||||||
for _, monster in ipairs(displayed_monsters) do
|
for _, monster in ipairs(displayed_monsters) do
|
||||||
local position_on_screen;
|
local position_on_screen;
|
||||||
|
|
||||||
if cached_config.dynamic_positioning.enabled then
|
if is_dynamic_positioning_enabled then
|
||||||
local world_offset = Vector3f.new(cached_config.dynamic_positioning.world_offset.x,
|
local world_offset = Vector3f.new(
|
||||||
|
cached_config.dynamic_positioning.world_offset.x,
|
||||||
cached_config.dynamic_positioning.world_offset.y,
|
cached_config.dynamic_positioning.world_offset.y,
|
||||||
cached_config.dynamic_positioning.world_offset.z);
|
cached_config.dynamic_positioning.world_offset.z
|
||||||
|
);
|
||||||
|
|
||||||
position_on_screen = draw.world_to_screen(monster.position + world_offset);
|
position_on_screen = draw.world_to_screen(monster.position + world_offset);
|
||||||
|
|
||||||
@@ -136,25 +150,15 @@ function this.draw()
|
|||||||
position_on_screen = screen.calculate_absolute_coordinates(cached_config.static_position);
|
position_on_screen = screen.calculate_absolute_coordinates(cached_config.static_position);
|
||||||
if cached_config.settings.orientation == "Horizontal" then
|
if cached_config.settings.orientation == "Horizontal" then
|
||||||
position_on_screen.x = position_on_screen.x + cached_config.static_spacing.x * i;
|
position_on_screen.x = position_on_screen.x + cached_config.static_spacing.x * i;
|
||||||
|
|
||||||
else
|
else
|
||||||
position_on_screen.y = position_on_screen.y + cached_config.static_spacing.y * i;
|
position_on_screen.y = position_on_screen.y + cached_config.static_spacing.y * i;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local opacity_scale = 1;
|
local opacity_scale = 1;
|
||||||
if cached_config.dynamic_positioning.enabled then
|
if is_dynamic_positioning_enabled and cached_config.dynamic_positioning.opacity_falloff then
|
||||||
if cached_config.dynamic_positioning.max_distance == 0 then
|
monster.distance = (players.myself_position - monster.position):length();
|
||||||
return;
|
opacity_scale = 1 - (monster.distance / cached_config.dynamic_positioning.max_distance);
|
||||||
end
|
|
||||||
|
|
||||||
if monster.distance > cached_config.dynamic_positioning.max_distance then
|
|
||||||
goto continue;
|
|
||||||
end
|
|
||||||
|
|
||||||
if cached_config.dynamic_positioning.opacity_falloff then
|
|
||||||
opacity_scale = 1 - (monster.distance / cached_config.dynamic_positioning.max_distance);
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
small_monster.draw(monster, cached_config, position_on_screen, opacity_scale);
|
small_monster.draw(monster, cached_config, position_on_screen, opacity_scale);
|
||||||
|
|||||||
Reference in New Issue
Block a user