2 Commits

Author SHA1 Message Date
GreenComfyTea
a84c698a4b remove comments 2022-12-02 13:59:06 +02:00
GreenComfyTea
f0eb9673b0 Fix freeze_displayed_players on quest end
...if module visibility is disabled during the quest
2022-12-02 13:49:14 +02:00
3 changed files with 20 additions and 12 deletions

View File

@@ -188,7 +188,7 @@ local function main_loop()
player.update_player_list(quest_status.index >= 2); player.update_player_list(quest_status.index >= 2);
non_players.update_servant_list(); non_players.update_servant_list();
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;

View File

@@ -1,5 +1,7 @@
local table_helpers = {}; local table_helpers = {};
local next = next;
function table_helpers.deep_copy(original, copies) function table_helpers.deep_copy(original, copies)
copies = copies or {}; copies = copies or {};
local original_type = type(original); local original_type = type(original);
@@ -25,9 +27,9 @@ function table_helpers.deep_copy(original, copies)
return copy; return copy;
end end
function table_helpers.find_index(table, value, nullable) function table_helpers.find_index(table_, value, nullable)
for i = 1, #table do for i = 1, #table_ do
if table[i] == value then if table_[i] == value then
return i; return i;
end end
end end
@@ -43,8 +45,8 @@ function table_helpers.merge(...)
local tables_to_merge = { ... }; local tables_to_merge = { ... };
assert(#tables_to_merge > 1, "There should be at least two tables to merge them"); assert(#tables_to_merge > 1, "There should be at least two tables to merge them");
for key, table in ipairs(tables_to_merge) do for key, table_ in ipairs(tables_to_merge) do
assert(type(table) == "table", string.format("Expected a table as function parameter %d", key)); assert(type(table_) == "table", string.format("Expected a table as function parameter %d", key));
end end
local result = table_helpers.deep_copy(tables_to_merge[1]); local result = table_helpers.deep_copy(tables_to_merge[1]);
@@ -65,10 +67,10 @@ function table_helpers.merge(...)
return result; return result;
end end
function table_helpers.tostring(table) function table_helpers.tostring(table_)
if type(table) == "table" then if type(table_) == "table" then
local s = "{ \n"; local s = "{ \n";
for k, v in pairs(table) do for k, v in pairs(table_) do
if type(k) ~= "number" then if type(k) ~= "number" then
k = "\"" .. k .. "\""; k = "\"" .. k .. "\"";
end end
@@ -76,11 +78,16 @@ function table_helpers.tostring(table)
end end
return s .. "} \n"; return s .. "} \n";
else else
return tostring(table); return tostring(table_);
end end
end end
function table_helpers.is_empty(table_)
return next(table_) == nil;
end
function table_helpers.init_module() function table_helpers.init_module()
end end
return table_helpers; return table_helpers;

View File

@@ -83,7 +83,8 @@ function damage_meter_UI.draw()
end end
local quest_players = {}; local quest_players = {};
if damage_meter_UI.freeze_displayed_players and damage_meter_UI.last_displayed_players ~= {} then
if damage_meter_UI.freeze_displayed_players and not table_helpers.is_empty(damage_meter_UI.last_displayed_players) then
quest_players = damage_meter_UI.last_displayed_players; 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 elseif quest_status.flow_state == quest_status.flow_states.IN_LOBBY or quest_status.flow_state == quest_status.flow_states.IN_TRAINING_AREA then
local player_info_list = hunter_info_field:get_data(singletons.lobby_manager); local player_info_list = hunter_info_field:get_data(singletons.lobby_manager);
@@ -93,7 +94,7 @@ function damage_meter_UI.draw()
quest_players = damage_meter_UI.get_players(player_info_list); quest_players = damage_meter_UI.get_players(player_info_list);
end 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 if #quest_players ~= 0 then
-- sort here -- sort here
if cached_config.sorting.type == "Normal" then if cached_config.sorting.type == "Normal" then