private static void HandleRestartConnect() { if (Multiplayer.restartConnect == null) { return; } // No colon means the connect string is a steam user id if (!Multiplayer.restartConnect.Contains(':')) { if (ulong.TryParse(Multiplayer.restartConnect, out ulong steamUser)) { DoubleLongEvent(() => ClientUtil.TrySteamConnectWithWindow((CSteamID)steamUser, false), "MpConnecting"); } return; } var split = Multiplayer.restartConnect.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (split.Length == 2 && int.TryParse(split[1], out int port)) { DoubleLongEvent(() => ClientUtil.TryConnectWithWindow(split[0], port, false), "MpConnecting"); } }
private void DrawSteam(Rect inRect) { string info = null; if (!SteamManager.Initialized) { info = "MpNotConnectedToSteam".Translate(); } else if (friends.Count == 0) { info = "MpNoFriendsPlaying".Translate(); } if (info != null) { using (MpStyle.Set(TextAnchor.MiddleCenter)) Widgets.Label(new Rect(0, 8, inRect.width, 40f), info); inRect.yMin += 40f; } float margin = 80; Rect outRect = new Rect(margin, inRect.yMin + 10, inRect.width - 2 * margin, inRect.height - 20); float height = friends.Count * 40; Rect viewRect = new Rect(0, 0, outRect.width - 16f, height); Widgets.BeginScrollView(outRect, ref steamScroll, viewRect, true); float y = 0; int i = 0; foreach (SteamPersona friend in friends) { Rect entryRect = new Rect(0, y, viewRect.width, 40); if (i % 2 == 0) { Widgets.DrawAltRect(entryRect); } if (Event.current.type == EventType.Repaint) { GUI.DrawTextureWithTexCoords(new Rect(5, entryRect.y + 4, 32, 32), SteamImages.GetTexture(friend.avatar), new Rect(0, 1, 1, -1)); } using (MpStyle.Set(TextAnchor.MiddleLeft)) Widgets.Label(entryRect.Right(45).Up(5), friend.username); using (MpStyle.Set(GameFont.Tiny)) using (MpStyle.Set(TextAnchor.MiddleLeft)) using (MpStyle.Set(SteamGreen)) Widgets.Label(entryRect.Right(45).Down(8), "MpPlayingRimWorld".Translate()); if (friend.serverHost != CSteamID.Nil) { Rect playButton = new Rect(entryRect.xMax - 85, entryRect.y + 5, 80, 40 - 10); if (Widgets.ButtonText(playButton, "MpJoinButton".Translate())) { Close(false); ClientUtil.TrySteamConnectWithWindow(friend.serverHost); } } else { Rect playButton = new Rect(entryRect.xMax - 125, entryRect.y + 5, 120, 40 - 10); Widgets.ButtonText(playButton, "MpNotInMultiplayer".Translate(), false, false, false); } y += entryRect.height; i++; } Widgets.EndScrollView(); }