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 ######################################################################################################### -- ##### Hooks #########################################################################################################
-- ##################################################################################################################### -- #####################################################################################################################
vmf:hook("GameModeManager.complete_level", function(func, ...) vmf:hook(GameModeManager, "complete_level", function(func, ...)
local num_dice = 0 local num_dice = 0
local max_dice = 7 local max_dice = 7
local mission_system = Managers.state.entity:system("mission_system") local mission_system = Managers.state.entity:system("mission_system")

View file

@ -57,7 +57,7 @@ end
-- ##################################################################################################################### -- #####################################################################################################################
-- Append difficulty name with enabled mutators' titles -- 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_settings = Managers.state.difficulty:get_difficulty_settings()
local difficulty_name = difficulty_settings.display_name 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 -- Notify everybody about enabled/disabled mutators when Play button is pressed on the map screen
vmf:hook("MatchmakingStateHostGame.host_game", function(func, ...) vmf:hook_safe(MatchmakingStateHostGame, "host_game", function()
func(...)
set_lobby_data() set_lobby_data()
local names = add_enabled_mutators_titles_to_string(", ") local names = add_enabled_mutators_titles_to_string(", ")
if names ~= "" then if names ~= "" then
@ -90,8 +89,9 @@ vmf:hook("MatchmakingStateHostGame.host_game", function(func, ...)
end) 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 -- 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(", ") local name = add_enabled_mutators_titles_to_string(", ")
if name ~= "" then if name ~= "" then
local message = vmf:localize("whisper_enabled_mutators") .. ": " .. name local message = vmf:localize("whisper_enabled_mutators") .. ": " .. name

View file

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

View file

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

View file

@ -72,8 +72,7 @@ end
-- ##### Hooks ######################################################################################################## -- ##### Hooks ########################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
vmf:hook("IngameUI.setup_views", function(func, self, ingame_ui_context) vmf:hook_safe(IngameUI, "setup_views", function(self, ingame_ui_context)
func(self, ingame_ui_context)
for view_name, view_settings in pairs(views_settings) do 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
end) end)
vmf:hook("IngameUI.init", function(func, self, ingame_ui_context) vmf:hook_safe(IngameUI, "init", function(self)
func(self, ingame_ui_context)
ingame_ui = self ingame_ui = self
end) end)
vmf:hook("IngameUI.destroy", function(func, self) vmf:hook_safe(IngameUI, "destroy", function()
func(self)
ingame_ui = nil ingame_ui = nil
end) end)

View file

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

View file

@ -46,25 +46,19 @@ end
-- ##### Hooks ######################################################################################################## -- ##### Hooks ########################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
vmf:hook("WorldManager.create_world", function(func, self, name, ...) vmf:hook_safe(WorldManager, "create_world", function(self_, name)
local world = func(self, name, ...)
if name == "top_ingame_view" then if name == "top_ingame_view" then
initialize_drawing_function() initialize_drawing_function()
end end
return world
end) end)
vmf:hook("ChatGui.block_input", function(func, ...) vmf:hook_safe("ChatGui", "block_input", function()
func(...)
_chat_opened = true _chat_opened = true
end) 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 local command_executed = false

View file

@ -383,15 +383,12 @@ end
-- ##### Hooks ######################################################################################################## -- ##### Hooks ########################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
vmf:hook("MapView.init", function (func, self, ingame_ui_context) vmf:hook_safe(MapView, "init", function (self)
func(self, ingame_ui_context)
initialize_mutators_ui(self) initialize_mutators_ui(self)
end) end)
vmf:hook("MapView.update", function (func, self, dt, t) vmf:hook_safe(MapView, "update", function (self, dt)
func(self, dt, t)
if self.menu_active and _IS_MUTATORS_GUI_INITIALIZED then 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") change_mods_options_button_state("disable")
end end
-- @BUG: Game crashes occasionaly here. See attached log
-- create mods options menu button in Esc-menu -- 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 = { local mods_options_button = {
display_name = vmf:localize("mods_options"), display_name = vmf:localize("mods_options"),
@ -4595,7 +4594,7 @@ vmf:hook("IngameView.setup_button_layout", function (func, self, layout_data)
end end
end end
func(self, layout_data) func(self, layout_data, ...)
for _, button_info in ipairs(self.active_button_data) do for _, button_info in ipairs(self.active_button_data) do
if button_info.transition == "vmf_options_view" then if button_info.transition == "vmf_options_view" then