profilerGraph.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. $ProfilerGraph::refreshRate = 32;
  2. // Profiles
  3. new GuiControlProfile (ProfilerGraphProfile)
  4. {
  5. modal = false;
  6. opaque = false;
  7. canKeyFocus = false;
  8. };
  9. new GuiControlProfile (ProfilerGraphKeyContainerProfile)
  10. {
  11. border = true;
  12. opaque = true;
  13. fillColor = "100 100 100 200";
  14. };
  15. new GuiControlProfile (ProfilerGraphGraphFrameRateProfile)
  16. {
  17. border = false;
  18. fontColor = "255 255 255";
  19. };
  20. new GuiControlProfile (ProfilerGraphPolyCountProfile)
  21. {
  22. border = false;
  23. fontColor = "255 0 0";
  24. };
  25. new GuiControlProfile (ProfilerGraphDrawCountProfile)
  26. {
  27. border = false;
  28. fontColor = "0 255 0";
  29. };
  30. new GuiControlProfile (ProfilerGraphRTChangesProfile)
  31. {
  32. border = false;
  33. fontColor = "0 0 255";
  34. };
  35. new GuiControlProfile (ProfilerGraphLatencyProfile)
  36. {
  37. border = false;
  38. fontColor = "0 255 255";
  39. };
  40. new GuiControlProfile (ProfilerGraphPacketLossProfile)
  41. {
  42. border = false;
  43. fontColor = "0 0 0";
  44. };
  45. function toggleProfilerGraph()
  46. {
  47. if(!$ProfilerGraph::isInitialized)
  48. {
  49. ProfilerGraph::updateStats();
  50. $ProfilerGraph::isInitialized = true;
  51. }
  52. if(!Canvas.isMember(ProfilerGraphGui))
  53. {
  54. Canvas.add(ProfilerGraphGui);
  55. }
  56. else
  57. Canvas.remove(ProfilerGraphGui);
  58. }
  59. function ProfilerGraph::updateStats()
  60. {
  61. $ProfilerGraphThread = ProfilerGraph.schedule($ProfilerGraph::refreshRate, "updateStats");
  62. if(!$Stats::netGhostUpdates)
  63. return;
  64. if(isobject(ProfilerGraph))
  65. {
  66. GhostsActive.setText("Frame Rate: " @ $fps::real);
  67. ProfilerGraph.addDatum(1,$fps::real);
  68. GhostUpdates.setText("Poly Count: " @ $GFXDeviceStatistics::polyCount);
  69. ProfilerGraph.addDatum(2,$GFXDeviceStatistics::polyCount);
  70. BitsSent.setText("Draw Calls: " @ $GFXDeviceStatistics::drawCalls);
  71. ProfilerGraph.addDatum(3,$GFXDeviceStatistics::drawCalls);
  72. BitsReceived.setText("Render Target Changes: " @ $GFXDeviceStatistics::renderTargetChanges);
  73. ProfilerGraph.addDatum(4,$GFXDeviceStatistics::renderTargetChanges);
  74. ProfilerGraph.matchScale(2,3);
  75. //Latency.setText("Latency: " @ ServerConnection.getPing());
  76. //ProfilerGraph.addDatum(5,ServerConnection.getPacketLoss());
  77. //PacketLoss.setText("Packet Loss: " @ ServerConnection.getPacketLoss());
  78. }
  79. }
  80. function ProfilerGraph::toggleKey()
  81. {
  82. if(!GhostsActive.visible)
  83. {
  84. GhostsActive.visible = 1;
  85. GhostUpdates.visible = 1;
  86. BitsSent.visible = 1;
  87. BitsReceived.visible = 1;
  88. Latency.visible = 1;
  89. PacketLoss.visible = 1;
  90. }
  91. else
  92. {
  93. GhostsActive.visible = 0;
  94. GhostUpdates.visible = 0;
  95. BitsSent.visible = 0;
  96. BitsReceived.visible = 0;
  97. Latency.visible = 0;
  98. PacketLoss.visible = 0;
  99. }
  100. }