Release v1.11

1) Cache config access function-wide where possible;
2) Break and Sever values added to parts;
3) Hooks are now applied in init_module instead of global space;
4) Added checks for submodule (health, stamina, etc) visibility. If not visible, do not pull data.
This commit is contained in:
GreenComfyTea
2022-06-20 13:01:10 +03:00
parent 286c54aa55
commit f64d6c84d3
31 changed files with 1617 additions and 1539 deletions

View File

@@ -23,6 +23,8 @@ local hunter_info_type_def = sdk.find_type_definition("snow.LobbyManager.HunterI
local member_index_field = hunter_info_type_def:get_field("_memberIndex");
function damage_meter_UI.get_players(player_info_list)
local cached_config = config.current_config.damage_meter_UI;
-- other players
if player_info_list == nil then
customization_menu.status = "No player info list";
@@ -52,7 +54,7 @@ function damage_meter_UI.get_players(player_info_list)
local _player = player.get_player(player_id);
if _player ~= nil then
if player_id == player.myself.id and config.current_config.damage_meter_UI.settings.my_damage_bar_location ~= "Normal" then
if player_id == player.myself.id and cached_config.settings.my_damage_bar_location ~= "Normal" then
goto continue;
end
table.insert(quest_players, _player);
@@ -65,11 +67,15 @@ function damage_meter_UI.get_players(player_info_list)
end
function damage_meter_UI.draw()
local cached_config = config.current_config.damage_meter_UI;
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
if player.total.display.total_damage == 0 and config.current_config.damage_meter_UI.settings.hide_module_if_total_damage_is_zero then
if player.total.display.total_damage == 0 and cached_config.settings.hide_module_if_total_damage_is_zero then
return;
end
local quest_players = {};
if damage_meter_UI.freeze_displayed_players and damage_meter_UI.last_displayed_players ~= {} then
quest_players = damage_meter_UI.last_displayed_players;
@@ -84,15 +90,15 @@ function damage_meter_UI.draw()
if not damage_meter_UI.freeze_displayed_players then
if #quest_players ~= 0 then
-- sort here
if config.current_config.damage_meter_UI.sorting.type == "Normal" and config.current_config.damage_meter_UI.sorting.reversed_order then
if cached_config.sorting.type == "Normal" and cached_config.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.current_config.damage_meter_UI.sorting.type == "DPS" then
if config.current_config.damage_meter_UI.sorting.reversed_order then
elseif cached_config.sorting.type == "DPS" then
if cached_config.sorting.reversed_order then
table.sort(quest_players, function(left, right)
return left.dps < right.dps;
end);
@@ -102,7 +108,7 @@ function damage_meter_UI.draw()
end);
end
else
if config.current_config.damage_meter_UI.sorting.reversed_order then
if cached_config.sorting.reversed_order then
table.sort(quest_players, function(left, right)
return left.display.total_damage < right.display.total_damage;
end);
@@ -114,9 +120,9 @@ function damage_meter_UI.draw()
end
end
if config.current_config.damage_meter_UI.settings.my_damage_bar_location == "First" then
if cached_config.settings.my_damage_bar_location == "First" then
table.insert(quest_players, 1, player.myself);
elseif config.current_config.damage_meter_UI.settings.my_damage_bar_location == "Last" then
elseif cached_config.settings.my_damage_bar_location == "Last" then
table.insert(quest_players, #quest_players + 1, player.myself);
elseif #player.list == 0 then
table.insert(quest_players, player.myself);
@@ -137,19 +143,19 @@ function damage_meter_UI.draw()
end
-- draw
local position_on_screen = screen.calculate_absolute_coordinates(config.current_config.damage_meter_UI.position);
local position_on_screen = screen.calculate_absolute_coordinates(cached_config.position);
for _, _player in ipairs(quest_players) do
if _player.display.total_damage == 0 and config.current_config.damage_meter_UI.settings.hide_player_if_player_damage_is_zero then
if _player.display.total_damage == 0 and cached_config.settings.hide_player_if_player_damage_is_zero then
goto continue1
end
player.draw(_player, position_on_screen, 1, top_damage, top_dps);
if config.current_config.damage_meter_UI.settings.orientation == "Horizontal" then
position_on_screen.x = position_on_screen.x + config.current_config.damage_meter_UI.spacing.x * config.current_config.global_settings.modifiers.global_scale_modifier;
if cached_config.settings.orientation == "Horizontal" then
position_on_screen.x = position_on_screen.x + cached_config.spacing.x * global_scale_modifier;
else
position_on_screen.y = position_on_screen.y + config.current_config.damage_meter_UI.spacing.y * config.current_config.global_settings.modifiers.global_scale_modifier;
position_on_screen.y = position_on_screen.y + cached_config.spacing.y * global_scale_modifier;
end
::continue1::
@@ -157,12 +163,12 @@ function damage_meter_UI.draw()
end
-- draw total damage
if config.current_config.damage_meter_UI.settings.hide_total_if_total_damage_is_zero and player.total.display.total_damage == 0 then
if cached_config.settings.hide_total_if_total_damage_is_zero and player.total.display.total_damage == 0 then
return;
end
if not config.current_config.damage_meter_UI.settings.total_damage_offset_is_relative then
position_on_screen = screen.calculate_absolute_coordinates(config.current_config.damage_meter_UI.position);
if not cached_config.settings.total_damage_offset_is_relative then
position_on_screen = screen.calculate_absolute_coordinates(cached_config.position);
end
player.draw_total(position_on_screen, 1);

View File

@@ -21,19 +21,22 @@ function env_creature_UI.draw()
return;
end
local cached_config = config.current_config.endemic_life_UI;
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
for _, creature in pairs(env_creature.list) do
if config.current_config.endemic_life_UI.settings.max_distance == 0 then
if cached_config.settings.max_distance == 0 then
break;
end
if config.current_config.endemic_life_UI.settings.hide_inactive_creatures and creature.is_inactive then
if cached_config.settings.hide_inactive_creatures and creature.is_inactive then
goto continue;
end
local position_on_screen = {};
local world_offset = Vector3f.new(config.current_config.endemic_life_UI.world_offset.x, config.current_config.endemic_life_UI.world_offset.y, config.current_config.endemic_life_UI.world_offset.z);
local world_offset = Vector3f.new(cached_config.world_offset.x, cached_config.world_offset.y, cached_config.world_offset.z);
position_on_screen = draw.world_to_screen(creature.position + world_offset);
@@ -41,19 +44,19 @@ function env_creature_UI.draw()
goto continue;
end
position_on_screen.x = position_on_screen.x + config.current_config.endemic_life_UI.viewport_offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
position_on_screen.y = position_on_screen.y + config.current_config.endemic_life_UI.viewport_offset.y * config.current_config.global_settings.modifiers.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;
creature.distance = (player.myself_position - creature.position):length();
local opacity_scale = 1;
if creature.distance > config.current_config.endemic_life_UI.settings.max_distance then
if creature.distance > cached_config.settings.max_distance then
goto continue;
end
if config.current_config.endemic_life_UI.settings.opacity_falloff then
opacity_scale = 1 - (creature.distance / config.current_config.endemic_life_UI.settings.max_distance);
if cached_config.settings.opacity_falloff then
opacity_scale = 1 - (creature.distance / cached_config.settings.max_distance);
end

View File

@@ -93,58 +93,64 @@ function large_monster_UI.draw(dynamic_enabled, static_enabled, highlighted_enab
end
function large_monster_UI.draw_dynamic(displayed_monsters, highlighted_monster)
local cached_config = config.current_config.large_monster_UI.dynamic;
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
local i = 0;
for _, monster in ipairs(displayed_monsters) do
if config.current_config.large_monster_UI.dynamic.settings.max_distance == 0 then
break;
end
if monster.dead_or_captured and config.current_config.large_monster_UI.dynamic.settings.hide_dead_or_captured then
goto continue;
end
if monster == highlighted_monster then
if not config.current_config.large_monster_UI.dynamic.settings.render_highlighted_monster then
goto continue;
end
else
if not config.current_config.large_monster_UI.dynamic.settings.render_not_highlighted_monsters then
goto continue;
end
end
local position_on_screen = {};
local world_offset = Vector3f.new(config.current_config.large_monster_UI.dynamic.world_offset.x, config.current_config.large_monster_UI.dynamic.world_offset.y, config.current_config.large_monster_UI.dynamic.world_offset.z);
position_on_screen = draw.world_to_screen(monster.position + world_offset);
if position_on_screen == nil then
goto continue;
end
position_on_screen.x = position_on_screen.x + config.current_config.large_monster_UI.dynamic.viewport_offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
position_on_screen.y = position_on_screen.y + config.current_config.large_monster_UI.dynamic.viewport_offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
local opacity_scale = 1;
if monster.distance > config.current_config.large_monster_UI.dynamic.settings.max_distance then
goto continue;
end
if config.current_config.large_monster_UI.dynamic.settings.opacity_falloff then
opacity_scale = 1 - (monster.distance / config.current_config.large_monster_UI.dynamic.settings.max_distance);
end
large_monster.draw_dynamic(monster, position_on_screen, opacity_scale);
i = i + 1;
::continue::
for _, monster in ipairs(displayed_monsters) do
if cached_config.settings.max_distance == 0 then
break;
end
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 position_on_screen = {};
local world_offset = Vector3f.new(cached_config.world_offset.x, cached_config.world_offset.y, cached_config.world_offset.z);
position_on_screen = draw.world_to_screen(monster.position + world_offset);
if position_on_screen == nil then
goto continue;
end
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;
local opacity_scale = 1;
if monster.distance > cached_config.settings.max_distance then
goto continue;
end
if cached_config.settings.opacity_falloff then
opacity_scale = 1 - (monster.distance / cached_config.settings.max_distance);
end
large_monster.draw_dynamic(monster, position_on_screen, opacity_scale);
i = i + 1;
::continue::
end
end
function large_monster_UI.draw_static(displayed_monsters, highlighted_monster)
local cached_config = config.current_config.large_monster_UI.static;
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
-- sort here
if config.current_config.large_monster_UI.static.sorting.type == "Normal" and config.current_config.large_monster_UI.static.sorting.reversed_order then
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]);
@@ -152,8 +158,8 @@ function large_monster_UI.draw_static(displayed_monsters, highlighted_monster)
displayed_monsters = reversed_monsters;
elseif config.current_config.large_monster_UI.static.sorting.type == "Health" then
if config.current_config.large_monster_UI.static.sorting.reversed_order then
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);
@@ -162,8 +168,8 @@ function large_monster_UI.draw_static(displayed_monsters, highlighted_monster)
return left.health < right.health;
end);
end
elseif config.current_config.large_monster_UI.static.sorting.type == "Health Percentage" then
if config.current_config.large_monster_UI.static.sorting.reversed_order then
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);
@@ -172,8 +178,8 @@ function large_monster_UI.draw_static(displayed_monsters, highlighted_monster)
return left.health_percentage < right.health_percentage;
end);
end
elseif config.current_config.large_monster_UI.static.sorting.type == "Distance" then
if config.current_config.large_monster_UI.static.sorting.reversed_order then
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);
@@ -184,20 +190,20 @@ function large_monster_UI.draw_static(displayed_monsters, highlighted_monster)
end
end
local position_on_screen = screen.calculate_absolute_coordinates(config.current_config.large_monster_UI.static.position);
local position_on_screen = screen.calculate_absolute_coordinates(cached_config.position);
local i = 0;
for _, monster in ipairs(displayed_monsters) do
if monster.dead_or_captured and config.current_config.large_monster_UI.static.settings.hide_dead_or_captured then
if monster.dead_or_captured and cached_config.settings.hide_dead_or_captured then
goto continue;
end
if monster == highlighted_monster then
if not config.current_config.large_monster_UI.static.settings.render_highlighted_monster then
if not cached_config.settings.render_highlighted_monster then
goto continue;
end
else
if not config.current_config.large_monster_UI.static.settings.render_not_highlighted_monsters then
if not cached_config.settings.render_not_highlighted_monsters then
goto continue;
end
end
@@ -207,10 +213,10 @@ function large_monster_UI.draw_static(displayed_monsters, highlighted_monster)
y = position_on_screen.y
}
if config.current_config.large_monster_UI.static.settings.orientation == "Horizontal" then
monster_position_on_screen.x = monster_position_on_screen.x + config.current_config.large_monster_UI.static.spacing.x * i * config.current_config.global_settings.modifiers.global_scale_modifier;
if cached_config.settings.orientation == "Horizontal" then
monster_position_on_screen.x = monster_position_on_screen.x + cached_config.spacing.x * i * global_scale_modifier;
else
monster_position_on_screen.y = monster_position_on_screen.y + config.current_config.large_monster_UI.static.spacing.y * i * config.current_config.global_settings.modifiers.global_scale_modifier;
monster_position_on_screen.y = monster_position_on_screen.y + cached_config.spacing.y * i * global_scale_modifier;
end
large_monster.draw_static(monster, monster_position_on_screen, 1);
@@ -221,13 +227,15 @@ function large_monster_UI.draw_static(displayed_monsters, highlighted_monster)
end
function large_monster_UI.draw_highlighted(monster)
local cached_config = config.current_config.large_monster_UI.highlighted;
if monster == nil then
return;
end
local position_on_screen = screen.calculate_absolute_coordinates(config.current_config.large_monster_UI.highlighted.position);
local position_on_screen = screen.calculate_absolute_coordinates(cached_config.position);
if monster.dead_or_captured and config.current_config.large_monster_UI.highlighted.settings.hide_dead_or_captured then
if monster.dead_or_captured and cached_config.settings.hide_dead_or_captured then
return;
end

