t7x/data/ui_scripts/frontend_menus/DataSources_GameSettingsFlyoutButtons.lua

261 lines
8.5 KiB
Lua
Raw Normal View History

2023-04-12 17:39:36 -04:00
local f0_local0 = function(f1_arg0, f1_arg1)
2023-04-11 20:03:10 -04:00
if not CoD.useMouse then
2023-04-12 17:39:36 -04:00
return
2023-04-11 20:03:10 -04:00
else
2023-04-12 17:39:36 -04:00
f1_arg0.Options:setHandleMouse(true)
f1_arg0.Options:registerEventHandler("leftclick_outside", function(element, event)
CoD.PCUtil.SimulateButtonPress(event.controller, Enum.LUIButton.LUI_KEY_XBB_PSCIRCLE)
2023-04-11 20:03:10 -04:00
return true
2023-04-12 17:39:36 -04:00
end)
2023-04-11 20:03:10 -04:00
end
end
2023-04-12 17:39:36 -04:00
local PostLoadFunc = function(f3_arg0, f3_arg1)
f0_local0(f3_arg0, f3_arg1)
2023-04-11 20:03:10 -04:00
f3_arg0.disableBlur = true
f3_arg0.disablePopupOpenCloseAnim = true
2023-04-12 17:39:36 -04:00
Engine.SetModelValue(Engine.CreateModel(Engine.GetGlobalModel(), "GameSettingsFlyoutOpen"), true)
LUI.OverrideFunction_CallOriginalSecond(f3_arg0, "close", function(element)
Engine.SetModelValue(Engine.CreateModel(Engine.GetGlobalModel(), "GameSettingsFlyoutOpen"), false)
end)
f3_arg0:registerEventHandler("occlusion_change", function(element, event)
2023-04-11 20:03:10 -04:00
local f5_local0 = element:getParent()
if f5_local0 then
local f5_local1 = f5_local0:getFirstChild()
while f5_local1 ~= nil do
if f5_local1.menuName == "Lobby" then
break
end
f5_local1 = f5_local1:getNextSibling()
end
if f5_local1 then
if event.occluded == true then
2023-04-12 17:39:36 -04:00
f5_local1:setAlpha(0)
2023-04-11 20:03:10 -04:00
end
2023-04-12 17:39:36 -04:00
f5_local1:setAlpha(1)
2023-04-11 20:03:10 -04:00
end
end
2023-04-12 17:39:36 -04:00
element:OcclusionChange(event)
end)
f3_arg0:subscribeToModel(Engine.CreateModel(Engine.GetGlobalModel(), "lobbyRoot.lobbyNav", true), function(model)
2023-04-11 20:03:10 -04:00
local f6_local0 = f3_arg0.occludedBy
while f6_local0 do
if f6_local0.occludedBy ~= nil then
f6_local0 = f6_local0.occludedBy
end
while f6_local0 and f6_local0.menuName ~= "Lobby" do
2023-04-12 17:39:36 -04:00
f6_local0 = GoBack(f6_local0, f3_arg1)
2023-04-11 20:03:10 -04:00
end
2023-04-12 17:39:36 -04:00
Engine.SendClientScriptNotify(f3_arg1, "menu_change" .. Engine.GetLocalClientNum(f3_arg1), "Main",
"closeToMenu")
return
2023-04-11 20:03:10 -04:00
end
2023-04-12 17:39:36 -04:00
GoBack(f3_arg0, f3_arg1)
end, false)
2023-04-11 20:03:10 -04:00
end
2023-04-12 17:39:36 -04:00
DataSources.GameSettingsFlyoutButtonsCustom = DataSourceHelpers.ListSetup("GameSettingsFlyoutButtonsCustom",
function(f7_arg0)
2023-04-11 15:19:56 -04:00
local f7_local0 = {
{
optionDisplay = "MPUI_CHANGE_MAP_CAPS",
customId = "btnChangeMap",
action = OpenChangeMap
},
-- {
2023-04-12 17:39:36 -04:00
-- optionDisplay = "MPUI_CHANGE_GAME_MODE_CAPS",
-- customId = "btnChangeGameMode",
-- action = OpenChangeGameMode
2023-04-11 15:19:56 -04:00
-- },
{
optionDisplay = "MENU_SETUP_BOTS_CAPS",
customId = "btnSetupBots",
action = OpenBotSettings
},
{
optionDisplay = "MPUI_EDIT_GAME_RULES_CAPS",
customId = "btnEditGameRules",
action = OpenEditGameRules
}
}
-- if CoD.isPC and IsServerBrowserEnabled() then
2023-04-12 17:39:36 -04:00
-- table.insert( f7_local0, {
-- optionDisplay = "PLATFORM_SERVER_SETTINGS_CAPS",
-- customID = "btnServerSettings",
-- action = OpenServerSettings
-- } )
2023-04-11 15:19:56 -04:00
-- end
local f7_local1 = {}
2023-04-12 17:39:36 -04:00
for f7_local5, f7_local6 in ipairs(f7_local0) do
table.insert(f7_local1, {
2023-04-11 15:19:56 -04:00
models = {
2023-04-12 17:39:36 -04:00
displayText = Engine.Localize(f7_local6.optionDisplay),
2023-04-11 15:19:56 -04:00
customId = f7_local6.customId,
disabled = f7_local6.disabled
},
properties = {
title = f7_local6.optionDisplay,
desc = f7_local6.desc,
action = f7_local6.action,
actionParam = f7_local6.actionParam
}
2023-04-12 17:39:36 -04:00
})
2023-04-11 15:19:56 -04:00
end
return f7_local1
2023-04-12 17:39:36 -04:00
end, nil, nil, nil)
2023-04-11 15:19:56 -04:00
2023-04-12 17:39:36 -04:00
LUI.createMenu.GameSettingsFlyoutMPCustom = function(controller)
local self = CoD.Menu.NewForUIEditor("GameSettingsFlyoutMPCustom")
2023-04-11 15:19:56 -04:00
if PreLoadFunc then
2023-04-12 17:39:36 -04:00
PreLoadFunc(self, controller)
2023-04-11 15:19:56 -04:00
end
self.soundSet = "default"
2023-04-12 17:39:36 -04:00
self:setOwner(controller)
self:setLeftRight(true, true, 0, 0)
self:setTopBottom(true, true, 0, 0)
self:playSound("menu_open", controller)
self.buttonModel = Engine.CreateModel(Engine.GetModelForController(controller), "GameSettingsFlyoutMP.buttonPrompts")
2023-04-11 15:19:56 -04:00
self.anyChildUsesUpdateState = true
2023-04-12 17:39:36 -04:00
local Options = LUI.UIList.new(self, controller, -2, 0, nil, false, false, 0, 0, false, false)
2023-04-11 15:19:56 -04:00
Options:makeFocusable()
2023-04-12 17:39:36 -04:00
Options:setLeftRight(true, false, 243.43, 523.43)
Options:setTopBottom(true, false, 177.56, 329.56)
Options:setYRot(25)
Options:setWidgetType(CoD.FE_List1ButtonLarge_PH)
Options:setVerticalCount(3)
Options:setSpacing(-2)
Options:setDataSource("GameSettingsFlyoutButtonsCustom")
Options:registerEventHandler("gain_focus", function(element, event)
2023-04-11 15:19:56 -04:00
local f9_local0 = nil
if element.gainFocus then
2023-04-12 17:39:36 -04:00
f9_local0 = element:gainFocus(event)
2023-04-11 15:19:56 -04:00
elseif element.super.gainFocus then
2023-04-12 17:39:36 -04:00
f9_local0 = element.super:gainFocus(event)
2023-04-11 15:19:56 -04:00
end
2023-04-12 17:39:36 -04:00
CoD.Menu.UpdateButtonShownState(element, self, controller, Enum.LUIButton.LUI_KEY_XBA_PSCROSS)
2023-04-11 15:19:56 -04:00
return f9_local0
2023-04-12 17:39:36 -04:00
end)
Options:registerEventHandler("lose_focus", function(element, event)
2023-04-11 15:19:56 -04:00
local f10_local0 = nil
if element.loseFocus then
2023-04-12 17:39:36 -04:00
f10_local0 = element:loseFocus(event)
2023-04-11 15:19:56 -04:00
elseif element.super.loseFocus then
2023-04-12 17:39:36 -04:00
f10_local0 = element.super:loseFocus(event)
2023-04-11 15:19:56 -04:00
end
return f10_local0
2023-04-12 17:39:36 -04:00
end)
self:AddButtonCallbackFunction(Options, controller, Enum.LUIButton.LUI_KEY_XBA_PSCROSS, "ENTER",
function(element, menu, controller, model)
ProcessListAction(self, element, controller)
2023-04-11 15:19:56 -04:00
return true
2023-04-12 17:39:36 -04:00
end, function(element, menu, controller)
CoD.Menu.SetButtonLabel(menu, Enum.LUIButton.LUI_KEY_XBA_PSCROSS, "MENU_SELECT")
2023-04-11 15:19:56 -04:00
return true
2023-04-12 17:39:36 -04:00
end, false)
self:addElement(Options)
2023-04-11 15:19:56 -04:00
self.Options = Options
2023-04-12 17:39:36 -04:00
self:mergeStateConditions({
2023-04-11 15:19:56 -04:00
{
stateName = "Local",
2023-04-12 17:39:36 -04:00
condition = function(menu, element, event)
2023-04-11 15:19:56 -04:00
return IsLobbyNetworkModeLAN()
end
}
2023-04-12 17:39:36 -04:00
})
self:subscribeToModel(Engine.GetModel(Engine.GetGlobalModel(), "lobbyRoot.lobbyNetworkMode"), function(model)
2023-04-11 15:19:56 -04:00
local f14_local0 = self
local f14_local1 = {
controller = controller,
name = "model_validation",
2023-04-12 17:39:36 -04:00
modelValue = Engine.GetModelValue(model),
2023-04-11 15:19:56 -04:00
modelName = "lobbyRoot.lobbyNetworkMode"
}
2023-04-12 17:39:36 -04:00
CoD.Menu.UpdateButtonShownState(f14_local0, self, controller, Enum.LUIButton.LUI_KEY_XBY_PSTRIANGLE)
end)
self:subscribeToModel(Engine.GetModel(Engine.GetGlobalModel(), "lobbyRoot.lobbyNav"), function(model)
2023-04-11 15:19:56 -04:00
local f15_local0 = self
local f15_local1 = {
controller = controller,
name = "model_validation",
2023-04-12 17:39:36 -04:00
modelValue = Engine.GetModelValue(model),
2023-04-11 15:19:56 -04:00
modelName = "lobbyRoot.lobbyNav"
}
2023-04-12 17:39:36 -04:00
CoD.Menu.UpdateButtonShownState(f15_local0, self, controller, Enum.LUIButton.LUI_KEY_XBY_PSTRIANGLE)
end)
self:AddButtonCallbackFunction(self, controller, Enum.LUIButton.LUI_KEY_XBB_PSCIRCLE, nil,
function(element, menu, controller, model)
GoBack(self, controller)
ClearMenuSavedState(menu)
2023-04-11 15:19:56 -04:00
return true
2023-04-12 17:39:36 -04:00
end, function(element, menu, controller)
CoD.Menu.SetButtonLabel(menu, Enum.LUIButton.LUI_KEY_XBB_PSCIRCLE, "")
2023-04-11 15:19:56 -04:00
return false
2023-04-12 17:39:36 -04:00
end, false)
self:AddButtonCallbackFunction(self, controller, Enum.LUIButton.LUI_KEY_START, "M",
function(element, menu, controller, model)
GoBackAndOpenOverlayOnParent(self, "StartMenu_Main", controller)
2023-04-11 15:19:56 -04:00
return true
2023-04-12 17:39:36 -04:00
end, function(element, menu, controller)
CoD.Menu.SetButtonLabel(menu, Enum.LUIButton.LUI_KEY_START, "MENU_MENU")
2023-04-11 15:19:56 -04:00
return true
2023-04-12 17:39:36 -04:00
end, false)
self:AddButtonCallbackFunction(self, controller, Enum.LUIButton.LUI_KEY_XBY_PSTRIANGLE, "S",
function(element, menu, controller, model)
if not IsLAN() and not IsPlayerAGuest(controller) and IsPlayerAllowedToPlayOnline(controller) then
GoBackAndOpenOverlayOnParent(self, "Social_Main", controller)
2023-04-11 15:19:56 -04:00
return true
else
2023-04-12 17:39:36 -04:00
2023-04-11 15:19:56 -04:00
end
2023-04-12 17:39:36 -04:00
end, function(element, menu, controller)
if not IsLAN() and not IsPlayerAGuest(controller) and IsPlayerAllowedToPlayOnline(controller) then
CoD.Menu.SetButtonLabel(menu, Enum.LUIButton.LUI_KEY_XBY_PSTRIANGLE, "")
2023-04-11 15:19:56 -04:00
return false
else
return false
end
2023-04-12 17:39:36 -04:00
end, false)
self:AddButtonCallbackFunction(self, controller, Enum.LUIButton.LUI_KEY_LB, nil,
function(element, menu, controller, model)
SendButtonPressToOccludedMenu(menu, controller, model, Enum.LUIButton.LUI_KEY_LB)
2023-04-11 15:19:56 -04:00
return true
2023-04-12 17:39:36 -04:00
end, function(element, menu, controller)
CoD.Menu.SetButtonLabel(menu, Enum.LUIButton.LUI_KEY_LB, "")
2023-04-11 15:19:56 -04:00
return false
2023-04-12 17:39:36 -04:00
end, false)
self:AddButtonCallbackFunction(self, controller, Enum.LUIButton.LUI_KEY_RB, nil,
function(element, menu, controller, model)
SendButtonPressToOccludedMenu(menu, controller, model, Enum.LUIButton.LUI_KEY_RB)
2023-04-11 15:19:56 -04:00
return true
2023-04-12 17:39:36 -04:00
end, function(element, menu, controller)
CoD.Menu.SetButtonLabel(menu, Enum.LUIButton.LUI_KEY_RB, "")
2023-04-11 15:19:56 -04:00
return false
2023-04-12 17:39:36 -04:00
end, false)
2023-04-11 15:19:56 -04:00
Options.id = "Options"
2023-04-12 17:39:36 -04:00
self:processEvent({
2023-04-11 15:19:56 -04:00
name = "menu_loaded",
controller = controller
2023-04-12 17:39:36 -04:00
})
self:processEvent({
2023-04-11 15:19:56 -04:00
name = "update_state",
menu = self
2023-04-12 17:39:36 -04:00
})
2023-04-11 15:19:56 -04:00
if not self:restoreState() then
2023-04-12 17:39:36 -04:00
self.Options:processEvent({
2023-04-11 15:19:56 -04:00
name = "gain_focus",
controller = controller
2023-04-12 17:39:36 -04:00
})
2023-04-11 15:19:56 -04:00
end
2023-04-12 17:39:36 -04:00
LUI.OverrideFunction_CallOriginalSecond(self, "close", function(element)
2023-04-11 15:19:56 -04:00
element.Options:close()
2023-04-12 17:39:36 -04:00
Engine.UnsubscribeAndFreeModel(Engine.GetModel(Engine.GetModelForController(controller),
"GameSettingsFlyoutMP.buttonPrompts"))
end)
2023-04-11 20:03:10 -04:00
if PostLoadFunc then
2023-04-12 17:39:36 -04:00
PostLoadFunc(self, controller)
2023-04-11 20:03:10 -04:00
end
2023-04-11 15:19:56 -04:00
return self
end