Skip to content

Commit c950171

Browse files
authored
Fix the SyncDebugPanel having content cut off (#699)
1 parent 1d9dd22 commit c950171

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

Source/Client/UI/DebugPanel/SyncDebugPanel.cs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,29 @@
22
using System.Linq;
33
using Multiplayer.Client.Desyncs;
44
using Multiplayer.Client.Util;
5-
using Multiplayer.Client.Patches;
65
using Multiplayer.Common;
76
using RimWorld;
87
using UnityEngine;
98
using Verse;
10-
using System.Collections.Generic; // Added for List
9+
using System.Collections.Generic;
1110

1211
namespace Multiplayer.Client.DebugUi
1312
{
1413
/// <summary>
1514
/// Enhanced expandable debug panel that organizes existing comprehensive debug information
1615
/// with modern UI/UX while preserving all developer functionality
1716
/// </summary>
18-
public static partial class SyncDebugPanel
17+
public static class SyncDebugPanel
1918
{
2019
// Panel state
21-
private static bool isExpanded = false;
20+
private static bool isExpanded;
2221
private static Vector2 scrollPosition = Vector2.zero;
2322

2423
// Panel dimensions
2524
private const float HeaderHeight = 40f;
2625
private const float VisibleExpandedHeight = 400f;
27-
private const float ContentHeight = 1500f;
2826
private const float PanelWidth = 275f;
27+
private static float contentHeight;
2928

3029
// Visual constants
3130
private const float Margin = 8f;
@@ -175,7 +174,7 @@ private static void DrawExpandedPanel(Rect rect)
175174
Rect contentRect = new(rect.x, rect.y + 30f, rect.width, rect.height - 30f);
176175

177176
DrawHeader(headerRect);
178-
Rect viewRect = new(0f, 0f, contentRect.width - 16f, ContentHeight);
177+
Rect viewRect = new(0f, 0f, contentRect.width - 16f, contentHeight);
179178
Widgets.BeginScrollView(contentRect, ref scrollPosition, viewRect);
180179

181180
float currentY = 0f;
@@ -194,6 +193,8 @@ private static void DrawExpandedPanel(Rect rect)
194193
currentY += DrawMemoryPerformanceSection(viewRect.x + Margin, currentY, viewRect.width - Margin);
195194
currentY += DrawMapManagementSection(viewRect.x + Margin, currentY, viewRect.width - Margin);
196195

196+
if (Event.current.type == EventType.Layout) contentHeight = currentY;
197+
197198
Widgets.EndScrollView();
198199
}
199200

@@ -241,7 +242,7 @@ private static float DrawStatusSummarySection(float x, float y, float width)
241242
private static float DrawPerformanceRecorderSection(float x, float y, float width)
242243
{
243244
StatusBadge recordingStatus = PerformanceRecorder.GetRecordingStatus();
244-
245+
245246
var lines = new List<DebugLine>
246247
{
247248
new("Status:", recordingStatus.text, recordingStatus.color),
@@ -254,7 +255,7 @@ private static float DrawPerformanceRecorderSection(float x, float y, float widt
254255
lines.Add(new("Duration:", $"{duration.TotalSeconds:F1}s", Color.white));
255256
lines.Add(new("Avg FPS:", PerformanceRecorder.AverageFPS > 0 ? $"{PerformanceRecorder.AverageFPS:F1}" : "N/A", Color.white));
256257
lines.Add(new("Avg TPS:", PerformanceRecorder.AverageTPS > 0 ? $"{PerformanceRecorder.AverageTPS:F1}" : "N/A", Color.white));
257-
258+
258259
if (PerformanceCalculator.IsInStabilizationPeriod())
259260
{
260261
lines.Add(new("TPS Perf:", "STABILIZING", Color.yellow));
@@ -267,11 +268,11 @@ private static float DrawPerformanceRecorderSection(float x, float y, float widt
267268

268269
var section = new DebugSection("PERFORMANCE RECORDER", lines.ToArray());
269270
float sectionHeight = DrawSection(x, y, width, section);
270-
271+
271272
// Add control buttons below the section
272273
float buttonY = y + sectionHeight - SectionSpacing + 4f;
273274
float buttonHeight = DrawRecorderControls(x, buttonY, width);
274-
275+
275276
return sectionHeight + buttonHeight;
276277
}
277278

@@ -314,21 +315,21 @@ private static float DrawRecorderControls(float x, float y, float width)
314315

315316
var startRect = new Rect(x, currentY, buttonWidth, buttonHeight);
316317
var stopRect = new Rect(x + buttonWidth + spacing, currentY, buttonWidth, buttonHeight);
317-
318+
318319
GUI.color = PerformanceRecorder.IsRecording ? Color.gray : Color.white;
319-
320+
320321
if (Widgets.ButtonText(startRect, "Start") && !PerformanceRecorder.IsRecording)
321322
{
322323
PerformanceRecorder.StartRecording();
323324
}
324325

325326
GUI.color = !PerformanceRecorder.IsRecording ? Color.gray : Color.white;
326-
327+
327328
if (Widgets.ButtonText(stopRect, "Stop") && PerformanceRecorder.IsRecording)
328329
{
329330
PerformanceRecorder.StopRecording();
330331
}
331-
332+
332333
GUI.color = Color.white;
333334
currentY += buttonHeight + spacing;
334335
return currentY - y;
@@ -379,7 +380,7 @@ private static float DrawPerformanceSection(float x, float y, float width)
379380
float targetTps = PerformanceCalculator.GetTargetTPS();
380381
string tpsPerformanceText;
381382
Color tpsColor;
382-
383+
383384
if (PerformanceCalculator.IsInStabilizationPeriod())
384385
{
385386
tpsPerformanceText = "STABILIZING";
@@ -477,7 +478,7 @@ private static float DrawTimingSyncSection(float x, float y, float width)
477478
{
478479
int timerLag = TickPatch.tickUntil - TickPatch.Timer;
479480
Color lagColor = PerformanceCalculator.GetPerformanceColor(timerLag, 15, 30);
480-
481+
481482
DebugLine[] timingLines = [
482483
new("Timer Lag:", $"{timerLag}", lagColor),
483484
new("Timer:", $"{TickPatch.Timer}", Color.white),
@@ -503,7 +504,7 @@ private static float DrawGameStateSection(float x, float y, float width)
503504
try
504505
{
505506
AsyncTimeComp async = Find.CurrentMap?.AsyncTime();
506-
507+
507508
DebugLine[] gameStateLines = [
508509
new("Classic Mode:", $"{Find.IdeoManager?.classicMode ?? false}", Color.white),
509510
new("Client Opinions:", $"{Multiplayer.game?.sync?.knownClientOpinions?.Count ?? 0}", Color.white),
@@ -544,7 +545,7 @@ private static float DrawCommandSyncSection(float x, float y, float width)
544545
try
545546
{
546547
AsyncTimeComp async = Find.CurrentMap?.AsyncTime();
547-
548+
548549
DebugLine[] commandLines = [
549550
new("Async Commands:", $"{async?.cmds?.Count ?? 0}", Color.white),
550551
new("World Commands:", $"{Multiplayer.AsyncWorldTime?.cmds?.Count ?? 0}", Color.white),
@@ -570,7 +571,7 @@ private static float DrawMemoryPerformanceSection(float x, float y, float width)
570571
float serverTpt = TickPatch.tickUntil - TickPatch.Timer <= 3 ? TickPatch.serverTimePerTick * 1.2f :
571572
TickPatch.tickUntil - TickPatch.Timer >= 7 ? TickPatch.serverTimePerTick * 0.8f :
572573
TickPatch.serverTimePerTick;
573-
574+
574575
DebugLine[] memoryLines = [
575576
new("World Pawns:", $"{Find.WorldPawns.AllPawnsAliveOrDead.Count}", Color.white),
576577
new("Pool Free Items:", $"{SimplePool<StackTraceLogItemRaw>.FreeItemsCount}", Color.white),
@@ -639,4 +640,4 @@ private static float DrawStatusLine(float x, float y, float width, string label,
639640
return y + LineHeight + 1f; // Small padding between lines
640641
}
641642
}
642-
}
643+
}

0 commit comments

Comments
 (0)