diff --git a/vmf_source/gui/vmf/mutator_button.dds b/vmf_source/gui/vmf/mutator_button.dds new file mode 100644 index 0000000..311c80e Binary files /dev/null and b/vmf_source/gui/vmf/mutator_button.dds differ diff --git a/vmf_source/gui/vmf/mutator_button.texture b/vmf_source/gui/vmf/mutator_button.texture new file mode 100644 index 0000000..d9e804f --- /dev/null +++ b/vmf_source/gui/vmf/mutator_button.texture @@ -0,0 +1,17 @@ +common = { + input = { + filename = "gui/vmf/mutator_button" + } + output = { + apply_processing = true + correct_gamma = true + cut_alpha_threshold = 0.5 + enable_cut_alpha_threshold = false + format = "A8R8G8B8" + mipmap_filter = "kaiser" + mipmap_filter_wrap_mode = "mirror" + mipmap_keep_original = false + mipmap_num_largest_steps_to_discard = 0 + mipmap_num_smallest_steps_to_discard = 0 + } +} \ No newline at end of file diff --git a/vmf_source/gui/vmf/mutator_button_hover.dds b/vmf_source/gui/vmf/mutator_button_hover.dds new file mode 100644 index 0000000..72a600b Binary files /dev/null and b/vmf_source/gui/vmf/mutator_button_hover.dds differ diff --git a/vmf_source/gui/vmf/mutator_button_hover.texture b/vmf_source/gui/vmf/mutator_button_hover.texture new file mode 100644 index 0000000..e1e5379 --- /dev/null +++ b/vmf_source/gui/vmf/mutator_button_hover.texture @@ -0,0 +1,17 @@ +common = { + input = { + filename = "gui/vmf/mutator_button_hover" + } + output = { + apply_processing = true + correct_gamma = true + cut_alpha_threshold = 0.5 + enable_cut_alpha_threshold = false + format = "A8R8G8B8" + mipmap_filter = "kaiser" + mipmap_filter_wrap_mode = "mirror" + mipmap_keep_original = false + mipmap_num_largest_steps_to_discard = 0 + mipmap_num_smallest_steps_to_discard = 0 + } +} \ No newline at end of file diff --git a/vmf_source/materials/vmf/mutator_button.material b/vmf_source/materials/vmf/mutator_button.material new file mode 100644 index 0000000..788a6c9 --- /dev/null +++ b/vmf_source/materials/vmf/mutator_button.material @@ -0,0 +1,14 @@ +mutator_button = { + material_contexts = { + surface_material = "" + } + + shader = "gui_gradient:DIFFUSE_MAP" + + textures = { + diffuse_map = "gui/vmf/mutator_button" + } + + variables = { + } +} diff --git a/vmf_source/materials/vmf/mutator_button_hover.material b/vmf_source/materials/vmf/mutator_button_hover.material new file mode 100644 index 0000000..5b04ff1 --- /dev/null +++ b/vmf_source/materials/vmf/mutator_button_hover.material @@ -0,0 +1,14 @@ +mutator_button_hover = { + material_contexts = { + surface_material = "" + } + + shader = "gui_gradient:DIFFUSE_MAP" + + textures = { + diffuse_map = "gui/vmf/mutator_button_hover" + } + + variables = { + } +} diff --git a/vmf_source/scripts/mods/vmf/modules/mutators/mutator_gui_definitions.lua b/vmf_source/scripts/mods/vmf/modules/mutators/mutator_gui_definitions.lua index 6e98cc5..77d8d14 100644 --- a/vmf_source/scripts/mods/vmf/modules/mutators/mutator_gui_definitions.lua +++ b/vmf_source/scripts/mods/vmf/modules/mutators/mutator_gui_definitions.lua @@ -1,3 +1,4 @@ + local definitions = local_require("scripts/ui/views/map_view_definitions") local scenegraph_definition = definitions.scenegraph_definition @@ -75,8 +76,8 @@ local new_widgets = { 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", + icon_texture = "mutator_button", + icon_hover_texture = "mutator_button_hover", tooltip_text = "Mutators", toggled_tooltip_text = "Mutators", button_hotspot = {} diff --git a/vmf_source/scripts/mods/vmf/modules/mutators/mutator_info.lua b/vmf_source/scripts/mods/vmf/modules/mutators/mutator_info.lua index b54de4e..a887c4b 100644 --- a/vmf_source/scripts/mods/vmf/modules/mutators/mutator_info.lua +++ b/vmf_source/scripts/mods/vmf/modules/mutators/mutator_info.lua @@ -42,9 +42,8 @@ local function set_lobby_data() Managers.matchmaking.lobby:set_lobby_data(lobby_data) end --- Return a function for chat system to only send messages to specific client --- TODO: test if this works -local function get_member_func(client_cookie) +-- Return a function for chat system to only send messages to specific client +local function get_peer_id_from_cookie(client_cookie) local peer_id = tostring(client_cookie) for _ = 1, 3 do peer_id = string.sub(peer_id, 1 + tonumber(tostring(string.find(peer_id,"-")))) @@ -54,24 +53,25 @@ local function get_member_func(client_cookie) peer_id = string.sub(peer_id, 2) peer_id = string.reverse(peer_id) - return function() - for _, v in ipairs(Managers.matchmaking.lobby:members():get_members()) do - if v == peer_id then - return {v} - end - end - return Managers.matchmaking.lobby:members():get_members() - end + return peer_id end --- Set difficulty in the tab menu --- TODO: see if this can be set every time a mutator is enabled/disable -manager:hook("IngamePlayerListUI.set_difficulty_name", function(func, self, name) +-- Append difficulty name with enabled mutators' titles +manager:hook("IngamePlayerListUI.update_difficulty", function(func, self) + local difficulty_settings = Managers.state.difficulty:get_difficulty_settings() + local difficulty_name = difficulty_settings.display_name + + local name = not self.is_in_inn and Localize(difficulty_name) or nil local mutators_name = get_enabled_mutators_names(" ", true) if mutators_name then - name = name .. " " .. mutators_name + if name then name = name .. " " else name = "" end + name = name .. mutators_name + else + name = "" end - self.headers.content.game_difficulty = name + self.set_difficulty_name(self, name) + + self.current_difficulty_name = difficulty_name end) -- Notify everybody about enabled/disabled mutators when Play button is pressed on the map screen @@ -79,24 +79,22 @@ manager:hook("MatchmakingStateHostGame.host_game", function(func, self, ...) func(self, ...) set_lobby_data() local names = get_enabled_mutators_names(", ") + manager:echo("TEST") if names then - Managers.chat:send_system_chat_message(1, "ENABLED MUTATORS: " .. names, 0, true) + manager:chat_broadcast("ENABLED MUTATORS: " .. names) were_enabled_before = true elseif were_enabled_before then - Managers.chat:send_system_chat_message(1, "ALL MUTATORS DISABLED", 0, true) + manager:chat_broadcast("ALL MUTATORS DISABLED") were_enabled_before = false end end) -- Send special messages with enabled mutators list to players just joining the lobby --- TODO: test if this works 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(", ") if name then local message = "[Automated message] This lobby has the following difficulty mod active : " .. name - manager:hook("Managers.chat.channels[1].members_func", get_member_func(client_cookie)) - Managers.chat:send_system_chat_message(1, message, 0, true) - manager:hook_remove("Managers.chat.channels[1].members_func") + manager:chat_whisper(get_peer_id_from_cookie(client_cookie), message) end func(self, sender, client_cookie, host_cookie, lobby_id, friend_join) end) diff --git a/vmf_source/scripts/mods/vmf/modules/mutators/mutator_manager.lua b/vmf_source/scripts/mods/vmf/modules/mutators/mutator_manager.lua index 2e1543f..8ec45bf 100644 --- a/vmf_source/scripts/mods/vmf/modules/mutators/mutator_manager.lua +++ b/vmf_source/scripts/mods/vmf/modules/mutators/mutator_manager.lua @@ -109,7 +109,7 @@ manager.disable_impossible_mutators = function(notify, everybody) message = message .. (i == 1 and " " or ", ") .. (mutator:get_config().title or mutator:get_name()) end if everybody then - Managers.chat:send_system_chat_message(1, message, 0, true) + manager:chat_broadcast(message) else manager:echo(message) end @@ -395,4 +395,4 @@ manager:pcall(function() mutators_view:init(mutators_view:get_map_view()) end) --[[ Testing --]] -manager:dofile("scripts/mods/vmf/modules/mutators/mutator_test") +--manager:dofile("scripts/mods/vmf/modules/mutators/mutator_test") diff --git a/vmf_source/scripts/mods/vmf/modules/mutators/mutator_test.lua b/vmf_source/scripts/mods/vmf/modules/mutators/mutator_test.lua index fe8f03b..88aa54f 100644 --- a/vmf_source/scripts/mods/vmf/modules/mutators/mutator_test.lua +++ b/vmf_source/scripts/mods/vmf/modules/mutators/mutator_test.lua @@ -1,32 +1,76 @@ -local mutator2 = new_mod("mutator2") -local mutator3 = new_mod("mutator3") local mutator555 = new_mod("mutator555") mutator555:register_as_mutator({ - incompatible_with_all = true + incompatible_with_all = true, + title = "Legendary" }) -mutator555:create_options({}, true, "mutator555", "mutator555 description") mutator555.on_enabled = function() end mutator555.on_disabled = function() end +local mutator3 = new_mod("mutator3") mutator3:register_as_mutator({ incompatible_with = { "mutator4" - } + }, + title = "Stormvermin Mutation" }) mutator3.on_enabled = function() end mutator3.on_disabled = function() end +local mutator2 = new_mod("mutator2") mutator2:register_as_mutator({ - compatible_with_all = true, difficulty_levels = { - "hardest" - } + "hardest", + "survival_hardest" + }, + title = "Deathwish" }) mutator2.on_enabled = function() end mutator2.on_disabled = function() end +local slayer = new_mod("slayer") +slayer:register_as_mutator({ + difficulty_levels = { + "survival_hard", + "survival_harder", + "survival_hardest" + }, + title = "Slayer's Oath" +}) +slayer.on_enabled = function() end +slayer.on_disabled = function() end + +local true_solo = new_mod("true_solo") +true_solo:register_as_mutator({ + compatible_with_all = true, + title = "True Solo" +}) +true_solo.on_enabled = function() end +true_solo.on_disabled = function() end + +local onslaught = new_mod("onslaught") +onslaught:register_as_mutator({ + title = "Onslaught" +}) +onslaught.on_enabled = function() end +onslaught.on_disabled = function() end + +local one_hit_one_kill = new_mod("one_hit_one_kill") +one_hit_one_kill:register_as_mutator({ + title = "One Hit One Kill" +}) +one_hit_one_kill.on_enabled = function() end +one_hit_one_kill.on_disabled = function() end + +local more_rat_weapons = new_mod("more_rat_weapons") +more_rat_weapons:register_as_mutator({ + compatible_with_all = true, + title = "More Rat Weapons" +}) +more_rat_weapons.on_enabled = function() end +more_rat_weapons.on_disabled = function() end + --[[for i=4,17 do local mutator = new_mod("mutator" .. i) mutator:register_as_mutator({}) diff --git a/vmf_source/scripts/mods/vmf/modules/options_menu/vmf_options_view.lua b/vmf_source/scripts/mods/vmf/modules/options_menu/vmf_options_view.lua index a0c8c40..867bde7 100644 --- a/vmf_source/scripts/mods/vmf/modules/options_menu/vmf_options_view.lua +++ b/vmf_source/scripts/mods/vmf/modules/options_menu/vmf_options_view.lua @@ -19,6 +19,10 @@ inject_material("materials/vmf/header_fav_icon_lit", "header_fav_icon_lit", "ing inject_material("materials/vmf/header_fav_arrow", "header_fav_arrow", "ingame_ui") inject_material("materials/vmf/search_bar_icon", "search_bar_icon", "ingame_ui") +-- TODO: move to mutator_gui +inject_material("materials/vmf/mutator_button", "mutator_button", "ingame_ui") +inject_material("materials/vmf/mutator_button_hover", "mutator_button_hover", "ingame_ui") + -- #################################################################################################################### -- ##### MENU WIDGETS DEFINITIONS ##################################################################################### @@ -4215,7 +4219,11 @@ if ingame_ui_exists then "material", "materials/vmf/header_fav_arrow", "material", - "materials/vmf/search_bar_icon") + "materials/vmf/search_bar_icon", + "material", + "materials/vmf/mutator_button", + "material", + "materials/vmf/mutator_button_hover") local gui_retained = World.create_screen_gui(ingame_ui.ui_renderer.world, "material", @@ -4237,7 +4245,11 @@ if ingame_ui_exists then "material", "materials/vmf/header_fav_arrow", "material", - "materials/vmf/search_bar_icon") + "materials/vmf/search_bar_icon", + "material", + "materials/vmf/mutator_button", + "material", + "materials/vmf/mutator_button_hover") World.destroy_gui(ingame_ui.ui_renderer.world, ingame_ui.ui_renderer.gui) World.destroy_gui(ingame_ui.ui_renderer.world, ingame_ui.ui_renderer.gui_retained) @@ -4265,7 +4277,11 @@ if ingame_ui_exists then "material", "materials/vmf/header_fav_arrow", "material", - "materials/vmf/search_bar_icon") + "materials/vmf/search_bar_icon", + "material", + "materials/vmf/mutator_button", + "material", + "materials/vmf/mutator_button_hover") gui_retained = World.create_screen_gui(ingame_ui.ui_top_renderer.world, "material", @@ -4287,7 +4303,11 @@ if ingame_ui_exists then "material", "materials/vmf/header_fav_arrow", "material", - "materials/vmf/search_bar_icon") + "materials/vmf/search_bar_icon", + "material", + "materials/vmf/mutator_button", + "material", + "materials/vmf/mutator_button_hover") World.destroy_gui(ingame_ui.ui_top_renderer.world, ingame_ui.ui_top_renderer.gui) World.destroy_gui(ingame_ui.ui_top_renderer.world, ingame_ui.ui_top_renderer.gui_retained)