From 52d946ed095ef0dc8943cd044384421a9b1e3490 Mon Sep 17 00:00:00 2001 From: Jbleezy Date: Thu, 6 Jun 2024 02:47:59 -0700 Subject: [PATCH] Optimize private game lobby --- ui/t6/mainlobby.lua | 42 ++++++++++++++++----- ui/t6/mapslist.lua | 33 +++------------- ui/t6/menus/privateonlinegamelobby.lua | 20 ++++++---- ui_mp/t6/menus/privategamelobby_project.lua | 1 - 4 files changed, 50 insertions(+), 46 deletions(-) diff --git a/ui/t6/mainlobby.lua b/ui/t6/mainlobby.lua index 5efee877..b5794fdb 100644 --- a/ui/t6/mainlobby.lua +++ b/ui/t6/mainlobby.lua @@ -134,7 +134,6 @@ CoD.MainLobby.OpenPlayerMatchPartyLobby = function(MainLobbyWidget, ClientInstan if CoD.isZombie == true then Engine.PartyHostSetUIState(CoD.PARTYHOST_STATE_SELECTING_PLAYLIST) CoD.PlaylistCategoryFilter = "playermatch" - CoD.PrivateGameLobby.InGameLobby = nil MainLobbyWidget:openMenu("SelectGameModeListZM", ClientInstance.controller) CoD.GameGlobeZombie.MoveToCenter(ClientInstance.controller) else @@ -189,12 +188,11 @@ CoD.MainLobby.OpenCustomGamesLobby = function(MainLobbyWidget, ClientInstance) if CoD.MainLobby.ShouldPreventCreateLobby() then return elseif CoD.MainLobby.OnlinePlayAvailable(MainLobbyWidget, ClientInstance) == 1 and CoD.MainLobby.IsControllerCountValid(MainLobbyWidget, ClientInstance.controller, UIExpression.DvarInt(ClientInstance.controller, "party_maxlocalplayers_privatematch")) == 1 then - -- CoD.SwitchToPrivateLobby(ClientInstance.controller) + CoD.MainLobby.SwitchToPrivateLobby(ClientInstance) if CoD.isZombie == true then - -- Engine.SetDvar("ui_zm_mapstartlocation", "") - CoD.PrivateGameLobby.InGameLobby = nil + CoD.MainLobby.InitMapDvars() Engine.SetDvar("party_solo", 0) - MainLobbyWidget:openMenu("SelectGameModeListZM", ClientInstance.controller) + CoD.MainLobby.OpenPrivateGameLobbyAndSelectGameModeList(MainLobbyWidget, ClientInstance) -- CoD.GameGlobeZombie.MoveToCenter(ClientInstance.controller) else local PrivateOnlineLobbyMenu = MainLobbyWidget:openMenu("PrivateOnlineGameLobby", ClientInstance.controller) @@ -208,19 +206,45 @@ CoD.MainLobby.OpenSoloLobby_Zombie = function(MainLobbyWidget, ClientInstance) return elseif CoD.MainLobby.OnlinePlayAvailable(MainLobbyWidget, ClientInstance) == 1 then if CoD.MainLobby.IsControllerCountValid(MainLobbyWidget, ClientInstance.controller, 1) == 1 then + CoD.MainLobby.SwitchToPrivateLobby(ClientInstance) + CoD.MainLobby.InitMapDvars() MainLobbyWidget.lobbyPane.body.lobbyList.maxLocalPlayers = 1 - -- CoD.SwitchToPlayerMatchLobby(ClientInstance.controller) + Engine.SetDvar("party_solo", 1) Dvar.party_maxplayers:set(1) CoD.PlaylistCategoryFilter = CoD.Zombie.PLAYLIST_CATEGORY_FILTER_SOLOMATCH - CoD.PrivateGameLobby.InGameLobby = nil - Engine.SetDvar("party_solo", 1) - MainLobbyWidget:openMenu("SelectGameModeListZM", ClientInstance.controller) + CoD.MainLobby.OpenPrivateGameLobbyAndSelectGameModeList(MainLobbyWidget, ClientInstance) -- CoD.GameGlobeZombie.MoveToCenter(ClientInstance.controller) MainLobbyWidget:close() end end end +CoD.MainLobby.SwitchToPrivateLobby = function(ClientInstance) + local gameType = UIExpression.DvarString(nil, "ui_gametype") + local mapName = UIExpression.DvarString(nil, "ui_mapname") + CoD.SwitchToPrivateLobby(ClientInstance.controller) -- this changes these dvars + Engine.SetDvar("ui_gametype", gameType) + Engine.SetDvar("ui_mapname", mapName) +end + +CoD.MainLobby.InitMapDvars = function() + Engine.SetDvar("ui_mapname", "zm_transit") + Engine.SetDvar("ui_zm_mapstartlocation", "transit") + Engine.SetDvar("ui_zm_gamemodegroup", "zclassic") + Engine.SetDvar("ui_gametype", "zclassic") + Engine.SetDvar("ui_mapname_index", 1) + Engine.SetDvar("ui_zm_mapstartlocation_index", 1) + Engine.SetDvar("ui_gametype_index", 1) +end + +CoD.MainLobby.OpenPrivateGameLobbyAndSelectGameModeList = function(MainLobbyWidget, ClientInstance) + -- open both menus so map background is shown + local PrivateGameLobbyWidget = MainLobbyWidget:openMenu("PrivateOnlineGameLobby", ClientInstance.controller) + local SelectGameModeListWidget = PrivateGameLobbyWidget:openMenu("SelectGameModeListZM", ClientInstance.controller) + SelectGameModeListWidget:setPreviousMenu("PrivateOnlineGameLobby") + PrivateGameLobbyWidget:close() +end + CoD.MainLobby.OpenTheaterLobby = function(MainLobbyWidget, ClientInstance) if CoD.MainLobby.ShouldPreventCreateLobby() then return diff --git a/ui/t6/mapslist.lua b/ui/t6/mapslist.lua index b6e24af7..31d45b3f 100644 --- a/ui/t6/mapslist.lua +++ b/ui/t6/mapslist.lua @@ -42,14 +42,6 @@ CoD.MapsList.Locations = { -- "ZMUI_CRAZY_PLACE_CAPS", -- TODO: add localized string, uncomment when location is added } -local function switchToPrivateLobby(self) - local gameType = UIExpression.DvarString(nil, "ui_gametype") - local mapName = UIExpression.DvarString(nil, "ui_mapname") - CoD.SwitchToPrivateLobby(self.controller) -- this changes these dvars - Engine.SetDvar("ui_gametype", gameType) - Engine.SetDvar("ui_mapname", mapName) -end - local function gameModeListFocusChangedEventHandler(self, event) local focusedIndex = self.listBox:getFocussedIndex() end @@ -123,11 +115,7 @@ function LUI.createMenu.SelectGameModeListZM(controller) local self = CoD.Menu.New("SelectGameModeListZM") self.controller = controller - if CoD.PrivateGameLobby.InGameLobby == true then - self:setPreviousMenu("PrivateOnlineGameLobby") - else - self:setPreviousMenu("MainLobby") - end + self:setPreviousMenu("PrivateOnlineGameLobby") self:registerEventHandler("open_menu", CoD.Lobby.OpenMenu) self:addSelectButton() @@ -143,13 +131,7 @@ function LUI.createMenu.SelectGameModeListZM(controller) listBox:addScrollBar(530 + (8 * 12), 2) if UIExpression.DvarBool(nil, "party_solo") == 1 then - local numGameModes = 2 - - if index > numGameModes then - index = 1 - end - - listBox:setTotalItems(numGameModes, index) + listBox:setTotalItems(2, index) else listBox:setTotalItems(#CoD.MapsList.GameModes, index) end @@ -162,6 +144,7 @@ function LUI.createMenu.SelectGameModeListZM(controller) self:registerEventHandler("click", gameModeListSelectionClickedEventHandler) Engine.PartyHostSetUIState(CoD.PARTYHOST_STATE_SELECTING_GAMETYPE) + CoD.PrivateGameLobby.FadeIn = true return self end @@ -194,10 +177,6 @@ local function mapListSelectionClickedEventHandler(self, event) Engine.SetDvar("ui_zm_mapstartlocation", "tomb") end - if CoD.PrivateGameLobby.InGameLobby == nil then - switchToPrivateLobby(self) - end - self:openMenu("PrivateOnlineGameLobby", self.controller) self:close() @@ -243,6 +222,7 @@ function LUI.createMenu.SelectMapListZM(controller) self:registerEventHandler("click", mapListSelectionClickedEventHandler) Engine.PartyHostSetUIState(CoD.PARTYHOST_STATE_SELECTING_MAP) + CoD.PrivateGameLobby.FadeIn = true return self end @@ -310,10 +290,6 @@ local function locationListSelectionClickedEventHandler(self, event) -- TODO: set dvars when location is added end - if CoD.PrivateGameLobby.InGameLobby == nil then - switchToPrivateLobby(self) - end - self:openMenu("PrivateOnlineGameLobby", self.controller) self:close() @@ -359,6 +335,7 @@ function LUI.createMenu.SelectLocationListZM(controller) self:registerEventHandler("click", locationListSelectionClickedEventHandler) Engine.PartyHostSetUIState(CoD.PARTYHOST_STATE_SELECTING_MAP) + CoD.PrivateGameLobby.FadeIn = true return self end diff --git a/ui/t6/menus/privateonlinegamelobby.lua b/ui/t6/menus/privateonlinegamelobby.lua index 3f5c705a..6f486ab5 100644 --- a/ui/t6/menus/privateonlinegamelobby.lua +++ b/ui/t6/menus/privateonlinegamelobby.lua @@ -9,14 +9,18 @@ LUI.createMenu.PrivateOnlineGameLobby = function(f1_arg0) f1_local0:addTitle(f1_local1) f1_local0.panelManager.panels.buttonPane.titleText = f1_local1 - f1_local0:registerAnimationState("hide", { - alpha = 0, - }) - f1_local0:animateToState("hide") - f1_local0:registerAnimationState("show", { - alpha = 1, - }) - f1_local0:animateToState("show", 500) + if CoD.PrivateGameLobby.FadeIn == true then + CoD.PrivateGameLobby.FadeIn = nil + + f1_local0:registerAnimationState("hide", { + alpha = 0, + }) + f1_local0:animateToState("hide") + f1_local0:registerAnimationState("show", { + alpha = 1, + }) + f1_local0:animateToState("show", 500) + end return f1_local0 end diff --git a/ui_mp/t6/menus/privategamelobby_project.lua b/ui_mp/t6/menus/privategamelobby_project.lua index f1d86730..dacbfe4f 100644 --- a/ui_mp/t6/menus/privategamelobby_project.lua +++ b/ui_mp/t6/menus/privategamelobby_project.lua @@ -464,7 +464,6 @@ CoD.PrivateGameLobby.LeaveLobby_Project = function(PrivateGameLobbyWidget, Clien end CoD.PrivateGameLobby.OpenChangeStartLoc = function(PrivateGameLobbyWidget, ClientInstance) - CoD.PrivateGameLobby.InGameLobby = true if UIExpression.DvarString(nil, "ui_gameType") == "zclassic" then local f27_local0 = PrivateGameLobbyWidget:openMenu("SelectMapListZM", ClientInstance.controller) f27_local0:setPreviousMenu("SelectGameModeListZM")