core_bind.h 21 KB

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