SanAndreasUnity/Assets/Scripts/UI/StatsWindow.cs

53 lines
1.1 KiB
C#
Raw Normal View History

2019-05-25 23:40:05 +00:00
using System.Collections.Generic;
using UnityEngine;
using SanAndreasUnity.Utilities;
using System.Linq;
namespace SanAndreasUnity.UI
{
public class StatsWindow : PauseMenuWindow
{
int m_tabIndex = 0;
StatsWindow()
{
// set default parameters
this.windowName = "Stats";
this.useScrollView = true;
}
void Start ()
{
this.RegisterButtonInPauseMenu ();
// adjust rect
this.windowRect = Utilities.GUIUtils.GetCenteredRectPerc(new Vector2(0.8f, 0.8f));
}
protected override void OnWindowGUI ()
{
2019-05-26 00:50:38 +00:00
Utilities.Stats.DisplayRect = this.windowRect;
var categories = Utilities.Stats.Categories.ToArray();
2019-05-25 23:40:05 +00:00
m_tabIndex = GUIUtils.TabsControl(m_tabIndex, categories);
if (m_tabIndex >= 0)
{
2019-05-26 00:50:38 +00:00
var stats = Utilities.Stats.Entries.ElementAt(m_tabIndex).Value;
2019-05-25 23:40:05 +00:00
foreach (var stat in stats)
{
if (!string.IsNullOrEmpty(stat.text))
GUILayout.Label(stat.text);
if (stat.onGUI != null)
stat.onGUI();
}
}
}
}
}