/// <summary> /// Select a server in the list and prefill the steam lobby id hidden field /// </summary> /// <param name="index"></param> private void SetSelectedServer(int index) { // If we selected the server that was already selected then nothing else to do. if (selectedServer == index) { return; } selectedServer = index; // Set the border for the selected list item for (int i = 0; i < serverList.Count; i++) { SetListItemSelected(serverList[i], index == i); } if (index >= 0) { // We have selected a server from the server list so enable the connect button connectButton.interactable = true; // Rename the connect button to state the name of the server/lobby to be joined connectButtonLabel.text = $"Connect to {serverList[index].ListItem.serverName.text}"; // Tell the multiplayer menu the steam id of the lobby that was selected mpMenu.SetSelectedLobby(serverList[selectedServer].lobby); } else { connectButton.interactable = false; connectButtonLabel.text = "Connect"; mpMenu.SetSelectedLobby(default(Steamworks.Data.Lobby)); } }
/// <summary> /// Handle the lobby join requests when already in game for an invite /// </summary> /// <param name="result"></param> private void OnLobbyJoinRequested(GameLobbyJoinRequested_t result) { // TODO: make sure join requests can be accepted if already playing. // that will require setting the lobby id somewhere else and disconnecting from the game first. mpMenu.SetSelectedLobby(result.m_steamIDLobby); mpMenu.Connect(); }