Refactoring

This commit is contained in:
GreenComfyTea
2022-07-26 19:27:37 +03:00
parent a20c458629
commit 2f9a8ac6a3
41 changed files with 5939 additions and 18587 deletions

View File

@@ -335,7 +335,7 @@ function keyboard.check_modifiers(hard_keyboard)
if is_ctrl_down ~= nil then
keyboard.hotkey_modifiers_down.ctrl = is_ctrl_down;
end
local is_shift_down = get_down_method:call(hard_keyboard, 16);
if is_shift_down ~= nil then
keyboard.hotkey_modifiers_down.shift = is_shift_down;
@@ -458,16 +458,16 @@ function keyboard.check_hotkeys(hard_keyboard)
local cached_config = config.current_config.global_settings.hotkeys_with_modifiers;
if not (cached_config.all_UI.ctrl and not keyboard.hotkey_modifiers_down.ctrl)
and not (cached_config.all_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (cached_config.all_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
and not (cached_config.all_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (cached_config.all_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(cached_config.all_UI.key)) 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
or config.current_config.large_monster_UI.static.enabled
or config.current_config.large_monster_UI.highlighted.enabled
or config.current_config.damage_meter_UI.enabled;
or config.current_config.small_monster_UI.enabled
or 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
or config.current_config.damage_meter_UI.enabled;
config.current_config.time_UI.enabled = not is_any_enabled;
config.current_config.small_monster_UI.enabled = not is_any_enabled;
@@ -479,16 +479,16 @@ function keyboard.check_hotkeys(hard_keyboard)
end
if not (cached_config.small_monster_UI.ctrl and not keyboard.hotkey_modifiers_down.ctrl)
and not (cached_config.small_monster_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (cached_config.small_monster_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
and not (cached_config.small_monster_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (cached_config.small_monster_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(cached_config.small_monster_UI.key)) 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 keyboard.hotkey_modifiers_down.ctrl)
and not (cached_config.large_monster_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (cached_config.large_monster_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
and not (cached_config.large_monster_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (cached_config.large_monster_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(cached_config.large_monster_UI.key)) then
local is_any_enabled = config.current_config.large_monster_UI.dynamic.enabled
or config.current_config.large_monster_UI.static.enabled
@@ -501,48 +501,52 @@ function keyboard.check_hotkeys(hard_keyboard)
end
if not (cached_config.large_monster_dynamic_UI.ctrl and not keyboard.hotkey_modifiers_down.ctrl)
and not (cached_config.large_monster_dynamic_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (cached_config.large_monster_dynamic_UI.alt and not keyboard.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 keyboard.hotkey_modifiers_down.shift)
and not (cached_config.large_monster_dynamic_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard,
math.tointeger(cached_config.large_monster_dynamic_UI.key)) 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 keyboard.hotkey_modifiers_down.ctrl)
and not (cached_config.large_monster_static_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (cached_config.large_monster_static_UI.alt and not keyboard.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 keyboard.hotkey_modifiers_down.shift)
and not (cached_config.large_monster_static_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard,
math.tointeger(cached_config.large_monster_static_UI.key)) 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 keyboard.hotkey_modifiers_down.ctrl)
and not (cached_config.large_monster_highlighted_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (cached_config.large_monster_highlighted_UI.alt and not keyboard.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 keyboard.hotkey_modifiers_down.shift)
and not (cached_config.large_monster_highlighted_UI.alt and not keyboard.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;
end
end
if not (cached_config.time_UI.ctrl and not keyboard.hotkey_modifiers_down.ctrl)
and not (cached_config.time_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (cached_config.time_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
and not (cached_config.time_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (cached_config.time_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(cached_config.time_UI.key)) 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 keyboard.hotkey_modifiers_down.ctrl)
and not (cached_config.damage_meter_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (cached_config.damage_meter_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
and not (cached_config.damage_meter_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (cached_config.damage_meter_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(cached_config.damage_meter_UI.key)) 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 keyboard.hotkey_modifiers_down.ctrl)
and not (cached_config.endemic_life_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (cached_config.endemic_life_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
and not (cached_config.endemic_life_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (cached_config.endemic_life_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(cached_config.endemic_life_UI.key)) then
config.current_config.endemic_life_UI.enabled = not config.current_config.endemic_life_UI.enabled;
end
@@ -577,4 +581,4 @@ function keyboard.init_module()
time = require("MHR_Overlay.Game_Handler.time");
end
return keyboard;
return keyboard;

View File

@@ -1,4 +1,3 @@
local quest_status = {};
local singletons;
local customization_menu;
@@ -36,7 +35,7 @@ local is_quest_host_method = lobby_manager_type_definition:get_method("isQuestHo
function quest_status.on_changed_game_status(new_quest_status)
if (quest_status.index < 2 and new_quest_status == 2)
or new_quest_status < 2 then
or new_quest_status < 2 then
player.init();
small_monster.init_list();
@@ -145,7 +144,7 @@ function quest_status.init_module()
env_creature = require("MHR_Overlay.Endemic_Life.env_creature");
quest_status.init();
sdk.hook(on_changed_game_status, function(args)
quest_status.on_changed_game_status(sdk.to_int64(args[3]));
end, function(retval) return retval; end);
@@ -163,4 +162,4 @@ function quest_status.init_module()
end, function(retval) return retval; end);
end
return quest_status;
return quest_status;

View File

@@ -15,7 +15,7 @@ function screen.update_window_size()
else
width, height = screen.get_game_window_size();
end
if width ~= nil then
screen.width = width;
end
@@ -35,7 +35,9 @@ local height_field = size_type:get_field("h");
function screen.get_game_window_size()
if scene_view == nil then
scene_view = sdk.call_native_func(singletons.scene_manager, sdk.find_type_definition("via.SceneManager"), "get_MainView");
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");
@@ -56,7 +58,7 @@ function screen.get_game_window_size()
end
local screen_height = height_field:get_data(size);
if screen_height == nil then
if screen_height == nil then
--log.error("[MHR_Overlay.lua] No screen height");
return;
end
@@ -71,32 +73,32 @@ function screen.calculate_absolute_coordinates(position)
x = position.x * global_position_modifier;
y = position.y * global_position_modifier;
}
-- top left
if position.anchor == "Top-Left" then
return {x = _position.x, y = _position.y};
return { x = _position.x, y = _position.y };
end
-- top right
if position.anchor == "Top-Right" then
local screen_x = screen.width - _position.x;
return {x = screen_x, y = _position.y};
return { x = screen_x, y = _position.y };
end
-- bottom left
if position.anchor == "Bottom-Left" then
local screen_y = screen.height - _position.y;
return {x = _position.x, y = screen_y};
return { x = _position.x, y = screen_y };
end
-- bottom right
if position.anchor == "Bottom-Right" then
local screen_x = screen.width - _position.x;
local screen_y = screen.height - _position.y;
return {x = screen_x, y = screen_y};
return { x = screen_x, y = screen_y };
end
return {x = _position.x, y = _position.y};
return { x = _position.x, y = _position.y };
end
function screen.init_module()

View File

@@ -160,4 +160,4 @@ function singletons.init_module()
singletons.init();
end
return singletons;
return singletons;

View File

@@ -44,7 +44,7 @@ function time.tick()
time.total_elapsed_seconds = quest_time_total_elapsed_seconds;
time.elapsed_seconds = quest_time_total_elapsed_seconds - quest_time_elapsed_minutes * 60;
if time.total_elapsed_script_seconds - time.last_elapsed_script_seconds > 1 then
time.last_elapsed_script_seconds = time.total_elapsed_script_seconds;
time.update_players_dps();
@@ -53,7 +53,7 @@ end
function time.update_players_dps()
local cached_config = config.current_config.damage_meter_UI.settings;
if cached_config.freeze_dps_on_quest_clear and quest_status.is_quest_clear then
return;
end
@@ -93,4 +93,4 @@ function time.init_module()
quest_status = require("MHR_Overlay.Game_Handler.quest_status");
end
return time;
return time;