This repository has been archived on 2026-04-18. You can view files and clone it, but cannot push or open issues or pull requests.
Virtual-Memory-Demo/Assets/Scripts/UI/SimulationDashboardView.cs

53 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using TMPro;
using UnityEngine;
using VMdemo.Simulation;
namespace VMdemo.UI
{
public class SimulationDashboardView : MonoBehaviour
{
[SerializeField] private TMP_Text stateSummaryText;
[SerializeField] private TMP_Text statsText;
[SerializeField] private TMP_Text errorText;
public void ShowNotInitialized()
{
SetText(stateSummaryText, "引擎:未初始化");
SetText(statsText, "统计N/A");
}
public void Render(TranslatorEngine engine)
{
if (engine == null)
{
ShowNotInitialized();
return;
}
SetText(
stateSummaryText,
SimulationUIFormatter.FormatStateSummary(
engine.State,
engine.MachineBits,
engine.VaBits,
engine.PageSizeKB,
engine.PhysicalMemoryMB,
engine.TlbCache.Capacity));
SetText(statsText, SimulationUIFormatter.FormatStats(engine.Stats));
}
public void SetError(string message)
{
SetText(errorText, message);
}
private static void SetText(TMP_Text target, string value)
{
if (target != null)
{
target.text = value;
}
}
}
}