Implement Error Handler

This commit is contained in:
GreenComfyTea
2023-08-05 16:30:15 +03:00
parent 4bdb4ee2e6
commit dfb7893c1a
59 changed files with 1079 additions and 402 deletions

View File

@@ -8,6 +8,7 @@ local small_monster;
local large_monster;
local damage_meter_UI;
local time;
local error_handler;
local sdk = sdk;
local tostring = tostring;
@@ -333,16 +334,15 @@ this.keys = {
--[254] = "Clear"
};
function this.update()
if singletons.game_keyboard == nil then
customization_menu.status = "No game keyboard";
error_handler.report("keyboard.update", "Failed to Access Data: game_keyboard");
return;
end
local hard_keyboard = hard_keyboard_field:get_data(singletons.game_keyboard);
if hard_keyboard == nil then
customization_menu.status = "No hard keyboard";
error_handler.report("keyboard.update", "Failed to Access Data: hard_keyboard");
return;
end
@@ -350,8 +350,6 @@ function this.update()
local new_hotkey_registered = this.register_hotkey(hard_keyboard);
if new_hotkey_registered then
config.save_current();
else
@@ -491,10 +489,15 @@ function this.check_hotkeys(hard_keyboard)
local cached_config = config.current_config.global_settings.hotkeys_with_modifiers;
if not (cached_config.all_UI.ctrl and not this.hotkey_modifiers_down.ctrl)
and not (cached_config.all_UI.shift and not this.hotkey_modifiers_down.shift)
and not (cached_config.all_UI.alt and not this.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(cached_config.all_UI.key)) then
and not (cached_config.all_UI.shift and not this.hotkey_modifiers_down.shift)
and not (cached_config.all_UI.alt and not this.hotkey_modifiers_down.alt) then
local all_UI_key_release = get_release_method:call(hard_keyboard, math.tointeger(cached_config.all_UI.key));
if all_UI_key_release == nil then
error_handler.report("keyboard.check_hotkeys", "Failed to Access Data: all_UI_key_release");
elseif all_UI_key_release then
local is_any_enabled = config.current_config.time_UI.enabled
or config.current_config.small_monster_UI.enabled
or config.current_config.large_monster_UI.dynamic.enabled
@@ -512,17 +515,29 @@ function this.check_hotkeys(hard_keyboard)
end
if not (cached_config.small_monster_UI.ctrl and not this.hotkey_modifiers_down.ctrl)
and not (cached_config.small_monster_UI.shift and not this.hotkey_modifiers_down.shift)
and not (cached_config.small_monster_UI.alt and not this.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(cached_config.small_monster_UI.key)) then
and not (cached_config.small_monster_UI.shift and not this.hotkey_modifiers_down.shift)
and not (cached_config.small_monster_UI.alt and not this.hotkey_modifiers_down.alt) then
local small_monster_UI_key_release = get_release_method:call(hard_keyboard, math.tointeger(cached_config.small_monster_UI.key));
if small_monster_UI_key_release == nil then
error_handler.report("keyboard.check_hotkeys", "Failed to Access Data: small_monster_UI_key_release");
elseif small_monster_UI_key_release then
config.current_config.small_monster_UI.enabled = not config.current_config.small_monster_UI.enabled;
end
end
if not (cached_config.large_monster_UI.ctrl and not this.hotkey_modifiers_down.ctrl)
and not (cached_config.large_monster_UI.shift and not this.hotkey_modifiers_down.shift)
and not (cached_config.large_monster_UI.alt and not this.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(cached_config.large_monster_UI.key)) then
and not (cached_config.large_monster_UI.shift and not this.hotkey_modifiers_down.shift)
and not (cached_config.large_monster_UI.alt and not this.hotkey_modifiers_down.alt) then
local large_monster_UI_key_release = get_release_method:call(hard_keyboard, math.tointeger(cached_config.large_monster_UI.key));
if large_monster_UI_key_release == nil then
error_handler.report("keyboard.check_hotkeys", "Failed to Access Data: large_monster_UI_key_release");
elseif large_monster_UI_key_release then
local is_any_enabled = config.current_config.large_monster_UI.dynamic.enabled
or config.current_config.large_monster_UI.static.enabled
or config.current_config.large_monster_UI.highlighted.enabled;
@@ -534,53 +549,85 @@ function this.check_hotkeys(hard_keyboard)
end
if not (cached_config.large_monster_dynamic_UI.ctrl and not this.hotkey_modifiers_down.ctrl)
and not (cached_config.large_monster_dynamic_UI.shift and not this.hotkey_modifiers_down.shift)
and not (cached_config.large_monster_dynamic_UI.alt and not this.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard,
math.tointeger(cached_config.large_monster_dynamic_UI.key)) then
and not (cached_config.large_monster_dynamic_UI.shift and not this.hotkey_modifiers_down.shift)
and not (cached_config.large_monster_dynamic_UI.alt and not this.hotkey_modifiers_down.alt) then
local large_monster_dynamic_UI_key_release = get_release_method:call(hard_keyboard, math.tointeger(cached_config.large_monster_dynamic_UI.key));
if large_monster_dynamic_UI_key_release == nil then
error_handler.report("keyboard.check_hotkeys", "Failed to Access Data: large_monster_dynamic_UI_key_release");
elseif large_monster_dynamic_UI_key_release then
config.current_config.large_monster_UI.dynamic.enabled = not config.current_config.large_monster_UI.dynamic.enabled;
end
end
if not (cached_config.large_monster_static_UI.ctrl and not this.hotkey_modifiers_down.ctrl)
and not (cached_config.large_monster_static_UI.shift and not this.hotkey_modifiers_down.shift)
and not (cached_config.large_monster_static_UI.alt and not this.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard,
math.tointeger(cached_config.large_monster_static_UI.key)) then
and not (cached_config.large_monster_static_UI.shift and not this.hotkey_modifiers_down.shift)
and not (cached_config.large_monster_static_UI.alt and not this.hotkey_modifiers_down.alt) then
local large_monster_static_UI_key_release = get_release_method:call(hard_keyboard, math.tointeger(cached_config.large_monster_static_UI.key));
if large_monster_static_UI_key_release == nil then
error_handler.report("keyboard.check_hotkeys", "Failed to Access Data: large_monster_static_UI_key_release");
elseif large_monster_static_UI_key_release then
config.current_config.large_monster_UI.static.enabled = not config.current_config.large_monster_UI.static.enabled;
end
end
if not (cached_config.large_monster_highlighted_UI.ctrl and not this.hotkey_modifiers_down.ctrl)
and not (cached_config.large_monster_highlighted_UI.shift and not this.hotkey_modifiers_down.shift)
and not (cached_config.large_monster_highlighted_UI.alt and not this.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard,
math.tointeger(cached_config.large_monster_highlighted_UI.key)) then
config.current_config.large_monster_UI.highlighted.enabled = not
config.current_config.large_monster_UI.highlighted.enabled;
and not (cached_config.large_monster_highlighted_UI.shift and not this.hotkey_modifiers_down.shift)
and not (cached_config.large_monster_highlighted_UI.alt and not this.hotkey_modifiers_down.alt) then
local large_monster_highlighted_UI_key_release = get_release_method:call(hard_keyboard, math.tointeger(cached_config.large_monster_highlighted_UI.key));
if large_monster_highlighted_UI_key_release == nil then
error_handler.report("keyboard.check_hotkeys", "Failed to Access Data: large_monster_highlighted_UI_key_release");
elseif large_monster_highlighted_UI_key_release then
config.current_config.large_monster_UI.highlighted.enabled = not config.current_config.large_monster_UI.highlighted.enabled;
end
end
if not (cached_config.time_UI.ctrl and not this.hotkey_modifiers_down.ctrl)
and not (cached_config.time_UI.shift and not this.hotkey_modifiers_down.shift)
and not (cached_config.time_UI.alt and not this.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(cached_config.time_UI.key)) then
and not (cached_config.time_UI.shift and not this.hotkey_modifiers_down.shift)
and not (cached_config.time_UI.alt and not this.hotkey_modifiers_down.alt) then
local time_UI_key_release = get_release_method:call(hard_keyboard, math.tointeger(cached_config.time_UI.key));
if time_UI_key_release == nil then
error_handler.report("keyboard.check_hotkeys", "Failed to Access Data: time_UI_key_release");
elseif time_UI_key_release then
config.current_config.time_UI.enabled = not config.current_config.time_UI.enabled;
end
end
if not (cached_config.damage_meter_UI.ctrl and not this.hotkey_modifiers_down.ctrl)
and not (cached_config.damage_meter_UI.shift and not this.hotkey_modifiers_down.shift)
and not (cached_config.damage_meter_UI.alt and not this.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(cached_config.damage_meter_UI.key)) then
and not (cached_config.damage_meter_UI.shift and not this.hotkey_modifiers_down.shift)
and not (cached_config.damage_meter_UI.alt and not this.hotkey_modifiers_down.alt) then
local damage_meter_UI_key_release = get_release_method:call(hard_keyboard, math.tointeger(cached_config.damage_meter_UI.key));
if damage_meter_UI_key_release == nil then
error_handler.report("keyboard.check_hotkeys", "Failed to Access Data: damage_meter_UI_key_release");
elseif damage_meter_UI_key_release then
config.current_config.damage_meter_UI.enabled = not config.current_config.damage_meter_UI.enabled;
end
end
if not (cached_config.endemic_life_UI.ctrl and not this.hotkey_modifiers_down.ctrl)
and not (cached_config.endemic_life_UI.shift and not this.hotkey_modifiers_down.shift)
and not (cached_config.endemic_life_UI.alt and not this.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(cached_config.endemic_life_UI.key)) then
and not (cached_config.endemic_life_UI.shift and not this.hotkey_modifiers_down.shift)
and not (cached_config.endemic_life_UI.alt and not this.hotkey_modifiers_down.alt) then
local endemic_life_UI_key_release = get_release_method:call(hard_keyboard, math.tointeger(cached_config.endemic_life_UI.key));
if endemic_life_UI_key_release == nil then
error_handler.report("keyboard.check_hotkeys", "Failed to Access Data: endemic_life_UI_key_release");
elseif endemic_life_UI_key_release then
config.current_config.endemic_life_UI.enabled = not config.current_config.endemic_life_UI.enabled;
end
end
@@ -613,9 +660,10 @@ function this.init_dependencies()
large_monster = require("MHR_Overlay.Monsters.large_monster");
damage_meter_UI = require("MHR_Overlay.UI.Modules.damage_meter_UI");
time = require("MHR_Overlay.Game_Handler.time");
error_handler = require("MHR_Overlay.Misc.error_handler");
end
function this.init_module()
end
return this;
return this;

