core_bind.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. /**************************************************************************/
  2. /* core_bind.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #pragma once
  31. #include "core/debugger/engine_profiler.h"
  32. #include "core/io/resource_loader.h"
  33. #include "core/io/resource_saver.h"
  34. #include "core/os/semaphore.h"
  35. #include "core/os/thread.h"
  36. #include "core/templates/safe_refcount.h"
  37. class MainLoop;
  38. template <typename T>
  39. class TypedArray;
  40. namespace CoreBind {
  41. class ResourceLoader : public Object {
  42. GDCLASS(ResourceLoader, Object);
  43. protected:
  44. static void _bind_methods();
  45. static ResourceLoader *singleton;
  46. public:
  47. enum ThreadLoadStatus {
  48. THREAD_LOAD_INVALID_RESOURCE,
  49. THREAD_LOAD_IN_PROGRESS,
  50. THREAD_LOAD_FAILED,
  51. THREAD_LOAD_LOADED
  52. };
  53. enum CacheMode {
  54. CACHE_MODE_IGNORE,
  55. CACHE_MODE_REUSE,
  56. CACHE_MODE_REPLACE,
  57. CACHE_MODE_IGNORE_DEEP,
  58. CACHE_MODE_REPLACE_DEEP,
  59. };
  60. static ResourceLoader *get_singleton() { return singleton; }
  61. Error load_threaded_request(const String &p_path, const String &p_type_hint = "", bool p_use_sub_threads = false, CacheMode p_cache_mode = CACHE_MODE_REUSE);
  62. ThreadLoadStatus load_threaded_get_status(const String &p_path, Array r_progress = ClassDB::default_array_arg);
  63. Ref<Resource> load_threaded_get(const String &p_path);
  64. Ref<Resource> load(const String &p_path, const String &p_type_hint = "", CacheMode p_cache_mode = CACHE_MODE_REUSE);
  65. Vector<String> get_recognized_extensions_for_type(const String &p_type);
  66. void add_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader, bool p_at_front);
  67. void remove_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader);
  68. void set_abort_on_missing_resources(bool p_abort);
  69. PackedStringArray get_dependencies(const String &p_path);
  70. bool has_cached(const String &p_path);
  71. Ref<Resource> get_cached_ref(const String &p_path);
  72. bool exists(const String &p_path, const String &p_type_hint = "");
  73. ResourceUID::ID get_resource_uid(const String &p_path);
  74. Vector<String> list_directory(const String &p_directory);
  75. ResourceLoader() { singleton = this; }
  76. };
  77. class ResourceSaver : public Object {
  78. GDCLASS(ResourceSaver, Object);
  79. protected:
  80. static void _bind_methods();
  81. static ResourceSaver *singleton;
  82. public:
  83. enum SaverFlags {
  84. FLAG_NONE = 0,
  85. FLAG_RELATIVE_PATHS = 1,
  86. FLAG_BUNDLE_RESOURCES = 2,
  87. FLAG_CHANGE_PATH = 4,
  88. FLAG_OMIT_EDITOR_PROPERTIES = 8,
  89. FLAG_SAVE_BIG_ENDIAN = 16,
  90. FLAG_COMPRESS = 32,
  91. FLAG_REPLACE_SUBRESOURCE_PATHS = 64,
  92. };
  93. static ResourceSaver *get_singleton() { return singleton; }
  94. Error save(const Ref<Resource> &p_resource, const String &p_path, BitField<SaverFlags> p_flags);
  95. Vector<String> get_recognized_extensions(const Ref<Resource> &p_resource);
  96. void add_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver, bool p_at_front);
  97. void remove_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver);
  98. ResourceUID::ID get_resource_id_for_path(const String &p_path, bool p_generate = false);
  99. ResourceSaver() { singleton = this; }
  100. };
  101. class OS : public Object {
  102. GDCLASS(OS, Object);
  103. mutable HashMap<String, bool> feature_cache;
  104. protected:
  105. static void _bind_methods();
  106. static OS *singleton;
  107. #ifndef DISABLE_DEPRECATED
  108. Dictionary _execute_with_pipe_bind_compat_94434(const String &p_path, const Vector<String> &p_arguments);
  109. String _read_string_from_stdin_bind_compat_91201();
  110. static void _bind_compatibility_methods();
  111. #endif
  112. public:
  113. enum RenderingDriver {
  114. RENDERING_DRIVER_VULKAN,
  115. RENDERING_DRIVER_OPENGL3,
  116. RENDERING_DRIVER_D3D12,
  117. RENDERING_DRIVER_METAL,
  118. };
  119. PackedByteArray get_entropy(int p_bytes);
  120. String get_system_ca_certificates();
  121. enum StdHandleType {
  122. STD_HANDLE_INVALID,
  123. STD_HANDLE_CONSOLE,
  124. STD_HANDLE_FILE,
  125. STD_HANDLE_PIPE,
  126. STD_HANDLE_UNKNOWN,
  127. };
  128. virtual PackedStringArray get_connected_midi_inputs();
  129. virtual void open_midi_inputs();
  130. virtual void close_midi_inputs();
  131. void set_low_processor_usage_mode(bool p_enabled);
  132. bool is_in_low_processor_usage_mode() const;
  133. void set_low_processor_usage_mode_sleep_usec(int p_usec);
  134. int get_low_processor_usage_mode_sleep_usec() const;
  135. void set_delta_smoothing(bool p_enabled);
  136. bool is_delta_smoothing_enabled() const;
  137. void alert(const String &p_alert, const String &p_title = "ALERT!");
  138. void crash(const String &p_message);
  139. Vector<String> get_system_fonts() const;
  140. String get_system_font_path(const String &p_font_name, int p_weight = 400, int p_stretch = 100, bool p_italic = false) const;
  141. Vector<String> get_system_font_path_for_text(const String &p_font_name, const String &p_text, const String &p_locale = String(), const String &p_script = String(), int p_weight = 400, int p_stretch = 100, bool p_italic = false) const;
  142. String get_executable_path() const;
  143. String read_string_from_stdin(int64_t p_buffer_size = 1024);
  144. PackedByteArray read_buffer_from_stdin(int64_t p_buffer_size = 1024);
  145. StdHandleType get_stdin_type() const;
  146. StdHandleType get_stdout_type() const;
  147. StdHandleType get_stderr_type() const;
  148. int execute(const String &p_path, const Vector<String> &p_arguments, Array r_output = ClassDB::default_array_arg, bool p_read_stderr = false, bool p_open_console = false);
  149. Dictionary execute_with_pipe(const String &p_path, const Vector<String> &p_arguments, bool p_blocking = true);
  150. int create_process(const String &p_path, const Vector<String> &p_arguments, bool p_open_console = false);
  151. int create_instance(const Vector<String> &p_arguments);
  152. Error kill(int p_pid);
  153. Error shell_open(const String &p_uri);
  154. Error shell_show_in_file_manager(const String &p_path, bool p_open_folder = true);
  155. bool is_process_running(int p_pid) const;
  156. int get_process_exit_code(int p_pid) const;
  157. int get_process_id() const;
  158. void set_restart_on_exit(bool p_restart, const Vector<String> &p_restart_arguments = Vector<String>());
  159. bool is_restart_on_exit_set() const;
  160. Vector<String> get_restart_on_exit_arguments() const;
  161. bool has_environment(const String &p_var) const;
  162. String get_environment(const String &p_var) const;
  163. void set_environment(const String &p_var, const String &p_value) const;
  164. void unset_environment(const String &p_var) const;
  165. String get_name() const;
  166. String get_distribution_name() const;
  167. String get_version() const;
  168. String get_version_alias() const;
  169. Vector<String> get_cmdline_args();
  170. Vector<String> get_cmdline_user_args();
  171. Vector<String> get_video_adapter_driver_info() const;
  172. String get_locale() const;
  173. String get_locale_language() const;
  174. String get_model_name() const;
  175. bool is_debug_build() const;
  176. String get_unique_id() const;
  177. String get_keycode_string(Key p_code) const;
  178. bool is_keycode_unicode(char32_t p_unicode) const;
  179. Key find_keycode_from_string(const String &p_code) const;
  180. void set_use_file_access_save_and_swap(bool p_enable);
  181. uint64_t get_static_memory_usage() const;
  182. uint64_t get_static_memory_peak_usage() const;
  183. Dictionary get_memory_info() const;
  184. void delay_usec(int p_usec) const;
  185. void delay_msec(int p_msec) const;
  186. uint64_t get_ticks_msec() const;
  187. uint64_t get_ticks_usec() const;
  188. bool is_userfs_persistent() const;
  189. bool is_stdout_verbose() const;
  190. int get_processor_count() const;
  191. String get_processor_name() const;
  192. enum SystemDir {
  193. SYSTEM_DIR_DESKTOP,
  194. SYSTEM_DIR_DCIM,
  195. SYSTEM_DIR_DOCUMENTS,
  196. SYSTEM_DIR_DOWNLOADS,
  197. SYSTEM_DIR_MOVIES,
  198. SYSTEM_DIR_MUSIC,
  199. SYSTEM_DIR_PICTURES,
  200. SYSTEM_DIR_RINGTONES,
  201. };
  202. String get_system_dir(SystemDir p_dir, bool p_shared_storage = true) const;
  203. Error move_to_trash(const String &p_path) const;
  204. String get_user_data_dir() const;
  205. String get_config_dir() const;
  206. String get_data_dir() const;
  207. String get_cache_dir() const;
  208. String get_temp_dir() const;
  209. Error set_thread_name(const String &p_name);
  210. ::Thread::ID get_thread_caller_id() const;
  211. ::Thread::ID get_main_thread_id() const;
  212. bool has_feature(const String &p_feature) const;
  213. bool is_sandboxed() const;
  214. bool request_permission(const String &p_name);
  215. bool request_permissions();
  216. Vector<String> get_granted_permissions() const;
  217. void revoke_granted_permissions();
  218. static OS *get_singleton() { return singleton; }
  219. OS() { singleton = this; }
  220. };
  221. class Geometry2D : public Object {
  222. GDCLASS(Geometry2D, Object);
  223. static Geometry2D *singleton;
  224. protected:
  225. static void _bind_methods();
  226. public:
  227. static Geometry2D *get_singleton();
  228. Variant segment_intersects_segment(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b);
  229. Variant line_intersects_line(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b);
  230. Vector<Vector2> get_closest_points_between_segments(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2);
  231. Vector2 get_closest_point_to_segment(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
  232. Vector2 get_closest_point_to_segment_uncapped(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
  233. bool point_is_inside_triangle(const Vector2 &s, const Vector2 &a, const Vector2 &b, const Vector2 &c) const;
  234. bool is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius);
  235. real_t segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius);
  236. bool is_polygon_clockwise(const Vector<Vector2> &p_polygon);
  237. bool is_point_in_polygon(const Point2 &p_point, const Vector<Vector2> &p_polygon);
  238. Vector<int> triangulate_polygon(const Vector<Vector2> &p_polygon);
  239. Vector<int> triangulate_delaunay(const Vector<Vector2> &p_points);
  240. Vector<Point2> convex_hull(const Vector<Point2> &p_points);
  241. TypedArray<PackedVector2Array> decompose_polygon_in_convex(const Vector<Vector2> &p_polygon);
  242. enum PolyBooleanOperation {
  243. OPERATION_UNION,
  244. OPERATION_DIFFERENCE,
  245. OPERATION_INTERSECTION,
  246. OPERATION_XOR
  247. };
  248. // 2D polygon boolean operations.
  249. TypedArray<PackedVector2Array> merge_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Union (add).
  250. TypedArray<PackedVector2Array> clip_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Difference (subtract).
  251. TypedArray<PackedVector2Array> intersect_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Common area (multiply).
  252. TypedArray<PackedVector2Array> exclude_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // All but common area (xor).
  253. // 2D polyline vs polygon operations.
  254. TypedArray<PackedVector2Array> clip_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Cut.
  255. TypedArray<PackedVector2Array> intersect_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Chop.
  256. // 2D offset polygons/polylines.
  257. enum PolyJoinType {
  258. JOIN_SQUARE,
  259. JOIN_ROUND,
  260. JOIN_MITER
  261. };
  262. enum PolyEndType {
  263. END_POLYGON,
  264. END_JOINED,
  265. END_BUTT,
  266. END_SQUARE,
  267. END_ROUND
  268. };
  269. TypedArray<PackedVector2Array> offset_polygon(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE);
  270. TypedArray<PackedVector2Array> offset_polyline(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE, PolyEndType p_end_type = END_SQUARE);
  271. Dictionary make_atlas(const Vector<Size2> &p_rects);
  272. TypedArray<Point2i> bresenham_line(const Point2i &p_from, const Point2i &p_to);
  273. Geometry2D() { singleton = this; }
  274. };
  275. class Geometry3D : public Object {
  276. GDCLASS(Geometry3D, Object);
  277. static Geometry3D *singleton;
  278. protected:
  279. static void _bind_methods();
  280. public:
  281. static Geometry3D *get_singleton();
  282. Vector<Vector3> compute_convex_mesh_points(const TypedArray<Plane> &p_planes);
  283. TypedArray<Plane> build_box_planes(const Vector3 &p_extents);
  284. TypedArray<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis = Vector3::AXIS_Z);
  285. TypedArray<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z);
  286. Vector<Vector3> get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2);
  287. Vector3 get_closest_point_to_segment(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
  288. Vector3 get_closest_point_to_segment_uncapped(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
  289. Vector3 get_triangle_barycentric_coords(const Vector3 &p_point, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
  290. Variant ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
  291. Variant segment_intersects_triangle(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
  292. Vector<Vector3> segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius);
  293. Vector<Vector3> segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius);
  294. Vector<Vector3> segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const TypedArray<Plane> &p_planes);
  295. Vector<Vector3> clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane);
  296. Vector<int32_t> tetrahedralize_delaunay(const Vector<Vector3> &p_points);
  297. Geometry3D() { singleton = this; }
  298. };
  299. class Marshalls : public Object {
  300. GDCLASS(Marshalls, Object);
  301. static Marshalls *singleton;
  302. protected:
  303. static void _bind_methods();
  304. public:
  305. static Marshalls *get_singleton();
  306. String variant_to_base64(const Variant &p_var, bool p_full_objects = false);
  307. Variant base64_to_variant(const String &p_str, bool p_allow_objects = false);
  308. String raw_to_base64(const Vector<uint8_t> &p_arr);
  309. Vector<uint8_t> base64_to_raw(const String &p_str);
  310. String utf8_to_base64(const String &p_str);
  311. String base64_to_utf8(const String &p_str);
  312. Marshalls() { singleton = this; }
  313. ~Marshalls() { singleton = nullptr; }
  314. };
  315. class Mutex : public RefCounted {
  316. GDCLASS(Mutex, RefCounted);
  317. ::Mutex mutex;
  318. static void _bind_methods();
  319. public:
  320. void lock();
  321. bool try_lock();
  322. void unlock();
  323. };
  324. class Semaphore : public RefCounted {
  325. GDCLASS(Semaphore, RefCounted);
  326. ::Semaphore semaphore;
  327. protected:
  328. static void _bind_methods();
  329. #ifndef DISABLE_DEPRECATED
  330. void _post_bind_compat_93605();
  331. static void _bind_compatibility_methods();
  332. #endif // DISABLE_DEPRECATED
  333. public:
  334. void wait();
  335. bool try_wait();
  336. void post(int p_count = 1);
  337. };
  338. class Thread : public RefCounted {
  339. GDCLASS(Thread, RefCounted);
  340. protected:
  341. Variant ret;
  342. SafeFlag running;
  343. Callable target_callable;
  344. ::Thread thread;
  345. static void _bind_methods();
  346. static void _start_func(void *ud);
  347. public:
  348. enum Priority {
  349. PRIORITY_LOW,
  350. PRIORITY_NORMAL,
  351. PRIORITY_HIGH,
  352. PRIORITY_MAX
  353. };
  354. Error start(const Callable &p_callable, Priority p_priority = PRIORITY_NORMAL);
  355. String get_id() const;
  356. bool is_started() const;
  357. bool is_alive() const;
  358. Variant wait_to_finish();
  359. static void set_thread_safety_checks_enabled(bool p_enabled);
  360. };
  361. namespace Special {
  362. class ClassDB : public Object {
  363. GDCLASS(ClassDB, Object);
  364. protected:
  365. static void _bind_methods();
  366. public:
  367. enum APIType {
  368. API_CORE,
  369. API_EDITOR,
  370. API_EXTENSION,
  371. API_EDITOR_EXTENSION,
  372. API_NONE,
  373. };
  374. PackedStringArray get_class_list() const;
  375. PackedStringArray get_inheriters_from_class(const StringName &p_class) const;
  376. StringName get_parent_class(const StringName &p_class) const;
  377. bool class_exists(const StringName &p_class) const;
  378. bool is_parent_class(const StringName &p_class, const StringName &p_inherits) const;
  379. bool can_instantiate(const StringName &p_class) const;
  380. Variant instantiate(const StringName &p_class) const;
  381. APIType class_get_api_type(const StringName &p_class) const;
  382. bool class_has_signal(const StringName &p_class, const StringName &p_signal) const;
  383. Dictionary class_get_signal(const StringName &p_class, const StringName &p_signal) const;
  384. TypedArray<Dictionary> class_get_signal_list(const StringName &p_class, bool p_no_inheritance = false) const;
  385. TypedArray<Dictionary> class_get_property_list(const StringName &p_class, bool p_no_inheritance = false) const;
  386. StringName class_get_property_getter(const StringName &p_class, const StringName &p_property);
  387. StringName class_get_property_setter(const StringName &p_class, const StringName &p_property);
  388. Variant class_get_property(Object *p_object, const StringName &p_property) const;
  389. Error class_set_property(Object *p_object, const StringName &p_property, const Variant &p_value) const;
  390. Variant class_get_property_default_value(const StringName &p_class, const StringName &p_property) const;
  391. bool class_has_method(const StringName &p_class, const StringName &p_method, bool p_no_inheritance = false) const;
  392. int class_get_method_argument_count(const StringName &p_class, const StringName &p_method, bool p_no_inheritance = false) const;
  393. TypedArray<Dictionary> class_get_method_list(const StringName &p_class, bool p_no_inheritance = false) const;
  394. Variant class_call_static(const Variant **p_arguments, int p_argcount, Callable::CallError &r_call_error);
  395. PackedStringArray class_get_integer_constant_list(const StringName &p_class, bool p_no_inheritance = false) const;
  396. bool class_has_integer_constant(const StringName &p_class, const StringName &p_name) const;
  397. int64_t class_get_integer_constant(const StringName &p_class, const StringName &p_name) const;
  398. bool class_has_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false) const;
  399. PackedStringArray class_get_enum_list(const StringName &p_class, bool p_no_inheritance = false) const;
  400. PackedStringArray class_get_enum_constants(const StringName &p_class, const StringName &p_enum, bool p_no_inheritance = false) const;
  401. StringName class_get_integer_constant_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false) const;
  402. bool is_class_enum_bitfield(const StringName &p_class, const StringName &p_enum, bool p_no_inheritance = false) const;
  403. bool is_class_enabled(const StringName &p_class) const;
  404. #ifdef TOOLS_ENABLED
  405. virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
  406. #endif
  407. ClassDB() {}
  408. ~ClassDB() {}
  409. };
  410. } // namespace Special
  411. class Engine : public Object {
  412. GDCLASS(Engine, Object);
  413. protected:
  414. static void _bind_methods();
  415. static Engine *singleton;
  416. public:
  417. static Engine *get_singleton() { return singleton; }
  418. void set_physics_ticks_per_second(int p_ips);
  419. int get_physics_ticks_per_second() const;
  420. void set_max_physics_steps_per_frame(int p_max_physics_steps);
  421. int get_max_physics_steps_per_frame() const;
  422. void set_physics_jitter_fix(double p_threshold);
  423. double get_physics_jitter_fix() const;
  424. double get_physics_interpolation_fraction() const;
  425. void set_max_fps(int p_fps);
  426. int get_max_fps() const;
  427. double get_frames_per_second() const;
  428. uint64_t get_physics_frames() const;
  429. uint64_t get_process_frames() const;
  430. int get_frames_drawn();
  431. void set_time_scale(double p_scale);
  432. double get_time_scale();
  433. MainLoop *get_main_loop() const;
  434. Dictionary get_version_info() const;
  435. Dictionary get_author_info() const;
  436. TypedArray<Dictionary> get_copyright_info() const;
  437. Dictionary get_donor_info() const;
  438. Dictionary get_license_info() const;
  439. String get_license_text() const;
  440. String get_architecture_name() const;
  441. bool is_in_physics_frame() const;
  442. bool has_singleton(const StringName &p_name) const;
  443. Object *get_singleton_object(const StringName &p_name) const;
  444. void register_singleton(const StringName &p_name, Object *p_object);
  445. void unregister_singleton(const StringName &p_name);
  446. Vector<String> get_singleton_list() const;
  447. Error register_script_language(ScriptLanguage *p_language);
  448. Error unregister_script_language(const ScriptLanguage *p_language);
  449. int get_script_language_count();
  450. ScriptLanguage *get_script_language(int p_index) const;
  451. void set_editor_hint(bool p_enabled);
  452. bool is_editor_hint() const;
  453. bool is_embedded_in_editor() const;
  454. // `set_write_movie_path()` is not exposed to the scripting API as changing it at run-time has no effect.
  455. String get_write_movie_path() const;
  456. void set_print_to_stdout(bool p_enabled);
  457. bool is_printing_to_stdout() const;
  458. void set_print_error_messages(bool p_enabled);
  459. bool is_printing_error_messages() const;
  460. #ifdef TOOLS_ENABLED
  461. virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
  462. #endif
  463. Engine() { singleton = this; }
  464. };
  465. class EngineDebugger : public Object {
  466. GDCLASS(EngineDebugger, Object);
  467. HashMap<StringName, Callable> captures;
  468. HashMap<StringName, Ref<EngineProfiler>> profilers;
  469. protected:
  470. static void _bind_methods();
  471. static EngineDebugger *singleton;
  472. public:
  473. static EngineDebugger *get_singleton() { return singleton; }
  474. bool is_active();
  475. void register_profiler(const StringName &p_name, Ref<EngineProfiler> p_profiler);
  476. void unregister_profiler(const StringName &p_name);
  477. bool is_profiling(const StringName &p_name);
  478. bool has_profiler(const StringName &p_name);
  479. void profiler_add_frame_data(const StringName &p_name, const Array &p_data);
  480. void profiler_enable(const StringName &p_name, bool p_enabled, const Array &p_opts = Array());
  481. void register_message_capture(const StringName &p_name, const Callable &p_callable);
  482. void unregister_message_capture(const StringName &p_name);
  483. bool has_capture(const StringName &p_name);
  484. void send_message(const String &p_msg, const Array &p_data);
  485. void debug(bool p_can_continue = true, bool p_is_error_breakpoint = false);
  486. void script_debug(ScriptLanguage *p_lang, bool p_can_continue = true, bool p_is_error_breakpoint = false);
  487. static Error call_capture(void *p_user, const String &p_cmd, const Array &p_data, bool &r_captured);
  488. void line_poll();
  489. void set_lines_left(int p_lines);
  490. int get_lines_left() const;
  491. void set_depth(int p_depth);
  492. int get_depth() const;
  493. bool is_breakpoint(int p_line, const StringName &p_source) const;
  494. bool is_skipping_breakpoints() const;
  495. void insert_breakpoint(int p_line, const StringName &p_source);
  496. void remove_breakpoint(int p_line, const StringName &p_source);
  497. void clear_breakpoints();
  498. EngineDebugger() { singleton = this; }
  499. ~EngineDebugger();
  500. };
  501. } // namespace CoreBind
  502. VARIANT_ENUM_CAST(CoreBind::ResourceLoader::ThreadLoadStatus);
  503. VARIANT_ENUM_CAST(CoreBind::ResourceLoader::CacheMode);
  504. VARIANT_BITFIELD_CAST(CoreBind::ResourceSaver::SaverFlags);
  505. VARIANT_ENUM_CAST(CoreBind::OS::RenderingDriver);
  506. VARIANT_ENUM_CAST(CoreBind::OS::SystemDir);
  507. VARIANT_ENUM_CAST(CoreBind::OS::StdHandleType);
  508. VARIANT_ENUM_CAST(CoreBind::Geometry2D::PolyBooleanOperation);
  509. VARIANT_ENUM_CAST(CoreBind::Geometry2D::PolyJoinType);
  510. VARIANT_ENUM_CAST(CoreBind::Geometry2D::PolyEndType);
  511. VARIANT_ENUM_CAST(CoreBind::Thread::Priority);
  512. VARIANT_ENUM_CAST(CoreBind::Special::ClassDB::APIType);