mutators: gui rewrite part 1 (no checkboxes yet)
gui_mod is no longer needed, will be removed next commit created a separate mod for mutators manager
This commit is contained in:
parent
a28a09f15c
commit
15b89cdd0a
10 changed files with 507 additions and 62 deletions
|
@ -21,5 +21,4 @@ lua = [
|
|||
"scripts/mods/vmf/modules/gui/*"
|
||||
"scripts/mods/vmf/modules/options_menu/*"
|
||||
"scripts/mods/vmf/modules/mutators/*"
|
||||
"scripts/mods/vmf/modules/mod_gui/*"
|
||||
]
|
|
@ -1,5 +1,5 @@
|
|||
local vmf = get_mod("VMF")
|
||||
local mutators = vmf.mutators
|
||||
local manager = get_mod("vmf_mutator_manager")
|
||||
local mutators = manager.mutators
|
||||
|
||||
|
||||
local banner_level_widget = UIWidgets.create_texture_with_text_and_tooltip("title_bar", "Mutators", "map_level_setting_tooltip", "banner_level", "banner_level_text", {
|
||||
|
@ -50,7 +50,7 @@ local function create_window(map_view)
|
|||
|
||||
for i, mutator in ipairs(mutators) do
|
||||
local title = mutator:get_config().title or mutator:get_name()
|
||||
window:create_checkbox("checkbox_" .. mutator:get_name(), {30, 360 - 40 * (i - 1)}, {30, 30}, title, mutator:is_enabled(), function(self)
|
||||
window:create_checkbox("checkbox_" .. mutator:get_name(), {65, 360 - 40 * (i - 1)}, {30, 30}, title, mutator:is_enabled(), function(self)
|
||||
if self.value then
|
||||
if not mutator:is_enabled() and mutator:can_be_enabled() then
|
||||
mutator:enable()
|
||||
|
@ -85,58 +85,58 @@ local function reload_window()
|
|||
end
|
||||
end
|
||||
|
||||
vmf:hook("MapView.on_enter", function(func, self, ...)
|
||||
manager:hook("MapView.on_enter", function(func, self, ...)
|
||||
func(self, ...)
|
||||
print("on_enter")
|
||||
|
||||
vmf.sort_mutators()
|
||||
vmf.disable_impossible_mutators()
|
||||
vmf:pcall(function() create_window(self) end)
|
||||
manager.sort_mutators()
|
||||
manager.disable_impossible_mutators()
|
||||
manager:pcall(function() create_window(self) end)
|
||||
end)
|
||||
|
||||
vmf:hook("MapView.on_level_index_changed", function(func, self, ...)
|
||||
manager:hook("MapView.on_level_index_changed", function(func, self, ...)
|
||||
func(self, ...)
|
||||
print("on_level_index_changed")
|
||||
|
||||
vmf.disable_impossible_mutators()
|
||||
vmf:pcall(function() create_window(self) end)
|
||||
manager.disable_impossible_mutators()
|
||||
manager:pcall(function() create_window(self) end)
|
||||
end)
|
||||
|
||||
vmf:hook("MapView.on_difficulty_index_changed", function(func, self, ...)
|
||||
manager:hook("MapView.on_difficulty_index_changed", function(func, self, ...)
|
||||
func(self, ...)
|
||||
print("on_difficulty_index_changed")
|
||||
|
||||
vmf.disable_impossible_mutators()
|
||||
vmf:pcall(function() create_window(self) end)
|
||||
manager.disable_impossible_mutators()
|
||||
manager:pcall(function() create_window(self) end)
|
||||
end)
|
||||
|
||||
vmf:hook("MapView.set_difficulty_stepper_index", function(func, self, ...)
|
||||
manager:hook("MapView.set_difficulty_stepper_index", function(func, self, ...)
|
||||
func(self, ...)
|
||||
print("set_difficulty_stepper_index")
|
||||
|
||||
vmf.disable_impossible_mutators()
|
||||
vmf:pcall(function() create_window(self) end)
|
||||
manager.disable_impossible_mutators()
|
||||
manager:pcall(function() create_window(self) end)
|
||||
end)
|
||||
|
||||
vmf:hook("MapView.on_exit", function(func, self, ...)
|
||||
manager:hook("MapView.on_exit", function(func, self, ...)
|
||||
func(self, ...)
|
||||
print("on_exit")
|
||||
vmf:pcall(function() destroy_window(self) end)
|
||||
manager:pcall(function() destroy_window(self) end)
|
||||
window_opened = false
|
||||
end)
|
||||
|
||||
vmf:hook("MapView.suspend", function(func, self, ...)
|
||||
manager:hook("MapView.suspend", function(func, self, ...)
|
||||
func(self, ...)
|
||||
print("suspend")
|
||||
vmf:pcall(function() destroy_window(self) end)
|
||||
manager:pcall(function() destroy_window(self) end)
|
||||
end)
|
||||
|
||||
vmf:hook("MapView.update", function(func, self, dt, t)
|
||||
manager:hook("MapView.update", function(func, self, dt, t)
|
||||
func(self, dt, t)
|
||||
vmf:pcall(function() update_window_visibility(self) end)
|
||||
manager:pcall(function() update_window_visibility(self) end)
|
||||
end)
|
||||
|
||||
vmf:hook("MapView.draw", function(func, self, input_service, gamepad_active, dt)
|
||||
manager:hook("MapView.draw", function(func, self, input_service, gamepad_active, dt)
|
||||
local ui_renderer = self.ui_renderer
|
||||
local ui_scenegraph = self.ui_scenegraph
|
||||
|
||||
|
@ -157,7 +157,6 @@ vmf:hook("MapView.draw", function(func, self, input_service, gamepad_active, dt)
|
|||
if window_opened or not self.settings_button_widget.content.toggled then
|
||||
for widget_name, widget in pairs(self.normal_settings_widgets) do
|
||||
local skipped_widgets_keys = {
|
||||
"stepper_level",
|
||||
"level_preview",
|
||||
"level_preview_text",
|
||||
"banner_level"
|
||||
|
@ -167,7 +166,7 @@ vmf:hook("MapView.draw", function(func, self, input_service, gamepad_active, dt)
|
|||
end
|
||||
end
|
||||
if window_opened then
|
||||
vmf:pcall(function() UIRenderer.draw_widget(ui_renderer, banner_level) end)
|
||||
manager:pcall(function() UIRenderer.draw_widget(ui_renderer, banner_level) end)
|
||||
end
|
||||
else
|
||||
for widget_name, widget in pairs(self.advanced_settings_widgets) do
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
local vmf = get_mod("VMF")
|
||||
local manager = get_mod("vmf_mutator_manager")
|
||||
|
||||
local missions = {
|
||||
"bonus_dice_hidden_mission",
|
||||
|
@ -12,7 +12,7 @@ local num_dice_per_mission = {
|
|||
grimoire_hidden_mission = 0
|
||||
}
|
||||
|
||||
vmf:hook("GameModeManager.complete_level", function(func, self)
|
||||
manager:hook("GameModeManager.complete_level", function(func, self)
|
||||
local num_dice = 0
|
||||
local max_dice = 7
|
||||
local mission_system = Managers.state.entity:system("mission_system")
|
269
vmf_source/scripts/mods/vmf/modules/mutators/mutator_gui.lua
Normal file
269
vmf_source/scripts/mods/vmf/modules/mutators/mutator_gui.lua
Normal file
|
@ -0,0 +1,269 @@
|
|||
local manager = get_mod("vmf_mutator_manager")
|
||||
local mutators = manager.mutators
|
||||
|
||||
local definitions = manager:dofile("scripts/mods/vmf/modules/mutators/mutator_gui_definitions")
|
||||
|
||||
local PER_PAGE = 5
|
||||
|
||||
local mutators_view = {
|
||||
|
||||
initialized = false,
|
||||
active = false,
|
||||
was_active = false,
|
||||
map_view = nil,
|
||||
current_page = 1,
|
||||
|
||||
init = function(self, map_view)
|
||||
if self.initialized then return end
|
||||
|
||||
self.map_view = map_view
|
||||
if not self.map_view then return end
|
||||
|
||||
-- Recreate the map_view scenegraph defs
|
||||
self.map_view.scenegraph_definition = UISceneGraph.init_scenegraph(definitions.scenegraph_definition)
|
||||
|
||||
-- Setup custom widgets
|
||||
self.widgets = {
|
||||
banner_mutators = UIWidget.init(definitions.new_widgets.banner_mutators_widget),
|
||||
mutators_button = UIWidget.init(definitions.new_widgets.mutators_button_widget),
|
||||
}
|
||||
|
||||
-- Save widgets we're gonna mess with
|
||||
local widgets = self.map_view.normal_settings_widget_types
|
||||
self.saved_widgets = {
|
||||
level_preview = widgets.adventure.level_preview,
|
||||
level_preview_text = widgets.adventure.level_preview_text
|
||||
}
|
||||
|
||||
-- Add our button to render lists
|
||||
widgets.adventure.mutators_button = self.widgets.mutators_button
|
||||
widgets.survival.mutators_button = self.widgets.mutators_button
|
||||
self.map_view.advanced_settings_widgets.mutators_button = self.widgets.mutators_button
|
||||
|
||||
-- Move other buttons over
|
||||
self.map_view.ui_scenegraph.settings_button.position[1] = -50
|
||||
self.map_view.ui_scenegraph.lobby_button.position[1] = 150
|
||||
self.map_view.ui_scenegraph.friends_button.position[1] = 50
|
||||
|
||||
-- Alter level select stepper's callback
|
||||
self.map_view.steppers.level.callback = function(index_change)
|
||||
self:on_mutators_page_change(index_change)
|
||||
end
|
||||
|
||||
self:setup_hooks()
|
||||
|
||||
self.initialized = true
|
||||
print("INIT")
|
||||
end,
|
||||
|
||||
deinitialize = function(self)
|
||||
if not self.initialized then return end
|
||||
|
||||
self:deactivate()
|
||||
self.was_active = false
|
||||
|
||||
-- Reset the stepper callback
|
||||
self.map_view.steppers.level.callback = callback(self.map_view, "on_level_index_changed")
|
||||
|
||||
-- Remove our button
|
||||
self.map_view.normal_settings_widget_types.adventure.mutators_button = nil
|
||||
self.map_view.normal_settings_widget_types.survival.mutators_button = nil
|
||||
self.map_view.advanced_settings_widgets.mutators_button = nil
|
||||
|
||||
-- Move other buttons back
|
||||
self.map_view.ui_scenegraph.settings_button.position[1] = -100
|
||||
self.map_view.ui_scenegraph.lobby_button.position[1] = 100
|
||||
self.map_view.ui_scenegraph.friends_button.position[1] = 0
|
||||
|
||||
self.saved_widgets = {}
|
||||
|
||||
self:reset_hooks()
|
||||
|
||||
self.map_view = nil
|
||||
|
||||
self.initialized = false
|
||||
print("DEINIT")
|
||||
end,
|
||||
|
||||
update = function(self)
|
||||
if not self.initialized then
|
||||
self:init()
|
||||
end
|
||||
|
||||
if not self.initialized or not self.map_view.active then return end
|
||||
|
||||
local transitioning = self.map_view:transitioning()
|
||||
local friends = self.map_view.friends
|
||||
local friends_menu_active = friends:is_active()
|
||||
|
||||
local mutators_button = self.widgets.mutators_button
|
||||
local mutators_button_hotspot = mutators_button.content.button_hotspot
|
||||
local settings_button = self.map_view.settings_button_widget
|
||||
|
||||
-- Handle menu toggles
|
||||
if not transitioning and not friends_menu_active then
|
||||
if mutators_button_hotspot.on_release then
|
||||
self.map_view:play_sound("Play_hud_select")
|
||||
mutators_button.content.toggled = not mutators_button.content.toggled
|
||||
if mutators_button.content.toggled then
|
||||
settings_button.content.toggled = false
|
||||
end
|
||||
elseif settings_button.content.toggled then
|
||||
mutators_button.content.toggled = false
|
||||
end
|
||||
end
|
||||
|
||||
-- Open/close mutators view
|
||||
if mutators_button.content.toggled then
|
||||
self:activate()
|
||||
self.was_active = true
|
||||
else
|
||||
self:deactivate()
|
||||
self.was_active = false
|
||||
end
|
||||
|
||||
if self.active then
|
||||
-- Disable the Mission banner tooltip
|
||||
local widgets = self.map_view.normal_settings_widget_types
|
||||
widgets.adventure.banner_level.content.tooltip_hotspot.disabled = true
|
||||
widgets.survival.banner_level.content.tooltip_hotspot.disabled = true
|
||||
end
|
||||
end,
|
||||
|
||||
activate = function(self)
|
||||
if not self.initialized or not self.map_view.active or self.active then return end
|
||||
|
||||
-- Hiding widgets
|
||||
local widgets = self.map_view.normal_settings_widget_types
|
||||
|
||||
widgets.adventure.level_preview = nil
|
||||
widgets.adventure.level_preview_text = nil
|
||||
widgets.adventure.banner_mutators = self.widgets.banner_mutators
|
||||
|
||||
widgets.survival.level_preview = nil
|
||||
widgets.survival.level_preview_text = nil
|
||||
widgets.survival.banner_mutators = self.widgets.banner_mutators
|
||||
|
||||
-- "Mission" banner position
|
||||
self.map_view.ui_scenegraph.banner_level_text.position[2] = -10000
|
||||
|
||||
-- Update steppers
|
||||
self.map_view.steppers.level.widget.style.setting_text.offset[2] = -10000
|
||||
local level_stepper_widget = self.map_view.steppers.level.widget
|
||||
local num_pages = math.ceil(#mutators/PER_PAGE)
|
||||
level_stepper_widget.content.left_button_hotspot.disable_button = num_pages <= 1
|
||||
level_stepper_widget.content.right_button_hotspot.disable_button = num_pages <= 1
|
||||
|
||||
self.active = true
|
||||
|
||||
print("ACTIVE")
|
||||
end,
|
||||
|
||||
deactivate = function(self)
|
||||
if not self.initialized or not self.active then return end
|
||||
|
||||
-- Showing widgets
|
||||
local widgets = self.map_view.normal_settings_widget_types
|
||||
|
||||
widgets.adventure.level_preview = self.saved_widgets.level_preview
|
||||
widgets.adventure.level_preview_text = self.saved_widgets.level_preview
|
||||
widgets.adventure.banner_mutators = nil
|
||||
|
||||
widgets.survival.level_preview = self.saved_widgets.level_preview
|
||||
widgets.survival.level_preview_text = self.saved_widgets.level_preview
|
||||
widgets.survival.banner_mutators = nil
|
||||
|
||||
-- "Mission" banner position
|
||||
self.map_view.ui_scenegraph.banner_level_text.position[2] = 0
|
||||
|
||||
-- Update steppers
|
||||
self.map_view.steppers.level.widget.style.setting_text.offset[2] = -120
|
||||
self.map_view:update_level_stepper()
|
||||
|
||||
self.active = false
|
||||
|
||||
print("DEACTIVE")
|
||||
end,
|
||||
|
||||
on_mutators_page_change = function(self, index_change)
|
||||
if not self.initialized then return end
|
||||
|
||||
if self.active then
|
||||
local current_index = self.current_page
|
||||
local new_index = current_index + index_change
|
||||
local num_pages = math.ceil(#mutators/PER_PAGE)
|
||||
|
||||
if new_index < 1 then
|
||||
new_index = num_pages
|
||||
elseif num_pages < new_index then
|
||||
new_index = 1
|
||||
end
|
||||
|
||||
self.current_page = new_index
|
||||
print("TEST", tostring(new_index))
|
||||
else
|
||||
self.map_view:on_level_index_changed(index_change)
|
||||
end
|
||||
end,
|
||||
|
||||
setup_hooks = function(self)
|
||||
|
||||
-- Update the view after map_view has updated
|
||||
manager:hook("MapView.update", function(func, map_view, dt, t)
|
||||
func(map_view, dt, t)
|
||||
manager:pcall(function() self:update(dt, t) end)
|
||||
end)
|
||||
|
||||
-- Activate the view on enter if it was active on exit
|
||||
manager:hook("MapView.on_enter", function(func, map_view)
|
||||
func(map_view)
|
||||
if self.was_active then
|
||||
self.widgets.mutators_button.content.toggled = true
|
||||
manager:pcall(function() self:activate() end)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Deactivate the view on exit
|
||||
manager:hook("MapView.on_exit", function(func, map_view)
|
||||
func(map_view)
|
||||
manager:pcall(function() self:deactivate() end)
|
||||
end)
|
||||
|
||||
-- We don't want to let the game disable steppers when mutators view is active
|
||||
manager:hook("MapView.update_level_stepper", function(func, map_view)
|
||||
if not self.active then
|
||||
func(map_view)
|
||||
end
|
||||
end)
|
||||
end,
|
||||
|
||||
reset_hooks = function(self)
|
||||
manager:hook_remove("MapView.update")
|
||||
manager:hook_remove("MapView.on_enter")
|
||||
manager:hook_remove("MapView.on_exit")
|
||||
manager:hook_remove("MapView.update_level_stepper")
|
||||
end,
|
||||
}
|
||||
|
||||
-- Initialize mutators view after map view
|
||||
manager:hook("MapView.init", function(func, self, ...)
|
||||
func(self, ...)
|
||||
manager:pcall(function() mutators_view:init(self) end)
|
||||
end)
|
||||
|
||||
-- Destroy mutators view after map view
|
||||
manager:hook("MapView.destroy", function(func, ...)
|
||||
mutators_view:deinitialize()
|
||||
func(...)
|
||||
end)
|
||||
|
||||
|
||||
-- Initialize mutators view when map_view has been initialized already
|
||||
local function get_map_view()
|
||||
local ingame_ui = Managers.matchmaking and Managers.matchmaking.ingame_ui
|
||||
return ingame_ui and ingame_ui.views and ingame_ui.views.map_view
|
||||
end
|
||||
|
||||
manager:pcall(function() mutators_view:init(get_map_view()) end)
|
||||
|
||||
return mutators_view
|
|
@ -0,0 +1,172 @@
|
|||
local definitions = local_require("scripts/ui/views/map_view_definitions")
|
||||
|
||||
definitions.scenegraph_definition.mutators_button = {
|
||||
vertical_alignment = "bottom",
|
||||
parent = "banner_party",
|
||||
horizontal_alignment = "center",
|
||||
size = {
|
||||
64,
|
||||
64
|
||||
},
|
||||
position = {
|
||||
-150,
|
||||
90,
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
definitions.scenegraph_definition.banner_mutators_text = {
|
||||
vertical_alignment = "center",
|
||||
parent = "banner_level",
|
||||
horizontal_alignment = "center",
|
||||
size = {
|
||||
300,
|
||||
40
|
||||
},
|
||||
position = {
|
||||
0,
|
||||
0,
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
definitions.new_widgets = {
|
||||
banner_mutators_widget = UIWidgets.create_texture_with_text_and_tooltip("title_bar", "Mutators", "Enable and disable mutators", "banner_level", "banner_mutators_text", {
|
||||
vertical_alignment = "center",
|
||||
scenegraph_id = "banner_mutators_text",
|
||||
localize = false,
|
||||
font_size = 28,
|
||||
horizontal_alignment = "center",
|
||||
font_type = "hell_shark",
|
||||
text_color = Colors.get_color_table_with_alpha("cheeseburger", 255)
|
||||
},
|
||||
{
|
||||
font_size = 24,
|
||||
max_width = 500,
|
||||
localize = false,
|
||||
horizontal_alignment = "left",
|
||||
vertical_alignment = "top",
|
||||
font_type = "hell_shark",
|
||||
text_color = Colors.get_color_table_with_alpha("white", 255),
|
||||
line_colors = {},
|
||||
offset = {
|
||||
0,
|
||||
0,
|
||||
50
|
||||
}
|
||||
}),
|
||||
mutators_button_widget = {
|
||||
element = UIElements.ToggleIconButton,
|
||||
content = {
|
||||
click_texture = "octagon_button_clicked",
|
||||
toggle_hover_texture = "octagon_button_toggled_hover",
|
||||
toggle_texture = "octagon_button_toggled",
|
||||
hover_texture = "octagon_button_hover",
|
||||
normal_texture = "octagon_button_normal",
|
||||
icon_texture = "map_icon_browser_01",
|
||||
icon_hover_texture = "map_icon_browser_01",
|
||||
tooltip_text = "Mutators",
|
||||
toggled_tooltip_text = "Mutators",
|
||||
button_hotspot = {}
|
||||
},
|
||||
style = {
|
||||
normal_texture = {
|
||||
color = {
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255
|
||||
}
|
||||
},
|
||||
hover_texture = {
|
||||
color = {
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255
|
||||
}
|
||||
},
|
||||
click_texture = {
|
||||
color = {
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255
|
||||
}
|
||||
},
|
||||
toggle_texture = {
|
||||
color = {
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255
|
||||
}
|
||||
},
|
||||
toggle_hover_texture = {
|
||||
color = {
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255
|
||||
}
|
||||
},
|
||||
icon_texture = {
|
||||
color = {
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255
|
||||
},
|
||||
offset = {
|
||||
0,
|
||||
0,
|
||||
1
|
||||
}
|
||||
},
|
||||
icon_hover_texture = {
|
||||
color = {
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255
|
||||
},
|
||||
offset = {
|
||||
0,
|
||||
0,
|
||||
1
|
||||
}
|
||||
},
|
||||
icon_click_texture = {
|
||||
color = {
|
||||
255,
|
||||
255,
|
||||
255,
|
||||
255
|
||||
},
|
||||
offset = {
|
||||
0,
|
||||
-1,
|
||||
1
|
||||
}
|
||||
},
|
||||
tooltip_text = {
|
||||
font_size = 24,
|
||||
max_width = 500,
|
||||
localize = false,
|
||||
horizontal_alignment = "left",
|
||||
vertical_alignment = "top",
|
||||
font_type = "hell_shark",
|
||||
text_color = Colors.get_color_table_with_alpha("white", 255),
|
||||
line_colors = {},
|
||||
offset = {
|
||||
0,
|
||||
0,
|
||||
20
|
||||
}
|
||||
}
|
||||
},
|
||||
scenegraph_id = "mutators_button"
|
||||
}
|
||||
}
|
||||
|
||||
return definitions
|
|
@ -1,5 +1,5 @@
|
|||
local vmf = get_mod("VMF")
|
||||
local mutators = vmf.mutators
|
||||
local manager = get_mod("vmf_mutator_manager")
|
||||
local mutators = manager.mutators
|
||||
|
||||
local were_enabled_before = false
|
||||
|
||||
|
@ -59,7 +59,7 @@ local function get_member_func(client_cookie)
|
|||
end
|
||||
|
||||
|
||||
vmf:hook("IngamePlayerListUI.set_difficulty_name", function(func, self, name)
|
||||
manager:hook("IngamePlayerListUI.set_difficulty_name", function(func, self, name)
|
||||
local mutators_name = get_enabled_mutators_names(true)
|
||||
if mutators_name then
|
||||
name = name .. " " .. mutators_name
|
||||
|
@ -67,7 +67,7 @@ vmf:hook("IngamePlayerListUI.set_difficulty_name", function(func, self, name)
|
|||
self.headers.content.game_difficulty = name
|
||||
end)
|
||||
|
||||
vmf:hook("MatchmakingStateHostGame.host_game", function(func, self, ...)
|
||||
manager:hook("MatchmakingStateHostGame.host_game", function(func, self, ...)
|
||||
func(self, ...)
|
||||
set_lobby_data()
|
||||
local names = get_enabled_mutators_names()
|
||||
|
@ -80,13 +80,13 @@ vmf:hook("MatchmakingStateHostGame.host_game", function(func, self, ...)
|
|||
end
|
||||
end)
|
||||
|
||||
vmf:hook("MatchmakingManager.rpc_matchmaking_request_join_lobby", function(func, self, sender, client_cookie, host_cookie, lobby_id, friend_join)
|
||||
manager:hook("MatchmakingManager.rpc_matchmaking_request_join_lobby", function(func, self, sender, client_cookie, host_cookie, lobby_id, friend_join)
|
||||
local name = get_enabled_mutators_names(false)
|
||||
if name then
|
||||
local message = "[Automated message] This lobby has the following difficulty mod active : " .. name
|
||||
vmf:hook("Managers.chat.channels[1].members_func", get_member_func(client_cookie))
|
||||
manager:hook("Managers.chat.channels[1].members_func", get_member_func(client_cookie))
|
||||
Managers.chat:send_system_chat_message(1, message, 0, true)
|
||||
vmf:hook_remove("Managers.chat.channels[1].members_func")
|
||||
manager:hook_remove("Managers.chat.channels[1].members_func")
|
||||
end
|
||||
func(self, sender, client_cookie, host_cookie, lobby_id, friend_join)
|
||||
end)
|
|
@ -1,13 +1,13 @@
|
|||
local vmf = get_mod("VMF")
|
||||
local manager = new_mod("vmf_mutator_manager")
|
||||
|
||||
|
||||
-- List of mods that are also mutators in order in which they should be enabled
|
||||
-- This is populated via VMFMod.register_as_mutator
|
||||
vmf.mutators = {}
|
||||
local mutators = vmf.mutators
|
||||
manager.mutators = {}
|
||||
local mutators = manager.mutators
|
||||
|
||||
local mutators_config = {}
|
||||
local default_config = dofile("scripts/mods/vmf/modules/mutators/default_config")
|
||||
local default_config = manager:dofile("scripts/mods/vmf/modules/mutators/mutator_default_config")
|
||||
|
||||
-- This lists mutators and which ones should be enabled after them
|
||||
-- This is populated via VMFMod.register_as_mutator
|
||||
|
@ -29,12 +29,12 @@ local mutators_sorted = false
|
|||
]]--
|
||||
|
||||
-- Sorts mutators in order they should be enabled
|
||||
vmf.sort_mutators = function()
|
||||
manager.sort_mutators = function()
|
||||
|
||||
if mutators_sorted then return end
|
||||
|
||||
-- LOG --
|
||||
vmf:dump(mutators_sequence, "seq", 5)
|
||||
manager:dump(mutators_sequence, "seq", 5)
|
||||
for i, v in ipairs(mutators) do
|
||||
print(i, v:get_name())
|
||||
end
|
||||
|
@ -73,7 +73,7 @@ vmf.sort_mutators = function()
|
|||
|
||||
numIter = numIter + 1
|
||||
if numIter > maxIter then
|
||||
vmf:error("Mutators: too many iterations. Check for loops in 'enable_before_these'/'enable_after_these'.")
|
||||
manager:error("Mutators: too many iterations. Check for loops in 'enable_before_these'/'enable_after_these'.")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
@ -88,7 +88,7 @@ vmf.sort_mutators = function()
|
|||
end
|
||||
|
||||
-- Disables mutators that cannot be enabled right now
|
||||
vmf.disable_impossible_mutators = function()
|
||||
manager.disable_impossible_mutators = function()
|
||||
local disabled_mutators = {}
|
||||
for _, mutator in pairs(mutators) do
|
||||
if mutator:is_enabled() and not mutator:can_be_enabled() then
|
||||
|
@ -104,9 +104,9 @@ end
|
|||
PRIVATE METHODS
|
||||
]]--
|
||||
|
||||
local update_mutators_view, get_map_view = dofile("scripts/mods/vmf/modules/mutators/gui")
|
||||
local addDice, removeDice = dofile("scripts/mods/vmf/modules/mutators/dice")
|
||||
local set_lobby_data = dofile("scripts/mods/vmf/modules/mutators/info")
|
||||
local mutators_view = manager:dofile("scripts/mods/vmf/modules/mutators/mutator_gui")
|
||||
local addDice, removeDice = manager:dofile("scripts/mods/vmf/modules/mutators/mutator_dice")
|
||||
local set_lobby_data = manager:dofile("scripts/mods/vmf/modules/mutators/mutator_info")
|
||||
|
||||
-- Adds mutator names from enable_these_after to the list of mutators that should be enabled after the mutator_name
|
||||
local function update_mutators_sequence(mutator_name, enable_these_after)
|
||||
|
@ -116,7 +116,7 @@ local function update_mutators_sequence(mutator_name, enable_these_after)
|
|||
for _, other_mutator_name in ipairs(enable_these_after) do
|
||||
|
||||
if mutators_sequence[other_mutator_name] and table.has_item(mutators_sequence[other_mutator_name], mutator_name) then
|
||||
vmf:error("Mutators '" .. mutator_name .. "' and '" .. other_mutator_name .. "' are both set to load after the other one.")
|
||||
manager:error("Mutators '" .. mutator_name .. "' and '" .. other_mutator_name .. "' are both set to load after the other one.")
|
||||
elseif not table.has_item(mutators_sequence[mutator_name], other_mutator_name) then
|
||||
table.insert(mutators_sequence[mutator_name], other_mutator_name)
|
||||
end
|
||||
|
@ -186,7 +186,7 @@ local function disable_incompatible_with(mutator)
|
|||
end
|
||||
if names then
|
||||
-- TODO: output this to the menu instead of chat
|
||||
vmf:echo("These mutators are incompatible with " .. mutator:get_name() .. " and were disabled: " .. names)
|
||||
manager:echo("These mutators are incompatible with " .. mutator:get_name() .. " and were disabled: " .. names)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -223,7 +223,7 @@ local function set_mutator_state(mutator, state)
|
|||
|
||||
-- Sort mutators if this is the first call
|
||||
if not mutators_sorted then
|
||||
vmf.sort_mutators()
|
||||
manager.sort_mutators()
|
||||
end
|
||||
|
||||
-- Disable mutators that aren't compatible
|
||||
|
@ -268,8 +268,6 @@ local function set_mutator_state(mutator, state)
|
|||
end
|
||||
end
|
||||
|
||||
update_mutators_view()
|
||||
|
||||
print("---------")
|
||||
end
|
||||
|
||||
|
@ -280,12 +278,12 @@ end
|
|||
|
||||
-- Enables mutator (pcall for now)
|
||||
local function enable_mutator(self)
|
||||
vmf:pcall(function() set_mutator_state(self, true) end)
|
||||
manager:pcall(function() set_mutator_state(self, true) end)
|
||||
end
|
||||
|
||||
-- Disables mutator (pcall for now)
|
||||
local function disable_mutator(self)
|
||||
vmf:pcall(function() set_mutator_state(self, false) end)
|
||||
manager:pcall(function() set_mutator_state(self, false) end)
|
||||
end
|
||||
|
||||
-- Checks current difficulty and map selection screen settings to determine if a mutator can be enabled
|
||||
|
@ -296,7 +294,7 @@ local function can_be_enabled(self)
|
|||
local actual_difficulty = Managers.state and Managers.state.difficulty:get_difficulty()
|
||||
local right_difficulty = not actual_difficulty or table.has_item(mutator_difficulties, actual_difficulty)
|
||||
|
||||
local map_view = get_map_view()
|
||||
local map_view = mutators_view.map_view
|
||||
local map_view_active = map_view and map_view.active
|
||||
local right_unapplied_difficulty = false
|
||||
|
||||
|
@ -366,8 +364,8 @@ end
|
|||
--[[
|
||||
HOOKS
|
||||
]]--
|
||||
vmf:hook("DifficultyManager.set_difficulty", function(func, self, difficulty)
|
||||
local disabled_mutators = vmf.disable_impossible_mutators()
|
||||
manager:hook("DifficultyManager.set_difficulty", function(func, self, difficulty)
|
||||
local disabled_mutators = manager.disable_impossible_mutators()
|
||||
if #disabled_mutators > 0 then
|
||||
local message = "MUTATORS DISABLED DUE TO DIFFICULTY CHANGE:"
|
||||
for _, mutator in ipairs(disabled_mutators) do
|
|
@ -132,10 +132,21 @@ local options_widgets = {
|
|||
["default_value"] = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
["setting_name"] = "win",
|
||||
["widget_type"] = "keybind",
|
||||
["text"] = "WIN",
|
||||
["default_value"] = {},
|
||||
["action"] = "win"
|
||||
},
|
||||
}
|
||||
vmf:create_options(options_widgets, false, "Vermintide Mod Framework")
|
||||
|
||||
vmf.win = function()
|
||||
Managers.state.game_mode:complete_level()
|
||||
end
|
||||
|
||||
vmf.setting_changed = function (setting_name)
|
||||
|
||||
if setting_name == "vmf_options_scrolling_speed" then
|
||||
|
|
|
@ -21,10 +21,7 @@ return {
|
|||
dofile("scripts/mods/vmf/modules/options_menu/vmf_options_view")
|
||||
dofile("scripts/mods/vmf/modules/vmf_options")
|
||||
|
||||
dofile("scripts/mods/vmf/modules/mod_gui/basic_gui")
|
||||
dofile("scripts/mods/vmf/modules/mod_gui/gui")
|
||||
|
||||
dofile("scripts/mods/vmf/modules/mutators/mutators")
|
||||
dofile("scripts/mods/vmf/modules/mutators/mutator_manager")
|
||||
|
||||
object.vmf = get_mod("VMF")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue