53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
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;
|
||
}
|
||
}
|
||
}
|
||
}
|