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;
|
2019-05-28 15:00:34 +00:00
|
|
|
Vector2 m_scrollViewPos = Vector2.zero;
|
2019-05-25 23:40:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
StatsWindow()
|
|
|
|
{
|
|
|
|
// set default parameters
|
|
|
|
|
|
|
|
this.windowName = "Stats";
|
2019-05-28 15:00:34 +00:00
|
|
|
this.useScrollView = false;
|
2019-05-25 23:40:05 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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-28 15:00:34 +00:00
|
|
|
m_scrollViewPos = GUILayout.BeginScrollView(m_scrollViewPos);
|
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();
|
|
|
|
}
|
2019-05-28 15:00:34 +00:00
|
|
|
GUILayout.EndScrollView();
|
2019-05-25 23:40:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|