From 5581f0100f1eaa2d5cfc718e1534d2daa61cb823 Mon Sep 17 00:00:00 2001 From: WantedDV <122710241+WantedDV@users.noreply.github.com> Date: Tue, 11 Apr 2023 17:26:50 -0230 Subject: [PATCH 1/5] set com_maxclients ingame to allow direct connect - 4 for zombies - 18 for multiplayer --- data/ui_scripts/party/__init__.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/data/ui_scripts/party/__init__.lua b/data/ui_scripts/party/__init__.lua index 741d9378..7702e6df 100644 --- a/data/ui_scripts/party/__init__.lua +++ b/data/ui_scripts/party/__init__.lua @@ -1,4 +1,3 @@ - -- Removed check for public matches to allow team change in ranked matches CoD.IsTeamChangeAllowed = function() if Engine.GetGametypeSetting( "allowInGameTeamChange" ) == 1 then @@ -8,6 +7,18 @@ CoD.IsTeamChangeAllowed = function() end end +-- Set com_maxclients InGame so players can join via direct connect +local maxclients = function() + if Engine.IsZombiesGame() then + return 4 + else + return 18 + end +end + +Engine.SetDvar( "com_maxclients", maxclients() ) + + DataSources.StartMenuGameOptions = ListHelper_SetupDataSource("StartMenuGameOptions", function (controller) local options = {} if Engine.IsDemoPlaying() then From 56b5d346d4bcf9669d528bbf95a9b0fdda97f38a Mon Sep 17 00:00:00 2001 From: WantedDV <122710241+WantedDV@users.noreply.github.com> Date: Tue, 11 Apr 2023 17:27:59 -0230 Subject: [PATCH 2/5] Move Datasource.StartMenuGameOptions --- .../DataSources_StartMenuGameOptions.lua | 74 ++++++++++++++++++ data/ui_scripts/party/__init__.lua | 76 +------------------ 2 files changed, 75 insertions(+), 75 deletions(-) create mode 100644 data/ui_scripts/party/DataSources_StartMenuGameOptions.lua diff --git a/data/ui_scripts/party/DataSources_StartMenuGameOptions.lua b/data/ui_scripts/party/DataSources_StartMenuGameOptions.lua new file mode 100644 index 00000000..522b21f3 --- /dev/null +++ b/data/ui_scripts/party/DataSources_StartMenuGameOptions.lua @@ -0,0 +1,74 @@ +DataSources.StartMenuGameOptions = ListHelper_SetupDataSource("StartMenuGameOptions", function (controller) + local options = {} + if Engine.IsDemoPlaying() then + if not IsDemoRestrictedBasicMode() then + table.insert(options, {models = {displayText = Engine.ToUpper(Engine.Localize("MENU_UPLOAD_CLIP", Engine.GetDemoSegmentCount())), action = StartMenuUploadClip, disabledFunction = IsUploadClipButtonDisabled}, properties = {hideHelpItemLabel = true}}) + end + if Engine.IsDemoHighlightReelMode() then + table.insert(options, {models = {displayText = Engine.ToUpper(Engine.Localize("MENU_DEMO_CUSTOMIZE_HIGHLIGHT_REEL")), action = StartMenuOpenCustomizeHighlightReel, disabledFunction = IsCustomizeHighlightReelButtonDisabled}}) + end + table.insert(options, {models = {displayText = Engine.ToUpper(Engine.ToUpper(Engine.Localize("MENU_JUMP_TO_START"))), action = StartMenuJumpToStart, disabledFunction = IsJumpToStartButtonDisabled}, properties = {hideHelpItemLabel = true}}) + local endDemoButtonText = nil + if Engine.IsDemoClipPlaying() then + endDemoButtonText = Engine.ToUpper(Engine.Localize("MENU_END_CLIP")) + else + endDemoButtonText = Engine.ToUpper(Engine.Localize("MENU_END_FILM")) + end + table.insert(options, {models = {displayText = Engine.ToUpper(endDemoButtonText), action = StartMenuEndDemo}}) + elseif CoD.isCampaign then + table.insert(options, {models = {displayText = "MENU_RESUMEGAME_CAPS", action = StartMenuGoBack_ListElement}}) + local inTrainingSim = CoD.SafeGetModelValue(Engine.GetModelForController(controller), "safehouse.inTrainingSim") + if not inTrainingSim then + inTrainingSim = 0 + end + if Engine.IsLobbyHost(Enum.LobbyType.LOBBY_TYPE_GAME) then + if not CoD.isSafehouse and controller == Engine.GetPrimaryController() then + table.insert(options, {models = {displayText = "MENU_RESTART_MISSION_CAPS", action = RestartMission}}) + if LUI.DEV ~= nil then + table.insert(options, {models = {displayText = "MENU_RESTART_CHECKPOINT_CAPS", action = RestartFromCheckpoint}}) + end + end + if controller == Engine.GetPrimaryController() then + table.insert(options, {models = {displayText = "MENU_CHANGE_DIFFICULTY_CAPS", action = OpenDifficultySelect}}) + end + if CoD.isSafehouse and inTrainingSim == 1 then + table.insert(options, {models = {displayText = "MENU_END_TRAINING_SIM", action = EndTrainingSim}}) + elseif controller == Engine.GetPrimaryController() then + if Engine.DvarBool(0, "ui_blocksaves") then + table.insert(options, {models = {displayText = "MENU_EXIT_CAPS", action = SaveAndQuitGame}}) + else + table.insert(options, {models = {displayText = "MENU_SAVE_AND_QUIT_CAPS", action = SaveAndQuitGame}}) + end + end + elseif CoD.isSafehouse and inTrainingSim == 1 then + table.insert(options, {models = {displayText = "MENU_END_TRAINING_SIM", action = EndTrainingSim}}) + else + table.insert(options, {models = {displayText = "MENU_LEAVE_PARTY_AND_EXIT_CAPS", action = QuitGame}}) + end + elseif CoD.isMultiplayer then + if Engine.Team(controller, "name") ~= "TEAM_SPECTATOR" and Engine.GetGametypeSetting("disableClassSelection") ~= 1 then + table.insert(options, {models = {displayText = "MPUI_CHOOSE_CLASS_BUTTON_CAPS", action = ChooseClass}}) + end + if not Engine.IsVisibilityBitSet(controller, Enum.UIVisibilityBit.BIT_ROUND_END_KILLCAM) and not Engine.IsVisibilityBitSet(controller, Enum.UIVisibilityBit.BIT_FINAL_KILLCAM) and CoD.IsTeamChangeAllowed() then + table.insert(options, {models = {displayText = "MPUI_CHANGE_TEAM_BUTTON_CAPS", action = ChooseTeam}}) + end + if controller == 0 then + local endGameText = "MENU_QUIT_GAME_CAPS" + if Engine.IsLobbyHost(Enum.LobbyType.LOBBY_TYPE_GAME) and not CoD.isOnlineGame() then + endGameText = "MENU_END_GAME_CAPS" + end + table.insert(options, {models = {displayText = endGameText, action = QuitGame_MP}}) + end + elseif CoD.isZombie then + table.insert(options, {models = {displayText = "MENU_RESUMEGAME_CAPS", action = StartMenuGoBack_ListElement}}) + if Engine.IsLobbyHost(Enum.LobbyType.LOBBY_TYPE_GAME) and (not Engine.SessionModeIsMode(CoD.SESSIONMODE_SYSTEMLINK) or Engine.SessionModeIsMode(CoD.SESSIONMODE_OFFLINE)) then + table.insert(options, {models = {displayText = "MENU_RESTART_LEVEL_CAPS", action = RestartGame}}) + end + if Engine.IsLobbyHost(Enum.LobbyType.LOBBY_TYPE_GAME) == true then + table.insert(options, {models = {displayText = "MENU_END_GAME_CAPS", action = QuitGame_MP}}) + else + table.insert(options, {models = {displayText = "MENU_QUIT_GAME_CAPS", action = QuitGame_MP}}) + end + end + return options +end, true) diff --git a/data/ui_scripts/party/__init__.lua b/data/ui_scripts/party/__init__.lua index 7702e6df..2030b7bc 100644 --- a/data/ui_scripts/party/__init__.lua +++ b/data/ui_scripts/party/__init__.lua @@ -18,78 +18,4 @@ end Engine.SetDvar( "com_maxclients", maxclients() ) - -DataSources.StartMenuGameOptions = ListHelper_SetupDataSource("StartMenuGameOptions", function (controller) - local options = {} - if Engine.IsDemoPlaying() then - if not IsDemoRestrictedBasicMode() then - table.insert(options, {models = {displayText = Engine.ToUpper(Engine.Localize("MENU_UPLOAD_CLIP", Engine.GetDemoSegmentCount())), action = StartMenuUploadClip, disabledFunction = IsUploadClipButtonDisabled}, properties = {hideHelpItemLabel = true}}) - end - if Engine.IsDemoHighlightReelMode() then - table.insert(options, {models = {displayText = Engine.ToUpper(Engine.Localize("MENU_DEMO_CUSTOMIZE_HIGHLIGHT_REEL")), action = StartMenuOpenCustomizeHighlightReel, disabledFunction = IsCustomizeHighlightReelButtonDisabled}}) - end - table.insert(options, {models = {displayText = Engine.ToUpper(Engine.ToUpper(Engine.Localize("MENU_JUMP_TO_START"))), action = StartMenuJumpToStart, disabledFunction = IsJumpToStartButtonDisabled}, properties = {hideHelpItemLabel = true}}) - local endDemoButtonText = nil - if Engine.IsDemoClipPlaying() then - endDemoButtonText = Engine.ToUpper(Engine.Localize("MENU_END_CLIP")) - else - endDemoButtonText = Engine.ToUpper(Engine.Localize("MENU_END_FILM")) - end - table.insert(options, {models = {displayText = Engine.ToUpper(endDemoButtonText), action = StartMenuEndDemo}}) - elseif CoD.isCampaign then - table.insert(options, {models = {displayText = "MENU_RESUMEGAME_CAPS", action = StartMenuGoBack_ListElement}}) - local inTrainingSim = CoD.SafeGetModelValue(Engine.GetModelForController(controller), "safehouse.inTrainingSim") - if not inTrainingSim then - inTrainingSim = 0 - end - if Engine.IsLobbyHost(Enum.LobbyType.LOBBY_TYPE_GAME) then - if not CoD.isSafehouse and controller == Engine.GetPrimaryController() then - table.insert(options, {models = {displayText = "MENU_RESTART_MISSION_CAPS", action = RestartMission}}) - if LUI.DEV ~= nil then - table.insert(options, {models = {displayText = "MENU_RESTART_CHECKPOINT_CAPS", action = RestartFromCheckpoint}}) - end - end - if controller == Engine.GetPrimaryController() then - table.insert(options, {models = {displayText = "MENU_CHANGE_DIFFICULTY_CAPS", action = OpenDifficultySelect}}) - end - if CoD.isSafehouse and inTrainingSim == 1 then - table.insert(options, {models = {displayText = "MENU_END_TRAINING_SIM", action = EndTrainingSim}}) - elseif controller == Engine.GetPrimaryController() then - if Engine.DvarBool(0, "ui_blocksaves") then - table.insert(options, {models = {displayText = "MENU_EXIT_CAPS", action = SaveAndQuitGame}}) - else - table.insert(options, {models = {displayText = "MENU_SAVE_AND_QUIT_CAPS", action = SaveAndQuitGame}}) - end - end - elseif CoD.isSafehouse and inTrainingSim == 1 then - table.insert(options, {models = {displayText = "MENU_END_TRAINING_SIM", action = EndTrainingSim}}) - else - table.insert(options, {models = {displayText = "MENU_LEAVE_PARTY_AND_EXIT_CAPS", action = QuitGame}}) - end - elseif CoD.isMultiplayer then - if Engine.Team(controller, "name") ~= "TEAM_SPECTATOR" and Engine.GetGametypeSetting("disableClassSelection") ~= 1 then - table.insert(options, {models = {displayText = "MPUI_CHOOSE_CLASS_BUTTON_CAPS", action = ChooseClass}}) - end - if not Engine.IsVisibilityBitSet(controller, Enum.UIVisibilityBit.BIT_ROUND_END_KILLCAM) and not Engine.IsVisibilityBitSet(controller, Enum.UIVisibilityBit.BIT_FINAL_KILLCAM) and CoD.IsTeamChangeAllowed() then - table.insert(options, {models = {displayText = "MPUI_CHANGE_TEAM_BUTTON_CAPS", action = ChooseTeam}}) - end - if controller == 0 then - local endGameText = "MENU_QUIT_GAME_CAPS" - if Engine.IsLobbyHost(Enum.LobbyType.LOBBY_TYPE_GAME) and not CoD.isOnlineGame() then - endGameText = "MENU_END_GAME_CAPS" - end - table.insert(options, {models = {displayText = endGameText, action = QuitGame_MP}}) - end - elseif CoD.isZombie then - table.insert(options, {models = {displayText = "MENU_RESUMEGAME_CAPS", action = StartMenuGoBack_ListElement}}) - if Engine.IsLobbyHost(Enum.LobbyType.LOBBY_TYPE_GAME) and (not Engine.SessionModeIsMode(CoD.SESSIONMODE_SYSTEMLINK) or Engine.SessionModeIsMode(CoD.SESSIONMODE_OFFLINE)) then - table.insert(options, {models = {displayText = "MENU_RESTART_LEVEL_CAPS", action = RestartGame}}) - end - if Engine.IsLobbyHost(Enum.LobbyType.LOBBY_TYPE_GAME) == true then - table.insert(options, {models = {displayText = "MENU_END_GAME_CAPS", action = QuitGame_MP}}) - else - table.insert(options, {models = {displayText = "MENU_QUIT_GAME_CAPS", action = QuitGame_MP}}) - end - end - return options -end, true) +require("DataSources_StartMenuGameOptions") From 6a25f0e4aba88338ae9794536dd227e2b12dc44b Mon Sep 17 00:00:00 2001 From: WantedDV <122710241+WantedDV@users.noreply.github.com> Date: Wed, 12 Apr 2023 18:29:00 -0230 Subject: [PATCH 3/5] Robust com_maxclients override - now sets com_maxclients to lobby default - supports all modes --- data/ui_scripts/party/__init__.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/data/ui_scripts/party/__init__.lua b/data/ui_scripts/party/__init__.lua index 2030b7bc..a2a96f46 100644 --- a/data/ui_scripts/party/__init__.lua +++ b/data/ui_scripts/party/__init__.lua @@ -7,15 +7,17 @@ CoD.IsTeamChangeAllowed = function() end end --- Set com_maxclients InGame so players can join via direct connect -local maxclients = function() - if Engine.IsZombiesGame() then - return 4 - else - return 18 - end +local GetModeInfo = function() + local id = Engine.GetLobbyUIScreen() + return LobbyData:UITargetFromId(id) end -Engine.SetDvar( "com_maxclients", maxclients() ) +local GetMaxClients = function() + local ModeInfo = GetModeInfo() + return ModeInfo.maxClients +end + +-- Set com_maxclients InGame so players can join via direct connect (default from lobbydata) +Engine.SetDvar( "com_maxclients", GetMaxClients() ) require("DataSources_StartMenuGameOptions") From b32168dce6642853d3712ee6d7f0a8e67e65f25c Mon Sep 17 00:00:00 2001 From: WantedDV <122710241+WantedDV@users.noreply.github.com> Date: Wed, 12 Apr 2023 19:50:41 -0230 Subject: [PATCH 4/5] Make these changes InGame only --- data/ui_scripts/party/__init__.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/data/ui_scripts/party/__init__.lua b/data/ui_scripts/party/__init__.lua index a2a96f46..5821c1fd 100644 --- a/data/ui_scripts/party/__init__.lua +++ b/data/ui_scripts/party/__init__.lua @@ -1,3 +1,7 @@ +if not Engine.IsInGame() then + return +end + -- Removed check for public matches to allow team change in ranked matches CoD.IsTeamChangeAllowed = function() if Engine.GetGametypeSetting( "allowInGameTeamChange" ) == 1 then From 07586dfeee41e79babffde3e739a59aeea5f949f Mon Sep 17 00:00:00 2001 From: WantedDV <122710241+WantedDV@users.noreply.github.com> Date: Wed, 12 Apr 2023 19:51:35 -0230 Subject: [PATCH 5/5] Standard Lua formating --- data/ui_scripts/party/__init__.lua | 16 ++++++++-------- ...a => datasources_start_menu_game_options.lua} | 0 2 files changed, 8 insertions(+), 8 deletions(-) rename data/ui_scripts/party/{DataSources_StartMenuGameOptions.lua => datasources_start_menu_game_options.lua} (100%) diff --git a/data/ui_scripts/party/__init__.lua b/data/ui_scripts/party/__init__.lua index 5821c1fd..cd6c5e3e 100644 --- a/data/ui_scripts/party/__init__.lua +++ b/data/ui_scripts/party/__init__.lua @@ -4,24 +4,24 @@ end -- Removed check for public matches to allow team change in ranked matches CoD.IsTeamChangeAllowed = function() - if Engine.GetGametypeSetting( "allowInGameTeamChange" ) == 1 then + if Engine.GetGametypeSetting("allowInGameTeamChange") == 1 then return true else return false end end -local GetModeInfo = function() +local getModeInfo = function() local id = Engine.GetLobbyUIScreen() - return LobbyData:UITargetFromId(id) + return LobbyData:UITargetFromId(id) end -local GetMaxClients = function() - local ModeInfo = GetModeInfo() - return ModeInfo.maxClients +local getMaxClients = function() + local modeInfo = getModeInfo() + return modeInfo.maxClients end -- Set com_maxclients InGame so players can join via direct connect (default from lobbydata) -Engine.SetDvar( "com_maxclients", GetMaxClients() ) +Engine.SetDvar("com_maxclients", getMaxClients()) -require("DataSources_StartMenuGameOptions") +require("datasources_start_menu_game_options") diff --git a/data/ui_scripts/party/DataSources_StartMenuGameOptions.lua b/data/ui_scripts/party/datasources_start_menu_game_options.lua similarity index 100% rename from data/ui_scripts/party/DataSources_StartMenuGameOptions.lua rename to data/ui_scripts/party/datasources_start_menu_game_options.lua