StatisticsConsoleCommands.cs 1.7 KB

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