1 /** 2 Operating System functions. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.os; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.traits; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.globalenums; 22 import godot.object; 23 import godot.image; 24 /** 25 Operating System functions. 26 27 OS wraps the most common functionality to communicate with the host operating system, such as the clipboard, video driver, date and time, timers, environment variables, execution of binaries, command line, etc. 28 */ 29 @GodotBaseClass struct OSSingleton 30 { 31 package(godot) enum string _GODOT_internal_name = "_OS"; 32 public: 33 @nogc nothrow: 34 union { /** */ godot_object _godot_object; /** */ GodotObject _GODOT_base; } 35 alias _GODOT_base this; 36 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 37 package(godot) __gshared bool _classBindingInitialized = false; 38 package(godot) static struct GDNativeClassBinding 39 { 40 __gshared: 41 godot_object _singleton; 42 immutable char* _singletonName = "OS"; 43 @GodotName("alert") GodotMethod!(void, String, String) alert; 44 @GodotName("can_draw") GodotMethod!(bool) canDraw; 45 @GodotName("can_use_threads") GodotMethod!(bool) canUseThreads; 46 @GodotName("center_window") GodotMethod!(void) centerWindow; 47 @GodotName("close_midi_inputs") GodotMethod!(void) closeMidiInputs; 48 @GodotName("delay_msec") GodotMethod!(void, long) delayMsec; 49 @GodotName("delay_usec") GodotMethod!(void, long) delayUsec; 50 @GodotName("dump_memory_to_file") GodotMethod!(void, String) dumpMemoryToFile; 51 @GodotName("dump_resources_to_file") GodotMethod!(void, String) dumpResourcesToFile; 52 @GodotName("execute") GodotMethod!(long, String, PoolStringArray, bool, Array, bool) execute; 53 @GodotName("find_scancode_from_string") GodotMethod!(long, String) findScancodeFromString; 54 @GodotName("get_audio_driver_count") GodotMethod!(long) getAudioDriverCount; 55 @GodotName("get_audio_driver_name") GodotMethod!(String, long) getAudioDriverName; 56 @GodotName("get_borderless_window") GodotMethod!(bool) getBorderlessWindow; 57 @GodotName("get_clipboard") GodotMethod!(String) getClipboard; 58 @GodotName("get_cmdline_args") GodotMethod!(PoolStringArray) getCmdlineArgs; 59 @GodotName("get_connected_midi_inputs") GodotMethod!(PoolStringArray) getConnectedMidiInputs; 60 @GodotName("get_current_screen") GodotMethod!(long) getCurrentScreen; 61 @GodotName("get_current_tablet_driver") GodotMethod!(String) getCurrentTabletDriver; 62 @GodotName("get_current_video_driver") GodotMethod!(OS.VideoDriver) getCurrentVideoDriver; 63 @GodotName("get_date") GodotMethod!(Dictionary, bool) getDate; 64 @GodotName("get_datetime") GodotMethod!(Dictionary, bool) getDatetime; 65 @GodotName("get_datetime_from_unix_time") GodotMethod!(Dictionary, long) getDatetimeFromUnixTime; 66 @GodotName("get_dynamic_memory_usage") GodotMethod!(long) getDynamicMemoryUsage; 67 @GodotName("get_environment") GodotMethod!(String, String) getEnvironment; 68 @GodotName("get_executable_path") GodotMethod!(String) getExecutablePath; 69 @GodotName("get_exit_code") GodotMethod!(long) getExitCode; 70 @GodotName("get_granted_permissions") GodotMethod!(PoolStringArray) getGrantedPermissions; 71 @GodotName("get_ime_selection") GodotMethod!(Vector2) getImeSelection; 72 @GodotName("get_ime_text") GodotMethod!(String) getImeText; 73 @GodotName("get_latin_keyboard_variant") GodotMethod!(String) getLatinKeyboardVariant; 74 @GodotName("get_locale") GodotMethod!(String) getLocale; 75 @GodotName("get_low_processor_usage_mode_sleep_usec") GodotMethod!(long) getLowProcessorUsageModeSleepUsec; 76 @GodotName("get_max_window_size") GodotMethod!(Vector2) getMaxWindowSize; 77 @GodotName("get_min_window_size") GodotMethod!(Vector2) getMinWindowSize; 78 @GodotName("get_model_name") GodotMethod!(String) getModelName; 79 @GodotName("get_name") GodotMethod!(String) getName; 80 @GodotName("get_native_handle") GodotMethod!(long, long) getNativeHandle; 81 @GodotName("get_power_percent_left") GodotMethod!(long) getPowerPercentLeft; 82 @GodotName("get_power_seconds_left") GodotMethod!(long) getPowerSecondsLeft; 83 @GodotName("get_power_state") GodotMethod!(OS.PowerState) getPowerState; 84 @GodotName("get_process_id") GodotMethod!(long) getProcessId; 85 @GodotName("get_processor_count") GodotMethod!(long) getProcessorCount; 86 @GodotName("get_real_window_size") GodotMethod!(Vector2) getRealWindowSize; 87 @GodotName("get_scancode_string") GodotMethod!(String, long) getScancodeString; 88 @GodotName("get_screen_count") GodotMethod!(long) getScreenCount; 89 @GodotName("get_screen_dpi") GodotMethod!(long, long) getScreenDpi; 90 @GodotName("get_screen_max_scale") GodotMethod!(double) getScreenMaxScale; 91 @GodotName("get_screen_orientation") GodotMethod!(OS.ScreenOrientation) getScreenOrientation; 92 @GodotName("get_screen_position") GodotMethod!(Vector2, long) getScreenPosition; 93 @GodotName("get_screen_scale") GodotMethod!(double, long) getScreenScale; 94 @GodotName("get_screen_size") GodotMethod!(Vector2, long) getScreenSize; 95 @GodotName("get_splash_tick_msec") GodotMethod!(long) getSplashTickMsec; 96 @GodotName("get_static_memory_peak_usage") GodotMethod!(long) getStaticMemoryPeakUsage; 97 @GodotName("get_static_memory_usage") GodotMethod!(long) getStaticMemoryUsage; 98 @GodotName("get_system_dir") GodotMethod!(String, long) getSystemDir; 99 @GodotName("get_system_time_msecs") GodotMethod!(long) getSystemTimeMsecs; 100 @GodotName("get_system_time_secs") GodotMethod!(long) getSystemTimeSecs; 101 @GodotName("get_tablet_driver_count") GodotMethod!(long) getTabletDriverCount; 102 @GodotName("get_tablet_driver_name") GodotMethod!(String, long) getTabletDriverName; 103 @GodotName("get_thread_caller_id") GodotMethod!(long) getThreadCallerId; 104 @GodotName("get_ticks_msec") GodotMethod!(long) getTicksMsec; 105 @GodotName("get_ticks_usec") GodotMethod!(long) getTicksUsec; 106 @GodotName("get_time") GodotMethod!(Dictionary, bool) getTime; 107 @GodotName("get_time_zone_info") GodotMethod!(Dictionary) getTimeZoneInfo; 108 @GodotName("get_unique_id") GodotMethod!(String) getUniqueId; 109 @GodotName("get_unix_time") GodotMethod!(long) getUnixTime; 110 @GodotName("get_unix_time_from_datetime") GodotMethod!(long, Dictionary) getUnixTimeFromDatetime; 111 @GodotName("get_user_data_dir") GodotMethod!(String) getUserDataDir; 112 @GodotName("get_video_driver_count") GodotMethod!(long) getVideoDriverCount; 113 @GodotName("get_video_driver_name") GodotMethod!(String, long) getVideoDriverName; 114 @GodotName("get_virtual_keyboard_height") GodotMethod!(long) getVirtualKeyboardHeight; 115 @GodotName("get_window_per_pixel_transparency_enabled") GodotMethod!(bool) getWindowPerPixelTransparencyEnabled; 116 @GodotName("get_window_position") GodotMethod!(Vector2) getWindowPosition; 117 @GodotName("get_window_safe_area") GodotMethod!(Rect2) getWindowSafeArea; 118 @GodotName("get_window_size") GodotMethod!(Vector2) getWindowSize; 119 @GodotName("global_menu_add_item") GodotMethod!(void, String, String, Variant, Variant) globalMenuAddItem; 120 @GodotName("global_menu_add_separator") GodotMethod!(void, String) globalMenuAddSeparator; 121 @GodotName("global_menu_clear") GodotMethod!(void, String) globalMenuClear; 122 @GodotName("global_menu_remove_item") GodotMethod!(void, String, long) globalMenuRemoveItem; 123 @GodotName("has_environment") GodotMethod!(bool, String) hasEnvironment; 124 @GodotName("has_feature") GodotMethod!(bool, String) hasFeature; 125 @GodotName("has_touchscreen_ui_hint") GodotMethod!(bool) hasTouchscreenUiHint; 126 @GodotName("has_virtual_keyboard") GodotMethod!(bool) hasVirtualKeyboard; 127 @GodotName("hide_virtual_keyboard") GodotMethod!(void) hideVirtualKeyboard; 128 @GodotName("is_debug_build") GodotMethod!(bool) isDebugBuild; 129 @GodotName("is_in_low_processor_usage_mode") GodotMethod!(bool) isInLowProcessorUsageMode; 130 @GodotName("is_keep_screen_on") GodotMethod!(bool) isKeepScreenOn; 131 @GodotName("is_ok_left_and_cancel_right") GodotMethod!(bool) isOkLeftAndCancelRight; 132 @GodotName("is_scancode_unicode") GodotMethod!(bool, long) isScancodeUnicode; 133 @GodotName("is_stdout_verbose") GodotMethod!(bool) isStdoutVerbose; 134 @GodotName("is_userfs_persistent") GodotMethod!(bool) isUserfsPersistent; 135 @GodotName("is_vsync_enabled") GodotMethod!(bool) isVsyncEnabled; 136 @GodotName("is_vsync_via_compositor_enabled") GodotMethod!(bool) isVsyncViaCompositorEnabled; 137 @GodotName("is_window_always_on_top") GodotMethod!(bool) isWindowAlwaysOnTop; 138 @GodotName("is_window_focused") GodotMethod!(bool) isWindowFocused; 139 @GodotName("is_window_fullscreen") GodotMethod!(bool) isWindowFullscreen; 140 @GodotName("is_window_maximized") GodotMethod!(bool) isWindowMaximized; 141 @GodotName("is_window_minimized") GodotMethod!(bool) isWindowMinimized; 142 @GodotName("is_window_resizable") GodotMethod!(bool) isWindowResizable; 143 @GodotName("keyboard_get_current_layout") GodotMethod!(long) keyboardGetCurrentLayout; 144 @GodotName("keyboard_get_layout_count") GodotMethod!(long) keyboardGetLayoutCount; 145 @GodotName("keyboard_get_layout_language") GodotMethod!(String, long) keyboardGetLayoutLanguage; 146 @GodotName("keyboard_get_layout_name") GodotMethod!(String, long) keyboardGetLayoutName; 147 @GodotName("keyboard_set_current_layout") GodotMethod!(void, long) keyboardSetCurrentLayout; 148 @GodotName("kill") GodotMethod!(GodotError, long) kill; 149 @GodotName("move_window_to_foreground") GodotMethod!(void) moveWindowToForeground; 150 @GodotName("native_video_is_playing") GodotMethod!(bool) nativeVideoIsPlaying; 151 @GodotName("native_video_pause") GodotMethod!(void) nativeVideoPause; 152 @GodotName("native_video_play") GodotMethod!(GodotError, String, double, String, String) nativeVideoPlay; 153 @GodotName("native_video_stop") GodotMethod!(void) nativeVideoStop; 154 @GodotName("native_video_unpause") GodotMethod!(void) nativeVideoUnpause; 155 @GodotName("open_midi_inputs") GodotMethod!(void) openMidiInputs; 156 @GodotName("print_all_resources") GodotMethod!(void, String) printAllResources; 157 @GodotName("print_all_textures_by_size") GodotMethod!(void) printAllTexturesBySize; 158 @GodotName("print_resources_by_type") GodotMethod!(void, PoolStringArray) printResourcesByType; 159 @GodotName("print_resources_in_use") GodotMethod!(void, bool) printResourcesInUse; 160 @GodotName("request_attention") GodotMethod!(void) requestAttention; 161 @GodotName("request_permission") GodotMethod!(bool, String) requestPermission; 162 @GodotName("request_permissions") GodotMethod!(bool) requestPermissions; 163 @GodotName("set_borderless_window") GodotMethod!(void, bool) setBorderlessWindow; 164 @GodotName("set_clipboard") GodotMethod!(void, String) setClipboard; 165 @GodotName("set_current_screen") GodotMethod!(void, long) setCurrentScreen; 166 @GodotName("set_current_tablet_driver") GodotMethod!(void, String) setCurrentTabletDriver; 167 @GodotName("set_environment") GodotMethod!(bool, String, String) setEnvironment; 168 @GodotName("set_exit_code") GodotMethod!(void, long) setExitCode; 169 @GodotName("set_icon") GodotMethod!(void, Image) setIcon; 170 @GodotName("set_ime_active") GodotMethod!(void, bool) setImeActive; 171 @GodotName("set_ime_position") GodotMethod!(void, Vector2) setImePosition; 172 @GodotName("set_keep_screen_on") GodotMethod!(void, bool) setKeepScreenOn; 173 @GodotName("set_low_processor_usage_mode") GodotMethod!(void, bool) setLowProcessorUsageMode; 174 @GodotName("set_low_processor_usage_mode_sleep_usec") GodotMethod!(void, long) setLowProcessorUsageModeSleepUsec; 175 @GodotName("set_max_window_size") GodotMethod!(void, Vector2) setMaxWindowSize; 176 @GodotName("set_min_window_size") GodotMethod!(void, Vector2) setMinWindowSize; 177 @GodotName("set_native_icon") GodotMethod!(void, String) setNativeIcon; 178 @GodotName("set_screen_orientation") GodotMethod!(void, long) setScreenOrientation; 179 @GodotName("set_thread_name") GodotMethod!(GodotError, String) setThreadName; 180 @GodotName("set_use_file_access_save_and_swap") GodotMethod!(void, bool) setUseFileAccessSaveAndSwap; 181 @GodotName("set_use_vsync") GodotMethod!(void, bool) setUseVsync; 182 @GodotName("set_vsync_via_compositor") GodotMethod!(void, bool) setVsyncViaCompositor; 183 @GodotName("set_window_always_on_top") GodotMethod!(void, bool) setWindowAlwaysOnTop; 184 @GodotName("set_window_fullscreen") GodotMethod!(void, bool) setWindowFullscreen; 185 @GodotName("set_window_maximized") GodotMethod!(void, bool) setWindowMaximized; 186 @GodotName("set_window_minimized") GodotMethod!(void, bool) setWindowMinimized; 187 @GodotName("set_window_mouse_passthrough") GodotMethod!(void, PoolVector2Array) setWindowMousePassthrough; 188 @GodotName("set_window_per_pixel_transparency_enabled") GodotMethod!(void, bool) setWindowPerPixelTransparencyEnabled; 189 @GodotName("set_window_position") GodotMethod!(void, Vector2) setWindowPosition; 190 @GodotName("set_window_resizable") GodotMethod!(void, bool) setWindowResizable; 191 @GodotName("set_window_size") GodotMethod!(void, Vector2) setWindowSize; 192 @GodotName("set_window_title") GodotMethod!(void, String) setWindowTitle; 193 @GodotName("shell_open") GodotMethod!(GodotError, String) shellOpen; 194 @GodotName("show_virtual_keyboard") GodotMethod!(void, String, bool) showVirtualKeyboard; 195 } 196 /// 197 pragma(inline, true) bool opEquals(in OSSingleton other) const 198 { return _godot_object.ptr is other._godot_object.ptr; } 199 /// 200 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 201 { _godot_object.ptr = n; return null; } 202 /// 203 pragma(inline, true) bool opEquals(typeof(null) n) const 204 { return _godot_object.ptr is n; } 205 /// 206 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 207 mixin baseCasts; 208 /// Construct a new instance of OSSingleton. 209 /// Note: use `memnew!OSSingleton` instead. 210 static OSSingleton _new() 211 { 212 static godot_class_constructor constructor; 213 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("_OS"); 214 if(constructor is null) return typeof(this).init; 215 return cast(OSSingleton)(constructor()); 216 } 217 @disable new(size_t s); 218 /// 219 enum VideoDriver : int 220 { 221 /** 222 The GLES3 rendering backend. It uses OpenGL ES 3.0 on mobile devices, OpenGL 3.3 on desktop platforms and WebGL 2.0 on the web. 223 */ 224 videoDriverGles3 = 0, 225 /** 226 The GLES2 rendering backend. It uses OpenGL ES 2.0 on mobile devices, OpenGL 2.1 on desktop platforms and WebGL 1.0 on the web. 227 */ 228 videoDriverGles2 = 1, 229 } 230 /// 231 enum SystemDir : int 232 { 233 /** 234 Desktop directory path. 235 */ 236 systemDirDesktop = 0, 237 /** 238 DCIM (Digital Camera Images) directory path. 239 */ 240 systemDirDcim = 1, 241 /** 242 Documents directory path. 243 */ 244 systemDirDocuments = 2, 245 /** 246 Downloads directory path. 247 */ 248 systemDirDownloads = 3, 249 /** 250 Movies directory path. 251 */ 252 systemDirMovies = 4, 253 /** 254 Music directory path. 255 */ 256 systemDirMusic = 5, 257 /** 258 Pictures directory path. 259 */ 260 systemDirPictures = 6, 261 /** 262 Ringtones directory path. 263 */ 264 systemDirRingtones = 7, 265 } 266 /// 267 enum ScreenOrientation : int 268 { 269 /** 270 Landscape screen orientation. 271 */ 272 screenOrientationLandscape = 0, 273 /** 274 Portrait screen orientation. 275 */ 276 screenOrientationPortrait = 1, 277 /** 278 Reverse landscape screen orientation. 279 */ 280 screenOrientationReverseLandscape = 2, 281 /** 282 Reverse portrait screen orientation. 283 */ 284 screenOrientationReversePortrait = 3, 285 /** 286 Uses landscape or reverse landscape based on the hardware sensor. 287 */ 288 screenOrientationSensorLandscape = 4, 289 /** 290 Uses portrait or reverse portrait based on the hardware sensor. 291 */ 292 screenOrientationSensorPortrait = 5, 293 /** 294 Uses most suitable orientation based on the hardware sensor. 295 */ 296 screenOrientationSensor = 6, 297 } 298 /// 299 enum PowerState : int 300 { 301 /** 302 Unknown powerstate. 303 */ 304 powerstateUnknown = 0, 305 /** 306 Unplugged, running on battery. 307 */ 308 powerstateOnBattery = 1, 309 /** 310 Plugged in, no battery available. 311 */ 312 powerstateNoBattery = 2, 313 /** 314 Plugged in, battery charging. 315 */ 316 powerstateCharging = 3, 317 /** 318 Plugged in, battery fully charged. 319 */ 320 powerstateCharged = 4, 321 } 322 /// 323 enum HandleType : int 324 { 325 /** 326 Application handle: 327 - Windows: `HINSTANCE` of the application 328 - MacOS: `NSApplication*` of the application (not yet implemented) 329 - Android: `JNIEnv*` of the application (not yet implemented) 330 */ 331 applicationHandle = 0, 332 /** 333 Display handle: 334 - Linux: `X11::Display*` for the display 335 */ 336 displayHandle = 1, 337 /** 338 Window handle: 339 - Windows: `HWND` of the main window 340 - Linux: `X11::Window*` of the main window 341 - MacOS: `NSWindow*` of the main window (not yet implemented) 342 - Android: `jObject` the main android activity (not yet implemented) 343 */ 344 windowHandle = 2, 345 /** 346 Window view: 347 - Windows: `HDC` of the main window drawing context 348 - MacOS: `NSView*` of the main windows view (not yet implemented) 349 */ 350 windowView = 3, 351 /** 352 OpenGL Context: 353 - Windows: `HGLRC` 354 - Linux: `X11::GLXContext` 355 - MacOS: `NSOpenGLContext*` (not yet implemented) 356 */ 357 openglContext = 4, 358 } 359 /// 360 enum Month : int 361 { 362 /** 363 January. 364 */ 365 monthJanuary = 1, 366 /** 367 February. 368 */ 369 monthFebruary = 2, 370 /** 371 March. 372 */ 373 monthMarch = 3, 374 /** 375 April. 376 */ 377 monthApril = 4, 378 /** 379 May. 380 */ 381 monthMay = 5, 382 /** 383 June. 384 */ 385 monthJune = 6, 386 /** 387 July. 388 */ 389 monthJuly = 7, 390 /** 391 August. 392 */ 393 monthAugust = 8, 394 /** 395 September. 396 */ 397 monthSeptember = 9, 398 /** 399 October. 400 */ 401 monthOctober = 10, 402 /** 403 November. 404 */ 405 monthNovember = 11, 406 /** 407 December. 408 */ 409 monthDecember = 12, 410 } 411 /// 412 enum Weekday : int 413 { 414 /** 415 Sunday. 416 */ 417 daySunday = 0, 418 /** 419 Monday. 420 */ 421 dayMonday = 1, 422 /** 423 Tuesday. 424 */ 425 dayTuesday = 2, 426 /** 427 Wednesday. 428 */ 429 dayWednesday = 3, 430 /** 431 Thursday. 432 */ 433 dayThursday = 4, 434 /** 435 Friday. 436 */ 437 dayFriday = 5, 438 /** 439 Saturday. 440 */ 441 daySaturday = 6, 442 } 443 /// 444 enum Constants : int 445 { 446 videoDriverGles3 = 0, 447 powerstateUnknown = 0, 448 screenOrientationLandscape = 0, 449 systemDirDesktop = 0, 450 applicationHandle = 0, 451 daySunday = 0, 452 screenOrientationPortrait = 1, 453 videoDriverGles2 = 1, 454 systemDirDcim = 1, 455 monthJanuary = 1, 456 dayMonday = 1, 457 powerstateOnBattery = 1, 458 displayHandle = 1, 459 powerstateNoBattery = 2, 460 monthFebruary = 2, 461 windowHandle = 2, 462 dayTuesday = 2, 463 screenOrientationReverseLandscape = 2, 464 systemDirDocuments = 2, 465 windowView = 3, 466 screenOrientationReversePortrait = 3, 467 monthMarch = 3, 468 powerstateCharging = 3, 469 systemDirDownloads = 3, 470 dayWednesday = 3, 471 screenOrientationSensorLandscape = 4, 472 openglContext = 4, 473 powerstateCharged = 4, 474 dayThursday = 4, 475 systemDirMovies = 4, 476 monthApril = 4, 477 dayFriday = 5, 478 systemDirMusic = 5, 479 screenOrientationSensorPortrait = 5, 480 monthMay = 5, 481 screenOrientationSensor = 6, 482 daySaturday = 6, 483 monthJune = 6, 484 systemDirPictures = 6, 485 monthJuly = 7, 486 systemDirRingtones = 7, 487 monthAugust = 8, 488 monthSeptember = 9, 489 monthOctober = 10, 490 monthNovember = 11, 491 monthDecember = 12, 492 } 493 /** 494 Displays a modal dialog box using the host OS' facilities. Execution is blocked until the dialog is closed. 495 */ 496 void alert(in String text, in String title = gs!"Alert!") 497 { 498 checkClassBinding!(typeof(this))(); 499 ptrcall!(void)(GDNativeClassBinding.alert, _godot_object, text, title); 500 } 501 /** 502 Returns `true` if the host OS allows drawing. 503 */ 504 bool canDraw() const 505 { 506 checkClassBinding!(typeof(this))(); 507 return ptrcall!(bool)(GDNativeClassBinding.canDraw, _godot_object); 508 } 509 /** 510 Returns `true` if the current host platform is using multiple threads. 511 */ 512 bool canUseThreads() const 513 { 514 checkClassBinding!(typeof(this))(); 515 return ptrcall!(bool)(GDNativeClassBinding.canUseThreads, _godot_object); 516 } 517 /** 518 Centers the window on the screen if in windowed mode. 519 */ 520 void centerWindow() 521 { 522 checkClassBinding!(typeof(this))(); 523 ptrcall!(void)(GDNativeClassBinding.centerWindow, _godot_object); 524 } 525 /** 526 Shuts down system MIDI driver. 527 $(B Note:) This method is implemented on Linux, macOS and Windows. 528 */ 529 void closeMidiInputs() 530 { 531 checkClassBinding!(typeof(this))(); 532 ptrcall!(void)(GDNativeClassBinding.closeMidiInputs, _godot_object); 533 } 534 /** 535 Delay execution of the current thread by `msec` milliseconds. `msec` must be greater than or equal to `0`. Otherwise, $(D delayMsec) will do nothing and will print an error message. 536 */ 537 void delayMsec(in long msec) const 538 { 539 checkClassBinding!(typeof(this))(); 540 ptrcall!(void)(GDNativeClassBinding.delayMsec, _godot_object, msec); 541 } 542 /** 543 Delay execution of the current thread by `usec` microseconds. `usec` must be greater than or equal to `0`. Otherwise, $(D delayUsec) will do nothing and will print an error message. 544 */ 545 void delayUsec(in long usec) const 546 { 547 checkClassBinding!(typeof(this))(); 548 ptrcall!(void)(GDNativeClassBinding.delayUsec, _godot_object, usec); 549 } 550 /** 551 Dumps the memory allocation ringlist to a file (only works in debug). 552 Entry format per line: "Address - Size - Description". 553 */ 554 void dumpMemoryToFile(in String file) 555 { 556 checkClassBinding!(typeof(this))(); 557 ptrcall!(void)(GDNativeClassBinding.dumpMemoryToFile, _godot_object, file); 558 } 559 /** 560 Dumps all used resources to file (only works in debug). 561 Entry format per line: "Resource Type : Resource Location". 562 At the end of the file is a statistic of all used Resource Types. 563 */ 564 void dumpResourcesToFile(in String file) 565 { 566 checkClassBinding!(typeof(this))(); 567 ptrcall!(void)(GDNativeClassBinding.dumpResourcesToFile, _godot_object, file); 568 } 569 /** 570 Execute the file at the given path with the arguments passed as an array of strings. Platform path resolution will take place. The resolved file must exist and be executable. 571 The arguments are used in the given order and separated by a space, so `OS.execute("ping", $(D "-w", "3", "godotengine.org"), false)` will resolve to `ping -w 3 godotengine.org` in the system's shell. 572 This method has slightly different behavior based on whether the `blocking` mode is enabled. 573 If `blocking` is `true`, the Godot thread will pause its execution while waiting for the process to terminate. The shell output of the process will be written to the `output` array as a single string. When the process terminates, the Godot thread will resume execution. 574 If `blocking` is `false`, the Godot thread will continue while the new process runs. It is not possible to retrieve the shell output in non-blocking mode, so `output` will be empty. 575 The return value also depends on the blocking mode. When blocking, the method will return an exit code of the process. When non-blocking, the method returns a process ID, which you can use to monitor the process (and potentially terminate it with $(D kill)). If the process forking (non-blocking) or opening (blocking) fails, the method will return `-1` or another exit code. 576 Example of blocking mode and retrieving the shell output: 577 578 579 var output = [] 580 var exit_code = OS.execute("ls", $(D "-l", "/tmp"), true, output) 581 582 583 Example of non-blocking mode, running another instance of the project and storing its process ID: 584 585 586 var pid = OS.execute(OS.get_executable_path(), [], false) 587 588 589 If you wish to access a shell built-in or perform a composite command, a platform-specific shell can be invoked. For example: 590 591 592 OS.execute("CMD.exe", $(D "/C", "cd %TEMP% && dir"), true, output) 593 594 595 $(B Note:) This method is implemented on Android, iOS, Linux, macOS and Windows. 596 */ 597 long execute(in String path, in PoolStringArray arguments, in bool blocking = true, in Array output = Array.make(), in bool read_stderr = false) 598 { 599 checkClassBinding!(typeof(this))(); 600 return ptrcall!(long)(GDNativeClassBinding.execute, _godot_object, path, arguments, blocking, output, read_stderr); 601 } 602 /** 603 Returns the scancode of the given string (e.g. "Escape"). 604 */ 605 long findScancodeFromString(in String string) const 606 { 607 checkClassBinding!(typeof(this))(); 608 return ptrcall!(long)(GDNativeClassBinding.findScancodeFromString, _godot_object, string); 609 } 610 /** 611 Returns the total number of available audio drivers. 612 */ 613 long getAudioDriverCount() const 614 { 615 checkClassBinding!(typeof(this))(); 616 return ptrcall!(long)(GDNativeClassBinding.getAudioDriverCount, _godot_object); 617 } 618 /** 619 Returns the audio driver name for the given index. 620 */ 621 String getAudioDriverName(in long driver) const 622 { 623 checkClassBinding!(typeof(this))(); 624 return ptrcall!(String)(GDNativeClassBinding.getAudioDriverName, _godot_object, driver); 625 } 626 /** 627 628 */ 629 bool getBorderlessWindow() const 630 { 631 checkClassBinding!(typeof(this))(); 632 return ptrcall!(bool)(GDNativeClassBinding.getBorderlessWindow, _godot_object); 633 } 634 /** 635 636 */ 637 String getClipboard() const 638 { 639 checkClassBinding!(typeof(this))(); 640 return ptrcall!(String)(GDNativeClassBinding.getClipboard, _godot_object); 641 } 642 /** 643 Returns the command-line arguments passed to the engine. 644 Command-line arguments can be written in any form, including both `--key value` and `--key=value` forms so they can be properly parsed, as long as custom command-line arguments do not conflict with engine arguments. 645 You can also incorporate environment variables using the $(D getEnvironment) method. 646 You can set `editor/main_run_args` in the Project Settings to define command-line arguments to be passed by the editor when running the project. 647 Here's a minimal example on how to parse command-line arguments into a dictionary using the `--key=value` form for arguments: 648 649 650 var arguments = {} 651 for argument in OS.get_cmdline_args(): 652 if argument.find("=") > -1: 653 var key_value = argument.split("=") 654 arguments$(D key_value[0).lstrip("--")] = key_value$(D 1) 655 656 657 */ 658 PoolStringArray getCmdlineArgs() 659 { 660 checkClassBinding!(typeof(this))(); 661 return ptrcall!(PoolStringArray)(GDNativeClassBinding.getCmdlineArgs, _godot_object); 662 } 663 /** 664 Returns an array of MIDI device names. 665 The returned array will be empty if the system MIDI driver has not previously been initialised with $(D openMidiInputs). 666 $(B Note:) This method is implemented on Linux, macOS and Windows. 667 */ 668 PoolStringArray getConnectedMidiInputs() 669 { 670 checkClassBinding!(typeof(this))(); 671 return ptrcall!(PoolStringArray)(GDNativeClassBinding.getConnectedMidiInputs, _godot_object); 672 } 673 /** 674 675 */ 676 long getCurrentScreen() const 677 { 678 checkClassBinding!(typeof(this))(); 679 return ptrcall!(long)(GDNativeClassBinding.getCurrentScreen, _godot_object); 680 } 681 /** 682 683 */ 684 String getCurrentTabletDriver() const 685 { 686 checkClassBinding!(typeof(this))(); 687 return ptrcall!(String)(GDNativeClassBinding.getCurrentTabletDriver, _godot_object); 688 } 689 /** 690 Returns the currently used video driver, using one of the values from $(D videodriver). 691 */ 692 OS.VideoDriver getCurrentVideoDriver() const 693 { 694 checkClassBinding!(typeof(this))(); 695 return ptrcall!(OS.VideoDriver)(GDNativeClassBinding.getCurrentVideoDriver, _godot_object); 696 } 697 /** 698 Returns current date as a dictionary of keys: `year`, `month`, `day`, `weekday`, `dst` (Daylight Savings Time). 699 */ 700 Dictionary getDate(in bool utc = false) const 701 { 702 checkClassBinding!(typeof(this))(); 703 return ptrcall!(Dictionary)(GDNativeClassBinding.getDate, _godot_object, utc); 704 } 705 /** 706 Returns current datetime as a dictionary of keys: `year`, `month`, `day`, `weekday`, `dst` (Daylight Savings Time), `hour`, `minute`, `second`. 707 */ 708 Dictionary getDatetime(in bool utc = false) const 709 { 710 checkClassBinding!(typeof(this))(); 711 return ptrcall!(Dictionary)(GDNativeClassBinding.getDatetime, _godot_object, utc); 712 } 713 /** 714 Gets a dictionary of time values corresponding to the given UNIX epoch time (in seconds). 715 The returned Dictionary's values will be the same as $(D getDatetime), with the exception of Daylight Savings Time as it cannot be determined from the epoch. 716 */ 717 Dictionary getDatetimeFromUnixTime(in long unix_time_val) const 718 { 719 checkClassBinding!(typeof(this))(); 720 return ptrcall!(Dictionary)(GDNativeClassBinding.getDatetimeFromUnixTime, _godot_object, unix_time_val); 721 } 722 /** 723 Returns the total amount of dynamic memory used (only works in debug). 724 */ 725 long getDynamicMemoryUsage() const 726 { 727 checkClassBinding!(typeof(this))(); 728 return ptrcall!(long)(GDNativeClassBinding.getDynamicMemoryUsage, _godot_object); 729 } 730 /** 731 Returns the value of an environment variable. Returns an empty string if the environment variable doesn't exist. 732 $(B Note:) Double-check the casing of `variable`. Environment variable names are case-sensitive on all platforms except Windows. 733 */ 734 String getEnvironment(in String variable) const 735 { 736 checkClassBinding!(typeof(this))(); 737 return ptrcall!(String)(GDNativeClassBinding.getEnvironment, _godot_object, variable); 738 } 739 /** 740 Returns the path to the current engine executable. 741 */ 742 String getExecutablePath() const 743 { 744 checkClassBinding!(typeof(this))(); 745 return ptrcall!(String)(GDNativeClassBinding.getExecutablePath, _godot_object); 746 } 747 /** 748 749 */ 750 long getExitCode() const 751 { 752 checkClassBinding!(typeof(this))(); 753 return ptrcall!(long)(GDNativeClassBinding.getExitCode, _godot_object); 754 } 755 /** 756 With this function, you can get the list of dangerous permissions that have been granted to the Android application. 757 $(B Note:) This method is implemented on Android. 758 */ 759 PoolStringArray getGrantedPermissions() const 760 { 761 checkClassBinding!(typeof(this))(); 762 return ptrcall!(PoolStringArray)(GDNativeClassBinding.getGrantedPermissions, _godot_object); 763 } 764 /** 765 Returns the IME cursor position (the currently-edited portion of the string) relative to the characters in the composition string. 766 $(D constant MainLoop.NOTIFICATION_OS_IME_UPDATE) is sent to the application to notify it of changes to the IME cursor position. 767 $(B Note:) This method is implemented on macOS. 768 */ 769 Vector2 getImeSelection() const 770 { 771 checkClassBinding!(typeof(this))(); 772 return ptrcall!(Vector2)(GDNativeClassBinding.getImeSelection, _godot_object); 773 } 774 /** 775 Returns the IME intermediate composition string. 776 $(D constant MainLoop.NOTIFICATION_OS_IME_UPDATE) is sent to the application to notify it of changes to the IME composition string. 777 $(B Note:) This method is implemented on macOS. 778 */ 779 String getImeText() const 780 { 781 checkClassBinding!(typeof(this))(); 782 return ptrcall!(String)(GDNativeClassBinding.getImeText, _godot_object); 783 } 784 /** 785 Returns the current latin keyboard variant as a String. 786 Possible return values are: `"QWERTY"`, `"AZERTY"`, `"QZERTY"`, `"DVORAK"`, `"NEO"`, `"COLEMAK"` or `"ERROR"`. 787 $(B Note:) This method is implemented on Linux, macOS and Windows. Returns `"QWERTY"` on unsupported platforms. 788 */ 789 String getLatinKeyboardVariant() const 790 { 791 checkClassBinding!(typeof(this))(); 792 return ptrcall!(String)(GDNativeClassBinding.getLatinKeyboardVariant, _godot_object); 793 } 794 /** 795 Returns the host OS locale. 796 */ 797 String getLocale() const 798 { 799 checkClassBinding!(typeof(this))(); 800 return ptrcall!(String)(GDNativeClassBinding.getLocale, _godot_object); 801 } 802 /** 803 804 */ 805 long getLowProcessorUsageModeSleepUsec() const 806 { 807 checkClassBinding!(typeof(this))(); 808 return ptrcall!(long)(GDNativeClassBinding.getLowProcessorUsageModeSleepUsec, _godot_object); 809 } 810 /** 811 812 */ 813 Vector2 getMaxWindowSize() const 814 { 815 checkClassBinding!(typeof(this))(); 816 return ptrcall!(Vector2)(GDNativeClassBinding.getMaxWindowSize, _godot_object); 817 } 818 /** 819 820 */ 821 Vector2 getMinWindowSize() const 822 { 823 checkClassBinding!(typeof(this))(); 824 return ptrcall!(Vector2)(GDNativeClassBinding.getMinWindowSize, _godot_object); 825 } 826 /** 827 Returns the model name of the current device. 828 $(B Note:) This method is implemented on Android and iOS. Returns `"GenericDevice"` on unsupported platforms. 829 */ 830 String getModelName() const 831 { 832 checkClassBinding!(typeof(this))(); 833 return ptrcall!(String)(GDNativeClassBinding.getModelName, _godot_object); 834 } 835 /** 836 Returns the name of the host OS. Possible values are: `"Android"`, `"iOS"`, `"HTML5"`, `"OSX"`, `"Server"`, `"Windows"`, `"UWP"`, `"X11"`. 837 */ 838 String getName() const 839 { 840 checkClassBinding!(typeof(this))(); 841 return ptrcall!(String)(GDNativeClassBinding.getName, _godot_object); 842 } 843 /** 844 Returns internal structure pointers for use in GDNative plugins. 845 $(B Note:) This method is implemented on Linux and Windows (other OSs will soon be supported). 846 */ 847 long getNativeHandle(in long handle_type) 848 { 849 checkClassBinding!(typeof(this))(); 850 return ptrcall!(long)(GDNativeClassBinding.getNativeHandle, _godot_object, handle_type); 851 } 852 /** 853 Returns the amount of battery left in the device as a percentage. Returns `-1` if power state is unknown. 854 $(B Note:) This method is implemented on Linux, macOS and Windows. 855 */ 856 long getPowerPercentLeft() 857 { 858 checkClassBinding!(typeof(this))(); 859 return ptrcall!(long)(GDNativeClassBinding.getPowerPercentLeft, _godot_object); 860 } 861 /** 862 Returns an estimate of the time left in seconds before the device runs out of battery. Returns `-1` if power state is unknown. 863 $(B Note:) This method is implemented on Linux, macOS and Windows. 864 */ 865 long getPowerSecondsLeft() 866 { 867 checkClassBinding!(typeof(this))(); 868 return ptrcall!(long)(GDNativeClassBinding.getPowerSecondsLeft, _godot_object); 869 } 870 /** 871 Returns the current state of the device regarding battery and power. See $(D powerstate) constants. 872 $(B Note:) This method is implemented on Linux, macOS and Windows. 873 */ 874 OS.PowerState getPowerState() 875 { 876 checkClassBinding!(typeof(this))(); 877 return ptrcall!(OS.PowerState)(GDNativeClassBinding.getPowerState, _godot_object); 878 } 879 /** 880 Returns the project's process ID. 881 $(B Note:) This method is implemented on Android, iOS, Linux, macOS and Windows. 882 */ 883 long getProcessId() const 884 { 885 checkClassBinding!(typeof(this))(); 886 return ptrcall!(long)(GDNativeClassBinding.getProcessId, _godot_object); 887 } 888 /** 889 Returns the number of threads available on the host machine. 890 */ 891 long getProcessorCount() const 892 { 893 checkClassBinding!(typeof(this))(); 894 return ptrcall!(long)(GDNativeClassBinding.getProcessorCount, _godot_object); 895 } 896 /** 897 Returns the window size including decorations like window borders. 898 */ 899 Vector2 getRealWindowSize() const 900 { 901 checkClassBinding!(typeof(this))(); 902 return ptrcall!(Vector2)(GDNativeClassBinding.getRealWindowSize, _godot_object); 903 } 904 /** 905 Returns the given scancode as a string (e.g. Return values: `"Escape"`, `"Shift+Escape"`). 906 See also $(D InputEventKey.scancode) and $(D InputEventKey.getScancodeWithModifiers). 907 */ 908 String getScancodeString(in long code) const 909 { 910 checkClassBinding!(typeof(this))(); 911 return ptrcall!(String)(GDNativeClassBinding.getScancodeString, _godot_object, code); 912 } 913 /** 914 Returns the number of displays attached to the host machine. 915 */ 916 long getScreenCount() const 917 { 918 checkClassBinding!(typeof(this))(); 919 return ptrcall!(long)(GDNativeClassBinding.getScreenCount, _godot_object); 920 } 921 /** 922 Returns the dots per inch density of the specified screen. If `screen` is $(D /code)-1$(D /code) (the default value), the current screen will be used. 923 $(B Note:) On macOS, returned value is inaccurate if fractional display scaling mode is used. 924 $(B Note:) On Android devices, the actual screen densities are grouped into six generalized densities: 925 926 927 ldpi - 120 dpi 928 mdpi - 160 dpi 929 hdpi - 240 dpi 930 xhdpi - 320 dpi 931 xxhdpi - 480 dpi 932 xxxhdpi - 640 dpi 933 934 935 $(B Note:) This method is implemented on Android, Linux, macOS and Windows. Returns `72` on unsupported platforms. 936 */ 937 long getScreenDpi(in long screen = -1) const 938 { 939 checkClassBinding!(typeof(this))(); 940 return ptrcall!(long)(GDNativeClassBinding.getScreenDpi, _godot_object, screen); 941 } 942 /** 943 Return the greatest scale factor of all screens. 944 $(B Note:) On macOS returned value is `2.0` if there is at least one hiDPI (Retina) screen in the system, and `1.0` in all other cases. 945 $(B Note:) This method is implemented on macOS. 946 */ 947 double getScreenMaxScale() const 948 { 949 checkClassBinding!(typeof(this))(); 950 return ptrcall!(double)(GDNativeClassBinding.getScreenMaxScale, _godot_object); 951 } 952 /** 953 954 */ 955 OS.ScreenOrientation getScreenOrientation() const 956 { 957 checkClassBinding!(typeof(this))(); 958 return ptrcall!(OS.ScreenOrientation)(GDNativeClassBinding.getScreenOrientation, _godot_object); 959 } 960 /** 961 Returns the position of the specified screen by index. If `screen` is $(D /code)-1$(D /code) (the default value), the current screen will be used. 962 */ 963 Vector2 getScreenPosition(in long screen = -1) const 964 { 965 checkClassBinding!(typeof(this))(); 966 return ptrcall!(Vector2)(GDNativeClassBinding.getScreenPosition, _godot_object, screen); 967 } 968 /** 969 Return the scale factor of the specified screen by index. If `screen` is $(D /code)-1$(D /code) (the default value), the current screen will be used. 970 $(B Note:) On macOS returned value is `2.0` for hiDPI (Retina) screen, and `1.0` for all other cases. 971 $(B Note:) This method is implemented on macOS. 972 */ 973 double getScreenScale(in long screen = -1) const 974 { 975 checkClassBinding!(typeof(this))(); 976 return ptrcall!(double)(GDNativeClassBinding.getScreenScale, _godot_object, screen); 977 } 978 /** 979 Returns the dimensions in pixels of the specified screen. If `screen` is $(D /code)-1$(D /code) (the default value), the current screen will be used. 980 */ 981 Vector2 getScreenSize(in long screen = -1) const 982 { 983 checkClassBinding!(typeof(this))(); 984 return ptrcall!(Vector2)(GDNativeClassBinding.getScreenSize, _godot_object, screen); 985 } 986 /** 987 Returns the amount of time in milliseconds it took for the boot logo to appear. 988 */ 989 long getSplashTickMsec() const 990 { 991 checkClassBinding!(typeof(this))(); 992 return ptrcall!(long)(GDNativeClassBinding.getSplashTickMsec, _godot_object); 993 } 994 /** 995 Returns the maximum amount of static memory used (only works in debug). 996 */ 997 long getStaticMemoryPeakUsage() const 998 { 999 checkClassBinding!(typeof(this))(); 1000 return ptrcall!(long)(GDNativeClassBinding.getStaticMemoryPeakUsage, _godot_object); 1001 } 1002 /** 1003 Returns the amount of static memory being used by the program in bytes. 1004 */ 1005 long getStaticMemoryUsage() const 1006 { 1007 checkClassBinding!(typeof(this))(); 1008 return ptrcall!(long)(GDNativeClassBinding.getStaticMemoryUsage, _godot_object); 1009 } 1010 /** 1011 Returns the actual path to commonly used folders across different platforms. Available locations are specified in $(D systemdir). 1012 $(B Note:) This method is implemented on Android, Linux, macOS and Windows. 1013 $(B Note:) Shared storage is implemented on Android and allows to differentiate between app specific and shared directories. Shared directories have additional restrictions on Android. 1014 */ 1015 String getSystemDir(in long dir) const 1016 { 1017 checkClassBinding!(typeof(this))(); 1018 return ptrcall!(String)(GDNativeClassBinding.getSystemDir, _godot_object, dir); 1019 } 1020 /** 1021 Returns the epoch time of the operating system in milliseconds. 1022 */ 1023 long getSystemTimeMsecs() const 1024 { 1025 checkClassBinding!(typeof(this))(); 1026 return ptrcall!(long)(GDNativeClassBinding.getSystemTimeMsecs, _godot_object); 1027 } 1028 /** 1029 Returns the epoch time of the operating system in seconds. 1030 */ 1031 long getSystemTimeSecs() const 1032 { 1033 checkClassBinding!(typeof(this))(); 1034 return ptrcall!(long)(GDNativeClassBinding.getSystemTimeSecs, _godot_object); 1035 } 1036 /** 1037 Returns the total number of available tablet drivers. 1038 $(B Note:) This method is implemented on Windows. 1039 */ 1040 long getTabletDriverCount() const 1041 { 1042 checkClassBinding!(typeof(this))(); 1043 return ptrcall!(long)(GDNativeClassBinding.getTabletDriverCount, _godot_object); 1044 } 1045 /** 1046 Returns the tablet driver name for the given index. 1047 $(B Note:) This method is implemented on Windows. 1048 */ 1049 String getTabletDriverName(in long idx) const 1050 { 1051 checkClassBinding!(typeof(this))(); 1052 return ptrcall!(String)(GDNativeClassBinding.getTabletDriverName, _godot_object, idx); 1053 } 1054 /** 1055 Returns the ID of the current thread. This can be used in logs to ease debugging of multi-threaded applications. 1056 $(B Note:) Thread IDs are not deterministic and may be reused across application restarts. 1057 */ 1058 long getThreadCallerId() const 1059 { 1060 checkClassBinding!(typeof(this))(); 1061 return ptrcall!(long)(GDNativeClassBinding.getThreadCallerId, _godot_object); 1062 } 1063 /** 1064 Returns the amount of time passed in milliseconds since the engine started. 1065 */ 1066 long getTicksMsec() const 1067 { 1068 checkClassBinding!(typeof(this))(); 1069 return ptrcall!(long)(GDNativeClassBinding.getTicksMsec, _godot_object); 1070 } 1071 /** 1072 Returns the amount of time passed in microseconds since the engine started. 1073 */ 1074 long getTicksUsec() const 1075 { 1076 checkClassBinding!(typeof(this))(); 1077 return ptrcall!(long)(GDNativeClassBinding.getTicksUsec, _godot_object); 1078 } 1079 /** 1080 Returns current time as a dictionary of keys: hour, minute, second. 1081 */ 1082 Dictionary getTime(in bool utc = false) const 1083 { 1084 checkClassBinding!(typeof(this))(); 1085 return ptrcall!(Dictionary)(GDNativeClassBinding.getTime, _godot_object, utc); 1086 } 1087 /** 1088 Returns the current time zone as a dictionary with the keys: bias and name. 1089 */ 1090 Dictionary getTimeZoneInfo() const 1091 { 1092 checkClassBinding!(typeof(this))(); 1093 return ptrcall!(Dictionary)(GDNativeClassBinding.getTimeZoneInfo, _godot_object); 1094 } 1095 /** 1096 Returns a string that is unique to the device. 1097 $(B Note:) This string may change without notice if the user reinstalls/upgrades their operating system or changes their hardware. This means it should generally not be used to encrypt persistent data as the data saved before an unexpected ID change would become inaccessible. The returned string may also be falsified using external programs, so do not rely on the string returned by $(D getUniqueId) for security purposes. 1098 $(B Note:) Returns an empty string on HTML5 and UWP, as this method isn't implemented on those platforms yet. 1099 */ 1100 String getUniqueId() const 1101 { 1102 checkClassBinding!(typeof(this))(); 1103 return ptrcall!(String)(GDNativeClassBinding.getUniqueId, _godot_object); 1104 } 1105 /** 1106 Returns the current UNIX epoch timestamp in seconds. 1107 $(B Important:) This is the system clock that the user can manually set. $(B Never use) this method for precise time calculation since its results are also subject to automatic adjustments by the operating system. $(B Always use) $(D getTicksUsec) or $(D getTicksMsec) for precise time calculation instead, since they are guaranteed to be monotonic (i.e. never decrease). 1108 */ 1109 long getUnixTime() const 1110 { 1111 checkClassBinding!(typeof(this))(); 1112 return ptrcall!(long)(GDNativeClassBinding.getUnixTime, _godot_object); 1113 } 1114 /** 1115 Gets an epoch time value from a dictionary of time values. 1116 `datetime` must be populated with the following keys: `year`, `month`, `day`, `hour`, `minute`, `second`. 1117 If the dictionary is empty `0` is returned. If some keys are omitted, they default to the equivalent values for the UNIX epoch timestamp 0 (1970-01-01 at 00:00:00 UTC). 1118 You can pass the output from $(D getDatetimeFromUnixTime) directly into this function. Daylight Savings Time (`dst`), if present, is ignored. 1119 */ 1120 long getUnixTimeFromDatetime(in Dictionary datetime) const 1121 { 1122 checkClassBinding!(typeof(this))(); 1123 return ptrcall!(long)(GDNativeClassBinding.getUnixTimeFromDatetime, _godot_object, datetime); 1124 } 1125 /** 1126 Returns the absolute directory path where user data is written (`user://`). 1127 On Linux, this is `~/.local/share/godot/app_userdata/$(D project_name)`, or `~/.local/share/$(D custom_name)` if `use_custom_user_dir` is set. 1128 On macOS, this is `~/Library/Application Support/Godot/app_userdata/$(D project_name)`, or `~/Library/Application Support/$(D custom_name)` if `use_custom_user_dir` is set. 1129 On Windows, this is `%APPDATA%\Godot\app_userdata\$(D project_name)`, or `%APPDATA%\$(D custom_name)` if `use_custom_user_dir` is set. `%APPDATA%` expands to `%USERPROFILE%\AppData\Roaming`. 1130 If the project name is empty, `user://` falls back to `res://`. 1131 */ 1132 String getUserDataDir() const 1133 { 1134 checkClassBinding!(typeof(this))(); 1135 return ptrcall!(String)(GDNativeClassBinding.getUserDataDir, _godot_object); 1136 } 1137 /** 1138 Returns the number of video drivers supported on the current platform. 1139 */ 1140 long getVideoDriverCount() const 1141 { 1142 checkClassBinding!(typeof(this))(); 1143 return ptrcall!(long)(GDNativeClassBinding.getVideoDriverCount, _godot_object); 1144 } 1145 /** 1146 Returns the name of the video driver matching the given `driver` index. This index is a value from $(D videodriver), and you can use $(D getCurrentVideoDriver) to get the current backend's index. 1147 */ 1148 String getVideoDriverName(in long driver) const 1149 { 1150 checkClassBinding!(typeof(this))(); 1151 return ptrcall!(String)(GDNativeClassBinding.getVideoDriverName, _godot_object, driver); 1152 } 1153 /** 1154 Returns the on-screen keyboard's height in pixels. Returns 0 if there is no keyboard or if it is currently hidden. 1155 */ 1156 long getVirtualKeyboardHeight() 1157 { 1158 checkClassBinding!(typeof(this))(); 1159 return ptrcall!(long)(GDNativeClassBinding.getVirtualKeyboardHeight, _godot_object); 1160 } 1161 /** 1162 1163 */ 1164 bool getWindowPerPixelTransparencyEnabled() const 1165 { 1166 checkClassBinding!(typeof(this))(); 1167 return ptrcall!(bool)(GDNativeClassBinding.getWindowPerPixelTransparencyEnabled, _godot_object); 1168 } 1169 /** 1170 1171 */ 1172 Vector2 getWindowPosition() const 1173 { 1174 checkClassBinding!(typeof(this))(); 1175 return ptrcall!(Vector2)(GDNativeClassBinding.getWindowPosition, _godot_object); 1176 } 1177 /** 1178 Returns unobscured area of the window where interactive controls should be rendered. 1179 */ 1180 Rect2 getWindowSafeArea() const 1181 { 1182 checkClassBinding!(typeof(this))(); 1183 return ptrcall!(Rect2)(GDNativeClassBinding.getWindowSafeArea, _godot_object); 1184 } 1185 /** 1186 1187 */ 1188 Vector2 getWindowSize() const 1189 { 1190 checkClassBinding!(typeof(this))(); 1191 return ptrcall!(Vector2)(GDNativeClassBinding.getWindowSize, _godot_object); 1192 } 1193 /** 1194 Add a new item with text "label" to global menu. Use "_dock" menu to add item to the macOS dock icon menu. 1195 $(B Note:) This method is implemented on macOS. 1196 */ 1197 void globalMenuAddItem(VariantArg2, VariantArg3)(in String menu, in String label, in VariantArg2 id, in VariantArg3 meta) 1198 { 1199 checkClassBinding!(typeof(this))(); 1200 ptrcall!(void)(GDNativeClassBinding.globalMenuAddItem, _godot_object, menu, label, id, meta); 1201 } 1202 /** 1203 Add a separator between items. Separators also occupy an index. 1204 $(B Note:) This method is implemented on macOS. 1205 */ 1206 void globalMenuAddSeparator(in String menu) 1207 { 1208 checkClassBinding!(typeof(this))(); 1209 ptrcall!(void)(GDNativeClassBinding.globalMenuAddSeparator, _godot_object, menu); 1210 } 1211 /** 1212 Clear the global menu, in effect removing all items. 1213 $(B Note:) This method is implemented on macOS. 1214 */ 1215 void globalMenuClear(in String menu) 1216 { 1217 checkClassBinding!(typeof(this))(); 1218 ptrcall!(void)(GDNativeClassBinding.globalMenuClear, _godot_object, menu); 1219 } 1220 /** 1221 Removes the item at index "idx" from the global menu. Note that the indexes of items after the removed item are going to be shifted by one. 1222 $(B Note:) This method is implemented on macOS. 1223 */ 1224 void globalMenuRemoveItem(in String menu, in long idx) 1225 { 1226 checkClassBinding!(typeof(this))(); 1227 ptrcall!(void)(GDNativeClassBinding.globalMenuRemoveItem, _godot_object, menu, idx); 1228 } 1229 /** 1230 Returns `true` if the environment variable with the name `variable` exists. 1231 $(B Note:) Double-check the casing of `variable`. Environment variable names are case-sensitive on all platforms except Windows. 1232 */ 1233 bool hasEnvironment(in String variable) const 1234 { 1235 checkClassBinding!(typeof(this))(); 1236 return ptrcall!(bool)(GDNativeClassBinding.hasEnvironment, _godot_object, variable); 1237 } 1238 /** 1239 Returns `true` if the feature for the given feature tag is supported in the currently running instance, depending on the platform, build etc. Can be used to check whether you're currently running a debug build, on a certain platform or arch, etc. Refer to the $(D url=https://docs.godotengine.org/en/3.3/getting_started/workflow/export/feature_tags.html)Feature Tags$(D /url) documentation for more details. 1240 $(B Note:) Tag names are case-sensitive. 1241 */ 1242 bool hasFeature(in String tag_name) const 1243 { 1244 checkClassBinding!(typeof(this))(); 1245 return ptrcall!(bool)(GDNativeClassBinding.hasFeature, _godot_object, tag_name); 1246 } 1247 /** 1248 Returns `true` if the device has a touchscreen or emulates one. 1249 */ 1250 bool hasTouchscreenUiHint() const 1251 { 1252 checkClassBinding!(typeof(this))(); 1253 return ptrcall!(bool)(GDNativeClassBinding.hasTouchscreenUiHint, _godot_object); 1254 } 1255 /** 1256 Returns `true` if the platform has a virtual keyboard, `false` otherwise. 1257 */ 1258 bool hasVirtualKeyboard() const 1259 { 1260 checkClassBinding!(typeof(this))(); 1261 return ptrcall!(bool)(GDNativeClassBinding.hasVirtualKeyboard, _godot_object); 1262 } 1263 /** 1264 Hides the virtual keyboard if it is shown, does nothing otherwise. 1265 */ 1266 void hideVirtualKeyboard() 1267 { 1268 checkClassBinding!(typeof(this))(); 1269 ptrcall!(void)(GDNativeClassBinding.hideVirtualKeyboard, _godot_object); 1270 } 1271 /** 1272 Returns `true` if the Godot binary used to run the project is a $(I debug) export template, or when running in the editor. 1273 Returns `false` if the Godot binary used to run the project is a $(I release) export template. 1274 To check whether the Godot binary used to run the project is an export template (debug or release), use `OS.has_feature("standalone")` instead. 1275 */ 1276 bool isDebugBuild() const 1277 { 1278 checkClassBinding!(typeof(this))(); 1279 return ptrcall!(bool)(GDNativeClassBinding.isDebugBuild, _godot_object); 1280 } 1281 /** 1282 1283 */ 1284 bool isInLowProcessorUsageMode() const 1285 { 1286 checkClassBinding!(typeof(this))(); 1287 return ptrcall!(bool)(GDNativeClassBinding.isInLowProcessorUsageMode, _godot_object); 1288 } 1289 /** 1290 1291 */ 1292 bool isKeepScreenOn() const 1293 { 1294 checkClassBinding!(typeof(this))(); 1295 return ptrcall!(bool)(GDNativeClassBinding.isKeepScreenOn, _godot_object); 1296 } 1297 /** 1298 Returns `true` if the $(B OK) button should appear on the left and $(B Cancel) on the right. 1299 */ 1300 bool isOkLeftAndCancelRight() const 1301 { 1302 checkClassBinding!(typeof(this))(); 1303 return ptrcall!(bool)(GDNativeClassBinding.isOkLeftAndCancelRight, _godot_object); 1304 } 1305 /** 1306 Returns `true` if the input scancode corresponds to a Unicode character. 1307 */ 1308 bool isScancodeUnicode(in long code) const 1309 { 1310 checkClassBinding!(typeof(this))(); 1311 return ptrcall!(bool)(GDNativeClassBinding.isScancodeUnicode, _godot_object, code); 1312 } 1313 /** 1314 Returns `true` if the engine was executed with `-v` (verbose stdout). 1315 */ 1316 bool isStdoutVerbose() const 1317 { 1318 checkClassBinding!(typeof(this))(); 1319 return ptrcall!(bool)(GDNativeClassBinding.isStdoutVerbose, _godot_object); 1320 } 1321 /** 1322 If `true`, the `user://` file system is persistent, so that its state is the same after a player quits and starts the game again. Relevant to the HTML5 platform, where this persistence may be unavailable. 1323 */ 1324 bool isUserfsPersistent() const 1325 { 1326 checkClassBinding!(typeof(this))(); 1327 return ptrcall!(bool)(GDNativeClassBinding.isUserfsPersistent, _godot_object); 1328 } 1329 /** 1330 1331 */ 1332 bool isVsyncEnabled() const 1333 { 1334 checkClassBinding!(typeof(this))(); 1335 return ptrcall!(bool)(GDNativeClassBinding.isVsyncEnabled, _godot_object); 1336 } 1337 /** 1338 1339 */ 1340 bool isVsyncViaCompositorEnabled() const 1341 { 1342 checkClassBinding!(typeof(this))(); 1343 return ptrcall!(bool)(GDNativeClassBinding.isVsyncViaCompositorEnabled, _godot_object); 1344 } 1345 /** 1346 Returns `true` if the window should always be on top of other windows. 1347 */ 1348 bool isWindowAlwaysOnTop() const 1349 { 1350 checkClassBinding!(typeof(this))(); 1351 return ptrcall!(bool)(GDNativeClassBinding.isWindowAlwaysOnTop, _godot_object); 1352 } 1353 /** 1354 Returns `true` if the window is currently focused. 1355 $(B Note:) Only implemented on desktop platforms. On other platforms, it will always return `true`. 1356 */ 1357 bool isWindowFocused() const 1358 { 1359 checkClassBinding!(typeof(this))(); 1360 return ptrcall!(bool)(GDNativeClassBinding.isWindowFocused, _godot_object); 1361 } 1362 /** 1363 1364 */ 1365 bool isWindowFullscreen() const 1366 { 1367 checkClassBinding!(typeof(this))(); 1368 return ptrcall!(bool)(GDNativeClassBinding.isWindowFullscreen, _godot_object); 1369 } 1370 /** 1371 1372 */ 1373 bool isWindowMaximized() const 1374 { 1375 checkClassBinding!(typeof(this))(); 1376 return ptrcall!(bool)(GDNativeClassBinding.isWindowMaximized, _godot_object); 1377 } 1378 /** 1379 1380 */ 1381 bool isWindowMinimized() const 1382 { 1383 checkClassBinding!(typeof(this))(); 1384 return ptrcall!(bool)(GDNativeClassBinding.isWindowMinimized, _godot_object); 1385 } 1386 /** 1387 1388 */ 1389 bool isWindowResizable() const 1390 { 1391 checkClassBinding!(typeof(this))(); 1392 return ptrcall!(bool)(GDNativeClassBinding.isWindowResizable, _godot_object); 1393 } 1394 /** 1395 Returns active keyboard layout index. 1396 $(B Note:) This method is implemented on Linux, macOS and Windows. 1397 */ 1398 long keyboardGetCurrentLayout() const 1399 { 1400 checkClassBinding!(typeof(this))(); 1401 return ptrcall!(long)(GDNativeClassBinding.keyboardGetCurrentLayout, _godot_object); 1402 } 1403 /** 1404 Returns the number of keyboard layouts. 1405 $(B Note:) This method is implemented on Linux, macOS and Windows. 1406 */ 1407 long keyboardGetLayoutCount() const 1408 { 1409 checkClassBinding!(typeof(this))(); 1410 return ptrcall!(long)(GDNativeClassBinding.keyboardGetLayoutCount, _godot_object); 1411 } 1412 /** 1413 Returns the ISO-639/BCP-47 language code of the keyboard layout at position `index`. 1414 $(B Note:) This method is implemented on Linux, macOS and Windows. 1415 */ 1416 String keyboardGetLayoutLanguage(in long index) const 1417 { 1418 checkClassBinding!(typeof(this))(); 1419 return ptrcall!(String)(GDNativeClassBinding.keyboardGetLayoutLanguage, _godot_object, index); 1420 } 1421 /** 1422 Returns the localized name of the keyboard layout at position `index`. 1423 $(B Note:) This method is implemented on Linux, macOS and Windows. 1424 */ 1425 String keyboardGetLayoutName(in long index) const 1426 { 1427 checkClassBinding!(typeof(this))(); 1428 return ptrcall!(String)(GDNativeClassBinding.keyboardGetLayoutName, _godot_object, index); 1429 } 1430 /** 1431 Sets active keyboard layout. 1432 $(B Note:) This method is implemented on Linux, macOS and Windows. 1433 */ 1434 void keyboardSetCurrentLayout(in long index) 1435 { 1436 checkClassBinding!(typeof(this))(); 1437 ptrcall!(void)(GDNativeClassBinding.keyboardSetCurrentLayout, _godot_object, index); 1438 } 1439 /** 1440 Kill (terminate) the process identified by the given process ID (`pid`), e.g. the one returned by $(D execute) in non-blocking mode. 1441 $(B Note:) This method can also be used to kill processes that were not spawned by the game. 1442 $(B Note:) This method is implemented on Android, iOS, Linux, macOS and Windows. 1443 */ 1444 GodotError kill(in long pid) 1445 { 1446 checkClassBinding!(typeof(this))(); 1447 return ptrcall!(GodotError)(GDNativeClassBinding.kill, _godot_object, pid); 1448 } 1449 /** 1450 Moves the window to the front. 1451 $(B Note:) This method is implemented on Linux, macOS and Windows. 1452 */ 1453 void moveWindowToForeground() 1454 { 1455 checkClassBinding!(typeof(this))(); 1456 ptrcall!(void)(GDNativeClassBinding.moveWindowToForeground, _godot_object); 1457 } 1458 /** 1459 Returns `true` if native video is playing. 1460 $(B Note:) This method is implemented on Android and iOS. 1461 */ 1462 bool nativeVideoIsPlaying() 1463 { 1464 checkClassBinding!(typeof(this))(); 1465 return ptrcall!(bool)(GDNativeClassBinding.nativeVideoIsPlaying, _godot_object); 1466 } 1467 /** 1468 Pauses native video playback. 1469 $(B Note:) This method is implemented on Android and iOS. 1470 */ 1471 void nativeVideoPause() 1472 { 1473 checkClassBinding!(typeof(this))(); 1474 ptrcall!(void)(GDNativeClassBinding.nativeVideoPause, _godot_object); 1475 } 1476 /** 1477 Plays native video from the specified path, at the given volume and with audio and subtitle tracks. 1478 $(B Note:) This method is implemented on Android and iOS, and the current Android implementation does not support the `volume`, `audio_track` and `subtitle_track` options. 1479 */ 1480 GodotError nativeVideoPlay(in String path, in double volume, in String audio_track, in String subtitle_track) 1481 { 1482 checkClassBinding!(typeof(this))(); 1483 return ptrcall!(GodotError)(GDNativeClassBinding.nativeVideoPlay, _godot_object, path, volume, audio_track, subtitle_track); 1484 } 1485 /** 1486 Stops native video playback. 1487 $(B Note:) This method is implemented on Android and iOS. 1488 */ 1489 void nativeVideoStop() 1490 { 1491 checkClassBinding!(typeof(this))(); 1492 ptrcall!(void)(GDNativeClassBinding.nativeVideoStop, _godot_object); 1493 } 1494 /** 1495 Resumes native video playback. 1496 $(B Note:) This method is implemented on Android and iOS. 1497 */ 1498 void nativeVideoUnpause() 1499 { 1500 checkClassBinding!(typeof(this))(); 1501 ptrcall!(void)(GDNativeClassBinding.nativeVideoUnpause, _godot_object); 1502 } 1503 /** 1504 Initialises the singleton for the system MIDI driver. 1505 $(B Note:) This method is implemented on Linux, macOS and Windows. 1506 */ 1507 void openMidiInputs() 1508 { 1509 checkClassBinding!(typeof(this))(); 1510 ptrcall!(void)(GDNativeClassBinding.openMidiInputs, _godot_object); 1511 } 1512 /** 1513 Shows all resources in the game. Optionally, the list can be written to a file by specifying a file path in `tofile`. 1514 */ 1515 void printAllResources(in String tofile = gs!"") 1516 { 1517 checkClassBinding!(typeof(this))(); 1518 ptrcall!(void)(GDNativeClassBinding.printAllResources, _godot_object, tofile); 1519 } 1520 /** 1521 Shows the list of loaded textures sorted by size in memory. 1522 */ 1523 void printAllTexturesBySize() 1524 { 1525 checkClassBinding!(typeof(this))(); 1526 ptrcall!(void)(GDNativeClassBinding.printAllTexturesBySize, _godot_object); 1527 } 1528 /** 1529 Shows the number of resources loaded by the game of the given types. 1530 */ 1531 void printResourcesByType(in PoolStringArray types) 1532 { 1533 checkClassBinding!(typeof(this))(); 1534 ptrcall!(void)(GDNativeClassBinding.printResourcesByType, _godot_object, types); 1535 } 1536 /** 1537 Shows all resources currently used by the game. 1538 */ 1539 void printResourcesInUse(in bool _short = false) 1540 { 1541 checkClassBinding!(typeof(this))(); 1542 ptrcall!(void)(GDNativeClassBinding.printResourcesInUse, _godot_object, _short); 1543 } 1544 /** 1545 Request the user attention to the window. It'll flash the taskbar button on Windows or bounce the dock icon on OSX. 1546 $(B Note:) This method is implemented on Linux, macOS and Windows. 1547 */ 1548 void requestAttention() 1549 { 1550 checkClassBinding!(typeof(this))(); 1551 ptrcall!(void)(GDNativeClassBinding.requestAttention, _godot_object); 1552 } 1553 /** 1554 At the moment this function is only used by `AudioDriverOpenSL` to request permission for `RECORD_AUDIO` on Android. 1555 */ 1556 bool requestPermission(in String name) 1557 { 1558 checkClassBinding!(typeof(this))(); 1559 return ptrcall!(bool)(GDNativeClassBinding.requestPermission, _godot_object, name); 1560 } 1561 /** 1562 With this function, you can request dangerous permissions since normal permissions are automatically granted at install time in Android applications. 1563 $(B Note:) This method is implemented on Android. 1564 */ 1565 bool requestPermissions() 1566 { 1567 checkClassBinding!(typeof(this))(); 1568 return ptrcall!(bool)(GDNativeClassBinding.requestPermissions, _godot_object); 1569 } 1570 /** 1571 1572 */ 1573 void setBorderlessWindow(in bool borderless) 1574 { 1575 checkClassBinding!(typeof(this))(); 1576 ptrcall!(void)(GDNativeClassBinding.setBorderlessWindow, _godot_object, borderless); 1577 } 1578 /** 1579 1580 */ 1581 void setClipboard(in String clipboard) 1582 { 1583 checkClassBinding!(typeof(this))(); 1584 ptrcall!(void)(GDNativeClassBinding.setClipboard, _godot_object, clipboard); 1585 } 1586 /** 1587 1588 */ 1589 void setCurrentScreen(in long screen) 1590 { 1591 checkClassBinding!(typeof(this))(); 1592 ptrcall!(void)(GDNativeClassBinding.setCurrentScreen, _godot_object, screen); 1593 } 1594 /** 1595 1596 */ 1597 void setCurrentTabletDriver(in String name) 1598 { 1599 checkClassBinding!(typeof(this))(); 1600 ptrcall!(void)(GDNativeClassBinding.setCurrentTabletDriver, _godot_object, name); 1601 } 1602 /** 1603 Sets the value of the environment variable `variable` to `value`. The environment variable will be set for the Godot process and any process executed with $(D execute) after running $(D setEnvironment). The environment variable will $(I not) persist to processes run after the Godot process was terminated. 1604 $(B Note:) Double-check the casing of `variable`. Environment variable names are case-sensitive on all platforms except Windows. 1605 */ 1606 bool setEnvironment(in String variable, in String value) const 1607 { 1608 checkClassBinding!(typeof(this))(); 1609 return ptrcall!(bool)(GDNativeClassBinding.setEnvironment, _godot_object, variable, value); 1610 } 1611 /** 1612 1613 */ 1614 void setExitCode(in long code) 1615 { 1616 checkClassBinding!(typeof(this))(); 1617 ptrcall!(void)(GDNativeClassBinding.setExitCode, _godot_object, code); 1618 } 1619 /** 1620 Sets the game's icon using an $(D Image) resource. 1621 The same image is used for window caption, taskbar/dock and window selection dialog. Image is scaled as needed. 1622 $(B Note:) This method is implemented on HTML5, Linux, macOS and Windows. 1623 */ 1624 void setIcon(Image icon) 1625 { 1626 checkClassBinding!(typeof(this))(); 1627 ptrcall!(void)(GDNativeClassBinding.setIcon, _godot_object, icon); 1628 } 1629 /** 1630 Sets whether IME input mode should be enabled. 1631 If active IME handles key events before the application and creates an composition string and suggestion list. 1632 Application can retrieve the composition status by using $(D getImeSelection) and $(D getImeText) functions. 1633 Completed composition string is committed when input is finished. 1634 $(B Note:) This method is implemented on Linux, macOS and Windows. 1635 */ 1636 void setImeActive(in bool active) 1637 { 1638 checkClassBinding!(typeof(this))(); 1639 ptrcall!(void)(GDNativeClassBinding.setImeActive, _godot_object, active); 1640 } 1641 /** 1642 Sets position of IME suggestion list popup (in window coordinates). 1643 $(B Note:) This method is implemented on Linux, macOS and Windows. 1644 */ 1645 void setImePosition(in Vector2 position) 1646 { 1647 checkClassBinding!(typeof(this))(); 1648 ptrcall!(void)(GDNativeClassBinding.setImePosition, _godot_object, position); 1649 } 1650 /** 1651 1652 */ 1653 void setKeepScreenOn(in bool enabled) 1654 { 1655 checkClassBinding!(typeof(this))(); 1656 ptrcall!(void)(GDNativeClassBinding.setKeepScreenOn, _godot_object, enabled); 1657 } 1658 /** 1659 1660 */ 1661 void setLowProcessorUsageMode(in bool enable) 1662 { 1663 checkClassBinding!(typeof(this))(); 1664 ptrcall!(void)(GDNativeClassBinding.setLowProcessorUsageMode, _godot_object, enable); 1665 } 1666 /** 1667 1668 */ 1669 void setLowProcessorUsageModeSleepUsec(in long usec) 1670 { 1671 checkClassBinding!(typeof(this))(); 1672 ptrcall!(void)(GDNativeClassBinding.setLowProcessorUsageModeSleepUsec, _godot_object, usec); 1673 } 1674 /** 1675 1676 */ 1677 void setMaxWindowSize(in Vector2 size) 1678 { 1679 checkClassBinding!(typeof(this))(); 1680 ptrcall!(void)(GDNativeClassBinding.setMaxWindowSize, _godot_object, size); 1681 } 1682 /** 1683 1684 */ 1685 void setMinWindowSize(in Vector2 size) 1686 { 1687 checkClassBinding!(typeof(this))(); 1688 ptrcall!(void)(GDNativeClassBinding.setMinWindowSize, _godot_object, size); 1689 } 1690 /** 1691 Sets the game's icon using a multi-size platform-specific icon file (`*.ico` on Windows and `*.icns` on macOS). 1692 Appropriate size sub-icons are used for window caption, taskbar/dock and window selection dialog. 1693 $(B Note:) This method is implemented on macOS and Windows. 1694 */ 1695 void setNativeIcon(in String filename) 1696 { 1697 checkClassBinding!(typeof(this))(); 1698 ptrcall!(void)(GDNativeClassBinding.setNativeIcon, _godot_object, filename); 1699 } 1700 /** 1701 1702 */ 1703 void setScreenOrientation(in long orientation) 1704 { 1705 checkClassBinding!(typeof(this))(); 1706 ptrcall!(void)(GDNativeClassBinding.setScreenOrientation, _godot_object, orientation); 1707 } 1708 /** 1709 Sets the name of the current thread. 1710 */ 1711 GodotError setThreadName(in String name) 1712 { 1713 checkClassBinding!(typeof(this))(); 1714 return ptrcall!(GodotError)(GDNativeClassBinding.setThreadName, _godot_object, name); 1715 } 1716 /** 1717 Enables backup saves if `enabled` is `true`. 1718 */ 1719 void setUseFileAccessSaveAndSwap(in bool enabled) 1720 { 1721 checkClassBinding!(typeof(this))(); 1722 ptrcall!(void)(GDNativeClassBinding.setUseFileAccessSaveAndSwap, _godot_object, enabled); 1723 } 1724 /** 1725 1726 */ 1727 void setUseVsync(in bool enable) 1728 { 1729 checkClassBinding!(typeof(this))(); 1730 ptrcall!(void)(GDNativeClassBinding.setUseVsync, _godot_object, enable); 1731 } 1732 /** 1733 1734 */ 1735 void setVsyncViaCompositor(in bool enable) 1736 { 1737 checkClassBinding!(typeof(this))(); 1738 ptrcall!(void)(GDNativeClassBinding.setVsyncViaCompositor, _godot_object, enable); 1739 } 1740 /** 1741 Sets whether the window should always be on top. 1742 $(B Note:) This method is implemented on Linux, macOS and Windows. 1743 */ 1744 void setWindowAlwaysOnTop(in bool enabled) 1745 { 1746 checkClassBinding!(typeof(this))(); 1747 ptrcall!(void)(GDNativeClassBinding.setWindowAlwaysOnTop, _godot_object, enabled); 1748 } 1749 /** 1750 1751 */ 1752 void setWindowFullscreen(in bool enabled) 1753 { 1754 checkClassBinding!(typeof(this))(); 1755 ptrcall!(void)(GDNativeClassBinding.setWindowFullscreen, _godot_object, enabled); 1756 } 1757 /** 1758 1759 */ 1760 void setWindowMaximized(in bool enabled) 1761 { 1762 checkClassBinding!(typeof(this))(); 1763 ptrcall!(void)(GDNativeClassBinding.setWindowMaximized, _godot_object, enabled); 1764 } 1765 /** 1766 1767 */ 1768 void setWindowMinimized(in bool enabled) 1769 { 1770 checkClassBinding!(typeof(this))(); 1771 ptrcall!(void)(GDNativeClassBinding.setWindowMinimized, _godot_object, enabled); 1772 } 1773 /** 1774 Sets a polygonal region of the window which accepts mouse events. Mouse events outside the region will be passed through. 1775 Passing an empty array will disable passthrough support (all mouse events will be intercepted by the window, which is the default behavior). 1776 1777 1778 # Set region, using Path2D node. 1779 OS.set_window_mouse_passthrough($Path2D.curve.get_baked_points()) 1780 1781 # Set region, using Polygon2D node. 1782 OS.set_window_mouse_passthrough($Polygon2D.polygon) 1783 1784 # Reset region to default. 1785 OS.set_window_mouse_passthrough([]) 1786 1787 1788 $(B Note:) On Windows, the portion of a window that lies outside the region is not drawn, while on Linux and macOS it is. 1789 $(B Note:) This method is implemented on Linux, macOS and Windows. 1790 */ 1791 void setWindowMousePassthrough(in PoolVector2Array region) 1792 { 1793 checkClassBinding!(typeof(this))(); 1794 ptrcall!(void)(GDNativeClassBinding.setWindowMousePassthrough, _godot_object, region); 1795 } 1796 /** 1797 1798 */ 1799 void setWindowPerPixelTransparencyEnabled(in bool enabled) 1800 { 1801 checkClassBinding!(typeof(this))(); 1802 ptrcall!(void)(GDNativeClassBinding.setWindowPerPixelTransparencyEnabled, _godot_object, enabled); 1803 } 1804 /** 1805 1806 */ 1807 void setWindowPosition(in Vector2 position) 1808 { 1809 checkClassBinding!(typeof(this))(); 1810 ptrcall!(void)(GDNativeClassBinding.setWindowPosition, _godot_object, position); 1811 } 1812 /** 1813 1814 */ 1815 void setWindowResizable(in bool enabled) 1816 { 1817 checkClassBinding!(typeof(this))(); 1818 ptrcall!(void)(GDNativeClassBinding.setWindowResizable, _godot_object, enabled); 1819 } 1820 /** 1821 1822 */ 1823 void setWindowSize(in Vector2 size) 1824 { 1825 checkClassBinding!(typeof(this))(); 1826 ptrcall!(void)(GDNativeClassBinding.setWindowSize, _godot_object, size); 1827 } 1828 /** 1829 Sets the window title to the specified string. 1830 $(B Note:) This should be used sporadically. Don't set this every frame, as that will negatively affect performance on some window managers. 1831 $(B Note:) This method is implemented on HTML5, Linux, macOS and Windows. 1832 */ 1833 void setWindowTitle(in String title) 1834 { 1835 checkClassBinding!(typeof(this))(); 1836 ptrcall!(void)(GDNativeClassBinding.setWindowTitle, _godot_object, title); 1837 } 1838 /** 1839 Requests the OS to open a resource with the most appropriate program. For example: 1840 - `OS.shell_open("C:\\Users\name\Downloads")` on Windows opens the file explorer at the user's Downloads folder. 1841 - `OS.shell_open("https://godotengine.org")` opens the default web browser on the official Godot website. 1842 - `OS.shell_open("mailto:example@example.com")` opens the default email client with the "To" field set to `example@example.com`. See $(D url=https://blog.escapecreative.com/customizing-mailto-links/)Customizing `mailto:` Links$(D /url) for a list of fields that can be added. 1843 Use $(D ProjectSettings.globalizePath) to convert a `res://` or `user://` path into a system path for use with this method. 1844 $(B Note:) This method is implemented on Android, iOS, HTML5, Linux, macOS and Windows. 1845 */ 1846 GodotError shellOpen(in String uri) 1847 { 1848 checkClassBinding!(typeof(this))(); 1849 return ptrcall!(GodotError)(GDNativeClassBinding.shellOpen, _godot_object, uri); 1850 } 1851 /** 1852 Shows the virtual keyboard if the platform has one. 1853 The `existing_text` parameter is useful for implementing your own $(D LineEdit) or $(D TextEdit), as it tells the virtual keyboard what text has already been typed (the virtual keyboard uses it for auto-correct and predictions). 1854 The `multiline` parameter needs to be set to `true` to be able to enter multiple lines of text, as in $(D TextEdit). 1855 $(B Note:) This method is implemented on Android, iOS and UWP. 1856 */ 1857 void showVirtualKeyboard(in String existing_text = gs!"", in bool multiline = false) 1858 { 1859 checkClassBinding!(typeof(this))(); 1860 ptrcall!(void)(GDNativeClassBinding.showVirtualKeyboard, _godot_object, existing_text, multiline); 1861 } 1862 /** 1863 The clipboard from the host OS. Might be unavailable on some platforms. 1864 */ 1865 @property String clipboard() 1866 { 1867 return getClipboard(); 1868 } 1869 /// ditto 1870 @property void clipboard(String v) 1871 { 1872 setClipboard(v); 1873 } 1874 /** 1875 The current screen index (starting from 0). 1876 */ 1877 @property long currentScreen() 1878 { 1879 return getCurrentScreen(); 1880 } 1881 /// ditto 1882 @property void currentScreen(long v) 1883 { 1884 setCurrentScreen(v); 1885 } 1886 /** 1887 The exit code passed to the OS when the main loop exits. By convention, an exit code of `0` indicates success whereas a non-zero exit code indicates an error. For portability reasons, the exit code should be set between 0 and 125 (inclusive). 1888 $(B Note:) This value will be ignored if using $(D SceneTree.quit) with an `exit_code` argument passed. 1889 */ 1890 @property long exitCode() 1891 { 1892 return getExitCode(); 1893 } 1894 /// ditto 1895 @property void exitCode(long v) 1896 { 1897 setExitCode(v); 1898 } 1899 /** 1900 If `true`, the engine tries to keep the screen on while the game is running. Useful on mobile. 1901 */ 1902 @property bool keepScreenOn() 1903 { 1904 return isKeepScreenOn(); 1905 } 1906 /// ditto 1907 @property void keepScreenOn(bool v) 1908 { 1909 setKeepScreenOn(v); 1910 } 1911 /** 1912 If `true`, the engine optimizes for low processor usage by only refreshing the screen if needed. Can improve battery consumption on mobile. 1913 */ 1914 @property bool lowProcessorUsageMode() 1915 { 1916 return isInLowProcessorUsageMode(); 1917 } 1918 /// ditto 1919 @property void lowProcessorUsageMode(bool v) 1920 { 1921 setLowProcessorUsageMode(v); 1922 } 1923 /** 1924 The amount of sleeping between frames when the low-processor usage mode is enabled (in microseconds). Higher values will result in lower CPU usage. 1925 */ 1926 @property long lowProcessorUsageModeSleepUsec() 1927 { 1928 return getLowProcessorUsageModeSleepUsec(); 1929 } 1930 /// ditto 1931 @property void lowProcessorUsageModeSleepUsec(long v) 1932 { 1933 setLowProcessorUsageModeSleepUsec(v); 1934 } 1935 /** 1936 The maximum size of the window (without counting window manager decorations). Does not affect fullscreen mode. Set to `(0, 0)` to reset to the system default value. 1937 */ 1938 @property Vector2 maxWindowSize() 1939 { 1940 return getMaxWindowSize(); 1941 } 1942 /// ditto 1943 @property void maxWindowSize(Vector2 v) 1944 { 1945 setMaxWindowSize(v); 1946 } 1947 /** 1948 The minimum size of the window (without counting window manager decorations). Does not affect fullscreen mode. Set to `(0, 0)` to reset to the system default value. 1949 */ 1950 @property Vector2 minWindowSize() 1951 { 1952 return getMinWindowSize(); 1953 } 1954 /// ditto 1955 @property void minWindowSize(Vector2 v) 1956 { 1957 setMinWindowSize(v); 1958 } 1959 /** 1960 The current screen orientation. 1961 */ 1962 @property OS.ScreenOrientation screenOrientation() 1963 { 1964 return getScreenOrientation(); 1965 } 1966 /// ditto 1967 @property void screenOrientation(long v) 1968 { 1969 setScreenOrientation(v); 1970 } 1971 /** 1972 The current tablet driver in use. 1973 */ 1974 @property String tabletDriver() 1975 { 1976 return getCurrentTabletDriver(); 1977 } 1978 /// ditto 1979 @property void tabletDriver(String v) 1980 { 1981 setCurrentTabletDriver(v); 1982 } 1983 /** 1984 If `true`, vertical synchronization (Vsync) is enabled. 1985 */ 1986 @property bool vsyncEnabled() 1987 { 1988 return isVsyncEnabled(); 1989 } 1990 /// ditto 1991 @property void vsyncEnabled(bool v) 1992 { 1993 setUseVsync(v); 1994 } 1995 /** 1996 If `true` and `vsync_enabled` is true, the operating system's window compositor will be used for vsync when the compositor is enabled and the game is in windowed mode. 1997 $(B Note:) This option is experimental and meant to alleviate stutter experienced by some users. However, some users have experienced a Vsync framerate halving (e.g. from 60 FPS to 30 FPS) when using it. 1998 $(B Note:) This property is only implemented on Windows. 1999 */ 2000 @property bool vsyncViaCompositor() 2001 { 2002 return isVsyncViaCompositorEnabled(); 2003 } 2004 /// ditto 2005 @property void vsyncViaCompositor(bool v) 2006 { 2007 setVsyncViaCompositor(v); 2008 } 2009 /** 2010 If `true`, removes the window frame. 2011 $(B Note:) Setting `window_borderless` to `false` disables per-pixel transparency. 2012 */ 2013 @property bool windowBorderless() 2014 { 2015 return getBorderlessWindow(); 2016 } 2017 /// ditto 2018 @property void windowBorderless(bool v) 2019 { 2020 setBorderlessWindow(v); 2021 } 2022 /** 2023 If `true`, the window is fullscreen. 2024 */ 2025 @property bool windowFullscreen() 2026 { 2027 return isWindowFullscreen(); 2028 } 2029 /// ditto 2030 @property void windowFullscreen(bool v) 2031 { 2032 setWindowFullscreen(v); 2033 } 2034 /** 2035 If `true`, the window is maximized. 2036 */ 2037 @property bool windowMaximized() 2038 { 2039 return isWindowMaximized(); 2040 } 2041 /// ditto 2042 @property void windowMaximized(bool v) 2043 { 2044 setWindowMaximized(v); 2045 } 2046 /** 2047 If `true`, the window is minimized. 2048 */ 2049 @property bool windowMinimized() 2050 { 2051 return isWindowMinimized(); 2052 } 2053 /// ditto 2054 @property void windowMinimized(bool v) 2055 { 2056 setWindowMinimized(v); 2057 } 2058 /** 2059 If `true`, the window background is transparent and window frame is removed. 2060 Use `get_tree().get_root().set_transparent_background(true)` to disable main viewport background rendering. 2061 $(B Note:) This property has no effect if $(B Project > Project Settings > Display > Window > Per-pixel transparency > Allowed) setting is disabled. 2062 $(B Note:) This property is implemented on HTML5, Linux, macOS and Windows. 2063 */ 2064 @property bool windowPerPixelTransparencyEnabled() 2065 { 2066 return getWindowPerPixelTransparencyEnabled(); 2067 } 2068 /// ditto 2069 @property void windowPerPixelTransparencyEnabled(bool v) 2070 { 2071 setWindowPerPixelTransparencyEnabled(v); 2072 } 2073 /** 2074 The window position relative to the screen, the origin is the top left corner, +Y axis goes to the bottom and +X axis goes to the right. 2075 */ 2076 @property Vector2 windowPosition() 2077 { 2078 return getWindowPosition(); 2079 } 2080 /// ditto 2081 @property void windowPosition(Vector2 v) 2082 { 2083 setWindowPosition(v); 2084 } 2085 /** 2086 If `true`, the window is resizable by the user. 2087 */ 2088 @property bool windowResizable() 2089 { 2090 return isWindowResizable(); 2091 } 2092 /// ditto 2093 @property void windowResizable(bool v) 2094 { 2095 setWindowResizable(v); 2096 } 2097 /** 2098 The size of the window (without counting window manager decorations). 2099 */ 2100 @property Vector2 windowSize() 2101 { 2102 return getWindowSize(); 2103 } 2104 /// ditto 2105 @property void windowSize(Vector2 v) 2106 { 2107 setWindowSize(v); 2108 } 2109 } 2110 /// Returns: the OSSingleton 2111 @property @nogc nothrow pragma(inline, true) 2112 OSSingleton OS() 2113 { 2114 checkClassBinding!OSSingleton(); 2115 return OSSingleton(OSSingleton.GDNativeClassBinding._singleton); 2116 }