View File

@@ -9,6 +9,7 @@ local damage_meter_UI;
local time;
local env_creature;
local non_players;
local error_handler;
local sdk = sdk;
local tostring = tostring;
@@ -153,16 +154,20 @@ end
function this.get_cart_count()
local death_num = get_death_num_method:call(singletons.quest_manager);
if death_num ~= nil then
this.cart_count = death_num;
if death_num == nil then
error_handler.report("quest_status.get_cart_count", "Failed to Access Data: death_num");
end
this.cart_count = death_num;
end
function this.get_max_cart_count()
local quest_life = get_quest_life_method:call(singletons.quest_manager);
if quest_life ~= nil then
this.max_cart_count = quest_life;
if quest_life == nil then
error_handler.report("quest_status.get_max_cart_count", "Failed to Access Data: quest_life");
end
this.max_cart_count = quest_life;
end
--type 2 = quest start
@@ -170,6 +175,7 @@ end
--type 5 = end screen
function this.on_demo_request_activation(request_data_base)
if request_data_base == nil then
error_handler.report("quest_status.on_demo_request_activation", "Missing Parameter: request_data_base");
return;
end
@@ -179,6 +185,7 @@ function this.on_demo_request_activation(request_data_base)
local request_data_type = request_data_base:call("get_Type");
if request_data_type == nil then
error_handler.report("quest_status.on_demo_request_activation", "Failed to Access Data: request_data_type");
return;
end
@@ -278,6 +285,7 @@ end
function this.on_village_fast_travel(area)
if area == nil then
error_handler.report("quest_status.on_village_fast_travel", "Missing Parameter: area");
return;
end
@@ -289,6 +297,11 @@ function this.on_village_fast_travel(area)
end
function this.on_changed_game_status(new_quest_status)
if new_quest_status == nil then
error_handler.report("quest_status.on_changed_game_status", "Missing Parameter: new_quest_status");
return;
end
this.index = new_quest_status;
if this.index == 0 then
@@ -304,12 +317,13 @@ end
function this.init()
if singletons.quest_manager == nil then
error_handler.report("quest_status.init", "Failed to Access Data: quest_manager");
return;
end
local new_quest_status = get_status_method:call(singletons.game_manager);
if new_quest_status == nil then
customization_menu.status = "No quest status";
error_handler.report("quest_status.init", "Failed to Access Data: new_quest_status");
return;
end
@@ -330,11 +344,13 @@ end
function this.update_is_online()
if singletons.lobby_manager == nil then
error_handler.report("quest_status.update_is_online", "Failed to Access Data: lobby_manager");
return;
end
local is_quest_online = is_quest_online_method:call(singletons.lobby_manager);
if is_quest_online == nil then
error_handler.report("quest_status.update_is_online", "Failed to Access Data: is_quest_online");
return;
end
@@ -343,11 +359,13 @@ end
--[[function quest_status.update_is_quest_host()
if singletons.lobby_manager == nil then
error_handler.report("quest_status.update_is_quest_host", "Failed to Access Data: lobby_manager");
return;
end
local is_quest_host = is_quest_host_method:call(singletons.lobby_manager, true);
if is_quest_host == nil then
error_handler.report("quest_status.update_is_quest_host", "Failed to Access Data: is_quest_host");
return;
end
@@ -356,16 +374,17 @@ end--]]
function this.update_is_training_area()
if singletons.village_area_manager == nil then
customization_menu.status = "No village area manager";
error_handler.report("quest_status.update_is_training_area", "Failed to Access Data: village_area_manager");
return;
end
local _is_training_area = check_current_area_training_area_method:call(singletons.village_area_manager);
if _is_training_area == nil then
local is_training_area = check_current_area_training_area_method:call(singletons.village_area_manager);
if is_training_area == nil then
error_handler.report("quest_status.update_is_training_area", "Failed to Access Data: is_training_area");
return;
end
if _is_training_area then
if is_training_area then
this.set_flow_state(this.flow_states.IN_TRAINING_AREA);
end
end
@@ -380,6 +399,7 @@ function this.init_dependencies()
time = require("MHR_Overlay.Game_Handler.time");
env_creature = require("MHR_Overlay.Endemic_Life.env_creature");
non_players = require("MHR_Overlay.Damage_Meter.non_players");
error_handler = require("MHR_Overlay.Misc.error_handler");
end
function this.init_module()

