os_test.gd 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. extends Node
  2. onready var rtl = $HBoxContainer/Features
  3. onready var mono_test = $MonoTest
  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 = OS.get_connected_midi_inputs().join(", ")
  40. OS.close_midi_inputs()
  41. return devices
  42. func add_header(header):
  43. rtl.append_bbcode("\n[b][u][color=#6df]{header}[/color][/u][/b]\n".format({
  44. header = header,
  45. }))
  46. func add_line(key, value):
  47. rtl.append_bbcode("[b]{key}:[/b] {value}\n".format({
  48. key = key,
  49. value = value if str(value) != "" else "[color=#8fff](empty)[/color]",
  50. }))
  51. func _ready():
  52. add_header("Audio")
  53. var audio_drivers = PoolStringArray()
  54. for i in OS.get_audio_driver_count():
  55. audio_drivers.push_back(OS.get_audio_driver_name(i))
  56. add_line("Available drivers", audio_drivers.join(", "))
  57. add_header("Date")
  58. add_line("Date and time (local)", datetime_to_string(OS.get_datetime()))
  59. add_line("Date and time (UTC)", datetime_to_string(OS.get_datetime(true)))
  60. add_line("Date (local)", datetime_to_string(OS.get_date()))
  61. add_line("Date (UTC)", datetime_to_string(OS.get_date(true)))
  62. add_line("Time (local)", datetime_to_string(OS.get_time()))
  63. add_line("Time (UTC)", datetime_to_string(OS.get_time(true)))
  64. add_line("Timezone", OS.get_time_zone_info())
  65. add_line("System time (milliseconds)", OS.get_system_time_msecs())
  66. add_line("System time (seconds)", OS.get_system_time_secs())
  67. add_line("UNIX time", OS.get_unix_time())
  68. add_header("Display")
  69. add_line("Screen count", OS.get_screen_count())
  70. add_line("DPI", OS.get_screen_dpi())
  71. add_line("Startup screen position", OS.get_screen_position())
  72. add_line("Startup screen size", OS.get_screen_size())
  73. add_line("Safe area rectangle", OS.get_window_safe_area())
  74. add_line("Screen orientation", [
  75. "Landscape",
  76. "Portrait",
  77. "Landscape (reverse)",
  78. "Portrait (reverse)",
  79. "Landscape (defined by sensor)",
  80. "Portrait (defined by sensor)",
  81. "Defined by sensor",
  82. ][OS.screen_orientation])
  83. add_header("Engine")
  84. add_line("Version", Engine.get_version_info()["string"])
  85. add_line("Command-line arguments", str(OS.get_cmdline_args()))
  86. add_line("Is debug build", OS.is_debug_build())
  87. add_line("Executable path", OS.get_executable_path())
  88. add_line("User data directory", OS.get_user_data_dir())
  89. add_line("Filesystem is persistent", OS.is_userfs_persistent())
  90. add_header("Environment")
  91. add_line("Value of `PATH`", OS.get_environment("PATH"))
  92. add_line("Value of `path`", OS.get_environment("path"))
  93. add_header("Hardware")
  94. add_line("Model name", OS.get_model_name())
  95. add_line("Processor count", OS.get_processor_count())
  96. add_line("Device unique ID", OS.get_unique_id())
  97. add_line("Video adapter name", VisualServer.get_video_adapter_name())
  98. add_line("Video adapter vendor", VisualServer.get_video_adapter_vendor())
  99. add_header("Input")
  100. add_line("Latin keyboard variant", OS.get_latin_keyboard_variant())
  101. add_line("Device has touch screen", OS.has_touchscreen_ui_hint())
  102. add_line("Device has virtual keyboard", OS.has_virtual_keyboard())
  103. add_line("Virtual keyboard height", OS.get_virtual_keyboard_height())
  104. add_header("Localization")
  105. add_line("Locale", OS.get_locale())
  106. add_header("Mobile")
  107. add_line("Granted permissions", OS.get_granted_permissions())
  108. add_header("Mono (C#)")
  109. var mono_enabled = ResourceLoader.exists("res://MonoTest.cs")
  110. add_line("Mono module enabled", "Yes" if mono_enabled else "No")
  111. if mono_enabled:
  112. mono_test.set_script(load("res://MonoTest.cs"))
  113. add_line("Operating System", mono_test.OperatingSystem())
  114. add_line("Platform Type", mono_test.PlatformType())
  115. add_header("Software")
  116. add_line("OS name", OS.get_name())
  117. add_line("Process ID", OS.get_process_id())
  118. add_header("System directories")
  119. add_line("Desktop", OS.get_system_dir(OS.SYSTEM_DIR_DESKTOP))
  120. add_line("DCIM", OS.get_system_dir(OS.SYSTEM_DIR_DCIM))
  121. add_line("Documents", OS.get_system_dir(OS.SYSTEM_DIR_DOCUMENTS))
  122. add_line("Downloads", OS.get_system_dir(OS.SYSTEM_DIR_DOWNLOADS))
  123. add_line("Movies", OS.get_system_dir(OS.SYSTEM_DIR_MOVIES))
  124. add_line("Music", OS.get_system_dir(OS.SYSTEM_DIR_MUSIC))
  125. add_line("Pictures", OS.get_system_dir(OS.SYSTEM_DIR_PICTURES))
  126. add_line("Ringtones", OS.get_system_dir(OS.SYSTEM_DIR_RINGTONES))
  127. add_header("Video")
  128. var video_drivers = PoolStringArray()
  129. for i in OS.get_video_driver_count():
  130. video_drivers.push_back(OS.get_video_driver_name(i))
  131. add_line("Available drivers", video_drivers.join(", "))
  132. add_line("Current driver", OS.get_video_driver_name(OS.get_current_video_driver()))