static bool Prefix() { Text.Font = GameFont.Small; if (MpVersion.IsDebug) { DoDebugInfo(); } if (Multiplayer.IsReplay || TickPatch.Skipping) { DrawTimeline(); DrawSkippingWindow(); } DoButtons(); if (Multiplayer.Client != null && !Multiplayer.IsReplay && Multiplayer.ToggleChatDef.KeyDownEvent) { Event.current.Use(); if (ChatWindow.Opened != null) { ChatWindow.Opened.Close(); } else { ChatWindow.OpenChat(); } } return(Find.Maps.Count > 0); }
static bool Prefix() { Text.Font = GameFont.Small; if (MpVersion.IsDebug) { DoDebugInfo(); } if (Multiplayer.IsReplay || TickPatch.Simulating) { DrawTimeline(); } if (TickPatch.Simulating) { HandleSimulatingEvents(); DrawModalWindow( TickPatch.simulating.simTextKey.Translate(), () => TickPatch.Simulating, TickPatch.simulating.onCancel, TickPatch.simulating.cancelButtonKey.Translate() ); } if (TickPatch.Paused) { DrawModalWindow( "Waiting for other players", () => TickPatch.Paused, MainMenuPatch.AskQuitToMainMenu, "Quit" ); } DoButtons(); if (Multiplayer.Client != null && !Multiplayer.IsReplay && MultiplayerStatic.ToggleChatDef.KeyDownEvent) { Event.current.Use(); if (ChatWindow.Opened != null) { ChatWindow.Opened.Close(); } else { ChatWindow.OpenChat(); } } return(Find.Maps.Count > 0); }
static void DoButtons() { float y = 10f; const float btnHeight = 27f; const float btnWidth = 80f; float x = UI.screenWidth - btnWidth - 10f; var session = Multiplayer.session; if (session != null && !Multiplayer.IsReplay) { var btnRect = new Rect(x, y, btnWidth, btnHeight); var chatColor = session.players.Any(p => p.status == PlayerStatus.Desynced) ? "#ff5555" : "#dddddd"; var hasUnread = session.hasUnread ? "*" : ""; var chatLabel = $"{"MpChatButton".Translate()} <color={chatColor}>({session.players.Count})</color>{hasUnread}"; if (Widgets.ButtonText(btnRect, chatLabel)) { ChatWindow.OpenChat(); } if (!TickPatch.Skipping) { IndicatorInfo(out Color color, out string text, out bool slow); var indRect = new Rect(btnRect.x - 25f - 5f + 6f / 2f, btnRect.y + 6f / 2f, 19f, 19f); var biggerRect = new Rect(btnRect.x - 25f - 5f + 2f / 2f, btnRect.y + 2f / 2f, 23f, 23f); if (slow && Widgets.ButtonInvisible(biggerRect)) { TickPatch.SkipTo(toTickUntil: true, canESC: true); } Widgets.DrawRectFast(biggerRect, new Color(color.r * 0.6f, color.g * 0.6f, color.b * 0.6f)); Widgets.DrawRectFast(indRect, color); TooltipHandler.TipRegion(indRect, new TipSignal(text, 31641624)); } y += btnHeight; } if (Multiplayer.ShowDevInfo && Multiplayer.WriterLog != null) { if (Widgets.ButtonText(new Rect(x, y, 80f, 27f), $"Write ({Multiplayer.WriterLog.nodes.Count})")) { Find.WindowStack.Add(Multiplayer.WriterLog); } y += btnHeight; if (Widgets.ButtonText(new Rect(x, y, 80f, 27f), $"Read ({Multiplayer.ReaderLog.nodes.Count})")) { Find.WindowStack.Add(Multiplayer.ReaderLog); } y += btnHeight; } if (Multiplayer.Client != null && Multiplayer.WorldComp.trading.Any()) { if (Widgets.ButtonText(new Rect(x, y, btnWidth, btnHeight), "MpTradingButton".Translate())) { Find.WindowStack.Add(new TradingWindow()); } y += btnHeight; } if (Multiplayer.Client != null && Multiplayer.WorldComp.debugMode) { Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(new Rect(x, y, btnWidth, 30f), $"Debug mode"); Text.Anchor = TextAnchor.UpperLeft; Text.Font = GameFont.Small; } }