Updated hooks definitions

This commit is contained in:
bi 2018-06-18 19:50:58 +03:00
parent 5b153657e7
commit e0e519fbad
9 changed files with 28 additions and 47 deletions

View file

@ -39,7 +39,7 @@ end
-- ##### Hooks #########################################################################################################
-- #####################################################################################################################
vmf:hook("GameModeManager.complete_level", function(func, ...)
vmf:hook(GameModeManager, "complete_level", function(func, ...)
local num_dice = 0
local max_dice = 7
local mission_system = Managers.state.entity:system("mission_system")

View file

@ -57,7 +57,7 @@ end
-- #####################################################################################################################
-- Append difficulty name with enabled mutators' titles
vmf:hook("IngamePlayerListUI.update_difficulty", function(func_, self)
vmf:hook_origin(IngamePlayerListUI, "update_difficulty", function(self)
local difficulty_settings = Managers.state.difficulty:get_difficulty_settings()
local difficulty_name = difficulty_settings.display_name
@ -76,8 +76,7 @@ end)
-- Notify everybody about enabled/disabled mutators when Play button is pressed on the map screen
vmf:hook("MatchmakingStateHostGame.host_game", function(func, ...)
func(...)
vmf:hook_safe(MatchmakingStateHostGame, "host_game", function()
set_lobby_data()
local names = add_enabled_mutators_titles_to_string(", ")
if names ~= "" then
@ -90,8 +89,9 @@ vmf:hook("MatchmakingStateHostGame.host_game", function(func, ...)
end)
-- @TODO: can't I do it with hook_safe? Also can't I just use 'sender' intead of extracting peer_id form cookie?
-- Send special messages with enabled mutators list to players just joining the lobby
vmf:hook("MatchmakingManager.rpc_matchmaking_request_join_lobby", function(func, self, sender, client_cookie, ...)
vmf:hook(MatchmakingManager, "rpc_matchmaking_request_join_lobby", function(func, self, sender, client_cookie, ...)
local name = add_enabled_mutators_titles_to_string(", ")
if name ~= "" then
local message = vmf:localize("whisper_enabled_mutators") .. ": " .. name

View file

@ -493,8 +493,7 @@ end
-- ##### Hooks #########################################################################################################
-- #####################################################################################################################
vmf:hook("DifficultyManager.set_difficulty", function(func, ...)
func(...)
vmf:hook_safe(DifficultyManager, "set_difficulty", function()
disable_impossible_mutators(true, "disabled_reason_difficulty_change")
end)

View file

@ -227,8 +227,8 @@ end
-- ##### Hooks ########################################################################################################
-- ####################################################################################################################
vmf:hook("ChatManager.rpc_chat_message",
function(func, self, sender, channel_id, message_sender, message, localization_param, ...)
vmf:hook("ChatManager", "rpc_chat_message",
function(func, self, sender, channel_id, message_sender, message, localization_param, ...)
if channel_id == VERMINTIDE_CHANNEL_ID then
@ -299,16 +299,16 @@ vmf:hook("ChatManager.rpc_chat_message",
end
end)
vmf:hook("PlayerManager.add_remote_player", function (func, self, peer_id, player_controlled, local_player_id, clan_tag)
vmf:hook(PlayerManager, "add_remote_player", function (func, self, peer_id, player_controlled, ...)
if player_controlled then
send_rpc_vmf_ping(peer_id)
end
return func(self, peer_id, player_controlled, local_player_id, clan_tag)
return func(self, peer_id, player_controlled, ...)
end)
vmf:hook("PlayerManager.remove_player", function (func, self, peer_id, local_player_id)
vmf:hook(PlayerManager, "remove_player", function (func, self, peer_id, ...)
if _vmf_users[peer_id] then
@ -332,7 +332,7 @@ vmf:hook("PlayerManager.remove_player", function (func, self, peer_id, local_pla
end
end
func(self, peer_id, local_player_id)
func(self, peer_id, ...)
end)
-- ####################################################################################################################

View file

@ -72,8 +72,7 @@ end
-- ##### Hooks ########################################################################################################
-- ####################################################################################################################
vmf:hook("IngameUI.setup_views", function(func, self, ingame_ui_context)
func(self, ingame_ui_context)
vmf:hook_safe(IngameUI, "setup_views", function(self, ingame_ui_context)
for view_name, view_settings in pairs(views_settings) do
@ -97,15 +96,11 @@ vmf:hook("IngameUI.setup_views", function(func, self, ingame_ui_context)
end
end)
vmf:hook("IngameUI.init", function(func, self, ingame_ui_context)
func(self, ingame_ui_context)
vmf:hook_safe(IngameUI, "init", function(self)
ingame_ui = self
end)
vmf:hook("IngameUI.destroy", function(func, self)
func(self)
vmf:hook_safe(IngameUI, "destroy", function()
ingame_ui = nil
end)

View file

@ -173,7 +173,7 @@ end
-- ####################################################################################################################
local LUA_SCRIPT_CALLER_POSITION = 4
vmf:hook("UIRenderer.create", function(func, world, ...)
vmf:hook(UIRenderer, "create", function(func, world, ...)
local is_modified = false
@ -239,25 +239,22 @@ vmf:hook("UIRenderer.create", function(func, world, ...)
end)
vmf:hook("UIRenderer.destroy", function(func, self, world)
vmf:hook_safe(UIRenderer, "destroy", function(self)
_ui_renderers[self] = nil
func(self, world)
end)
vmf:hook("UIAtlasHelper.has_atlas_settings_by_texture_name", function(func, texture_name)
vmf:hook(UIAtlasHelper, "has_atlas_settings_by_texture_name", function(func, texture_name, ...)
if _custom_ui_atlas_settings[texture_name] then
return true
end
return func(texture_name)
return func(texture_name, ...)
end)
vmf:hook("UIAtlasHelper.get_atlas_settings_by_texture_name", function(func, texture_name)
vmf:hook(UIAtlasHelper, "get_atlas_settings_by_texture_name", function(func, texture_name, ...)
if _custom_none_atlas_textures[texture_name] then
return
@ -267,7 +264,7 @@ vmf:hook("UIAtlasHelper.get_atlas_settings_by_texture_name", function(func, text
return _custom_ui_atlas_settings[texture_name]
end
return func(texture_name)
return func(texture_name, ...)
end)
-- ####################################################################################################################

View file

@ -46,25 +46,19 @@ end
-- ##### Hooks ########################################################################################################
-- ####################################################################################################################
vmf:hook("WorldManager.create_world", function(func, self, name, ...)
local world = func(self, name, ...)
vmf:hook_safe(WorldManager, "create_world", function(self_, name)
if name == "top_ingame_view" then
initialize_drawing_function()
end
return world
end)
vmf:hook("ChatGui.block_input", function(func, ...)
func(...)
vmf:hook_safe("ChatGui", "block_input", function()
_chat_opened = true
end)
vmf:hook("ChatGui._update_input", function(func, self, input_service, menu_input_service, dt, no_unblock, chat_enabled)
vmf:hook("ChatGui", "_update_input", function(func, self, input_service, menu_input_service, dt, no_unblock, chat_enabled)
local command_executed = false

View file

@ -383,15 +383,12 @@ end
-- ##### Hooks ########################################################################################################
-- ####################################################################################################################
vmf:hook("MapView.init", function (func, self, ingame_ui_context)
func(self, ingame_ui_context)
vmf:hook_safe(MapView, "init", function (self)
initialize_mutators_ui(self)
end)
vmf:hook("MapView.update", function (func, self, dt, t)
func(self, dt, t)
vmf:hook_safe(MapView, "update", function (self, dt)
if self.menu_active and _IS_MUTATORS_GUI_INITIALIZED then

View file

@ -4578,9 +4578,8 @@ vmf.disable_mods_options_button = function ()
change_mods_options_button_state("disable")
end
-- @BUG: Game crashes occasionaly here. See attached log
-- create mods options menu button in Esc-menu
vmf:hook("IngameView.setup_button_layout", function (func, self, layout_data)
vmf:hook(IngameView, "setup_button_layout", function (func, self, layout_data, ...)
local mods_options_button = {
display_name = vmf:localize("mods_options"),
@ -4595,7 +4594,7 @@ vmf:hook("IngameView.setup_button_layout", function (func, self, layout_data)
end
end
func(self, layout_data)
func(self, layout_data, ...)
for _, button_info in ipairs(self.active_button_data) do
if button_info.transition == "vmf_options_view" then