os_test.gd 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. extends Node
  2. @onready var rtl = $HBoxContainer/Features
  3. @onready var csharp_test = $CSharpTest
  4. # Returns a human-readable string from a date and time, date, or time dictionary.
  5. func datetime_to_string(date):
  6. if (
  7. date.has("year")
  8. and date.has("month")
  9. and date.has("day")
  10. and date.has("hour")
  11. and date.has("minute")
  12. and date.has("second")
  13. ):
  14. # Date and time.
  15. return "{year}-{month}-{day} {hour}:{minute}:{second}".format({
  16. year = str(date.year).pad_zeros(2),
  17. month = str(date.month).pad_zeros(2),
  18. day = str(date.day).pad_zeros(2),
  19. hour = str(date.hour).pad_zeros(2),
  20. minute = str(date.minute).pad_zeros(2),
  21. second = str(date.second).pad_zeros(2),
  22. })
  23. elif date.has("year") and date.has("month") and date.has("day"):
  24. # Date only.
  25. return "{year}-{month}-{day}".format({
  26. year = str(date.year).pad_zeros(2),
  27. month = str(date.month).pad_zeros(2),
  28. day = str(date.day).pad_zeros(2),
  29. })
  30. else:
  31. # Time only.
  32. return "{hour}:{minute}:{second}".format({
  33. hour = str(date.hour).pad_zeros(2),
  34. minute = str(date.minute).pad_zeros(2),
  35. second = str(date.second).pad_zeros(2),
  36. })
  37. func scan_midi_devices():
  38. OS.open_midi_inputs()
  39. var devices = ", ".join(OS.get_connected_midi_inputs())
  40. OS.close_midi_inputs()
  41. return devices
  42. func add_header(header):
  43. rtl.append_text("\n[font_size=24][color=#6df]{header}[/color][/font_size]\n\n".format({
  44. header = header,
  45. }))
  46. func add_line(key, value):
  47. rtl.append_text("[color=#adf]{key}:[/color] {value}\n".format({
  48. key = key,
  49. value = value if str(value) != "" else "[color=#fff8](empty)[/color]",
  50. }))
  51. func _ready():
  52. add_header("Audio")
  53. add_line("Mix rate", "%d Hz" % AudioServer.get_mix_rate())
  54. add_line("Output latency", "%f ms" % (AudioServer.get_output_latency() * 1000))
  55. add_line("Output device list", ", ".join(AudioServer.get_output_device_list()))
  56. add_line("Capture device list", ", ".join(AudioServer.get_input_device_list()))
  57. add_header("Date")
  58. add_line("Date and time (local)", Time.get_datetime_string_from_system(false, true))
  59. add_line("Date and time (UTC)", Time.get_datetime_string_from_system(true, true))
  60. add_line("Date (local)", Time.get_date_string_from_system(false))
  61. add_line("Date (UTC)", Time.get_date_string_from_system(true))
  62. add_line("Time (local)", Time.get_time_string_from_system(false))
  63. add_line("Time (UTC)", Time.get_time_string_from_system(true))
  64. add_line("Timezone", Time.get_time_zone_from_system())
  65. add_line("UNIX time", Time.get_unix_time_from_system())
  66. add_header("Display")
  67. add_line("Screen count", DisplayServer.get_screen_count())
  68. add_line("DPI", DisplayServer.screen_get_dpi())
  69. add_line("Scale factor", DisplayServer.screen_get_scale())
  70. add_line("Maximum scale factor", DisplayServer.screen_get_max_scale())
  71. add_line("Startup screen position", DisplayServer.screen_get_position())
  72. add_line("Startup screen size", DisplayServer.screen_get_size())
  73. add_line("Startup screen refresh rate", ("%f Hz" % DisplayServer.screen_get_refresh_rate()) if DisplayServer.screen_get_refresh_rate() > 0.0 else "")
  74. add_line("Usable (safe) area rectangle", DisplayServer.get_display_safe_area())
  75. add_line("Screen orientation", [
  76. "Landscape",
  77. "Portrait",
  78. "Landscape (reverse)",
  79. "Portrait (reverse)",
  80. "Landscape (defined by sensor)",
  81. "Portrait (defined by sensor)",
  82. "Defined by sensor",
  83. ][DisplayServer.screen_get_orientation()])
  84. add_header("Engine")
  85. add_line("Version", Engine.get_version_info()["string"])
  86. add_line("Command-line arguments", str(OS.get_cmdline_args()))
  87. add_line("Is debug build", OS.is_debug_build())
  88. add_line("Executable path", OS.get_executable_path())
  89. add_line("User data directory", OS.get_user_data_dir())
  90. add_line("Filesystem is persistent", OS.is_userfs_persistent())
  91. add_header("Environment")
  92. add_line("Value of `PATH`", OS.get_environment("PATH"))
  93. add_line("Value of `path`", OS.get_environment("path"))
  94. add_header("Hardware")
  95. add_line("Model name", OS.get_model_name())
  96. add_line("Processor name", OS.get_processor_name())
  97. add_line("Processor count", OS.get_processor_count())
  98. add_line("Device unique ID", OS.get_unique_id())
  99. add_header("Input")
  100. add_line("Device has touch screen", DisplayServer.is_touchscreen_available())
  101. var has_virtual_keyboard = DisplayServer.has_feature(DisplayServer.FEATURE_VIRTUAL_KEYBOARD)
  102. add_line("Device has virtual keyboard", has_virtual_keyboard)
  103. if has_virtual_keyboard:
  104. add_line("Virtual keyboard height", DisplayServer.virtual_keyboard_get_height())
  105. add_header("Localization")
  106. add_line("Locale", OS.get_locale())
  107. add_header("Mobile")
  108. add_line("Granted permissions", OS.get_granted_permissions())
  109. add_header(".NET (C#)")
  110. var csharp_enabled = ResourceLoader.exists("res://CSharpTest.cs")
  111. add_line("Mono module enabled", "Yes" if csharp_enabled else "No")
  112. if csharp_enabled:
  113. csharp_test.set_script(load("res://CSharpTest.cs"))
  114. add_line("Operating System", csharp_test.OperatingSystem())
  115. add_line("Platform Type", csharp_test.PlatformType())
  116. add_header("Software")
  117. add_line("OS name", OS.get_name())
  118. add_line("Process ID", OS.get_process_id())
  119. add_line("System dark mode supported", DisplayServer.is_dark_mode_supported())
  120. add_line("System dark mode enabled", DisplayServer.is_dark_mode())
  121. add_line("System accent color", "#%s" % DisplayServer.get_accent_color().to_html())
  122. add_header("System directories")
  123. add_line("Desktop", OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP))
  124. add_line("DCIM", OS.get_system_dir(OS.SYSTEM_DIR_DCIM))
  125. add_line("Documents", OS.get_system_dir(OS.SYSTEM_DIR_DOCUMENTS))
  126. add_line("Downloads", OS.get_system_dir(OS.SYSTEM_DIR_DOWNLOADS))
  127. add_line("Movies", OS.get_system_dir(OS.SYSTEM_DIR_MOVIES))
  128. add_line("Music", OS.get_system_dir(OS.SYSTEM_DIR_MUSIC))
  129. add_line("Pictures", OS.get_system_dir(OS.SYSTEM_DIR_PICTURES))
  130. add_line("Ringtones", OS.get_system_dir(OS.SYSTEM_DIR_RINGTONES))
  131. add_header("Video")
  132. add_line("Adapter name", RenderingServer.get_video_adapter_name())
  133. add_line("Adapter vendor", RenderingServer.get_video_adapter_vendor())
  134. add_line("Adapter type", [
  135. "Other (Unknown)",
  136. "Integrated",
  137. "Discrete",
  138. "Virtual",
  139. "CPU",
  140. ][RenderingServer.get_video_adapter_type()])
  141. add_line("Adapter graphics API version", RenderingServer.get_video_adapter_api_version())
  142. var video_adapter_driver_info = OS.get_video_adapter_driver_info()
  143. if video_adapter_driver_info.size() > 0:
  144. add_line("Adapter driver name", video_adapter_driver_info[0])
  145. if video_adapter_driver_info.size() > 1:
  146. add_line("Adapter driver version", video_adapter_driver_info[1])