View File

@@ -4,6 +4,7 @@ local config;
local singletons;
local utils;
local time;
local error_handler;
local sdk = sdk;
local tostring = tostring;
@@ -72,26 +73,26 @@ function this.get_game_window_size()
scene_view = sdk.call_native_func(singletons.scene_manager, sdk.find_type_definition("via.SceneManager") , "get_MainView");
if scene_view == nil then
--log.error("[MHR_Overlay.lua] No scene view");
error_handler.report("screen.get_game_window_size", "Failed to Access Data: scene_view");
return;
end
end
local size = get_size_method:call(scene_view);
if size == nil then
--log.error("[MHR_Overlay.lua] No scene view size");
error_handler.report("screen.get_game_window_size", "Failed to Access Data: size");
return;
end
local screen_width = width_field:get_data(size);
if screen_width == nil then
--log.error("[MHR_Overlay.lua] No screen width");
error_handler.report("screen.get_game_window_size", "Failed to Access Data: screen_width");
return;
end
local screen_height = height_field:get_data(size);
if screen_height == nil then
--log.error("[MHR_Overlay.lua] No screen height");
error_handler.report("screen.get_game_window_size", "Failed to Access Data: screen_height");
return;
end
@@ -138,6 +139,7 @@ function this.init_dependencies()
singletons = require("MHR_Overlay.Game_Handler.singletons");
time = require("MHR_Overlay.Game_Handler.time");
utils = require("MHR_Overlay.Misc.utils");
error_handler = require("MHR_Overlay.Misc.error_handler");
end
function this.init_module()

