summaryrefslogtreecommitdiff
path: root/core/bind
diff options
context:
space:
mode:
Diffstat (limited to 'core/bind')
-rw-r--r--core/bind/SCsub2
-rw-r--r--core/bind/core_bind.cpp1856
-rw-r--r--core/bind/core_bind.h393
3 files changed, 794 insertions, 1457 deletions
diff --git a/core/bind/SCsub b/core/bind/SCsub
index 1c5f954470..19a6549225 100644
--- a/core/bind/SCsub
+++ b/core/bind/SCsub
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-Import('env')
+Import("env")
env.add_source_files(env.core_sources, "*.cpp")
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index efd7e3dbf5..489ff762c9 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -31,11 +31,13 @@
#include "core_bind.h"
#include "core/crypto/crypto_core.h"
+#include "core/debugger/engine_debugger.h"
#include "core/io/file_access_compressed.h"
#include "core/io/file_access_encrypted.h"
#include "core/io/json.h"
#include "core/io/marshalls.h"
-#include "core/math/geometry.h"
+#include "core/math/geometry_2d.h"
+#include "core/math/geometry_3d.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "core/project_settings.h"
@@ -62,14 +64,29 @@ static const unsigned int MONTH_DAYS_TABLE[2][12] = {
{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
};
-_ResourceLoader *_ResourceLoader::singleton = NULL;
+////// _ResourceLoader //////
-Ref<ResourceInteractiveLoader> _ResourceLoader::load_interactive(const String &p_path, const String &p_type_hint) {
- return ResourceLoader::load_interactive(p_path, p_type_hint);
+_ResourceLoader *_ResourceLoader::singleton = nullptr;
+
+Error _ResourceLoader::load_threaded_request(const String &p_path, const String &p_type_hint, bool p_use_sub_threads) {
+ return ResourceLoader::load_threaded_request(p_path, p_type_hint, p_use_sub_threads);
}
-RES _ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p_no_cache) {
+_ResourceLoader::ThreadLoadStatus _ResourceLoader::load_threaded_get_status(const String &p_path, Array r_progress) {
+ float progress = 0;
+ ResourceLoader::ThreadLoadStatus tls = ResourceLoader::load_threaded_get_status(p_path, &progress);
+ r_progress.resize(1);
+ r_progress[0] = progress;
+ return (ThreadLoadStatus)tls;
+}
+RES _ResourceLoader::load_threaded_get(const String &p_path) {
+ Error error;
+ RES res = ResourceLoader::load_threaded_get(p_path, &error);
+ return res;
+}
+
+RES _ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p_no_cache) {
Error err = OK;
RES ret = ResourceLoader::load(p_path, p_type_hint, p_no_cache, &err);
@@ -77,13 +94,11 @@ RES _ResourceLoader::load(const String &p_path, const String &p_type_hint, bool
return ret;
}
-PoolVector<String> _ResourceLoader::get_recognized_extensions_for_type(const String &p_type) {
-
+Vector<String> _ResourceLoader::get_recognized_extensions_for_type(const String &p_type) {
List<String> exts;
ResourceLoader::get_recognized_extensions_for_type(p_type, &exts);
- PoolVector<String> ret;
+ Vector<String> ret;
for (List<String>::Element *E = exts.front(); E; E = E->next()) {
-
ret.push_back(E->get());
}
@@ -91,32 +106,22 @@ PoolVector<String> _ResourceLoader::get_recognized_extensions_for_type(const Str
}
void _ResourceLoader::set_abort_on_missing_resources(bool p_abort) {
-
ResourceLoader::set_abort_on_missing_resources(p_abort);
}
-PoolStringArray _ResourceLoader::get_dependencies(const String &p_path) {
-
+PackedStringArray _ResourceLoader::get_dependencies(const String &p_path) {
List<String> deps;
ResourceLoader::get_dependencies(p_path, &deps);
- PoolStringArray ret;
+ PackedStringArray ret;
for (List<String>::Element *E = deps.front(); E; E = E->next()) {
ret.push_back(E->get());
}
return ret;
-};
-
-#ifndef DISABLE_DEPRECATED
-bool _ResourceLoader::has(const String &p_path) {
- WARN_PRINTS("ResourceLoader.has() is deprecated, please replace it with the equivalent has_cached() or the new exists().");
- return has_cached(p_path);
}
-#endif // DISABLE_DEPRECATED
bool _ResourceLoader::has_cached(const String &p_path) {
-
String local_path = ProjectSettings::get_singleton()->localize_path(p_path);
return ResourceCache::has(local_path);
}
@@ -126,46 +131,44 @@ bool _ResourceLoader::exists(const String &p_path, const String &p_type_hint) {
}
void _ResourceLoader::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("load_threaded_request", "path", "type_hint", "use_sub_threads"), &_ResourceLoader::load_threaded_request, DEFVAL(""), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("load_threaded_get_status", "path", "progress"), &_ResourceLoader::load_threaded_get_status, DEFVAL(Array()));
+ ClassDB::bind_method(D_METHOD("load_threaded_get", "path"), &_ResourceLoader::load_threaded_get);
- ClassDB::bind_method(D_METHOD("load_interactive", "path", "type_hint"), &_ResourceLoader::load_interactive, DEFVAL(""));
ClassDB::bind_method(D_METHOD("load", "path", "type_hint", "no_cache"), &_ResourceLoader::load, DEFVAL(""), DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_recognized_extensions_for_type", "type"), &_ResourceLoader::get_recognized_extensions_for_type);
ClassDB::bind_method(D_METHOD("set_abort_on_missing_resources", "abort"), &_ResourceLoader::set_abort_on_missing_resources);
ClassDB::bind_method(D_METHOD("get_dependencies", "path"), &_ResourceLoader::get_dependencies);
ClassDB::bind_method(D_METHOD("has_cached", "path"), &_ResourceLoader::has_cached);
ClassDB::bind_method(D_METHOD("exists", "path", "type_hint"), &_ResourceLoader::exists, DEFVAL(""));
-#ifndef DISABLE_DEPRECATED
- ClassDB::bind_method(D_METHOD("has", "path"), &_ResourceLoader::has);
-#endif // DISABLE_DEPRECATED
-}
-
-_ResourceLoader::_ResourceLoader() {
- singleton = this;
+ BIND_ENUM_CONSTANT(THREAD_LOAD_INVALID_RESOURCE);
+ BIND_ENUM_CONSTANT(THREAD_LOAD_IN_PROGRESS);
+ BIND_ENUM_CONSTANT(THREAD_LOAD_FAILED);
+ BIND_ENUM_CONSTANT(THREAD_LOAD_LOADED);
}
+////// _ResourceSaver //////
+
Error _ResourceSaver::save(const String &p_path, const RES &p_resource, SaverFlags p_flags) {
ERR_FAIL_COND_V_MSG(p_resource.is_null(), ERR_INVALID_PARAMETER, "Can't save empty resource to path '" + String(p_path) + "'.");
return ResourceSaver::save(p_path, p_resource, p_flags);
}
-PoolVector<String> _ResourceSaver::get_recognized_extensions(const RES &p_resource) {
-
- ERR_FAIL_COND_V_MSG(p_resource.is_null(), PoolVector<String>(), "It's not a reference to a valid Resource object.");
+Vector<String> _ResourceSaver::get_recognized_extensions(const RES &p_resource) {
+ ERR_FAIL_COND_V_MSG(p_resource.is_null(), Vector<String>(), "It's not a reference to a valid Resource object.");
List<String> exts;
ResourceSaver::get_recognized_extensions(p_resource, &exts);
- PoolVector<String> ret;
+ Vector<String> ret;
for (List<String>::Element *E = exts.front(); E; E = E->next()) {
-
ret.push_back(E->get());
}
return ret;
}
-_ResourceSaver *_ResourceSaver::singleton = NULL;
+_ResourceSaver *_ResourceSaver::singleton = nullptr;
void _ResourceSaver::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("save", "path", "resource", "flags"), &_ResourceSaver::save, DEFVAL(0));
ClassDB::bind_method(D_METHOD("get_recognized_extensions", "type"), &_ResourceSaver::get_recognized_extensions);
@@ -178,88 +181,9 @@ void _ResourceSaver::_bind_methods() {
BIND_ENUM_CONSTANT(FLAG_REPLACE_SUBRESOURCE_PATHS);
}
-_ResourceSaver::_ResourceSaver() {
-
- singleton = this;
-}
-
-/////////////////OS
-
-void _OS::global_menu_add_item(const String &p_menu, const String &p_label, const Variant &p_signal, const Variant &p_meta) {
-
- OS::get_singleton()->global_menu_add_item(p_menu, p_label, p_signal, p_meta);
-}
-
-void _OS::global_menu_add_separator(const String &p_menu) {
-
- OS::get_singleton()->global_menu_add_separator(p_menu);
-}
-
-void _OS::global_menu_remove_item(const String &p_menu, int p_idx) {
-
- OS::get_singleton()->global_menu_remove_item(p_menu, p_idx);
-}
-
-void _OS::global_menu_clear(const String &p_menu) {
-
- OS::get_singleton()->global_menu_clear(p_menu);
-}
-
-Point2 _OS::get_mouse_position() const {
-
- return OS::get_singleton()->get_mouse_position();
-}
-
-void _OS::set_window_title(const String &p_title) {
-
- OS::get_singleton()->set_window_title(p_title);
-}
-
-int _OS::get_mouse_button_state() const {
-
- return OS::get_singleton()->get_mouse_button_state();
-}
-
-String _OS::get_unique_id() const {
- return OS::get_singleton()->get_unique_id();
-}
-
-bool _OS::has_touchscreen_ui_hint() const {
-
- return OS::get_singleton()->has_touchscreen_ui_hint();
-}
-
-void _OS::set_clipboard(const String &p_text) {
-
- OS::get_singleton()->set_clipboard(p_text);
-}
-
-String _OS::get_clipboard() const {
+////// _OS //////
- return OS::get_singleton()->get_clipboard();
-}
-
-int _OS::get_video_driver_count() const {
- return OS::get_singleton()->get_video_driver_count();
-}
-
-String _OS::get_video_driver_name(VideoDriver p_driver) const {
- return OS::get_singleton()->get_video_driver_name((int)p_driver);
-}
-
-_OS::VideoDriver _OS::get_current_video_driver() const {
- return (VideoDriver)OS::get_singleton()->get_current_video_driver();
-}
-
-int _OS::get_audio_driver_count() const {
- return OS::get_singleton()->get_audio_driver_count();
-}
-
-String _OS::get_audio_driver_name(int p_driver) const {
- return OS::get_singleton()->get_audio_driver_name(p_driver);
-}
-
-PoolStringArray _OS::get_connected_midi_inputs() {
+PackedStringArray _OS::get_connected_midi_inputs() {
return OS::get_singleton()->get_connected_midi_inputs();
}
@@ -271,275 +195,83 @@ void _OS::close_midi_inputs() {
OS::get_singleton()->close_midi_inputs();
}
-void _OS::set_video_mode(const Size2 &p_size, bool p_fullscreen, bool p_resizeable, int p_screen) {
-
- OS::VideoMode vm;
- vm.width = p_size.width;
- vm.height = p_size.height;
- vm.fullscreen = p_fullscreen;
- vm.resizable = p_resizeable;
- OS::get_singleton()->set_video_mode(vm, p_screen);
-}
-
-Size2 _OS::get_video_mode(int p_screen) const {
-
- OS::VideoMode vm;
- vm = OS::get_singleton()->get_video_mode(p_screen);
- return Size2(vm.width, vm.height);
-}
-
-bool _OS::is_video_mode_fullscreen(int p_screen) const {
-
- OS::VideoMode vm;
- vm = OS::get_singleton()->get_video_mode(p_screen);
- return vm.fullscreen;
-}
-
-int _OS::get_screen_count() const {
- return OS::get_singleton()->get_screen_count();
-}
-
-int _OS::get_current_screen() const {
- return OS::get_singleton()->get_current_screen();
-}
-
-void _OS::set_current_screen(int p_screen) {
- OS::get_singleton()->set_current_screen(p_screen);
-}
-
-Point2 _OS::get_screen_position(int p_screen) const {
- return OS::get_singleton()->get_screen_position(p_screen);
-}
-
-Size2 _OS::get_screen_size(int p_screen) const {
- return OS::get_singleton()->get_screen_size(p_screen);
-}
-
-int _OS::get_screen_dpi(int p_screen) const {
-
- return OS::get_singleton()->get_screen_dpi(p_screen);
-}
-
-Point2 _OS::get_window_position() const {
- return OS::get_singleton()->get_window_position();
-}
-
-void _OS::set_window_position(const Point2 &p_position) {
- OS::get_singleton()->set_window_position(p_position);
-}
-
-Size2 _OS::get_max_window_size() const {
- return OS::get_singleton()->get_max_window_size();
-}
-
-Size2 _OS::get_min_window_size() const {
- return OS::get_singleton()->get_min_window_size();
-}
-
-Size2 _OS::get_window_size() const {
- return OS::get_singleton()->get_window_size();
-}
-
-Size2 _OS::get_real_window_size() const {
- return OS::get_singleton()->get_real_window_size();
-}
-
-void _OS::set_max_window_size(const Size2 &p_size) {
- OS::get_singleton()->set_max_window_size(p_size);
-}
-
-void _OS::set_min_window_size(const Size2 &p_size) {
- OS::get_singleton()->set_min_window_size(p_size);
-}
-
-void _OS::set_window_size(const Size2 &p_size) {
- OS::get_singleton()->set_window_size(p_size);
-}
-
-Rect2 _OS::get_window_safe_area() const {
- return OS::get_singleton()->get_window_safe_area();
-}
-
-void _OS::set_window_fullscreen(bool p_enabled) {
- OS::get_singleton()->set_window_fullscreen(p_enabled);
-}
-
-bool _OS::is_window_fullscreen() const {
- return OS::get_singleton()->is_window_fullscreen();
-}
-
-void _OS::set_window_resizable(bool p_enabled) {
- OS::get_singleton()->set_window_resizable(p_enabled);
-}
-
-bool _OS::is_window_resizable() const {
- return OS::get_singleton()->is_window_resizable();
-}
-
-void _OS::set_window_minimized(bool p_enabled) {
- OS::get_singleton()->set_window_minimized(p_enabled);
-}
-
-bool _OS::is_window_minimized() const {
- return OS::get_singleton()->is_window_minimized();
-}
-
-void _OS::set_window_maximized(bool p_enabled) {
- OS::get_singleton()->set_window_maximized(p_enabled);
-}
-
-bool _OS::is_window_maximized() const {
- return OS::get_singleton()->is_window_maximized();
-}
-
-void _OS::set_window_always_on_top(bool p_enabled) {
- OS::get_singleton()->set_window_always_on_top(p_enabled);
-}
-
-bool _OS::is_window_always_on_top() const {
- return OS::get_singleton()->is_window_always_on_top();
-}
-
-bool _OS::is_window_focused() const {
- return OS::get_singleton()->is_window_focused();
-}
-
-void _OS::set_borderless_window(bool p_borderless) {
- OS::get_singleton()->set_borderless_window(p_borderless);
-}
-
-bool _OS::get_window_per_pixel_transparency_enabled() const {
- return OS::get_singleton()->get_window_per_pixel_transparency_enabled();
-}
-
-void _OS::set_window_per_pixel_transparency_enabled(bool p_enabled) {
- OS::get_singleton()->set_window_per_pixel_transparency_enabled(p_enabled);
-}
-
-bool _OS::get_borderless_window() const {
- return OS::get_singleton()->get_borderless_window();
-}
-
-void _OS::set_ime_active(const bool p_active) {
-
- OS::get_singleton()->set_ime_active(p_active);
-}
-
-void _OS::set_ime_position(const Point2 &p_pos) {
-
- OS::get_singleton()->set_ime_position(p_pos);
-}
-
-Point2 _OS::get_ime_selection() const {
- return OS::get_singleton()->get_ime_selection();
-}
-
-String _OS::get_ime_text() const {
- return OS::get_singleton()->get_ime_text();
-}
-
void _OS::set_use_file_access_save_and_swap(bool p_enable) {
-
FileAccess::set_backup_save(p_enable);
}
-bool _OS::is_video_mode_resizable(int p_screen) const {
-
- OS::VideoMode vm;
- vm = OS::get_singleton()->get_video_mode(p_screen);
- return vm.resizable;
-}
-
-Array _OS::get_fullscreen_mode_list(int p_screen) const {
-
- List<OS::VideoMode> vmlist;
- OS::get_singleton()->get_fullscreen_mode_list(&vmlist, p_screen);
- Array vmarr;
- for (List<OS::VideoMode>::Element *E = vmlist.front(); E; E = E->next()) {
-
- vmarr.push_back(Size2(E->get().width, E->get().height));
- }
-
- return vmarr;
-}
-
void _OS::set_low_processor_usage_mode(bool p_enabled) {
-
OS::get_singleton()->set_low_processor_usage_mode(p_enabled);
}
-bool _OS::is_in_low_processor_usage_mode() const {
+bool _OS::is_in_low_processor_usage_mode() const {
return OS::get_singleton()->is_in_low_processor_usage_mode();
}
void _OS::set_low_processor_usage_mode_sleep_usec(int p_usec) {
-
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(p_usec);
}
int _OS::get_low_processor_usage_mode_sleep_usec() const {
-
return OS::get_singleton()->get_low_processor_usage_mode_sleep_usec();
}
String _OS::get_executable_path() const {
-
return OS::get_singleton()->get_executable_path();
}
Error _OS::shell_open(String p_uri) {
-
+ if (p_uri.begins_with("res://")) {
+ WARN_PRINT("Attempting to open an URL with the \"res://\" protocol. Use `ProjectSettings.globalize_path()` to convert a Godot-specific path to a system path before opening it with `OS.shell_open()`.");
+ } else if (p_uri.begins_with("user://")) {
+ WARN_PRINT("Attempting to open an URL with the \"user://\" protocol. Use `ProjectSettings.globalize_path()` to convert a Godot-specific path to a system path before opening it with `OS.shell_open()`.");
+ }
return OS::get_singleton()->shell_open(p_uri);
-};
+}
int _OS::execute(const String &p_path, const Vector<String> &p_arguments, bool p_blocking, Array p_output, bool p_read_stderr) {
-
OS::ProcessID pid = -2;
int exitcode = 0;
List<String> args;
- for (int i = 0; i < p_arguments.size(); i++)
+ for (int i = 0; i < p_arguments.size(); i++) {
args.push_back(p_arguments[i]);
+ }
String pipe;
Error err = OS::get_singleton()->execute(p_path, args, p_blocking, &pid, &pipe, &exitcode, p_read_stderr);
p_output.clear();
p_output.push_back(pipe);
- if (err != OK)
+ if (err != OK) {
return -1;
- else if (p_blocking)
+ } else if (p_blocking) {
return exitcode;
- else
+ } else {
return pid;
+ }
}
Error _OS::kill(int p_pid) {
-
return OS::get_singleton()->kill(p_pid);
}
int _OS::get_process_id() const {
-
return OS::get_singleton()->get_process_id();
-};
+}
bool _OS::has_environment(const String &p_var) const {
-
return OS::get_singleton()->has_environment(p_var);
}
-String _OS::get_environment(const String &p_var) const {
+String _OS::get_environment(const String &p_var) const {
return OS::get_singleton()->get_environment(p_var);
}
String _OS::get_name() const {
-
return OS::get_singleton()->get_name();
}
-Vector<String> _OS::get_cmdline_args() {
+Vector<String> _OS::get_cmdline_args() {
List<String> cmdline = OS::get_singleton()->get_cmdline_args();
Vector<String> cmdlinev;
for (List<String>::Element *E = cmdline.front(); E; E = E->next()) {
-
cmdlinev.push_back(E->get());
}
@@ -547,149 +279,34 @@ Vector<String> _OS::get_cmdline_args() {
}
String _OS::get_locale() const {
-
return OS::get_singleton()->get_locale();
}
-String _OS::get_latin_keyboard_variant() const {
- switch (OS::get_singleton()->get_latin_keyboard_variant()) {
- case OS::LATIN_KEYBOARD_QWERTY: return "QWERTY";
- case OS::LATIN_KEYBOARD_QWERTZ: return "QWERTZ";
- case OS::LATIN_KEYBOARD_AZERTY: return "AZERTY";
- case OS::LATIN_KEYBOARD_QZERTY: return "QZERTY";
- case OS::LATIN_KEYBOARD_DVORAK: return "DVORAK";
- case OS::LATIN_KEYBOARD_NEO: return "NEO";
- case OS::LATIN_KEYBOARD_COLEMAK: return "COLEMAK";
- default: return "ERROR";
- }
-}
-
String _OS::get_model_name() const {
-
return OS::get_singleton()->get_model_name();
}
-bool _OS::is_ok_left_and_cancel_right() const {
-
- return OS::get_singleton()->get_swap_ok_cancel();
-}
-
Error _OS::set_thread_name(const String &p_name) {
-
return Thread::set_name(p_name);
-};
-
-void _OS::set_use_vsync(bool p_enable) {
- OS::get_singleton()->set_use_vsync(p_enable);
-}
-
-bool _OS::is_vsync_enabled() const {
-
- return OS::get_singleton()->is_vsync_enabled();
-}
-
-void _OS::set_vsync_via_compositor(bool p_enable) {
- OS::get_singleton()->set_vsync_via_compositor(p_enable);
-}
-
-bool _OS::is_vsync_via_compositor_enabled() const {
-
- return OS::get_singleton()->is_vsync_via_compositor_enabled();
-}
-
-_OS::PowerState _OS::get_power_state() {
- return _OS::PowerState(OS::get_singleton()->get_power_state());
-}
-
-int _OS::get_power_seconds_left() {
- return OS::get_singleton()->get_power_seconds_left();
-}
-
-int _OS::get_power_percent_left() {
- return OS::get_singleton()->get_power_percent_left();
}
bool _OS::has_feature(const String &p_feature) const {
-
return OS::get_singleton()->has_feature(p_feature);
}
-/*
-enum Weekday {
- DAY_SUNDAY,
- DAY_MONDAY,
- DAY_TUESDAY,
- DAY_WEDNESDAY,
- DAY_THURSDAY,
- DAY_FRIDAY,
- DAY_SATURDAY
-};
-
-enum Month {
- MONTH_JANUARY,
- MONTH_FEBRUARY,
- MONTH_MARCH,
- MONTH_APRIL,
- MONTH_MAY,
- MONTH_JUNE,
- MONTH_JULY,
- MONTH_AUGUST,
- MONTH_SEPTEMBER,
- MONTH_OCTOBER,
- MONTH_NOVEMBER,
- MONTH_DECEMBER
-};
-*/
-/*
-struct Date {
-
- int year;
- Month month;
- int day;
- Weekday weekday;
- bool dst;
-};
-
-struct Time {
-
- int hour;
- int min;
- int sec;
-};
-*/
-
uint64_t _OS::get_static_memory_usage() const {
-
return OS::get_singleton()->get_static_memory_usage();
}
uint64_t _OS::get_static_memory_peak_usage() const {
-
return OS::get_singleton()->get_static_memory_peak_usage();
}
-uint64_t _OS::get_dynamic_memory_usage() const {
-
- return OS::get_singleton()->get_dynamic_memory_usage();
-}
-
-void _OS::set_native_icon(const String &p_filename) {
-
- OS::get_singleton()->set_native_icon(p_filename);
-}
-
-void _OS::set_icon(const Ref<Image> &p_icon) {
-
- OS::get_singleton()->set_icon(p_icon);
-}
-
int _OS::get_exit_code() const {
-
return OS::get_singleton()->get_exit_code();
}
void _OS::set_exit_code(int p_code) {
-
if (p_code < 0 || p_code > 125) {
WARN_PRINT("For portability reasons, the exit code should be set between 0 and 125 (inclusive).");
}
@@ -702,7 +319,6 @@ void _OS::set_exit_code(int p_code) {
* dst
*/
Dictionary _OS::get_datetime(bool utc) const {
-
Dictionary dated = get_date(utc);
Dictionary timed = get_time(utc);
@@ -717,7 +333,6 @@ Dictionary _OS::get_datetime(bool utc) const {
}
Dictionary _OS::get_date(bool utc) const {
-
OS::Date date = OS::get_singleton()->get_date(utc);
Dictionary dated;
dated[YEAR_KEY] = date.year;
@@ -729,7 +344,6 @@ Dictionary _OS::get_date(bool utc) const {
}
Dictionary _OS::get_time(bool utc) const {
-
OS::Time time = OS::get_singleton()->get_time(utc);
Dictionary timed;
timed[HOUR_KEY] = time.hour;
@@ -751,7 +365,6 @@ Dictionary _OS::get_time(bool utc) const {
* @return epoch calculated
*/
int64_t _OS::get_unix_time_from_datetime(Dictionary datetime) const {
-
// Bunch of conversion constants
static const unsigned int SECONDS_PER_MINUTE = 60;
static const unsigned int MINUTES_PER_HOUR = 60;
@@ -824,7 +437,6 @@ int64_t _OS::get_unix_time_from_datetime(Dictionary datetime) const {
* @return dictionary of date and time values
*/
Dictionary _OS::get_datetime_from_unix_time(int64_t unix_time_val) const {
-
OS::Date date;
OS::Time time;
@@ -843,7 +455,7 @@ Dictionary _OS::get_datetime_from_unix_time(int64_t unix_time_val) const {
} else {
dayno = (unix_time_val - SECS_DAY + 1) / SECS_DAY;
dayclock = unix_time_val - dayno * SECS_DAY;
- date.weekday = static_cast<OS::Weekday>((dayno - 3) % 7 + 7);
+ date.weekday = static_cast<OS::Weekday>(((dayno % 7) + 11) % 7);
do {
year--;
dayno += YEARSIZE(year);
@@ -887,76 +499,51 @@ Dictionary _OS::get_time_zone_info() const {
return infod;
}
-uint64_t _OS::get_unix_time() const {
-
+double _OS::get_unix_time() const {
return OS::get_singleton()->get_unix_time();
}
-uint64_t _OS::get_system_time_secs() const {
- return OS::get_singleton()->get_system_time_secs();
-}
-
-uint64_t _OS::get_system_time_msecs() const {
- return OS::get_singleton()->get_system_time_msecs();
-}
-
void _OS::delay_usec(uint32_t p_usec) const {
-
OS::get_singleton()->delay_usec(p_usec);
}
void _OS::delay_msec(uint32_t p_msec) const {
-
OS::get_singleton()->delay_usec(int64_t(p_msec) * 1000);
}
uint32_t _OS::get_ticks_msec() const {
-
return OS::get_singleton()->get_ticks_msec();
}
uint64_t _OS::get_ticks_usec() const {
-
return OS::get_singleton()->get_ticks_usec();
}
uint32_t _OS::get_splash_tick_msec() const {
-
return OS::get_singleton()->get_splash_tick_msec();
}
bool _OS::can_use_threads() const {
-
return OS::get_singleton()->can_use_threads();
}
-bool _OS::can_draw() const {
-
- return OS::get_singleton()->can_draw();
-}
-
bool _OS::is_userfs_persistent() const {
-
return OS::get_singleton()->is_userfs_persistent();
}
int _OS::get_processor_count() const {
-
return OS::get_singleton()->get_processor_count();
}
bool _OS::is_stdout_verbose() const {
-
return OS::get_singleton()->is_stdout_verbose();
}
void _OS::dump_memory_to_file(const String &p_file) {
-
OS::get_singleton()->dump_memory_to_file(p_file.utf8().get_data());
}
struct _OSCoreBindImg {
-
String path;
Size2 size;
int fmt;
@@ -966,17 +553,16 @@ struct _OSCoreBindImg {
};
void _OS::print_all_textures_by_size() {
-
List<_OSCoreBindImg> imgs;
int total = 0;
{
- List<Ref<Resource> > rsrc;
+ List<Ref<Resource>> rsrc;
ResourceCache::get_cached_resources(&rsrc);
- for (List<Ref<Resource> >::Element *E = rsrc.front(); E; E = E->next()) {
-
- if (!E->get()->is_class("ImageTexture"))
+ for (List<Ref<Resource>>::Element *E = rsrc.front(); E; E = E->next()) {
+ if (!E->get()->is_class("ImageTexture")) {
continue;
+ }
Size2 size = E->get()->call("get_size");
int fmt = E->get()->call("get_format");
@@ -995,33 +581,32 @@ void _OS::print_all_textures_by_size() {
imgs.sort();
for (List<_OSCoreBindImg>::Element *E = imgs.front(); E; E = E->next()) {
-
total -= E->get().vram;
}
}
void _OS::print_resources_by_type(const Vector<String> &p_types) {
-
Map<String, int> type_count;
- List<Ref<Resource> > resources;
+ List<Ref<Resource>> resources;
ResourceCache::get_cached_resources(&resources);
- List<Ref<Resource> > rsrc;
+ List<Ref<Resource>> rsrc;
ResourceCache::get_cached_resources(&rsrc);
- for (List<Ref<Resource> >::Element *E = rsrc.front(); E; E = E->next()) {
-
+ for (List<Ref<Resource>>::Element *E = rsrc.front(); E; E = E->next()) {
Ref<Resource> r = E->get();
bool found = false;
for (int i = 0; i < p_types.size(); i++) {
- if (r->is_class(p_types[i]))
+ if (r->is_class(p_types[i])) {
found = true;
+ }
}
- if (!found)
+ if (!found) {
continue;
+ }
if (!type_count.has(r->get_class())) {
type_count[r->get_class()] = 0;
@@ -1029,85 +614,25 @@ void _OS::print_resources_by_type(const Vector<String> &p_types) {
type_count[r->get_class()]++;
}
-};
-
-bool _OS::has_virtual_keyboard() const {
- return OS::get_singleton()->has_virtual_keyboard();
-}
-
-void _OS::show_virtual_keyboard(const String &p_existing_text) {
- OS::get_singleton()->show_virtual_keyboard(p_existing_text, Rect2());
-}
-
-void _OS::hide_virtual_keyboard() {
- OS::get_singleton()->hide_virtual_keyboard();
-}
-
-int _OS::get_virtual_keyboard_height() {
- return OS::get_singleton()->get_virtual_keyboard_height();
}
void _OS::print_all_resources(const String &p_to_file) {
-
OS::get_singleton()->print_all_resources(p_to_file);
}
void _OS::print_resources_in_use(bool p_short) {
-
OS::get_singleton()->print_resources_in_use(p_short);
}
void _OS::dump_resources_to_file(const String &p_file) {
-
OS::get_singleton()->dump_resources_to_file(p_file.utf8().get_data());
}
String _OS::get_user_data_dir() const {
-
return OS::get_singleton()->get_user_data_dir();
-};
-
-Error _OS::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) {
-
- return OS::get_singleton()->native_video_play(p_path, p_volume, p_audio_track, p_subtitle_track);
-};
-
-bool _OS::native_video_is_playing() {
-
- return OS::get_singleton()->native_video_is_playing();
-};
-
-void _OS::native_video_pause() {
-
- OS::get_singleton()->native_video_pause();
-};
-
-void _OS::native_video_unpause() {
- OS::get_singleton()->native_video_unpause();
-};
-
-void _OS::native_video_stop() {
-
- OS::get_singleton()->native_video_stop();
-};
-
-void _OS::request_attention() {
-
- OS::get_singleton()->request_attention();
-}
-
-void _OS::center_window() {
-
- OS::get_singleton()->center_window();
-}
-
-void _OS::move_window_to_foreground() {
-
- OS::get_singleton()->move_window_to_foreground();
}
bool _OS::is_debug_build() const {
-
#ifdef DEBUG_ENABLED
return true;
#else
@@ -1115,148 +640,61 @@ bool _OS::is_debug_build() const {
#endif
}
-void _OS::set_screen_orientation(ScreenOrientation p_orientation) {
-
- OS::get_singleton()->set_screen_orientation(OS::ScreenOrientation(p_orientation));
-}
-
-_OS::ScreenOrientation _OS::get_screen_orientation() const {
-
- return ScreenOrientation(OS::get_singleton()->get_screen_orientation());
-}
-
-void _OS::set_keep_screen_on(bool p_enabled) {
-
- OS::get_singleton()->set_keep_screen_on(p_enabled);
-}
-
-bool _OS::is_keep_screen_on() const {
-
- return OS::get_singleton()->is_keep_screen_on();
-}
-
String _OS::get_system_dir(SystemDir p_dir) const {
-
return OS::get_singleton()->get_system_dir(OS::SystemDir(p_dir));
}
-String _OS::get_scancode_string(uint32_t p_code) const {
-
+String _OS::get_keycode_string(uint32_t p_code) const {
return keycode_get_string(p_code);
}
-bool _OS::is_scancode_unicode(uint32_t p_unicode) const {
+bool _OS::is_keycode_unicode(uint32_t p_unicode) const {
return keycode_has_unicode(p_unicode);
}
-int _OS::find_scancode_from_string(const String &p_code) const {
+int _OS::find_keycode_from_string(const String &p_code) const {
return find_keycode(p_code);
}
-void _OS::alert(const String &p_alert, const String &p_title) {
-
- OS::get_singleton()->alert(p_alert, p_title);
-}
-
bool _OS::request_permission(const String &p_name) {
-
return OS::get_singleton()->request_permission(p_name);
}
bool _OS::request_permissions() {
-
return OS::get_singleton()->request_permissions();
}
Vector<String> _OS::get_granted_permissions() const {
-
return OS::get_singleton()->get_granted_permissions();
}
-_OS *_OS::singleton = NULL;
-
-void _OS::_bind_methods() {
+String _OS::get_unique_id() const {
+ return OS::get_singleton()->get_unique_id();
+}
- //ClassDB::bind_method(D_METHOD("get_mouse_position"),&_OS::get_mouse_position);
- //ClassDB::bind_method(D_METHOD("is_mouse_grab_enabled"),&_OS::is_mouse_grab_enabled);
+int _OS::get_tablet_driver_count() const {
+ return OS::get_singleton()->get_tablet_driver_count();
+}
- ClassDB::bind_method(D_METHOD("set_clipboard", "clipboard"), &_OS::set_clipboard);
- ClassDB::bind_method(D_METHOD("get_clipboard"), &_OS::get_clipboard);
+String _OS::get_tablet_driver_name(int p_driver) const {
+ return OS::get_singleton()->get_tablet_driver_name(p_driver);
+}
- //will not delete for now, just unexpose
- //ClassDB::bind_method(D_METHOD("set_video_mode","size","fullscreen","resizable","screen"),&_OS::set_video_mode,DEFVAL(0));
- //ClassDB::bind_method(D_METHOD("get_video_mode_size","screen"),&_OS::get_video_mode,DEFVAL(0));
- //ClassDB::bind_method(D_METHOD("is_video_mode_fullscreen","screen"),&_OS::is_video_mode_fullscreen,DEFVAL(0));
- //ClassDB::bind_method(D_METHOD("is_video_mode_resizable","screen"),&_OS::is_video_mode_resizable,DEFVAL(0));
- //ClassDB::bind_method(D_METHOD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0));
+String _OS::get_current_tablet_driver() const {
+ return OS::get_singleton()->get_current_tablet_driver();
+}
- ClassDB::bind_method(D_METHOD("global_menu_add_item", "menu", "label", "id", "meta"), &_OS::global_menu_add_item);
- ClassDB::bind_method(D_METHOD("global_menu_add_separator", "menu"), &_OS::global_menu_add_separator);
- ClassDB::bind_method(D_METHOD("global_menu_remove_item", "menu", "idx"), &_OS::global_menu_remove_item);
- ClassDB::bind_method(D_METHOD("global_menu_clear", "menu"), &_OS::global_menu_clear);
+void _OS::set_current_tablet_driver(const String &p_driver) {
+ OS::get_singleton()->set_current_tablet_driver(p_driver);
+}
- ClassDB::bind_method(D_METHOD("get_video_driver_count"), &_OS::get_video_driver_count);
- ClassDB::bind_method(D_METHOD("get_video_driver_name", "driver"), &_OS::get_video_driver_name);
- ClassDB::bind_method(D_METHOD("get_current_video_driver"), &_OS::get_current_video_driver);
+_OS *_OS::singleton = nullptr;
- ClassDB::bind_method(D_METHOD("get_audio_driver_count"), &_OS::get_audio_driver_count);
- ClassDB::bind_method(D_METHOD("get_audio_driver_name", "driver"), &_OS::get_audio_driver_name);
+void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_connected_midi_inputs"), &_OS::get_connected_midi_inputs);
ClassDB::bind_method(D_METHOD("open_midi_inputs"), &_OS::open_midi_inputs);
ClassDB::bind_method(D_METHOD("close_midi_inputs"), &_OS::close_midi_inputs);
- ClassDB::bind_method(D_METHOD("get_screen_count"), &_OS::get_screen_count);
- ClassDB::bind_method(D_METHOD("get_current_screen"), &_OS::get_current_screen);
- ClassDB::bind_method(D_METHOD("set_current_screen", "screen"), &_OS::set_current_screen);
- ClassDB::bind_method(D_METHOD("get_screen_position", "screen"), &_OS::get_screen_position, DEFVAL(-1));
- ClassDB::bind_method(D_METHOD("get_screen_size", "screen"), &_OS::get_screen_size, DEFVAL(-1));
- ClassDB::bind_method(D_METHOD("get_screen_dpi", "screen"), &_OS::get_screen_dpi, DEFVAL(-1));
- ClassDB::bind_method(D_METHOD("get_window_position"), &_OS::get_window_position);
- ClassDB::bind_method(D_METHOD("set_window_position", "position"), &_OS::set_window_position);
- ClassDB::bind_method(D_METHOD("get_window_size"), &_OS::get_window_size);
- ClassDB::bind_method(D_METHOD("get_max_window_size"), &_OS::get_max_window_size);
- ClassDB::bind_method(D_METHOD("get_min_window_size"), &_OS::get_min_window_size);
- ClassDB::bind_method(D_METHOD("set_max_window_size", "size"), &_OS::set_max_window_size);
- ClassDB::bind_method(D_METHOD("set_min_window_size", "size"), &_OS::set_min_window_size);
- ClassDB::bind_method(D_METHOD("set_window_size", "size"), &_OS::set_window_size);
- ClassDB::bind_method(D_METHOD("get_window_safe_area"), &_OS::get_window_safe_area);
- ClassDB::bind_method(D_METHOD("set_window_fullscreen", "enabled"), &_OS::set_window_fullscreen);
- ClassDB::bind_method(D_METHOD("is_window_fullscreen"), &_OS::is_window_fullscreen);
- ClassDB::bind_method(D_METHOD("set_window_resizable", "enabled"), &_OS::set_window_resizable);
- ClassDB::bind_method(D_METHOD("is_window_resizable"), &_OS::is_window_resizable);
- ClassDB::bind_method(D_METHOD("set_window_minimized", "enabled"), &_OS::set_window_minimized);
- ClassDB::bind_method(D_METHOD("is_window_minimized"), &_OS::is_window_minimized);
- ClassDB::bind_method(D_METHOD("set_window_maximized", "enabled"), &_OS::set_window_maximized);
- ClassDB::bind_method(D_METHOD("is_window_maximized"), &_OS::is_window_maximized);
- ClassDB::bind_method(D_METHOD("set_window_always_on_top", "enabled"), &_OS::set_window_always_on_top);
- ClassDB::bind_method(D_METHOD("is_window_always_on_top"), &_OS::is_window_always_on_top);
- ClassDB::bind_method(D_METHOD("is_window_focused"), &_OS::is_window_focused);
- ClassDB::bind_method(D_METHOD("request_attention"), &_OS::request_attention);
- ClassDB::bind_method(D_METHOD("get_real_window_size"), &_OS::get_real_window_size);
- ClassDB::bind_method(D_METHOD("center_window"), &_OS::center_window);
- ClassDB::bind_method(D_METHOD("move_window_to_foreground"), &_OS::move_window_to_foreground);
-
- ClassDB::bind_method(D_METHOD("set_borderless_window", "borderless"), &_OS::set_borderless_window);
- ClassDB::bind_method(D_METHOD("get_borderless_window"), &_OS::get_borderless_window);
-
- ClassDB::bind_method(D_METHOD("get_window_per_pixel_transparency_enabled"), &_OS::get_window_per_pixel_transparency_enabled);
- ClassDB::bind_method(D_METHOD("set_window_per_pixel_transparency_enabled", "enabled"), &_OS::set_window_per_pixel_transparency_enabled);
-
- ClassDB::bind_method(D_METHOD("set_ime_active", "active"), &_OS::set_ime_active);
- ClassDB::bind_method(D_METHOD("set_ime_position", "position"), &_OS::set_ime_position);
- ClassDB::bind_method(D_METHOD("get_ime_selection"), &_OS::get_ime_selection);
- ClassDB::bind_method(D_METHOD("get_ime_text"), &_OS::get_ime_text);
-
- ClassDB::bind_method(D_METHOD("set_screen_orientation", "orientation"), &_OS::set_screen_orientation);
- ClassDB::bind_method(D_METHOD("get_screen_orientation"), &_OS::get_screen_orientation);
-
- ClassDB::bind_method(D_METHOD("set_keep_screen_on", "enabled"), &_OS::set_keep_screen_on);
- ClassDB::bind_method(D_METHOD("is_keep_screen_on"), &_OS::is_keep_screen_on);
-
- ClassDB::bind_method(D_METHOD("has_touchscreen_ui_hint"), &_OS::has_touchscreen_ui_hint);
-
- ClassDB::bind_method(D_METHOD("set_window_title", "title"), &_OS::set_window_title);
-
ClassDB::bind_method(D_METHOD("set_low_processor_usage_mode", "enable"), &_OS::set_low_processor_usage_mode);
ClassDB::bind_method(D_METHOD("is_in_low_processor_usage_mode"), &_OS::is_in_low_processor_usage_mode);
@@ -1284,11 +722,6 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_unix_time"), &_OS::get_unix_time);
ClassDB::bind_method(D_METHOD("get_datetime_from_unix_time", "unix_time_val"), &_OS::get_datetime_from_unix_time);
ClassDB::bind_method(D_METHOD("get_unix_time_from_datetime", "datetime"), &_OS::get_unix_time_from_datetime);
- ClassDB::bind_method(D_METHOD("get_system_time_secs"), &_OS::get_system_time_secs);
- ClassDB::bind_method(D_METHOD("get_system_time_msecs"), &_OS::get_system_time_msecs);
-
- ClassDB::bind_method(D_METHOD("set_native_icon", "filename"), &_OS::set_native_icon);
- ClassDB::bind_method(D_METHOD("set_icon", "icon"), &_OS::set_icon);
ClassDB::bind_method(D_METHOD("get_exit_code"), &_OS::get_exit_code);
ClassDB::bind_method(D_METHOD("set_exit_code", "code"), &_OS::set_exit_code);
@@ -1299,10 +732,8 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_ticks_usec"), &_OS::get_ticks_usec);
ClassDB::bind_method(D_METHOD("get_splash_tick_msec"), &_OS::get_splash_tick_msec);
ClassDB::bind_method(D_METHOD("get_locale"), &_OS::get_locale);
- ClassDB::bind_method(D_METHOD("get_latin_keyboard_variant"), &_OS::get_latin_keyboard_variant);
ClassDB::bind_method(D_METHOD("get_model_name"), &_OS::get_model_name);
- ClassDB::bind_method(D_METHOD("can_draw"), &_OS::can_draw);
ClassDB::bind_method(D_METHOD("is_userfs_persistent"), &_OS::is_userfs_persistent);
ClassDB::bind_method(D_METHOD("is_stdout_verbose"), &_OS::is_stdout_verbose);
@@ -1310,107 +741,54 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_debug_build"), &_OS::is_debug_build);
- //ClassDB::bind_method(D_METHOD("get_mouse_button_state"),&_OS::get_mouse_button_state);
-
ClassDB::bind_method(D_METHOD("dump_memory_to_file", "file"), &_OS::dump_memory_to_file);
ClassDB::bind_method(D_METHOD("dump_resources_to_file", "file"), &_OS::dump_resources_to_file);
- ClassDB::bind_method(D_METHOD("has_virtual_keyboard"), &_OS::has_virtual_keyboard);
- ClassDB::bind_method(D_METHOD("show_virtual_keyboard", "existing_text"), &_OS::show_virtual_keyboard, DEFVAL(""));
- ClassDB::bind_method(D_METHOD("hide_virtual_keyboard"), &_OS::hide_virtual_keyboard);
- ClassDB::bind_method(D_METHOD("get_virtual_keyboard_height"), &_OS::get_virtual_keyboard_height);
ClassDB::bind_method(D_METHOD("print_resources_in_use", "short"), &_OS::print_resources_in_use, DEFVAL(false));
ClassDB::bind_method(D_METHOD("print_all_resources", "tofile"), &_OS::print_all_resources, DEFVAL(""));
ClassDB::bind_method(D_METHOD("get_static_memory_usage"), &_OS::get_static_memory_usage);
ClassDB::bind_method(D_METHOD("get_static_memory_peak_usage"), &_OS::get_static_memory_peak_usage);
- ClassDB::bind_method(D_METHOD("get_dynamic_memory_usage"), &_OS::get_dynamic_memory_usage);
ClassDB::bind_method(D_METHOD("get_user_data_dir"), &_OS::get_user_data_dir);
ClassDB::bind_method(D_METHOD("get_system_dir", "dir"), &_OS::get_system_dir);
ClassDB::bind_method(D_METHOD("get_unique_id"), &_OS::get_unique_id);
- ClassDB::bind_method(D_METHOD("is_ok_left_and_cancel_right"), &_OS::is_ok_left_and_cancel_right);
-
ClassDB::bind_method(D_METHOD("print_all_textures_by_size"), &_OS::print_all_textures_by_size);
ClassDB::bind_method(D_METHOD("print_resources_by_type", "types"), &_OS::print_resources_by_type);
- ClassDB::bind_method(D_METHOD("native_video_play", "path", "volume", "audio_track", "subtitle_track"), &_OS::native_video_play);
- ClassDB::bind_method(D_METHOD("native_video_is_playing"), &_OS::native_video_is_playing);
- ClassDB::bind_method(D_METHOD("native_video_stop"), &_OS::native_video_stop);
- ClassDB::bind_method(D_METHOD("native_video_pause"), &_OS::native_video_pause);
- ClassDB::bind_method(D_METHOD("native_video_unpause"), &_OS::native_video_unpause);
-
- ClassDB::bind_method(D_METHOD("get_scancode_string", "code"), &_OS::get_scancode_string);
- ClassDB::bind_method(D_METHOD("is_scancode_unicode", "code"), &_OS::is_scancode_unicode);
- ClassDB::bind_method(D_METHOD("find_scancode_from_string", "string"), &_OS::find_scancode_from_string);
+ ClassDB::bind_method(D_METHOD("get_keycode_string", "code"), &_OS::get_keycode_string);
+ ClassDB::bind_method(D_METHOD("is_keycode_unicode", "code"), &_OS::is_keycode_unicode);
+ ClassDB::bind_method(D_METHOD("find_keycode_from_string", "string"), &_OS::find_keycode_from_string);
ClassDB::bind_method(D_METHOD("set_use_file_access_save_and_swap", "enabled"), &_OS::set_use_file_access_save_and_swap);
- ClassDB::bind_method(D_METHOD("alert", "text", "title"), &_OS::alert, DEFVAL("Alert!"));
-
ClassDB::bind_method(D_METHOD("set_thread_name", "name"), &_OS::set_thread_name);
- ClassDB::bind_method(D_METHOD("set_use_vsync", "enable"), &_OS::set_use_vsync);
- ClassDB::bind_method(D_METHOD("is_vsync_enabled"), &_OS::is_vsync_enabled);
-
- ClassDB::bind_method(D_METHOD("set_vsync_via_compositor", "enable"), &_OS::set_vsync_via_compositor);
- ClassDB::bind_method(D_METHOD("is_vsync_via_compositor_enabled"), &_OS::is_vsync_via_compositor_enabled);
-
ClassDB::bind_method(D_METHOD("has_feature", "tag_name"), &_OS::has_feature);
- ClassDB::bind_method(D_METHOD("get_power_state"), &_OS::get_power_state);
- ClassDB::bind_method(D_METHOD("get_power_seconds_left"), &_OS::get_power_seconds_left);
- ClassDB::bind_method(D_METHOD("get_power_percent_left"), &_OS::get_power_percent_left);
-
ClassDB::bind_method(D_METHOD("request_permission", "name"), &_OS::request_permission);
ClassDB::bind_method(D_METHOD("request_permissions"), &_OS::request_permissions);
ClassDB::bind_method(D_METHOD("get_granted_permissions"), &_OS::get_granted_permissions);
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "clipboard"), "set_clipboard", "get_clipboard");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "current_screen"), "set_current_screen", "get_current_screen");
+ ClassDB::bind_method(D_METHOD("get_tablet_driver_count"), &_OS::get_tablet_driver_count);
+ ClassDB::bind_method(D_METHOD("get_tablet_driver_name", "idx"), &_OS::get_tablet_driver_name);
+ ClassDB::bind_method(D_METHOD("get_current_tablet_driver"), &_OS::get_current_tablet_driver);
+ ClassDB::bind_method(D_METHOD("set_current_tablet_driver", "name"), &_OS::set_current_tablet_driver);
+
ADD_PROPERTY(PropertyInfo(Variant::INT, "exit_code"), "set_exit_code", "get_exit_code");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "vsync_enabled"), "set_use_vsync", "is_vsync_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "vsync_via_compositor"), "set_vsync_via_compositor", "is_vsync_via_compositor_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "low_processor_usage_mode"), "set_low_processor_usage_mode", "is_in_low_processor_usage_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "low_processor_usage_mode_sleep_usec"), "set_low_processor_usage_mode_sleep_usec", "get_low_processor_usage_mode_sleep_usec");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keep_screen_on"), "set_keep_screen_on", "is_keep_screen_on");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "min_window_size"), "set_min_window_size", "get_min_window_size");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "max_window_size"), "set_max_window_size", "get_max_window_size");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "screen_orientation", PROPERTY_HINT_ENUM, "Landscape,Portrait,Reverse Landscape,Reverse Portrait,Sensor Landscape,Sensor Portrait,Sensor"), "set_screen_orientation", "get_screen_orientation");
- ADD_GROUP("Window", "window_");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_borderless"), "set_borderless_window", "get_borderless_window");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_per_pixel_transparency_enabled"), "set_window_per_pixel_transparency_enabled", "get_window_per_pixel_transparency_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_fullscreen"), "set_window_fullscreen", "is_window_fullscreen");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_maximized"), "set_window_maximized", "is_window_maximized");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_minimized"), "set_window_minimized", "is_window_minimized");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_resizable"), "set_window_resizable", "is_window_resizable");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "window_position"), "set_window_position", "get_window_position");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "window_size"), "set_window_size", "get_window_size");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "tablet_driver"), "set_current_tablet_driver", "get_current_tablet_driver");
// Those default values need to be specified for the docs generator,
// to avoid using values from the documentation writer's own OS instance.
- ADD_PROPERTY_DEFAULT("clipboard", "");
- ADD_PROPERTY_DEFAULT("current_screen", 0);
+ ADD_PROPERTY_DEFAULT("tablet_driver", "");
ADD_PROPERTY_DEFAULT("exit_code", 0);
- ADD_PROPERTY_DEFAULT("vsync_enabled", true);
- ADD_PROPERTY_DEFAULT("vsync_via_compositor", false);
ADD_PROPERTY_DEFAULT("low_processor_usage_mode", false);
ADD_PROPERTY_DEFAULT("low_processor_usage_mode_sleep_usec", 6900);
- ADD_PROPERTY_DEFAULT("keep_screen_on", true);
- ADD_PROPERTY_DEFAULT("min_window_size", Vector2());
- ADD_PROPERTY_DEFAULT("max_window_size", Vector2());
- ADD_PROPERTY_DEFAULT("screen_orientation", 0);
- ADD_PROPERTY_DEFAULT("window_borderless", false);
- ADD_PROPERTY_DEFAULT("window_per_pixel_transparency_enabled", false);
- ADD_PROPERTY_DEFAULT("window_fullscreen", false);
- ADD_PROPERTY_DEFAULT("window_maximized", false);
- ADD_PROPERTY_DEFAULT("window_minimized", false);
- ADD_PROPERTY_DEFAULT("window_resizable", true);
- ADD_PROPERTY_DEFAULT("window_position", Vector2());
- ADD_PROPERTY_DEFAULT("window_size", Vector2());
BIND_ENUM_CONSTANT(VIDEO_DRIVER_GLES2);
- BIND_ENUM_CONSTANT(VIDEO_DRIVER_GLES3);
+ BIND_ENUM_CONSTANT(VIDEO_DRIVER_VULKAN);
BIND_ENUM_CONSTANT(DAY_SUNDAY);
BIND_ENUM_CONSTANT(DAY_MONDAY);
@@ -1433,14 +811,6 @@ void _OS::_bind_methods() {
BIND_ENUM_CONSTANT(MONTH_NOVEMBER);
BIND_ENUM_CONSTANT(MONTH_DECEMBER);
- BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_LANDSCAPE);
- BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_PORTRAIT);
- BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
- BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_REVERSE_PORTRAIT);
- BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
- BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_SENSOR_PORTRAIT);
- BIND_ENUM_CONSTANT(SCREEN_ORIENTATION_SENSOR);
-
BIND_ENUM_CONSTANT(SYSTEM_DIR_DESKTOP);
BIND_ENUM_CONSTANT(SYSTEM_DIR_DCIM);
BIND_ENUM_CONSTANT(SYSTEM_DIR_DOCUMENTS);
@@ -1449,206 +819,88 @@ void _OS::_bind_methods() {
BIND_ENUM_CONSTANT(SYSTEM_DIR_MUSIC);
BIND_ENUM_CONSTANT(SYSTEM_DIR_PICTURES);
BIND_ENUM_CONSTANT(SYSTEM_DIR_RINGTONES);
-
- BIND_ENUM_CONSTANT(POWERSTATE_UNKNOWN);
- BIND_ENUM_CONSTANT(POWERSTATE_ON_BATTERY);
- BIND_ENUM_CONSTANT(POWERSTATE_NO_BATTERY);
- BIND_ENUM_CONSTANT(POWERSTATE_CHARGING);
- BIND_ENUM_CONSTANT(POWERSTATE_CHARGED);
-}
-
-_OS::_OS() {
-
- singleton = this;
}
-///////////////////// GEOMETRY
-
-_Geometry *_Geometry::singleton = NULL;
+////// _Geometry2D //////
-_Geometry *_Geometry::get_singleton() {
+_Geometry2D *_Geometry2D::singleton = nullptr;
+_Geometry2D *_Geometry2D::get_singleton() {
return singleton;
}
-PoolVector<Plane> _Geometry::build_box_planes(const Vector3 &p_extents) {
-
- return Geometry::build_box_planes(p_extents);
-}
-
-PoolVector<Plane> _Geometry::build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis) {
-
- return Geometry::build_cylinder_planes(p_radius, p_height, p_sides, p_axis);
+bool _Geometry2D::is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius) {
+ return Geometry2D::is_point_in_circle(p_point, p_circle_pos, p_circle_radius);
}
-PoolVector<Plane> _Geometry::build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
- return Geometry::build_capsule_planes(p_radius, p_height, p_sides, p_lats, p_axis);
+real_t _Geometry2D::segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius) {
+ return Geometry2D::segment_intersects_circle(p_from, p_to, p_circle_pos, p_circle_radius);
}
-bool _Geometry::is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius) {
-
- return Geometry::is_point_in_circle(p_point, p_circle_pos, p_circle_radius);
-}
-
-real_t _Geometry::segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius) {
-
- return Geometry::segment_intersects_circle(p_from, p_to, p_circle_pos, p_circle_radius);
-}
-
-Variant _Geometry::segment_intersects_segment_2d(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b) {
-
+Variant _Geometry2D::segment_intersects_segment(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b) {
Vector2 result;
- if (Geometry::segment_intersects_segment_2d(p_from_a, p_to_a, p_from_b, p_to_b, &result)) {
-
+ if (Geometry2D::segment_intersects_segment(p_from_a, p_to_a, p_from_b, p_to_b, &result)) {
return result;
} else {
return Variant();
- };
-};
-
-Variant _Geometry::line_intersects_line_2d(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b) {
+ }
+}
+Variant _Geometry2D::line_intersects_line(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b) {
Vector2 result;
- if (Geometry::line_intersects_line_2d(p_from_a, p_dir_a, p_from_b, p_dir_b, result)) {
+ if (Geometry2D::line_intersects_line(p_from_a, p_dir_a, p_from_b, p_dir_b, result)) {
return result;
} else {
return Variant();
}
}
-PoolVector<Vector2> _Geometry::get_closest_points_between_segments_2d(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2) {
-
+Vector<Vector2> _Geometry2D::get_closest_points_between_segments(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2) {
Vector2 r1, r2;
- Geometry::get_closest_points_between_segments(p1, q1, p2, q2, r1, r2);
- PoolVector<Vector2> r;
- r.resize(2);
- r.set(0, r1);
- r.set(1, r2);
- return r;
-}
-
-PoolVector<Vector3> _Geometry::get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2) {
-
- Vector3 r1, r2;
- Geometry::get_closest_points_between_segments(p1, p2, q1, q2, r1, r2);
- PoolVector<Vector3> r;
+ Geometry2D::get_closest_points_between_segments(p1, q1, p2, q2, r1, r2);
+ Vector<Vector2> r;
r.resize(2);
r.set(0, r1);
r.set(1, r2);
return r;
}
-Vector2 _Geometry::get_closest_point_to_segment_2d(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b) {
+Vector2 _Geometry2D::get_closest_point_to_segment(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b) {
Vector2 s[2] = { p_a, p_b };
- return Geometry::get_closest_point_to_segment_2d(p_point, s);
-}
-Vector3 _Geometry::get_closest_point_to_segment(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b) {
-
- Vector3 s[2] = { p_a, p_b };
- return Geometry::get_closest_point_to_segment(p_point, s);
+ return Geometry2D::get_closest_point_to_segment(p_point, s);
}
-Vector2 _Geometry::get_closest_point_to_segment_uncapped_2d(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b) {
+Vector2 _Geometry2D::get_closest_point_to_segment_uncapped(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b) {
Vector2 s[2] = { p_a, p_b };
- return Geometry::get_closest_point_to_segment_uncapped_2d(p_point, s);
-}
-Vector3 _Geometry::get_closest_point_to_segment_uncapped(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b) {
-
- Vector3 s[2] = { p_a, p_b };
- return Geometry::get_closest_point_to_segment_uncapped(p_point, s);
-}
-Variant _Geometry::ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2) {
-
- Vector3 res;
- if (Geometry::ray_intersects_triangle(p_from, p_dir, p_v0, p_v1, p_v2, &res))
- return res;
- else
- return Variant();
-}
-Variant _Geometry::segment_intersects_triangle(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2) {
-
- Vector3 res;
- if (Geometry::segment_intersects_triangle(p_from, p_to, p_v0, p_v1, p_v2, &res))
- return res;
- else
- return Variant();
-}
-
-bool _Geometry::point_is_inside_triangle(const Vector2 &s, const Vector2 &a, const Vector2 &b, const Vector2 &c) const {
-
- return Geometry::is_point_in_triangle(s, a, b, c);
-}
-
-PoolVector<Vector3> _Geometry::segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius) {
-
- PoolVector<Vector3> r;
- Vector3 res, norm;
- if (!Geometry::segment_intersects_sphere(p_from, p_to, p_sphere_pos, p_sphere_radius, &res, &norm))
- return r;
-
- r.resize(2);
- r.set(0, res);
- r.set(1, norm);
- return r;
+ return Geometry2D::get_closest_point_to_segment_uncapped(p_point, s);
}
-PoolVector<Vector3> _Geometry::segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius) {
- PoolVector<Vector3> r;
- Vector3 res, norm;
- if (!Geometry::segment_intersects_cylinder(p_from, p_to, p_height, p_radius, &res, &norm))
- return r;
-
- r.resize(2);
- r.set(0, res);
- r.set(1, norm);
- return r;
+bool _Geometry2D::point_is_inside_triangle(const Vector2 &s, const Vector2 &a, const Vector2 &b, const Vector2 &c) const {
+ return Geometry2D::is_point_in_triangle(s, a, b, c);
}
-PoolVector<Vector3> _Geometry::segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const Vector<Plane> &p_planes) {
-
- PoolVector<Vector3> r;
- Vector3 res, norm;
- if (!Geometry::segment_intersects_convex(p_from, p_to, p_planes.ptr(), p_planes.size(), &res, &norm))
- return r;
- r.resize(2);
- r.set(0, res);
- r.set(1, norm);
- return r;
-}
-
-bool _Geometry::is_polygon_clockwise(const Vector<Vector2> &p_polygon) {
-
- return Geometry::is_polygon_clockwise(p_polygon);
+bool _Geometry2D::is_polygon_clockwise(const Vector<Vector2> &p_polygon) {
+ return Geometry2D::is_polygon_clockwise(p_polygon);
}
-bool _Geometry::is_point_in_polygon(const Point2 &p_point, const Vector<Vector2> &p_polygon) {
-
- return Geometry::is_point_in_polygon(p_point, p_polygon);
-}
-
-Vector<int> _Geometry::triangulate_polygon(const Vector<Vector2> &p_polygon) {
-
- return Geometry::triangulate_polygon(p_polygon);
+bool _Geometry2D::is_point_in_polygon(const Point2 &p_point, const Vector<Vector2> &p_polygon) {
+ return Geometry2D::is_point_in_polygon(p_point, p_polygon);
}
-Vector<int> _Geometry::triangulate_delaunay_2d(const Vector<Vector2> &p_points) {
-
- return Geometry::triangulate_delaunay_2d(p_points);
+Vector<int> _Geometry2D::triangulate_polygon(const Vector<Vector2> &p_polygon) {
+ return Geometry2D::triangulate_polygon(p_polygon);
}
-Vector<Point2> _Geometry::convex_hull_2d(const Vector<Point2> &p_points) {
-
- return Geometry::convex_hull_2d(p_points);
+Vector<int> _Geometry2D::triangulate_delaunay(const Vector<Vector2> &p_points) {
+ return Geometry2D::triangulate_delaunay(p_points);
}
-Vector<Vector3> _Geometry::clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane) {
-
- return Geometry::clip_polygon(p_points, p_plane);
+Vector<Point2> _Geometry2D::convex_hull(const Vector<Point2> &p_points) {
+ return Geometry2D::convex_hull(p_points);
}
-Array _Geometry::merge_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
-
- Vector<Vector<Point2> > polys = Geometry::merge_polygons_2d(p_polygon_a, p_polygon_b);
+Array _Geometry2D::merge_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
+ Vector<Vector<Point2>> polys = Geometry2D::merge_polygons(p_polygon_a, p_polygon_b);
Array ret;
@@ -1658,9 +910,8 @@ Array _Geometry::merge_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vec
return ret;
}
-Array _Geometry::clip_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
-
- Vector<Vector<Point2> > polys = Geometry::clip_polygons_2d(p_polygon_a, p_polygon_b);
+Array _Geometry2D::clip_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
+ Vector<Vector<Point2>> polys = Geometry2D::clip_polygons(p_polygon_a, p_polygon_b);
Array ret;
@@ -1670,9 +921,8 @@ Array _Geometry::clip_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vect
return ret;
}
-Array _Geometry::intersect_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
-
- Vector<Vector<Point2> > polys = Geometry::intersect_polygons_2d(p_polygon_a, p_polygon_b);
+Array _Geometry2D::intersect_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
+ Vector<Vector<Point2>> polys = Geometry2D::intersect_polygons(p_polygon_a, p_polygon_b);
Array ret;
@@ -1682,9 +932,8 @@ Array _Geometry::intersect_polygons_2d(const Vector<Vector2> &p_polygon_a, const
return ret;
}
-Array _Geometry::exclude_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
-
- Vector<Vector<Point2> > polys = Geometry::exclude_polygons_2d(p_polygon_a, p_polygon_b);
+Array _Geometry2D::exclude_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b) {
+ Vector<Vector<Point2>> polys = Geometry2D::exclude_polygons(p_polygon_a, p_polygon_b);
Array ret;
@@ -1694,9 +943,8 @@ Array _Geometry::exclude_polygons_2d(const Vector<Vector2> &p_polygon_a, const V
return ret;
}
-Array _Geometry::clip_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon) {
-
- Vector<Vector<Point2> > polys = Geometry::clip_polyline_with_polygon_2d(p_polyline, p_polygon);
+Array _Geometry2D::clip_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon) {
+ Vector<Vector<Point2>> polys = Geometry2D::clip_polyline_with_polygon(p_polyline, p_polygon);
Array ret;
@@ -1706,9 +954,8 @@ Array _Geometry::clip_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline
return ret;
}
-Array _Geometry::intersect_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon) {
-
- Vector<Vector<Point2> > polys = Geometry::intersect_polyline_with_polygon_2d(p_polyline, p_polygon);
+Array _Geometry2D::intersect_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon) {
+ Vector<Vector<Point2>> polys = Geometry2D::intersect_polyline_with_polygon(p_polyline, p_polygon);
Array ret;
@@ -1718,9 +965,8 @@ Array _Geometry::intersect_polyline_with_polygon_2d(const Vector<Vector2> &p_pol
return ret;
}
-Array _Geometry::offset_polygon_2d(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type) {
-
- Vector<Vector<Point2> > polys = Geometry::offset_polygon_2d(p_polygon, p_delta, Geometry::PolyJoinType(p_join_type));
+Array _Geometry2D::offset_polygon(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type) {
+ Vector<Vector<Point2>> polys = Geometry2D::offset_polygon(p_polygon, p_delta, Geometry2D::PolyJoinType(p_join_type));
Array ret;
@@ -1730,9 +976,8 @@ Array _Geometry::offset_polygon_2d(const Vector<Vector2> &p_polygon, real_t p_de
return ret;
}
-Array _Geometry::offset_polyline_2d(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type, PolyEndType p_end_type) {
-
- Vector<Vector<Point2> > polys = Geometry::offset_polyline_2d(p_polygon, p_delta, Geometry::PolyJoinType(p_join_type), Geometry::PolyEndType(p_end_type));
+Array _Geometry2D::offset_polyline(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type, PolyEndType p_end_type) {
+ Vector<Vector<Point2>> polys = Geometry2D::offset_polyline(p_polygon, p_delta, Geometry2D::PolyJoinType(p_join_type), Geometry2D::PolyEndType(p_end_type));
Array ret;
@@ -1742,86 +987,62 @@ Array _Geometry::offset_polyline_2d(const Vector<Vector2> &p_polygon, real_t p_d
return ret;
}
-Dictionary _Geometry::make_atlas(const Vector<Size2> &p_rects) {
-
+Dictionary _Geometry2D::make_atlas(const Vector<Size2> &p_rects) {
Dictionary ret;
Vector<Size2i> rects;
for (int i = 0; i < p_rects.size(); i++) {
-
rects.push_back(p_rects[i]);
- };
+ }
Vector<Point2i> result;
Size2i size;
- Geometry::make_atlas(rects, result, size);
+ Geometry2D::make_atlas(rects, result, size);
Size2 r_size = size;
Vector<Point2> r_result;
for (int i = 0; i < result.size(); i++) {
-
r_result.push_back(result[i]);
- };
+ }
ret["points"] = r_result;
ret["size"] = r_size;
return ret;
-};
-
-int _Geometry::get_uv84_normal_bit(const Vector3 &p_vector) {
-
- return Geometry::get_uv84_normal_bit(p_vector);
}
-void _Geometry::_bind_methods() {
+void _Geometry2D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("is_point_in_circle", "point", "circle_position", "circle_radius"), &_Geometry2D::is_point_in_circle);
+ ClassDB::bind_method(D_METHOD("segment_intersects_segment", "from_a", "to_a", "from_b", "to_b"), &_Geometry2D::segment_intersects_segment);
+ ClassDB::bind_method(D_METHOD("line_intersects_line", "from_a", "dir_a", "from_b", "dir_b"), &_Geometry2D::line_intersects_line);
- ClassDB::bind_method(D_METHOD("build_box_planes", "extents"), &_Geometry::build_box_planes);
- ClassDB::bind_method(D_METHOD("build_cylinder_planes", "radius", "height", "sides", "axis"), &_Geometry::build_cylinder_planes, DEFVAL(Vector3::AXIS_Z));
- ClassDB::bind_method(D_METHOD("build_capsule_planes", "radius", "height", "sides", "lats", "axis"), &_Geometry::build_capsule_planes, DEFVAL(Vector3::AXIS_Z));
- ClassDB::bind_method(D_METHOD("is_point_in_circle", "point", "circle_position", "circle_radius"), &_Geometry::is_point_in_circle);
- ClassDB::bind_method(D_METHOD("segment_intersects_circle", "segment_from", "segment_to", "circle_position", "circle_radius"), &_Geometry::segment_intersects_circle);
- ClassDB::bind_method(D_METHOD("segment_intersects_segment_2d", "from_a", "to_a", "from_b", "to_b"), &_Geometry::segment_intersects_segment_2d);
- ClassDB::bind_method(D_METHOD("line_intersects_line_2d", "from_a", "dir_a", "from_b", "dir_b"), &_Geometry::line_intersects_line_2d);
+ ClassDB::bind_method(D_METHOD("get_closest_points_between_segments", "p1", "q1", "p2", "q2"), &_Geometry2D::get_closest_points_between_segments);
- ClassDB::bind_method(D_METHOD("get_closest_points_between_segments_2d", "p1", "q1", "p2", "q2"), &_Geometry::get_closest_points_between_segments_2d);
- ClassDB::bind_method(D_METHOD("get_closest_points_between_segments", "p1", "p2", "q1", "q2"), &_Geometry::get_closest_points_between_segments);
+ ClassDB::bind_method(D_METHOD("get_closest_point_to_segment", "point", "s1", "s2"), &_Geometry2D::get_closest_point_to_segment);
- ClassDB::bind_method(D_METHOD("get_closest_point_to_segment_2d", "point", "s1", "s2"), &_Geometry::get_closest_point_to_segment_2d);
- ClassDB::bind_method(D_METHOD("get_closest_point_to_segment", "point", "s1", "s2"), &_Geometry::get_closest_point_to_segment);
+ ClassDB::bind_method(D_METHOD("get_closest_point_to_segment_uncapped", "point", "s1", "s2"), &_Geometry2D::get_closest_point_to_segment_uncapped);
- ClassDB::bind_method(D_METHOD("get_closest_point_to_segment_uncapped_2d", "point", "s1", "s2"), &_Geometry::get_closest_point_to_segment_uncapped_2d);
- ClassDB::bind_method(D_METHOD("get_closest_point_to_segment_uncapped", "point", "s1", "s2"), &_Geometry::get_closest_point_to_segment_uncapped);
+ ClassDB::bind_method(D_METHOD("point_is_inside_triangle", "point", "a", "b", "c"), &_Geometry2D::point_is_inside_triangle);
- ClassDB::bind_method(D_METHOD("get_uv84_normal_bit", "normal"), &_Geometry::get_uv84_normal_bit);
+ ClassDB::bind_method(D_METHOD("is_polygon_clockwise", "polygon"), &_Geometry2D::is_polygon_clockwise);
+ ClassDB::bind_method(D_METHOD("is_point_in_polygon", "point", "polygon"), &_Geometry2D::is_point_in_polygon);
+ ClassDB::bind_method(D_METHOD("triangulate_polygon", "polygon"), &_Geometry2D::triangulate_polygon);
+ ClassDB::bind_method(D_METHOD("triangulate_delaunay", "points"), &_Geometry2D::triangulate_delaunay);
+ ClassDB::bind_method(D_METHOD("convex_hull", "points"), &_Geometry2D::convex_hull);
- ClassDB::bind_method(D_METHOD("ray_intersects_triangle", "from", "dir", "a", "b", "c"), &_Geometry::ray_intersects_triangle);
- ClassDB::bind_method(D_METHOD("segment_intersects_triangle", "from", "to", "a", "b", "c"), &_Geometry::segment_intersects_triangle);
- ClassDB::bind_method(D_METHOD("segment_intersects_sphere", "from", "to", "sphere_position", "sphere_radius"), &_Geometry::segment_intersects_sphere);
- ClassDB::bind_method(D_METHOD("segment_intersects_cylinder", "from", "to", "height", "radius"), &_Geometry::segment_intersects_cylinder);
- ClassDB::bind_method(D_METHOD("segment_intersects_convex", "from", "to", "planes"), &_Geometry::segment_intersects_convex);
- ClassDB::bind_method(D_METHOD("point_is_inside_triangle", "point", "a", "b", "c"), &_Geometry::point_is_inside_triangle);
+ ClassDB::bind_method(D_METHOD("merge_polygons", "polygon_a", "polygon_b"), &_Geometry2D::merge_polygons);
+ ClassDB::bind_method(D_METHOD("clip_polygons", "polygon_a", "polygon_b"), &_Geometry2D::clip_polygons);
+ ClassDB::bind_method(D_METHOD("intersect_polygons", "polygon_a", "polygon_b"), &_Geometry2D::intersect_polygons);
+ ClassDB::bind_method(D_METHOD("exclude_polygons", "polygon_a", "polygon_b"), &_Geometry2D::exclude_polygons);
- ClassDB::bind_method(D_METHOD("is_polygon_clockwise", "polygon"), &_Geometry::is_polygon_clockwise);
- ClassDB::bind_method(D_METHOD("is_point_in_polygon", "point", "polygon"), &_Geometry::is_point_in_polygon);
- ClassDB::bind_method(D_METHOD("triangulate_polygon", "polygon"), &_Geometry::triangulate_polygon);
- ClassDB::bind_method(D_METHOD("triangulate_delaunay_2d", "points"), &_Geometry::triangulate_delaunay_2d);
- ClassDB::bind_method(D_METHOD("convex_hull_2d", "points"), &_Geometry::convex_hull_2d);
- ClassDB::bind_method(D_METHOD("clip_polygon", "points", "plane"), &_Geometry::clip_polygon);
+ ClassDB::bind_method(D_METHOD("clip_polyline_with_polygon", "polyline", "polygon"), &_Geometry2D::clip_polyline_with_polygon);
+ ClassDB::bind_method(D_METHOD("intersect_polyline_with_polygon", "polyline", "polygon"), &_Geometry2D::intersect_polyline_with_polygon);
- ClassDB::bind_method(D_METHOD("merge_polygons_2d", "polygon_a", "polygon_b"), &_Geometry::merge_polygons_2d);
- ClassDB::bind_method(D_METHOD("clip_polygons_2d", "polygon_a", "polygon_b"), &_Geometry::clip_polygons_2d);
- ClassDB::bind_method(D_METHOD("intersect_polygons_2d", "polygon_a", "polygon_b"), &_Geometry::intersect_polygons_2d);
- ClassDB::bind_method(D_METHOD("exclude_polygons_2d", "polygon_a", "polygon_b"), &_Geometry::exclude_polygons_2d);
+ ClassDB::bind_method(D_METHOD("offset_polygon", "polygon", "delta", "join_type"), &_Geometry2D::offset_polygon, DEFVAL(JOIN_SQUARE));
+ ClassDB::bind_method(D_METHOD("offset_polyline", "polyline", "delta", "join_type", "end_type"), &_Geometry2D::offset_polyline, DEFVAL(JOIN_SQUARE), DEFVAL(END_SQUARE));
- ClassDB::bind_method(D_METHOD("clip_polyline_with_polygon_2d", "polyline", "polygon"), &_Geometry::clip_polyline_with_polygon_2d);
- ClassDB::bind_method(D_METHOD("intersect_polyline_with_polygon_2d", "polyline", "polygon"), &_Geometry::intersect_polyline_with_polygon_2d);
-
- ClassDB::bind_method(D_METHOD("offset_polygon_2d", "polygon", "delta", "join_type"), &_Geometry::offset_polygon_2d, DEFVAL(JOIN_SQUARE));
- ClassDB::bind_method(D_METHOD("offset_polyline_2d", "polyline", "delta", "join_type", "end_type"), &_Geometry::offset_polyline_2d, DEFVAL(JOIN_SQUARE), DEFVAL(END_SQUARE));
-
- ClassDB::bind_method(D_METHOD("make_atlas", "sizes"), &_Geometry::make_atlas);
+ ClassDB::bind_method(D_METHOD("make_atlas", "sizes"), &_Geometry2D::make_atlas);
BIND_ENUM_CONSTANT(OPERATION_UNION);
BIND_ENUM_CONSTANT(OPERATION_DIFFERENCE);
@@ -1839,17 +1060,140 @@ void _Geometry::_bind_methods() {
BIND_ENUM_CONSTANT(END_ROUND);
}
-_Geometry::_Geometry() {
- singleton = this;
+////// _Geometry3D //////
+
+_Geometry3D *_Geometry3D::singleton = nullptr;
+
+_Geometry3D *_Geometry3D::get_singleton() {
+ return singleton;
+}
+
+Vector<Plane> _Geometry3D::build_box_planes(const Vector3 &p_extents) {
+ return Geometry3D::build_box_planes(p_extents);
}
-///////////////////////// FILE
+Vector<Plane> _Geometry3D::build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis) {
+ return Geometry3D::build_cylinder_planes(p_radius, p_height, p_sides, p_axis);
+}
-Error _File::open_encrypted(const String &p_path, ModeFlags p_mode_flags, const Vector<uint8_t> &p_key) {
+Vector<Plane> _Geometry3D::build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
+ return Geometry3D::build_capsule_planes(p_radius, p_height, p_sides, p_lats, p_axis);
+}
+
+Vector<Vector3> _Geometry3D::get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2) {
+ Vector3 r1, r2;
+ Geometry3D::get_closest_points_between_segments(p1, p2, q1, q2, r1, r2);
+ Vector<Vector3> r;
+ r.resize(2);
+ r.set(0, r1);
+ r.set(1, r2);
+ return r;
+}
+
+Vector3 _Geometry3D::get_closest_point_to_segment(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b) {
+ Vector3 s[2] = { p_a, p_b };
+ return Geometry3D::get_closest_point_to_segment(p_point, s);
+}
+
+Vector3 _Geometry3D::get_closest_point_to_segment_uncapped(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b) {
+ Vector3 s[2] = { p_a, p_b };
+ return Geometry3D::get_closest_point_to_segment_uncapped(p_point, s);
+}
+
+Variant _Geometry3D::ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2) {
+ Vector3 res;
+ if (Geometry3D::ray_intersects_triangle(p_from, p_dir, p_v0, p_v1, p_v2, &res)) {
+ return res;
+ } else {
+ return Variant();
+ }
+}
+
+Variant _Geometry3D::segment_intersects_triangle(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2) {
+ Vector3 res;
+ if (Geometry3D::segment_intersects_triangle(p_from, p_to, p_v0, p_v1, p_v2, &res)) {
+ return res;
+ } else {
+ return Variant();
+ }
+}
+Vector<Vector3> _Geometry3D::segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius) {
+ Vector<Vector3> r;
+ Vector3 res, norm;
+ if (!Geometry3D::segment_intersects_sphere(p_from, p_to, p_sphere_pos, p_sphere_radius, &res, &norm)) {
+ return r;
+ }
+
+ r.resize(2);
+ r.set(0, res);
+ r.set(1, norm);
+ return r;
+}
+
+Vector<Vector3> _Geometry3D::segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius) {
+ Vector<Vector3> r;
+ Vector3 res, norm;
+ if (!Geometry3D::segment_intersects_cylinder(p_from, p_to, p_height, p_radius, &res, &norm)) {
+ return r;
+ }
+
+ r.resize(2);
+ r.set(0, res);
+ r.set(1, norm);
+ return r;
+}
+
+Vector<Vector3> _Geometry3D::segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const Vector<Plane> &p_planes) {
+ Vector<Vector3> r;
+ Vector3 res, norm;
+ if (!Geometry3D::segment_intersects_convex(p_from, p_to, p_planes.ptr(), p_planes.size(), &res, &norm)) {
+ return r;
+ }
+
+ r.resize(2);
+ r.set(0, res);
+ r.set(1, norm);
+ return r;
+}
+
+Vector<Vector3> _Geometry3D::clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane) {
+ return Geometry3D::clip_polygon(p_points, p_plane);
+}
+
+int _Geometry3D::get_uv84_normal_bit(const Vector3 &p_vector) {
+ return Geometry3D::get_uv84_normal_bit(p_vector);
+}
+
+void _Geometry3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("build_box_planes", "extents"), &_Geometry3D::build_box_planes);
+ ClassDB::bind_method(D_METHOD("build_cylinder_planes", "radius", "height", "sides", "axis"), &_Geometry3D::build_cylinder_planes, DEFVAL(Vector3::AXIS_Z));
+ ClassDB::bind_method(D_METHOD("build_capsule_planes", "radius", "height", "sides", "lats", "axis"), &_Geometry3D::build_capsule_planes, DEFVAL(Vector3::AXIS_Z));
+
+ ClassDB::bind_method(D_METHOD("get_closest_points_between_segments", "p1", "p2", "q1", "q2"), &_Geometry3D::get_closest_points_between_segments);
+
+ ClassDB::bind_method(D_METHOD("get_closest_point_to_segment", "point", "s1", "s2"), &_Geometry3D::get_closest_point_to_segment);
+
+ ClassDB::bind_method(D_METHOD("get_closest_point_to_segment_uncapped", "point", "s1", "s2"), &_Geometry3D::get_closest_point_to_segment_uncapped);
+
+ ClassDB::bind_method(D_METHOD("get_uv84_normal_bit", "normal"), &_Geometry3D::get_uv84_normal_bit);
+
+ ClassDB::bind_method(D_METHOD("ray_intersects_triangle", "from", "dir", "a", "b", "c"), &_Geometry3D::ray_intersects_triangle);
+ ClassDB::bind_method(D_METHOD("segment_intersects_triangle", "from", "to", "a", "b", "c"), &_Geometry3D::segment_intersects_triangle);
+ ClassDB::bind_method(D_METHOD("segment_intersects_sphere", "from", "to", "sphere_position", "sphere_radius"), &_Geometry3D::segment_intersects_sphere);
+ ClassDB::bind_method(D_METHOD("segment_intersects_cylinder", "from", "to", "height", "radius"), &_Geometry3D::segment_intersects_cylinder);
+ ClassDB::bind_method(D_METHOD("segment_intersects_convex", "from", "to", "planes"), &_Geometry3D::segment_intersects_convex);
+
+ ClassDB::bind_method(D_METHOD("clip_polygon", "points", "plane"), &_Geometry3D::clip_polygon);
+}
+
+////// _File //////
+
+Error _File::open_encrypted(const String &p_path, ModeFlags p_mode_flags, const Vector<uint8_t> &p_key) {
Error err = open(p_path, p_mode_flags);
- if (err)
+ if (err) {
return err;
+ }
FileAccessEncrypted *fae = memnew(FileAccessEncrypted);
err = fae->open_and_parse(f, p_key, (p_mode_flags == WRITE) ? FileAccessEncrypted::MODE_WRITE_AES256 : FileAccessEncrypted::MODE_READ);
@@ -1863,10 +1207,10 @@ Error _File::open_encrypted(const String &p_path, ModeFlags p_mode_flags, const
}
Error _File::open_encrypted_pass(const String &p_path, ModeFlags p_mode_flags, const String &p_pass) {
-
Error err = open(p_path, p_mode_flags);
- if (err)
+ if (err) {
return err;
+ }
FileAccessEncrypted *fae = memnew(FileAccessEncrypted);
err = fae->open_and_parse_password(f, p_pass, (p_mode_flags == WRITE) ? FileAccessEncrypted::MODE_WRITE_AES256 : FileAccessEncrypted::MODE_READ);
@@ -1881,7 +1225,6 @@ Error _File::open_encrypted_pass(const String &p_path, ModeFlags p_mode_flags, c
}
Error _File::open_compressed(const String &p_path, ModeFlags p_mode_flags, CompressionMode p_compress_mode) {
-
FileAccessCompressed *fac = memnew(FileAccessCompressed);
fac->configure("GCPF", (Compression::Mode)p_compress_mode);
@@ -1898,128 +1241,120 @@ Error _File::open_compressed(const String &p_path, ModeFlags p_mode_flags, Compr
}
Error _File::open(const String &p_path, ModeFlags p_mode_flags) {
-
close();
Error err;
f = FileAccess::open(p_path, p_mode_flags, &err);
- if (f)
+ if (f) {
f->set_endian_swap(eswap);
+ }
return err;
}
void _File::close() {
-
- if (f)
+ if (f) {
memdelete(f);
- f = NULL;
+ }
+ f = nullptr;
}
-bool _File::is_open() const {
- return f != NULL;
+bool _File::is_open() const {
+ return f != nullptr;
}
-String _File::get_path() const {
+String _File::get_path() const {
ERR_FAIL_COND_V_MSG(!f, "", "File must be opened before use.");
return f->get_path();
}
String _File::get_path_absolute() const {
-
ERR_FAIL_COND_V_MSG(!f, "", "File must be opened before use.");
return f->get_path_absolute();
}
void _File::seek(int64_t p_position) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->seek(p_position);
}
-void _File::seek_end(int64_t p_position) {
+void _File::seek_end(int64_t p_position) {
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->seek_end(p_position);
}
-int64_t _File::get_position() const {
+int64_t _File::get_position() const {
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_position();
}
int64_t _File::get_len() const {
-
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_len();
}
bool _File::eof_reached() const {
-
ERR_FAIL_COND_V_MSG(!f, false, "File must be opened before use.");
return f->eof_reached();
}
uint8_t _File::get_8() const {
-
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_8();
}
-uint16_t _File::get_16() const {
+uint16_t _File::get_16() const {
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_16();
}
-uint32_t _File::get_32() const {
+uint32_t _File::get_32() const {
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_32();
}
-uint64_t _File::get_64() const {
+uint64_t _File::get_64() const {
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_64();
}
float _File::get_float() const {
-
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_float();
}
-double _File::get_double() const {
+double _File::get_double() const {
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_double();
}
-real_t _File::get_real() const {
+real_t _File::get_real() const {
ERR_FAIL_COND_V_MSG(!f, 0, "File must be opened before use.");
return f->get_real();
}
-PoolVector<uint8_t> _File::get_buffer(int p_length) const {
-
- PoolVector<uint8_t> data;
+Vector<uint8_t> _File::get_buffer(int p_length) const {
+ Vector<uint8_t> data;
ERR_FAIL_COND_V_MSG(!f, data, "File must be opened before use.");
ERR_FAIL_COND_V_MSG(p_length < 0, data, "Length of buffer cannot be smaller than 0.");
- if (p_length == 0)
+ if (p_length == 0) {
return data;
+ }
Error err = data.resize(p_length);
ERR_FAIL_COND_V_MSG(err != OK, data, "Can't resize data to " + itos(p_length) + " elements.");
- PoolVector<uint8_t>::Write w = data.write();
+ uint8_t *w = data.ptrw();
int len = f->get_buffer(&w[0], p_length);
- ERR_FAIL_COND_V(len < 0, PoolVector<uint8_t>());
-
- w.release();
+ ERR_FAIL_COND_V(len < 0, Vector<uint8_t>());
- if (len < p_length)
+ if (len < p_length) {
data.resize(p_length);
+ }
return data;
}
String _File::get_as_text() const {
-
ERR_FAIL_COND_V_MSG(!f, String(), "File must be opened before use.");
String text;
@@ -2039,17 +1374,14 @@ String _File::get_as_text() const {
}
String _File::get_md5(const String &p_path) const {
-
return FileAccess::get_md5(p_path);
}
String _File::get_sha256(const String &p_path) const {
-
return FileAccess::get_sha256(p_path);
}
String _File::get_line() const {
-
ERR_FAIL_COND_V_MSG(!f, String(), "File must be opened before use.");
return f->get_line();
}
@@ -2065,90 +1397,84 @@ Vector<String> _File::get_csv_line(const String &p_delim) const {
*/
void _File::set_endian_swap(bool p_swap) {
-
eswap = p_swap;
- if (f)
+ if (f) {
f->set_endian_swap(p_swap);
+ }
}
-bool _File::get_endian_swap() {
+bool _File::get_endian_swap() {
return eswap;
}
Error _File::get_error() const {
-
- if (!f)
+ if (!f) {
return ERR_UNCONFIGURED;
+ }
return f->get_error();
}
void _File::store_8(uint8_t p_dest) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_8(p_dest);
}
-void _File::store_16(uint16_t p_dest) {
+void _File::store_16(uint16_t p_dest) {
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_16(p_dest);
}
-void _File::store_32(uint32_t p_dest) {
+void _File::store_32(uint32_t p_dest) {
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_32(p_dest);
}
-void _File::store_64(uint64_t p_dest) {
+void _File::store_64(uint64_t p_dest) {
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_64(p_dest);
}
void _File::store_float(float p_dest) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_float(p_dest);
}
-void _File::store_double(double p_dest) {
+void _File::store_double(double p_dest) {
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_double(p_dest);
}
-void _File::store_real(real_t p_real) {
+void _File::store_real(real_t p_real) {
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_real(p_real);
}
void _File::store_string(const String &p_string) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_string(p_string);
}
void _File::store_pascal_string(const String &p_string) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_pascal_string(p_string);
-};
+}
String _File::get_pascal_string() {
-
ERR_FAIL_COND_V_MSG(!f, "", "File must be opened before use.");
return f->get_pascal_string();
-};
+}
void _File::store_line(const String &p_string) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
f->store_line(p_string);
}
@@ -2158,66 +1484,60 @@ void _File::store_csv_line(const Vector<String> &p_values, const String &p_delim
f->store_csv_line(p_values, p_delim);
}
-void _File::store_buffer(const PoolVector<uint8_t> &p_buffer) {
-
+void _File::store_buffer(const Vector<uint8_t> &p_buffer) {
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
int len = p_buffer.size();
- if (len == 0)
+ if (len == 0) {
return;
+ }
- PoolVector<uint8_t>::Read r = p_buffer.read();
+ const uint8_t *r = p_buffer.ptr();
f->store_buffer(&r[0], len);
}
bool _File::file_exists(const String &p_name) const {
-
return FileAccess::exists(p_name);
}
void _File::store_var(const Variant &p_var, bool p_full_objects) {
-
ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
int len;
- Error err = encode_variant(p_var, NULL, len, p_full_objects);
+ Error err = encode_variant(p_var, nullptr, len, p_full_objects);
ERR_FAIL_COND_MSG(err != OK, "Error when trying to encode Variant.");
- PoolVector<uint8_t> buff;
+ Vector<uint8_t> buff;
buff.resize(len);
- PoolVector<uint8_t>::Write w = buff.write();
+ uint8_t *w = buff.ptrw();
err = encode_variant(p_var, &w[0], len, p_full_objects);
ERR_FAIL_COND_MSG(err != OK, "Error when trying to encode Variant.");
- w.release();
store_32(len);
store_buffer(buff);
}
Variant _File::get_var(bool p_allow_objects) const {
-
ERR_FAIL_COND_V_MSG(!f, Variant(), "File must be opened before use.");
uint32_t len = get_32();
- PoolVector<uint8_t> buff = get_buffer(len);
+ Vector<uint8_t> buff = get_buffer(len);
ERR_FAIL_COND_V((uint32_t)buff.size() != len, Variant());
- PoolVector<uint8_t>::Read r = buff.read();
+ const uint8_t *r = buff.ptr();
Variant v;
- Error err = decode_variant(v, &r[0], len, NULL, p_allow_objects);
+ Error err = decode_variant(v, &r[0], len, nullptr, p_allow_objects);
ERR_FAIL_COND_V_MSG(err != OK, Variant(), "Error when trying to encode Variant.");
return v;
}
uint64_t _File::get_modified_time(const String &p_file) const {
-
return FileAccess::get_modified_time(p_file);
}
void _File::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("open_encrypted", "path", "mode_flags", "key"), &_File::open_encrypted);
ClassDB::bind_method(D_METHOD("open_encrypted_with_pass", "path", "mode_flags", "pass"), &_File::open_encrypted_pass);
ClassDB::bind_method(D_METHOD("open_compressed", "path", "mode_flags", "compression_mode"), &_File::open_compressed, DEFVAL(0));
@@ -2282,36 +1602,36 @@ void _File::_bind_methods() {
BIND_ENUM_CONSTANT(COMPRESSION_GZIP);
}
-_File::_File() {
-
- f = NULL;
- eswap = false;
-}
-
_File::~_File() {
-
- if (f)
+ if (f) {
memdelete(f);
+ }
}
-///////////////////////////////////////////////////////
+////// _Directory //////
Error _Directory::open(const String &p_path) {
Error err;
DirAccess *alt = DirAccess::open(p_path, &err);
- if (!alt)
+ if (!alt) {
return err;
- if (d)
+ }
+ if (d) {
memdelete(d);
+ }
d = alt;
+ dir_open = true;
return OK;
}
-Error _Directory::list_dir_begin(bool p_skip_navigational, bool p_skip_hidden) {
+bool _Directory::is_open() const {
+ return d && dir_open;
+}
- ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
+Error _Directory::list_dir_begin(bool p_skip_navigational, bool p_skip_hidden) {
+ ERR_FAIL_COND_V_MSG(!is_open(), ERR_UNCONFIGURED, "Directory must be opened before use.");
_list_skip_navigational = p_skip_navigational;
_list_skip_hidden = p_skip_hidden;
@@ -2320,56 +1640,59 @@ Error _Directory::list_dir_begin(bool p_skip_navigational, bool p_skip_hidden) {
}
String _Directory::get_next() {
-
- ERR_FAIL_COND_V_MSG(!d, "", "Directory must be opened before use.");
+ ERR_FAIL_COND_V_MSG(!is_open(), "", "Directory must be opened before use.");
String next = d->get_next();
while (next != "" && ((_list_skip_navigational && (next == "." || next == "..")) || (_list_skip_hidden && d->current_is_hidden()))) {
-
next = d->get_next();
}
return next;
}
-bool _Directory::current_is_dir() const {
- ERR_FAIL_COND_V_MSG(!d, false, "Directory must be opened before use.");
+bool _Directory::current_is_dir() const {
+ ERR_FAIL_COND_V_MSG(!is_open(), false, "Directory must be opened before use.");
return d->current_is_dir();
}
void _Directory::list_dir_end() {
-
- ERR_FAIL_COND_MSG(!d, "Directory must be opened before use.");
+ ERR_FAIL_COND_MSG(!is_open(), "Directory must be opened before use.");
d->list_dir_end();
}
int _Directory::get_drive_count() {
-
- ERR_FAIL_COND_V_MSG(!d, 0, "Directory must be opened before use.");
+ ERR_FAIL_COND_V_MSG(!is_open(), 0, "Directory must be opened before use.");
return d->get_drive_count();
}
-String _Directory::get_drive(int p_drive) {
- ERR_FAIL_COND_V_MSG(!d, "", "Directory must be opened before use.");
+String _Directory::get_drive(int p_drive) {
+ ERR_FAIL_COND_V_MSG(!is_open(), "", "Directory must be opened before use.");
return d->get_drive(p_drive);
}
+
int _Directory::get_current_drive() {
- ERR_FAIL_COND_V_MSG(!d, 0, "Directory must be opened before use.");
+ ERR_FAIL_COND_V_MSG(!is_open(), 0, "Directory must be opened before use.");
return d->get_current_drive();
}
Error _Directory::change_dir(String p_dir) {
+ ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory is not configured properly.");
+ Error err = d->change_dir(p_dir);
+
+ if (err != OK) {
+ return err;
+ }
+ dir_open = true;
- ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
- return d->change_dir(p_dir);
+ return OK;
}
-String _Directory::get_current_dir() {
- ERR_FAIL_COND_V_MSG(!d, "", "Directory must be opened before use.");
+String _Directory::get_current_dir() {
+ ERR_FAIL_COND_V_MSG(!is_open(), "", "Directory must be opened before use.");
return d->get_current_dir();
}
-Error _Directory::make_dir(String p_dir) {
- ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
+Error _Directory::make_dir(String p_dir) {
+ ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory is not configured properly.");
if (!p_dir.is_rel_path()) {
DirAccess *d = DirAccess::create_for_path(p_dir);
Error err = d->make_dir(p_dir);
@@ -2378,9 +1701,9 @@ Error _Directory::make_dir(String p_dir) {
}
return d->make_dir(p_dir);
}
-Error _Directory::make_dir_recursive(String p_dir) {
- ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
+Error _Directory::make_dir_recursive(String p_dir) {
+ ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory is not configured properly.");
if (!p_dir.is_rel_path()) {
DirAccess *d = DirAccess::create_for_path(p_dir);
Error err = d->make_dir_recursive(p_dir);
@@ -2391,9 +1714,7 @@ Error _Directory::make_dir_recursive(String p_dir) {
}
bool _Directory::file_exists(String p_file) {
-
- ERR_FAIL_COND_V_MSG(!d, false, "Directory must be opened before use.");
-
+ ERR_FAIL_COND_V_MSG(!d, false, "Directory is not configured properly.");
if (!p_file.is_rel_path()) {
return FileAccess::exists(p_file);
}
@@ -2402,33 +1723,29 @@ bool _Directory::file_exists(String p_file) {
}
bool _Directory::dir_exists(String p_dir) {
- ERR_FAIL_COND_V_MSG(!d, false, "Directory must be opened before use.");
+ ERR_FAIL_COND_V_MSG(!d, false, "Directory is not configured properly.");
if (!p_dir.is_rel_path()) {
-
DirAccess *d = DirAccess::create_for_path(p_dir);
bool exists = d->dir_exists(p_dir);
memdelete(d);
return exists;
-
- } else {
- return d->dir_exists(p_dir);
}
+
+ return d->dir_exists(p_dir);
}
int _Directory::get_space_left() {
-
- ERR_FAIL_COND_V_MSG(!d, 0, "Directory must be opened before use.");
+ ERR_FAIL_COND_V_MSG(!is_open(), 0, "Directory must be opened before use.");
return d->get_space_left() / 1024 * 1024; //return value in megabytes, given binding is int
}
Error _Directory::copy(String p_from, String p_to) {
-
- ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
+ ERR_FAIL_COND_V_MSG(!is_open(), ERR_UNCONFIGURED, "Directory must be opened before use.");
return d->copy(p_from, p_to);
}
-Error _Directory::rename(String p_from, String p_to) {
- ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
+Error _Directory::rename(String p_from, String p_to) {
+ ERR_FAIL_COND_V_MSG(!is_open(), ERR_UNCONFIGURED, "Directory must be opened before use.");
if (!p_from.is_rel_path()) {
DirAccess *d = DirAccess::create_for_path(p_from);
Error err = d->rename(p_from, p_to);
@@ -2438,9 +1755,9 @@ Error _Directory::rename(String p_from, String p_to) {
return d->rename(p_from, p_to);
}
-Error _Directory::remove(String p_name) {
- ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory must be opened before use.");
+Error _Directory::remove(String p_name) {
+ ERR_FAIL_COND_V_MSG(!is_open(), ERR_UNCONFIGURED, "Directory must be opened before use.");
if (!p_name.is_rel_path()) {
DirAccess *d = DirAccess::create_for_path(p_name);
Error err = d->remove(p_name);
@@ -2452,7 +1769,6 @@ Error _Directory::remove(String p_name) {
}
void _Directory::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("open", "path"), &_Directory::open);
ClassDB::bind_method(D_METHOD("list_dir_begin", "skip_navigational", "skip_hidden"), &_Directory::list_dir_begin, DEFVAL(false), DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_next"), &_Directory::get_next);
@@ -2475,31 +1791,31 @@ void _Directory::_bind_methods() {
}
_Directory::_Directory() {
-
d = DirAccess::create(DirAccess::ACCESS_RESOURCES);
}
_Directory::~_Directory() {
-
- if (d)
+ if (d) {
memdelete(d);
+ }
}
-_Marshalls *_Marshalls::singleton = NULL;
+////// _Marshalls //////
+
+_Marshalls *_Marshalls::singleton = nullptr;
_Marshalls *_Marshalls::get_singleton() {
return singleton;
}
String _Marshalls::variant_to_base64(const Variant &p_var, bool p_full_objects) {
-
int len;
- Error err = encode_variant(p_var, NULL, len, p_full_objects);
+ Error err = encode_variant(p_var, nullptr, len, p_full_objects);
ERR_FAIL_COND_V_MSG(err != OK, "", "Error when trying to encode Variant.");
- PoolVector<uint8_t> buff;
+ Vector<uint8_t> buff;
buff.resize(len);
- PoolVector<uint8_t>::Write w = buff.write();
+ uint8_t *w = buff.ptrw();
err = encode_variant(p_var, &w[0], len, p_full_objects);
ERR_FAIL_COND_V_MSG(err != OK, "", "Error when trying to encode Variant.");
@@ -2508,68 +1824,63 @@ String _Marshalls::variant_to_base64(const Variant &p_var, bool p_full_objects)
ERR_FAIL_COND_V(ret == "", ret);
return ret;
-};
+}
Variant _Marshalls::base64_to_variant(const String &p_str, bool p_allow_objects) {
-
int strlen = p_str.length();
CharString cstr = p_str.ascii();
- PoolVector<uint8_t> buf;
+ Vector<uint8_t> buf;
buf.resize(strlen / 4 * 3 + 1);
- PoolVector<uint8_t>::Write w = buf.write();
+ uint8_t *w = buf.ptrw();
size_t len = 0;
ERR_FAIL_COND_V(CryptoCore::b64_decode(&w[0], buf.size(), &len, (unsigned char *)cstr.get_data(), strlen) != OK, Variant());
Variant v;
- Error err = decode_variant(v, &w[0], len, NULL, p_allow_objects);
+ Error err = decode_variant(v, &w[0], len, nullptr, p_allow_objects);
ERR_FAIL_COND_V_MSG(err != OK, Variant(), "Error when trying to decode Variant.");
return v;
-};
-
-String _Marshalls::raw_to_base64(const PoolVector<uint8_t> &p_arr) {
+}
- String ret = CryptoCore::b64_encode_str(p_arr.read().ptr(), p_arr.size());
+String _Marshalls::raw_to_base64(const Vector<uint8_t> &p_arr) {
+ String ret = CryptoCore::b64_encode_str(p_arr.ptr(), p_arr.size());
ERR_FAIL_COND_V(ret == "", ret);
return ret;
-};
-
-PoolVector<uint8_t> _Marshalls::base64_to_raw(const String &p_str) {
+}
+Vector<uint8_t> _Marshalls::base64_to_raw(const String &p_str) {
int strlen = p_str.length();
CharString cstr = p_str.ascii();
size_t arr_len = 0;
- PoolVector<uint8_t> buf;
+ Vector<uint8_t> buf;
{
buf.resize(strlen / 4 * 3 + 1);
- PoolVector<uint8_t>::Write w = buf.write();
+ uint8_t *w = buf.ptrw();
- ERR_FAIL_COND_V(CryptoCore::b64_decode(&w[0], buf.size(), &arr_len, (unsigned char *)cstr.get_data(), strlen) != OK, PoolVector<uint8_t>());
+ ERR_FAIL_COND_V(CryptoCore::b64_decode(&w[0], buf.size(), &arr_len, (unsigned char *)cstr.get_data(), strlen) != OK, Vector<uint8_t>());
}
buf.resize(arr_len);
return buf;
-};
+}
String _Marshalls::utf8_to_base64(const String &p_str) {
-
CharString cstr = p_str.utf8();
String ret = CryptoCore::b64_encode_str((unsigned char *)cstr.get_data(), cstr.length());
ERR_FAIL_COND_V(ret == "", ret);
return ret;
-};
+}
String _Marshalls::base64_to_utf8(const String &p_str) {
-
int strlen = p_str.length();
CharString cstr = p_str.ascii();
- PoolVector<uint8_t> buf;
+ Vector<uint8_t> buf;
buf.resize(strlen / 4 * 3 + 1 + 1);
- PoolVector<uint8_t>::Write w = buf.write();
+ uint8_t *w = buf.ptrw();
size_t len = 0;
ERR_FAIL_COND_V(CryptoCore::b64_decode(&w[0], buf.size(), &len, (unsigned char *)cstr.get_data(), strlen) != OK, String());
@@ -2578,10 +1889,9 @@ String _Marshalls::base64_to_utf8(const String &p_str) {
String ret = String::utf8((char *)&w[0]);
return ret;
-};
+}
void _Marshalls::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("variant_to_base64", "variant", "full_objects"), &_Marshalls::variant_to_base64, DEFVAL(false));
ClassDB::bind_method(D_METHOD("base64_to_variant", "base64_str", "allow_objects"), &_Marshalls::base64_to_variant, DEFVAL(false));
@@ -2590,101 +1900,73 @@ void _Marshalls::_bind_methods() {
ClassDB::bind_method(D_METHOD("utf8_to_base64", "utf8_str"), &_Marshalls::utf8_to_base64);
ClassDB::bind_method(D_METHOD("base64_to_utf8", "base64_str"), &_Marshalls::base64_to_utf8);
-};
-
-////////////////
+}
-Error _Semaphore::wait() {
+////// _Semaphore //////
- return semaphore->wait();
+void _Semaphore::wait() {
+ semaphore.wait();
}
-Error _Semaphore::post() {
+Error _Semaphore::try_wait() {
+ return semaphore.try_wait() ? OK : ERR_BUSY;
+}
- return semaphore->post();
+void _Semaphore::post() {
+ semaphore.post();
}
void _Semaphore::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("wait"), &_Semaphore::wait);
+ ClassDB::bind_method(D_METHOD("try_wait"), &_Semaphore::try_wait);
ClassDB::bind_method(D_METHOD("post"), &_Semaphore::post);
}
-_Semaphore::_Semaphore() {
-
- semaphore = Semaphore::create();
-}
-
-_Semaphore::~_Semaphore() {
-
- memdelete(semaphore);
-}
-
-///////////////
+////// _Mutex //////
void _Mutex::lock() {
-
- mutex->lock();
+ mutex.lock();
}
Error _Mutex::try_lock() {
-
- return mutex->try_lock();
+ return mutex.try_lock();
}
void _Mutex::unlock() {
-
- mutex->unlock();
+ mutex.unlock();
}
void _Mutex::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("lock"), &_Mutex::lock);
ClassDB::bind_method(D_METHOD("try_lock"), &_Mutex::try_lock);
ClassDB::bind_method(D_METHOD("unlock"), &_Mutex::unlock);
}
-_Mutex::_Mutex() {
-
- mutex = Mutex::create();
-}
-
-_Mutex::~_Mutex() {
-
- memdelete(mutex);
-}
-
-///////////////
+////// _Thread //////
void _Thread::_start_func(void *ud) {
-
Ref<_Thread> *tud = (Ref<_Thread> *)ud;
Ref<_Thread> t = *tud;
memdelete(tud);
- Variant::CallError ce;
+ Callable::CallError ce;
const Variant *arg[1] = { &t->userdata };
Thread::set_name(t->target_method);
t->ret = t->target_instance->call(t->target_method, arg, 1, ce);
- if (ce.error != Variant::CallError::CALL_OK) {
-
+ if (ce.error != Callable::CallError::CALL_OK) {
String reason;
switch (ce.error) {
- case Variant::CallError::CALL_ERROR_INVALID_ARGUMENT: {
-
+ case Callable::CallError::CALL_ERROR_INVALID_ARGUMENT: {
reason = "Invalid Argument #" + itos(ce.argument);
} break;
- case Variant::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS: {
-
+ case Callable::CallError::CALL_ERROR_TOO_MANY_ARGUMENTS: {
reason = "Too Many Arguments";
} break;
- case Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS: {
-
+ case Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS: {
reason = "Too Few Arguments";
} break;
- case Variant::CallError::CALL_ERROR_INVALID_METHOD: {
-
+ case Callable::CallError::CALL_ERROR_INVALID_METHOD: {
reason = "Method Not Found";
} break;
default: {
@@ -2696,7 +1978,6 @@ void _Thread::_start_func(void *ud) {
}
Error _Thread::start(Object *p_instance, const StringName &p_method, const Variant &p_userdata, Priority p_priority) {
-
ERR_FAIL_COND_V_MSG(active, ERR_ALREADY_IN_USE, "Thread already started.");
ERR_FAIL_COND_V(!p_instance, ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(p_method == StringName(), ERR_INVALID_PARAMETER);
@@ -2716,7 +1997,7 @@ Error _Thread::start(Object *p_instance, const StringName &p_method, const Varia
if (!thread) {
active = false;
target_method = StringName();
- target_instance = NULL;
+ target_instance = nullptr;
userdata = Variant();
return ERR_CANT_CREATE;
}
@@ -2725,36 +2006,35 @@ Error _Thread::start(Object *p_instance, const StringName &p_method, const Varia
}
String _Thread::get_id() const {
-
- if (!thread)
+ if (!thread) {
return String();
+ }
return itos(thread->get_id());
}
bool _Thread::is_active() const {
-
return active;
}
-Variant _Thread::wait_to_finish() {
+Variant _Thread::wait_to_finish() {
ERR_FAIL_COND_V_MSG(!thread, Variant(), "Thread must exist to wait for its completion.");
ERR_FAIL_COND_V_MSG(!active, Variant(), "Thread must be active to wait for its completion.");
Thread::wait_to_finish(thread);
Variant r = ret;
active = false;
target_method = StringName();
- target_instance = NULL;
+ target_instance = nullptr;
userdata = Variant();
- if (thread)
+ if (thread) {
memdelete(thread);
- thread = NULL;
+ }
+ thread = nullptr;
return r;
}
void _Thread::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("start", "instance", "method", "userdata", "priority"), &_Thread::start, DEFVAL(Variant()), DEFVAL(PRIORITY_NORMAL));
ClassDB::bind_method(D_METHOD("get_id"), &_Thread::get_id);
ClassDB::bind_method(D_METHOD("is_active"), &_Thread::is_active);
@@ -2764,26 +2044,18 @@ void _Thread::_bind_methods() {
BIND_ENUM_CONSTANT(PRIORITY_NORMAL);
BIND_ENUM_CONSTANT(PRIORITY_HIGH);
}
-_Thread::_Thread() {
-
- active = false;
- thread = NULL;
- target_instance = NULL;
-}
_Thread::~_Thread() {
-
ERR_FAIL_COND_MSG(active, "Reference to a Thread object was lost while the thread is still running...");
}
-/////////////////////////////////////
-
-PoolStringArray _ClassDB::get_class_list() const {
+////// _ClassDB //////
+PackedStringArray _ClassDB::get_class_list() const {
List<StringName> classes;
ClassDB::get_class_list(&classes);
- PoolStringArray ret;
+ PackedStringArray ret;
ret.resize(classes.size());
int idx = 0;
for (List<StringName>::Element *E = classes.front(); E; E = E->next()) {
@@ -2792,12 +2064,12 @@ PoolStringArray _ClassDB::get_class_list() const {
return ret;
}
-PoolStringArray _ClassDB::get_inheriters_from_class(const StringName &p_class) const {
+PackedStringArray _ClassDB::get_inheriters_from_class(const StringName &p_class) const {
List<StringName> classes;
ClassDB::get_inheriters_from_class(p_class, &classes);
- PoolStringArray ret;
+ PackedStringArray ret;
ret.resize(classes.size());
int idx = 0;
for (List<StringName>::Element *E = classes.front(); E; E = E->next()) {
@@ -2806,27 +2078,28 @@ PoolStringArray _ClassDB::get_inheriters_from_class(const StringName &p_class) c
return ret;
}
-StringName _ClassDB::get_parent_class(const StringName &p_class) const {
+StringName _ClassDB::get_parent_class(const StringName &p_class) const {
return ClassDB::get_parent_class(p_class);
}
-bool _ClassDB::class_exists(const StringName &p_class) const {
+bool _ClassDB::class_exists(const StringName &p_class) const {
return ClassDB::class_exists(p_class);
}
-bool _ClassDB::is_parent_class(const StringName &p_class, const StringName &p_inherits) const {
+bool _ClassDB::is_parent_class(const StringName &p_class, const StringName &p_inherits) const {
return ClassDB::is_parent_class(p_class, p_inherits);
}
-bool _ClassDB::can_instance(const StringName &p_class) const {
+bool _ClassDB::can_instance(const StringName &p_class) const {
return ClassDB::can_instance(p_class);
}
-Variant _ClassDB::instance(const StringName &p_class) const {
+Variant _ClassDB::instance(const StringName &p_class) const {
Object *obj = ClassDB::instance(p_class);
- if (!obj)
+ if (!obj) {
return Variant();
+ }
Reference *r = Object::cast_to<Reference>(obj);
if (r) {
@@ -2837,11 +2110,10 @@ Variant _ClassDB::instance(const StringName &p_class) const {
}
bool _ClassDB::has_signal(StringName p_class, StringName p_signal) const {
-
return ClassDB::has_signal(p_class, p_signal);
}
-Dictionary _ClassDB::get_signal(StringName p_class, StringName p_signal) const {
+Dictionary _ClassDB::get_signal(StringName p_class, StringName p_signal) const {
MethodInfo signal;
if (ClassDB::get_signal(p_class, p_signal, &signal)) {
return signal.operator Dictionary();
@@ -2849,8 +2121,8 @@ Dictionary _ClassDB::get_signal(StringName p_class, StringName p_signal) const {
return Dictionary();
}
}
-Array _ClassDB::get_signal_list(StringName p_class, bool p_no_inheritance) const {
+Array _ClassDB::get_signal_list(StringName p_class, bool p_no_inheritance) const {
List<MethodInfo> signals;
ClassDB::get_signal_list(p_class, &signals, p_no_inheritance);
Array ret;
@@ -2863,7 +2135,6 @@ Array _ClassDB::get_signal_list(StringName p_class, bool p_no_inheritance) const
}
Array _ClassDB::get_property_list(StringName p_class, bool p_no_inheritance) const {
-
List<PropertyInfo> plist;
ClassDB::get_property_list(p_class, &plist, p_no_inheritance);
Array ret;
@@ -2892,12 +2163,10 @@ Error _ClassDB::set_property(Object *p_object, const StringName &p_property, con
}
bool _ClassDB::has_method(StringName p_class, StringName p_method, bool p_no_inheritance) const {
-
return ClassDB::has_method(p_class, p_method, p_no_inheritance);
}
Array _ClassDB::get_method_list(StringName p_class, bool p_no_inheritance) const {
-
List<MethodInfo> methods;
ClassDB::get_method_list(p_class, &methods, p_no_inheritance);
Array ret;
@@ -2915,12 +2184,11 @@ Array _ClassDB::get_method_list(StringName p_class, bool p_no_inheritance) const
return ret;
}
-PoolStringArray _ClassDB::get_integer_constant_list(const StringName &p_class, bool p_no_inheritance) const {
-
+PackedStringArray _ClassDB::get_integer_constant_list(const StringName &p_class, bool p_no_inheritance) const {
List<String> constants;
ClassDB::get_integer_constant_list(p_class, &constants, p_no_inheritance);
- PoolStringArray ret;
+ PackedStringArray ret;
ret.resize(constants.size());
int idx = 0;
for (List<String>::Element *E = constants.front(); E; E = E->next()) {
@@ -2931,31 +2199,27 @@ PoolStringArray _ClassDB::get_integer_constant_list(const StringName &p_class, b
}
bool _ClassDB::has_integer_constant(const StringName &p_class, const StringName &p_name) const {
-
bool success;
ClassDB::get_integer_constant(p_class, p_name, &success);
return success;
}
int _ClassDB::get_integer_constant(const StringName &p_class, const StringName &p_name) const {
-
bool found;
int c = ClassDB::get_integer_constant(p_class, p_name, &found);
ERR_FAIL_COND_V(!found, 0);
return c;
}
-StringName _ClassDB::get_category(const StringName &p_node) const {
+StringName _ClassDB::get_category(const StringName &p_node) const {
return ClassDB::get_category(p_node);
}
bool _ClassDB::is_class_enabled(StringName p_class) const {
-
return ClassDB::is_class_enabled(p_class);
}
void _ClassDB::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_class_list"), &_ClassDB::get_class_list);
ClassDB::bind_method(D_METHOD("get_inheriters_from_class", "class"), &_ClassDB::get_inheriters_from_class);
ClassDB::bind_method(D_METHOD("get_parent_class", "class"), &_ClassDB::get_parent_class);
@@ -2985,18 +2249,13 @@ void _ClassDB::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_class_enabled", "class"), &_ClassDB::is_class_enabled);
}
-_ClassDB::_ClassDB() {
-}
-_ClassDB::~_ClassDB() {
-}
-///////////////////////////////
+////// _Engine //////
void _Engine::set_iterations_per_second(int p_ips) {
-
Engine::get_singleton()->set_iterations_per_second(p_ips);
}
-int _Engine::get_iterations_per_second() const {
+int _Engine::get_iterations_per_second() const {
return Engine::get_singleton()->get_iterations_per_second();
}
@@ -3021,17 +2280,14 @@ int _Engine::get_target_fps() const {
}
float _Engine::get_frames_per_second() const {
-
return Engine::get_singleton()->get_frames_per_second();
}
uint64_t _Engine::get_physics_frames() const {
-
return Engine::get_singleton()->get_physics_frames();
}
uint64_t _Engine::get_idle_frames() const {
-
return Engine::get_singleton()->get_idle_frames();
}
@@ -3040,23 +2296,19 @@ void _Engine::set_time_scale(float p_scale) {
}
float _Engine::get_time_scale() {
-
return Engine::get_singleton()->get_time_scale();
}
int _Engine::get_frames_drawn() {
-
return Engine::get_singleton()->get_frames_drawn();
}
MainLoop *_Engine::get_main_loop() const {
-
//needs to remain in OS, since it's actually OS that interacts with it, but it's better exposed here
return OS::get_singleton()->get_main_loop();
}
Dictionary _Engine::get_version_info() const {
-
return Engine::get_singleton()->get_version_info();
}
@@ -3085,27 +2337,22 @@ bool _Engine::is_in_physics_frame() const {
}
bool _Engine::has_singleton(const String &p_name) const {
-
return Engine::get_singleton()->has_singleton(p_name);
}
Object *_Engine::get_singleton_object(const String &p_name) const {
-
return Engine::get_singleton()->get_singleton_object(p_name);
}
void _Engine::set_editor_hint(bool p_enabled) {
-
Engine::get_singleton()->set_editor_hint(p_enabled);
}
bool _Engine::is_editor_hint() const {
-
return Engine::get_singleton()->is_editor_hint();
}
void _Engine::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("set_iterations_per_second", "iterations_per_second"), &_Engine::set_iterations_per_second);
ClassDB::bind_method(D_METHOD("get_iterations_per_second"), &_Engine::get_iterations_per_second);
ClassDB::bind_method(D_METHOD("set_physics_jitter_fix", "physics_jitter_fix"), &_Engine::set_physics_jitter_fix);
@@ -3142,15 +2389,13 @@ void _Engine::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_hint"), "set_editor_hint", "is_editor_hint");
ADD_PROPERTY(PropertyInfo(Variant::INT, "iterations_per_second"), "set_iterations_per_second", "get_iterations_per_second");
ADD_PROPERTY(PropertyInfo(Variant::INT, "target_fps"), "set_target_fps", "get_target_fps");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "time_scale"), "set_time_scale", "get_time_scale");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "physics_jitter_fix"), "set_physics_jitter_fix", "get_physics_jitter_fix");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "time_scale"), "set_time_scale", "get_time_scale");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "physics_jitter_fix"), "set_physics_jitter_fix", "get_physics_jitter_fix");
}
-_Engine *_Engine::singleton = NULL;
+_Engine *_Engine::singleton = nullptr;
-_Engine::_Engine() {
- singleton = this;
-}
+////// _JSON //////
void JSONParseResult::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_error"), &JSONParseResult::get_error);
@@ -3217,13 +2462,160 @@ Ref<JSONParseResult> _JSON::parse(const String &p_json) {
result->error = JSON::parse(p_json, result->result, result->error_string, result->error_line);
if (result->error != OK) {
- ERR_PRINTS(vformat("Error parsing JSON at line %s: %s", result->error_line, result->error_string));
+ ERR_PRINT(vformat("Error parsing JSON at line %s: %s", result->error_line, result->error_string));
}
return result;
}
-_JSON *_JSON::singleton = NULL;
+_JSON *_JSON::singleton = nullptr;
+
+////// _EngineDebugger //////
+
+void _EngineDebugger::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("is_active"), &_EngineDebugger::is_active);
+
+ ClassDB::bind_method(D_METHOD("register_profiler", "name", "toggle", "add", "tick"), &_EngineDebugger::register_profiler);
+ ClassDB::bind_method(D_METHOD("unregister_profiler", "name"), &_EngineDebugger::unregister_profiler);
+ ClassDB::bind_method(D_METHOD("is_profiling", "name"), &_EngineDebugger::is_profiling);
+ ClassDB::bind_method(D_METHOD("has_profiler", "name"), &_EngineDebugger::has_profiler);
+
+ ClassDB::bind_method(D_METHOD("profiler_add_frame_data", "name", "data"), &_EngineDebugger::profiler_add_frame_data);
+ ClassDB::bind_method(D_METHOD("profiler_enable", "name", "enable", "arguments"), &_EngineDebugger::profiler_enable, DEFVAL(Array()));
+
+ ClassDB::bind_method(D_METHOD("register_message_capture", "name", "callable"), &_EngineDebugger::register_message_capture);
+ ClassDB::bind_method(D_METHOD("unregister_message_capture", "name"), &_EngineDebugger::unregister_message_capture);
+ ClassDB::bind_method(D_METHOD("has_capture", "name"), &_EngineDebugger::has_capture);
+
+ ClassDB::bind_method(D_METHOD("send_message", "message", "data"), &_EngineDebugger::send_message);
+}
+
+bool _EngineDebugger::is_active() {
+ return EngineDebugger::is_active();
+}
+
+void _EngineDebugger::register_profiler(const StringName &p_name, const Callable &p_toggle, const Callable &p_add, const Callable &p_tick) {
+ ERR_FAIL_COND_MSG(profilers.has(p_name) || has_profiler(p_name), "Profiler already registered: " + p_name);
+ profilers.insert(p_name, ProfilerCallable(p_toggle, p_add, p_tick));
+ ProfilerCallable &p = profilers[p_name];
+ EngineDebugger::Profiler profiler(
+ &p,
+ &_EngineDebugger::call_toggle,
+ &_EngineDebugger::call_add,
+ &_EngineDebugger::call_tick);
+ EngineDebugger::register_profiler(p_name, profiler);
+}
-_JSON::_JSON() {
- singleton = this;
+void _EngineDebugger::unregister_profiler(const StringName &p_name) {
+ ERR_FAIL_COND_MSG(!profilers.has(p_name), "Profiler not registered: " + p_name);
+ EngineDebugger::unregister_profiler(p_name);
+ profilers.erase(p_name);
}
+
+bool _EngineDebugger::_EngineDebugger::is_profiling(const StringName &p_name) {
+ return EngineDebugger::is_profiling(p_name);
+}
+
+bool _EngineDebugger::has_profiler(const StringName &p_name) {
+ return EngineDebugger::has_profiler(p_name);
+}
+
+void _EngineDebugger::profiler_add_frame_data(const StringName &p_name, const Array &p_data) {
+ EngineDebugger::profiler_add_frame_data(p_name, p_data);
+}
+
+void _EngineDebugger::profiler_enable(const StringName &p_name, bool p_enabled, const Array &p_opts) {
+ if (EngineDebugger::get_singleton()) {
+ EngineDebugger::get_singleton()->profiler_enable(p_name, p_enabled, p_opts);
+ }
+}
+
+void _EngineDebugger::register_message_capture(const StringName &p_name, const Callable &p_callable) {
+ ERR_FAIL_COND_MSG(captures.has(p_name) || has_capture(p_name), "Capture already registered: " + p_name);
+ captures.insert(p_name, p_callable);
+ Callable &c = captures[p_name];
+ EngineDebugger::Capture capture(&c, &_EngineDebugger::call_capture);
+ EngineDebugger::register_message_capture(p_name, capture);
+}
+
+void _EngineDebugger::unregister_message_capture(const StringName &p_name) {
+ ERR_FAIL_COND_MSG(!captures.has(p_name), "Capture not registered: " + p_name);
+ EngineDebugger::unregister_message_capture(p_name);
+ captures.erase(p_name);
+}
+
+bool _EngineDebugger::has_capture(const StringName &p_name) {
+ return EngineDebugger::has_capture(p_name);
+}
+
+void _EngineDebugger::send_message(const String &p_msg, const Array &p_data) {
+ ERR_FAIL_COND_MSG(!EngineDebugger::is_active(), "Can't send message. No active debugger");
+ EngineDebugger::get_singleton()->send_message(p_msg, p_data);
+}
+
+void _EngineDebugger::call_toggle(void *p_user, bool p_enable, const Array &p_opts) {
+ Callable &toggle = ((ProfilerCallable *)p_user)->callable_toggle;
+ if (toggle.is_null()) {
+ return;
+ }
+ Variant enable = p_enable, opts = p_opts;
+ const Variant *args[2] = { &enable, &opts };
+ Variant retval;
+ Callable::CallError err;
+ toggle.call(args, 2, retval, err);
+ ERR_FAIL_COND_MSG(err.error != Callable::CallError::CALL_OK, "Error calling 'toggle' to callable: " + Variant::get_callable_error_text(toggle, args, 2, err));
+}
+
+void _EngineDebugger::call_add(void *p_user, const Array &p_data) {
+ Callable &add = ((ProfilerCallable *)p_user)->callable_add;
+ if (add.is_null()) {
+ return;
+ }
+ Variant data = p_data;
+ const Variant *args[1] = { &data };
+ Variant retval;
+ Callable::CallError err;
+ add.call(args, 1, retval, err);
+ ERR_FAIL_COND_MSG(err.error != Callable::CallError::CALL_OK, "Error calling 'add' to callable: " + Variant::get_callable_error_text(add, args, 1, err));
+}
+
+void _EngineDebugger::call_tick(void *p_user, float p_frame_time, float p_idle_time, float p_physics_time, float p_physics_frame_time) {
+ Callable &tick = ((ProfilerCallable *)p_user)->callable_tick;
+ if (tick.is_null()) {
+ return;
+ }
+ Variant frame_time = p_frame_time, idle_time = p_idle_time, physics_time = p_physics_time, physics_frame_time = p_physics_frame_time;
+ const Variant *args[4] = { &frame_time, &idle_time, &physics_time, &physics_frame_time };
+ Variant retval;
+ Callable::CallError err;
+ tick.call(args, 4, retval, err);
+ ERR_FAIL_COND_MSG(err.error != Callable::CallError::CALL_OK, "Error calling 'tick' to callable: " + Variant::get_callable_error_text(tick, args, 4, err));
+}
+
+Error _EngineDebugger::call_capture(void *p_user, const String &p_cmd, const Array &p_data, bool &r_captured) {
+ Callable &capture = *(Callable *)p_user;
+ if (capture.is_null()) {
+ return FAILED;
+ }
+ Variant cmd = p_cmd, data = p_data;
+ const Variant *args[2] = { &cmd, &data };
+ Variant retval;
+ Callable::CallError err;
+ capture.call(args, 2, retval, err);
+ ERR_FAIL_COND_V_MSG(err.error != Callable::CallError::CALL_OK, FAILED, "Error calling 'capture' to callable: " + Variant::get_callable_error_text(capture, args, 2, err));
+ ERR_FAIL_COND_V_MSG(retval.get_type() != Variant::BOOL, FAILED, "Error calling 'capture' to callable: " + String(capture) + ". Return type is not bool.");
+ r_captured = retval;
+ return OK;
+}
+
+_EngineDebugger::~_EngineDebugger() {
+ for (Map<StringName, Callable>::Element *E = captures.front(); E; E = E->next()) {
+ EngineDebugger::unregister_message_capture(E->key());
+ }
+ captures.clear();
+ for (Map<StringName, ProfilerCallable>::Element *E = profilers.front(); E; E = E->next()) {
+ EngineDebugger::unregister_profiler(E->key());
+ }
+ profilers.clear();
+}
+
+_EngineDebugger *_EngineDebugger::singleton = nullptr;
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 87da51f97e..a59fcda60c 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -49,21 +49,31 @@ protected:
static _ResourceLoader *singleton;
public:
+ enum ThreadLoadStatus {
+ THREAD_LOAD_INVALID_RESOURCE,
+ THREAD_LOAD_IN_PROGRESS,
+ THREAD_LOAD_FAILED,
+ THREAD_LOAD_LOADED
+ };
+
static _ResourceLoader *get_singleton() { return singleton; }
- Ref<ResourceInteractiveLoader> load_interactive(const String &p_path, const String &p_type_hint = "");
+
+ Error load_threaded_request(const String &p_path, const String &p_type_hint = "", bool p_use_sub_threads = false);
+ ThreadLoadStatus load_threaded_get_status(const String &p_path, Array r_progress = Array());
+ RES load_threaded_get(const String &p_path);
+
RES load(const String &p_path, const String &p_type_hint = "", bool p_no_cache = false);
- PoolVector<String> get_recognized_extensions_for_type(const String &p_type);
+ Vector<String> get_recognized_extensions_for_type(const String &p_type);
void set_abort_on_missing_resources(bool p_abort);
- PoolStringArray get_dependencies(const String &p_path);
-#ifndef DISABLE_DEPRECATED
- bool has(const String &p_path);
-#endif // DISABLE_DEPRECATED
+ PackedStringArray get_dependencies(const String &p_path);
bool has_cached(const String &p_path);
bool exists(const String &p_path, const String &p_type_hint = "");
- _ResourceLoader();
+ _ResourceLoader() { singleton = this; }
};
+VARIANT_ENUM_CAST(_ResourceLoader::ThreadLoadStatus);
+
class _ResourceSaver : public Object {
GDCLASS(_ResourceSaver, Object);
@@ -86,9 +96,9 @@ public:
static _ResourceSaver *get_singleton() { return singleton; }
Error save(const String &p_path, const RES &p_resource, SaverFlags p_flags);
- PoolVector<String> get_recognized_extensions(const RES &p_resource);
+ Vector<String> get_recognized_extensions(const RES &p_resource);
- _ResourceSaver();
+ _ResourceSaver() { singleton = this; }
};
VARIANT_ENUM_CAST(_ResourceSaver::SaverFlags);
@@ -104,16 +114,8 @@ protected:
public:
enum VideoDriver {
- VIDEO_DRIVER_GLES3,
VIDEO_DRIVER_GLES2,
- };
-
- enum PowerState {
- POWERSTATE_UNKNOWN, // Cannot determine power status.
- POWERSTATE_ON_BATTERY, // Not plugged in, running on the battery.
- POWERSTATE_NO_BATTERY, // Plugged in, no battery available.
- POWERSTATE_CHARGING, // Plugged in, charging battery.
- POWERSTATE_CHARGED // Plugged in, battery charged.
+ VIDEO_DRIVER_VULKAN,
};
enum Weekday {
@@ -143,83 +145,10 @@ public:
MONTH_DECEMBER
};
- void global_menu_add_item(const String &p_menu, const String &p_label, const Variant &p_signal, const Variant &p_meta);
- void global_menu_add_separator(const String &p_menu);
- void global_menu_remove_item(const String &p_menu, int p_idx);
- void global_menu_clear(const String &p_menu);
-
- Point2 get_mouse_position() const;
- void set_window_title(const String &p_title);
- int get_mouse_button_state() const;
-
- void set_clipboard(const String &p_text);
- String get_clipboard() const;
-
- void set_video_mode(const Size2 &p_size, bool p_fullscreen, bool p_resizeable, int p_screen = 0);
- Size2 get_video_mode(int p_screen = 0) const;
- bool is_video_mode_fullscreen(int p_screen = 0) const;
- bool is_video_mode_resizable(int p_screen = 0) const;
- Array get_fullscreen_mode_list(int p_screen = 0) const;
-
- virtual int get_video_driver_count() const;
- virtual String get_video_driver_name(VideoDriver p_driver) const;
- virtual VideoDriver get_current_video_driver() const;
-
- virtual int get_audio_driver_count() const;
- virtual String get_audio_driver_name(int p_driver) const;
-
- virtual PoolStringArray get_connected_midi_inputs();
+ virtual PackedStringArray get_connected_midi_inputs();
virtual void open_midi_inputs();
virtual void close_midi_inputs();
- virtual int get_screen_count() const;
- virtual int get_current_screen() const;
- virtual void set_current_screen(int p_screen);
- virtual Point2 get_screen_position(int p_screen = -1) const;
- virtual Size2 get_screen_size(int p_screen = -1) const;
- virtual int get_screen_dpi(int p_screen = -1) const;
- virtual Point2 get_window_position() const;
- virtual void set_window_position(const Point2 &p_position);
- virtual Size2 get_max_window_size() const;
- virtual Size2 get_min_window_size() const;
- virtual Size2 get_window_size() const;
- virtual Size2 get_real_window_size() const;
- virtual Rect2 get_window_safe_area() const;
- virtual void set_max_window_size(const Size2 &p_size);
- virtual void set_min_window_size(const Size2 &p_size);
- virtual void set_window_size(const Size2 &p_size);
- virtual void set_window_fullscreen(bool p_enabled);
- virtual bool is_window_fullscreen() const;
- virtual void set_window_resizable(bool p_enabled);
- virtual bool is_window_resizable() const;
- virtual void set_window_minimized(bool p_enabled);
- virtual bool is_window_minimized() const;
- virtual void set_window_maximized(bool p_enabled);
- virtual bool is_window_maximized() const;
- virtual void set_window_always_on_top(bool p_enabled);
- virtual bool is_window_always_on_top() const;
- virtual bool is_window_focused() const;
- virtual void request_attention();
- virtual void center_window();
- virtual void move_window_to_foreground();
-
- virtual void set_borderless_window(bool p_borderless);
- virtual bool get_borderless_window() const;
-
- virtual bool get_window_per_pixel_transparency_enabled() const;
- virtual void set_window_per_pixel_transparency_enabled(bool p_enabled);
-
- virtual void set_ime_active(const bool p_active);
- virtual void set_ime_position(const Point2 &p_pos);
- virtual Point2 get_ime_selection() const;
- virtual String get_ime_text() const;
-
- Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
- bool native_video_is_playing();
- void native_video_pause();
- void native_video_unpause();
- void native_video_stop();
-
void set_low_processor_usage_mode(bool p_enabled);
bool is_in_low_processor_usage_mode() const;
@@ -241,38 +170,27 @@ public:
Vector<String> get_cmdline_args();
String get_locale() const;
- String get_latin_keyboard_variant() const;
String get_model_name() const;
void dump_memory_to_file(const String &p_file);
void dump_resources_to_file(const String &p_file);
- bool has_virtual_keyboard() const;
- void show_virtual_keyboard(const String &p_existing_text = "");
- void hide_virtual_keyboard();
- int get_virtual_keyboard_height();
-
void print_resources_in_use(bool p_short = false);
void print_all_resources(const String &p_to_file);
void print_all_textures_by_size();
void print_resources_by_type(const Vector<String> &p_types);
- bool has_touchscreen_ui_hint() const;
-
bool is_debug_build() const;
String get_unique_id() const;
- String get_scancode_string(uint32_t p_code) const;
- bool is_scancode_unicode(uint32_t p_unicode) const;
- int find_scancode_from_string(const String &p_code) const;
+ String get_keycode_string(uint32_t p_code) const;
+ bool is_keycode_unicode(uint32_t p_unicode) const;
+ int find_keycode_from_string(const String &p_code) const;
void set_use_file_access_save_and_swap(bool p_enable);
- void set_native_icon(const String &p_filename);
- void set_icon(const Ref<Image> &p_icon);
-
int get_exit_code() const;
void set_exit_code(int p_code);
Dictionary get_date(bool utc) const;
@@ -281,13 +199,10 @@ public:
Dictionary get_datetime_from_unix_time(int64_t unix_time_val) const;
int64_t get_unix_time_from_datetime(Dictionary datetime) const;
Dictionary get_time_zone_info() const;
- uint64_t get_unix_time() const;
- uint64_t get_system_time_secs() const;
- uint64_t get_system_time_msecs() const;
+ double get_unix_time() const;
uint64_t get_static_memory_usage() const;
uint64_t get_static_memory_peak_usage() const;
- uint64_t get_dynamic_memory_usage() const;
void delay_usec(uint32_t p_usec) const;
void delay_msec(uint32_t p_msec) const;
@@ -297,8 +212,6 @@ public:
bool can_use_threads() const;
- bool can_draw() const;
-
bool is_userfs_persistent() const;
bool is_stdout_verbose() const;
@@ -316,100 +229,58 @@ public:
SYSTEM_DIR_RINGTONES,
};
- enum ScreenOrientation {
-
- SCREEN_ORIENTATION_LANDSCAPE,
- SCREEN_ORIENTATION_PORTRAIT,
- SCREEN_ORIENTATION_REVERSE_LANDSCAPE,
- SCREEN_ORIENTATION_REVERSE_PORTRAIT,
- SCREEN_ORIENTATION_SENSOR_LANDSCAPE,
- SCREEN_ORIENTATION_SENSOR_PORTRAIT,
- SCREEN_ORIENTATION_SENSOR,
- };
-
String get_system_dir(SystemDir p_dir) const;
String get_user_data_dir() const;
- void alert(const String &p_alert, const String &p_title = "ALERT!");
-
- void set_screen_orientation(ScreenOrientation p_orientation);
- ScreenOrientation get_screen_orientation() const;
-
- void set_keep_screen_on(bool p_enabled);
- bool is_keep_screen_on() const;
-
- bool is_ok_left_and_cancel_right() const;
-
Error set_thread_name(const String &p_name);
- void set_use_vsync(bool p_enable);
- bool is_vsync_enabled() const;
-
- void set_vsync_via_compositor(bool p_enable);
- bool is_vsync_via_compositor_enabled() const;
-
- PowerState get_power_state();
- int get_power_seconds_left();
- int get_power_percent_left();
-
bool has_feature(const String &p_feature) const;
bool request_permission(const String &p_name);
bool request_permissions();
Vector<String> get_granted_permissions() const;
+ int get_tablet_driver_count() const;
+ String get_tablet_driver_name(int p_driver) const;
+ String get_current_tablet_driver() const;
+ void set_current_tablet_driver(const String &p_driver);
+
static _OS *get_singleton() { return singleton; }
- _OS();
+ _OS() { singleton = this; }
};
VARIANT_ENUM_CAST(_OS::VideoDriver);
-VARIANT_ENUM_CAST(_OS::PowerState);
VARIANT_ENUM_CAST(_OS::Weekday);
VARIANT_ENUM_CAST(_OS::Month);
VARIANT_ENUM_CAST(_OS::SystemDir);
-VARIANT_ENUM_CAST(_OS::ScreenOrientation);
-
-class _Geometry : public Object {
- GDCLASS(_Geometry, Object);
+class _Geometry2D : public Object {
+ GDCLASS(_Geometry2D, Object);
- static _Geometry *singleton;
+ static _Geometry2D *singleton;
protected:
static void _bind_methods();
public:
- static _Geometry *get_singleton();
- PoolVector<Plane> build_box_planes(const Vector3 &p_extents);
- PoolVector<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis = Vector3::AXIS_Z);
- PoolVector<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z);
- 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);
- Variant line_intersects_line_2d(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b);
- PoolVector<Vector2> get_closest_points_between_segments_2d(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2);
- PoolVector<Vector3> get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2);
- Vector2 get_closest_point_to_segment_2d(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
- Vector3 get_closest_point_to_segment(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
- Vector2 get_closest_point_to_segment_uncapped_2d(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
- Vector3 get_closest_point_to_segment_uncapped(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
- Variant ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
- Variant segment_intersects_triangle(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
+ static _Geometry2D *get_singleton();
+ Variant segment_intersects_segment(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b);
+ Variant line_intersects_line(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b);
+ Vector<Vector2> get_closest_points_between_segments(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2);
+ Vector2 get_closest_point_to_segment(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
+ Vector2 get_closest_point_to_segment_uncapped(const Vector2 &p_point, const Vector2 &p_a, const Vector2 &p_b);
bool point_is_inside_triangle(const Vector2 &s, const Vector2 &a, const Vector2 &b, const Vector2 &c) const;
- PoolVector<Vector3> segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius);
- PoolVector<Vector3> segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius);
- PoolVector<Vector3> segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const Vector<Plane> &p_planes);
bool is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius);
real_t segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius);
- int get_uv84_normal_bit(const Vector3 &p_vector);
bool is_polygon_clockwise(const Vector<Vector2> &p_polygon);
bool is_point_in_polygon(const Point2 &p_point, const Vector<Vector2> &p_polygon);
Vector<int> triangulate_polygon(const Vector<Vector2> &p_polygon);
- Vector<int> triangulate_delaunay_2d(const Vector<Vector2> &p_points);
- Vector<Point2> convex_hull_2d(const Vector<Point2> &p_points);
- Vector<Vector3> clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane);
+ Vector<int> triangulate_delaunay(const Vector<Vector2> &p_points);
+ Vector<Point2> convex_hull(const Vector<Point2> &p_points);
enum PolyBooleanOperation {
OPERATION_UNION,
@@ -418,14 +289,14 @@ public:
OPERATION_XOR
};
// 2D polygon boolean operations.
- Array merge_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Union (add).
- Array clip_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Difference (subtract).
- Array intersect_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Common area (multiply).
- Array exclude_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // All but common area (xor).
+ Array merge_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Union (add).
+ Array clip_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Difference (subtract).
+ Array intersect_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Common area (multiply).
+ Array exclude_polygons(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // All but common area (xor).
// 2D polyline vs polygon operations.
- Array clip_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Cut.
- Array intersect_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Chop.
+ Array clip_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Cut.
+ Array intersect_polyline_with_polygon(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Chop.
// 2D offset polygons/polylines.
enum PolyJoinType {
@@ -440,23 +311,52 @@ public:
END_SQUARE,
END_ROUND
};
- Array offset_polygon_2d(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE);
- Array offset_polyline_2d(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE, PolyEndType p_end_type = END_SQUARE);
+ Array offset_polygon(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE);
+ Array offset_polyline(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE, PolyEndType p_end_type = END_SQUARE);
Dictionary make_atlas(const Vector<Size2> &p_rects);
- _Geometry();
+ _Geometry2D() { singleton = this; }
};
-VARIANT_ENUM_CAST(_Geometry::PolyBooleanOperation);
-VARIANT_ENUM_CAST(_Geometry::PolyJoinType);
-VARIANT_ENUM_CAST(_Geometry::PolyEndType);
+VARIANT_ENUM_CAST(_Geometry2D::PolyBooleanOperation);
+VARIANT_ENUM_CAST(_Geometry2D::PolyJoinType);
+VARIANT_ENUM_CAST(_Geometry2D::PolyEndType);
-class _File : public Reference {
+class _Geometry3D : public Object {
+ GDCLASS(_Geometry3D, Object);
+ static _Geometry3D *singleton;
+
+protected:
+ static void _bind_methods();
+
+public:
+ static _Geometry3D *get_singleton();
+ Vector<Plane> build_box_planes(const Vector3 &p_extents);
+ Vector<Plane> build_cylinder_planes(float p_radius, float p_height, int p_sides, Vector3::Axis p_axis = Vector3::AXIS_Z);
+ Vector<Plane> build_capsule_planes(float p_radius, float p_height, int p_sides, int p_lats, Vector3::Axis p_axis = Vector3::AXIS_Z);
+ Vector<Vector3> get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2);
+ Vector3 get_closest_point_to_segment(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
+ Vector3 get_closest_point_to_segment_uncapped(const Vector3 &p_point, const Vector3 &p_a, const Vector3 &p_b);
+ Variant ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
+ Variant segment_intersects_triangle(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2);
+
+ Vector<Vector3> segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius);
+ Vector<Vector3> segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius);
+ Vector<Vector3> segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const Vector<Plane> &p_planes);
+ int get_uv84_normal_bit(const Vector3 &p_vector);
+
+ Vector<Vector3> clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane);
+
+ _Geometry3D() { singleton = this; }
+};
+
+class _File : public Reference {
GDCLASS(_File, Reference);
- FileAccess *f;
- bool eswap;
+
+ FileAccess *f = nullptr;
+ bool eswap = false;
protected:
static void _bind_methods();
@@ -506,7 +406,7 @@ public:
Variant get_var(bool p_allow_objects = false) const;
- PoolVector<uint8_t> get_buffer(int p_length) const; // Get an array of bytes.
+ Vector<uint8_t> get_buffer(int p_length) const; // Get an array of bytes.
String get_line() const;
Vector<String> get_csv_line(const String &p_delim = ",") const;
String get_as_text() const;
@@ -539,7 +439,7 @@ public:
virtual void store_pascal_string(const String &p_string);
virtual String get_pascal_string();
- void store_buffer(const PoolVector<uint8_t> &p_buffer); // Store an array of bytes.
+ void store_buffer(const Vector<uint8_t> &p_buffer); // Store an array of bytes.
void store_var(const Variant &p_var, bool p_full_objects = false);
@@ -547,7 +447,7 @@ public:
uint64_t get_modified_time(const String &p_file) const;
- _File();
+ _File() {}
virtual ~_File();
};
@@ -555,9 +455,9 @@ VARIANT_ENUM_CAST(_File::ModeFlags);
VARIANT_ENUM_CAST(_File::CompressionMode);
class _Directory : public Reference {
-
GDCLASS(_Directory, Reference);
DirAccess *d;
+ bool dir_open = false;
protected:
static void _bind_methods();
@@ -565,6 +465,8 @@ protected:
public:
Error open(const String &p_path);
+ bool is_open() const;
+
Error list_dir_begin(bool p_skip_navigational = false, bool p_skip_hidden = false); // This starts dir listing.
String get_next();
bool current_is_dir() const;
@@ -598,9 +500,8 @@ private:
bool _list_skip_hidden;
};
-class _Marshalls : public Reference {
-
- GDCLASS(_Marshalls, Reference);
+class _Marshalls : public Object {
+ GDCLASS(_Marshalls, Object);
static _Marshalls *singleton;
@@ -613,20 +514,19 @@ public:
String variant_to_base64(const Variant &p_var, bool p_full_objects = false);
Variant base64_to_variant(const String &p_str, bool p_allow_objects = false);
- String raw_to_base64(const PoolVector<uint8_t> &p_arr);
- PoolVector<uint8_t> base64_to_raw(const String &p_str);
+ String raw_to_base64(const Vector<uint8_t> &p_arr);
+ Vector<uint8_t> base64_to_raw(const String &p_str);
String utf8_to_base64(const String &p_str);
String base64_to_utf8(const String &p_str);
_Marshalls() { singleton = this; }
- ~_Marshalls() { singleton = NULL; }
+ ~_Marshalls() { singleton = nullptr; }
};
class _Mutex : public Reference {
-
GDCLASS(_Mutex, Reference);
- Mutex *mutex;
+ Mutex mutex;
static void _bind_methods();
@@ -634,37 +534,30 @@ public:
void lock();
Error try_lock();
void unlock();
-
- _Mutex();
- ~_Mutex();
};
class _Semaphore : public Reference {
-
GDCLASS(_Semaphore, Reference);
- Semaphore *semaphore;
+ Semaphore semaphore;
static void _bind_methods();
public:
- Error wait();
- Error post();
-
- _Semaphore();
- ~_Semaphore();
+ void wait();
+ Error try_wait();
+ void post();
};
class _Thread : public Reference {
-
GDCLASS(_Thread, Reference);
protected:
Variant ret;
Variant userdata;
- volatile bool active;
- Object *target_instance;
+ volatile bool active = false;
+ Object *target_instance = nullptr;
StringName target_method;
- Thread *thread;
+ Thread *thread = nullptr;
static void _bind_methods();
static void _start_func(void *ud);
@@ -682,22 +575,21 @@ public:
bool is_active() const;
Variant wait_to_finish();
- _Thread();
+ _Thread() {}
~_Thread();
};
VARIANT_ENUM_CAST(_Thread::Priority);
class _ClassDB : public Object {
-
GDCLASS(_ClassDB, Object);
protected:
static void _bind_methods();
public:
- PoolStringArray get_class_list() const;
- PoolStringArray get_inheriters_from_class(const StringName &p_class) const;
+ PackedStringArray get_class_list() const;
+ PackedStringArray get_inheriters_from_class(const StringName &p_class) const;
StringName get_parent_class(const StringName &p_class) const;
bool class_exists(const StringName &p_class) const;
bool is_parent_class(const StringName &p_class, const StringName &p_inherits) const;
@@ -716,15 +608,15 @@ public:
Array get_method_list(StringName p_class, bool p_no_inheritance = false) const;
- PoolStringArray get_integer_constant_list(const StringName &p_class, bool p_no_inheritance = false) const;
+ PackedStringArray get_integer_constant_list(const StringName &p_class, bool p_no_inheritance = false) const;
bool has_integer_constant(const StringName &p_class, const StringName &p_name) const;
int get_integer_constant(const StringName &p_class, const StringName &p_name) const;
StringName get_category(const StringName &p_node) const;
bool is_class_enabled(StringName p_class) const;
- _ClassDB();
- ~_ClassDB();
+ _ClassDB() {}
+ ~_ClassDB() {}
};
class _Engine : public Object {
@@ -772,7 +664,7 @@ public:
void set_editor_hint(bool p_enabled);
bool is_editor_hint() const;
- _Engine();
+ _Engine() { singleton = this; }
};
class _JSON;
@@ -784,7 +676,7 @@ class JSONParseResult : public Reference {
Error error;
String error_string;
- int error_line;
+ int error_line = -1;
Variant result;
@@ -804,8 +696,7 @@ public:
void set_result(const Variant &p_result);
Variant get_result() const;
- JSONParseResult() :
- error_line(-1) {}
+ JSONParseResult() {}
};
class _JSON : public Object {
@@ -821,7 +712,61 @@ public:
String print(const Variant &p_value, const String &p_indent = "", bool p_sort_keys = false);
Ref<JSONParseResult> parse(const String &p_json);
- _JSON();
+ _JSON() { singleton = this; }
+};
+
+class _EngineDebugger : public Object {
+ GDCLASS(_EngineDebugger, Object);
+
+ class ProfilerCallable {
+ friend class _EngineDebugger;
+
+ Callable callable_toggle;
+ Callable callable_add;
+ Callable callable_tick;
+
+ public:
+ ProfilerCallable() {}
+
+ ProfilerCallable(const Callable &p_toggle, const Callable &p_add, const Callable &p_tick) {
+ callable_toggle = p_toggle;
+ callable_add = p_add;
+ callable_tick = p_tick;
+ }
+ };
+
+ Map<StringName, Callable> captures;
+ Map<StringName, ProfilerCallable> profilers;
+
+protected:
+ static void _bind_methods();
+ static _EngineDebugger *singleton;
+
+public:
+ static _EngineDebugger *get_singleton() { return singleton; }
+
+ bool is_active();
+
+ void register_profiler(const StringName &p_name, const Callable &p_toggle, const Callable &p_add, const Callable &p_tick);
+ void unregister_profiler(const StringName &p_name);
+ bool is_profiling(const StringName &p_name);
+ bool has_profiler(const StringName &p_name);
+ void profiler_add_frame_data(const StringName &p_name, const Array &p_data);
+ void profiler_enable(const StringName &p_name, bool p_enabled, const Array &p_opts = Array());
+
+ void register_message_capture(const StringName &p_name, const Callable &p_callable);
+ void unregister_message_capture(const StringName &p_name);
+ bool has_capture(const StringName &p_name);
+
+ void send_message(const String &p_msg, const Array &p_data);
+
+ static void call_toggle(void *p_user, bool p_enable, const Array &p_opts);
+ static void call_add(void *p_user, const Array &p_data);
+ static void call_tick(void *p_user, float p_frame_time, float p_idle_time, float p_physics_time, float p_physics_frame_time);
+ static Error call_capture(void *p_user, const String &p_cmd, const Array &p_data, bool &r_captured);
+
+ _EngineDebugger() { singleton = this; }
+ ~_EngineDebugger();
};
#endif // CORE_BIND_H