Release v1.11

1) Cache config access function-wide where possible;
2) Break and Sever values added to parts;
3) Hooks are now applied in init_module instead of global space;
4) Added checks for submodule (health, stamina, etc) visibility. If not visible, do not pull data.
This commit is contained in:
GreenComfyTea
2022-06-20 13:01:10 +03:00
parent 286c54aa55
commit f64d6c84d3
31 changed files with 1617 additions and 1539 deletions

View File

@@ -348,13 +348,15 @@ function keyboard.check_modifiers(hard_keyboard)
end
function keyboard.register_hotkey(hard_keyboard)
local cached_config = config.current_config.global_settings.hotkeys_with_modifiers;
if customization_menu.all_UI_waiting_for_key then
for key, key_name in pairs(keyboard.keys) do
if get_release_method:call(hard_keyboard, key) then
config.current_config.global_settings.hotkeys_with_modifiers.all_UI.ctrl = keyboard.hotkey_modifiers_down.ctrl;
config.current_config.global_settings.hotkeys_with_modifiers.all_UI.shift = keyboard.hotkey_modifiers_down.shift;
config.current_config.global_settings.hotkeys_with_modifiers.all_UI.alt = keyboard.hotkey_modifiers_down.alt;
config.current_config.global_settings.hotkeys_with_modifiers.all_UI.key = key;
cached_config.all_UI.ctrl = keyboard.hotkey_modifiers_down.ctrl;
cached_config.all_UI.shift = keyboard.hotkey_modifiers_down.shift;
cached_config.all_UI.alt = keyboard.hotkey_modifiers_down.alt;
cached_config.all_UI.key = key;
customization_menu.all_UI_waiting_for_key = false;
return true;
end
@@ -362,10 +364,10 @@ function keyboard.register_hotkey(hard_keyboard)
elseif customization_menu.small_monster_UI_waiting_for_key then
for key, key_name in pairs(keyboard.keys) do
if get_release_method:call(hard_keyboard, key) then
config.current_config.global_settings.hotkeys_with_modifiers.small_monster_UI.ctrl = keyboard.hotkey_modifiers_down.ctrl;
config.current_config.global_settings.hotkeys_with_modifiers.small_monster_UI.shift = keyboard.hotkey_modifiers_down.shift;
config.current_config.global_settings.hotkeys_with_modifiers.small_monster_UI.alt = keyboard.hotkey_modifiers_down.alt;
config.current_config.global_settings.hotkeys_with_modifiers.small_monster_UI.key = key;
cached_config.small_monster_UI.ctrl = keyboard.hotkey_modifiers_down.ctrl;
cached_config.small_monster_UI.shift = keyboard.hotkey_modifiers_down.shift;
cached_config.small_monster_UI.alt = keyboard.hotkey_modifiers_down.alt;
cached_config.small_monster_UI.key = key;
customization_menu.small_monster_UI_waiting_for_key = false;
return true;
end
@@ -373,10 +375,10 @@ function keyboard.register_hotkey(hard_keyboard)
elseif customization_menu.large_monster_UI_waiting_for_key then
for key, key_name in pairs(keyboard.keys) do
if get_release_method:call(hard_keyboard, key) then
config.current_config.global_settings.hotkeys_with_modifiers.large_monster_UI.ctrl = keyboard.hotkey_modifiers_down.ctrl;
config.current_config.global_settings.hotkeys_with_modifiers.large_monster_UI.shift = keyboard.hotkey_modifiers_down.shift;
config.current_config.global_settings.hotkeys_with_modifiers.large_monster_UI.alt = keyboard.hotkey_modifiers_down.alt;
config.current_config.global_settings.hotkeys_with_modifiers.large_monster_UI.key = key;
cached_config.large_monster_UI.ctrl = keyboard.hotkey_modifiers_down.ctrl;
cached_config.large_monster_UI.shift = keyboard.hotkey_modifiers_down.shift;
cached_config.large_monster_UI.alt = keyboard.hotkey_modifiers_down.alt;
cached_config.large_monster_UI.key = key;
customization_menu.large_monster_UI_waiting_for_key = false;
return true;
end
@@ -384,10 +386,10 @@ function keyboard.register_hotkey(hard_keyboard)
elseif customization_menu.large_monster_dynamic_UI_waiting_for_key then
for key, key_name in pairs(keyboard.keys) do
if get_release_method:call(hard_keyboard, key) then
config.current_config.global_settings.hotkeys_with_modifiers.large_monster_dynamic_UI.ctrl = keyboard.hotkey_modifiers_down.ctrl;
config.current_config.global_settings.hotkeys_with_modifiers.large_monster_dynamic_UI.shift = keyboard.hotkey_modifiers_down.shift;
config.current_config.global_settings.hotkeys_with_modifiers.large_monster_dynamic_UI.alt = keyboard.hotkey_modifiers_down.alt;
config.current_config.global_settings.hotkeys_with_modifiers.large_monster_dynamic_UI.key = key;
cached_config.large_monster_dynamic_UI.ctrl = keyboard.hotkey_modifiers_down.ctrl;
cached_config.large_monster_dynamic_UI.shift = keyboard.hotkey_modifiers_down.shift;
cached_config.large_monster_dynamic_UI.alt = keyboard.hotkey_modifiers_down.alt;
cached_config.large_monster_dynamic_UI.key = key;
customization_menu.large_monster_dynamic_UI_waiting_for_key = false;
return true;
end
@@ -395,10 +397,10 @@ function keyboard.register_hotkey(hard_keyboard)
elseif customization_menu.large_monster_static_UI_waiting_for_key then
for key, key_name in pairs(keyboard.keys) do
if get_release_method:call(hard_keyboard, key) then
config.current_config.global_settings.hotkeys_with_modifiers.large_monster_static_UI.ctrl = keyboard.hotkey_modifiers_down.ctrl;
config.current_config.global_settings.hotkeys_with_modifiers.large_monster_static_UI.shift = keyboard.hotkey_modifiers_down.shift;
config.current_config.global_settings.hotkeys_with_modifiers.large_monster_static_UI.alt = keyboard.hotkey_modifiers_down.alt;
config.current_config.global_settings.hotkeys_with_modifiers.large_monster_static_UI.key = key;
cached_config.large_monster_static_UI.ctrl = keyboard.hotkey_modifiers_down.ctrl;
cached_config.large_monster_static_UI.shift = keyboard.hotkey_modifiers_down.shift;
cached_config.large_monster_static_UI.alt = keyboard.hotkey_modifiers_down.alt;
cached_config.large_monster_static_UI.key = key;
customization_menu.large_monster_static_UI_waiting_for_key = false;
return true;
end
@@ -406,10 +408,10 @@ function keyboard.register_hotkey(hard_keyboard)
elseif customization_menu.large_monster_highlighted_UI_waiting_for_key then
for key, key_name in pairs(keyboard.keys) do
if get_release_method:call(hard_keyboard, key) then
config.current_config.global_settings.hotkeys_with_modifiers.large_monster_highlighted_UI.ctrl = keyboard.hotkey_modifiers_down.ctrl;
config.current_config.global_settings.hotkeys_with_modifiers.large_monster_highlighted_UI.shift = keyboard.hotkey_modifiers_down.shift;
config.current_config.global_settings.hotkeys_with_modifiers.large_monster_highlighted_UI.alt = keyboard.hotkey_modifiers_down.alt;
config.current_config.global_settings.hotkeys_with_modifiers.large_monster_highlighted_UI.key = key;
cached_config.large_monster_highlighted_UI.ctrl = keyboard.hotkey_modifiers_down.ctrl;
cached_config.large_monster_highlighted_UI.shift = keyboard.hotkey_modifiers_down.shift;
cached_config.large_monster_highlighted_UI.alt = keyboard.hotkey_modifiers_down.alt;
cached_config.large_monster_highlighted_UI.key = key;
customization_menu.large_monster_highlighted_UI_waiting_for_key = false;
return true;
end
@@ -417,10 +419,10 @@ function keyboard.register_hotkey(hard_keyboard)
elseif customization_menu.time_UI_waiting_for_key then
for key, key_name in pairs(keyboard.keys) do
if get_release_method:call(hard_keyboard, key) then
config.current_config.global_settings.hotkeys_with_modifiers.time_UI.ctrl = keyboard.hotkey_modifiers_down.ctrl;
config.current_config.global_settings.hotkeys_with_modifiers.time_UI.shift = keyboard.hotkey_modifiers_down.shift;
config.current_config.global_settings.hotkeys_with_modifiers.time_UI.alt = keyboard.hotkey_modifiers_down.alt;
config.current_config.global_settings.hotkeys_with_modifiers.time_UI.key = key;
cached_config.time_UI.ctrl = keyboard.hotkey_modifiers_down.ctrl;
cached_config.time_UI.shift = keyboard.hotkey_modifiers_down.shift;
cached_config.time_UI.alt = keyboard.hotkey_modifiers_down.alt;
cached_config.time_UI.key = key;
customization_menu.time_UI_waiting_for_key = false;
return true;
end
@@ -428,10 +430,10 @@ function keyboard.register_hotkey(hard_keyboard)
elseif customization_menu.damage_meter_UI_waiting_for_key then
for key, key_name in pairs(keyboard.keys) do
if get_release_method:call(hard_keyboard, key) then
config.current_config.global_settings.hotkeys_with_modifiers.damage_meter_UI.ctrl = keyboard.hotkey_modifiers_down.ctrl;
config.current_config.global_settings.hotkeys_with_modifiers.damage_meter_UI.shift = keyboard.hotkey_modifiers_down.shift;
config.current_config.global_settings.hotkeys_with_modifiers.damage_meter_UI.alt = keyboard.hotkey_modifiers_down.alt;
config.current_config.global_settings.hotkeys_with_modifiers.damage_meter_UI.key = key;
cached_config.damage_meter_UI.ctrl = keyboard.hotkey_modifiers_down.ctrl;
cached_config.damage_meter_UI.shift = keyboard.hotkey_modifiers_down.shift;
cached_config.damage_meter_UI.alt = keyboard.hotkey_modifiers_down.alt;
cached_config.damage_meter_UI.key = key;
customization_menu.damage_meter_UI_waiting_for_key = false;
return true;
end
@@ -439,10 +441,10 @@ function keyboard.register_hotkey(hard_keyboard)
elseif customization_menu.endemic_life_UI_waiting_for_key then
for key, key_name in pairs(keyboard.keys) do
if get_release_method:call(hard_keyboard, key) then
config.current_config.global_settings.hotkeys_with_modifiers.endemic_life_UI.ctrl = keyboard.hotkey_modifiers_down.ctrl;
config.current_config.global_settings.hotkeys_with_modifiers.endemic_life_UI.shift = keyboard.hotkey_modifiers_down.shift;
config.current_config.global_settings.hotkeys_with_modifiers.endemic_life_UI.alt = keyboard.hotkey_modifiers_down.alt;
config.current_config.global_settings.hotkeys_with_modifiers.endemic_life_UI.key = key;
cached_config.endemic_life_UI.ctrl = keyboard.hotkey_modifiers_down.ctrl;
cached_config.endemic_life_UI.shift = keyboard.hotkey_modifiers_down.shift;
cached_config.endemic_life_UI.alt = keyboard.hotkey_modifiers_down.alt;
cached_config.endemic_life_UI.key = key;
customization_menu.endemic_life_UI_waiting_for_key = false;
return true;
end
@@ -453,10 +455,12 @@ function keyboard.register_hotkey(hard_keyboard)
end
function keyboard.check_hotkeys(hard_keyboard)
if not (config.current_config.global_settings.hotkeys_with_modifiers.all_UI.ctrl and not keyboard.hotkey_modifiers_down.ctrl)
and not (config.current_config.global_settings.hotkeys_with_modifiers.all_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (config.current_config.global_settings.hotkeys_with_modifiers.all_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(config.current_config.global_settings.hotkeys_with_modifiers.all_UI.key)) then
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
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
@@ -474,18 +478,18 @@ function keyboard.check_hotkeys(hard_keyboard)
end
end
if not (config.current_config.global_settings.hotkeys_with_modifiers.small_monster_UI.ctrl and not keyboard.hotkey_modifiers_down.ctrl)
and not (config.current_config.global_settings.hotkeys_with_modifiers.small_monster_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (config.current_config.global_settings.hotkeys_with_modifiers.small_monster_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(config.current_config.global_settings.hotkeys_with_modifiers.small_monster_UI.key)) then
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
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 (config.current_config.global_settings.hotkeys_with_modifiers.large_monster_UI.ctrl and not keyboard.hotkey_modifiers_down.ctrl)
and not (config.current_config.global_settings.hotkeys_with_modifiers.large_monster_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (config.current_config.global_settings.hotkeys_with_modifiers.large_monster_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(config.current_config.global_settings.hotkeys_with_modifiers.large_monster_UI.key)) then
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
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
or config.current_config.large_monster_UI.highlighted.enabled;
@@ -496,50 +500,50 @@ function keyboard.check_hotkeys(hard_keyboard)
end
end
if not (config.current_config.global_settings.hotkeys_with_modifiers.large_monster_dynamic_UI.ctrl and not keyboard.hotkey_modifiers_down.ctrl)
and not (config.current_config.global_settings.hotkeys_with_modifiers.large_monster_dynamic_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (config.current_config.global_settings.hotkeys_with_modifiers.large_monster_dynamic_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(config.current_config.global_settings.hotkeys_with_modifiers.large_monster_dynamic_UI.key)) then
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
config.current_config.large_monster_UI.dynamic.enabled = not config.current_config.large_monster_UI.dynamic.enabled;
end
end
if not (config.current_config.global_settings.hotkeys_with_modifiers.large_monster_static_UI.ctrl and not keyboard.hotkey_modifiers_down.ctrl)
and not (config.current_config.global_settings.hotkeys_with_modifiers.large_monster_static_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (config.current_config.global_settings.hotkeys_with_modifiers.large_monster_static_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(config.current_config.global_settings.hotkeys_with_modifiers.large_monster_static_UI.key)) then
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
config.current_config.large_monster_UI.static.enabled = not config.current_config.large_monster_UI.static.enabled;
end
end
if not (config.current_config.global_settings.hotkeys_with_modifiers.large_monster_highlighted_UI.ctrl and not keyboard.hotkey_modifiers_down.ctrl)
and not (config.current_config.global_settings.hotkeys_with_modifiers.large_monster_highlighted_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (config.current_config.global_settings.hotkeys_with_modifiers.large_monster_highlighted_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(config.current_config.global_settings.hotkeys_with_modifiers.large_monster_highlighted_UI.key)) then
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;
end
end
if not (config.current_config.global_settings.hotkeys_with_modifiers.time_UI.ctrl and not keyboard.hotkey_modifiers_down.ctrl)
and not (config.current_config.global_settings.hotkeys_with_modifiers.time_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (config.current_config.global_settings.hotkeys_with_modifiers.time_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(config.current_config.global_settings.hotkeys_with_modifiers.time_UI.key)) then
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
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 (config.current_config.global_settings.hotkeys_with_modifiers.damage_meter_UI.ctrl and not keyboard.hotkey_modifiers_down.ctrl)
and not (config.current_config.global_settings.hotkeys_with_modifiers.damage_meter_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (config.current_config.global_settings.hotkeys_with_modifiers.damage_meter_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(config.current_config.global_settings.hotkeys_with_modifiers.damage_meter_UI.key)) then
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
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 (config.current_config.global_settings.hotkeys_with_modifiers.endemic_life_UI.ctrl and not keyboard.hotkey_modifiers_down.ctrl)
and not (config.current_config.global_settings.hotkeys_with_modifiers.endemic_life_UI.shift and not keyboard.hotkey_modifiers_down.shift)
and not (config.current_config.global_settings.hotkeys_with_modifiers.endemic_life_UI.alt and not keyboard.hotkey_modifiers_down.alt) then
if get_release_method:call(hard_keyboard, math.tointeger(config.current_config.global_settings.hotkeys_with_modifiers.endemic_life_UI.key)) then
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
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
end

View File

@@ -41,10 +41,6 @@ function quest_status.update(args)
end
end
sdk.hook(on_changed_game_status, function(args)
pcall(quest_status.update, args);
end, function(retval) return retval; end);
function quest_status.init()
if singletons.quest_manager == nil then
return;
@@ -121,6 +117,10 @@ function quest_status.init_module()
time = require("MHR_Overlay.Game_Handler.time");
quest_status.init();
sdk.hook(on_changed_game_status, function(args)
pcall(quest_status.update, args);
end, function(retval) return retval; end);
end
return quest_status;

View File

@@ -65,9 +65,11 @@ function screen.get_game_window_size()
end
function screen.calculate_absolute_coordinates(position)
local global_position_modifier = config.current_config.global_settings.modifiers.global_position_modifier;
local _position = {
x = position.x * config.current_config.global_settings.modifiers.global_position_modifier;
y = position.y * config.current_config.global_settings.modifiers.global_position_modifier;
x = position.x * global_position_modifier;
y = position.y * global_position_modifier;
}
-- top left

View File

@@ -43,21 +43,23 @@ function time.tick()
end
function time.update_players_dps()
local cached_config = config.current_config.damage_meter_UI.settings;
local new_total_dps = 0;
for _, _player in pairs(player.list) do
if _player.join_time == -1 then
_player.join_time = time.total_elapsed_seconds;
end
if config.current_config.damage_meter_UI.settings.dps_mode == "Quest Time" then
if cached_config.dps_mode == "Quest Time" then
if time.total_elapsed_seconds > 0 then
_player.dps = _player.display.total_damage / time.total_elapsed_seconds;
end
elseif config.current_config.damage_meter_UI.settings.dps_mode == "Join Time" then
elseif cached_config.dps_mode == "Join Time" then
if time.total_elapsed_seconds - _player.join_time > 0 then
_player.dps = _player.display.total_damage / (time.total_elapsed_seconds - _player.join_time);
end
elseif config.current_config.damage_meter_UI.settings.dps_mode == "First Hit" then
elseif cached_config.dps_mode == "First Hit" then
if time.total_elapsed_seconds - _player.first_hit_time > 0 then
_player.dps = _player.display.total_damage / (time.total_elapsed_seconds - _player.first_hit_time);
end