View File

@@ -2,6 +2,7 @@ local this = {};
local time;
local utils;
local error_handler;
local sdk = sdk;
local tostring = tostring;
@@ -70,7 +71,7 @@ function this.init_message_manager()
this.message_manager = sdk.get_managed_singleton("snow.gui.MessageManager");
if this.message_manager == nil then
--log.error("[MHR Overlay] No message manager");
error_handler.report("singletons.init_message_manager", "Failed to Access Data: message_manager");
end
return this.message_manager;
@@ -83,7 +84,7 @@ function this.init_enemy_manager()
this.enemy_manager = sdk.get_managed_singleton("snow.enemy.EnemyManager");
if this.enemy_manager == nil then
--log.error("[MHR Overlay] No enemy manager");
error_handler.report("singletons.init_enemy_manager", "Failed to Access Data: enemy_manager");
end
return this.enemy_manager;
@@ -96,7 +97,7 @@ function this.init_lobby_manager()
this.lobby_manager = sdk.get_managed_singleton("snow.LobbyManager");
if this.lobby_manager == nil then
--log.error("[MHR Overlay] No lobby manager");
error_handler.report("singletons.init_lobby_manager", "Failed to Access Data: lobby_manager");
return false;
end
@@ -110,7 +111,7 @@ function this.init_progress_manager()
this.progress_manager = sdk.get_managed_singleton("snow.progress.ProgressManager");
if this.progress_manager == nil then
--log.error("[MHR Overlay] No progress manager");
error_handler.report("singletons.init_lobby_manager", "Failed to Access Data: progress_manager");
return false;
end
@@ -124,7 +125,7 @@ function this.init_quest_manager()
this.quest_manager = sdk.get_managed_singleton("snow.QuestManager");
if this.quest_manager == nil then
--log.error("[MHR Overlay] No quest manager");
error_handler.report("singletons.init_quest_manager", "Failed to Access Data: quest_manager");
end
return this.quest_manager;
@@ -137,7 +138,7 @@ function this.init_player_manager()
this.player_manager = sdk.get_managed_singleton("snow.player.PlayerManager");
if this.player_manager == nil then
--log.error("[MHR Overlay] No player manager");
error_handler.report("singletons.init_player_manager", "Failed to Access Data: player_manager");
end
return this.player_manager;
@@ -150,7 +151,7 @@ function this.init_village_area_manager()
this.village_area_manager = sdk.get_managed_singleton("snow.VillageAreaManager");
if this.village_area_manager == nil then
--log.error("[MHR Overlay] No village area manager");
error_handler.report("singletons.init_village_area_manager", "Failed to Access Data: village_area_manager");
end
return this.village_area_manager;
@@ -163,7 +164,7 @@ function this.init_gui_manager()
this.gui_manager = sdk.get_managed_singleton("snow.gui.GuiManager");
if this.gui_manager == nil then
--log.error("[MHR Overlay] No gui manager");
error_handler.report("singletons.init_gui_manager", "Failed to Access Data: gui_manager");
end
return this.gui_manager;
@@ -176,7 +177,7 @@ function this.init_game_keyboard()
this.game_keyboard = sdk.get_managed_singleton("snow.GameKeyboard");
if this.game_keyboard == nil then
--log.error("[MHR Overlay] No game keyboard");
error_handler.report("singletons.init_game_keyboard", "Failed to Access Data: game_keyboard");
end
return this.game_keyboard;
@@ -189,7 +190,7 @@ function this.init_scene_manager()
this.scene_manager = sdk.get_native_singleton("via.SceneManager");
if this.scene_manager == nil then
--log.error("[MHR Overlay] No enemy manager");
error_handler.report("singletons.init_scene_manager", "Failed to Access Data: scene_manager");
end
return this.scene_manager;
@@ -202,7 +203,7 @@ function this.init_game_manager()
this.game_manager = sdk.get_managed_singleton("snow.SnowGameManager");
if this.game_manager == nil then
--log.error("[MHR Overlay] No enemy manager");
error_handler.report("singletons.init_game_manager", "Failed to Access Data: game_manager");
end
return this.game_manager;
@@ -215,7 +216,7 @@ function this.init_servant_manager()
this.servant_manager = sdk.get_managed_singleton("snow.ai.ServantManager");
if this.servant_manager == nil then
--log.error("[MHR Overlay] No enemy manager");
error_handler.report("singletons.init_servant_manager", "Failed to Access Data: servant_manager");
end
return this.servant_manager;
@@ -228,7 +229,7 @@ function this.init_otomo_manager()
this.otomo_manager = sdk.get_managed_singleton("snow.otomo.OtomoManager");
if this.otomo_manager == nil then
--log.error("[MHR Overlay] No enemy manager");
error_handler.report("singletons.init_otomo_manager", "Failed to Access Data: otomo_manager");
end
return this.otomo_manager;
@@ -237,6 +238,7 @@ end
function this.init_dependencies()
time = require("MHR_Overlay.Game_Handler.time");
utils = require("MHR_Overlay.Misc.utils");
error_handler = require("MHR_Overlay.Misc.error_handler");
end
function this.init_module()

