Fix freeze_displayed_players on quest end

...if module visibility is disabled during the quest
This commit is contained in:
GreenComfyTea
2022-12-02 13:49:14 +02:00
parent add4cca6f1
commit f0eb9673b0
3 changed files with 26 additions and 12 deletions

View File

@@ -188,7 +188,7 @@ local function main_loop()
player.update_player_list(quest_status.index >= 2);
non_players.update_servant_list();
if quest_status.flow_state == quest_status.flow_states.IN_TRAINING_AREA then
local large_monster_UI_config = config.current_config.large_monster_UI;

View File

@@ -1,5 +1,7 @@
local table_helpers = {};
local next = next;
function table_helpers.deep_copy(original, copies)
copies = copies or {};
local original_type = type(original);
@@ -25,9 +27,9 @@ function table_helpers.deep_copy(original, copies)
return copy;
end
function table_helpers.find_index(table, value, nullable)
for i = 1, #table do
if table[i] == value then
function table_helpers.find_index(table_, value, nullable)
for i = 1, #table_ do
if table_[i] == value then
return i;
end
end
@@ -43,8 +45,8 @@ function table_helpers.merge(...)
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));
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_helpers.deep_copy(tables_to_merge[1]);
@@ -65,10 +67,10 @@ function table_helpers.merge(...)
return result;
end
function table_helpers.tostring(table)
if type(table) == "table" then
function table_helpers.tostring(table_)
if type(table_) == "table" then
local s = "{ \n";
for k, v in pairs(table) do
for k, v in pairs(table_) do
if type(k) ~= "number" then
k = "\"" .. k .. "\"";
end
@@ -76,11 +78,16 @@ function table_helpers.tostring(table)
end
return s .. "} \n";
else
return tostring(table);
return tostring(table_);
end
end
function table_helpers.is_empty(table_)
return next(table_) == nil;
end
function table_helpers.init_module()
end
return table_helpers;

View File

@@ -83,17 +83,24 @@ function damage_meter_UI.draw()
end
local quest_players = {};
if damage_meter_UI.freeze_displayed_players and damage_meter_UI.last_displayed_players ~= {} then
xy = string.format("freeze: %s\nis_empty: %s\n", tostring(damage_meter_UI.freeze_displayed_players), tostring(table_helpers.is_empty(damage_meter_UI.last_displayed_players)));
xy = xy .. table_helpers.tostring(damage_meter_UI.last_displayed_players);
if damage_meter_UI.freeze_displayed_players and not table_helpers.is_empty(damage_meter_UI.last_displayed_players) then
xy = 1;
quest_players = damage_meter_UI.last_displayed_players;
elseif quest_status.flow_state == quest_status.flow_states.IN_LOBBY or quest_status.flow_state == quest_status.flow_states.IN_TRAINING_AREA then
xy = 2;
local player_info_list = hunter_info_field:get_data(singletons.lobby_manager);
quest_players = damage_meter_UI.get_players(player_info_list);
else
xy = 3;
local player_info_list = quest_hunter_info_field:get_data(singletons.lobby_manager);
quest_players = damage_meter_UI.get_players(player_info_list);
end
if not damage_meter_UI.freeze_displayed_players then
if not damage_meter_UI.freeze_displayed_players or table_helpers.is_empty(damage_meter_UI.last_displayed_players) then
if #quest_players ~= 0 then
-- sort here
if cached_config.sorting.type == "Normal" then