core_bind.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738
  1. /*************************************************************************/
  2. /* core_bind.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
  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 "image.h"
  33. #include "io/compression.h"
  34. #include "io/resource_loader.h"
  35. #include "io/resource_saver.h"
  36. #include "os/dir_access.h"
  37. #include "os/file_access.h"
  38. #include "os/os.h"
  39. #include "os/semaphore.h"
  40. #include "os/thread.h"
  41. class _ResourceLoader : public Object {
  42. GDCLASS(_ResourceLoader, Object);
  43. protected:
  44. static void _bind_methods();
  45. static _ResourceLoader *singleton;
  46. public:
  47. static _ResourceLoader *get_singleton() { return singleton; }
  48. Ref<ResourceInteractiveLoader> load_interactive(const String &p_path, const String &p_type_hint = "");
  49. RES load(const String &p_path, const String &p_type_hint = "", bool p_no_cache = false);
  50. PoolVector<String> get_recognized_extensions_for_type(const String &p_type);
  51. void set_abort_on_missing_resources(bool p_abort);
  52. PoolStringArray get_dependencies(const String &p_path);
  53. bool has(const String &p_path);
  54. _ResourceLoader();
  55. };
  56. class _ResourceSaver : public Object {
  57. GDCLASS(_ResourceSaver, Object);
  58. protected:
  59. static void _bind_methods();
  60. static _ResourceSaver *singleton;
  61. public:
  62. enum SaverFlags {
  63. FLAG_RELATIVE_PATHS = 1,
  64. FLAG_BUNDLE_RESOURCES = 2,
  65. FLAG_CHANGE_PATH = 4,
  66. FLAG_OMIT_EDITOR_PROPERTIES = 8,
  67. FLAG_SAVE_BIG_ENDIAN = 16,
  68. FLAG_COMPRESS = 32,
  69. };
  70. static _ResourceSaver *get_singleton() { return singleton; }
  71. Error save(const String &p_path, const RES &p_resource, uint32_t p_flags);
  72. PoolVector<String> get_recognized_extensions(const RES &p_resource);
  73. _ResourceSaver();
  74. };
  75. VARIANT_ENUM_CAST(_ResourceSaver::SaverFlags);
  76. class MainLoop;
  77. class _OS : public Object {
  78. GDCLASS(_OS, Object);
  79. protected:
  80. static void _bind_methods();
  81. static _OS *singleton;
  82. public:
  83. enum PowerState {
  84. POWERSTATE_UNKNOWN, /**< cannot determine power status */
  85. POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */
  86. POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */
  87. POWERSTATE_CHARGING, /**< Plugged in, charging battery */
  88. POWERSTATE_CHARGED /**< Plugged in, battery charged */
  89. };
  90. enum Weekday {
  91. DAY_SUNDAY,
  92. DAY_MONDAY,
  93. DAY_TUESDAY,
  94. DAY_WEDNESDAY,
  95. DAY_THURSDAY,
  96. DAY_FRIDAY,
  97. DAY_SATURDAY
  98. };
  99. enum Month {
  100. /// Start at 1 to follow Windows SYSTEMTIME structure
  101. /// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
  102. MONTH_JANUARY = 1,
  103. MONTH_FEBRUARY,
  104. MONTH_MARCH,
  105. MONTH_APRIL,
  106. MONTH_MAY,
  107. MONTH_JUNE,
  108. MONTH_JULY,
  109. MONTH_AUGUST,
  110. MONTH_SEPTEMBER,
  111. MONTH_OCTOBER,
  112. MONTH_NOVEMBER,
  113. MONTH_DECEMBER
  114. };
  115. Point2 get_mouse_position() const;
  116. void set_window_title(const String &p_title);
  117. int get_mouse_button_state() const;
  118. void set_clipboard(const String &p_text);
  119. String get_clipboard() const;
  120. void set_video_mode(const Size2 &p_size, bool p_fullscreen, bool p_resizeable, int p_screen = 0);
  121. Size2 get_video_mode(int p_screen = 0) const;
  122. bool is_video_mode_fullscreen(int p_screen = 0) const;
  123. bool is_video_mode_resizable(int p_screen = 0) const;
  124. Array get_fullscreen_mode_list(int p_screen = 0) const;
  125. virtual int get_screen_count() const;
  126. virtual int get_current_screen() const;
  127. virtual void set_current_screen(int p_screen);
  128. virtual Point2 get_screen_position(int p_screen = -1) const;
  129. virtual Size2 get_screen_size(int p_screen = -1) const;
  130. virtual int get_screen_dpi(int p_screen = -1) const;
  131. virtual Point2 get_window_position() const;
  132. virtual void set_window_position(const Point2 &p_position);
  133. virtual Size2 get_window_size() const;
  134. virtual Size2 get_real_window_size() const;
  135. virtual Rect2 get_window_safe_area() const;
  136. virtual void set_window_size(const Size2 &p_size);
  137. virtual void set_window_fullscreen(bool p_enabled);
  138. virtual bool is_window_fullscreen() const;
  139. virtual void set_window_resizable(bool p_enabled);
  140. virtual bool is_window_resizable() const;
  141. virtual void set_window_minimized(bool p_enabled);
  142. virtual bool is_window_minimized() const;
  143. virtual void set_window_maximized(bool p_enabled);
  144. virtual bool is_window_maximized() const;
  145. virtual void set_window_always_on_top(bool p_enabled);
  146. virtual bool is_window_always_on_top() const;
  147. virtual void request_attention();
  148. virtual void center_window();
  149. virtual void set_borderless_window(bool p_borderless);
  150. virtual bool get_borderless_window() const;
  151. virtual void set_ime_position(const Point2 &p_pos);
  152. Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
  153. bool native_video_is_playing();
  154. void native_video_pause();
  155. void native_video_unpause();
  156. void native_video_stop();
  157. void set_low_processor_usage_mode(bool p_enabled);
  158. bool is_in_low_processor_usage_mode() const;
  159. String get_executable_path() const;
  160. int execute(const String &p_path, const Vector<String> &p_arguments, bool p_blocking, Array p_output = Array());
  161. Error kill(int p_pid);
  162. Error shell_open(String p_uri);
  163. int get_process_id() const;
  164. bool has_environment(const String &p_var) const;
  165. String get_environment(const String &p_var) const;
  166. String get_name() const;
  167. Vector<String> get_cmdline_args();
  168. String get_locale() const;
  169. String get_latin_keyboard_variant() const;
  170. String get_model_name() const;
  171. void dump_memory_to_file(const String &p_file);
  172. void dump_resources_to_file(const String &p_file);
  173. bool has_virtual_keyboard() const;
  174. void show_virtual_keyboard(const String &p_existing_text = "");
  175. void hide_virtual_keyboard();
  176. int get_virtual_keyboard_height();
  177. void print_resources_in_use(bool p_short = false);
  178. void print_all_resources(const String &p_to_file);
  179. void print_all_textures_by_size();
  180. void print_resources_by_type(const Vector<String> &p_types);
  181. bool has_touchscreen_ui_hint() const;
  182. bool is_debug_build() const;
  183. String get_unique_id() const;
  184. String get_scancode_string(uint32_t p_code) const;
  185. bool is_scancode_unicode(uint32_t p_unicode) const;
  186. int find_scancode_from_string(const String &p_code) const;
  187. /*
  188. struct Date {
  189. int year;
  190. Month month;
  191. int day;
  192. Weekday weekday;
  193. bool dst;
  194. };
  195. struct Time {
  196. int hour;
  197. int min;
  198. int sec;
  199. };
  200. */
  201. void set_use_file_access_save_and_swap(bool p_enable);
  202. void set_icon(const Ref<Image> &p_icon);
  203. int get_exit_code() const;
  204. void set_exit_code(int p_code);
  205. Dictionary get_date(bool utc) const;
  206. Dictionary get_time(bool utc) const;
  207. Dictionary get_datetime(bool utc) const;
  208. Dictionary get_datetime_from_unix_time(uint64_t unix_time_val) const;
  209. uint64_t get_unix_time_from_datetime(Dictionary datetime) const;
  210. Dictionary get_time_zone_info() const;
  211. uint64_t get_unix_time() const;
  212. uint64_t get_system_time_secs() const;
  213. int get_static_memory_usage() const;
  214. int get_static_memory_peak_usage() const;
  215. int get_dynamic_memory_usage() const;
  216. void delay_usec(uint32_t p_usec) const;
  217. void delay_msec(uint32_t p_msec) const;
  218. uint32_t get_ticks_msec() const;
  219. uint32_t get_splash_tick_msec() const;
  220. bool can_use_threads() const;
  221. bool can_draw() const;
  222. bool is_userfs_persistent() const;
  223. bool is_stdout_verbose() const;
  224. int get_processor_count() const;
  225. enum SystemDir {
  226. SYSTEM_DIR_DESKTOP,
  227. SYSTEM_DIR_DCIM,
  228. SYSTEM_DIR_DOCUMENTS,
  229. SYSTEM_DIR_DOWNLOADS,
  230. SYSTEM_DIR_MOVIES,
  231. SYSTEM_DIR_MUSIC,
  232. SYSTEM_DIR_PICTURES,
  233. SYSTEM_DIR_RINGTONES,
  234. };
  235. enum ScreenOrientation {
  236. SCREEN_ORIENTATION_LANDSCAPE,
  237. SCREEN_ORIENTATION_PORTRAIT,
  238. SCREEN_ORIENTATION_REVERSE_LANDSCAPE,
  239. SCREEN_ORIENTATION_REVERSE_PORTRAIT,
  240. SCREEN_ORIENTATION_SENSOR_LANDSCAPE,
  241. SCREEN_ORIENTATION_SENSOR_PORTRAIT,
  242. SCREEN_ORIENTATION_SENSOR,
  243. };
  244. String get_system_dir(SystemDir p_dir) const;
  245. String get_user_data_dir() const;
  246. void alert(const String &p_alert, const String &p_title = "ALERT!");
  247. void set_screen_orientation(ScreenOrientation p_orientation);
  248. ScreenOrientation get_screen_orientation() const;
  249. void set_keep_screen_on(bool p_enabled);
  250. bool is_keep_screen_on() const;
  251. bool is_ok_left_and_cancel_right() const;
  252. Error set_thread_name(const String &p_name);
  253. void set_use_vsync(bool p_enable);
  254. bool is_vsync_enabled() const;
  255. PowerState get_power_state();
  256. int get_power_seconds_left();
  257. int get_power_percent_left();
  258. bool has_feature(const String &p_feature) const;
  259. static _OS *get_singleton() { return singleton; }
  260. _OS();
  261. };
  262. VARIANT_ENUM_CAST(_OS::PowerState);
  263. VARIANT_ENUM_CAST(_OS::Weekday);
  264. VARIANT_ENUM_CAST(_OS::Month);
  265. VARIANT_ENUM_CAST(_OS::SystemDir);
  266. VARIANT_ENUM_CAST(_OS::ScreenOrientation);
  267. class _Geometry : public Object {
  268. GDCLASS(_Geometry, Object);
  269. static _Geometry *singleton;
  270. protected:
  271. static void _bind_methods();
  272. public:
  273. static _Geometry *get_singleton();
  274. PoolVector<Plane> build_box_planes(const Vector3 &p_extents);
  275. PoolVector<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis = Vector3::AXIS_Z);
  276. PoolVector<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z);
  277. Variant segment_intersects_segment_2d(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b);
  278. PoolVector<Vector2> get_closest_points_between_segments_2d(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2);
  279. PoolVector<Vector3> get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2);
  280. Vector2 get_closest_point_to_segment_2d(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
  281. Vector3 get_closest_point_to_segment(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
  282. Vector2 get_closest_point_to_segment_uncapped_2d(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
  283. Vector3 get_closest_point_to_segment_uncapped(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
  284. Variant ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
  285. Variant segment_intersects_triangle(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
  286. bool point_is_inside_triangle(const Vector2 &s, const Vector2 &a, const Vector2 &b, const Vector2 &c) const;
  287. PoolVector<Vector3> segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius);
  288. PoolVector<Vector3> segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius);
  289. PoolVector<Vector3> segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const Vector<Plane> &p_planes);
  290. real_t segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius);
  291. int get_uv84_normal_bit(const Vector3 &p_vector);
  292. Vector<int> triangulate_polygon(const Vector<Vector2> &p_polygon);
  293. Vector<Point2> convex_hull_2d(const Vector<Point2> &p_points);
  294. Vector<Vector3> clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane);
  295. Dictionary make_atlas(const Vector<Size2> &p_rects);
  296. _Geometry();
  297. };
  298. class _File : public Reference {
  299. GDCLASS(_File, Reference);
  300. FileAccess *f;
  301. bool eswap;
  302. protected:
  303. static void _bind_methods();
  304. public:
  305. enum ModeFlags {
  306. READ = 1,
  307. WRITE = 2,
  308. READ_WRITE = 3,
  309. WRITE_READ = 7,
  310. };
  311. enum CompressionMode {
  312. COMPRESSION_FASTLZ = Compression::MODE_FASTLZ,
  313. COMPRESSION_DEFLATE = Compression::MODE_DEFLATE,
  314. COMPRESSION_ZSTD = Compression::MODE_ZSTD,
  315. COMPRESSION_GZIP = Compression::MODE_GZIP
  316. };
  317. Error open_encrypted(const String &p_path, int p_mode_flags, const Vector<uint8_t> &p_key);
  318. Error open_encrypted_pass(const String &p_path, int p_mode_flags, const String &p_pass);
  319. Error open_compressed(const String &p_path, int p_mode_flags, int p_compress_mode = 0);
  320. Error open(const String &p_path, int p_mode_flags); ///< open a file
  321. void close(); ///< close a file
  322. bool is_open() const; ///< true when file is open
  323. String get_path() const; /// returns the path for the current open file
  324. String get_path_absolute() const; /// returns the absolute path for the current open file
  325. void seek(int64_t p_position); ///< seek to a given position
  326. void seek_end(int64_t p_position = 0); ///< seek from the end of file
  327. int64_t get_position() const; ///< get position in the file
  328. int64_t get_len() const; ///< get size of the file
  329. bool eof_reached() const; ///< reading passed EOF
  330. uint8_t get_8() const; ///< get a byte
  331. uint16_t get_16() const; ///< get 16 bits uint
  332. uint32_t get_32() const; ///< get 32 bits uint
  333. uint64_t get_64() const; ///< get 64 bits uint
  334. float get_float() const;
  335. double get_double() const;
  336. real_t get_real() const;
  337. Variant get_var() const;
  338. PoolVector<uint8_t> get_buffer(int p_length) const; ///< get an array of bytes
  339. String get_line() const;
  340. String get_as_text() const;
  341. String get_md5(const String &p_path) const;
  342. String get_sha256(const String &p_path) const;
  343. /**< use this for files WRITTEN in _big_ endian machines (ie, amiga/mac)
  344. * It's not about the current CPU type but file formats.
  345. * this flags get reset to false (little endian) on each open
  346. */
  347. void set_endian_swap(bool p_swap);
  348. bool get_endian_swap();
  349. Error get_error() const; ///< get last error
  350. void store_8(uint8_t p_dest); ///< store a byte
  351. void store_16(uint16_t p_dest); ///< store 16 bits uint
  352. void store_32(uint32_t p_dest); ///< store 32 bits uint
  353. void store_64(uint64_t p_dest); ///< store 64 bits uint
  354. void store_float(float p_dest);
  355. void store_double(double p_dest);
  356. void store_real(real_t p_real);
  357. void store_string(const String &p_string);
  358. void store_line(const String &p_string);
  359. virtual void store_pascal_string(const String &p_string);
  360. virtual String get_pascal_string();
  361. Vector<String> get_csv_line(String delim = ",") const;
  362. void store_buffer(const PoolVector<uint8_t> &p_buffer); ///< store an array of bytes
  363. void store_var(const Variant &p_var);
  364. bool file_exists(const String &p_name) const; ///< return true if a file exists
  365. uint64_t get_modified_time(const String &p_file) const;
  366. _File();
  367. virtual ~_File();
  368. };
  369. VARIANT_ENUM_CAST(_File::ModeFlags);
  370. VARIANT_ENUM_CAST(_File::CompressionMode);
  371. class _Directory : public Reference {
  372. GDCLASS(_Directory, Reference);
  373. DirAccess *d;
  374. protected:
  375. static void _bind_methods();
  376. public:
  377. Error open(const String &p_path);
  378. Error list_dir_begin(bool p_skip_navigational = false, bool p_skip_hidden = false); ///< This starts dir listing
  379. String get_next();
  380. bool current_is_dir() const;
  381. void list_dir_end(); ///<
  382. int get_drive_count();
  383. String get_drive(int p_drive);
  384. int get_current_drive();
  385. Error change_dir(String p_dir); ///< can be relative or absolute, return false on success
  386. String get_current_dir(); ///< return current dir location
  387. Error make_dir(String p_dir);
  388. Error make_dir_recursive(String p_dir);
  389. bool file_exists(String p_file);
  390. bool dir_exists(String p_dir);
  391. int get_space_left();
  392. Error copy(String p_from, String p_to);
  393. Error rename(String p_from, String p_to);
  394. Error remove(String p_name);
  395. _Directory();
  396. virtual ~_Directory();
  397. private:
  398. bool _list_skip_navigational;
  399. bool _list_skip_hidden;
  400. };
  401. class _Marshalls : public Reference {
  402. GDCLASS(_Marshalls, Reference);
  403. static _Marshalls *singleton;
  404. protected:
  405. static void _bind_methods();
  406. public:
  407. static _Marshalls *get_singleton();
  408. String variant_to_base64(const Variant &p_var);
  409. Variant base64_to_variant(const String &p_str);
  410. String raw_to_base64(const PoolVector<uint8_t> &p_arr);
  411. PoolVector<uint8_t> base64_to_raw(const String &p_str);
  412. String utf8_to_base64(const String &p_str);
  413. String base64_to_utf8(const String &p_str);
  414. _Marshalls() { singleton = this; }
  415. ~_Marshalls() { singleton = NULL; }
  416. };
  417. class _Mutex : public Reference {
  418. GDCLASS(_Mutex, Reference);
  419. Mutex *mutex;
  420. static void _bind_methods();
  421. public:
  422. void lock();
  423. Error try_lock();
  424. void unlock();
  425. _Mutex();
  426. ~_Mutex();
  427. };
  428. class _Semaphore : public Reference {
  429. GDCLASS(_Semaphore, Reference);
  430. Semaphore *semaphore;
  431. static void _bind_methods();
  432. public:
  433. Error wait();
  434. Error post();
  435. _Semaphore();
  436. ~_Semaphore();
  437. };
  438. class _Thread : public Reference {
  439. GDCLASS(_Thread, Reference);
  440. protected:
  441. Variant ret;
  442. Variant userdata;
  443. volatile bool active;
  444. Object *target_instance;
  445. StringName target_method;
  446. Thread *thread;
  447. static void _bind_methods();
  448. static void _start_func(void *ud);
  449. public:
  450. enum Priority {
  451. PRIORITY_LOW,
  452. PRIORITY_NORMAL,
  453. PRIORITY_HIGH
  454. };
  455. Error start(Object *p_instance, const StringName &p_method, const Variant &p_userdata = Variant(), int p_priority = PRIORITY_NORMAL);
  456. String get_id() const;
  457. bool is_active() const;
  458. Variant wait_to_finish();
  459. _Thread();
  460. ~_Thread();
  461. };
  462. VARIANT_ENUM_CAST(_Thread::Priority);
  463. class _ClassDB : public Object {
  464. GDCLASS(_ClassDB, Object)
  465. protected:
  466. static void _bind_methods();
  467. public:
  468. PoolStringArray get_class_list() const;
  469. PoolStringArray get_inheriters_from_class(const StringName &p_class) const;
  470. StringName get_parent_class(const StringName &p_class) const;
  471. bool class_exists(const StringName &p_class) const;
  472. bool is_parent_class(const StringName &p_class, const StringName &p_inherits) const;
  473. bool can_instance(const StringName &p_class) const;
  474. Variant instance(const StringName &p_class) const;
  475. bool has_signal(StringName p_class, StringName p_signal) const;
  476. Dictionary get_signal(StringName p_class, StringName p_signal) const;
  477. Array get_signal_list(StringName p_class, bool p_no_inheritance = false) const;
  478. Array get_property_list(StringName p_class, bool p_no_inheritance = false) const;
  479. Variant get_property(Object *p_object, const StringName &p_property) const;
  480. Error set_property(Object *p_object, const StringName &p_property, const Variant &p_value) const;
  481. bool has_method(StringName p_class, StringName p_method, bool p_no_inheritance = false) const;
  482. Array get_method_list(StringName p_class, bool p_no_inheritance = false) const;
  483. PoolStringArray get_integer_constant_list(const StringName &p_class, bool p_no_inheritance = false) const;
  484. bool has_integer_constant(const StringName &p_class, const StringName &p_name) const;
  485. int get_integer_constant(const StringName &p_class, const StringName &p_name) const;
  486. StringName get_category(const StringName &p_node) const;
  487. bool is_class_enabled(StringName p_class) const;
  488. _ClassDB();
  489. ~_ClassDB();
  490. };
  491. class _Engine : public Object {
  492. GDCLASS(_Engine, Object);
  493. protected:
  494. static void _bind_methods();
  495. static _Engine *singleton;
  496. public:
  497. static _Engine *get_singleton() { return singleton; }
  498. void set_iterations_per_second(int p_ips);
  499. int get_iterations_per_second() const;
  500. void set_target_fps(int p_fps);
  501. int get_target_fps() const;
  502. float get_frames_per_second() const;
  503. int get_frames_drawn();
  504. void set_time_scale(float p_scale);
  505. float get_time_scale();
  506. MainLoop *get_main_loop() const;
  507. Dictionary get_version_info() const;
  508. bool is_in_physics_frame() const;
  509. bool has_singleton(const String &p_name) const;
  510. Object *get_singleton_object(const String &p_name) const;
  511. void set_editor_hint(bool p_enabled);
  512. bool is_editor_hint() const;
  513. _Engine();
  514. };
  515. class _JSON;
  516. class JSONParseResult : public Reference {
  517. GDCLASS(JSONParseResult, Reference)
  518. friend class _JSON;
  519. Error error;
  520. String error_string;
  521. int error_line;
  522. Variant result;
  523. protected:
  524. static void _bind_methods();
  525. public:
  526. void set_error(Error p_error);
  527. Error get_error() const;
  528. void set_error_string(const String &p_error_string);
  529. String get_error_string() const;
  530. void set_error_line(int p_error_line);
  531. int get_error_line() const;
  532. void set_result(const Variant &p_result);
  533. Variant get_result() const;
  534. };
  535. class _JSON : public Object {
  536. GDCLASS(_JSON, Object)
  537. protected:
  538. static void _bind_methods();
  539. static _JSON *singleton;
  540. public:
  541. static _JSON *get_singleton() { return singleton; }
  542. String print(const Variant &p_value, const String &p_indent = "", bool p_sort_keys = false);
  543. Ref<JSONParseResult> parse(const String &p_json);
  544. _JSON();
  545. };
  546. #endif // CORE_BIND_H