mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-24 12:28:03 -08:00
Implement Error Handler
This commit is contained in:
@@ -7,6 +7,7 @@ local consumables;
|
||||
local melody_effects;
|
||||
local screen;
|
||||
local utils;
|
||||
local error_handler;
|
||||
|
||||
local sdk = sdk;
|
||||
local tostring = tostring;
|
||||
@@ -49,23 +50,23 @@ function this.draw()
|
||||
for key, consumable in pairs(consumables.list) do
|
||||
|
||||
if not consumable.is_active then
|
||||
goto continue2;
|
||||
goto continue;
|
||||
end
|
||||
|
||||
table.insert(displayed_buffs, consumable);
|
||||
|
||||
::continue2::
|
||||
::continue::
|
||||
end
|
||||
|
||||
for _, melody_effect in pairs(melody_effects.list) do
|
||||
|
||||
if not melody_effect.is_active then
|
||||
goto continue3;
|
||||
goto continue2;
|
||||
end
|
||||
|
||||
table.insert(displayed_buffs, melody_effect);
|
||||
|
||||
::continue3::
|
||||
::continue2::
|
||||
end
|
||||
|
||||
-- sort
|
||||
@@ -107,7 +108,7 @@ function this.draw()
|
||||
for _, buff in ipairs(displayed_buffs) do
|
||||
|
||||
if not buff.is_active then
|
||||
goto continue4;
|
||||
goto continue3;
|
||||
end
|
||||
|
||||
buffs.draw(buff, buff.buff_UI, position_on_screen, 1);
|
||||
@@ -118,7 +119,7 @@ function this.draw()
|
||||
position_on_screen.y = position_on_screen.y + cached_config.spacing.y * global_scale_modifier;
|
||||
end
|
||||
|
||||
::continue4::
|
||||
::continue3::
|
||||
end
|
||||
end
|
||||
|
||||
@@ -137,6 +138,7 @@ function this.init_dependencies()
|
||||
screen = require("MHR_Overlay.Game_Handler.screen");
|
||||
--drawing = require("MHR_Overlay.UI.drawing");
|
||||
utils = require("MHR_Overlay.Misc.utils");
|
||||
error_handler = require("MHR_Overlay.Misc.error_handler");
|
||||
end
|
||||
|
||||
function this.init_module()
|
||||
|
||||
@@ -10,6 +10,7 @@ local screen;
|
||||
local drawing;
|
||||
local language;
|
||||
local utils;
|
||||
local error_handler;
|
||||
|
||||
local sdk = sdk;
|
||||
local tostring = tostring;
|
||||
@@ -46,17 +47,6 @@ local package = package;
|
||||
this.last_displayed_players = {};
|
||||
this.freeze_displayed_players = false;
|
||||
|
||||
local lobby_manager_type_def = sdk.find_type_definition("snow.LobbyManager");
|
||||
local quest_hunter_info_field = lobby_manager_type_def:get_field("_questHunterInfo");
|
||||
local hunter_info_field = lobby_manager_type_def:get_field("_hunterInfo");
|
||||
|
||||
local quest_hunter_info_type_def = quest_hunter_info_field:get_type();
|
||||
local get_count_method = quest_hunter_info_type_def:get_method("get_Count");
|
||||
local get_item_method = quest_hunter_info_type_def:get_method("get_Item");
|
||||
|
||||
local hunter_info_type_def = sdk.find_type_definition("snow.LobbyManager.HunterInfo");
|
||||
local member_index_field = hunter_info_type_def:get_field("_memberIndex");
|
||||
|
||||
function this.draw()
|
||||
local cached_config = config.current_config.damage_meter_UI;
|
||||
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
|
||||
@@ -116,32 +106,32 @@ function this.draw()
|
||||
for _, player in ipairs(quest_players) do
|
||||
|
||||
if player.display.total_damage == 0 and cached_config.settings.hide_player_if_player_damage_is_zero then
|
||||
goto continue
|
||||
goto continue;
|
||||
end
|
||||
|
||||
if player.type == players.types.myself then
|
||||
if cached_config.settings.hide_myself then
|
||||
goto continue
|
||||
goto continue;
|
||||
end
|
||||
elseif player.type == players.types.servant then
|
||||
if cached_config.settings.hide_servants then
|
||||
goto continue
|
||||
goto continue;
|
||||
end
|
||||
elseif player.type == players.types.other_player then
|
||||
if cached_config.settings.hide_other_players then
|
||||
goto continue
|
||||
goto continue;
|
||||
end
|
||||
elseif player.type == players.types.my_otomo then
|
||||
if not cached_config.settings.show_my_otomos_separately then
|
||||
goto continue
|
||||
goto continue;
|
||||
end
|
||||
elseif player.type == players.types.other_player_otomo then
|
||||
if not cached_config.settings.show_other_player_otomos_separately then
|
||||
goto continue
|
||||
goto continue;
|
||||
end
|
||||
elseif player.type == players.types.servant_otomo then
|
||||
if not cached_config.settings.show_servant_otomos_separately then
|
||||
goto continue
|
||||
goto continue;
|
||||
end
|
||||
end
|
||||
|
||||
@@ -154,7 +144,6 @@ function this.draw()
|
||||
end
|
||||
|
||||
::continue::
|
||||
|
||||
end
|
||||
|
||||
-- draw total damage
|
||||
@@ -186,6 +175,7 @@ function this.init_dependencies()
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
language = require("MHR_Overlay.Misc.language");
|
||||
utils = require("MHR_Overlay.Misc.utils");
|
||||
error_handler = require("MHR_Overlay.Misc.error_handler");
|
||||
end
|
||||
|
||||
function this.init_module()
|
||||
|
||||
@@ -11,6 +11,7 @@ local health_UI_entity;
|
||||
local stamina_UI_entity;
|
||||
local rage_UI_entity;
|
||||
local env_creature;
|
||||
local error_handler;
|
||||
|
||||
local sdk = sdk;
|
||||
local tostring = tostring;
|
||||
@@ -44,8 +45,6 @@ local os = os;
|
||||
local ValueType = ValueType;
|
||||
local package = package;
|
||||
|
||||
local enemy_manager_type_def = sdk.find_type_definition("snow.enemy.EnemyManager");
|
||||
|
||||
function this.draw()
|
||||
if singletons.enemy_manager == nil then
|
||||
return;
|
||||
@@ -57,11 +56,11 @@ function this.draw()
|
||||
for REcreature, creature in pairs(env_creature.list) do
|
||||
|
||||
if cached_config.settings.max_distance == 0 then
|
||||
break
|
||||
break;
|
||||
end
|
||||
|
||||
if cached_config.settings.hide_inactive_creatures and creature.is_inactive then
|
||||
goto continue
|
||||
goto continue;
|
||||
end
|
||||
|
||||
local position_on_screen = {};
|
||||
@@ -72,7 +71,7 @@ function this.draw()
|
||||
position_on_screen = draw.world_to_screen(creature.position + world_offset);
|
||||
|
||||
if position_on_screen == nil then
|
||||
goto continue
|
||||
goto continue;
|
||||
end
|
||||
|
||||
position_on_screen.x = position_on_screen.x + cached_config.viewport_offset.x * global_scale_modifier;
|
||||
@@ -82,7 +81,7 @@ function this.draw()
|
||||
|
||||
local opacity_scale = 1;
|
||||
if creature.distance > cached_config.settings.max_distance then
|
||||
goto continue
|
||||
goto continue;
|
||||
end
|
||||
|
||||
if cached_config.settings.opacity_falloff then
|
||||
@@ -106,6 +105,7 @@ function this.init_dependencies()
|
||||
stamina_UI_entity = require("MHR_Overlay.UI.UI_Entities.stamina_UI_entity");
|
||||
rage_UI_entity = require("MHR_Overlay.UI.UI_Entities.rage_UI_entity");
|
||||
env_creature = require("MHR_Overlay.Endemic_Life.env_creature");
|
||||
error_handler = require("MHR_Overlay.Misc.error_handler");
|
||||
end
|
||||
|
||||
function this.init_module()
|
||||
|
||||
@@ -10,6 +10,7 @@ local drawing;
|
||||
local health_UI_entity;
|
||||
local stamina_UI_entity;
|
||||
local rage_UI_entity;
|
||||
local error_handler;
|
||||
|
||||
local sdk = sdk;
|
||||
local tostring = tostring;
|
||||
@@ -78,6 +79,7 @@ function this.draw(dynamic_enabled, static_enabled, highlighted_enabled)
|
||||
highlighted_id = get_targeting_enemy_index_field:get_data(gui_hud_target_camera);
|
||||
|
||||
if highlighted_id == nil then
|
||||
error_handler.report("large_monster_UI.draw", "Failed to Access Data: highlighted_id");
|
||||
highlighted_id = -1;
|
||||
end
|
||||
end
|
||||
@@ -85,20 +87,21 @@ function this.draw(dynamic_enabled, static_enabled, highlighted_enabled)
|
||||
|
||||
local enemy_count = get_boss_enemy_count_method:call(singletons.enemy_manager);
|
||||
if enemy_count == nil then
|
||||
error_handler.report("large_monster_UI.draw", "Failed to Access Data: enemy_count");
|
||||
return;
|
||||
end
|
||||
|
||||
for i = 0, enemy_count - 1 do
|
||||
local enemy = get_boss_enemy_method:call(singletons.enemy_manager, i);
|
||||
if enemy == nil then
|
||||
customization_menu.status = "No enemy";
|
||||
goto continue
|
||||
error_handler.report("large_monster_UI.draw", "Failed to Access Data: enemy No. " .. tostring(i));
|
||||
goto continue;
|
||||
end
|
||||
|
||||
local monster = large_monster.list[enemy];
|
||||
if monster == nil then
|
||||
customization_menu.status = "No large monster entry";
|
||||
goto continue
|
||||
error_handler.report("large_monster_UI.draw", "Missing Entry: monster No. " .. tostring(i));
|
||||
goto continue;
|
||||
end
|
||||
|
||||
if update_distance then
|
||||
@@ -155,21 +158,21 @@ function this.draw(dynamic_enabled, static_enabled, highlighted_enabled)
|
||||
if dynamic_enabled then
|
||||
local success = pcall(this.draw_dynamic, displayed_monsters, highlighted_monster, cached_config);
|
||||
if not success then
|
||||
customization_menu.status = string.format("[%s] Dynamic Large Monster drawing function threw an exception");
|
||||
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, highlighted_monster, cached_config);
|
||||
if not success then
|
||||
customization_menu.status = string.format("[%s] Highlighted Large Monster drawing function threw an exception");
|
||||
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, displayed_monsters, highlighted_monster, cached_config);
|
||||
if not success then
|
||||
customization_menu.status = string.format("[%s] Static Large Monster drawing function threw an exception");
|
||||
error_handler.report("large_monster_UI.draw", "Static Large Monster drawing function threw an exception");
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -181,24 +184,24 @@ function this.draw_dynamic(displayed_monsters, highlighted_monster, cached_confi
|
||||
local i = 0;
|
||||
for _, monster in ipairs(displayed_monsters) do
|
||||
if cached_config.settings.max_distance == 0 then
|
||||
break
|
||||
break;
|
||||
end
|
||||
|
||||
if monster.is_stealth then
|
||||
goto continue
|
||||
goto continue;
|
||||
end
|
||||
|
||||
if monster.dead_or_captured and cached_config.settings.hide_dead_or_captured then
|
||||
goto continue
|
||||
goto continue;
|
||||
end
|
||||
|
||||
if monster == highlighted_monster then
|
||||
if not cached_config.settings.render_highlighted_monster then
|
||||
goto continue
|
||||
goto continue;
|
||||
end
|
||||
else
|
||||
if not cached_config.settings.render_not_highlighted_monsters then
|
||||
goto continue
|
||||
goto continue;
|
||||
end
|
||||
end
|
||||
|
||||
@@ -281,16 +284,16 @@ function this.draw_static(displayed_monsters, highlighted_monster, cached_config
|
||||
local i = 0;
|
||||
for _, monster in ipairs(displayed_monsters) do
|
||||
if monster.dead_or_captured and cached_config.settings.hide_dead_or_captured then
|
||||
goto continue
|
||||
goto continue;
|
||||
end
|
||||
|
||||
if monster == highlighted_monster then
|
||||
if not cached_config.settings.render_highlighted_monster then
|
||||
goto continue
|
||||
goto continue;
|
||||
end
|
||||
else
|
||||
if not cached_config.settings.render_not_highlighted_monsters then
|
||||
goto continue
|
||||
goto continue;
|
||||
end
|
||||
end
|
||||
|
||||
@@ -339,6 +342,7 @@ function this.init_dependencies()
|
||||
health_UI_entity = require("MHR_Overlay.UI.UI_Entities.health_UI_entity");
|
||||
stamina_UI_entity = require("MHR_Overlay.UI.UI_Entities.stamina_UI_entity");
|
||||
rage_UI_entity = require("MHR_Overlay.UI.UI_Entities.rage_UI_entity");
|
||||
error_handler = require("MHR_Overlay.Misc.error_handler");
|
||||
end
|
||||
|
||||
function this.init_module()
|
||||
|
||||
@@ -9,6 +9,7 @@ local players;
|
||||
local drawing;
|
||||
local health_UI_entity;
|
||||
local stamina_UI_entity;
|
||||
local error_handler;
|
||||
|
||||
local sdk = sdk;
|
||||
local tostring = tostring;
|
||||
@@ -57,33 +58,33 @@ function this.draw()
|
||||
|
||||
local enemy_count = get_zako_enemy_count_method:call(singletons.enemy_manager);
|
||||
if enemy_count == nil then
|
||||
customization_menu.status = "No enemy count";
|
||||
error_handler.report("small_monster_UI.draw", "Failed to Access Data: enemy_count");
|
||||
return;
|
||||
end
|
||||
|
||||
for i = 0, enemy_count - 1 do
|
||||
local enemy = get_zako_enemy_method:call(singletons.enemy_manager, i);
|
||||
if enemy == nil then
|
||||
customization_menu.status = "No enemy";
|
||||
goto continue
|
||||
error_handler.report("small_monster_UI.draw", "Failed to Access Data: enemy No. " .. tostring(i));
|
||||
goto continue;
|
||||
end
|
||||
|
||||
local monster = small_monster.list[enemy];
|
||||
if monster == nil then
|
||||
customization_menu.status = "No small monster entry";
|
||||
goto continue
|
||||
error_handler.report("small_monster_UI.draw", "Missing Entry: monster No. " .. tostring(i));
|
||||
goto continue;
|
||||
end
|
||||
|
||||
if monster.dead_or_captured and cached_config.settings.hide_dead_or_captured then
|
||||
goto continue
|
||||
end
|
||||
goto continue;
|
||||
end;
|
||||
|
||||
table.insert(displayed_monsters, monster);
|
||||
::continue::
|
||||
end
|
||||
|
||||
if cached_config.dynamic_positioning.enabled
|
||||
or (not cached_config.dynamic_positioning.enabled and cached_config.static_sorting.type == "Distance") then
|
||||
or (not cached_config.dynamic_positioning.enabled and cached_config.static_sorting.type == "Distance") then
|
||||
for _, monster in ipairs(displayed_monsters) do
|
||||
monster.distance = (players.myself_position - monster.position):length();
|
||||
end
|
||||
@@ -159,9 +160,6 @@ function this.draw()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
local opacity_scale = 1;
|
||||
if cached_config.dynamic_positioning.enabled then
|
||||
if cached_config.dynamic_positioning.max_distance == 0 then
|
||||
@@ -177,8 +175,6 @@ function this.draw()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
small_monster.draw(monster, cached_config, position_on_screen, opacity_scale);
|
||||
|
||||
i = i + 1;
|
||||
@@ -196,6 +192,7 @@ function this.init_dependencies()
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
health_UI_entity = require("MHR_Overlay.UI.UI_Entities.health_UI_entity");
|
||||
stamina_UI_entity = require("MHR_Overlay.UI.UI_Entities.stamina_UI_entity");
|
||||
error_handler = require("MHR_Overlay.Misc.error_handler");
|
||||
end
|
||||
|
||||
function this.init_module()
|
||||
|
||||
@@ -5,6 +5,7 @@ local screen;
|
||||
local config;
|
||||
local drawing;
|
||||
local utils;
|
||||
local error_handler;
|
||||
|
||||
local sdk = sdk;
|
||||
local tostring = tostring;
|
||||
@@ -68,6 +69,7 @@ function this.init_dependencies()
|
||||
config = require("MHR_Overlay.Misc.config");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
utils = require("MHR_Overlay.Misc.utils");
|
||||
error_handler = require("MHR_Overlay.Misc.error_handler");
|
||||
end
|
||||
|
||||
function this.init_module()
|
||||
|
||||
Reference in New Issue
Block a user