StatisticsConsoleCommands.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using UnityEngine;
  5. using KairoEngine.Utilities;
  6. using QFSW.QC;
  7. using QFSW.QC.Utilities;
  8. using KairoEngine.Core;
  9. namespace KairoEngine.Utilities.Statistics
  10. {
  11. public static class StatisticsConsoleCommands
  12. {
  13. private static readonly Pool<StringBuilder> _builderPool = new Pool<StringBuilder>();
  14. [Command("statistics-list", "List of statistics names")]
  15. private static string PrintStatistics()
  16. {
  17. QuantumConsole console = QuantumConsole.Instance;
  18. string result = "";
  19. StringBuilder buffer = _builderPool.GetObject();
  20. Color color = Color.white;
  21. buffer.Clear();
  22. if(console != null)
  23. {
  24. QuantumTheme theme = console.GetTheme();
  25. color = theme ? theme.SuccessColor : Color.white;
  26. }
  27. foreach (var stat in Statistics.instance.db.data)
  28. {
  29. result += stat.title;
  30. switch (stat.category)
  31. {
  32. case StatisticType.integer:
  33. result += " - " + ColorExtensions.ColorText(stat.GetInteger().ToString(), color);
  34. break;
  35. case StatisticType.time:
  36. result += " - " + ColorExtensions.ColorText(KairoEngine.Core.Utilities.TimeToString(stat.GetTime()), color);
  37. break;
  38. default:
  39. break;
  40. }
  41. buffer.AppendLine(result);
  42. result = "";
  43. }
  44. result = buffer.ToString();
  45. _builderPool.Release(buffer);
  46. return result;
  47. }
  48. }
  49. }