View File

@@ -19,6 +19,8 @@ function small_monster_UI.draw()
return;
end
local cached_config = config.current_config.small_monster_UI;
local displayed_monsters = {};
local enemy_count = get_zako_enemy_count_method:call(singletons.enemy_manager);
@@ -40,7 +42,7 @@ function small_monster_UI.draw()
goto continue;
end
if monster.dead_or_captured and config.current_config.small_monster_UI.settings.hide_dead_or_captured then
if monster.dead_or_captured and cached_config.settings.hide_dead_or_captured then
goto continue;
end
@@ -48,24 +50,24 @@ function small_monster_UI.draw()
::continue::
end
if config.current_config.small_monster_UI.dynamic_positioning.enabled
or (not config.current_config.small_monster_UI.dynamic_positioning.enabled and config.current_config.small_monster_UI.static_sorting.type == "Distance") then
if cached_config.dynamic_positioning.enabled
or (not cached_config.dynamic_positioning.enabled and cached_config.static_sorting.type == "Distance") then
for _, monster in ipairs(displayed_monsters) do
monster.distance = (player.myself_position - monster.position):length();
end
end
if not config.current_config.small_monster_UI.dynamic_positioning.enabled then
if not cached_config.dynamic_positioning.enabled then
-- sort here
if config.current_config.small_monster_UI.static_sorting.type == "Normal" and config.current_config.small_monster_UI.static_sorting.reversed_order then
if cached_config.static_sorting.type == "Normal" and cached_config.static_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 config.current_config.small_monster_UI.static_sorting.type == "Health" then
if config.current_config.small_monster_UI.static_sorting.reversed_order then
elseif cached_config.static_sorting.type == "Health" then
if cached_config.static_sorting.reversed_order then
table.sort(displayed_monsters, function(left, right)
return left.health > right.health;
end);
@@ -75,8 +77,8 @@ function small_monster_UI.draw()
end);
end
elseif config.current_config.small_monster_UI.static_sorting.type == "Health Percentage" then
if config.current_config.small_monster_UI.static_sorting.reversed_order then
elseif cached_config.static_sorting.type == "Health Percentage" then
if cached_config.static_sorting.reversed_order then
table.sort(displayed_monsters, function(left, right)
return left.health_percentage > right.health_percentage;
end);
@@ -85,8 +87,8 @@ function small_monster_UI.draw()
return left.health_percentage < right.health_percentage;
end);
end
elseif config.current_config.small_monster_UI.static_sorting.type == "Distance" then
if config.current_config.small_monster_UI.static_sorting.reversed_order then
elseif cached_config.static_sorting.type == "Distance" then
if cached_config.static_sorting.reversed_order then
table.sort(displayed_monsters, function(left, right)
return left.distance > right.distance;
end);
@@ -102,8 +104,8 @@ function small_monster_UI.draw()
for _, monster in ipairs(displayed_monsters) do
local position_on_screen;
if config.current_config.small_monster_UI.dynamic_positioning.enabled then
local world_offset = Vector3f.new(config.current_config.small_monster_UI.dynamic_positioning.world_offset.x, config.current_config.small_monster_UI.dynamic_positioning.world_offset.y, config.current_config.small_monster_UI.dynamic_positioning.world_offset.z);
if cached_config.dynamic_positioning.enabled then
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.z);
position_on_screen = draw.world_to_screen(monster.position + world_offset);
@@ -111,31 +113,31 @@ function small_monster_UI.draw()
goto continue
end
position_on_screen.x = position_on_screen.x + config.current_config.small_monster_UI.dynamic_positioning.viewport_offset.x;
position_on_screen.y = position_on_screen.y + config.current_config.small_monster_UI.dynamic_positioning.viewport_offset.y;
position_on_screen.x = position_on_screen.x + cached_config.dynamic_positioning.viewport_offset.x;
position_on_screen.y = position_on_screen.y + cached_config.dynamic_positioning.viewport_offset.y;
else
position_on_screen = screen.calculate_absolute_coordinates(config.current_config.small_monster_UI.static_position);
if config.current_config.small_monster_UI.settings.orientation == "Horizontal" then
position_on_screen.x = position_on_screen.x + config.current_config.small_monster_UI.static_spacing.x * i;
position_on_screen = screen.calculate_absolute_coordinates(cached_config.static_position);
if cached_config.settings.orientation == "Horizontal" then
position_on_screen.x = position_on_screen.x + cached_config.static_spacing.x * i;
else
position_on_screen.y = position_on_screen.y + config.current_config.small_monster_UI.static_spacing.y * i;
position_on_screen.y = position_on_screen.y + cached_config.static_spacing.y * i;
end
end
local opacity_scale = 1;
if config.current_config.small_monster_UI.dynamic_positioning.enabled then
if config.current_config.small_monster_UI.dynamic_positioning.max_distance == 0 then
if cached_config.dynamic_positioning.enabled then
if cached_config.dynamic_positioning.max_distance == 0 then
return;
end
if monster.distance > config.current_config.small_monster_UI.dynamic_positioning.max_distance then
if monster.distance > cached_config.dynamic_positioning.max_distance then
goto continue;
end
if config.current_config.small_monster_UI.dynamic_positioning.opacity_falloff then
opacity_scale = 1 - (monster.distance / config.current_config.small_monster_UI.dynamic_positioning.max_distance);
if cached_config.dynamic_positioning.opacity_falloff then
opacity_scale = 1 - (monster.distance / cached_config.dynamic_positioning.max_distance);
end
end

View File

@@ -23,8 +23,10 @@ end
function time_UI.init_UI()
time_UI.label = table_helpers.deep_copy(config.current_config.time_UI.time_label);
time_UI.label.offset.x = time_UI.label.offset.x * config.current_config.global_settings.modifiers.global_scale_modifier;
time_UI.label.offset.y = time_UI.label.offset.y * config.current_config.global_settings.modifiers.global_scale_modifier;
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
time_UI.label.offset.x = time_UI.label.offset.x * global_scale_modifier;
time_UI.label.offset.y = time_UI.label.offset.y * global_scale_modifier;
end
function time_UI.init_module()