private async void OnServerNameChange(string newValue) { Plugin.Config.CustomGameName = newValue; newValue = MpSession.GetHostGameName(); // this will read CustomGameName but fall back to a default name if left empty Plugin.Config.CustomGameName = newValue; _serverNameSetting.EnterPressed(newValue); // this will update both keyboard text & button face text }
private static HostedGameData GenerateAnnounce() { var sessionManager = MpSession.SessionManager; var localPlayer = sessionManager.localPlayer; var connectedPlayers = sessionManager.connectedPlayers; if (_mpExVersion == null) { _mpExVersion = MpExHelper.GetInstalledVersion(); if (_mpExVersion != null) { Plugin.Log?.Info($"Detected MultiplayerExtensions, version {_mpExVersion}"); } } var lobbyAnnounce = new HostedGameData() { ServerCode = _lobbyCode, GameName = MpSession.GetHostGameName(), OwnerId = localPlayer.userId, OwnerName = localPlayer.userName, PlayerCount = MpSession.GetPlayerCount(), PlayerLimit = MpSession.GetPlayerLimit(), IsModded = localPlayer.HasState("modded") || localPlayer.HasState("customsongs") || _mpExVersion != null, LobbyState = MpLobbyStatePatch.LobbyState, LevelId = _level?.levelID, SongName = _level?.songName, SongAuthor = _level?.songAuthorName, Difficulty = _difficulty, Platform = MpLocalPlayer.PlatformId, MasterServerHost = MpConnect.LastUsedMasterServer != null ? MpConnect.LastUsedMasterServer.hostName : null, MasterServerPort = MpConnect.LastUsedMasterServer != null ? MpConnect.LastUsedMasterServer.port : MpConnect.DEFAULT_MASTER_PORT, MpExVersion = _mpExVersion }; lobbyAnnounce.Players = new List <HostedGamePlayer>(); lobbyAnnounce.Players.Add(new HostedGamePlayer() { SortIndex = localPlayer.sortIndex, UserId = localPlayer.userId, UserName = localPlayer.userName, IsHost = localPlayer.isConnectionOwner, Latency = localPlayer.currentLatency }); foreach (var connectedPlayer in connectedPlayers) { lobbyAnnounce.Players.Add(new HostedGamePlayer() { SortIndex = connectedPlayer.sortIndex, UserId = connectedPlayer.userId, UserName = connectedPlayer.userName, IsHost = connectedPlayer.isConnectionOwner, Latency = connectedPlayer.currentLatency }); } return(lobbyAnnounce); }