core_bind.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  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. #ifndef CORE_BIND_H
  31. #define CORE_BIND_H
  32. #include "core/debugger/engine_profiler.h"
  33. #include "core/io/image.h"
  34. #include "core/io/resource_loader.h"
  35. #include "core/io/resource_saver.h"
  36. #include "core/object/script_language.h"
  37. #include "core/os/os.h"
  38. #include "core/os/semaphore.h"
  39. #include "core/os/thread.h"
  40. #include "core/templates/safe_refcount.h"
  41. class MainLoop;
  42. template <typename T>
  43. class TypedArray;
  44. namespace core_bind {
  45. class ResourceLoader : public Object {
  46. GDCLASS(ResourceLoader, Object);
  47. protected:
  48. static void _bind_methods();
  49. static ResourceLoader *singleton;
  50. public:
  51. enum ThreadLoadStatus {
  52. THREAD_LOAD_INVALID_RESOURCE,
  53. THREAD_LOAD_IN_PROGRESS,
  54. THREAD_LOAD_FAILED,
  55. THREAD_LOAD_LOADED
  56. };
  57. enum CacheMode {
  58. CACHE_MODE_IGNORE,
  59. CACHE_MODE_REUSE,
  60. CACHE_MODE_REPLACE,
  61. CACHE_MODE_IGNORE_DEEP,
  62. CACHE_MODE_REPLACE_DEEP,
  63. };
  64. static ResourceLoader *get_singleton() { return singleton; }
  65. 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);
  66. ThreadLoadStatus load_threaded_get_status(const String &p_path, Array r_progress = Array());
  67. Ref<Resource> load_threaded_get(const String &p_path);
  68. Ref<Resource> load(const String &p_path, const String &p_type_hint = "", CacheMode p_cache_mode = CACHE_MODE_REUSE);
  69. Vector<String> get_recognized_extensions_for_type(const String &p_type);
  70. void add_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader, bool p_at_front);
  71. void remove_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader);
  72. void set_abort_on_missing_resources(bool p_abort);
  73. PackedStringArray get_dependencies(const String &p_path);
  74. bool has_cached(const String &p_path);
  75. bool exists(const String &p_path, const String &p_type_hint = "");
  76. ResourceUID::ID get_resource_uid(const String &p_path);
  77. ResourceLoader() { singleton = this; }
  78. };
  79. class ResourceSaver : public Object {
  80. GDCLASS(ResourceSaver, Object);
  81. protected:
  82. static void _bind_methods();
  83. static ResourceSaver *singleton;
  84. public:
  85. enum SaverFlags {
  86. FLAG_NONE = 0,
  87. FLAG_RELATIVE_PATHS = 1,
  88. FLAG_BUNDLE_RESOURCES = 2,
  89. FLAG_CHANGE_PATH = 4,
  90. FLAG_OMIT_EDITOR_PROPERTIES = 8,
  91. FLAG_SAVE_BIG_ENDIAN = 16,
  92. FLAG_COMPRESS = 32,
  93. FLAG_REPLACE_SUBRESOURCE_PATHS = 64,
  94. };
  95. static ResourceSaver *get_singleton() { return singleton; }
  96. Error save(const Ref<Resource> &p_resource, const String &p_path, BitField<SaverFlags> p_flags);
  97. Vector<String> get_recognized_extensions(const Ref<Resource> &p_resource);
  98. void add_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver, bool p_at_front);
  99. void remove_resource_format_saver(Ref<ResourceFormatSaver> p_format_saver);
  100. ResourceSaver() { singleton = this; }
  101. };
  102. class OS : public Object {
  103. GDCLASS(OS, Object);
  104. mutable HashMap<String, bool> feature_cache;
  105. protected:
  106. static void _bind_methods();
  107. static OS *singleton;
  108. public:
  109. enum RenderingDriver {
  110. RENDERING_DRIVER_VULKAN,
  111. RENDERING_DRIVER_OPENGL3,
  112. RENDERING_DRIVER_D3D12,
  113. };
  114. PackedByteArray get_entropy(int p_bytes);
  115. String get_system_ca_certificates();
  116. virtual PackedStringArray get_connected_midi_inputs();
  117. virtual void open_midi_inputs();
  118. virtual void close_midi_inputs();
  119. void set_low_processor_usage_mode(bool p_enabled);
  120. bool is_in_low_processor_usage_mode() const;
  121. void set_low_processor_usage_mode_sleep_usec(int p_usec);
  122. int get_low_processor_usage_mode_sleep_usec() const;
  123. void set_delta_smoothing(bool p_enabled);
  124. bool is_delta_smoothing_enabled() const;
  125. void alert(const String &p_alert, const String &p_title = "ALERT!");
  126. void crash(const String &p_message);
  127. Vector<String> get_system_fonts() const;
  128. String get_system_font_path(const String &p_font_name, int p_weight = 400, int p_stretch = 100, bool p_italic = false) const;
  129. 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;
  130. String get_executable_path() const;
  131. String read_string_from_stdin();
  132. int execute(const String &p_path, const Vector<String> &p_arguments, Array r_output = Array(), bool p_read_stderr = false, bool p_open_console = false);
  133. Dictionary execute_with_pipe(const String &p_path, const Vector<String> &p_arguments);
  134. int create_process(const String &p_path, const Vector<String> &p_arguments, bool p_open_console = false);
  135. int create_instance(const Vector<String> &p_arguments);
  136. Error kill(int p_pid);
  137. Error shell_open(const String &p_uri);
  138. Error shell_show_in_file_manager(const String &p_path, bool p_open_folder = true);
  139. bool is_process_running(int p_pid) const;
  140. int get_process_exit_code(int p_pid) const;
  141. int get_process_id() const;
  142. void set_restart_on_exit(bool p_restart, const Vector<String> &p_restart_arguments = Vector<String>());
  143. bool is_restart_on_exit_set() const;
  144. Vector<String> get_restart_on_exit_arguments() const;
  145. bool has_environment(const String &p_var) const;
  146. String get_environment(const String &p_var) const;
  147. void set_environment(const String &p_var, const String &p_value) const;
  148. void unset_environment(const String &p_var) const;
  149. String get_name() const;
  150. String get_distribution_name() const;
  151. String get_version() const;
  152. Vector<String> get_cmdline_args();
  153. Vector<String> get_cmdline_user_args();
  154. Vector<String> get_video_adapter_driver_info() const;
  155. String get_locale() const;
  156. String get_locale_language() const;
  157. String get_model_name() const;
  158. bool is_debug_build() const;
  159. String get_unique_id() const;
  160. String get_keycode_string(Key p_code) const;
  161. bool is_keycode_unicode(char32_t p_unicode) const;
  162. Key find_keycode_from_string(const String &p_code) const;
  163. void set_use_file_access_save_and_swap(bool p_enable);
  164. uint64_t get_static_memory_usage() const;
  165. uint64_t get_static_memory_peak_usage() const;
  166. Dictionary get_memory_info() const;
  167. void delay_usec(int p_usec) const;
  168. void delay_msec(int p_msec) const;
  169. uint64_t get_ticks_msec() const;
  170. uint64_t get_ticks_usec() const;
  171. bool is_userfs_persistent() const;
  172. bool is_stdout_verbose() const;
  173. int get_processor_count() const;
  174. String get_processor_name() const;
  175. enum SystemDir {
  176. SYSTEM_DIR_DESKTOP,
  177. SYSTEM_DIR_DCIM,
  178. SYSTEM_DIR_DOCUMENTS,
  179. SYSTEM_DIR_DOWNLOADS,
  180. SYSTEM_DIR_MOVIES,
  181. SYSTEM_DIR_MUSIC,
  182. SYSTEM_DIR_PICTURES,
  183. SYSTEM_DIR_RINGTONES,
  184. };
  185. String get_system_dir(SystemDir p_dir, bool p_shared_storage = true) const;
  186. Error move_to_trash(const String &p_path) const;
  187. String get_user_data_dir() const;
  188. String get_config_dir() const;
  189. String get_data_dir() const;
  190. String get_cache_dir() const;
  191. Error set_thread_name(const String &p_name);
  192. ::Thread::ID get_thread_caller_id() const;
  193. ::Thread::ID get_main_thread_id() const;
  194. bool has_feature(const String &p_feature) const;
  195. bool is_sandboxed() const;
  196. bool request_permission(const String &p_name);
  197. bool request_permissions();
  198. Vector<String> get_granted_permissions() const;
  199. void revoke_granted_permissions();
  200. static OS *get_singleton() { return singleton; }
  201. OS() { singleton = this; }
  202. };
  203. class Geometry2D : public Object {
  204. GDCLASS(Geometry2D, Object);
  205. static Geometry2D *singleton;
  206. protected:
  207. static void _bind_methods();
  208. public:
  209. static Geometry2D *get_singleton();
  210. Variant segment_intersects_segment(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b);
  211. Variant line_intersects_line(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b);
  212. Vector<Vector2> get_closest_points_between_segments(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2);
  213. Vector2 get_closest_point_to_segment(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
  214. Vector2 get_closest_point_to_segment_uncapped(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
  215. bool point_is_inside_triangle(const Vector2 &s, const Vector2 &a, const Vector2 &b, const Vector2 &c) const;
  216. bool is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius);
  217. real_t segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius);
  218. bool is_polygon_clockwise(const Vector<Vector2> &p_polygon);
  219. bool is_point_in_polygon(const Point2 &p_point, const Vector<Vector2> &p_polygon);
  220. Vector<int> triangulate_polygon(const Vector<Vector2> &p_polygon);
  221. Vector<int> triangulate_delaunay(const Vector<Vector2> &p_points);
  222. Vector<Point2> convex_hull(const Vector<Point2> &p_points);
  223. TypedArray<PackedVector2Array> decompose_polygon_in_convex(const Vector<Vector2> &p_polygon);
  224. enum PolyBooleanOperation {
  225. OPERATION_UNION,
  226. OPERATION_DIFFERENCE,
  227. OPERATION_INTERSECTION,
  228. OPERATION_XOR
  229. };
  230. // 2D polygon boolean operations.
  231. TypedArray<PackedVector2Array> merge_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Union (add).
  232. TypedArray<PackedVector2Array> clip_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Difference (subtract).
  233. TypedArray<PackedVector2Array> intersect_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Common area (multiply).
  234. TypedArray<PackedVector2Array> exclude_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // All but common area (xor).
  235. // 2D polyline vs polygon operations.
  236. TypedArray<PackedVector2Array> clip_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Cut.
  237. TypedArray<PackedVector2Array> intersect_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Chop.
  238. // 2D offset polygons/polylines.
  239. enum PolyJoinType {
  240. JOIN_SQUARE,
  241. JOIN_ROUND,
  242. JOIN_MITER
  243. };
  244. enum PolyEndType {
  245. END_POLYGON,
  246. END_JOINED,
  247. END_BUTT,
  248. END_SQUARE,
  249. END_ROUND
  250. };
  251. TypedArray<PackedVector2Array> offset_polygon(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE);
  252. 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);
  253. Dictionary make_atlas(const Vector<Size2> &p_rects);
  254. Geometry2D() { singleton = this; }
  255. };
  256. class Geometry3D : public Object {
  257. GDCLASS(Geometry3D, Object);
  258. static Geometry3D *singleton;
  259. protected:
  260. static void _bind_methods();
  261. public:
  262. static Geometry3D *get_singleton();
  263. Vector<Vector3> compute_convex_mesh_points(const TypedArray<Plane> &p_planes);
  264. TypedArray<Plane> build_box_planes(const Vector3 &p_extents);
  265. TypedArray<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis = Vector3::AXIS_Z);
  266. TypedArray<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z);
  267. Vector<Vector3> get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2);
  268. Vector3 get_closest_point_to_segment(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
  269. Vector3 get_closest_point_to_segment_uncapped(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
  270. Vector3 get_triangle_barycentric_coords(const Vector3 &p_point, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
  271. Variant ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
  272. Variant segment_intersects_triangle(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
  273. Vector<Vector3> segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius);
  274. Vector<Vector3> segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius);
  275. Vector<Vector3> segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const TypedArray<Plane> &p_planes);
  276. Vector<Vector3> clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane);
  277. Vector<int32_t> tetrahedralize_delaunay(const Vector<Vector3> &p_points);
  278. Geometry3D() { singleton = this; }
  279. };
  280. class Marshalls : public Object {
  281. GDCLASS(Marshalls, Object);
  282. static Marshalls *singleton;
  283. protected:
  284. static void _bind_methods();
  285. public:
  286. static Marshalls *get_singleton();
  287. String variant_to_base64(const Variant &p_var, bool p_full_objects = false);
  288. Variant base64_to_variant(const String &p_str, bool p_allow_objects = false);
  289. String raw_to_base64(const Vector<uint8_t> &p_arr);
  290. Vector<uint8_t> base64_to_raw(const String &p_str);
  291. String utf8_to_base64(const String &p_str);
  292. String base64_to_utf8(const String &p_str);
  293. Marshalls() { singleton = this; }
  294. ~Marshalls() { singleton = nullptr; }
  295. };
  296. class Mutex : public RefCounted {
  297. GDCLASS(Mutex, RefCounted);
  298. ::Mutex mutex;
  299. static void _bind_methods();
  300. public:
  301. void lock();
  302. bool try_lock();
  303. void unlock();
  304. };
  305. class Semaphore : public RefCounted {
  306. GDCLASS(Semaphore, RefCounted);
  307. ::Semaphore semaphore;
  308. static void _bind_methods();
  309. public:
  310. void wait();
  311. bool try_wait();
  312. void post();
  313. };
  314. class Thread : public RefCounted {
  315. GDCLASS(Thread, RefCounted);
  316. protected:
  317. Variant ret;
  318. SafeFlag running;
  319. Callable target_callable;
  320. ::Thread thread;
  321. static void _bind_methods();
  322. static void _start_func(void *ud);
  323. public:
  324. enum Priority {
  325. PRIORITY_LOW,
  326. PRIORITY_NORMAL,
  327. PRIORITY_HIGH,
  328. PRIORITY_MAX
  329. };
  330. Error start(const Callable &p_callable, Priority p_priority = PRIORITY_NORMAL);
  331. String get_id() const;
  332. bool is_started() const;
  333. bool is_alive() const;
  334. Variant wait_to_finish();
  335. static void set_thread_safety_checks_enabled(bool p_enabled);
  336. };
  337. namespace special {
  338. class ClassDB : public Object {
  339. GDCLASS(ClassDB, Object);
  340. protected:
  341. static void _bind_methods();
  342. public:
  343. PackedStringArray get_class_list() const;
  344. PackedStringArray get_inheriters_from_class(const StringName &p_class) const;
  345. StringName get_parent_class(const StringName &p_class) const;
  346. bool class_exists(const StringName &p_class) const;
  347. bool is_parent_class(const StringName &p_class, const StringName &p_inherits) const;
  348. bool can_instantiate(const StringName &p_class) const;
  349. Variant instantiate(const StringName &p_class) const;
  350. bool class_has_signal(const StringName &p_class, const StringName &p_signal) const;
  351. Dictionary class_get_signal(const StringName &p_class, const StringName &p_signal) const;
  352. TypedArray<Dictionary> class_get_signal_list(const StringName &p_class, bool p_no_inheritance = false) const;
  353. TypedArray<Dictionary> class_get_property_list(const StringName &p_class, bool p_no_inheritance = false) const;
  354. Variant class_get_property(Object *p_object, const StringName &p_property) const;
  355. Error class_set_property(Object *p_object, const StringName &p_property, const Variant &p_value) const;
  356. Variant class_get_property_default_value(const StringName &p_class, const StringName &p_property) const;
  357. bool class_has_method(const StringName &p_class, const StringName &p_method, bool p_no_inheritance = false) const;
  358. int class_get_method_argument_count(const StringName &p_class, const StringName &p_method, bool p_no_inheritance = false) const;
  359. TypedArray<Dictionary> class_get_method_list(const StringName &p_class, bool p_no_inheritance = false) const;
  360. PackedStringArray class_get_integer_constant_list(const StringName &p_class, bool p_no_inheritance = false) const;
  361. bool class_has_integer_constant(const StringName &p_class, const StringName &p_name) const;
  362. int64_t class_get_integer_constant(const StringName &p_class, const StringName &p_name) const;
  363. bool class_has_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false) const;
  364. PackedStringArray class_get_enum_list(const StringName &p_class, bool p_no_inheritance = false) const;
  365. PackedStringArray class_get_enum_constants(const StringName &p_class, const StringName &p_enum, bool p_no_inheritance = false) const;
  366. StringName class_get_integer_constant_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false) const;
  367. bool is_class_enum_bitfield(const StringName &p_class, const StringName &p_enum, bool p_no_inheritance = false) const;
  368. bool is_class_enabled(const StringName &p_class) const;
  369. #ifdef TOOLS_ENABLED
  370. virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
  371. #endif
  372. ClassDB() {}
  373. ~ClassDB() {}
  374. };
  375. } // namespace special
  376. class Engine : public Object {
  377. GDCLASS(Engine, Object);
  378. protected:
  379. static void _bind_methods();
  380. static Engine *singleton;
  381. public:
  382. static Engine *get_singleton() { return singleton; }
  383. void set_physics_ticks_per_second(int p_ips);
  384. int get_physics_ticks_per_second() const;
  385. void set_max_physics_steps_per_frame(int p_max_physics_steps);
  386. int get_max_physics_steps_per_frame() const;
  387. void set_physics_jitter_fix(double p_threshold);
  388. double get_physics_jitter_fix() const;
  389. double get_physics_interpolation_fraction() const;
  390. void set_max_fps(int p_fps);
  391. int get_max_fps() const;
  392. double get_frames_per_second() const;
  393. uint64_t get_physics_frames() const;
  394. uint64_t get_process_frames() const;
  395. int get_frames_drawn();
  396. void set_time_scale(double p_scale);
  397. double get_time_scale();
  398. MainLoop *get_main_loop() const;
  399. Dictionary get_version_info() const;
  400. Dictionary get_author_info() const;
  401. TypedArray<Dictionary> get_copyright_info() const;
  402. Dictionary get_donor_info() const;
  403. Dictionary get_license_info() const;
  404. String get_license_text() const;
  405. String get_architecture_name() const;
  406. bool is_in_physics_frame() const;
  407. bool has_singleton(const StringName &p_name) const;
  408. Object *get_singleton_object(const StringName &p_name) const;
  409. void register_singleton(const StringName &p_name, Object *p_object);
  410. void unregister_singleton(const StringName &p_name);
  411. Vector<String> get_singleton_list() const;
  412. Error register_script_language(ScriptLanguage *p_language);
  413. Error unregister_script_language(const ScriptLanguage *p_language);
  414. int get_script_language_count();
  415. ScriptLanguage *get_script_language(int p_index) const;
  416. void set_editor_hint(bool p_enabled);
  417. bool is_editor_hint() const;
  418. // `set_write_movie_path()` is not exposed to the scripting API as changing it at run-time has no effect.
  419. String get_write_movie_path() const;
  420. void set_print_error_messages(bool p_enabled);
  421. bool is_printing_error_messages() const;
  422. #ifdef TOOLS_ENABLED
  423. virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
  424. #endif
  425. Engine() { singleton = this; }
  426. };
  427. class EngineDebugger : public Object {
  428. GDCLASS(EngineDebugger, Object);
  429. HashMap<StringName, Callable> captures;
  430. HashMap<StringName, Ref<EngineProfiler>> profilers;
  431. protected:
  432. static void _bind_methods();
  433. static EngineDebugger *singleton;
  434. public:
  435. static EngineDebugger *get_singleton() { return singleton; }
  436. bool is_active();
  437. void register_profiler(const StringName &p_name, Ref<EngineProfiler> p_profiler);
  438. void unregister_profiler(const StringName &p_name);
  439. bool is_profiling(const StringName &p_name);
  440. bool has_profiler(const StringName &p_name);
  441. void profiler_add_frame_data(const StringName &p_name, const Array &p_data);
  442. void profiler_enable(const StringName &p_name, bool p_enabled, const Array &p_opts = Array());
  443. void register_message_capture(const StringName &p_name, const Callable &p_callable);
  444. void unregister_message_capture(const StringName &p_name);
  445. bool has_capture(const StringName &p_name);
  446. void send_message(const String &p_msg, const Array &p_data);
  447. void debug(bool p_can_continue = true, bool p_is_error_breakpoint = false);
  448. void script_debug(ScriptLanguage *p_lang, bool p_can_continue = true, bool p_is_error_breakpoint = false);
  449. static Error call_capture(void *p_user, const String &p_cmd, const Array &p_data, bool &r_captured);
  450. void line_poll();
  451. void set_lines_left(int p_lines);
  452. int get_lines_left() const;
  453. void set_depth(int p_depth);
  454. int get_depth() const;
  455. bool is_breakpoint(int p_line, const StringName &p_source) const;
  456. bool is_skipping_breakpoints() const;
  457. void insert_breakpoint(int p_line, const StringName &p_source);
  458. void remove_breakpoint(int p_line, const StringName &p_source);
  459. void clear_breakpoints();
  460. EngineDebugger() { singleton = this; }
  461. ~EngineDebugger();
  462. };
  463. } // namespace core_bind
  464. VARIANT_ENUM_CAST(core_bind::ResourceLoader::ThreadLoadStatus);
  465. VARIANT_ENUM_CAST(core_bind::ResourceLoader::CacheMode);
  466. VARIANT_BITFIELD_CAST(core_bind::ResourceSaver::SaverFlags);
  467. VARIANT_ENUM_CAST(core_bind::OS::RenderingDriver);
  468. VARIANT_ENUM_CAST(core_bind::OS::SystemDir);
  469. VARIANT_ENUM_CAST(core_bind::Geometry2D::PolyBooleanOperation);
  470. VARIANT_ENUM_CAST(core_bind::Geometry2D::PolyJoinType);
  471. VARIANT_ENUM_CAST(core_bind::Geometry2D::PolyEndType);
  472. VARIANT_ENUM_CAST(core_bind::Thread::Priority);
  473. #endif // CORE_BIND_H