ServerDisplay.gd 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. extends Control
  2. #
  3. @onready var infoLabel : RichTextLabel = $HSections/Info/VBox/ScrollContainer/RichTextLabel
  4. @onready var peersLabel : RichTextLabel = $HSections/Peers/RichTextLabel
  5. var timer : Timer = null
  6. #
  7. func _on_info_update():
  8. infoLabel.clear()
  9. infoLabel.add_text("Time FPS: %.1f\n" % Performance.get_monitor(Performance.TIME_FPS))
  10. infoLabel.add_text("Time Process: %.3f ms\n" % [Performance.get_monitor(Performance.TIME_PROCESS)*1000.0])
  11. infoLabel.add_text("Time Physics Process: %.3f ms\n" % [Performance.get_monitor(Performance.TIME_PHYSICS_PROCESS)*1000.0])
  12. infoLabel.add_text("Time Navigation Process: %.3f ms\n" % Performance.get_monitor(Performance.TIME_NAVIGATION_PROCESS))
  13. infoLabel.add_text("Memory Static: %.3f/%.3f MB\n" % [Performance.get_monitor(Performance.MEMORY_STATIC)/1000000.0, Performance.get_monitor(Performance.MEMORY_STATIC_MAX)/1000000.0])
  14. infoLabel.add_text("Memory Message Buffer: %.3f MB\n" % [Performance.get_monitor(Performance.MEMORY_MESSAGE_BUFFER_MAX)/1000000.0])
  15. infoLabel.add_text("Object Count: %d\n" % int(Performance.get_monitor(Performance.OBJECT_COUNT)))
  16. infoLabel.add_text("Object Resource Count: %d\n" % int(Performance.get_monitor(Performance.OBJECT_RESOURCE_COUNT)))
  17. infoLabel.add_text("Object Node Count: %d\n" % int(Performance.get_monitor(Performance.OBJECT_NODE_COUNT)))
  18. infoLabel.add_text("Object Orphan Node Count: %d\n" % int(Performance.get_monitor(Performance.OBJECT_ORPHAN_NODE_COUNT)))
  19. infoLabel.add_text("Render Total Objects: %d\n" % int(Performance.get_monitor(Performance.RENDER_TOTAL_OBJECTS_IN_FRAME)))
  20. infoLabel.add_text("Render Total Primitives: %d\n" % int(Performance.get_monitor(Performance.RENDER_TOTAL_PRIMITIVES_IN_FRAME)))
  21. infoLabel.add_text("Render Total Draw Calls: %d\n" % int(Performance.get_monitor(Performance.RENDER_TOTAL_DRAW_CALLS_IN_FRAME)))
  22. infoLabel.add_text("Render Video Mem. Used: %.3f MB\n" % [Performance.get_monitor(Performance.RENDER_VIDEO_MEM_USED)/1000000.0])
  23. infoLabel.add_text("Render Texture Mem. Used: %.3f MB\n" % [Performance.get_monitor(Performance.RENDER_TEXTURE_MEM_USED)/1000000.0])
  24. infoLabel.add_text("Render Buffer Mem. Used: %.3f MB\n" % [Performance.get_monitor(Performance.RENDER_BUFFER_MEM_USED)/1000000.0])
  25. infoLabel.add_text("Physics Active Objects: %d\n" % int(Performance.get_monitor(Performance.PHYSICS_2D_ACTIVE_OBJECTS)))
  26. infoLabel.add_text("Physics Collision Pairs: %d\n" % int(Performance.get_monitor(Performance.PHYSICS_2D_COLLISION_PAIRS)))
  27. infoLabel.add_text("Physics Island Count: %d\n" % int(Performance.get_monitor(Performance.PHYSICS_2D_ISLAND_COUNT)))
  28. infoLabel.add_text("Navigation Active Maps: %d\n" % int(Performance.get_monitor(Performance.NAVIGATION_ACTIVE_MAPS)))
  29. infoLabel.add_text("Navigation Region Count: %d\n" % int(Performance.get_monitor(Performance.NAVIGATION_REGION_COUNT)))
  30. infoLabel.add_text("Navigation Agent Count: %d\n" % int(Performance.get_monitor(Performance.NAVIGATION_AGENT_COUNT)))
  31. infoLabel.add_text("Navigation Link Count: %d\n" % int(Performance.get_monitor(Performance.NAVIGATION_LINK_COUNT)))
  32. infoLabel.add_text("Navigation Polygon Count: %d\n" % int(Performance.get_monitor(Performance.NAVIGATION_POLYGON_COUNT)))
  33. infoLabel.add_text("Navigation Edge Count: %d\n" % int(Performance.get_monitor(Performance.NAVIGATION_EDGE_COUNT)))
  34. infoLabel.add_text("Navigation Edge Merge Count: %d\n" % int(Performance.get_monitor(Performance.NAVIGATION_EDGE_MERGE_COUNT)))
  35. infoLabel.add_text("Navigation Edge Connection Count: %d\n" % int(Performance.get_monitor(Performance.NAVIGATION_EDGE_CONNECTION_COUNT)))
  36. infoLabel.add_text("Navigation Edge Free Count: %d\n" % int(Performance.get_monitor(Performance.NAVIGATION_EDGE_FREE_COUNT)))
  37. func _on_peer_connection_update():
  38. peersLabel.text = ""
  39. for rpcID in Peers.peers:
  40. var peer : Peers.Peer = Peers.GetPeer(rpcID)
  41. var player : PlayerAgent = Peers.GetAgent(rpcID)
  42. var playerNickname : String = player.nick if player else "-1"
  43. peersLabel.add_text("RPC: %d\t\tAccount: %d\t\tCharacter: %d\t\tAgent: %s [%d]\t\tMode: %s\n" % [rpcID, peer.accountRID, peer.characterRID, playerNickname, peer.agentRID, "WebSocket" if peer.usingWebSocket else "ENet"])
  44. #
  45. func _ready():
  46. Network.peer_update.connect(_on_peer_connection_update)
  47. Network.online_accounts_update.connect(_on_peer_connection_update)
  48. Network.online_characters_update.connect(_on_peer_connection_update)
  49. Network.online_agents_update.connect(_on_peer_connection_update)
  50. if NetworkCommons.IsLocal:
  51. timer = Timer.new()
  52. timer.set_name("ServerTimer")
  53. add_child(timer)
  54. Callback.StartTimer(timer, 3, _on_info_update)
  55. _on_info_update()