Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions Source/Client/UI/DebugPanel/SyncDebugPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ private static float DrawRecorderControls(float x, float y, float width)

float nonPerfInterval = PerformanceRecorder.NonPerfFrameIntervalSetting;
var nonPerfLabelRect = new Rect(x, currentY, width, lineHeight);
Widgets.Label(nonPerfLabelRect, $"Non-performance metric sample interval: {nonPerfInterval}");
currentY += lineHeight + 1;
Widgets.Label(nonPerfLabelRect, ref currentY, $"Non-performance metric sample interval: {nonPerfInterval}");
currentY += 1;

var nonPerfSliderRect = new Rect(x, currentY, width, lineHeight);
nonPerfInterval = Widgets.HorizontalSlider(nonPerfSliderRect, nonPerfInterval, 1f, 300f, roundTo: 0);
Expand Down Expand Up @@ -623,21 +623,25 @@ private static float DrawStatusLine(float x, float y, float width, string label,
float labelWidth = width * LabelColumnWidth;
float valueWidth = width * (1f - LabelColumnWidth);

float height = 0;
// Label with right padding
using (MpStyle.Set(GameFont.Tiny).Set(Color.white).Set(TextAnchor.MiddleLeft))
{
Rect labelRect = new(x, y, labelWidth - 4f, LineHeight);
var labelRect = new Rect(x, y, labelWidth - 4f, LineHeight).FitToTextWithinWidth(label);
Widgets.Label(labelRect, label);
height = labelRect.height;
}

// Value with left padding
using (MpStyle.Set(GameFont.Tiny).Set(valueColor).Set(TextAnchor.MiddleLeft))
{
Rect valueRect = new(x + labelWidth + 4f, y, valueWidth - 4f, LineHeight);
var valueRect =
new Rect(x + labelWidth + 4f, y, valueWidth - 8f, LineHeight).FitToTextWithinWidth(value);
Widgets.Label(valueRect, value);
height = Math.Max(height, valueRect.height);
}

return y + LineHeight + 1f; // Small padding between lines
return y + height;
}
}
}
7 changes: 7 additions & 0 deletions Source/Client/Util/RectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ public static Rect FitToText(this Rect rect, string text)
return rect;
}

public static Rect FitToTextWithinWidth(this Rect rect, string text)
{
var height = Text.CalcHeight(text, rect.width);
rect.height = height;
return rect;
}

public static Rect MarginLeft(this Rect rect, float margin)
{
rect.x += margin;
Expand Down
Loading