View File

@@ -8,6 +8,7 @@ local non_players;
local config;
local small_monster;
local utils;
local error_handler;
local sdk = sdk;
local tostring = tostring;
@@ -50,7 +51,6 @@ this.elapsed_minutes = 0;
this.elapsed_seconds = 0;
this.total_elapsed_script_seconds = 0;
this.last_elapsed_script_seconds = 0;
this.list = {};
@@ -60,7 +60,6 @@ function this.new_timer(callback, cooldown_seconds, start_offset_seconds)
if callback == nil or cooldown_seconds == nil then
return;
end
local timer = {};
timer.callback = callback;
timer.cooldown = cooldown_seconds;
@@ -69,7 +68,6 @@ function this.new_timer(callback, cooldown_seconds, start_offset_seconds)
table.insert(this.list, timer);
callback();
end
function this.update_timers()
@@ -99,14 +97,14 @@ function this.update_quest_time()
local quest_time_elapsed_minutes = get_quest_elapsed_time_min_method:call(singletons.quest_manager);
if quest_time_elapsed_minutes == nil then
customization_menu.status = "No quest time elapsed minutes";
error_handler.report("time.update_quest_time", "Failed to Access Data: quest_time_elapsed_minutes");
else
this.elapsed_minutes = quest_time_elapsed_minutes;
end
local quest_time_total_elapsed_seconds = get_quest_elapsed_time_sec_method:call(singletons.quest_manager);
if quest_time_total_elapsed_seconds == nil then
customization_menu.status = "No quest time total elapsed seconds";
error_handler.report("time.update_quest_time", "Failed to Access Data: quest_time_total_elapsed_seconds");
else
this.total_elapsed_seconds = quest_time_total_elapsed_seconds;
end
@@ -123,6 +121,7 @@ function this.init_dependencies()
quest_status = require("MHR_Overlay.Game_Handler.quest_status");
non_players = require("MHR_Overlay.Damage_Meter.non_players");
utils = require("MHR_Overlay.Misc.utils");
error_handler = require("MHR_Overlay.Misc.error_handler");
end
function this.init_module()