Crisp launcher (sizes and fonts scaled in screen pixels instead of a GUI matrix), fps command and display, fewer hitches (staggered scans, shared rigidbody scan, crash-damage mesh reads only after impacts, rarer vehicle fx lookups, cached display prefs)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 20:26:43 +02:00
co-authored by Claude Opus 5.5
parent 0b55d270e5
commit 7d341126e8
13 changed files with 381 additions and 231 deletions
+83 -4
View File
@@ -279,8 +279,84 @@ namespace MSCO
/// <summary>Ping-Anzeige oben rechts (Konsole: "ping"), bleibt gespeichert.</summary>
public bool ShowPing
{
get { return PlayerPrefs.GetInt(PrefShowPing, 0) == 1; }
set { PlayerPrefs.SetInt(PrefShowPing, value ? 1 : 0); }
get
{
if (showPing < 0) showPing = PlayerPrefs.GetInt(PrefShowPing, 0); // einmal lesen, nicht bei jedem Zeichnen
return showPing == 1;
}
set
{
showPing = value ? 1 : 0;
PlayerPrefs.SetInt(PrefShowPing, showPing);
}
}
int showPing = -1, showFps = -1;
// ---------------------------------------------------------------- FPS-Anzeige (Konsole: "fps")
const string PrefShowFps = "MSCO_ShowFps";
float fpsTimer, fpsValue = -1f, frameMsWorst;
int fpsFrames;
float frameMsWorstWindow;
/// <summary>FPS-Anzeige oben rechts, bleibt gespeichert.</summary>
public bool ShowFps
{
get
{
if (showFps < 0) showFps = PlayerPrefs.GetInt(PrefShowFps, 0);
return showFps == 1;
}
set
{
showFps = value ? 1 : 0;
PlayerPrefs.SetInt(PrefShowFps, showFps);
}
}
/// <summary>Bilder pro Sekunde (Mittel über eine halbe Sekunde) und längstes Bild darin (Ruckler).</summary>
public string FpsText
{
get
{
if (fpsValue < 0f) return "measuring...";
return Mathf.RoundToInt(fpsValue) + " FPS (" + (1000f / Mathf.Max(1f, fpsValue)).ToString("0.0") + " ms, worst " +
frameMsWorst.ToString("0") + " ms)";
}
}
void MeasureFps()
{
float dt = Time.unscaledDeltaTime;
fpsFrames++;
fpsTimer += dt;
frameMsWorstWindow = Mathf.Max(frameMsWorstWindow, dt * 1000f);
if (fpsTimer < 0.5f) return;
fpsValue = fpsFrames / fpsTimer;
frameMsWorst = frameMsWorstWindow;
fpsFrames = 0;
fpsTimer = 0f;
frameMsWorstWindow = 0f;
}
GUIStyle fpsStyle;
/// <summary>Oben rechts, links neben dem Ping.</summary>
void DrawFps(float rightEdge)
{
if (!ShowFps) return;
if (fpsStyle == null)
{
fpsStyle = UiTheme.Panel9(new Color(0.06f, 0.06f, 0.07f, 0.85f), 6);
fpsStyle.fontSize = 12;
fpsStyle.fontStyle = FontStyle.Bold;
fpsStyle.alignment = TextAnchor.MiddleCenter;
fpsStyle.padding = new RectOffset(10, 10, 0, 0);
}
// grün ab 50, gelb ab 30, sonst rot
fpsStyle.normal.textColor = fpsValue < 0f ? UiTheme.Muted : fpsValue >= 50f ? UiTheme.Online : fpsValue >= 30f ? UiTheme.Pending : UiTheme.Danger;
var content = new GUIContent(fpsValue < 0f ? "FPS ..." : "FPS " + Mathf.RoundToInt(fpsValue));
float width = fpsStyle.CalcSize(content).x;
GUI.Box(new Rect(rightEdge - width, 8, width, 24), content, fpsStyle);
}
/// <summary>Text für Anzeige und Konsole.</summary>
@@ -311,7 +387,9 @@ namespace MSCO
var content = new GUIContent("PING " + PingText);
float width = pingStyle.CalcSize(content).x;
GUI.Box(new Rect(Screen.width - width - 12, 8, width, 24), content, pingStyle);
pingWidth = width + 8;
}
float pingWidth; // Platz, den die Ping-Anzeige belegt (FPS steht links daneben)
// ---------------------------------------------------------------- Cheats (Admin-Menü)
@@ -871,6 +949,7 @@ namespace MSCO
void Update()
{
MeasureFps();
// Menü-Buttons des Spiels nicht durch unser Fenster hindurch auslösen (z.B. Changelog)
// Solange das Multiplayer-Fenster offen ist, reagiert das Spielmenü (CONTINUE, QUIT ...) gar nicht;
// erst nach MINIMIZE wieder. Über der eingeklappten Leiste ebenfalls nicht (sonst öffnet sich z.B. der Changelog).
@@ -2179,7 +2258,7 @@ namespace MSCO
if (MenuHelper.InMenu)
{
lobby.Draw(this);
DrawPing(); toasts.Draw();
pingWidth = 0f; DrawPing(); DrawFps(Screen.width - 12 - pingWidth); toasts.Draw();
overlays.Draw(this, false);
return;
}
@@ -2196,7 +2275,7 @@ namespace MSCO
}
if (session != null) DrawHud();
DrawPing(); toasts.Draw();
pingWidth = 0f; DrawPing(); DrawFps(Screen.width - 12 - pingWidth); toasts.Draw();
overlays.Draw(this, session != null);
}