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) { Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(new Rect(0, 8, inRect.width, 40f), info); Text.Anchor = TextAnchor.UpperLeft; 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)); } Text.Anchor = TextAnchor.MiddleLeft; Widgets.Label(entryRect.Right(45).Up(5), friend.username); GUI.color = SteamGreen; Text.Font = GameFont.Tiny; Widgets.Label(entryRect.Right(45).Down(8), "MpPlayingRimWorld".Translate()); Text.Font = GameFont.Small; GUI.color = Color.white; Text.Anchor = TextAnchor.MiddleCenter; 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); Log.Message("Connecting through Steam"); Find.WindowStack.Add(new SteamConnectingWindow(friend.serverHost) { returnToServerBrowser = true }); var conn = new SteamClientConn(friend.serverHost); conn.username = Multiplayer.username; Multiplayer.session = new MultiplayerSession(); Multiplayer.session.client = conn; Multiplayer.session.ReapplyPrefs(); conn.State = ConnectionStateEnum.ClientSteam; } } else { Rect playButton = new Rect(entryRect.xMax - 125, entryRect.y + 5, 120, 40 - 10); Widgets.ButtonText(playButton, "MpNotInMultiplayer".Translate(), false, false, false); } Text.Anchor = TextAnchor.UpperLeft; y += entryRect.height; i++; } Widgets.EndScrollView(); }
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(); }