t7x/data/ui_scripts/frontend_menus/__init__.lua

126 lines
4.3 KiB
Lua
Raw Normal View History

if Engine.GetCurrentMap() ~= "core_frontend" then
return
end
local EnableLobbyMapVote = true -- toggle map vote in public lobby
local utils = require("utils")
2023-04-11 15:04:04 -04:00
require("DataSources_StartMenuTabs")
2023-04-11 15:19:56 -04:00
require("DataSources_GameSettingsFlyoutButtons")
CoD.LobbyButtons.MP_PUBLIC_MATCH = {
stringRef = "MENU_PLAY_CAPS",
action = NavigateToLobby_SelectionList,
param = "MPLobbyOnline",
customId = "btnPublicMatch",
}
CoD.LobbyButtons.MP_FIND_MATCH = {
stringRef = "MPUI_BASICTRAINING_CAPS",
action = OpenFindMatch,
customId = "btnFindMatch",
}
CoD.LobbyButtons.MP_STATS = {
stringRef = "STATS",
action = function(self, element, controller, param, menu)
SetPerControllerTableProperty(controller, "disableGameSettingsOptions", true)
OpenPopup(menu, "BoiiiStatsMenu", controller)
end,
customId = "btnMPStats"
}
CoD.LobbyButtons.MP_START_GAME = {
stringRef = "MENU_START_GAME_CAPS",
action = function(self, element, controller, param, menu)
Engine.SetDvar("party_minplayers", 1)
Engine.Exec(nil, "launchgame")
end,
customId = "btnStartGame"
}
CoD.LobbyButtons.SETTING_UP_BOTS = {
stringRef = "MENU_SETUP_BOTS_CAPS",
action = function(self, element, controller, param, menu)
SetPerControllerTableProperty(controller, "disableGameSettingsOptions", true)
OpenPopup(menu, "GameSettings_Bots", controller)
end,
customId = "btnSettingUpBots"
}
2023-04-11 15:19:56 -04:00
CoD.LobbyButtons.GameSettingsFlyoutArenas = {
stringRef = "MPUI_SETUP_GAME_CAPS",
action = function( self, element, controller, param, menu )
SetPerControllerTableProperty( controller, "disableGameSettingsOptions", true )
OpenPopup( menu, "GameSettingsFlyoutMP", controller )
end,
customId = "btnGameSettingsFlyoutMP"
}
CoD.LobbyButtons.GameSettingsFlyoutMP = {
stringRef = "MPUI_SETUP_GAME_CAPS",
action = function( self, element, controller, param, menu )
SetPerControllerTableProperty( controller, "disableGameSettingsOptions", true )
OpenPopup( menu, "GameSettingsFlyoutMPCustom", controller )
end,
customId = "btnGameSettingsFlyoutMPCustom"
}
CoD.LobbyButtons.MP_CUSTOM_SETUP_GAME = {
stringRef = "MPUI_SETUP_GAME_CAPS",
action = OpenSetupGameMP,
customId = "btnSetupGame",
}
local LobbyMapVoteIsEnabled = EnableLobbyMapVote
local LobbyMapVote = function( LobbyMapVoteIsEnabled )
if LobbyMapVoteIsEnabled == true then
Engine.Exec( nil, "LobbyStopDemo" )
end
end
local addCustomButtons = function(controller, menuId, buttonTable, isLeader)
if menuId == LobbyData.UITargets.UI_MPLOBBYONLINE.id or menuId == LobbyData.UITargets.UI_ZMLOBBYONLINE.id then
utils.AddSpacer(buttonTable)
utils.AddSmallButton(controller, buttonTable, CoD.LobbyButtons.MP_STATS)
end
if menuId == LobbyData.UITargets.UI_MPLOBBYONLINE.id or menuId == LobbyData.UITargets.UI_ZMLOBBYONLINE.id or menuId == LobbyData.UITargets.UI_MPLOBBYMAIN.id or menuId == LobbyData.UITargets.UI_MPLOBBYLANGAME.id then
Engine.Mods_Lists_UpdateUsermaps()
end
if menuId == LobbyData.UITargets.UI_MPLOBBYONLINE.id then
LobbyMapVoteIsEnabled = EnableLobbyMapVote
elseif menuId == LobbyData.UITargets.UI_MPLOBBYONLINEPUBLICGAME.id then
LobbyMapVote( LobbyMapVoteIsEnabled )
LobbyMapVoteIsEnabled = false
utils.AddLargeButton(controller, buttonTable, CoD.LobbyButtons.MP_START_GAME, 1) --Launch match button
utils.AddSpacer(buttonTable, 1)
utils.AddSpacer(buttonTable)
utils.AddSmallButton(controller, buttonTable, CoD.LobbyButtons.MP_CUSTOM_SETUP_GAME) --Setup game in public lobby
elseif menuId == LobbyData.UITargets.UI_MPLOBBYONLINEARENAGAME.id then
utils.AddSpacer(buttonTable)
utils.AddSmallButton(controller, buttonTable, CoD.LobbyButtons.SETTING_UP_BOTS) --Bot setting button in public lobby
end
end
local oldAddButtonsForTarget = CoD.LobbyMenus.AddButtonsForTarget
CoD.LobbyMenus.AddButtonsForTarget = function(controller, id)
local model = nil
if Engine.IsLobbyActive(Enum.LobbyType.LOBBY_TYPE_GAME) then
model = Engine.GetModel(DataSources.LobbyRoot.getModel(controller), "gameClient.isHost")
else
model = Engine.GetModel(DataSources.LobbyRoot.getModel(controller), "privateClient.isHost")
end
local isLeader = nil
if model ~= nil then
isLeader = Engine.GetModelValue(model)
else
isLeader = 1
end
local result = oldAddButtonsForTarget(controller, id)
addCustomButtons(controller, id, result, isLeader)
return result
end