diff options
340 files changed, 5418 insertions, 5720 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 60759cd71c..912c89a9d2 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -35,7 +35,6 @@ #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_2d.h" #include "core/math/geometry_3d.h" @@ -426,6 +425,21 @@ String _OS::get_external_data_dir() const { return OS::get_singleton()->get_external_data_dir(); } +String _OS::get_config_dir() const { + // Exposed as `get_config_dir()` instead of `get_config_path()` for consistency with other exposed OS methods. + return OS::get_singleton()->get_config_path(); +} + +String _OS::get_data_dir() const { + // Exposed as `get_data_dir()` instead of `get_data_path()` for consistency with other exposed OS methods. + return OS::get_singleton()->get_data_path(); +} + +String _OS::get_cache_dir() const { + // Exposed as `get_cache_dir()` instead of `get_cache_path()` for consistency with other exposed OS methods. + return OS::get_singleton()->get_cache_path(); +} + bool _OS::is_debug_build() const { #ifdef DEBUG_ENABLED return true; @@ -518,6 +532,9 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("get_user_data_dir"), &_OS::get_user_data_dir); ClassDB::bind_method(D_METHOD("get_external_data_dir"), &_OS::get_external_data_dir); ClassDB::bind_method(D_METHOD("get_system_dir", "dir"), &_OS::get_system_dir); + ClassDB::bind_method(D_METHOD("get_config_dir"), &_OS::get_config_dir); + ClassDB::bind_method(D_METHOD("get_data_dir"), &_OS::get_data_dir); + ClassDB::bind_method(D_METHOD("get_cache_dir"), &_OS::get_cache_dir); ClassDB::bind_method(D_METHOD("get_unique_id"), &_OS::get_unique_id); ClassDB::bind_method(D_METHOD("print_all_textures_by_size"), &_OS::print_all_textures_by_size); @@ -2137,80 +2154,6 @@ void _Engine::_bind_methods() { _Engine *_Engine::singleton = nullptr; -////// _JSON ////// - -void JSONParseResult::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_error"), &JSONParseResult::get_error); - ClassDB::bind_method(D_METHOD("get_error_string"), &JSONParseResult::get_error_string); - ClassDB::bind_method(D_METHOD("get_error_line"), &JSONParseResult::get_error_line); - ClassDB::bind_method(D_METHOD("get_result"), &JSONParseResult::get_result); - - ClassDB::bind_method(D_METHOD("set_error", "error"), &JSONParseResult::set_error); - ClassDB::bind_method(D_METHOD("set_error_string", "error_string"), &JSONParseResult::set_error_string); - ClassDB::bind_method(D_METHOD("set_error_line", "error_line"), &JSONParseResult::set_error_line); - ClassDB::bind_method(D_METHOD("set_result", "result"), &JSONParseResult::set_result); - - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "error", PROPERTY_HINT_NONE, "Error", PROPERTY_USAGE_CLASS_IS_ENUM), "set_error", "get_error"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "error_string"), "set_error_string", "get_error_string"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "error_line"), "set_error_line", "get_error_line"); - ADD_PROPERTY(PropertyInfo(Variant::NIL, "result", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT), "set_result", "get_result"); -} - -void JSONParseResult::set_error(Error p_error) { - error = p_error; -} - -Error JSONParseResult::get_error() const { - return error; -} - -void JSONParseResult::set_error_string(const String &p_error_string) { - error_string = p_error_string; -} - -String JSONParseResult::get_error_string() const { - return error_string; -} - -void JSONParseResult::set_error_line(int p_error_line) { - error_line = p_error_line; -} - -int JSONParseResult::get_error_line() const { - return error_line; -} - -void JSONParseResult::set_result(const Variant &p_result) { - result = p_result; -} - -Variant JSONParseResult::get_result() const { - return result; -} - -void _JSON::_bind_methods() { - ClassDB::bind_method(D_METHOD("print", "value", "indent", "sort_keys", "full_precision"), &_JSON::print, DEFVAL(String()), DEFVAL(false), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("parse", "json"), &_JSON::parse); -} - -String _JSON::print(const Variant &p_value, const String &p_indent, bool p_sort_keys, bool p_full_precision) { - return JSON::print(p_value, p_indent, p_sort_keys, p_full_precision); -} - -Ref<JSONParseResult> _JSON::parse(const String &p_json) { - Ref<JSONParseResult> result; - result.instance(); - - result->error = JSON::parse(p_json, result->result, result->error_string, result->error_line); - - if (result->error != OK) { - ERR_PRINT(vformat("Error parsing JSON at line %s: %s", result->error_line, result->error_string)); - } - return result; -} - -_JSON *_JSON::singleton = nullptr; - ////// _EngineDebugger ////// void _EngineDebugger::_bind_methods() { diff --git a/core/core_bind.h b/core/core_bind.h index b161effe95..74b6a5b26f 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -230,6 +230,9 @@ public: String get_user_data_dir() const; String get_external_data_dir() const; + String get_config_dir() const; + String get_data_dir() const; + String get_cache_dir() const; Error set_thread_name(const String &p_name); Thread::ID get_thread_caller_id() const; @@ -656,54 +659,6 @@ public: _Engine() { singleton = this; } }; -class _JSON; - -class JSONParseResult : public RefCounted { - GDCLASS(JSONParseResult, RefCounted); - - friend class _JSON; - - Error error; - String error_string; - int error_line = -1; - - Variant result; - -protected: - static void _bind_methods(); - -public: - void set_error(Error p_error); - Error get_error() const; - - void set_error_string(const String &p_error_string); - String get_error_string() const; - - void set_error_line(int p_error_line); - int get_error_line() const; - - void set_result(const Variant &p_result); - Variant get_result() const; - - JSONParseResult() {} -}; - -class _JSON : public Object { - GDCLASS(_JSON, Object); - -protected: - static void _bind_methods(); - static _JSON *singleton; - -public: - static _JSON *get_singleton() { return singleton; } - - String print(const Variant &p_value, const String &p_indent = "", bool p_sort_keys = false, bool p_full_precision = false); - Ref<JSONParseResult> parse(const String &p_json); - - _JSON() { singleton = this; } -}; - class _EngineDebugger : public Object { GDCLASS(_EngineDebugger, Object); diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index 9c1cf15342..72fb409b63 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -88,7 +88,7 @@ bool InputEvent::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, f return false; } -bool InputEvent::shortcut_match(const Ref<InputEvent> &p_event) const { +bool InputEvent::is_match(const Ref<InputEvent> &p_event, bool p_exact_match) const { return false; } @@ -110,7 +110,7 @@ void InputEvent::_bind_methods() { ClassDB::bind_method(D_METHOD("as_text"), &InputEvent::as_text); - ClassDB::bind_method(D_METHOD("shortcut_match", "event"), &InputEvent::shortcut_match); + ClassDB::bind_method(D_METHOD("is_match", "event", "exact_match"), &InputEvent::is_match, DEFVAL(true)); ClassDB::bind_method(D_METHOD("is_action_type"), &InputEvent::is_action_type); @@ -194,6 +194,23 @@ void InputEventWithModifiers::set_modifiers_from_event(const InputEventWithModif set_meta_pressed(event->is_meta_pressed()); } +uint32_t InputEventWithModifiers::get_modifiers_mask() const { + uint32_t mask = 0; + if (is_ctrl_pressed()) { + mask |= KEY_MASK_CTRL; + } + if (is_shift_pressed()) { + mask |= KEY_MASK_SHIFT; + } + if (is_alt_pressed()) { + mask |= KEY_MASK_ALT; + } + if (is_meta_pressed()) { + mask |= KEY_MASK_META; + } + return mask; +} + String InputEventWithModifiers::as_text() const { Vector<String> mod_names; @@ -313,39 +330,11 @@ bool InputEventKey::is_echo() const { } uint32_t InputEventKey::get_keycode_with_modifiers() const { - uint32_t sc = keycode; - if (is_ctrl_pressed()) { - sc |= KEY_MASK_CTRL; - } - if (is_alt_pressed()) { - sc |= KEY_MASK_ALT; - } - if (is_shift_pressed()) { - sc |= KEY_MASK_SHIFT; - } - if (is_meta_pressed()) { - sc |= KEY_MASK_META; - } - - return sc; + return keycode | get_modifiers_mask(); } uint32_t InputEventKey::get_physical_keycode_with_modifiers() const { - uint32_t sc = physical_keycode; - if (is_ctrl_pressed()) { - sc |= KEY_MASK_CTRL; - } - if (is_alt_pressed()) { - sc |= KEY_MASK_ALT; - } - if (is_shift_pressed()) { - sc |= KEY_MASK_SHIFT; - } - if (is_meta_pressed()) { - sc |= KEY_MASK_META; - } - - return sc; + return physical_keycode | get_modifiers_mask(); } String InputEventKey::as_text() const { @@ -442,16 +431,14 @@ bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool *p_pressed return match; } -bool InputEventKey::shortcut_match(const Ref<InputEvent> &p_event) const { +bool InputEventKey::is_match(const Ref<InputEvent> &p_event, bool p_exact_match) const { Ref<InputEventKey> key = p_event; if (key.is_null()) { return false; } - uint32_t code = get_keycode_with_modifiers(); - uint32_t event_code = key->get_keycode_with_modifiers(); - - return code == event_code; + return keycode == key->keycode && + (!p_exact_match || get_modifiers_mask() == key->get_modifiers_mask()); } void InputEventKey::_bind_methods() { @@ -599,6 +586,16 @@ bool InputEventMouseButton::action_match(const Ref<InputEvent> &p_event, bool *p return match; } +bool InputEventMouseButton::is_match(const Ref<InputEvent> &p_event, bool p_exact_match) const { + Ref<InputEventMouseButton> mb = p_event; + if (mb.is_null()) { + return false; + } + + return button_index == mb->button_index && + (!p_exact_match || get_modifiers_mask() == mb->get_modifiers_mask()); +} + static const char *_mouse_button_descriptions[9] = { TTRC("Left Mouse Button"), TTRC("Right Mouse Button"), @@ -904,6 +901,16 @@ bool InputEventJoypadMotion::action_match(const Ref<InputEvent> &p_event, bool * return match; } +bool InputEventJoypadMotion::is_match(const Ref<InputEvent> &p_event, bool p_exact_match) const { + Ref<InputEventJoypadMotion> jm = p_event; + if (jm.is_null()) { + return false; + } + + return axis == jm->axis && + (!p_exact_match || ((axis_value < 0) == (jm->axis_value < 0))); +} + static const char *_joy_axis_descriptions[JOY_AXIS_MAX] = { TTRC("Left Stick X-Axis, Joystick 0 X-Axis"), TTRC("Left Stick Y-Axis, Joystick 0 Y-Axis"), @@ -987,7 +994,7 @@ bool InputEventJoypadButton::action_match(const Ref<InputEvent> &p_event, bool * return match; } -bool InputEventJoypadButton::shortcut_match(const Ref<InputEvent> &p_event) const { +bool InputEventJoypadButton::is_match(const Ref<InputEvent> &p_event, bool p_exact_match) const { Ref<InputEventJoypadButton> button = p_event; if (button.is_null()) { return false; @@ -1229,7 +1236,7 @@ float InputEventAction::get_strength() const { return strength; } -bool InputEventAction::shortcut_match(const Ref<InputEvent> &p_event) const { +bool InputEventAction::is_match(const Ref<InputEvent> &p_event, bool p_exact_match) const { if (p_event.is_null()) { return false; } diff --git a/core/input/input_event.h b/core/input/input_event.h index eed0d79326..3ef135221d 100644 --- a/core/input/input_event.h +++ b/core/input/input_event.h @@ -142,7 +142,8 @@ public: virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const; virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const; - virtual bool shortcut_match(const Ref<InputEvent> &p_event) const; + virtual bool is_match(const Ref<InputEvent> &p_event, bool p_exact_match = true) const; + virtual bool is_action_type() const; virtual bool accumulate(const Ref<InputEvent> &p_event) { return false; } @@ -212,6 +213,8 @@ public: void set_modifiers_from_event(const InputEventWithModifiers *event); + uint32_t get_modifiers_mask() const; + virtual String as_text() const override; virtual String to_string() override; @@ -252,7 +255,7 @@ public: uint32_t get_physical_keycode_with_modifiers() const; virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const override; - virtual bool shortcut_match(const Ref<InputEvent> &p_event) const override; + virtual bool is_match(const Ref<InputEvent> &p_event, bool p_exact_match = true) const override; virtual bool is_action_type() const override { return true; } @@ -313,7 +316,9 @@ public: bool is_double_click() const; virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const override; + virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const override; + virtual bool is_match(const Ref<InputEvent> &p_event, bool p_exact_match = true) const override; virtual bool is_action_type() const override { return true; } virtual String as_text() const override; @@ -373,6 +378,7 @@ public: virtual bool is_pressed() const override; virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const override; + virtual bool is_match(const Ref<InputEvent> &p_event, bool p_exact_match = true) const override; virtual bool is_action_type() const override { return true; } virtual String as_text() const override; @@ -401,9 +407,10 @@ public: float get_pressure() const; virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const override; - virtual bool shortcut_match(const Ref<InputEvent> &p_event) const override; + virtual bool is_match(const Ref<InputEvent> &p_event, bool p_exact_match = true) const override; virtual bool is_action_type() const override { return true; } + virtual String as_text() const override; virtual String to_string() override; @@ -491,9 +498,10 @@ public: virtual bool is_action(const StringName &p_action) const; virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float *p_raw_strength, float p_deadzone) const override; + virtual bool is_match(const Ref<InputEvent> &p_event, bool p_exact_match = true) const override; - virtual bool shortcut_match(const Ref<InputEvent> &p_event) const override; virtual bool is_action_type() const override { return true; } + virtual String as_text() const override; virtual String to_string() override; diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp index c43fd64561..52dc561546 100644 --- a/core/input/input_map.cpp +++ b/core/input/input_map.cpp @@ -130,12 +130,9 @@ List<Ref<InputEvent>>::Element *InputMap::_find_event(Action &p_action, const Re for (List<Ref<InputEvent>>::Element *E = p_action.inputs.front(); E; E = E->next()) { const Ref<InputEvent> e = E->get(); - //if (e.type != Ref<InputEvent>::KEY && e.device != p_event.device) -- unsure about the KEY comparison, why is this here? - // continue; - int device = e->get_device(); if (device == ALL_DEVICES || device == p_event->get_device()) { - if (p_exact_match && e->shortcut_match(p_event)) { + if (p_exact_match && e->is_match(p_event, true)) { return E; } else if (!p_exact_match && e->action_match(p_event, p_pressed, p_strength, p_raw_strength, p_action.deadzone)) { return E; diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 0cf870e7e7..449ebaa6ee 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -825,7 +825,7 @@ void HTTPClient::_bind_methods() { ClassDB::bind_method(D_METHOD("query_string_from_dict", "fields"), &HTTPClient::query_string_from_dict); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "blocking_mode_enabled"), "set_blocking_mode", "is_blocking_mode_enabled"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "connection", PROPERTY_HINT_RESOURCE_TYPE, "StreamPeer", 0), "set_connection", "get_connection"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "connection", PROPERTY_HINT_RESOURCE_TYPE, "StreamPeer", PROPERTY_USAGE_NONE), "set_connection", "get_connection"); ADD_PROPERTY(PropertyInfo(Variant::INT, "read_chunk_size", PROPERTY_HINT_RANGE, "256,16777216"), "set_read_chunk_size", "get_read_chunk_size"); BIND_ENUM_CONSTANT(METHOD_GET); diff --git a/core/io/json.cpp b/core/io/json.cpp index 82ef2a6894..b3a2498212 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -45,7 +45,7 @@ const char *JSON::tk_name[TK_MAX] = { "EOF", }; -static String _make_indent(const String &p_indent, int p_size) { +String JSON::_make_indent(const String &p_indent, int p_size) { String indent_text = ""; if (!p_indent.is_empty()) { for (int i = 0; i < p_size; i++) { @@ -55,7 +55,7 @@ static String _make_indent(const String &p_indent, int p_size) { return indent_text; } -String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys, Set<const void *> &p_markers, bool p_full_precision) { +String JSON::_stringify(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys, Set<const void *> &p_markers, bool p_full_precision) { String colon = ":"; String end_statement = ""; @@ -100,7 +100,7 @@ String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_ s += ","; s += end_statement; } - s += _make_indent(p_indent, p_cur_indent + 1) + _print_var(a[i], p_indent, p_cur_indent + 1, p_sort_keys, p_markers); + s += _make_indent(p_indent, p_cur_indent + 1) + _stringify(a[i], p_indent, p_cur_indent + 1, p_sort_keys, p_markers); } s += end_statement + _make_indent(p_indent, p_cur_indent) + "]"; p_markers.erase(a.id()); @@ -126,9 +126,9 @@ String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_ s += ","; s += end_statement; } - s += _make_indent(p_indent, p_cur_indent + 1) + _print_var(String(E->get()), p_indent, p_cur_indent + 1, p_sort_keys, p_markers); + s += _make_indent(p_indent, p_cur_indent + 1) + _stringify(String(E->get()), p_indent, p_cur_indent + 1, p_sort_keys, p_markers); s += colon; - s += _print_var(d[E->get()], p_indent, p_cur_indent + 1, p_sort_keys, p_markers); + s += _stringify(d[E->get()], p_indent, p_cur_indent + 1, p_sort_keys, p_markers); } s += end_statement + _make_indent(p_indent, p_cur_indent) + "}"; @@ -140,11 +140,6 @@ String JSON::_print_var(const Variant &p_var, const String &p_indent, int p_cur_ } } -String JSON::print(const Variant &p_var, const String &p_indent, bool p_sort_keys, bool p_full_precision) { - Set<const void *> markers; - return _print_var(p_var, p_indent, 0, p_sort_keys, markers, p_full_precision); -} - Error JSON::_get_token(const char32_t *p_str, int &index, int p_len, Token &r_token, int &line, String &r_err_str) { while (p_len > 0) { switch (p_str[index]) { @@ -499,7 +494,7 @@ Error JSON::_parse_object(Dictionary &object, const char32_t *p_str, int &index, return ERR_PARSE_ERROR; } -Error JSON::parse(const String &p_json, Variant &r_ret, String &r_err_str, int &r_err_line) { +Error JSON::_parse_string(const String &p_json, Variant &r_ret, String &r_err_str, int &r_err_line) { const char32_t *str = p_json.ptr(); int idx = 0; int len = p_json.length(); @@ -530,34 +525,24 @@ Error JSON::parse(const String &p_json, Variant &r_ret, String &r_err_str, int & return err; } -Error JSONParser::parse_string(const String &p_json_string) { - return JSON::parse(p_json_string, data, err_text, err_line); -} -String JSONParser::get_error_text() const { - return err_text; -} -int JSONParser::get_error_line() const { - return err_line; -} -Variant JSONParser::get_data() const { - return data; +String JSON::stringify(const Variant &p_var, const String &p_indent, bool p_sort_keys, bool p_full_precision) { + Set<const void *> markers; + return _stringify(p_var, p_indent, 0, p_sort_keys, markers, p_full_precision); } -Error JSONParser::decode_data(const Variant &p_data, const String &p_indent, bool p_sort_keys) { - string = JSON::print(p_data, p_indent, p_sort_keys); - data = p_data; - return OK; +Error JSON::parse(const String &p_json_string) { + Error err = _parse_string(p_json_string, data, err_str, err_line); + if (err == Error::OK) { + err_line = 0; + } + return err; } -String JSONParser::get_string() const { - return string; -} +void JSON::_bind_methods() { + ClassDB::bind_method(D_METHOD("stringify", "data", "indent", "sort_keys", "full_precision"), &JSON::stringify, DEFVAL(""), DEFVAL(true), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("parse", "json_string"), &JSON::parse); -void JSONParser::_bind_methods() { - ClassDB::bind_method(D_METHOD("parse_string", "json_string"), &JSONParser::parse_string); - ClassDB::bind_method(D_METHOD("get_error_text"), &JSONParser::get_error_text); - ClassDB::bind_method(D_METHOD("get_error_line"), &JSONParser::get_error_line); - ClassDB::bind_method(D_METHOD("get_data"), &JSONParser::get_data); - ClassDB::bind_method(D_METHOD("decode_data", "data", "indent", "sort_keys"), &JSONParser::decode_data, DEFVAL(""), DEFVAL(true)); - ClassDB::bind_method(D_METHOD("get_string"), &JSONParser::get_string); + ClassDB::bind_method(D_METHOD("get_data"), &JSON::get_data); + ClassDB::bind_method(D_METHOD("get_error_line"), &JSON::get_error_line); + ClassDB::bind_method(D_METHOD("get_error_message"), &JSON::get_error_message); } diff --git a/core/io/json.h b/core/io/json.h index 5be8cc1e86..f20c97f540 100644 --- a/core/io/json.h +++ b/core/io/json.h @@ -33,7 +33,10 @@ #include "core/object/ref_counted.h" #include "core/variant/variant.h" -class JSON { + +class JSON : public RefCounted { + GDCLASS(JSON, RefCounted); + enum TokenType { TK_CURLY_BRACKET_OPEN, TK_CURLY_BRACKET_CLOSE, @@ -60,39 +63,30 @@ class JSON { Variant value; }; - static const char *tk_name[TK_MAX]; + Variant data; + String err_str; + int err_line = 0; - static String _print_var(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys, Set<const void *> &p_markers, bool p_full_precision = false); + static const char *tk_name[]; + static String _make_indent(const String &p_indent, int p_size); + static String _stringify(const Variant &p_var, const String &p_indent, int p_cur_indent, bool p_sort_keys, Set<const void *> &p_markers, bool p_full_precision = false); static Error _get_token(const char32_t *p_str, int &index, int p_len, Token &r_token, int &line, String &r_err_str); static Error _parse_value(Variant &value, Token &token, const char32_t *p_str, int &index, int p_len, int &line, String &r_err_str); static Error _parse_array(Array &array, const char32_t *p_str, int &index, int p_len, int &line, String &r_err_str); static Error _parse_object(Dictionary &object, const char32_t *p_str, int &index, int p_len, int &line, String &r_err_str); - -public: - static String print(const Variant &p_var, const String &p_indent = "", bool p_sort_keys = true, bool p_full_precision = false); - static Error parse(const String &p_json, Variant &r_ret, String &r_err_str, int &r_err_line); -}; - -class JSONParser : public RefCounted { - GDCLASS(JSONParser, RefCounted); - - Variant data; - String string; - String err_text; - int err_line = 0; + static Error _parse_string(const String &p_json, Variant &r_ret, String &r_err_str, int &r_err_line); protected: static void _bind_methods(); public: - Error parse_string(const String &p_json_string); - String get_error_text() const; - int get_error_line() const; - Variant get_data() const; + String stringify(const Variant &p_var, const String &p_indent = "", bool p_sort_keys = true, bool p_full_precision = false); + Error parse(const String &p_json_string); - Error decode_data(const Variant &p_data, const String &p_indent = "", bool p_sort_keys = true); - String get_string() const; + inline Variant get_data() const { return data; } + inline int get_error_line() const { return err_line; } + inline String get_error_message() const { return err_str; } }; #endif // JSON_H diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 4c58c84c14..c447e11ee7 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -111,6 +111,9 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = 4; } + // Note: We cannot use sizeof(real_t) for decoding, in case a different size is encoded. + // Decoding math types always checks for the encoded size, while encoding always uses compilation setting. + // This does lead to some code duplication for decoding, but compatibility is the priority. switch (type & ENCODE_MASK) { case Variant::NIL: { r_variant = Variant(); @@ -144,18 +147,18 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int } break; case Variant::FLOAT: { if (type & ENCODE_FLAG_64) { - ERR_FAIL_COND_V(len < 8, ERR_INVALID_DATA); + ERR_FAIL_COND_V((size_t)len < sizeof(double), ERR_INVALID_DATA); double val = decode_double(buf); r_variant = val; if (r_len) { - (*r_len) += 8; + (*r_len) += sizeof(double); } } else { - ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA); + ERR_FAIL_COND_V((size_t)len < sizeof(float), ERR_INVALID_DATA); float val = decode_float(buf); r_variant = val; if (r_len) { - (*r_len) += 4; + (*r_len) += sizeof(float); } } @@ -172,15 +175,25 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int // math types case Variant::VECTOR2: { - ERR_FAIL_COND_V(len < 4 * 2, ERR_INVALID_DATA); Vector2 val; - val.x = decode_float(&buf[0]); - val.y = decode_float(&buf[4]); - r_variant = val; + if (type & ENCODE_FLAG_64) { + ERR_FAIL_COND_V((size_t)len < sizeof(double) * 2, ERR_INVALID_DATA); + val.x = decode_double(&buf[0]); + val.y = decode_double(&buf[sizeof(double)]); - if (r_len) { - (*r_len) += 4 * 2; + if (r_len) { + (*r_len) += sizeof(double) * 2; + } + } else { + ERR_FAIL_COND_V((size_t)len < sizeof(float) * 2, ERR_INVALID_DATA); + val.x = decode_float(&buf[0]); + val.y = decode_float(&buf[sizeof(float)]); + + if (r_len) { + (*r_len) += sizeof(float) * 2; + } } + r_variant = val; } break; case Variant::VECTOR2I: { @@ -196,17 +209,29 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int } break; case Variant::RECT2: { - ERR_FAIL_COND_V(len < 4 * 4, ERR_INVALID_DATA); Rect2 val; - val.position.x = decode_float(&buf[0]); - val.position.y = decode_float(&buf[4]); - val.size.x = decode_float(&buf[8]); - val.size.y = decode_float(&buf[12]); - r_variant = val; + if (type & ENCODE_FLAG_64) { + ERR_FAIL_COND_V((size_t)len < sizeof(double) * 4, ERR_INVALID_DATA); + val.position.x = decode_double(&buf[0]); + val.position.y = decode_double(&buf[sizeof(double)]); + val.size.x = decode_double(&buf[sizeof(double) * 2]); + val.size.y = decode_double(&buf[sizeof(double) * 3]); - if (r_len) { - (*r_len) += 4 * 4; + if (r_len) { + (*r_len) += sizeof(double) * 4; + } + } else { + ERR_FAIL_COND_V((size_t)len < sizeof(float) * 4, ERR_INVALID_DATA); + val.position.x = decode_float(&buf[0]); + val.position.y = decode_float(&buf[sizeof(float)]); + val.size.x = decode_float(&buf[sizeof(float) * 2]); + val.size.y = decode_float(&buf[sizeof(float) * 3]); + + if (r_len) { + (*r_len) += sizeof(float) * 4; + } } + r_variant = val; } break; case Variant::RECT2I: { @@ -224,16 +249,27 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int } break; case Variant::VECTOR3: { - ERR_FAIL_COND_V(len < 4 * 3, ERR_INVALID_DATA); Vector3 val; - val.x = decode_float(&buf[0]); - val.y = decode_float(&buf[4]); - val.z = decode_float(&buf[8]); - r_variant = val; + if (type & ENCODE_FLAG_64) { + ERR_FAIL_COND_V((size_t)len < sizeof(double) * 3, ERR_INVALID_DATA); + val.x = decode_double(&buf[0]); + val.y = decode_double(&buf[sizeof(double)]); + val.z = decode_double(&buf[sizeof(double) * 2]); - if (r_len) { - (*r_len) += 4 * 3; + if (r_len) { + (*r_len) += sizeof(double) * 3; + } + } else { + ERR_FAIL_COND_V((size_t)len < sizeof(float) * 3, ERR_INVALID_DATA); + val.x = decode_float(&buf[0]); + val.y = decode_float(&buf[sizeof(float)]); + val.z = decode_float(&buf[sizeof(float) * 2]); + + if (r_len) { + (*r_len) += sizeof(float) * 3; + } } + r_variant = val; } break; case Variant::VECTOR3I: { @@ -250,101 +286,177 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int } break; case Variant::TRANSFORM2D: { - ERR_FAIL_COND_V(len < 4 * 6, ERR_INVALID_DATA); Transform2D val; - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 2; j++) { - val.elements[i][j] = decode_float(&buf[(i * 2 + j) * 4]); + if (type & ENCODE_FLAG_64) { + ERR_FAIL_COND_V((size_t)len < sizeof(double) * 6, ERR_INVALID_DATA); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 2; j++) { + val.elements[i][j] = decode_double(&buf[(i * 2 + j) * sizeof(double)]); + } } - } - r_variant = val; + if (r_len) { + (*r_len) += sizeof(double) * 6; + } + } else { + ERR_FAIL_COND_V((size_t)len < sizeof(float) * 6, ERR_INVALID_DATA); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 2; j++) { + val.elements[i][j] = decode_float(&buf[(i * 2 + j) * sizeof(float)]); + } + } - if (r_len) { - (*r_len) += 4 * 6; + if (r_len) { + (*r_len) += sizeof(float) * 6; + } } + r_variant = val; } break; case Variant::PLANE: { - ERR_FAIL_COND_V(len < 4 * 4, ERR_INVALID_DATA); Plane val; - val.normal.x = decode_float(&buf[0]); - val.normal.y = decode_float(&buf[4]); - val.normal.z = decode_float(&buf[8]); - val.d = decode_float(&buf[12]); - r_variant = val; + if (type & ENCODE_FLAG_64) { + ERR_FAIL_COND_V((size_t)len < sizeof(double) * 4, ERR_INVALID_DATA); + val.normal.x = decode_double(&buf[0]); + val.normal.y = decode_double(&buf[sizeof(double)]); + val.normal.z = decode_double(&buf[sizeof(double) * 2]); + val.d = decode_double(&buf[sizeof(double) * 3]); - if (r_len) { - (*r_len) += 4 * 4; + if (r_len) { + (*r_len) += sizeof(double) * 4; + } + } else { + ERR_FAIL_COND_V((size_t)len < sizeof(float) * 4, ERR_INVALID_DATA); + val.normal.x = decode_float(&buf[0]); + val.normal.y = decode_float(&buf[sizeof(float)]); + val.normal.z = decode_float(&buf[sizeof(float) * 2]); + val.d = decode_float(&buf[sizeof(float) * 3]); + + if (r_len) { + (*r_len) += sizeof(float) * 4; + } } + r_variant = val; } break; case Variant::QUATERNION: { - ERR_FAIL_COND_V(len < 4 * 4, ERR_INVALID_DATA); Quaternion val; - val.x = decode_float(&buf[0]); - val.y = decode_float(&buf[4]); - val.z = decode_float(&buf[8]); - val.w = decode_float(&buf[12]); - r_variant = val; + if (type & ENCODE_FLAG_64) { + ERR_FAIL_COND_V((size_t)len < sizeof(double) * 4, ERR_INVALID_DATA); + val.x = decode_double(&buf[0]); + val.y = decode_double(&buf[sizeof(double)]); + val.z = decode_double(&buf[sizeof(double) * 2]); + val.w = decode_double(&buf[sizeof(double) * 3]); - if (r_len) { - (*r_len) += 4 * 4; + if (r_len) { + (*r_len) += sizeof(double) * 4; + } + } else { + ERR_FAIL_COND_V((size_t)len < sizeof(float) * 4, ERR_INVALID_DATA); + val.x = decode_float(&buf[0]); + val.y = decode_float(&buf[sizeof(float)]); + val.z = decode_float(&buf[sizeof(float) * 2]); + val.w = decode_float(&buf[sizeof(float) * 3]); + + if (r_len) { + (*r_len) += sizeof(float) * 4; + } } + r_variant = val; } break; case Variant::AABB: { - ERR_FAIL_COND_V(len < 4 * 6, ERR_INVALID_DATA); AABB val; - val.position.x = decode_float(&buf[0]); - val.position.y = decode_float(&buf[4]); - val.position.z = decode_float(&buf[8]); - val.size.x = decode_float(&buf[12]); - val.size.y = decode_float(&buf[16]); - val.size.z = decode_float(&buf[20]); - r_variant = val; + if (type & ENCODE_FLAG_64) { + ERR_FAIL_COND_V((size_t)len < sizeof(double) * 6, ERR_INVALID_DATA); + val.position.x = decode_double(&buf[0]); + val.position.y = decode_double(&buf[sizeof(double)]); + val.position.z = decode_double(&buf[sizeof(double) * 2]); + val.size.x = decode_double(&buf[sizeof(double) * 3]); + val.size.y = decode_double(&buf[sizeof(double) * 4]); + val.size.z = decode_double(&buf[sizeof(double) * 5]); - if (r_len) { - (*r_len) += 4 * 6; + if (r_len) { + (*r_len) += sizeof(double) * 6; + } + } else { + ERR_FAIL_COND_V((size_t)len < sizeof(float) * 6, ERR_INVALID_DATA); + val.position.x = decode_float(&buf[0]); + val.position.y = decode_float(&buf[sizeof(float)]); + val.position.z = decode_float(&buf[sizeof(float) * 2]); + val.size.x = decode_float(&buf[sizeof(float) * 3]); + val.size.y = decode_float(&buf[sizeof(float) * 4]); + val.size.z = decode_float(&buf[sizeof(float) * 5]); + + if (r_len) { + (*r_len) += sizeof(float) * 6; + } } + r_variant = val; } break; case Variant::BASIS: { - ERR_FAIL_COND_V(len < 4 * 9, ERR_INVALID_DATA); Basis val; - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { - val.elements[i][j] = decode_float(&buf[(i * 3 + j) * 4]); + if (type & ENCODE_FLAG_64) { + ERR_FAIL_COND_V((size_t)len < sizeof(double) * 9, ERR_INVALID_DATA); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + val.elements[i][j] = decode_double(&buf[(i * 3 + j) * sizeof(double)]); + } } - } - r_variant = val; + if (r_len) { + (*r_len) += sizeof(double) * 9; + } + } else { + ERR_FAIL_COND_V((size_t)len < sizeof(float) * 9, ERR_INVALID_DATA); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + val.elements[i][j] = decode_float(&buf[(i * 3 + j) * sizeof(float)]); + } + } - if (r_len) { - (*r_len) += 4 * 9; + if (r_len) { + (*r_len) += sizeof(float) * 9; + } } + r_variant = val; } break; case Variant::TRANSFORM3D: { - ERR_FAIL_COND_V(len < 4 * 12, ERR_INVALID_DATA); Transform3D val; - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 3; j++) { - val.basis.elements[i][j] = decode_float(&buf[(i * 3 + j) * 4]); + if (type & ENCODE_FLAG_64) { + ERR_FAIL_COND_V((size_t)len < sizeof(double) * 12, ERR_INVALID_DATA); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + val.basis.elements[i][j] = decode_double(&buf[(i * 3 + j) * sizeof(double)]); + } } - } - val.origin[0] = decode_float(&buf[36]); - val.origin[1] = decode_float(&buf[40]); - val.origin[2] = decode_float(&buf[44]); + val.origin[0] = decode_double(&buf[sizeof(double) * 9]); + val.origin[1] = decode_double(&buf[sizeof(double) * 10]); + val.origin[2] = decode_double(&buf[sizeof(double) * 11]); - r_variant = val; + if (r_len) { + (*r_len) += sizeof(double) * 12; + } + } else { + ERR_FAIL_COND_V((size_t)len < sizeof(float) * 12, ERR_INVALID_DATA); + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + val.basis.elements[i][j] = decode_float(&buf[(i * 3 + j) * sizeof(float)]); + } + } + val.origin[0] = decode_float(&buf[sizeof(float) * 9]); + val.origin[1] = decode_float(&buf[sizeof(float) * 10]); + val.origin[2] = decode_float(&buf[sizeof(float) * 11]); - if (r_len) { - (*r_len) += 4 * 12; + if (r_len) { + (*r_len) += sizeof(float) * 12; + } } + r_variant = val; } break; - // misc types case Variant::COLOR: { ERR_FAIL_COND_V(len < 4 * 4, ERR_INVALID_DATA); @@ -356,9 +468,8 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int r_variant = val; if (r_len) { - (*r_len) += 4 * 4; + (*r_len) += 4 * 4; // Colors should always be in single-precision. } - } break; case Variant::STRING_NAME: { String str; @@ -463,7 +574,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int buf += 4; len -= 4; if (r_len) { - (*r_len) += 4; + (*r_len) += 4; // Size of count number. } for (int i = 0; i < count; i++) { @@ -516,7 +627,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int len -= 4; if (r_len) { - (*r_len) += 4; + (*r_len) += 4; // Size of count number. } Dictionary d; @@ -559,7 +670,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int len -= 4; if (r_len) { - (*r_len) += 4; + (*r_len) += 4; // Size of count number. } Array varr; @@ -716,9 +827,8 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int len -= 4; if (r_len) { - (*r_len) += 4; + (*r_len) += 4; // Size of count number. } - //printf("string count: %i\n",count); for (int32_t i = 0; i < count; i++) { String str; @@ -739,30 +849,57 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int buf += 4; len -= 4; - ERR_FAIL_MUL_OF(count, 4 * 2, ERR_INVALID_DATA); - ERR_FAIL_COND_V(count < 0 || count * 4 * 2 > len, ERR_INVALID_DATA); Vector<Vector2> varray; - if (r_len) { - (*r_len) += 4; - } - - if (count) { - varray.resize(count); - Vector2 *w = varray.ptrw(); + if (type & ENCODE_FLAG_64) { + ERR_FAIL_MUL_OF(count, sizeof(double) * 2, ERR_INVALID_DATA); + ERR_FAIL_COND_V(count < 0 || count * sizeof(double) * 2 > (size_t)len, ERR_INVALID_DATA); - for (int32_t i = 0; i < count; i++) { - w[i].x = decode_float(buf + i * 4 * 2 + 4 * 0); - w[i].y = decode_float(buf + i * 4 * 2 + 4 * 1); + if (r_len) { + (*r_len) += 4; // Size of count number. } - int adv = 4 * 2 * count; + if (count) { + varray.resize(count); + Vector2 *w = varray.ptrw(); + + for (int32_t i = 0; i < count; i++) { + w[i].x = decode_double(buf + i * sizeof(double) * 2 + sizeof(double) * 0); + w[i].y = decode_double(buf + i * sizeof(double) * 2 + sizeof(double) * 1); + } + + int adv = sizeof(double) * 2 * count; + + if (r_len) { + (*r_len) += adv; + } + len -= adv; + buf += adv; + } + } else { + ERR_FAIL_MUL_OF(count, sizeof(float) * 2, ERR_INVALID_DATA); + ERR_FAIL_COND_V(count < 0 || count * sizeof(float) * 2 > (size_t)len, ERR_INVALID_DATA); if (r_len) { - (*r_len) += adv; + (*r_len) += 4; // Size of count number. } - } + if (count) { + varray.resize(count); + Vector2 *w = varray.ptrw(); + + for (int32_t i = 0; i < count; i++) { + w[i].x = decode_float(buf + i * sizeof(float) * 2 + sizeof(float) * 0); + w[i].y = decode_float(buf + i * sizeof(float) * 2 + sizeof(float) * 1); + } + + int adv = sizeof(float) * 2 * count; + + if (r_len) { + (*r_len) += adv; + } + } + } r_variant = varray; } break; @@ -772,32 +909,61 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int buf += 4; len -= 4; - ERR_FAIL_MUL_OF(count, 4 * 3, ERR_INVALID_DATA); - ERR_FAIL_COND_V(count < 0 || count * 4 * 3 > len, ERR_INVALID_DATA); - Vector<Vector3> varray; - if (r_len) { - (*r_len) += 4; - } - - if (count) { - varray.resize(count); - Vector3 *w = varray.ptrw(); + if (type & ENCODE_FLAG_64) { + ERR_FAIL_MUL_OF(count, sizeof(double) * 3, ERR_INVALID_DATA); + ERR_FAIL_COND_V(count < 0 || count * sizeof(double) * 3 > (size_t)len, ERR_INVALID_DATA); - for (int32_t i = 0; i < count; i++) { - w[i].x = decode_float(buf + i * 4 * 3 + 4 * 0); - w[i].y = decode_float(buf + i * 4 * 3 + 4 * 1); - w[i].z = decode_float(buf + i * 4 * 3 + 4 * 2); + if (r_len) { + (*r_len) += 4; // Size of count number. } - int adv = 4 * 3 * count; + if (count) { + varray.resize(count); + Vector3 *w = varray.ptrw(); + + for (int32_t i = 0; i < count; i++) { + w[i].x = decode_double(buf + i * sizeof(double) * 3 + sizeof(double) * 0); + w[i].y = decode_double(buf + i * sizeof(double) * 3 + sizeof(double) * 1); + w[i].z = decode_double(buf + i * sizeof(double) * 3 + sizeof(double) * 2); + } + + int adv = sizeof(double) * 3 * count; + + if (r_len) { + (*r_len) += adv; + } + len -= adv; + buf += adv; + } + } else { + ERR_FAIL_MUL_OF(count, sizeof(float) * 3, ERR_INVALID_DATA); + ERR_FAIL_COND_V(count < 0 || count * sizeof(float) * 3 > (size_t)len, ERR_INVALID_DATA); if (r_len) { - (*r_len) += adv; + (*r_len) += 4; // Size of count number. } - } + if (count) { + varray.resize(count); + Vector3 *w = varray.ptrw(); + + for (int32_t i = 0; i < count; i++) { + w[i].x = decode_float(buf + i * sizeof(float) * 3 + sizeof(float) * 0); + w[i].y = decode_float(buf + i * sizeof(float) * 3 + sizeof(float) * 1); + w[i].z = decode_float(buf + i * sizeof(float) * 3 + sizeof(float) * 2); + } + + int adv = sizeof(float) * 3 * count; + + if (r_len) { + (*r_len) += adv; + } + len -= adv; + buf += adv; + } + } r_variant = varray; } break; @@ -813,7 +979,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int Vector<Color> carray; if (r_len) { - (*r_len) += 4; + (*r_len) += 4; // Size of count number. } if (count) { @@ -821,6 +987,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int Color *w = carray.ptrw(); for (int32_t i = 0; i < count; i++) { + // Colors should always be in single-precision. w[i].r = decode_float(buf + i * 4 * 4 + 4 * 0); w[i].g = decode_float(buf + i * 4 * 4 + 4 * 1); w[i].b = decode_float(buf + i * 4 * 4 + 4 * 2); @@ -882,7 +1049,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo double d = p_variant; float f = d; if (double(f) != d) { - flags |= ENCODE_FLAG_64; //always encode real as double + flags |= ENCODE_FLAG_64; } } break; case Variant::OBJECT: { @@ -1013,11 +1180,11 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo case Variant::VECTOR2: { if (buf) { Vector2 v2 = p_variant; - encode_float(v2.x, &buf[0]); - encode_float(v2.y, &buf[4]); + encode_real(v2.x, &buf[0]); + encode_real(v2.y, &buf[sizeof(real_t)]); } - r_len += 2 * 4; + r_len += 2 * sizeof(real_t); } break; case Variant::VECTOR2I: { @@ -1033,12 +1200,12 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo case Variant::RECT2: { if (buf) { Rect2 r2 = p_variant; - encode_float(r2.position.x, &buf[0]); - encode_float(r2.position.y, &buf[4]); - encode_float(r2.size.x, &buf[8]); - encode_float(r2.size.y, &buf[12]); + encode_real(r2.position.x, &buf[0]); + encode_real(r2.position.y, &buf[sizeof(real_t)]); + encode_real(r2.size.x, &buf[sizeof(real_t) * 2]); + encode_real(r2.size.y, &buf[sizeof(real_t) * 3]); } - r_len += 4 * 4; + r_len += 4 * sizeof(real_t); } break; case Variant::RECT2I: { @@ -1055,12 +1222,12 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo case Variant::VECTOR3: { if (buf) { Vector3 v3 = p_variant; - encode_float(v3.x, &buf[0]); - encode_float(v3.y, &buf[4]); - encode_float(v3.z, &buf[8]); + encode_real(v3.x, &buf[0]); + encode_real(v3.y, &buf[sizeof(real_t)]); + encode_real(v3.z, &buf[sizeof(real_t) * 2]); } - r_len += 3 * 4; + r_len += 3 * sizeof(real_t); } break; case Variant::VECTOR3I: { @@ -1079,50 +1246,50 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo Transform2D val = p_variant; for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { - memcpy(&buf[(i * 2 + j) * 4], &val.elements[i][j], sizeof(float)); + memcpy(&buf[(i * 2 + j) * sizeof(real_t)], &val.elements[i][j], sizeof(real_t)); } } } - r_len += 6 * 4; + r_len += 6 * sizeof(real_t); } break; case Variant::PLANE: { if (buf) { Plane p = p_variant; - encode_float(p.normal.x, &buf[0]); - encode_float(p.normal.y, &buf[4]); - encode_float(p.normal.z, &buf[8]); - encode_float(p.d, &buf[12]); + encode_real(p.normal.x, &buf[0]); + encode_real(p.normal.y, &buf[sizeof(real_t)]); + encode_real(p.normal.z, &buf[sizeof(real_t) * 2]); + encode_real(p.d, &buf[sizeof(real_t) * 3]); } - r_len += 4 * 4; + r_len += 4 * sizeof(real_t); } break; case Variant::QUATERNION: { if (buf) { Quaternion q = p_variant; - encode_float(q.x, &buf[0]); - encode_float(q.y, &buf[4]); - encode_float(q.z, &buf[8]); - encode_float(q.w, &buf[12]); + encode_real(q.x, &buf[0]); + encode_real(q.y, &buf[sizeof(real_t)]); + encode_real(q.z, &buf[sizeof(real_t) * 2]); + encode_real(q.w, &buf[sizeof(real_t) * 3]); } - r_len += 4 * 4; + r_len += 4 * sizeof(real_t); } break; case Variant::AABB: { if (buf) { AABB aabb = p_variant; - encode_float(aabb.position.x, &buf[0]); - encode_float(aabb.position.y, &buf[4]); - encode_float(aabb.position.z, &buf[8]); - encode_float(aabb.size.x, &buf[12]); - encode_float(aabb.size.y, &buf[16]); - encode_float(aabb.size.z, &buf[20]); + encode_real(aabb.position.x, &buf[0]); + encode_real(aabb.position.y, &buf[sizeof(real_t)]); + encode_real(aabb.position.z, &buf[sizeof(real_t) * 2]); + encode_real(aabb.size.x, &buf[sizeof(real_t) * 3]); + encode_real(aabb.size.y, &buf[sizeof(real_t) * 4]); + encode_real(aabb.size.z, &buf[sizeof(real_t) * 5]); } - r_len += 6 * 4; + r_len += 6 * sizeof(real_t); } break; case Variant::BASIS: { @@ -1130,12 +1297,12 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo Basis val = p_variant; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - memcpy(&buf[(i * 3 + j) * 4], &val.elements[i][j], sizeof(float)); + memcpy(&buf[(i * 3 + j) * sizeof(real_t)], &val.elements[i][j], sizeof(real_t)); } } } - r_len += 9 * 4; + r_len += 9 * sizeof(real_t); } break; case Variant::TRANSFORM3D: { @@ -1143,16 +1310,16 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo Transform3D val = p_variant; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { - memcpy(&buf[(i * 3 + j) * 4], &val.basis.elements[i][j], sizeof(float)); + memcpy(&buf[(i * 3 + j) * sizeof(real_t)], &val.basis.elements[i][j], sizeof(real_t)); } } - encode_float(val.origin.x, &buf[36]); - encode_float(val.origin.y, &buf[40]); - encode_float(val.origin.z, &buf[44]); + encode_real(val.origin.x, &buf[sizeof(real_t) * 9]); + encode_real(val.origin.y, &buf[sizeof(real_t) * 10]); + encode_real(val.origin.z, &buf[sizeof(real_t) * 11]); } - r_len += 12 * 4; + r_len += 12 * sizeof(real_t); } break; @@ -1166,7 +1333,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo encode_float(c.a, &buf[12]); } - r_len += 4 * 4; + r_len += 4 * 4; // Colors should always be in single-precision. } break; case Variant::RID: { @@ -1441,13 +1608,13 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo for (int i = 0; i < len; i++) { Vector2 v = data.get(i); - encode_float(v.x, &buf[0]); - encode_float(v.y, &buf[4]); - buf += 4 * 2; + encode_real(v.x, &buf[0]); + encode_real(v.y, &buf[sizeof(real_t)]); + buf += sizeof(real_t) * 2; } } - r_len += 4 * 2 * len; + r_len += sizeof(real_t) * 2 * len; } break; case Variant::PACKED_VECTOR3_ARRAY: { @@ -1465,14 +1632,14 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo for (int i = 0; i < len; i++) { Vector3 v = data.get(i); - encode_float(v.x, &buf[0]); - encode_float(v.y, &buf[4]); - encode_float(v.z, &buf[8]); - buf += 4 * 3; + encode_real(v.x, &buf[0]); + encode_real(v.y, &buf[sizeof(real_t)]); + encode_real(v.z, &buf[sizeof(real_t) * 2]); + buf += sizeof(real_t) * 3; } } - r_len += 4 * 3 * len; + r_len += sizeof(real_t) * 3 * len; } break; case Variant::PACKED_COLOR_ARRAY: { @@ -1494,7 +1661,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo encode_float(c.g, &buf[4]); encode_float(c.b, &buf[8]); encode_float(c.a, &buf[12]); - buf += 4 * 4; + buf += 4 * 4; // Colors should always be in single-precision. } } diff --git a/core/io/marshalls.h b/core/io/marshalls.h index 7fac708f97..3ebed914a3 100644 --- a/core/io/marshalls.h +++ b/core/io/marshalls.h @@ -31,10 +31,18 @@ #ifndef MARSHALLS_H #define MARSHALLS_H +#include "core/math/math_defs.h" #include "core/object/ref_counted.h" #include "core/typedefs.h" #include "core/variant/variant.h" +// uintr_t is only for pairing with real_t, and we only need it in here. +#ifdef REAL_T_IS_DOUBLE +typedef uint64_t uintr_t; +#else +typedef uint32_t uintr_t; +#endif + /** * Miscellaneous helpers for marshalling data types, and encoding * in an endian independent way @@ -50,6 +58,12 @@ union MarshallDouble { double d; ///< double }; +// Behaves like one of the above, depending on compilation setting. +union MarshallReal { + uintr_t i; + real_t r; +}; + static inline unsigned int encode_uint16(uint16_t p_uint, uint8_t *p_arr) { for (int i = 0; i < 2; i++) { *p_arr = p_uint & 0xFF; @@ -96,6 +110,24 @@ static inline unsigned int encode_double(double p_double, uint8_t *p_arr) { return sizeof(uint64_t); } +static inline unsigned int encode_uintr(uintr_t p_uint, uint8_t *p_arr) { + for (size_t i = 0; i < sizeof(uintr_t); i++) { + *p_arr = p_uint & 0xFF; + p_arr++; + p_uint >>= 8; + } + + return sizeof(uintr_t); +} + +static inline unsigned int encode_real(real_t p_real, uint8_t *p_arr) { + MarshallReal mr; + mr.r = p_real; + encode_uintr(mr.i, p_arr); + + return sizeof(uintr_t); +} + static inline int encode_cstring(const char *p_string, uint8_t *p_data) { int len = 0; diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp index 78ec7ea21a..51ba8800e4 100644 --- a/core/io/multiplayer_api.cpp +++ b/core/io/multiplayer_api.cpp @@ -1123,8 +1123,8 @@ void MultiplayerAPI::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_object_decoding"), "set_allow_object_decoding", "is_object_decoding_allowed"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "refuse_new_network_connections"), "set_refuse_new_network_connections", "is_refusing_new_network_connections"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "network_peer", PROPERTY_HINT_RESOURCE_TYPE, "NetworkedMultiplayerPeer", 0), "set_network_peer", "get_network_peer"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "root_node", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_root_node", "get_root_node"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "network_peer", PROPERTY_HINT_RESOURCE_TYPE, "NetworkedMultiplayerPeer", PROPERTY_USAGE_NONE), "set_network_peer", "get_network_peer"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "root_node", PROPERTY_HINT_RESOURCE_TYPE, "Node", PROPERTY_USAGE_NONE), "set_root_node", "get_root_node"); ADD_PROPERTY_DEFAULT("refuse_new_network_connections", false); ADD_SIGNAL(MethodInfo("network_peer_connected", PropertyInfo(Variant::INT, "id"))); diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp index 318fd10243..8da44fd290 100644 --- a/core/io/packet_peer.cpp +++ b/core/io/packet_peer.cpp @@ -161,7 +161,7 @@ void PacketPeerStream::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "input_buffer_max_size"), "set_input_buffer_max_size", "get_input_buffer_max_size"); ADD_PROPERTY(PropertyInfo(Variant::INT, "output_buffer_max_size"), "set_output_buffer_max_size", "get_output_buffer_max_size"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream_peer", PROPERTY_HINT_RESOURCE_TYPE, "StreamPeer", 0), "set_stream_peer", "get_stream_peer"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream_peer", PROPERTY_HINT_RESOURCE_TYPE, "StreamPeer", PROPERTY_USAGE_NONE), "set_stream_peer", "get_stream_peer"); } Error PacketPeerStream::_poll_buffer() const { diff --git a/core/math/basis.h b/core/math/basis.h index 3736047dd3..2889a4aa5e 100644 --- a/core/math/basis.h +++ b/core/math/basis.h @@ -158,8 +158,8 @@ public: _FORCE_INLINE_ Basis operator+(const Basis &p_matrix) const; _FORCE_INLINE_ void operator-=(const Basis &p_matrix); _FORCE_INLINE_ Basis operator-(const Basis &p_matrix) const; - _FORCE_INLINE_ void operator*=(real_t p_val); - _FORCE_INLINE_ Basis operator*(real_t p_val) const; + _FORCE_INLINE_ void operator*=(const real_t p_val); + _FORCE_INLINE_ Basis operator*(const real_t p_val) const; int get_orthogonal_index() const; void set_orthogonal_index(int p_index); @@ -298,13 +298,13 @@ _FORCE_INLINE_ Basis Basis::operator-(const Basis &p_matrix) const { return ret; } -_FORCE_INLINE_ void Basis::operator*=(real_t p_val) { +_FORCE_INLINE_ void Basis::operator*=(const real_t p_val) { elements[0] *= p_val; elements[1] *= p_val; elements[2] *= p_val; } -_FORCE_INLINE_ Basis Basis::operator*(real_t p_val) const { +_FORCE_INLINE_ Basis Basis::operator*(const real_t p_val) const { Basis ret(*this); ret *= p_val; return ret; diff --git a/core/math/quaternion.cpp b/core/math/quaternion.cpp index 7037db7112..3f1d2c58e5 100644 --- a/core/math/quaternion.cpp +++ b/core/math/quaternion.cpp @@ -33,6 +33,11 @@ #include "core/math/basis.h" #include "core/string/print_string.h" +real_t Quaternion::angle_to(const Quaternion &p_to) const { + real_t d = dot(p_to); + return Math::acos(CLAMP(d * d * 2 - 1, -1, 1)); +} + // get_euler_xyz returns a vector containing the Euler angles in the format // (ax,ay,az), where ax is the angle of rotation around x axis, // and similar for other axes. diff --git a/core/math/quaternion.h b/core/math/quaternion.h index 796214b79e..35324323b3 100644 --- a/core/math/quaternion.h +++ b/core/math/quaternion.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef QUAT_H -#define QUAT_H +#ifndef QUATERNION_H +#define QUATERNION_H #include "core/math/math_defs.h" #include "core/math/math_funcs.h" @@ -62,6 +62,7 @@ public: bool is_normalized() const; Quaternion inverse() const; _FORCE_INLINE_ real_t dot(const Quaternion &p_q) const; + real_t angle_to(const Quaternion &p_to) const; Vector3 get_euler_xyz() const; Vector3 get_euler_yxz() const; @@ -235,4 +236,4 @@ _FORCE_INLINE_ Quaternion operator*(const real_t &p_real, const Quaternion &p_qu return p_quaternion * p_real; } -#endif // QUAT_H +#endif // QUATERNION_H diff --git a/core/math/transform_2d.cpp b/core/math/transform_2d.cpp index 0140f31b8a..16934d67df 100644 --- a/core/math/transform_2d.cpp +++ b/core/math/transform_2d.cpp @@ -276,6 +276,18 @@ Transform2D Transform2D::interpolate_with(const Transform2D &p_transform, real_t return res; } +void Transform2D::operator*=(const real_t p_val) { + elements[0] *= p_val; + elements[1] *= p_val; + elements[2] *= p_val; +} + +Transform2D Transform2D::operator*(const real_t p_val) const { + Transform2D ret(*this); + ret *= p_val; + return ret; +} + Transform2D::operator String() const { return "[X: " + elements[0].operator String() + ", Y: " + elements[1].operator String() + diff --git a/core/math/transform_2d.h b/core/math/transform_2d.h index 715f013701..34cfd0c1a9 100644 --- a/core/math/transform_2d.h +++ b/core/math/transform_2d.h @@ -107,6 +107,8 @@ struct Transform2D { void operator*=(const Transform2D &p_transform); Transform2D operator*(const Transform2D &p_transform) const; + void operator*=(const real_t p_val); + Transform2D operator*(const real_t p_val) const; Transform2D interpolate_with(const Transform2D &p_transform, real_t p_c) const; diff --git a/core/math/transform_3d.cpp b/core/math/transform_3d.cpp index a34d998dde..51766b39f4 100644 --- a/core/math/transform_3d.cpp +++ b/core/math/transform_3d.cpp @@ -190,6 +190,17 @@ Transform3D Transform3D::operator*(const Transform3D &p_transform) const { return t; } +void Transform3D::operator*=(const real_t p_val) { + origin *= p_val; + basis *= p_val; +} + +Transform3D Transform3D::operator*(const real_t p_val) const { + Transform3D ret(*this); + ret *= p_val; + return ret; +} + Transform3D::operator String() const { return "[X: " + basis.get_axis(0).operator String() + ", Y: " + basis.get_axis(1).operator String() + diff --git a/core/math/transform_3d.h b/core/math/transform_3d.h index 078a2ca11a..3d8e70cec7 100644 --- a/core/math/transform_3d.h +++ b/core/math/transform_3d.h @@ -88,6 +88,8 @@ public: void operator*=(const Transform3D &p_transform); Transform3D operator*(const Transform3D &p_transform) const; + void operator*=(const real_t p_val); + Transform3D operator*(const real_t p_val) const; Transform3D interpolate_with(const Transform3D &p_transform, real_t p_c) const; diff --git a/core/object/object.h b/core/object/object.h index 37b2e61dfe..65621a47ca 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -101,6 +101,7 @@ enum PropertyHint { }; enum PropertyUsageFlags { + PROPERTY_USAGE_NONE = 0, PROPERTY_USAGE_STORAGE = 1, PROPERTY_USAGE_EDITOR = 2, PROPERTY_USAGE_NETWORK = 4, diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp index 196f7a1876..dd6bc09abb 100644 --- a/core/object/script_language.cpp +++ b/core/object/script_language.cpp @@ -120,7 +120,7 @@ void Script::_bind_methods() { ClassDB::bind_method(D_METHOD("is_tool"), &Script::is_tool); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "source_code", PROPERTY_HINT_NONE, "", 0), "set_source_code", "get_source_code"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "source_code", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_source_code", "get_source_code"); } void ScriptServer::set_scripting_enabled(bool p_enabled) { diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index f67d615418..fc8ab72e1a 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -86,7 +86,6 @@ static _OS *_os = nullptr; static _Engine *_engine = nullptr; static _ClassDB *_classdb = nullptr; static _Marshalls *_marshalls = nullptr; -static _JSON *_json = nullptr; static _EngineDebugger *_engine_debugger = nullptr; static IP *ip = nullptr; @@ -199,7 +198,7 @@ void register_core_types() { ClassDB::register_class<_Semaphore>(); ClassDB::register_class<XMLParser>(); - ClassDB::register_class<JSONParser>(); + ClassDB::register_class<JSON>(); ClassDB::register_class<ConfigFile>(); @@ -212,8 +211,6 @@ void register_core_types() { ClassDB::register_class<EncodedObjectAsID>(); ClassDB::register_class<RandomNumberGenerator>(); - ClassDB::register_class<JSONParseResult>(); - ClassDB::register_virtual_class<ResourceImporter>(); ip = IP::create(); @@ -227,7 +224,6 @@ void register_core_types() { _engine = memnew(_Engine); _classdb = memnew(_ClassDB); _marshalls = memnew(_Marshalls); - _json = memnew(_JSON); _engine_debugger = memnew(_EngineDebugger); } @@ -256,7 +252,6 @@ void register_core_singletons() { ClassDB::register_class<TranslationServer>(); ClassDB::register_virtual_class<Input>(); ClassDB::register_class<InputMap>(); - ClassDB::register_class<_JSON>(); ClassDB::register_class<Expression>(); ClassDB::register_class<_EngineDebugger>(); ClassDB::register_class<Time>(); @@ -274,7 +269,6 @@ void register_core_singletons() { Engine::get_singleton()->add_singleton(Engine::Singleton("TranslationServer", TranslationServer::get_singleton())); Engine::get_singleton()->add_singleton(Engine::Singleton("Input", Input::get_singleton())); Engine::get_singleton()->add_singleton(Engine::Singleton("InputMap", InputMap::get_singleton())); - Engine::get_singleton()->add_singleton(Engine::Singleton("JSON", _JSON::get_singleton())); Engine::get_singleton()->add_singleton(Engine::Singleton("EngineDebugger", _EngineDebugger::get_singleton())); Engine::get_singleton()->add_singleton(Engine::Singleton("Time", Time::get_singleton())); } @@ -286,7 +280,6 @@ void unregister_core_types() { memdelete(_engine); memdelete(_classdb); memdelete(_marshalls); - memdelete(_json); memdelete(_engine_debugger); memdelete(_geometry_2d); diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 019754bc22..16ecd2b985 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -294,7 +294,7 @@ Error String::parse_url(String &r_scheme, String &r_host, int &r_port, String &r // Port if (base.begins_with(":")) { base = base.substr(1, base.length() - 1); - if (!base.is_valid_integer()) { + if (!base.is_valid_int()) { return ERR_INVALID_PARAMETER; } r_port = base.to_int(); @@ -4168,7 +4168,7 @@ String String::trim_suffix(const String &p_suffix) const { return s; } -bool String::is_valid_integer() const { +bool String::is_valid_int() const { int len = length(); if (len == 0) { @@ -4393,7 +4393,7 @@ bool String::is_valid_ip_address() const { } for (int i = 0; i < ip.size(); i++) { String n = ip[i]; - if (!n.is_valid_integer()) { + if (!n.is_valid_int()) { return false; } int val = n.to_int(); diff --git a/core/string/ustring.h b/core/string/ustring.h index 82cd3e1667..ffb354d6e1 100644 --- a/core/string/ustring.h +++ b/core/string/ustring.h @@ -425,7 +425,7 @@ public: String validate_node_name() const; bool is_valid_identifier() const; - bool is_valid_integer() const; + bool is_valid_int() const; bool is_valid_float() const; bool is_valid_hex_number(bool p_with_prefix) const; bool is_valid_html_color() const; diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index 4e45862fd3..badb5ba103 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -32,6 +32,7 @@ #include "core/core_string_names.h" #include "core/debugger/engine_debugger.h" +#include "core/io/json.h" #include "core/io/marshalls.h" #include "core/io/resource.h" #include "core/math/math_funcs.h" @@ -1838,6 +1839,11 @@ String Variant::stringify(List<const void *> &stack) const { return ""; } +String Variant::to_json_string() const { + JSON json; + return json.stringify(*this); +} + Variant::operator Vector2() const { if (type == VECTOR2) { return *reinterpret_cast<const Vector2 *>(_data._mem); diff --git a/core/variant/variant.h b/core/variant/variant.h index 75316da63f..125173ea5c 100644 --- a/core/variant/variant.h +++ b/core/variant/variant.h @@ -645,6 +645,7 @@ public: bool hash_compare(const Variant &p_variant) const; bool booleanize() const; String stringify(List<const void *> &stack) const; + String to_json_string() const; void static_assign(const Variant &p_variant); static void get_constants_for_type(Variant::Type p_type, List<StringName> *p_constants); diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp index 05ed35c760..9c7cd23d72 100644 --- a/core/variant/variant_call.cpp +++ b/core/variant/variant_call.cpp @@ -1380,7 +1380,7 @@ static void _register_variant_builtin_methods() { bind_method(String, validate_node_name, sarray(), varray()); bind_method(String, is_valid_identifier, sarray(), varray()); - bind_method(String, is_valid_integer, sarray(), varray()); + bind_method(String, is_valid_int, sarray(), varray()); bind_method(String, is_valid_float, sarray(), varray()); bind_method(String, is_valid_hex_number, sarray("with_prefix"), varray(false)); bind_method(String, is_valid_html_color, sarray(), varray()); @@ -1552,6 +1552,7 @@ static void _register_variant_builtin_methods() { bind_method(Quaternion, is_normalized, sarray(), varray()); bind_method(Quaternion, is_equal_approx, sarray("to"), varray()); bind_method(Quaternion, inverse, sarray(), varray()); + bind_method(Quaternion, angle_to, sarray("to"), varray()); bind_method(Quaternion, dot, sarray("with"), varray()); bind_method(Quaternion, slerp, sarray("to", "weight"), varray()); bind_method(Quaternion, slerpni, sarray("to", "weight"), varray()); diff --git a/core/variant/variant_construct.cpp b/core/variant/variant_construct.cpp index 9e3ab5897b..a1a2bec369 100644 --- a/core/variant/variant_construct.cpp +++ b/core/variant/variant_construct.cpp @@ -28,543 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "variant.h" - -#include "core/core_string_names.h" -#include "core/crypto/crypto_core.h" -#include "core/debugger/engine_debugger.h" -#include "core/io/compression.h" -#include "core/object/class_db.h" -#include "core/os/os.h" -#include "core/templates/local_vector.h" -#include "core/templates/oa_hash_map.h" - -template <class T> -struct PtrConstruct {}; - -#define MAKE_PTRCONSTRUCT(m_type) \ - template <> \ - struct PtrConstruct<m_type> { \ - _FORCE_INLINE_ static void construct(const m_type &p_value, void *p_ptr) { \ - memnew_placement(p_ptr, m_type(p_value)); \ - } \ - }; - -MAKE_PTRCONSTRUCT(bool); -MAKE_PTRCONSTRUCT(int64_t); -MAKE_PTRCONSTRUCT(double); -MAKE_PTRCONSTRUCT(String); -MAKE_PTRCONSTRUCT(Vector2); -MAKE_PTRCONSTRUCT(Vector2i); -MAKE_PTRCONSTRUCT(Rect2); -MAKE_PTRCONSTRUCT(Rect2i); -MAKE_PTRCONSTRUCT(Vector3); -MAKE_PTRCONSTRUCT(Vector3i); -MAKE_PTRCONSTRUCT(Transform2D); -MAKE_PTRCONSTRUCT(Plane); -MAKE_PTRCONSTRUCT(Quaternion); -MAKE_PTRCONSTRUCT(AABB); -MAKE_PTRCONSTRUCT(Basis); -MAKE_PTRCONSTRUCT(Transform3D); -MAKE_PTRCONSTRUCT(Color); -MAKE_PTRCONSTRUCT(StringName); -MAKE_PTRCONSTRUCT(NodePath); -MAKE_PTRCONSTRUCT(RID); - -template <> -struct PtrConstruct<Object *> { - _FORCE_INLINE_ static void construct(Object *p_value, void *p_ptr) { - *((Object **)p_ptr) = p_value; - } -}; - -MAKE_PTRCONSTRUCT(Callable); -MAKE_PTRCONSTRUCT(Signal); -MAKE_PTRCONSTRUCT(Dictionary); -MAKE_PTRCONSTRUCT(Array); -MAKE_PTRCONSTRUCT(PackedByteArray); -MAKE_PTRCONSTRUCT(PackedInt32Array); -MAKE_PTRCONSTRUCT(PackedInt64Array); -MAKE_PTRCONSTRUCT(PackedFloat32Array); -MAKE_PTRCONSTRUCT(PackedFloat64Array); -MAKE_PTRCONSTRUCT(PackedStringArray); -MAKE_PTRCONSTRUCT(PackedVector2Array); -MAKE_PTRCONSTRUCT(PackedVector3Array); -MAKE_PTRCONSTRUCT(PackedColorArray); -MAKE_PTRCONSTRUCT(Variant); - -template <class T, class... P> -class VariantConstructor { - template <size_t... Is> - static _FORCE_INLINE_ void construct_helper(T &base, const Variant **p_args, Callable::CallError &r_error, IndexSequence<Is...>) { - r_error.error = Callable::CallError::CALL_OK; - -#ifdef DEBUG_METHODS_ENABLED - base = T(VariantCasterAndValidate<P>::cast(p_args, Is, r_error)...); -#else - base = T(VariantCaster<P>::cast(*p_args[Is])...); -#endif - } - - template <size_t... Is> - static _FORCE_INLINE_ void validated_construct_helper(T &base, const Variant **p_args, IndexSequence<Is...>) { - base = T((*VariantGetInternalPtr<P>::get_ptr(p_args[Is]))...); - } - - template <size_t... Is> - static _FORCE_INLINE_ void ptr_construct_helper(void *base, const void **p_args, IndexSequence<Is...>) { - PtrConstruct<T>::construct(T(PtrToArg<P>::convert(p_args[Is])...), base); - } - -public: - static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { - r_error.error = Callable::CallError::CALL_OK; - VariantTypeChanger<T>::change(&r_ret); - construct_helper(*VariantGetInternalPtr<T>::get_ptr(&r_ret), p_args, r_error, BuildIndexSequence<sizeof...(P)>{}); - } - - static void validated_construct(Variant *r_ret, const Variant **p_args) { - VariantTypeChanger<T>::change(r_ret); - validated_construct_helper(*VariantGetInternalPtr<T>::get_ptr(r_ret), p_args, BuildIndexSequence<sizeof...(P)>{}); - } - static void ptr_construct(void *base, const void **p_args) { - ptr_construct_helper(base, p_args, BuildIndexSequence<sizeof...(P)>{}); - } - - static int get_argument_count() { - return sizeof...(P); - } - - static Variant::Type get_argument_type(int p_arg) { - return call_get_argument_type<P...>(p_arg); - } - - static Variant::Type get_base_type() { - return GetTypeInfo<T>::VARIANT_TYPE; - } -}; - -class VariantConstructorObject { -public: - static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { - VariantInternal::clear(&r_ret); - if (p_args[0]->get_type() == Variant::NIL) { - VariantInternal::object_assign_null(&r_ret); - r_error.error = Callable::CallError::CALL_OK; - } else if (p_args[0]->get_type() == Variant::OBJECT) { - VariantInternal::object_assign(&r_ret, p_args[0]); - r_error.error = Callable::CallError::CALL_OK; - } else { - r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; - r_error.argument = 0; - r_error.expected = Variant::OBJECT; - } - } - - static void validated_construct(Variant *r_ret, const Variant **p_args) { - VariantInternal::clear(r_ret); - VariantInternal::object_assign(r_ret, p_args[0]); - } - static void ptr_construct(void *base, const void **p_args) { - PtrConstruct<Object *>::construct(PtrToArg<Object *>::convert(p_args[0]), base); - } - - static int get_argument_count() { - return 1; - } - - static Variant::Type get_argument_type(int p_arg) { - return Variant::OBJECT; - } - - static Variant::Type get_base_type() { - return Variant::OBJECT; - } -}; - -class VariantConstructorNilObject { -public: - static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { - if (p_args[0]->get_type() != Variant::NIL) { - r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; - r_error.argument = 0; - r_error.expected = Variant::NIL; - } - - VariantInternal::clear(&r_ret); - VariantInternal::object_assign_null(&r_ret); - } - - static void validated_construct(Variant *r_ret, const Variant **p_args) { - VariantInternal::clear(r_ret); - VariantInternal::object_assign_null(r_ret); - } - static void ptr_construct(void *base, const void **p_args) { - PtrConstruct<Object *>::construct(nullptr, base); - } - - static int get_argument_count() { - return 1; - } - - static Variant::Type get_argument_type(int p_arg) { - return Variant::NIL; - } - - static Variant::Type get_base_type() { - return Variant::OBJECT; - } -}; - -class VariantConstructorCallableArgs { -public: - static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { - ObjectID object_id; - StringName method; - - if (p_args[0]->get_type() == Variant::NIL) { - // leave as is - } else if (p_args[0]->get_type() == Variant::OBJECT) { - object_id = VariantInternal::get_object_id(p_args[0]); - } else { - r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; - r_error.argument = 0; - r_error.expected = Variant::OBJECT; - return; - } - - if (p_args[1]->get_type() == Variant::STRING_NAME) { - method = *VariantGetInternalPtr<StringName>::get_ptr(p_args[1]); - } else if (p_args[1]->get_type() == Variant::STRING) { - method = *VariantGetInternalPtr<String>::get_ptr(p_args[1]); - } else { - r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; - r_error.argument = 1; - r_error.expected = Variant::STRING_NAME; - return; - } - - VariantTypeChanger<Callable>::change(&r_ret); - *VariantGetInternalPtr<Callable>::get_ptr(&r_ret) = Callable(object_id, method); - } - - static void validated_construct(Variant *r_ret, const Variant **p_args) { - VariantTypeChanger<Callable>::change(r_ret); - *VariantGetInternalPtr<Callable>::get_ptr(r_ret) = Callable(VariantInternal::get_object_id(p_args[0]), *VariantGetInternalPtr<StringName>::get_ptr(p_args[1])); - } - static void ptr_construct(void *base, const void **p_args) { - PtrConstruct<Callable>::construct(Callable(PtrToArg<Object *>::convert(p_args[0]), PtrToArg<StringName>::convert(p_args[1])), base); - } - - static int get_argument_count() { - return 2; - } - - static Variant::Type get_argument_type(int p_arg) { - if (p_arg == 0) { - return Variant::OBJECT; - } else { - return Variant::STRING_NAME; - } - } - - static Variant::Type get_base_type() { - return Variant::CALLABLE; - } -}; - -class VariantConstructorSignalArgs { -public: - static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { - ObjectID object_id; - StringName method; - - if (p_args[0]->get_type() == Variant::NIL) { - // leave as is - } else if (p_args[0]->get_type() == Variant::OBJECT) { - object_id = VariantInternal::get_object_id(p_args[0]); - } else { - r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; - r_error.argument = 0; - r_error.expected = Variant::OBJECT; - return; - } - - if (p_args[1]->get_type() == Variant::STRING_NAME) { - method = *VariantGetInternalPtr<StringName>::get_ptr(p_args[1]); - } else if (p_args[1]->get_type() == Variant::STRING) { - method = *VariantGetInternalPtr<String>::get_ptr(p_args[1]); - } else { - r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; - r_error.argument = 1; - r_error.expected = Variant::STRING_NAME; - return; - } - - VariantTypeChanger<Signal>::change(&r_ret); - *VariantGetInternalPtr<Signal>::get_ptr(&r_ret) = Signal(object_id, method); - } - - static void validated_construct(Variant *r_ret, const Variant **p_args) { - VariantTypeChanger<Signal>::change(r_ret); - *VariantGetInternalPtr<Signal>::get_ptr(r_ret) = Signal(VariantInternal::get_object_id(p_args[0]), *VariantGetInternalPtr<StringName>::get_ptr(p_args[1])); - } - static void ptr_construct(void *base, const void **p_args) { - PtrConstruct<Signal>::construct(Signal(PtrToArg<Object *>::convert(p_args[0]), PtrToArg<StringName>::convert(p_args[1])), base); - } - - static int get_argument_count() { - return 2; - } - - static Variant::Type get_argument_type(int p_arg) { - if (p_arg == 0) { - return Variant::OBJECT; - } else { - return Variant::STRING_NAME; - } - } - - static Variant::Type get_base_type() { - return Variant::SIGNAL; - } -}; - -template <class T> -class VariantConstructorToArray { -public: - static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { - if (p_args[0]->get_type() != GetTypeInfo<T>::VARIANT_TYPE) { - r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; - r_error.argument = 0; - r_error.expected = GetTypeInfo<T>::VARIANT_TYPE; - return; - } - - VariantTypeChanger<Array>::change(&r_ret); - Array &dst_arr = *VariantGetInternalPtr<Array>::get_ptr(&r_ret); - const T &src_arr = *VariantGetInternalPtr<T>::get_ptr(p_args[0]); - - int size = src_arr.size(); - dst_arr.resize(size); - for (int i = 0; i < size; i++) { - dst_arr[i] = src_arr[i]; - } - } - - static void validated_construct(Variant *r_ret, const Variant **p_args) { - VariantTypeChanger<Array>::change(r_ret); - Array &dst_arr = *VariantGetInternalPtr<Array>::get_ptr(r_ret); - const T &src_arr = *VariantGetInternalPtr<T>::get_ptr(p_args[0]); - - int size = src_arr.size(); - dst_arr.resize(size); - for (int i = 0; i < size; i++) { - dst_arr[i] = src_arr[i]; - } - } - static void ptr_construct(void *base, const void **p_args) { - Array dst_arr; - T src_arr = PtrToArg<T>::convert(p_args[0]); - - int size = src_arr.size(); - dst_arr.resize(size); - for (int i = 0; i < size; i++) { - dst_arr[i] = src_arr[i]; - } - - PtrConstruct<Array>::construct(dst_arr, base); - } - - static int get_argument_count() { - return 1; - } - - static Variant::Type get_argument_type(int p_arg) { - return GetTypeInfo<T>::VARIANT_TYPE; - } - - static Variant::Type get_base_type() { - return Variant::ARRAY; - } -}; - -template <class T> -class VariantConstructorFromArray { -public: - static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { - if (p_args[0]->get_type() != Variant::ARRAY) { - r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; - r_error.argument = 0; - r_error.expected = Variant::ARRAY; - return; - } - - VariantTypeChanger<T>::change(&r_ret); - const Array &src_arr = *VariantGetInternalPtr<Array>::get_ptr(p_args[0]); - T &dst_arr = *VariantGetInternalPtr<T>::get_ptr(&r_ret); - - int size = src_arr.size(); - dst_arr.resize(size); - for (int i = 0; i < size; i++) { - dst_arr.write[i] = src_arr[i]; - } - } - - static void validated_construct(Variant *r_ret, const Variant **p_args) { - VariantTypeChanger<T>::change(r_ret); - const Array &src_arr = *VariantGetInternalPtr<Array>::get_ptr(p_args[0]); - T &dst_arr = *VariantGetInternalPtr<T>::get_ptr(r_ret); - - int size = src_arr.size(); - dst_arr.resize(size); - for (int i = 0; i < size; i++) { - dst_arr.write[i] = src_arr[i]; - } - } - static void ptr_construct(void *base, const void **p_args) { - Array src_arr = PtrToArg<Array>::convert(p_args[0]); - T dst_arr; - - int size = src_arr.size(); - dst_arr.resize(size); - for (int i = 0; i < size; i++) { - dst_arr.write[i] = src_arr[i]; - } - - PtrConstruct<T>::construct(dst_arr, base); - } - - static int get_argument_count() { - return 1; - } - - static Variant::Type get_argument_type(int p_arg) { - return Variant::ARRAY; - } - - static Variant::Type get_base_type() { - return GetTypeInfo<T>::VARIANT_TYPE; - } -}; - -class VariantConstructorNil { -public: - static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { - if (p_args[0]->get_type() != Variant::NIL) { - r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; - r_error.argument = 0; - r_error.expected = Variant::NIL; - return; - } - - r_error.error = Callable::CallError::CALL_OK; - VariantInternal::clear(&r_ret); - } - - static void validated_construct(Variant *r_ret, const Variant **p_args) { - VariantInternal::clear(r_ret); - } - static void ptr_construct(void *base, const void **p_args) { - PtrConstruct<Variant>::construct(Variant(), base); - } - - static int get_argument_count() { - return 1; - } - - static Variant::Type get_argument_type(int p_arg) { - return Variant::NIL; - } - - static Variant::Type get_base_type() { - return Variant::NIL; - } -}; - -template <class T> -class VariantConstructNoArgs { -public: - static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { - VariantTypeChanger<T>::change_and_reset(&r_ret); - r_error.error = Callable::CallError::CALL_OK; - } - - static void validated_construct(Variant *r_ret, const Variant **p_args) { - VariantTypeChanger<T>::change_and_reset(r_ret); - } - static void ptr_construct(void *base, const void **p_args) { - PtrConstruct<T>::construct(T(), base); - } - - static int get_argument_count() { - return 0; - } - - static Variant::Type get_argument_type(int p_arg) { - return Variant::NIL; - } - - static Variant::Type get_base_type() { - return GetTypeInfo<T>::VARIANT_TYPE; - } -}; - -class VariantConstructNoArgsNil { -public: - static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { - VariantInternal::clear(&r_ret); - r_error.error = Callable::CallError::CALL_OK; - } - - static void validated_construct(Variant *r_ret, const Variant **p_args) { - VariantInternal::clear(r_ret); - } - static void ptr_construct(void *base, const void **p_args) { - ERR_FAIL_MSG("can't ptrcall nil constructor"); - } - - static int get_argument_count() { - return 0; - } - - static Variant::Type get_argument_type(int p_arg) { - return Variant::NIL; - } - - static Variant::Type get_base_type() { - return Variant::NIL; - } -}; - -class VariantConstructNoArgsObject { -public: - static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { - VariantInternal::clear(&r_ret); - VariantInternal::object_assign_null(&r_ret); - r_error.error = Callable::CallError::CALL_OK; - } - - static void validated_construct(Variant *r_ret, const Variant **p_args) { - VariantInternal::clear(r_ret); - VariantInternal::object_assign_null(r_ret); - } - static void ptr_construct(void *base, const void **p_args) { - PtrConstruct<Object *>::construct(nullptr, base); - } - - static int get_argument_count() { - return 0; - } - - static Variant::Type get_argument_type(int p_arg) { - return Variant::NIL; - } - - static Variant::Type get_base_type() { - return Variant::OBJECT; - } -}; +#include "variant_construct.h" struct VariantConstructData { void (*construct)(Variant &r_base, const Variant **p_args, Callable::CallError &r_error); diff --git a/core/variant/variant_construct.h b/core/variant/variant_construct.h new file mode 100644 index 0000000000..b03f4a8d3b --- /dev/null +++ b/core/variant/variant_construct.h @@ -0,0 +1,572 @@ +/*************************************************************************/ +/* variant_construct.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef VARIANT_CONSTRUCT_H +#define VARIANT_CONSTRUCT_H + +#include "variant.h" + +#include "core/core_string_names.h" +#include "core/crypto/crypto_core.h" +#include "core/debugger/engine_debugger.h" +#include "core/io/compression.h" +#include "core/object/class_db.h" +#include "core/os/os.h" +#include "core/templates/local_vector.h" +#include "core/templates/oa_hash_map.h" + +template <class T> +struct PtrConstruct {}; + +#define MAKE_PTRCONSTRUCT(m_type) \ + template <> \ + struct PtrConstruct<m_type> { \ + _FORCE_INLINE_ static void construct(const m_type &p_value, void *p_ptr) { \ + memnew_placement(p_ptr, m_type(p_value)); \ + } \ + }; + +MAKE_PTRCONSTRUCT(bool); +MAKE_PTRCONSTRUCT(int64_t); +MAKE_PTRCONSTRUCT(double); +MAKE_PTRCONSTRUCT(String); +MAKE_PTRCONSTRUCT(Vector2); +MAKE_PTRCONSTRUCT(Vector2i); +MAKE_PTRCONSTRUCT(Rect2); +MAKE_PTRCONSTRUCT(Rect2i); +MAKE_PTRCONSTRUCT(Vector3); +MAKE_PTRCONSTRUCT(Vector3i); +MAKE_PTRCONSTRUCT(Transform2D); +MAKE_PTRCONSTRUCT(Plane); +MAKE_PTRCONSTRUCT(Quaternion); +MAKE_PTRCONSTRUCT(AABB); +MAKE_PTRCONSTRUCT(Basis); +MAKE_PTRCONSTRUCT(Transform3D); +MAKE_PTRCONSTRUCT(Color); +MAKE_PTRCONSTRUCT(StringName); +MAKE_PTRCONSTRUCT(NodePath); +MAKE_PTRCONSTRUCT(RID); + +template <> +struct PtrConstruct<Object *> { + _FORCE_INLINE_ static void construct(Object *p_value, void *p_ptr) { + *((Object **)p_ptr) = p_value; + } +}; + +MAKE_PTRCONSTRUCT(Callable); +MAKE_PTRCONSTRUCT(Signal); +MAKE_PTRCONSTRUCT(Dictionary); +MAKE_PTRCONSTRUCT(Array); +MAKE_PTRCONSTRUCT(PackedByteArray); +MAKE_PTRCONSTRUCT(PackedInt32Array); +MAKE_PTRCONSTRUCT(PackedInt64Array); +MAKE_PTRCONSTRUCT(PackedFloat32Array); +MAKE_PTRCONSTRUCT(PackedFloat64Array); +MAKE_PTRCONSTRUCT(PackedStringArray); +MAKE_PTRCONSTRUCT(PackedVector2Array); +MAKE_PTRCONSTRUCT(PackedVector3Array); +MAKE_PTRCONSTRUCT(PackedColorArray); +MAKE_PTRCONSTRUCT(Variant); + +template <class T, class... P> +class VariantConstructor { + template <size_t... Is> + static _FORCE_INLINE_ void construct_helper(T &base, const Variant **p_args, Callable::CallError &r_error, IndexSequence<Is...>) { + r_error.error = Callable::CallError::CALL_OK; + +#ifdef DEBUG_METHODS_ENABLED + base = T(VariantCasterAndValidate<P>::cast(p_args, Is, r_error)...); +#else + base = T(VariantCaster<P>::cast(*p_args[Is])...); +#endif + } + + template <size_t... Is> + static _FORCE_INLINE_ void validated_construct_helper(T &base, const Variant **p_args, IndexSequence<Is...>) { + base = T((*VariantGetInternalPtr<P>::get_ptr(p_args[Is]))...); + } + + template <size_t... Is> + static _FORCE_INLINE_ void ptr_construct_helper(void *base, const void **p_args, IndexSequence<Is...>) { + PtrConstruct<T>::construct(T(PtrToArg<P>::convert(p_args[Is])...), base); + } + +public: + static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { + r_error.error = Callable::CallError::CALL_OK; + VariantTypeChanger<T>::change(&r_ret); + construct_helper(*VariantGetInternalPtr<T>::get_ptr(&r_ret), p_args, r_error, BuildIndexSequence<sizeof...(P)>{}); + } + + static inline void validated_construct(Variant *r_ret, const Variant **p_args) { + VariantTypeChanger<T>::change(r_ret); + validated_construct_helper(*VariantGetInternalPtr<T>::get_ptr(r_ret), p_args, BuildIndexSequence<sizeof...(P)>{}); + } + static void ptr_construct(void *base, const void **p_args) { + ptr_construct_helper(base, p_args, BuildIndexSequence<sizeof...(P)>{}); + } + + static int get_argument_count() { + return sizeof...(P); + } + + static Variant::Type get_argument_type(int p_arg) { + return call_get_argument_type<P...>(p_arg); + } + + static Variant::Type get_base_type() { + return GetTypeInfo<T>::VARIANT_TYPE; + } +}; + +class VariantConstructorObject { +public: + static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { + VariantInternal::clear(&r_ret); + if (p_args[0]->get_type() == Variant::NIL) { + VariantInternal::object_assign_null(&r_ret); + r_error.error = Callable::CallError::CALL_OK; + } else if (p_args[0]->get_type() == Variant::OBJECT) { + VariantInternal::object_assign(&r_ret, p_args[0]); + r_error.error = Callable::CallError::CALL_OK; + } else { + r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument = 0; + r_error.expected = Variant::OBJECT; + } + } + + static inline void validated_construct(Variant *r_ret, const Variant **p_args) { + VariantInternal::clear(r_ret); + VariantInternal::object_assign(r_ret, p_args[0]); + } + static void ptr_construct(void *base, const void **p_args) { + PtrConstruct<Object *>::construct(PtrToArg<Object *>::convert(p_args[0]), base); + } + + static int get_argument_count() { + return 1; + } + + static Variant::Type get_argument_type(int p_arg) { + return Variant::OBJECT; + } + + static Variant::Type get_base_type() { + return Variant::OBJECT; + } +}; + +class VariantConstructorNilObject { +public: + static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { + if (p_args[0]->get_type() != Variant::NIL) { + r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument = 0; + r_error.expected = Variant::NIL; + } + + VariantInternal::clear(&r_ret); + VariantInternal::object_assign_null(&r_ret); + } + + static inline void validated_construct(Variant *r_ret, const Variant **p_args) { + VariantInternal::clear(r_ret); + VariantInternal::object_assign_null(r_ret); + } + static void ptr_construct(void *base, const void **p_args) { + PtrConstruct<Object *>::construct(nullptr, base); + } + + static int get_argument_count() { + return 1; + } + + static Variant::Type get_argument_type(int p_arg) { + return Variant::NIL; + } + + static Variant::Type get_base_type() { + return Variant::OBJECT; + } +}; + +class VariantConstructorCallableArgs { +public: + static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { + ObjectID object_id; + StringName method; + + if (p_args[0]->get_type() == Variant::NIL) { + // leave as is + } else if (p_args[0]->get_type() == Variant::OBJECT) { + object_id = VariantInternal::get_object_id(p_args[0]); + } else { + r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument = 0; + r_error.expected = Variant::OBJECT; + return; + } + + if (p_args[1]->get_type() == Variant::STRING_NAME) { + method = *VariantGetInternalPtr<StringName>::get_ptr(p_args[1]); + } else if (p_args[1]->get_type() == Variant::STRING) { + method = *VariantGetInternalPtr<String>::get_ptr(p_args[1]); + } else { + r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument = 1; + r_error.expected = Variant::STRING_NAME; + return; + } + + VariantTypeChanger<Callable>::change(&r_ret); + *VariantGetInternalPtr<Callable>::get_ptr(&r_ret) = Callable(object_id, method); + } + + static inline void validated_construct(Variant *r_ret, const Variant **p_args) { + VariantTypeChanger<Callable>::change(r_ret); + *VariantGetInternalPtr<Callable>::get_ptr(r_ret) = Callable(VariantInternal::get_object_id(p_args[0]), *VariantGetInternalPtr<StringName>::get_ptr(p_args[1])); + } + static void ptr_construct(void *base, const void **p_args) { + PtrConstruct<Callable>::construct(Callable(PtrToArg<Object *>::convert(p_args[0]), PtrToArg<StringName>::convert(p_args[1])), base); + } + + static int get_argument_count() { + return 2; + } + + static Variant::Type get_argument_type(int p_arg) { + if (p_arg == 0) { + return Variant::OBJECT; + } else { + return Variant::STRING_NAME; + } + } + + static Variant::Type get_base_type() { + return Variant::CALLABLE; + } +}; + +class VariantConstructorSignalArgs { +public: + static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { + ObjectID object_id; + StringName method; + + if (p_args[0]->get_type() == Variant::NIL) { + // leave as is + } else if (p_args[0]->get_type() == Variant::OBJECT) { + object_id = VariantInternal::get_object_id(p_args[0]); + } else { + r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument = 0; + r_error.expected = Variant::OBJECT; + return; + } + + if (p_args[1]->get_type() == Variant::STRING_NAME) { + method = *VariantGetInternalPtr<StringName>::get_ptr(p_args[1]); + } else if (p_args[1]->get_type() == Variant::STRING) { + method = *VariantGetInternalPtr<String>::get_ptr(p_args[1]); + } else { + r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument = 1; + r_error.expected = Variant::STRING_NAME; + return; + } + + VariantTypeChanger<Signal>::change(&r_ret); + *VariantGetInternalPtr<Signal>::get_ptr(&r_ret) = Signal(object_id, method); + } + + static inline void validated_construct(Variant *r_ret, const Variant **p_args) { + VariantTypeChanger<Signal>::change(r_ret); + *VariantGetInternalPtr<Signal>::get_ptr(r_ret) = Signal(VariantInternal::get_object_id(p_args[0]), *VariantGetInternalPtr<StringName>::get_ptr(p_args[1])); + } + static void ptr_construct(void *base, const void **p_args) { + PtrConstruct<Signal>::construct(Signal(PtrToArg<Object *>::convert(p_args[0]), PtrToArg<StringName>::convert(p_args[1])), base); + } + + static int get_argument_count() { + return 2; + } + + static Variant::Type get_argument_type(int p_arg) { + if (p_arg == 0) { + return Variant::OBJECT; + } else { + return Variant::STRING_NAME; + } + } + + static Variant::Type get_base_type() { + return Variant::SIGNAL; + } +}; + +template <class T> +class VariantConstructorToArray { +public: + static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { + if (p_args[0]->get_type() != GetTypeInfo<T>::VARIANT_TYPE) { + r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument = 0; + r_error.expected = GetTypeInfo<T>::VARIANT_TYPE; + return; + } + + VariantTypeChanger<Array>::change(&r_ret); + Array &dst_arr = *VariantGetInternalPtr<Array>::get_ptr(&r_ret); + const T &src_arr = *VariantGetInternalPtr<T>::get_ptr(p_args[0]); + + int size = src_arr.size(); + dst_arr.resize(size); + for (int i = 0; i < size; i++) { + dst_arr[i] = src_arr[i]; + } + } + + static inline void validated_construct(Variant *r_ret, const Variant **p_args) { + VariantTypeChanger<Array>::change(r_ret); + Array &dst_arr = *VariantGetInternalPtr<Array>::get_ptr(r_ret); + const T &src_arr = *VariantGetInternalPtr<T>::get_ptr(p_args[0]); + + int size = src_arr.size(); + dst_arr.resize(size); + for (int i = 0; i < size; i++) { + dst_arr[i] = src_arr[i]; + } + } + static void ptr_construct(void *base, const void **p_args) { + Array dst_arr; + T src_arr = PtrToArg<T>::convert(p_args[0]); + + int size = src_arr.size(); + dst_arr.resize(size); + for (int i = 0; i < size; i++) { + dst_arr[i] = src_arr[i]; + } + + PtrConstruct<Array>::construct(dst_arr, base); + } + + static int get_argument_count() { + return 1; + } + + static Variant::Type get_argument_type(int p_arg) { + return GetTypeInfo<T>::VARIANT_TYPE; + } + + static Variant::Type get_base_type() { + return Variant::ARRAY; + } +}; + +template <class T> +class VariantConstructorFromArray { +public: + static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { + if (p_args[0]->get_type() != Variant::ARRAY) { + r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument = 0; + r_error.expected = Variant::ARRAY; + return; + } + + VariantTypeChanger<T>::change(&r_ret); + const Array &src_arr = *VariantGetInternalPtr<Array>::get_ptr(p_args[0]); + T &dst_arr = *VariantGetInternalPtr<T>::get_ptr(&r_ret); + + int size = src_arr.size(); + dst_arr.resize(size); + for (int i = 0; i < size; i++) { + dst_arr.write[i] = src_arr[i]; + } + } + + static inline void validated_construct(Variant *r_ret, const Variant **p_args) { + VariantTypeChanger<T>::change(r_ret); + const Array &src_arr = *VariantGetInternalPtr<Array>::get_ptr(p_args[0]); + T &dst_arr = *VariantGetInternalPtr<T>::get_ptr(r_ret); + + int size = src_arr.size(); + dst_arr.resize(size); + for (int i = 0; i < size; i++) { + dst_arr.write[i] = src_arr[i]; + } + } + static void ptr_construct(void *base, const void **p_args) { + Array src_arr = PtrToArg<Array>::convert(p_args[0]); + T dst_arr; + + int size = src_arr.size(); + dst_arr.resize(size); + for (int i = 0; i < size; i++) { + dst_arr.write[i] = src_arr[i]; + } + + PtrConstruct<T>::construct(dst_arr, base); + } + + static int get_argument_count() { + return 1; + } + + static Variant::Type get_argument_type(int p_arg) { + return Variant::ARRAY; + } + + static Variant::Type get_base_type() { + return GetTypeInfo<T>::VARIANT_TYPE; + } +}; + +class VariantConstructorNil { +public: + static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { + if (p_args[0]->get_type() != Variant::NIL) { + r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT; + r_error.argument = 0; + r_error.expected = Variant::NIL; + return; + } + + r_error.error = Callable::CallError::CALL_OK; + VariantInternal::clear(&r_ret); + } + + static inline void validated_construct(Variant *r_ret, const Variant **p_args) { + VariantInternal::clear(r_ret); + } + static void ptr_construct(void *base, const void **p_args) { + PtrConstruct<Variant>::construct(Variant(), base); + } + + static int get_argument_count() { + return 1; + } + + static Variant::Type get_argument_type(int p_arg) { + return Variant::NIL; + } + + static Variant::Type get_base_type() { + return Variant::NIL; + } +}; + +template <class T> +class VariantConstructNoArgs { +public: + static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { + VariantTypeChanger<T>::change_and_reset(&r_ret); + r_error.error = Callable::CallError::CALL_OK; + } + + static inline void validated_construct(Variant *r_ret, const Variant **p_args) { + VariantTypeChanger<T>::change_and_reset(r_ret); + } + static void ptr_construct(void *base, const void **p_args) { + PtrConstruct<T>::construct(T(), base); + } + + static int get_argument_count() { + return 0; + } + + static Variant::Type get_argument_type(int p_arg) { + return Variant::NIL; + } + + static Variant::Type get_base_type() { + return GetTypeInfo<T>::VARIANT_TYPE; + } +}; + +class VariantConstructNoArgsNil { +public: + static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { + VariantInternal::clear(&r_ret); + r_error.error = Callable::CallError::CALL_OK; + } + + static inline void validated_construct(Variant *r_ret, const Variant **p_args) { + VariantInternal::clear(r_ret); + } + static void ptr_construct(void *base, const void **p_args) { + ERR_FAIL_MSG("can't ptrcall nil constructor"); + } + + static int get_argument_count() { + return 0; + } + + static Variant::Type get_argument_type(int p_arg) { + return Variant::NIL; + } + + static Variant::Type get_base_type() { + return Variant::NIL; + } +}; + +class VariantConstructNoArgsObject { +public: + static void construct(Variant &r_ret, const Variant **p_args, Callable::CallError &r_error) { + VariantInternal::clear(&r_ret); + VariantInternal::object_assign_null(&r_ret); + r_error.error = Callable::CallError::CALL_OK; + } + + static inline void validated_construct(Variant *r_ret, const Variant **p_args) { + VariantInternal::clear(r_ret); + VariantInternal::object_assign_null(r_ret); + } + static void ptr_construct(void *base, const void **p_args) { + PtrConstruct<Object *>::construct(nullptr, base); + } + + static int get_argument_count() { + return 0; + } + + static Variant::Type get_argument_type(int p_arg) { + return Variant::NIL; + } + + static Variant::Type get_base_type() { + return Variant::OBJECT; + } +}; + +#endif // VARIANT_CONSTRUCT_H diff --git a/core/variant/variant_op.cpp b/core/variant/variant_op.cpp index 10d0a83014..4a1950c9bf 100644 --- a/core/variant/variant_op.cpp +++ b/core/variant/variant_op.cpp @@ -28,1342 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "variant.h" - -#include "core/core_string_names.h" -#include "core/debugger/engine_debugger.h" -#include "core/object/class_db.h" - -template <class R, class A, class B> -class OperatorEvaluatorAdd { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - *r_ret = a + b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<R>::change(r_ret); - *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) + *VariantGetInternalPtr<B>::get_ptr(right); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<R>::encode(PtrToArg<A>::convert(left) + PtrToArg<B>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } -}; - -template <class R, class A, class B> -class OperatorEvaluatorSub { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - *r_ret = a - b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<R>::change(r_ret); - *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) - *VariantGetInternalPtr<B>::get_ptr(right); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<R>::encode(PtrToArg<A>::convert(left) - PtrToArg<B>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } -}; - -template <class R, class A, class B> -class OperatorEvaluatorMul { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - *r_ret = a * b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<R>::change(r_ret); - *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) * *VariantGetInternalPtr<B>::get_ptr(right); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<R>::encode(PtrToArg<A>::convert(left) * PtrToArg<B>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } -}; - -template <class R, class A, class B> -class OperatorEvaluatorXForm { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - *r_ret = a.xform(b); - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<R>::change(r_ret); - *VariantGetInternalPtr<R>::get_ptr(r_ret) = VariantGetInternalPtr<A>::get_ptr(left)->xform(*VariantGetInternalPtr<B>::get_ptr(right)); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<R>::encode(PtrToArg<A>::convert(left).xform(PtrToArg<B>::convert(right)), r_ret); - } - static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } -}; - -template <class R, class A, class B> -class OperatorEvaluatorXFormInv { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - *r_ret = b.xform_inv(a); - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<R>::change(r_ret); - *VariantGetInternalPtr<R>::get_ptr(r_ret) = VariantGetInternalPtr<B>::get_ptr(right)->xform_inv(*VariantGetInternalPtr<A>::get_ptr(left)); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<R>::encode(PtrToArg<B>::convert(right).xform_inv(PtrToArg<A>::convert(left)), r_ret); - } - static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } -}; - -template <class R, class A, class B> -class OperatorEvaluatorDiv { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - *r_ret = a / b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<R>::change(r_ret); - *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) / *VariantGetInternalPtr<B>::get_ptr(right); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<R>::encode(PtrToArg<A>::convert(left) / PtrToArg<B>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } -}; - -template <class R, class A, class B> -class OperatorEvaluatorDivNZ { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - if (b == 0) { - r_valid = false; - *r_ret = "Division by zero error"; - return; - } - *r_ret = a / b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<R>::change(r_ret); - *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) / *VariantGetInternalPtr<B>::get_ptr(right); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<R>::encode(PtrToArg<A>::convert(left) / PtrToArg<B>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } -}; - -template <class R, class A, class B> -class OperatorEvaluatorMod { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - *r_ret = a % b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<R>::change(r_ret); - *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) % *VariantGetInternalPtr<B>::get_ptr(right); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<R>::encode(PtrToArg<A>::convert(left) % PtrToArg<B>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } -}; - -template <class R, class A, class B> -class OperatorEvaluatorModNZ { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - if (b == 0) { - r_valid = false; - *r_ret = "Module by zero error"; - return; - } - *r_ret = a % b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<R>::change(r_ret); - *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) % *VariantGetInternalPtr<B>::get_ptr(right); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<R>::encode(PtrToArg<A>::convert(left) % PtrToArg<B>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } -}; - -template <class R, class A> -class OperatorEvaluatorNeg { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - *r_ret = -a; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<R>::change(r_ret); - *VariantGetInternalPtr<R>::get_ptr(r_ret) = -*VariantGetInternalPtr<A>::get_ptr(left); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<R>::encode(-PtrToArg<A>::convert(left), r_ret); - } - static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } -}; - -template <class R, class A> -class OperatorEvaluatorPos { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - *r_ret = a; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<R>::change(r_ret); - *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<R>::encode(PtrToArg<A>::convert(left), r_ret); - } - static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } -}; - -template <class R, class A, class B> -class OperatorEvaluatorShiftLeft { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - -#if defined(DEBUG_ENABLED) - if (b < 0 || a < 0) { - *r_ret = "Invalid operands for bit shifting. Only positive operands are supported."; - r_valid = false; - return; - } -#endif - *r_ret = a << b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<R>::change(r_ret); - *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) << *VariantGetInternalPtr<B>::get_ptr(right); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<R>::encode(PtrToArg<A>::convert(left) << PtrToArg<B>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } -}; - -template <class R, class A, class B> -class OperatorEvaluatorShiftRight { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - -#if defined(DEBUG_ENABLED) - if (b < 0 || a < 0) { - *r_ret = "Invalid operands for bit shifting. Only positive operands are supported."; - r_valid = false; - return; - } -#endif - *r_ret = a >> b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<R>::change(r_ret); - *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) >> *VariantGetInternalPtr<B>::get_ptr(right); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<R>::encode(PtrToArg<A>::convert(left) >> PtrToArg<B>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } -}; - -template <class R, class A, class B> -class OperatorEvaluatorBitOr { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - *r_ret = a | b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<R>::change(r_ret); - *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) | *VariantGetInternalPtr<B>::get_ptr(right); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<R>::encode(PtrToArg<A>::convert(left) | PtrToArg<B>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } -}; - -template <class R, class A, class B> -class OperatorEvaluatorBitAnd { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - *r_ret = a & b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<R>::change(r_ret); - *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) & *VariantGetInternalPtr<B>::get_ptr(right); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<R>::encode(PtrToArg<A>::convert(left) & PtrToArg<B>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } -}; - -template <class R, class A, class B> -class OperatorEvaluatorBitXor { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - *r_ret = a ^ b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<R>::change(r_ret); - *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) ^ *VariantGetInternalPtr<B>::get_ptr(right); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<R>::encode(PtrToArg<A>::convert(left) ^ PtrToArg<B>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } -}; - -template <class R, class A> -class OperatorEvaluatorBitNeg { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - *r_ret = ~a; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<R>::change(r_ret); - *VariantGetInternalPtr<R>::get_ptr(r_ret) = ~*VariantGetInternalPtr<A>::get_ptr(left); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<R>::encode(~PtrToArg<A>::convert(left), r_ret); - } - static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } -}; - -template <class A, class B> -class OperatorEvaluatorEqual { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - *r_ret = a == b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) == *VariantGetInternalPtr<B>::get_ptr(right); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(PtrToArg<A>::convert(left) == PtrToArg<B>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -class OperatorEvaluatorEqualObject { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const Object *a = p_left.get_validated_object(); - const Object *b = p_right.get_validated_object(); - *r_ret = a == b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - const Object *a = left->get_validated_object(); - const Object *b = right->get_validated_object(); - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = a == b; - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(PtrToArg<Object *>::convert(left) == PtrToArg<Object *>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -class OperatorEvaluatorEqualObjectNil { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const Object *a = p_left.get_validated_object(); - *r_ret = a == nullptr; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - const Object *a = left->get_validated_object(); - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = a == nullptr; - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(PtrToArg<Object *>::convert(left) == nullptr, r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -class OperatorEvaluatorEqualNilObject { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const Object *b = p_right.get_validated_object(); - *r_ret = nullptr == b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - const Object *b = right->get_validated_object(); - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = nullptr == b; - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(nullptr == PtrToArg<Object *>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -template <class A, class B> -class OperatorEvaluatorNotEqual { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - *r_ret = a != b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) != *VariantGetInternalPtr<B>::get_ptr(right); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(PtrToArg<A>::convert(left) != PtrToArg<B>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -class OperatorEvaluatorNotEqualObject { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - Object *a = p_left.get_validated_object(); - Object *b = p_right.get_validated_object(); - *r_ret = a != b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - Object *a = left->get_validated_object(); - Object *b = right->get_validated_object(); - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = a != b; - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(PtrToArg<Object *>::convert(left) != PtrToArg<Object *>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -class OperatorEvaluatorNotEqualObjectNil { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - Object *a = p_left.get_validated_object(); - *r_ret = a != nullptr; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - Object *a = left->get_validated_object(); - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = a != nullptr; - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(PtrToArg<Object *>::convert(left) != nullptr, r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -class OperatorEvaluatorNotEqualNilObject { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - Object *b = p_right.get_validated_object(); - *r_ret = nullptr != b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - Object *b = right->get_validated_object(); - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = nullptr != b; - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(nullptr != PtrToArg<Object *>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -template <class A, class B> -class OperatorEvaluatorLess { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - *r_ret = a < b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) < *VariantGetInternalPtr<B>::get_ptr(right); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(PtrToArg<A>::convert(left) < PtrToArg<B>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -template <class A, class B> -class OperatorEvaluatorLessEqual { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - *r_ret = a <= b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) <= *VariantGetInternalPtr<B>::get_ptr(right); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(PtrToArg<A>::convert(left) <= PtrToArg<B>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -template <class A, class B> -class OperatorEvaluatorGreater { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - *r_ret = a > b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) > *VariantGetInternalPtr<B>::get_ptr(right); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(PtrToArg<A>::convert(left) > PtrToArg<B>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -template <class A, class B> -class OperatorEvaluatorGreaterEqual { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - *r_ret = a >= b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) >= *VariantGetInternalPtr<B>::get_ptr(right); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(PtrToArg<A>::convert(left) >= PtrToArg<B>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -template <class A, class B> -class OperatorEvaluatorAnd { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - *r_ret = a && b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) && *VariantGetInternalPtr<B>::get_ptr(right); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(PtrToArg<A>::convert(left) && PtrToArg<B>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -template <class A, class B> -class OperatorEvaluatorOr { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - *r_ret = a || b; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) || *VariantGetInternalPtr<B>::get_ptr(right); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(PtrToArg<A>::convert(left) || PtrToArg<B>::convert(right), r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -#define XOR_OP(m_a, m_b) (((m_a) || (m_b)) && !((m_a) && (m_b))) -template <class A, class B> -class OperatorEvaluatorXor { -public: - _FORCE_INLINE_ static bool xor_op(const A &a, const B &b) { - return ((a) || (b)) && !((a) && (b)); - } - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - *r_ret = xor_op(a, b); - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = xor_op(*VariantGetInternalPtr<A>::get_ptr(left), *VariantGetInternalPtr<B>::get_ptr(right)); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(xor_op(PtrToArg<A>::convert(left), PtrToArg<B>::convert(right)), r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -template <class A> -class OperatorEvaluatorNot { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - *r_ret = !a; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = !*VariantGetInternalPtr<A>::get_ptr(left); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(!PtrToArg<A>::convert(left)); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -//// CUSTOM //// - -class OperatorEvaluatorAddArray { -public: - _FORCE_INLINE_ static void _add_arrays(Array &sum, const Array &array_a, const Array &array_b) { - int asize = array_a.size(); - int bsize = array_b.size(); - sum.resize(asize + bsize); - for (int i = 0; i < asize; i++) { - sum[i] = array_a[i]; - } - for (int i = 0; i < bsize; i++) { - sum[i + asize] = array_b[i]; - } - } - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const Array &array_a = *VariantGetInternalPtr<Array>::get_ptr(&p_left); - const Array &array_b = *VariantGetInternalPtr<Array>::get_ptr(&p_right); - Array sum; - _add_arrays(sum, array_a, array_b); - *r_ret = sum; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<Array>::change(r_ret); - _add_arrays(*VariantGetInternalPtr<Array>::get_ptr(r_ret), *VariantGetInternalPtr<Array>::get_ptr(left), *VariantGetInternalPtr<Array>::get_ptr(right)); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - Array ret; - _add_arrays(ret, PtrToArg<Array>::convert(left), PtrToArg<Array>::convert(right)); - PtrToArg<Array>::encode(ret, r_ret); - } - static Variant::Type get_return_type() { return Variant::ARRAY; } -}; - -template <class T> -class OperatorEvaluatorAppendArray { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const Vector<T> &array_a = *VariantGetInternalPtr<Vector<T>>::get_ptr(&p_left); - const Vector<T> &array_b = *VariantGetInternalPtr<Vector<T>>::get_ptr(&p_right); - Vector<T> sum = array_a; - sum.append_array(array_b); - *r_ret = sum; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<Vector<T>>::change(r_ret); - *VariantGetInternalPtr<Vector<T>>::get_ptr(r_ret) = *VariantGetInternalPtr<Vector<T>>::get_ptr(left); - VariantGetInternalPtr<Vector<T>>::get_ptr(r_ret)->append_array(*VariantGetInternalPtr<Vector<T>>::get_ptr(right)); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - Vector<T> sum = PtrToArg<Vector<T>>::convert(left); - sum.append_array(PtrToArg<Vector<T>>::convert(right)); - PtrToArg<Vector<T>>::encode(sum, r_ret); - } - static Variant::Type get_return_type() { return GetTypeInfo<Vector<T>>::VARIANT_TYPE; } -}; - -class OperatorEvaluatorStringModNil { -public: - _FORCE_INLINE_ static String do_mod(const String &s, bool *r_valid) { - Array values; - values.push_back(Variant()); - - String a = s.sprintf(values, r_valid); - if (r_valid) { - *r_valid = !*r_valid; - } - return a; - } - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left); - *r_ret = do_mod(a, &r_valid); - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<String>::change(r_ret); - *VariantGetInternalPtr<String>::get_ptr(r_ret) = do_mod(*VariantGetInternalPtr<String>::get_ptr(left), nullptr); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<String>::encode(do_mod(PtrToArg<String>::convert(left), nullptr), r_ret); - } - static Variant::Type get_return_type() { return Variant::STRING; } -}; - -class OperatorEvaluatorStringModArray { -public: - _FORCE_INLINE_ static String do_mod(const String &s, const Array &p_values, bool *r_valid) { - String a = s.sprintf(p_values, r_valid); - if (r_valid) { - *r_valid = !*r_valid; - } - return a; - } - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left); - *r_ret = do_mod(a, *VariantGetInternalPtr<Array>::get_ptr(&p_right), &r_valid); - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<String>::change(r_ret); - *VariantGetInternalPtr<String>::get_ptr(r_ret) = do_mod(*VariantGetInternalPtr<String>::get_ptr(left), *VariantGetInternalPtr<Array>::get_ptr(right), nullptr); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<String>::encode(do_mod(PtrToArg<String>::convert(left), PtrToArg<Array>::convert(right), nullptr), r_ret); - } - static Variant::Type get_return_type() { return Variant::STRING; } -}; - -class OperatorEvaluatorStringModObject { -public: - _FORCE_INLINE_ static String do_mod(const String &s, const Object *p_object, bool *r_valid) { - Array values; - values.push_back(p_object); - String a = s.sprintf(values, r_valid); - if (r_valid) { - *r_valid = !*r_valid; - } - - return a; - } - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left); - *r_ret = do_mod(a, p_right.get_validated_object(), &r_valid); - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<String>::change(r_ret); - *VariantGetInternalPtr<String>::get_ptr(r_ret) = do_mod(*VariantGetInternalPtr<String>::get_ptr(left), right->get_validated_object(), nullptr); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<String>::encode(do_mod(PtrToArg<String>::convert(left), PtrToArg<Object *>::convert(right), nullptr), r_ret); - } - static Variant::Type get_return_type() { return Variant::STRING; } -}; - -template <class T> -class OperatorEvaluatorStringModT { -public: - _FORCE_INLINE_ static String do_mod(const String &s, const T &p_value, bool *r_valid) { - Array values; - values.push_back(p_value); - String a = s.sprintf(values, r_valid); - if (r_valid) { - *r_valid = !*r_valid; - } - return a; - } - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left); - *r_ret = do_mod(a, *VariantGetInternalPtr<T>::get_ptr(&p_right), &r_valid); - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<String>::change(r_ret); - *VariantGetInternalPtr<String>::get_ptr(r_ret) = do_mod(*VariantGetInternalPtr<String>::get_ptr(left), *VariantGetInternalPtr<T>::get_ptr(right), nullptr); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<String>::encode(do_mod(PtrToArg<String>::convert(left), PtrToArg<T>::convert(right), nullptr), r_ret); - } - static Variant::Type get_return_type() { return Variant::STRING; } -}; - -template <Variant::Operator op, Variant::Type type_left, Variant::Type type_right> -class OperatorEvaluatorAlwaysTrue { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - *r_ret = true; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = true; - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(true, r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -template <Variant::Operator op, Variant::Type type_left, Variant::Type type_right> -class OperatorEvaluatorAlwaysFalse { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - *r_ret = false; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = false; - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(false, r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -///// OR /////// - -_FORCE_INLINE_ static bool _operate_or(bool p_left, bool p_right) { - return p_left || p_right; -} - -_FORCE_INLINE_ static bool _operate_and(bool p_left, bool p_right) { - return p_left && p_right; -} - -_FORCE_INLINE_ static bool _operate_xor(bool p_left, bool p_right) { - return (p_left || p_right) && !(p_left && p_right); -} - -_FORCE_INLINE_ static bool _operate_get_nil(const Variant *p_ptr) { - return p_ptr->get_validated_object() != nullptr; -} - -_FORCE_INLINE_ static bool _operate_get_bool(const Variant *p_ptr) { - return *VariantGetInternalPtr<bool>::get_ptr(p_ptr); -} - -_FORCE_INLINE_ static bool _operate_get_int(const Variant *p_ptr) { - return *VariantGetInternalPtr<int64_t>::get_ptr(p_ptr) != 0; -} - -_FORCE_INLINE_ static bool _operate_get_float(const Variant *p_ptr) { - return *VariantGetInternalPtr<double>::get_ptr(p_ptr) != 0.0; -} - -_FORCE_INLINE_ static bool _operate_get_object(const Variant *p_ptr) { - return p_ptr->get_validated_object() != nullptr; -} - -_FORCE_INLINE_ static bool _operate_get_ptr_nil(const void *p_ptr) { - return false; -} - -_FORCE_INLINE_ static bool _operate_get_ptr_bool(const void *p_ptr) { - return PtrToArg<bool>::convert(p_ptr); -} - -_FORCE_INLINE_ static bool _operate_get_ptr_int(const void *p_ptr) { - return PtrToArg<int64_t>::convert(p_ptr) != 0; -} - -_FORCE_INLINE_ static bool _operate_get_ptr_float(const void *p_ptr) { - return PtrToArg<double>::convert(p_ptr) != 0.0; -} - -_FORCE_INLINE_ static bool _operate_get_ptr_object(const void *p_ptr) { - return PtrToArg<Object *>::convert(p_ptr) != nullptr; -} - -#define OP_EVALUATOR(m_class_name, m_left, m_right, m_op) \ - class m_class_name { \ - public: \ - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { \ - *r_ret = m_op(_operate_get_##m_left(&p_left), _operate_get_##m_right(&p_right)); \ - r_valid = true; \ - } \ - \ - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { \ - VariantTypeChanger<bool>::change(r_ret); \ - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = m_op(_operate_get_##m_left(left), _operate_get_##m_right(right)); \ - } \ - \ - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { \ - PtrToArg<bool>::encode(m_op(_operate_get_ptr_##m_left(left), _operate_get_ptr_##m_right(right)), r_ret); \ - } \ - \ - static Variant::Type get_return_type() { \ - return Variant::BOOL; \ - } \ - }; - -// OR - -// nil -OP_EVALUATOR(OperatorEvaluatorNilXBoolOr, nil, bool, _operate_or) -OP_EVALUATOR(OperatorEvaluatorBoolXNilOr, bool, nil, _operate_or) - -OP_EVALUATOR(OperatorEvaluatorNilXIntOr, nil, int, _operate_or) -OP_EVALUATOR(OperatorEvaluatorIntXNilOr, int, nil, _operate_or) - -OP_EVALUATOR(OperatorEvaluatorNilXFloatOr, nil, float, _operate_or) -OP_EVALUATOR(OperatorEvaluatorFloatXNilOr, float, nil, _operate_or) - -OP_EVALUATOR(OperatorEvaluatorObjectXNilOr, object, nil, _operate_or) -OP_EVALUATOR(OperatorEvaluatorNilXObjectOr, nil, object, _operate_or) - -// bool -OP_EVALUATOR(OperatorEvaluatorBoolXBoolOr, bool, bool, _operate_or) - -OP_EVALUATOR(OperatorEvaluatorBoolXIntOr, bool, int, _operate_or) -OP_EVALUATOR(OperatorEvaluatorIntXBoolOr, int, bool, _operate_or) - -OP_EVALUATOR(OperatorEvaluatorBoolXFloatOr, bool, float, _operate_or) -OP_EVALUATOR(OperatorEvaluatorFloatXBoolOr, float, bool, _operate_or) - -OP_EVALUATOR(OperatorEvaluatorBoolXObjectOr, bool, object, _operate_or) -OP_EVALUATOR(OperatorEvaluatorObjectXBoolOr, object, bool, _operate_or) - -// int -OP_EVALUATOR(OperatorEvaluatorIntXIntOr, int, int, _operate_or) - -OP_EVALUATOR(OperatorEvaluatorIntXFloatOr, int, float, _operate_or) -OP_EVALUATOR(OperatorEvaluatorFloatXIntOr, float, int, _operate_or) - -OP_EVALUATOR(OperatorEvaluatorIntXObjectOr, int, object, _operate_or) -OP_EVALUATOR(OperatorEvaluatorObjectXIntOr, object, int, _operate_or) - -// float -OP_EVALUATOR(OperatorEvaluatorFloatXFloatOr, float, float, _operate_or) - -OP_EVALUATOR(OperatorEvaluatorFloatXObjectOr, float, object, _operate_or) -OP_EVALUATOR(OperatorEvaluatorObjectXFloatOr, object, float, _operate_or) - -// object -OP_EVALUATOR(OperatorEvaluatorObjectXObjectOr, object, object, _operate_or) - -// AND - -// nil -OP_EVALUATOR(OperatorEvaluatorNilXBoolAnd, nil, bool, _operate_and) -OP_EVALUATOR(OperatorEvaluatorBoolXNilAnd, bool, nil, _operate_and) - -OP_EVALUATOR(OperatorEvaluatorNilXIntAnd, nil, int, _operate_and) -OP_EVALUATOR(OperatorEvaluatorIntXNilAnd, int, nil, _operate_and) - -OP_EVALUATOR(OperatorEvaluatorNilXFloatAnd, nil, float, _operate_and) -OP_EVALUATOR(OperatorEvaluatorFloatXNilAnd, float, nil, _operate_and) - -OP_EVALUATOR(OperatorEvaluatorObjectXNilAnd, object, nil, _operate_and) -OP_EVALUATOR(OperatorEvaluatorNilXObjectAnd, nil, object, _operate_and) - -// bool -OP_EVALUATOR(OperatorEvaluatorBoolXBoolAnd, bool, bool, _operate_and) - -OP_EVALUATOR(OperatorEvaluatorBoolXIntAnd, bool, int, _operate_and) -OP_EVALUATOR(OperatorEvaluatorIntXBoolAnd, int, bool, _operate_and) - -OP_EVALUATOR(OperatorEvaluatorBoolXFloatAnd, bool, float, _operate_and) -OP_EVALUATOR(OperatorEvaluatorFloatXBoolAnd, float, bool, _operate_and) - -OP_EVALUATOR(OperatorEvaluatorBoolXObjectAnd, bool, object, _operate_and) -OP_EVALUATOR(OperatorEvaluatorObjectXBoolAnd, object, bool, _operate_and) - -// int -OP_EVALUATOR(OperatorEvaluatorIntXIntAnd, int, int, _operate_and) - -OP_EVALUATOR(OperatorEvaluatorIntXFloatAnd, int, float, _operate_and) -OP_EVALUATOR(OperatorEvaluatorFloatXIntAnd, float, int, _operate_and) - -OP_EVALUATOR(OperatorEvaluatorIntXObjectAnd, int, object, _operate_and) -OP_EVALUATOR(OperatorEvaluatorObjectXIntAnd, object, int, _operate_and) - -// float -OP_EVALUATOR(OperatorEvaluatorFloatXFloatAnd, float, float, _operate_and) - -OP_EVALUATOR(OperatorEvaluatorFloatXObjectAnd, float, object, _operate_and) -OP_EVALUATOR(OperatorEvaluatorObjectXFloatAnd, object, float, _operate_and) - -// object -OP_EVALUATOR(OperatorEvaluatorObjectXObjectAnd, object, object, _operate_and) - -// XOR - -// nil -OP_EVALUATOR(OperatorEvaluatorNilXBoolXor, nil, bool, _operate_xor) -OP_EVALUATOR(OperatorEvaluatorBoolXNilXor, bool, nil, _operate_xor) - -OP_EVALUATOR(OperatorEvaluatorNilXIntXor, nil, int, _operate_xor) -OP_EVALUATOR(OperatorEvaluatorIntXNilXor, int, nil, _operate_xor) - -OP_EVALUATOR(OperatorEvaluatorNilXFloatXor, nil, float, _operate_xor) -OP_EVALUATOR(OperatorEvaluatorFloatXNilXor, float, nil, _operate_xor) - -OP_EVALUATOR(OperatorEvaluatorObjectXNilXor, object, nil, _operate_xor) -OP_EVALUATOR(OperatorEvaluatorNilXObjectXor, nil, object, _operate_xor) - -// bool -OP_EVALUATOR(OperatorEvaluatorBoolXBoolXor, bool, bool, _operate_xor) - -OP_EVALUATOR(OperatorEvaluatorBoolXIntXor, bool, int, _operate_xor) -OP_EVALUATOR(OperatorEvaluatorIntXBoolXor, int, bool, _operate_xor) - -OP_EVALUATOR(OperatorEvaluatorBoolXFloatXor, bool, float, _operate_xor) -OP_EVALUATOR(OperatorEvaluatorFloatXBoolXor, float, bool, _operate_xor) - -OP_EVALUATOR(OperatorEvaluatorBoolXObjectXor, bool, object, _operate_xor) -OP_EVALUATOR(OperatorEvaluatorObjectXBoolXor, object, bool, _operate_xor) - -// int -OP_EVALUATOR(OperatorEvaluatorIntXIntXor, int, int, _operate_xor) - -OP_EVALUATOR(OperatorEvaluatorIntXFloatXor, int, float, _operate_xor) -OP_EVALUATOR(OperatorEvaluatorFloatXIntXor, float, int, _operate_xor) - -OP_EVALUATOR(OperatorEvaluatorIntXObjectXor, int, object, _operate_xor) -OP_EVALUATOR(OperatorEvaluatorObjectXIntXor, object, int, _operate_xor) - -// float -OP_EVALUATOR(OperatorEvaluatorFloatXFloatXor, float, float, _operate_xor) - -OP_EVALUATOR(OperatorEvaluatorFloatXObjectXor, float, object, _operate_xor) -OP_EVALUATOR(OperatorEvaluatorObjectXFloatXor, object, float, _operate_xor) - -// object -OP_EVALUATOR(OperatorEvaluatorObjectXObjectXor, object, object, _operate_xor) - -class OperatorEvaluatorNotBool { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - *r_ret = !*VariantGetInternalPtr<bool>::get_ptr(&p_left); - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = !*VariantGetInternalPtr<bool>::get_ptr(left); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(!PtrToArg<bool>::convert(left), r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -class OperatorEvaluatorNotInt { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - *r_ret = !*VariantGetInternalPtr<int64_t>::get_ptr(&p_left); - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = !*VariantGetInternalPtr<int64_t>::get_ptr(left); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(!PtrToArg<int64_t>::convert(left), r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -class OperatorEvaluatorNotFloat { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - *r_ret = !*VariantGetInternalPtr<double>::get_ptr(&p_left); - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = !*VariantGetInternalPtr<double>::get_ptr(left); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(!PtrToArg<double>::convert(left), r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -class OperatorEvaluatorNotObject { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - *r_ret = p_left.get_validated_object() == nullptr; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = left->get_validated_object() == nullptr; - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(PtrToArg<Object *>::convert(left) == nullptr, r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -//// - -class OperatorEvaluatorInStringFind { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const String &str_a = *VariantGetInternalPtr<String>::get_ptr(&p_left); - const String &str_b = *VariantGetInternalPtr<String>::get_ptr(&p_right); - - *r_ret = str_b.find(str_a) != -1; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - const String &str_a = *VariantGetInternalPtr<String>::get_ptr(left); - const String &str_b = *VariantGetInternalPtr<String>::get_ptr(right); - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = str_b.find(str_a) != -1; - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(PtrToArg<String>::convert(right).find(PtrToArg<String>::convert(left)) != -1, r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -template <class A, class B> -class OperatorEvaluatorInArrayFind { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); - - *r_ret = b.find(a) != -1; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - const A &a = *VariantGetInternalPtr<A>::get_ptr(left); - const B &b = *VariantGetInternalPtr<B>::get_ptr(right); - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.find(a) != -1; - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(PtrToArg<B>::convert(right).find(PtrToArg<A>::convert(left)) != -1, r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -class OperatorEvaluatorInArrayFindNil { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const Array &b = *VariantGetInternalPtr<Array>::get_ptr(&p_right); - *r_ret = b.find(Variant()) != -1; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - const Array &b = *VariantGetInternalPtr<Array>::get_ptr(right); - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.find(Variant()) != -1; - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(PtrToArg<Array>::convert(right).find(Variant()) != -1, r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -class OperatorEvaluatorInArrayFindObject { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const Array &b = *VariantGetInternalPtr<Array>::get_ptr(&p_right); - *r_ret = b.find(p_left) != -1; - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - const Array &b = *VariantGetInternalPtr<Array>::get_ptr(right); - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.find(*left) != -1; - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(PtrToArg<Array>::convert(right).find(PtrToArg<Object *>::convert(left)) != -1, r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -template <class A> -class OperatorEvaluatorInDictionaryHas { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(&p_right); - const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); - - *r_ret = b.has(a); - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(right); - const A &a = *VariantGetInternalPtr<A>::get_ptr(left); - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.has(a); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(PtrToArg<Dictionary>::convert(right).has(PtrToArg<A>::convert(left)), r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -class OperatorEvaluatorInDictionaryHasNil { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(&p_right); - - *r_ret = b.has(Variant()); - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(right); - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.has(Variant()); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(PtrToArg<Dictionary>::convert(right).has(Variant()), r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -class OperatorEvaluatorInDictionaryHasObject { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(&p_right); - - *r_ret = b.has(p_left); - r_valid = true; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(right); - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.has(*left); - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - PtrToArg<bool>::encode(PtrToArg<Dictionary>::convert(right).has(PtrToArg<Object *>::convert(left)), r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -class OperatorEvaluatorObjectHasPropertyString { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - Object *b = p_right.get_validated_object(); - if (!b) { - *r_ret = "Invalid base object for 'in'"; - r_valid = false; - return; - } - - const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left); - - b->get(a, &r_valid); - *r_ret = r_valid; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - Object *l = right->get_validated_object(); - ERR_FAIL_COND(l == nullptr); - const String &a = *VariantGetInternalPtr<String>::get_ptr(left); - - bool valid; - l->get(a, &valid); - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = valid; - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - bool valid; - PtrToArg<Object *>::convert(right)->get(PtrToArg<String>::convert(left), &valid); - PtrToArg<bool>::encode(valid, r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; - -class OperatorEvaluatorObjectHasPropertyStringName { -public: - static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { - Object *b = p_right.get_validated_object(); - if (!b) { - *r_ret = "Invalid base object for 'in'"; - r_valid = false; - return; - } - - const StringName &a = *VariantGetInternalPtr<StringName>::get_ptr(&p_left); - - b->get(a, &r_valid); - *r_ret = r_valid; - } - static void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { - Object *l = right->get_validated_object(); - ERR_FAIL_COND(l == nullptr); - const StringName &a = *VariantGetInternalPtr<StringName>::get_ptr(left); - - bool valid; - l->get(a, &valid); - VariantTypeChanger<bool>::change(r_ret); - *VariantGetInternalPtr<bool>::get_ptr(r_ret) = valid; - } - static void ptr_evaluate(const void *left, const void *right, void *r_ret) { - bool valid; - PtrToArg<Object *>::convert(right)->get(PtrToArg<StringName>::convert(left), &valid); - PtrToArg<bool>::encode(valid, r_ret); - } - static Variant::Type get_return_type() { return Variant::BOOL; } -}; +#include "variant_op.h" typedef void (*VariantEvaluatorFunction)(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid); @@ -1458,6 +123,8 @@ void Variant::_register_variant_operators() { register_op<OperatorEvaluatorMul<Color, Color, double>>(Variant::OP_MULTIPLY, Variant::COLOR, Variant::FLOAT); register_op<OperatorEvaluatorMul<Transform2D, Transform2D, Transform2D>>(Variant::OP_MULTIPLY, Variant::TRANSFORM2D, Variant::TRANSFORM2D); + register_op<OperatorEvaluatorMul<Transform2D, Transform2D, int64_t>>(Variant::OP_MULTIPLY, Variant::TRANSFORM2D, Variant::INT); + register_op<OperatorEvaluatorMul<Transform2D, Transform2D, double>>(Variant::OP_MULTIPLY, Variant::TRANSFORM2D, Variant::FLOAT); register_op<OperatorEvaluatorXForm<Vector2, Transform2D, Vector2>>(Variant::OP_MULTIPLY, Variant::TRANSFORM2D, Variant::VECTOR2); register_op<OperatorEvaluatorXFormInv<Vector2, Vector2, Transform2D>>(Variant::OP_MULTIPLY, Variant::VECTOR2, Variant::TRANSFORM2D); register_op<OperatorEvaluatorXForm<Rect2, Transform2D, Rect2>>(Variant::OP_MULTIPLY, Variant::TRANSFORM2D, Variant::RECT2); @@ -1466,6 +133,8 @@ void Variant::_register_variant_operators() { register_op<OperatorEvaluatorXFormInv<Vector<Vector2>, Vector<Vector2>, Transform2D>>(Variant::OP_MULTIPLY, Variant::PACKED_VECTOR2_ARRAY, Variant::TRANSFORM2D); register_op<OperatorEvaluatorMul<Transform3D, Transform3D, Transform3D>>(Variant::OP_MULTIPLY, Variant::TRANSFORM3D, Variant::TRANSFORM3D); + register_op<OperatorEvaluatorMul<Transform3D, Transform3D, int64_t>>(Variant::OP_MULTIPLY, Variant::TRANSFORM3D, Variant::INT); + register_op<OperatorEvaluatorMul<Transform3D, Transform3D, double>>(Variant::OP_MULTIPLY, Variant::TRANSFORM3D, Variant::FLOAT); register_op<OperatorEvaluatorXForm<Vector3, Transform3D, Vector3>>(Variant::OP_MULTIPLY, Variant::TRANSFORM3D, Variant::VECTOR3); register_op<OperatorEvaluatorXFormInv<Vector3, Vector3, Transform3D>>(Variant::OP_MULTIPLY, Variant::VECTOR3, Variant::TRANSFORM3D); register_op<OperatorEvaluatorXForm<::AABB, Transform3D, ::AABB>>(Variant::OP_MULTIPLY, Variant::TRANSFORM3D, Variant::AABB); @@ -1474,6 +143,8 @@ void Variant::_register_variant_operators() { register_op<OperatorEvaluatorXFormInv<Vector<Vector3>, Vector<Vector3>, Transform3D>>(Variant::OP_MULTIPLY, Variant::PACKED_VECTOR3_ARRAY, Variant::TRANSFORM3D); register_op<OperatorEvaluatorMul<Basis, Basis, Basis>>(Variant::OP_MULTIPLY, Variant::BASIS, Variant::BASIS); + register_op<OperatorEvaluatorMul<Basis, Basis, int64_t>>(Variant::OP_MULTIPLY, Variant::BASIS, Variant::INT); + register_op<OperatorEvaluatorMul<Basis, Basis, double>>(Variant::OP_MULTIPLY, Variant::BASIS, Variant::FLOAT); register_op<OperatorEvaluatorXForm<Vector3, Basis, Vector3>>(Variant::OP_MULTIPLY, Variant::BASIS, Variant::VECTOR3); register_op<OperatorEvaluatorXFormInv<Vector3, Vector3, Basis>>(Variant::OP_MULTIPLY, Variant::VECTOR3, Variant::BASIS); diff --git a/core/variant/variant_op.h b/core/variant/variant_op.h new file mode 100644 index 0000000000..e744e76ea3 --- /dev/null +++ b/core/variant/variant_op.h @@ -0,0 +1,1316 @@ +/*************************************************************************/ +/* variant_op.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef VARIANT_OP_H +#define VARIANT_OP_H + +#include "variant.h" + +#include "core/core_string_names.h" +#include "core/debugger/engine_debugger.h" +#include "core/object/class_db.h" + +template <class R, class A, class B> +class OperatorEvaluatorAdd { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + *r_ret = a + b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) + *VariantGetInternalPtr<B>::get_ptr(right); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<R>::encode(PtrToArg<A>::convert(left) + PtrToArg<B>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } +}; + +template <class R, class A, class B> +class OperatorEvaluatorSub { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + *r_ret = a - b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) - *VariantGetInternalPtr<B>::get_ptr(right); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<R>::encode(PtrToArg<A>::convert(left) - PtrToArg<B>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } +}; + +template <class R, class A, class B> +class OperatorEvaluatorMul { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + *r_ret = a * b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) * *VariantGetInternalPtr<B>::get_ptr(right); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<R>::encode(PtrToArg<A>::convert(left) * PtrToArg<B>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } +}; + +template <class R, class A, class B> +class OperatorEvaluatorXForm { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + *r_ret = a.xform(b); + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<R>::get_ptr(r_ret) = VariantGetInternalPtr<A>::get_ptr(left)->xform(*VariantGetInternalPtr<B>::get_ptr(right)); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<R>::encode(PtrToArg<A>::convert(left).xform(PtrToArg<B>::convert(right)), r_ret); + } + static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } +}; + +template <class R, class A, class B> +class OperatorEvaluatorXFormInv { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + *r_ret = b.xform_inv(a); + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<R>::get_ptr(r_ret) = VariantGetInternalPtr<B>::get_ptr(right)->xform_inv(*VariantGetInternalPtr<A>::get_ptr(left)); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<R>::encode(PtrToArg<B>::convert(right).xform_inv(PtrToArg<A>::convert(left)), r_ret); + } + static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } +}; + +template <class R, class A, class B> +class OperatorEvaluatorDiv { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + *r_ret = a / b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) / *VariantGetInternalPtr<B>::get_ptr(right); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<R>::encode(PtrToArg<A>::convert(left) / PtrToArg<B>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } +}; + +template <class R, class A, class B> +class OperatorEvaluatorDivNZ { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + if (b == 0) { + r_valid = false; + *r_ret = "Division by zero error"; + return; + } + *r_ret = a / b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) / *VariantGetInternalPtr<B>::get_ptr(right); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<R>::encode(PtrToArg<A>::convert(left) / PtrToArg<B>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } +}; + +template <class R, class A, class B> +class OperatorEvaluatorMod { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + *r_ret = a % b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) % *VariantGetInternalPtr<B>::get_ptr(right); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<R>::encode(PtrToArg<A>::convert(left) % PtrToArg<B>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } +}; + +template <class R, class A, class B> +class OperatorEvaluatorModNZ { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + if (b == 0) { + r_valid = false; + *r_ret = "Module by zero error"; + return; + } + *r_ret = a % b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) % *VariantGetInternalPtr<B>::get_ptr(right); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<R>::encode(PtrToArg<A>::convert(left) % PtrToArg<B>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } +}; + +template <class R, class A> +class OperatorEvaluatorNeg { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + *r_ret = -a; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<R>::get_ptr(r_ret) = -*VariantGetInternalPtr<A>::get_ptr(left); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<R>::encode(-PtrToArg<A>::convert(left), r_ret); + } + static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } +}; + +template <class R, class A> +class OperatorEvaluatorPos { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + *r_ret = a; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<R>::encode(PtrToArg<A>::convert(left), r_ret); + } + static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } +}; + +template <class R, class A, class B> +class OperatorEvaluatorShiftLeft { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + +#if defined(DEBUG_ENABLED) + if (b < 0 || a < 0) { + *r_ret = "Invalid operands for bit shifting. Only positive operands are supported."; + r_valid = false; + return; + } +#endif + *r_ret = a << b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) << *VariantGetInternalPtr<B>::get_ptr(right); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<R>::encode(PtrToArg<A>::convert(left) << PtrToArg<B>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } +}; + +template <class R, class A, class B> +class OperatorEvaluatorShiftRight { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + +#if defined(DEBUG_ENABLED) + if (b < 0 || a < 0) { + *r_ret = "Invalid operands for bit shifting. Only positive operands are supported."; + r_valid = false; + return; + } +#endif + *r_ret = a >> b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) >> *VariantGetInternalPtr<B>::get_ptr(right); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<R>::encode(PtrToArg<A>::convert(left) >> PtrToArg<B>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } +}; + +template <class R, class A, class B> +class OperatorEvaluatorBitOr { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + *r_ret = a | b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) | *VariantGetInternalPtr<B>::get_ptr(right); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<R>::encode(PtrToArg<A>::convert(left) | PtrToArg<B>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } +}; + +template <class R, class A, class B> +class OperatorEvaluatorBitAnd { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + *r_ret = a & b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) & *VariantGetInternalPtr<B>::get_ptr(right); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<R>::encode(PtrToArg<A>::convert(left) & PtrToArg<B>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } +}; + +template <class R, class A, class B> +class OperatorEvaluatorBitXor { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + *r_ret = a ^ b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<R>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) ^ *VariantGetInternalPtr<B>::get_ptr(right); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<R>::encode(PtrToArg<A>::convert(left) ^ PtrToArg<B>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } +}; + +template <class R, class A> +class OperatorEvaluatorBitNeg { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + *r_ret = ~a; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<R>::get_ptr(r_ret) = ~*VariantGetInternalPtr<A>::get_ptr(left); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<R>::encode(~PtrToArg<A>::convert(left), r_ret); + } + static Variant::Type get_return_type() { return GetTypeInfo<R>::VARIANT_TYPE; } +}; + +template <class A, class B> +class OperatorEvaluatorEqual { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + *r_ret = a == b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) == *VariantGetInternalPtr<B>::get_ptr(right); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(PtrToArg<A>::convert(left) == PtrToArg<B>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +class OperatorEvaluatorEqualObject { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const Object *a = p_left.get_validated_object(); + const Object *b = p_right.get_validated_object(); + *r_ret = a == b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + const Object *a = left->get_validated_object(); + const Object *b = right->get_validated_object(); + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = a == b; + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(PtrToArg<Object *>::convert(left) == PtrToArg<Object *>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +class OperatorEvaluatorEqualObjectNil { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const Object *a = p_left.get_validated_object(); + *r_ret = a == nullptr; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + const Object *a = left->get_validated_object(); + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = a == nullptr; + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(PtrToArg<Object *>::convert(left) == nullptr, r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +class OperatorEvaluatorEqualNilObject { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const Object *b = p_right.get_validated_object(); + *r_ret = nullptr == b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + const Object *b = right->get_validated_object(); + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = nullptr == b; + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(nullptr == PtrToArg<Object *>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +template <class A, class B> +class OperatorEvaluatorNotEqual { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + *r_ret = a != b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) != *VariantGetInternalPtr<B>::get_ptr(right); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(PtrToArg<A>::convert(left) != PtrToArg<B>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +class OperatorEvaluatorNotEqualObject { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + Object *a = p_left.get_validated_object(); + Object *b = p_right.get_validated_object(); + *r_ret = a != b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + Object *a = left->get_validated_object(); + Object *b = right->get_validated_object(); + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = a != b; + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(PtrToArg<Object *>::convert(left) != PtrToArg<Object *>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +class OperatorEvaluatorNotEqualObjectNil { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + Object *a = p_left.get_validated_object(); + *r_ret = a != nullptr; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + Object *a = left->get_validated_object(); + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = a != nullptr; + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(PtrToArg<Object *>::convert(left) != nullptr, r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +class OperatorEvaluatorNotEqualNilObject { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + Object *b = p_right.get_validated_object(); + *r_ret = nullptr != b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + Object *b = right->get_validated_object(); + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = nullptr != b; + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(nullptr != PtrToArg<Object *>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +template <class A, class B> +class OperatorEvaluatorLess { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + *r_ret = a < b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) < *VariantGetInternalPtr<B>::get_ptr(right); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(PtrToArg<A>::convert(left) < PtrToArg<B>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +template <class A, class B> +class OperatorEvaluatorLessEqual { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + *r_ret = a <= b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) <= *VariantGetInternalPtr<B>::get_ptr(right); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(PtrToArg<A>::convert(left) <= PtrToArg<B>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +template <class A, class B> +class OperatorEvaluatorGreater { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + *r_ret = a > b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) > *VariantGetInternalPtr<B>::get_ptr(right); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(PtrToArg<A>::convert(left) > PtrToArg<B>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +template <class A, class B> +class OperatorEvaluatorGreaterEqual { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + *r_ret = a >= b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) >= *VariantGetInternalPtr<B>::get_ptr(right); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(PtrToArg<A>::convert(left) >= PtrToArg<B>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +template <class A, class B> +class OperatorEvaluatorAnd { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + *r_ret = a && b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) && *VariantGetInternalPtr<B>::get_ptr(right); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(PtrToArg<A>::convert(left) && PtrToArg<B>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +template <class A, class B> +class OperatorEvaluatorOr { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + *r_ret = a || b; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = *VariantGetInternalPtr<A>::get_ptr(left) || *VariantGetInternalPtr<B>::get_ptr(right); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(PtrToArg<A>::convert(left) || PtrToArg<B>::convert(right), r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +#define XOR_OP(m_a, m_b) (((m_a) || (m_b)) && !((m_a) && (m_b))) +template <class A, class B> +class OperatorEvaluatorXor { +public: + _FORCE_INLINE_ static bool xor_op(const A &a, const B &b) { + return ((a) || (b)) && !((a) && (b)); + } + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + *r_ret = xor_op(a, b); + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = xor_op(*VariantGetInternalPtr<A>::get_ptr(left), *VariantGetInternalPtr<B>::get_ptr(right)); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(xor_op(PtrToArg<A>::convert(left), PtrToArg<B>::convert(right)), r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +template <class A> +class OperatorEvaluatorNot { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + *r_ret = !a; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = !*VariantGetInternalPtr<A>::get_ptr(left); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(!PtrToArg<A>::convert(left)); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +//// CUSTOM //// + +class OperatorEvaluatorAddArray { +public: + _FORCE_INLINE_ static void _add_arrays(Array &sum, const Array &array_a, const Array &array_b) { + int asize = array_a.size(); + int bsize = array_b.size(); + sum.resize(asize + bsize); + for (int i = 0; i < asize; i++) { + sum[i] = array_a[i]; + } + for (int i = 0; i < bsize; i++) { + sum[i + asize] = array_b[i]; + } + } + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const Array &array_a = *VariantGetInternalPtr<Array>::get_ptr(&p_left); + const Array &array_b = *VariantGetInternalPtr<Array>::get_ptr(&p_right); + Array sum; + _add_arrays(sum, array_a, array_b); + *r_ret = sum; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + _add_arrays(*VariantGetInternalPtr<Array>::get_ptr(r_ret), *VariantGetInternalPtr<Array>::get_ptr(left), *VariantGetInternalPtr<Array>::get_ptr(right)); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + Array ret; + _add_arrays(ret, PtrToArg<Array>::convert(left), PtrToArg<Array>::convert(right)); + PtrToArg<Array>::encode(ret, r_ret); + } + static Variant::Type get_return_type() { return Variant::ARRAY; } +}; + +template <class T> +class OperatorEvaluatorAppendArray { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const Vector<T> &array_a = *VariantGetInternalPtr<Vector<T>>::get_ptr(&p_left); + const Vector<T> &array_b = *VariantGetInternalPtr<Vector<T>>::get_ptr(&p_right); + Vector<T> sum = array_a; + sum.append_array(array_b); + *r_ret = sum; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<Vector<T>>::get_ptr(r_ret) = *VariantGetInternalPtr<Vector<T>>::get_ptr(left); + VariantGetInternalPtr<Vector<T>>::get_ptr(r_ret)->append_array(*VariantGetInternalPtr<Vector<T>>::get_ptr(right)); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + Vector<T> sum = PtrToArg<Vector<T>>::convert(left); + sum.append_array(PtrToArg<Vector<T>>::convert(right)); + PtrToArg<Vector<T>>::encode(sum, r_ret); + } + static Variant::Type get_return_type() { return GetTypeInfo<Vector<T>>::VARIANT_TYPE; } +}; + +class OperatorEvaluatorStringModNil { +public: + _FORCE_INLINE_ static String do_mod(const String &s, bool *r_valid) { + Array values; + values.push_back(Variant()); + + String a = s.sprintf(values, r_valid); + if (r_valid) { + *r_valid = !*r_valid; + } + return a; + } + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left); + *r_ret = do_mod(a, &r_valid); + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<String>::get_ptr(r_ret) = do_mod(*VariantGetInternalPtr<String>::get_ptr(left), nullptr); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<String>::encode(do_mod(PtrToArg<String>::convert(left), nullptr), r_ret); + } + static Variant::Type get_return_type() { return Variant::STRING; } +}; + +class OperatorEvaluatorStringModArray { +public: + _FORCE_INLINE_ static String do_mod(const String &s, const Array &p_values, bool *r_valid) { + String a = s.sprintf(p_values, r_valid); + if (r_valid) { + *r_valid = !*r_valid; + } + return a; + } + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left); + *r_ret = do_mod(a, *VariantGetInternalPtr<Array>::get_ptr(&p_right), &r_valid); + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<String>::get_ptr(r_ret) = do_mod(*VariantGetInternalPtr<String>::get_ptr(left), *VariantGetInternalPtr<Array>::get_ptr(right), nullptr); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<String>::encode(do_mod(PtrToArg<String>::convert(left), PtrToArg<Array>::convert(right), nullptr), r_ret); + } + static Variant::Type get_return_type() { return Variant::STRING; } +}; + +class OperatorEvaluatorStringModObject { +public: + _FORCE_INLINE_ static String do_mod(const String &s, const Object *p_object, bool *r_valid) { + Array values; + values.push_back(p_object); + String a = s.sprintf(values, r_valid); + if (r_valid) { + *r_valid = !*r_valid; + } + + return a; + } + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left); + *r_ret = do_mod(a, p_right.get_validated_object(), &r_valid); + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<String>::get_ptr(r_ret) = do_mod(*VariantGetInternalPtr<String>::get_ptr(left), right->get_validated_object(), nullptr); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<String>::encode(do_mod(PtrToArg<String>::convert(left), PtrToArg<Object *>::convert(right), nullptr), r_ret); + } + static Variant::Type get_return_type() { return Variant::STRING; } +}; + +template <class T> +class OperatorEvaluatorStringModT { +public: + _FORCE_INLINE_ static String do_mod(const String &s, const T &p_value, bool *r_valid) { + Array values; + values.push_back(p_value); + String a = s.sprintf(values, r_valid); + if (r_valid) { + *r_valid = !*r_valid; + } + return a; + } + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left); + *r_ret = do_mod(a, *VariantGetInternalPtr<T>::get_ptr(&p_right), &r_valid); + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<String>::get_ptr(r_ret) = do_mod(*VariantGetInternalPtr<String>::get_ptr(left), *VariantGetInternalPtr<T>::get_ptr(right), nullptr); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<String>::encode(do_mod(PtrToArg<String>::convert(left), PtrToArg<T>::convert(right), nullptr), r_ret); + } + static Variant::Type get_return_type() { return Variant::STRING; } +}; + +template <Variant::Operator op, Variant::Type type_left, Variant::Type type_right> +class OperatorEvaluatorAlwaysTrue { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + *r_ret = true; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = true; + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(true, r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +template <Variant::Operator op, Variant::Type type_left, Variant::Type type_right> +class OperatorEvaluatorAlwaysFalse { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + *r_ret = false; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = false; + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(false, r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +///// OR /////// + +_FORCE_INLINE_ static bool _operate_or(bool p_left, bool p_right) { + return p_left || p_right; +} + +_FORCE_INLINE_ static bool _operate_and(bool p_left, bool p_right) { + return p_left && p_right; +} + +_FORCE_INLINE_ static bool _operate_xor(bool p_left, bool p_right) { + return (p_left || p_right) && !(p_left && p_right); +} + +_FORCE_INLINE_ static bool _operate_get_nil(const Variant *p_ptr) { + return p_ptr->get_validated_object() != nullptr; +} + +_FORCE_INLINE_ static bool _operate_get_bool(const Variant *p_ptr) { + return *VariantGetInternalPtr<bool>::get_ptr(p_ptr); +} + +_FORCE_INLINE_ static bool _operate_get_int(const Variant *p_ptr) { + return *VariantGetInternalPtr<int64_t>::get_ptr(p_ptr) != 0; +} + +_FORCE_INLINE_ static bool _operate_get_float(const Variant *p_ptr) { + return *VariantGetInternalPtr<double>::get_ptr(p_ptr) != 0.0; +} + +_FORCE_INLINE_ static bool _operate_get_object(const Variant *p_ptr) { + return p_ptr->get_validated_object() != nullptr; +} + +_FORCE_INLINE_ static bool _operate_get_ptr_nil(const void *p_ptr) { + return false; +} + +_FORCE_INLINE_ static bool _operate_get_ptr_bool(const void *p_ptr) { + return PtrToArg<bool>::convert(p_ptr); +} + +_FORCE_INLINE_ static bool _operate_get_ptr_int(const void *p_ptr) { + return PtrToArg<int64_t>::convert(p_ptr) != 0; +} + +_FORCE_INLINE_ static bool _operate_get_ptr_float(const void *p_ptr) { + return PtrToArg<double>::convert(p_ptr) != 0.0; +} + +_FORCE_INLINE_ static bool _operate_get_ptr_object(const void *p_ptr) { + return PtrToArg<Object *>::convert(p_ptr) != nullptr; +} + +#define OP_EVALUATOR(m_class_name, m_left, m_right, m_op) \ + class m_class_name { \ + public: \ + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { \ + *r_ret = m_op(_operate_get_##m_left(&p_left), _operate_get_##m_right(&p_right)); \ + r_valid = true; \ + } \ + \ + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { \ + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = m_op(_operate_get_##m_left(left), _operate_get_##m_right(right)); \ + } \ + \ + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { \ + PtrToArg<bool>::encode(m_op(_operate_get_ptr_##m_left(left), _operate_get_ptr_##m_right(right)), r_ret); \ + } \ + \ + static Variant::Type get_return_type() { \ + return Variant::BOOL; \ + } \ + }; + +// OR + +// nil +OP_EVALUATOR(OperatorEvaluatorNilXBoolOr, nil, bool, _operate_or) +OP_EVALUATOR(OperatorEvaluatorBoolXNilOr, bool, nil, _operate_or) + +OP_EVALUATOR(OperatorEvaluatorNilXIntOr, nil, int, _operate_or) +OP_EVALUATOR(OperatorEvaluatorIntXNilOr, int, nil, _operate_or) + +OP_EVALUATOR(OperatorEvaluatorNilXFloatOr, nil, float, _operate_or) +OP_EVALUATOR(OperatorEvaluatorFloatXNilOr, float, nil, _operate_or) + +OP_EVALUATOR(OperatorEvaluatorObjectXNilOr, object, nil, _operate_or) +OP_EVALUATOR(OperatorEvaluatorNilXObjectOr, nil, object, _operate_or) + +// bool +OP_EVALUATOR(OperatorEvaluatorBoolXBoolOr, bool, bool, _operate_or) + +OP_EVALUATOR(OperatorEvaluatorBoolXIntOr, bool, int, _operate_or) +OP_EVALUATOR(OperatorEvaluatorIntXBoolOr, int, bool, _operate_or) + +OP_EVALUATOR(OperatorEvaluatorBoolXFloatOr, bool, float, _operate_or) +OP_EVALUATOR(OperatorEvaluatorFloatXBoolOr, float, bool, _operate_or) + +OP_EVALUATOR(OperatorEvaluatorBoolXObjectOr, bool, object, _operate_or) +OP_EVALUATOR(OperatorEvaluatorObjectXBoolOr, object, bool, _operate_or) + +// int +OP_EVALUATOR(OperatorEvaluatorIntXIntOr, int, int, _operate_or) + +OP_EVALUATOR(OperatorEvaluatorIntXFloatOr, int, float, _operate_or) +OP_EVALUATOR(OperatorEvaluatorFloatXIntOr, float, int, _operate_or) + +OP_EVALUATOR(OperatorEvaluatorIntXObjectOr, int, object, _operate_or) +OP_EVALUATOR(OperatorEvaluatorObjectXIntOr, object, int, _operate_or) + +// float +OP_EVALUATOR(OperatorEvaluatorFloatXFloatOr, float, float, _operate_or) + +OP_EVALUATOR(OperatorEvaluatorFloatXObjectOr, float, object, _operate_or) +OP_EVALUATOR(OperatorEvaluatorObjectXFloatOr, object, float, _operate_or) + +// object +OP_EVALUATOR(OperatorEvaluatorObjectXObjectOr, object, object, _operate_or) + +// AND + +// nil +OP_EVALUATOR(OperatorEvaluatorNilXBoolAnd, nil, bool, _operate_and) +OP_EVALUATOR(OperatorEvaluatorBoolXNilAnd, bool, nil, _operate_and) + +OP_EVALUATOR(OperatorEvaluatorNilXIntAnd, nil, int, _operate_and) +OP_EVALUATOR(OperatorEvaluatorIntXNilAnd, int, nil, _operate_and) + +OP_EVALUATOR(OperatorEvaluatorNilXFloatAnd, nil, float, _operate_and) +OP_EVALUATOR(OperatorEvaluatorFloatXNilAnd, float, nil, _operate_and) + +OP_EVALUATOR(OperatorEvaluatorObjectXNilAnd, object, nil, _operate_and) +OP_EVALUATOR(OperatorEvaluatorNilXObjectAnd, nil, object, _operate_and) + +// bool +OP_EVALUATOR(OperatorEvaluatorBoolXBoolAnd, bool, bool, _operate_and) + +OP_EVALUATOR(OperatorEvaluatorBoolXIntAnd, bool, int, _operate_and) +OP_EVALUATOR(OperatorEvaluatorIntXBoolAnd, int, bool, _operate_and) + +OP_EVALUATOR(OperatorEvaluatorBoolXFloatAnd, bool, float, _operate_and) +OP_EVALUATOR(OperatorEvaluatorFloatXBoolAnd, float, bool, _operate_and) + +OP_EVALUATOR(OperatorEvaluatorBoolXObjectAnd, bool, object, _operate_and) +OP_EVALUATOR(OperatorEvaluatorObjectXBoolAnd, object, bool, _operate_and) + +// int +OP_EVALUATOR(OperatorEvaluatorIntXIntAnd, int, int, _operate_and) + +OP_EVALUATOR(OperatorEvaluatorIntXFloatAnd, int, float, _operate_and) +OP_EVALUATOR(OperatorEvaluatorFloatXIntAnd, float, int, _operate_and) + +OP_EVALUATOR(OperatorEvaluatorIntXObjectAnd, int, object, _operate_and) +OP_EVALUATOR(OperatorEvaluatorObjectXIntAnd, object, int, _operate_and) + +// float +OP_EVALUATOR(OperatorEvaluatorFloatXFloatAnd, float, float, _operate_and) + +OP_EVALUATOR(OperatorEvaluatorFloatXObjectAnd, float, object, _operate_and) +OP_EVALUATOR(OperatorEvaluatorObjectXFloatAnd, object, float, _operate_and) + +// object +OP_EVALUATOR(OperatorEvaluatorObjectXObjectAnd, object, object, _operate_and) + +// XOR + +// nil +OP_EVALUATOR(OperatorEvaluatorNilXBoolXor, nil, bool, _operate_xor) +OP_EVALUATOR(OperatorEvaluatorBoolXNilXor, bool, nil, _operate_xor) + +OP_EVALUATOR(OperatorEvaluatorNilXIntXor, nil, int, _operate_xor) +OP_EVALUATOR(OperatorEvaluatorIntXNilXor, int, nil, _operate_xor) + +OP_EVALUATOR(OperatorEvaluatorNilXFloatXor, nil, float, _operate_xor) +OP_EVALUATOR(OperatorEvaluatorFloatXNilXor, float, nil, _operate_xor) + +OP_EVALUATOR(OperatorEvaluatorObjectXNilXor, object, nil, _operate_xor) +OP_EVALUATOR(OperatorEvaluatorNilXObjectXor, nil, object, _operate_xor) + +// bool +OP_EVALUATOR(OperatorEvaluatorBoolXBoolXor, bool, bool, _operate_xor) + +OP_EVALUATOR(OperatorEvaluatorBoolXIntXor, bool, int, _operate_xor) +OP_EVALUATOR(OperatorEvaluatorIntXBoolXor, int, bool, _operate_xor) + +OP_EVALUATOR(OperatorEvaluatorBoolXFloatXor, bool, float, _operate_xor) +OP_EVALUATOR(OperatorEvaluatorFloatXBoolXor, float, bool, _operate_xor) + +OP_EVALUATOR(OperatorEvaluatorBoolXObjectXor, bool, object, _operate_xor) +OP_EVALUATOR(OperatorEvaluatorObjectXBoolXor, object, bool, _operate_xor) + +// int +OP_EVALUATOR(OperatorEvaluatorIntXIntXor, int, int, _operate_xor) + +OP_EVALUATOR(OperatorEvaluatorIntXFloatXor, int, float, _operate_xor) +OP_EVALUATOR(OperatorEvaluatorFloatXIntXor, float, int, _operate_xor) + +OP_EVALUATOR(OperatorEvaluatorIntXObjectXor, int, object, _operate_xor) +OP_EVALUATOR(OperatorEvaluatorObjectXIntXor, object, int, _operate_xor) + +// float +OP_EVALUATOR(OperatorEvaluatorFloatXFloatXor, float, float, _operate_xor) + +OP_EVALUATOR(OperatorEvaluatorFloatXObjectXor, float, object, _operate_xor) +OP_EVALUATOR(OperatorEvaluatorObjectXFloatXor, object, float, _operate_xor) + +// object +OP_EVALUATOR(OperatorEvaluatorObjectXObjectXor, object, object, _operate_xor) + +class OperatorEvaluatorNotBool { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + *r_ret = !*VariantGetInternalPtr<bool>::get_ptr(&p_left); + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = !*VariantGetInternalPtr<bool>::get_ptr(left); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(!PtrToArg<bool>::convert(left), r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +class OperatorEvaluatorNotInt { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + *r_ret = !*VariantGetInternalPtr<int64_t>::get_ptr(&p_left); + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = !*VariantGetInternalPtr<int64_t>::get_ptr(left); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(!PtrToArg<int64_t>::convert(left), r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +class OperatorEvaluatorNotFloat { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + *r_ret = !*VariantGetInternalPtr<double>::get_ptr(&p_left); + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = !*VariantGetInternalPtr<double>::get_ptr(left); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(!PtrToArg<double>::convert(left), r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +class OperatorEvaluatorNotObject { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + *r_ret = p_left.get_validated_object() == nullptr; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = left->get_validated_object() == nullptr; + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(PtrToArg<Object *>::convert(left) == nullptr, r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +//// + +class OperatorEvaluatorInStringFind { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const String &str_a = *VariantGetInternalPtr<String>::get_ptr(&p_left); + const String &str_b = *VariantGetInternalPtr<String>::get_ptr(&p_right); + + *r_ret = str_b.find(str_a) != -1; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + const String &str_a = *VariantGetInternalPtr<String>::get_ptr(left); + const String &str_b = *VariantGetInternalPtr<String>::get_ptr(right); + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = str_b.find(str_a) != -1; + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(PtrToArg<String>::convert(right).find(PtrToArg<String>::convert(left)) != -1, r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +template <class A, class B> +class OperatorEvaluatorInArrayFind { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(&p_right); + + *r_ret = b.find(a) != -1; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + const A &a = *VariantGetInternalPtr<A>::get_ptr(left); + const B &b = *VariantGetInternalPtr<B>::get_ptr(right); + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.find(a) != -1; + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(PtrToArg<B>::convert(right).find(PtrToArg<A>::convert(left)) != -1, r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +class OperatorEvaluatorInArrayFindNil { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const Array &b = *VariantGetInternalPtr<Array>::get_ptr(&p_right); + *r_ret = b.find(Variant()) != -1; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + const Array &b = *VariantGetInternalPtr<Array>::get_ptr(right); + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.find(Variant()) != -1; + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(PtrToArg<Array>::convert(right).find(Variant()) != -1, r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +class OperatorEvaluatorInArrayFindObject { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const Array &b = *VariantGetInternalPtr<Array>::get_ptr(&p_right); + *r_ret = b.find(p_left) != -1; + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + const Array &b = *VariantGetInternalPtr<Array>::get_ptr(right); + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.find(*left) != -1; + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(PtrToArg<Array>::convert(right).find(PtrToArg<Object *>::convert(left)) != -1, r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +template <class A> +class OperatorEvaluatorInDictionaryHas { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(&p_right); + const A &a = *VariantGetInternalPtr<A>::get_ptr(&p_left); + + *r_ret = b.has(a); + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(right); + const A &a = *VariantGetInternalPtr<A>::get_ptr(left); + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.has(a); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(PtrToArg<Dictionary>::convert(right).has(PtrToArg<A>::convert(left)), r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +class OperatorEvaluatorInDictionaryHasNil { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(&p_right); + + *r_ret = b.has(Variant()); + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(right); + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.has(Variant()); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(PtrToArg<Dictionary>::convert(right).has(Variant()), r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +class OperatorEvaluatorInDictionaryHasObject { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(&p_right); + + *r_ret = b.has(p_left); + r_valid = true; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + const Dictionary &b = *VariantGetInternalPtr<Dictionary>::get_ptr(right); + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = b.has(*left); + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + PtrToArg<bool>::encode(PtrToArg<Dictionary>::convert(right).has(PtrToArg<Object *>::convert(left)), r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +class OperatorEvaluatorObjectHasPropertyString { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + Object *b = p_right.get_validated_object(); + if (!b) { + *r_ret = "Invalid base object for 'in'"; + r_valid = false; + return; + } + + const String &a = *VariantGetInternalPtr<String>::get_ptr(&p_left); + + b->get(a, &r_valid); + *r_ret = r_valid; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + Object *l = right->get_validated_object(); + ERR_FAIL_COND(l == nullptr); + const String &a = *VariantGetInternalPtr<String>::get_ptr(left); + + bool valid; + l->get(a, &valid); + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = valid; + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + bool valid; + PtrToArg<Object *>::convert(right)->get(PtrToArg<String>::convert(left), &valid); + PtrToArg<bool>::encode(valid, r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +class OperatorEvaluatorObjectHasPropertyStringName { +public: + static void evaluate(const Variant &p_left, const Variant &p_right, Variant *r_ret, bool &r_valid) { + Object *b = p_right.get_validated_object(); + if (!b) { + *r_ret = "Invalid base object for 'in'"; + r_valid = false; + return; + } + + const StringName &a = *VariantGetInternalPtr<StringName>::get_ptr(&p_left); + + b->get(a, &r_valid); + *r_ret = r_valid; + } + static inline void validated_evaluate(const Variant *left, const Variant *right, Variant *r_ret) { + Object *l = right->get_validated_object(); + ERR_FAIL_COND(l == nullptr); + const StringName &a = *VariantGetInternalPtr<StringName>::get_ptr(left); + + bool valid; + l->get(a, &valid); + *VariantGetInternalPtr<bool>::get_ptr(r_ret) = valid; + } + static void ptr_evaluate(const void *left, const void *right, void *r_ret) { + bool valid; + PtrToArg<Object *>::convert(right)->get(PtrToArg<StringName>::convert(left), &valid); + PtrToArg<bool>::encode(valid, r_ret); + } + static Variant::Type get_return_type() { return Variant::BOOL; } +}; + +#endif // VARIANT_OP_H diff --git a/core/variant/variant_parser.cpp b/core/variant/variant_parser.cpp index 751cb64c62..28930a19e2 100644 --- a/core/variant/variant_parser.cpp +++ b/core/variant/variant_parser.cpp @@ -1423,47 +1423,47 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str } break; case Variant::VECTOR2: { Vector2 v = p_variant; - p_store_string_func(p_store_string_ud, "Vector2( " + rtosfix(v.x) + ", " + rtosfix(v.y) + " )"); + p_store_string_func(p_store_string_ud, "Vector2(" + rtosfix(v.x) + ", " + rtosfix(v.y) + ")"); } break; case Variant::VECTOR2I: { Vector2i v = p_variant; - p_store_string_func(p_store_string_ud, "Vector2i( " + itos(v.x) + ", " + itos(v.y) + " )"); + p_store_string_func(p_store_string_ud, "Vector2i(" + itos(v.x) + ", " + itos(v.y) + ")"); } break; case Variant::RECT2: { Rect2 aabb = p_variant; - p_store_string_func(p_store_string_ud, "Rect2( " + rtosfix(aabb.position.x) + ", " + rtosfix(aabb.position.y) + ", " + rtosfix(aabb.size.x) + ", " + rtosfix(aabb.size.y) + " )"); + p_store_string_func(p_store_string_ud, "Rect2(" + rtosfix(aabb.position.x) + ", " + rtosfix(aabb.position.y) + ", " + rtosfix(aabb.size.x) + ", " + rtosfix(aabb.size.y) + ")"); } break; case Variant::RECT2I: { Rect2i aabb = p_variant; - p_store_string_func(p_store_string_ud, "Rect2i( " + itos(aabb.position.x) + ", " + itos(aabb.position.y) + ", " + itos(aabb.size.x) + ", " + itos(aabb.size.y) + " )"); + p_store_string_func(p_store_string_ud, "Rect2i(" + itos(aabb.position.x) + ", " + itos(aabb.position.y) + ", " + itos(aabb.size.x) + ", " + itos(aabb.size.y) + ")"); } break; case Variant::VECTOR3: { Vector3 v = p_variant; - p_store_string_func(p_store_string_ud, "Vector3( " + rtosfix(v.x) + ", " + rtosfix(v.y) + ", " + rtosfix(v.z) + " )"); + p_store_string_func(p_store_string_ud, "Vector3(" + rtosfix(v.x) + ", " + rtosfix(v.y) + ", " + rtosfix(v.z) + ")"); } break; case Variant::VECTOR3I: { Vector3i v = p_variant; - p_store_string_func(p_store_string_ud, "Vector3i( " + itos(v.x) + ", " + itos(v.y) + ", " + itos(v.z) + " )"); + p_store_string_func(p_store_string_ud, "Vector3i(" + itos(v.x) + ", " + itos(v.y) + ", " + itos(v.z) + ")"); } break; case Variant::PLANE: { Plane p = p_variant; - p_store_string_func(p_store_string_ud, "Plane( " + rtosfix(p.normal.x) + ", " + rtosfix(p.normal.y) + ", " + rtosfix(p.normal.z) + ", " + rtosfix(p.d) + " )"); + p_store_string_func(p_store_string_ud, "Plane(" + rtosfix(p.normal.x) + ", " + rtosfix(p.normal.y) + ", " + rtosfix(p.normal.z) + ", " + rtosfix(p.d) + ")"); } break; case Variant::AABB: { AABB aabb = p_variant; - p_store_string_func(p_store_string_ud, "AABB( " + rtosfix(aabb.position.x) + ", " + rtosfix(aabb.position.y) + ", " + rtosfix(aabb.position.z) + ", " + rtosfix(aabb.size.x) + ", " + rtosfix(aabb.size.y) + ", " + rtosfix(aabb.size.z) + " )"); + p_store_string_func(p_store_string_ud, "AABB(" + rtosfix(aabb.position.x) + ", " + rtosfix(aabb.position.y) + ", " + rtosfix(aabb.position.z) + ", " + rtosfix(aabb.size.x) + ", " + rtosfix(aabb.size.y) + ", " + rtosfix(aabb.size.z) + ")"); } break; case Variant::QUATERNION: { Quaternion quaternion = p_variant; - p_store_string_func(p_store_string_ud, "Quaternion( " + rtosfix(quaternion.x) + ", " + rtosfix(quaternion.y) + ", " + rtosfix(quaternion.z) + ", " + rtosfix(quaternion.w) + " )"); + p_store_string_func(p_store_string_ud, "Quaternion(" + rtosfix(quaternion.x) + ", " + rtosfix(quaternion.y) + ", " + rtosfix(quaternion.z) + ", " + rtosfix(quaternion.w) + ")"); } break; case Variant::TRANSFORM2D: { - String s = "Transform2D( "; + String s = "Transform2D("; Transform2D m3 = p_variant; for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { @@ -1474,11 +1474,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str } } - p_store_string_func(p_store_string_ud, s + " )"); + p_store_string_func(p_store_string_ud, s + ")"); } break; case Variant::BASIS: { - String s = "Basis( "; + String s = "Basis("; Basis m3 = p_variant; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { @@ -1489,11 +1489,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str } } - p_store_string_func(p_store_string_ud, s + " )"); + p_store_string_func(p_store_string_ud, s + ")"); } break; case Variant::TRANSFORM3D: { - String s = "Transform3D( "; + String s = "Transform3D("; Transform3D t = p_variant; Basis &m3 = t.basis; for (int i = 0; i < 3; i++) { @@ -1507,13 +1507,13 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str s = s + ", " + rtosfix(t.origin.x) + ", " + rtosfix(t.origin.y) + ", " + rtosfix(t.origin.z); - p_store_string_func(p_store_string_ud, s + " )"); + p_store_string_func(p_store_string_ud, s + ")"); } break; // misc types case Variant::COLOR: { Color c = p_variant; - p_store_string_func(p_store_string_ud, "Color( " + rtosfix(c.r) + ", " + rtosfix(c.g) + ", " + rtosfix(c.b) + ", " + rtosfix(c.a) + " )"); + p_store_string_func(p_store_string_ud, "Color(" + rtosfix(c.r) + ", " + rtosfix(c.g) + ", " + rtosfix(c.b) + ", " + rtosfix(c.a) + ")"); } break; case Variant::STRING_NAME: { @@ -1553,7 +1553,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str if (res_text == String() && res->get_path().is_resource_file()) { //external resource String path = res->get_path(); - res_text = "Resource( \"" + path + "\")"; + res_text = "Resource(\"" + path + "\")"; } //could come up with some sort of text @@ -1616,7 +1616,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str } break; case Variant::ARRAY: { - p_store_string_func(p_store_string_ud, "[ "); + p_store_string_func(p_store_string_ud, "["); Array array = p_variant; int len = array.size(); for (int i = 0; i < len; i++) { @@ -1625,12 +1625,12 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str } write(array[i], p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud); } - p_store_string_func(p_store_string_ud, " ]"); + p_store_string_func(p_store_string_ud, "]"); } break; case Variant::PACKED_BYTE_ARRAY: { - p_store_string_func(p_store_string_ud, "PackedByteArray( "); + p_store_string_func(p_store_string_ud, "PackedByteArray("); String s; Vector<uint8_t> data = p_variant; int len = data.size(); @@ -1644,11 +1644,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, itos(ptr[i])); } - p_store_string_func(p_store_string_ud, " )"); + p_store_string_func(p_store_string_ud, ")"); } break; case Variant::PACKED_INT32_ARRAY: { - p_store_string_func(p_store_string_ud, "PackedInt32Array( "); + p_store_string_func(p_store_string_ud, "PackedInt32Array("); Vector<int32_t> data = p_variant; int32_t len = data.size(); const int32_t *ptr = data.ptr(); @@ -1661,11 +1661,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, itos(ptr[i])); } - p_store_string_func(p_store_string_ud, " )"); + p_store_string_func(p_store_string_ud, ")"); } break; case Variant::PACKED_INT64_ARRAY: { - p_store_string_func(p_store_string_ud, "PackedInt64Array( "); + p_store_string_func(p_store_string_ud, "PackedInt64Array("); Vector<int64_t> data = p_variant; int64_t len = data.size(); const int64_t *ptr = data.ptr(); @@ -1678,11 +1678,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, itos(ptr[i])); } - p_store_string_func(p_store_string_ud, " )"); + p_store_string_func(p_store_string_ud, ")"); } break; case Variant::PACKED_FLOAT32_ARRAY: { - p_store_string_func(p_store_string_ud, "PackedFloat32Array( "); + p_store_string_func(p_store_string_ud, "PackedFloat32Array("); Vector<float> data = p_variant; int len = data.size(); const float *ptr = data.ptr(); @@ -1694,11 +1694,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, rtosfix(ptr[i])); } - p_store_string_func(p_store_string_ud, " )"); + p_store_string_func(p_store_string_ud, ")"); } break; case Variant::PACKED_FLOAT64_ARRAY: { - p_store_string_func(p_store_string_ud, "PackedFloat64Array( "); + p_store_string_func(p_store_string_ud, "PackedFloat64Array("); Vector<double> data = p_variant; int len = data.size(); const double *ptr = data.ptr(); @@ -1710,11 +1710,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, rtosfix(ptr[i])); } - p_store_string_func(p_store_string_ud, " )"); + p_store_string_func(p_store_string_ud, ")"); } break; case Variant::PACKED_STRING_ARRAY: { - p_store_string_func(p_store_string_ud, "PackedStringArray( "); + p_store_string_func(p_store_string_ud, "PackedStringArray("); Vector<String> data = p_variant; int len = data.size(); const String *ptr = data.ptr(); @@ -1730,11 +1730,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, "\"" + str.c_escape() + "\""); } - p_store_string_func(p_store_string_ud, " )"); + p_store_string_func(p_store_string_ud, ")"); } break; case Variant::PACKED_VECTOR2_ARRAY: { - p_store_string_func(p_store_string_ud, "PackedVector2Array( "); + p_store_string_func(p_store_string_ud, "PackedVector2Array("); Vector<Vector2> data = p_variant; int len = data.size(); const Vector2 *ptr = data.ptr(); @@ -1746,11 +1746,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, rtosfix(ptr[i].x) + ", " + rtosfix(ptr[i].y)); } - p_store_string_func(p_store_string_ud, " )"); + p_store_string_func(p_store_string_ud, ")"); } break; case Variant::PACKED_VECTOR3_ARRAY: { - p_store_string_func(p_store_string_ud, "PackedVector3Array( "); + p_store_string_func(p_store_string_ud, "PackedVector3Array("); Vector<Vector3> data = p_variant; int len = data.size(); const Vector3 *ptr = data.ptr(); @@ -1762,12 +1762,11 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, rtosfix(ptr[i].x) + ", " + rtosfix(ptr[i].y) + ", " + rtosfix(ptr[i].z)); } - p_store_string_func(p_store_string_ud, " )"); + p_store_string_func(p_store_string_ud, ")"); } break; case Variant::PACKED_COLOR_ARRAY: { - p_store_string_func(p_store_string_ud, "PackedColorArray( "); - + p_store_string_func(p_store_string_ud, "PackedColorArray("); Vector<Color> data = p_variant; int len = data.size(); const Color *ptr = data.ptr(); @@ -1779,7 +1778,7 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, rtosfix(ptr[i].r) + ", " + rtosfix(ptr[i].g) + ", " + rtosfix(ptr[i].b) + ", " + rtosfix(ptr[i].a)); } - p_store_string_func(p_store_string_ud, " )"); + p_store_string_func(p_store_string_ud, ")"); } break; default: { diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp index ae2795f2fd..5cb329e69a 100644 --- a/core/variant/variant_setget.cpp +++ b/core/variant/variant_setget.cpp @@ -28,282 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "variant.h" - -#include "core/core_string_names.h" -#include "core/debugger/engine_debugger.h" -#include "core/object/class_db.h" -#include "core/templates/local_vector.h" -#include "core/variant/variant_internal.h" - -/**** NAMED SETTERS AND GETTERS ****/ - -#define SETGET_STRUCT(m_base_type, m_member_type, m_member) \ - struct VariantSetGet_##m_base_type##_##m_member { \ - static void get(const Variant *base, Variant *member) { \ - VariantTypeAdjust<m_member_type>::adjust(member); \ - *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member; \ - } \ - static void ptr_get(const void *base, void *member) { \ - PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_member, member); \ - } \ - static void set(Variant *base, const Variant *value, bool &valid) { \ - if (value->get_type() == GetTypeInfo<m_member_type>::VARIANT_TYPE) { \ - VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \ - valid = true; \ - } else { \ - valid = false; \ - } \ - } \ - static void validated_set(Variant *base, const Variant *value) { \ - VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \ - } \ - static void ptr_set(void *base, const void *member) { \ - m_base_type b = PtrToArg<m_base_type>::convert(base); \ - b.m_member = PtrToArg<m_member_type>::convert(member); \ - PtrToArg<m_base_type>::encode(b, base); \ - } \ - static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \ - }; - -#define SETGET_NUMBER_STRUCT(m_base_type, m_member_type, m_member) \ - struct VariantSetGet_##m_base_type##_##m_member { \ - static void get(const Variant *base, Variant *member) { \ - VariantTypeAdjust<m_member_type>::adjust(member); \ - *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member; \ - } \ - static void ptr_get(const void *base, void *member) { \ - PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_member, member); \ - } \ - static void set(Variant *base, const Variant *value, bool &valid) { \ - if (value->get_type() == Variant::FLOAT) { \ - VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member = *VariantGetInternalPtr<double>::get_ptr(value); \ - valid = true; \ - } else if (value->get_type() == Variant::INT) { \ - VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member = *VariantGetInternalPtr<int64_t>::get_ptr(value); \ - valid = true; \ - } else { \ - valid = false; \ - } \ - } \ - static void validated_set(Variant *base, const Variant *value) { \ - VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \ - } \ - static void ptr_set(void *base, const void *member) { \ - m_base_type b = PtrToArg<m_base_type>::convert(base); \ - b.m_member = PtrToArg<m_member_type>::convert(member); \ - PtrToArg<m_base_type>::encode(b, base); \ - } \ - static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \ - }; - -#define SETGET_STRUCT_CUSTOM(m_base_type, m_member_type, m_member, m_custom) \ - struct VariantSetGet_##m_base_type##_##m_member { \ - static void get(const Variant *base, Variant *member) { \ - VariantTypeAdjust<m_member_type>::adjust(member); \ - *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom; \ - } \ - static void ptr_get(const void *base, void *member) { \ - PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_custom, member); \ - } \ - static void set(Variant *base, const Variant *value, bool &valid) { \ - if (value->get_type() == GetTypeInfo<m_member_type>::VARIANT_TYPE) { \ - VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \ - valid = true; \ - } else { \ - valid = false; \ - } \ - } \ - static void validated_set(Variant *base, const Variant *value) { \ - VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \ - } \ - static void ptr_set(void *base, const void *member) { \ - m_base_type b = PtrToArg<m_base_type>::convert(base); \ - b.m_custom = PtrToArg<m_member_type>::convert(member); \ - PtrToArg<m_base_type>::encode(b, base); \ - } \ - static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \ - }; - -#define SETGET_NUMBER_STRUCT_CUSTOM(m_base_type, m_member_type, m_member, m_custom) \ - struct VariantSetGet_##m_base_type##_##m_member { \ - static void get(const Variant *base, Variant *member) { \ - VariantTypeAdjust<m_member_type>::adjust(member); \ - *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom; \ - } \ - static void ptr_get(const void *base, void *member) { \ - PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_custom, member); \ - } \ - static void set(Variant *base, const Variant *value, bool &valid) { \ - if (value->get_type() == Variant::FLOAT) { \ - VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom = *VariantGetInternalPtr<double>::get_ptr(value); \ - valid = true; \ - } else if (value->get_type() == Variant::INT) { \ - VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom = *VariantGetInternalPtr<int64_t>::get_ptr(value); \ - valid = true; \ - } else { \ - valid = false; \ - } \ - } \ - static void validated_set(Variant *base, const Variant *value) { \ - VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \ - } \ - static void ptr_set(void *base, const void *member) { \ - m_base_type b = PtrToArg<m_base_type>::convert(base); \ - b.m_custom = PtrToArg<m_member_type>::convert(member); \ - PtrToArg<m_base_type>::encode(b, base); \ - } \ - static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \ - }; - -#define SETGET_STRUCT_FUNC(m_base_type, m_member_type, m_member, m_setter, m_getter) \ - struct VariantSetGet_##m_base_type##_##m_member { \ - static void get(const Variant *base, Variant *member) { \ - VariantTypeAdjust<m_member_type>::adjust(member); \ - *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_getter(); \ - } \ - static void ptr_get(const void *base, void *member) { \ - PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_getter(), member); \ - } \ - static void set(Variant *base, const Variant *value, bool &valid) { \ - if (value->get_type() == GetTypeInfo<m_member_type>::VARIANT_TYPE) { \ - VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(*VariantGetInternalPtr<m_member_type>::get_ptr(value)); \ - valid = true; \ - } else { \ - valid = false; \ - } \ - } \ - static void validated_set(Variant *base, const Variant *value) { \ - VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(*VariantGetInternalPtr<m_member_type>::get_ptr(value)); \ - } \ - static void ptr_set(void *base, const void *member) { \ - m_base_type b = PtrToArg<m_base_type>::convert(base); \ - b.m_setter(PtrToArg<m_member_type>::convert(member)); \ - PtrToArg<m_base_type>::encode(b, base); \ - } \ - static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \ - }; - -#define SETGET_NUMBER_STRUCT_FUNC(m_base_type, m_member_type, m_member, m_setter, m_getter) \ - struct VariantSetGet_##m_base_type##_##m_member { \ - static void get(const Variant *base, Variant *member) { \ - VariantTypeAdjust<m_member_type>::adjust(member); \ - *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_getter(); \ - } \ - static void ptr_get(const void *base, void *member) { \ - PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_getter(), member); \ - } \ - static void set(Variant *base, const Variant *value, bool &valid) { \ - if (value->get_type() == Variant::FLOAT) { \ - VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(*VariantGetInternalPtr<double>::get_ptr(value)); \ - valid = true; \ - } else if (value->get_type() == Variant::INT) { \ - VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(*VariantGetInternalPtr<int64_t>::get_ptr(value)); \ - valid = true; \ - } else { \ - valid = false; \ - } \ - } \ - static void validated_set(Variant *base, const Variant *value) { \ - VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(*VariantGetInternalPtr<m_member_type>::get_ptr(value)); \ - } \ - static void ptr_set(void *base, const void *member) { \ - m_base_type b = PtrToArg<m_base_type>::convert(base); \ - b.m_setter(PtrToArg<m_member_type>::convert(member)); \ - PtrToArg<m_base_type>::encode(b, base); \ - } \ - static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \ - }; - -#define SETGET_STRUCT_FUNC_INDEX(m_base_type, m_member_type, m_member, m_setter, m_getter, m_index) \ - struct VariantSetGet_##m_base_type##_##m_member { \ - static void get(const Variant *base, Variant *member) { \ - VariantTypeAdjust<m_member_type>::adjust(member); \ - *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_getter(m_index); \ - } \ - static void ptr_get(const void *base, void *member) { \ - PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_getter(m_index), member); \ - } \ - static void set(Variant *base, const Variant *value, bool &valid) { \ - if (value->get_type() == GetTypeInfo<m_member_type>::VARIANT_TYPE) { \ - VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(m_index, *VariantGetInternalPtr<m_member_type>::get_ptr(value)); \ - valid = true; \ - } else { \ - valid = false; \ - } \ - } \ - static void validated_set(Variant *base, const Variant *value) { \ - VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(m_index, *VariantGetInternalPtr<m_member_type>::get_ptr(value)); \ - } \ - static void ptr_set(void *base, const void *member) { \ - m_base_type b = PtrToArg<m_base_type>::convert(base); \ - b.m_setter(m_index, PtrToArg<m_member_type>::convert(member)); \ - PtrToArg<m_base_type>::encode(b, base); \ - } \ - static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \ - }; - -SETGET_NUMBER_STRUCT(Vector2, double, x) -SETGET_NUMBER_STRUCT(Vector2, double, y) - -SETGET_NUMBER_STRUCT(Vector2i, int64_t, x) -SETGET_NUMBER_STRUCT(Vector2i, int64_t, y) - -SETGET_NUMBER_STRUCT(Vector3, double, x) -SETGET_NUMBER_STRUCT(Vector3, double, y) -SETGET_NUMBER_STRUCT(Vector3, double, z) - -SETGET_NUMBER_STRUCT(Vector3i, int64_t, x) -SETGET_NUMBER_STRUCT(Vector3i, int64_t, y) -SETGET_NUMBER_STRUCT(Vector3i, int64_t, z) - -SETGET_STRUCT(Rect2, Vector2, position) -SETGET_STRUCT(Rect2, Vector2, size) -SETGET_STRUCT_FUNC(Rect2, Vector2, end, set_end, get_end) - -SETGET_STRUCT(Rect2i, Vector2i, position) -SETGET_STRUCT(Rect2i, Vector2i, size) -SETGET_STRUCT_FUNC(Rect2i, Vector2i, end, set_end, get_end) - -SETGET_STRUCT(AABB, Vector3, position) -SETGET_STRUCT(AABB, Vector3, size) -SETGET_STRUCT_FUNC(AABB, Vector3, end, set_end, get_end) - -SETGET_STRUCT_CUSTOM(Transform2D, Vector2, x, elements[0]) -SETGET_STRUCT_CUSTOM(Transform2D, Vector2, y, elements[1]) -SETGET_STRUCT_CUSTOM(Transform2D, Vector2, origin, elements[2]) - -SETGET_NUMBER_STRUCT_CUSTOM(Plane, double, x, normal.x) -SETGET_NUMBER_STRUCT_CUSTOM(Plane, double, y, normal.y) -SETGET_NUMBER_STRUCT_CUSTOM(Plane, double, z, normal.z) -SETGET_STRUCT(Plane, Vector3, normal) -SETGET_NUMBER_STRUCT(Plane, double, d) - -SETGET_NUMBER_STRUCT(Quaternion, double, x) -SETGET_NUMBER_STRUCT(Quaternion, double, y) -SETGET_NUMBER_STRUCT(Quaternion, double, z) -SETGET_NUMBER_STRUCT(Quaternion, double, w) - -SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, x, set_axis, get_axis, 0) -SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, y, set_axis, get_axis, 1) -SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, z, set_axis, get_axis, 2) - -SETGET_STRUCT(Transform3D, Basis, basis) -SETGET_STRUCT(Transform3D, Vector3, origin) - -SETGET_NUMBER_STRUCT(Color, double, r) -SETGET_NUMBER_STRUCT(Color, double, g) -SETGET_NUMBER_STRUCT(Color, double, b) -SETGET_NUMBER_STRUCT(Color, double, a) - -SETGET_NUMBER_STRUCT_FUNC(Color, int64_t, r8, set_r8, get_r8) -SETGET_NUMBER_STRUCT_FUNC(Color, int64_t, g8, set_g8, get_g8) -SETGET_NUMBER_STRUCT_FUNC(Color, int64_t, b8, set_b8, get_b8) -SETGET_NUMBER_STRUCT_FUNC(Color, int64_t, a8, set_a8, get_a8) - -SETGET_NUMBER_STRUCT_FUNC(Color, double, h, set_h, get_h) -SETGET_NUMBER_STRUCT_FUNC(Color, double, s, set_s, get_s) -SETGET_NUMBER_STRUCT_FUNC(Color, double, v, set_v, get_v) +#include "variant_setget.h" struct VariantSetterGetterInfo { void (*setter)(Variant *base, const Variant *value, bool &valid); @@ -326,7 +51,7 @@ static void register_member(Variant::Type p_type, const StringName &p_member) { sgi.ptr_setter = T::ptr_set; sgi.getter = T::get; - sgi.validated_getter = T::get; + sgi.validated_getter = T::validated_get; sgi.ptr_getter = T::ptr_get; sgi.member_type = T::get_type(); diff --git a/core/variant/variant_setget.h b/core/variant/variant_setget.h new file mode 100644 index 0000000000..dbf24ab3e3 --- /dev/null +++ b/core/variant/variant_setget.h @@ -0,0 +1,332 @@ +/*************************************************************************/ +/* variant_setget.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef VARIANT_SETGET_H +#define VARIANT_SETGET_H + +#include "variant.h" + +#include "core/core_string_names.h" +#include "core/debugger/engine_debugger.h" +#include "core/object/class_db.h" +#include "core/templates/local_vector.h" +#include "core/variant/variant_internal.h" + +/**** NAMED SETTERS AND GETTERS ****/ + +#define SETGET_STRUCT(m_base_type, m_member_type, m_member) \ + struct VariantSetGet_##m_base_type##_##m_member { \ + static void get(const Variant *base, Variant *member) { \ + VariantTypeAdjust<m_member_type>::adjust(member); \ + *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member; \ + } \ + static inline void validated_get(const Variant *base, Variant *member) { \ + *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member; \ + } \ + static void ptr_get(const void *base, void *member) { \ + PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_member, member); \ + } \ + static void set(Variant *base, const Variant *value, bool &valid) { \ + if (value->get_type() == GetTypeInfo<m_member_type>::VARIANT_TYPE) { \ + VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \ + valid = true; \ + } else { \ + valid = false; \ + } \ + } \ + static inline void validated_set(Variant *base, const Variant *value) { \ + VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \ + } \ + static void ptr_set(void *base, const void *member) { \ + m_base_type b = PtrToArg<m_base_type>::convert(base); \ + b.m_member = PtrToArg<m_member_type>::convert(member); \ + PtrToArg<m_base_type>::encode(b, base); \ + } \ + static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \ + }; + +#define SETGET_NUMBER_STRUCT(m_base_type, m_member_type, m_member) \ + struct VariantSetGet_##m_base_type##_##m_member { \ + static void get(const Variant *base, Variant *member) { \ + VariantTypeAdjust<m_member_type>::adjust(member); \ + *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member; \ + } \ + static inline void validated_get(const Variant *base, Variant *member) { \ + *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member; \ + } \ + static void ptr_get(const void *base, void *member) { \ + PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_member, member); \ + } \ + static void set(Variant *base, const Variant *value, bool &valid) { \ + if (value->get_type() == Variant::FLOAT) { \ + VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member = *VariantGetInternalPtr<double>::get_ptr(value); \ + valid = true; \ + } else if (value->get_type() == Variant::INT) { \ + VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member = *VariantGetInternalPtr<int64_t>::get_ptr(value); \ + valid = true; \ + } else { \ + valid = false; \ + } \ + } \ + static inline void validated_set(Variant *base, const Variant *value) { \ + VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_member = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \ + } \ + static void ptr_set(void *base, const void *member) { \ + m_base_type b = PtrToArg<m_base_type>::convert(base); \ + b.m_member = PtrToArg<m_member_type>::convert(member); \ + PtrToArg<m_base_type>::encode(b, base); \ + } \ + static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \ + }; + +#define SETGET_STRUCT_CUSTOM(m_base_type, m_member_type, m_member, m_custom) \ + struct VariantSetGet_##m_base_type##_##m_member { \ + static void get(const Variant *base, Variant *member) { \ + VariantTypeAdjust<m_member_type>::adjust(member); \ + *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom; \ + } \ + static inline void validated_get(const Variant *base, Variant *member) { \ + *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom; \ + } \ + static void ptr_get(const void *base, void *member) { \ + PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_custom, member); \ + } \ + static void set(Variant *base, const Variant *value, bool &valid) { \ + if (value->get_type() == GetTypeInfo<m_member_type>::VARIANT_TYPE) { \ + VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \ + valid = true; \ + } else { \ + valid = false; \ + } \ + } \ + static inline void validated_set(Variant *base, const Variant *value) { \ + VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \ + } \ + static void ptr_set(void *base, const void *member) { \ + m_base_type b = PtrToArg<m_base_type>::convert(base); \ + b.m_custom = PtrToArg<m_member_type>::convert(member); \ + PtrToArg<m_base_type>::encode(b, base); \ + } \ + static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \ + }; + +#define SETGET_NUMBER_STRUCT_CUSTOM(m_base_type, m_member_type, m_member, m_custom) \ + struct VariantSetGet_##m_base_type##_##m_member { \ + static void get(const Variant *base, Variant *member) { \ + VariantTypeAdjust<m_member_type>::adjust(member); \ + *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom; \ + } \ + static inline void validated_get(const Variant *base, Variant *member) { \ + *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom; \ + } \ + static void ptr_get(const void *base, void *member) { \ + PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_custom, member); \ + } \ + static void set(Variant *base, const Variant *value, bool &valid) { \ + if (value->get_type() == Variant::FLOAT) { \ + VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom = *VariantGetInternalPtr<double>::get_ptr(value); \ + valid = true; \ + } else if (value->get_type() == Variant::INT) { \ + VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom = *VariantGetInternalPtr<int64_t>::get_ptr(value); \ + valid = true; \ + } else { \ + valid = false; \ + } \ + } \ + static inline void validated_set(Variant *base, const Variant *value) { \ + VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_custom = *VariantGetInternalPtr<m_member_type>::get_ptr(value); \ + } \ + static void ptr_set(void *base, const void *member) { \ + m_base_type b = PtrToArg<m_base_type>::convert(base); \ + b.m_custom = PtrToArg<m_member_type>::convert(member); \ + PtrToArg<m_base_type>::encode(b, base); \ + } \ + static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \ + }; + +#define SETGET_STRUCT_FUNC(m_base_type, m_member_type, m_member, m_setter, m_getter) \ + struct VariantSetGet_##m_base_type##_##m_member { \ + static void get(const Variant *base, Variant *member) { \ + VariantTypeAdjust<m_member_type>::adjust(member); \ + *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_getter(); \ + } \ + static inline void validated_get(const Variant *base, Variant *member) { \ + *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_getter(); \ + } \ + static void ptr_get(const void *base, void *member) { \ + PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_getter(), member); \ + } \ + static void set(Variant *base, const Variant *value, bool &valid) { \ + if (value->get_type() == GetTypeInfo<m_member_type>::VARIANT_TYPE) { \ + VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(*VariantGetInternalPtr<m_member_type>::get_ptr(value)); \ + valid = true; \ + } else { \ + valid = false; \ + } \ + } \ + static inline void validated_set(Variant *base, const Variant *value) { \ + VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(*VariantGetInternalPtr<m_member_type>::get_ptr(value)); \ + } \ + static void ptr_set(void *base, const void *member) { \ + m_base_type b = PtrToArg<m_base_type>::convert(base); \ + b.m_setter(PtrToArg<m_member_type>::convert(member)); \ + PtrToArg<m_base_type>::encode(b, base); \ + } \ + static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \ + }; + +#define SETGET_NUMBER_STRUCT_FUNC(m_base_type, m_member_type, m_member, m_setter, m_getter) \ + struct VariantSetGet_##m_base_type##_##m_member { \ + static void get(const Variant *base, Variant *member) { \ + VariantTypeAdjust<m_member_type>::adjust(member); \ + *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_getter(); \ + } \ + static inline void validated_get(const Variant *base, Variant *member) { \ + *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_getter(); \ + } \ + static void ptr_get(const void *base, void *member) { \ + PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_getter(), member); \ + } \ + static void set(Variant *base, const Variant *value, bool &valid) { \ + if (value->get_type() == Variant::FLOAT) { \ + VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(*VariantGetInternalPtr<double>::get_ptr(value)); \ + valid = true; \ + } else if (value->get_type() == Variant::INT) { \ + VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(*VariantGetInternalPtr<int64_t>::get_ptr(value)); \ + valid = true; \ + } else { \ + valid = false; \ + } \ + } \ + static inline void validated_set(Variant *base, const Variant *value) { \ + VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(*VariantGetInternalPtr<m_member_type>::get_ptr(value)); \ + } \ + static void ptr_set(void *base, const void *member) { \ + m_base_type b = PtrToArg<m_base_type>::convert(base); \ + b.m_setter(PtrToArg<m_member_type>::convert(member)); \ + PtrToArg<m_base_type>::encode(b, base); \ + } \ + static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \ + }; + +#define SETGET_STRUCT_FUNC_INDEX(m_base_type, m_member_type, m_member, m_setter, m_getter, m_index) \ + struct VariantSetGet_##m_base_type##_##m_member { \ + static void get(const Variant *base, Variant *member) { \ + VariantTypeAdjust<m_member_type>::adjust(member); \ + *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_getter(m_index); \ + } \ + static inline void validated_get(const Variant *base, Variant *member) { \ + *VariantGetInternalPtr<m_member_type>::get_ptr(member) = VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_getter(m_index); \ + } \ + static void ptr_get(const void *base, void *member) { \ + PtrToArg<m_member_type>::encode(PtrToArg<m_base_type>::convert(base).m_getter(m_index), member); \ + } \ + static void set(Variant *base, const Variant *value, bool &valid) { \ + if (value->get_type() == GetTypeInfo<m_member_type>::VARIANT_TYPE) { \ + VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(m_index, *VariantGetInternalPtr<m_member_type>::get_ptr(value)); \ + valid = true; \ + } else { \ + valid = false; \ + } \ + } \ + static inline void validated_set(Variant *base, const Variant *value) { \ + VariantGetInternalPtr<m_base_type>::get_ptr(base)->m_setter(m_index, *VariantGetInternalPtr<m_member_type>::get_ptr(value)); \ + } \ + static void ptr_set(void *base, const void *member) { \ + m_base_type b = PtrToArg<m_base_type>::convert(base); \ + b.m_setter(m_index, PtrToArg<m_member_type>::convert(member)); \ + PtrToArg<m_base_type>::encode(b, base); \ + } \ + static Variant::Type get_type() { return GetTypeInfo<m_member_type>::VARIANT_TYPE; } \ + }; + +SETGET_NUMBER_STRUCT(Vector2, double, x) +SETGET_NUMBER_STRUCT(Vector2, double, y) + +SETGET_NUMBER_STRUCT(Vector2i, int64_t, x) +SETGET_NUMBER_STRUCT(Vector2i, int64_t, y) + +SETGET_NUMBER_STRUCT(Vector3, double, x) +SETGET_NUMBER_STRUCT(Vector3, double, y) +SETGET_NUMBER_STRUCT(Vector3, double, z) + +SETGET_NUMBER_STRUCT(Vector3i, int64_t, x) +SETGET_NUMBER_STRUCT(Vector3i, int64_t, y) +SETGET_NUMBER_STRUCT(Vector3i, int64_t, z) + +SETGET_STRUCT(Rect2, Vector2, position) +SETGET_STRUCT(Rect2, Vector2, size) +SETGET_STRUCT_FUNC(Rect2, Vector2, end, set_end, get_end) + +SETGET_STRUCT(Rect2i, Vector2i, position) +SETGET_STRUCT(Rect2i, Vector2i, size) +SETGET_STRUCT_FUNC(Rect2i, Vector2i, end, set_end, get_end) + +SETGET_STRUCT(AABB, Vector3, position) +SETGET_STRUCT(AABB, Vector3, size) +SETGET_STRUCT_FUNC(AABB, Vector3, end, set_end, get_end) + +SETGET_STRUCT_CUSTOM(Transform2D, Vector2, x, elements[0]) +SETGET_STRUCT_CUSTOM(Transform2D, Vector2, y, elements[1]) +SETGET_STRUCT_CUSTOM(Transform2D, Vector2, origin, elements[2]) + +SETGET_NUMBER_STRUCT_CUSTOM(Plane, double, x, normal.x) +SETGET_NUMBER_STRUCT_CUSTOM(Plane, double, y, normal.y) +SETGET_NUMBER_STRUCT_CUSTOM(Plane, double, z, normal.z) +SETGET_STRUCT(Plane, Vector3, normal) +SETGET_NUMBER_STRUCT(Plane, double, d) + +SETGET_NUMBER_STRUCT(Quaternion, double, x) +SETGET_NUMBER_STRUCT(Quaternion, double, y) +SETGET_NUMBER_STRUCT(Quaternion, double, z) +SETGET_NUMBER_STRUCT(Quaternion, double, w) + +SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, x, set_axis, get_axis, 0) +SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, y, set_axis, get_axis, 1) +SETGET_STRUCT_FUNC_INDEX(Basis, Vector3, z, set_axis, get_axis, 2) + +SETGET_STRUCT(Transform3D, Basis, basis) +SETGET_STRUCT(Transform3D, Vector3, origin) + +SETGET_NUMBER_STRUCT(Color, double, r) +SETGET_NUMBER_STRUCT(Color, double, g) +SETGET_NUMBER_STRUCT(Color, double, b) +SETGET_NUMBER_STRUCT(Color, double, a) + +SETGET_NUMBER_STRUCT_FUNC(Color, int64_t, r8, set_r8, get_r8) +SETGET_NUMBER_STRUCT_FUNC(Color, int64_t, g8, set_g8, get_g8) +SETGET_NUMBER_STRUCT_FUNC(Color, int64_t, b8, set_b8, get_b8) +SETGET_NUMBER_STRUCT_FUNC(Color, int64_t, a8, set_a8, get_a8) + +SETGET_NUMBER_STRUCT_FUNC(Color, double, h, set_h, get_h) +SETGET_NUMBER_STRUCT_FUNC(Color, double, s, set_s, get_s) +SETGET_NUMBER_STRUCT_FUNC(Color, double, v, set_v, get_v) + +#endif // VARIANT_SETGET_H diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index 552fc41318..fa118bec54 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -1066,11 +1066,13 @@ <description> Returns the internal type of the given Variant object, using the [enum Variant.Type] values. [codeblock] - p = parse_json('["a", "b", "c"]') - if typeof(p) == TYPE_ARRAY: - print(p[0]) # Prints a + var json = JSON.new() + json.parse('["a", "b", "c"]') + var result = json.get_data() + if typeof(result) == TYPE_ARRAY: + print(result[0]) # Prints a else: - print("unexpected results") + print("Unexpected result") [/codeblock] </description> </method> @@ -1211,9 +1213,6 @@ <member name="InputMap" type="InputMap" setter="" getter=""> The [InputMap] singleton. </member> - <member name="JSON" type="JSON" setter="" getter=""> - The [JSON] singleton. - </member> <member name="JavaClassWrapper" type="JavaClassWrapper" setter="" getter=""> The [JavaClassWrapper] singleton. [b]Note:[/b] Only implemented on Android. diff --git a/doc/classes/AABB.xml b/doc/classes/AABB.xml index af34a948f5..03607661df 100644 --- a/doc/classes/AABB.xml +++ b/doc/classes/AABB.xml @@ -257,13 +257,13 @@ </method> </methods> <members> - <member name="end" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )"> + <member name="end" type="Vector3" setter="" getter="" default="Vector3(0, 0, 0)"> Ending corner. This is calculated as [code]position + size[/code]. Setting this value will change the size. </member> - <member name="position" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )"> + <member name="position" type="Vector3" setter="" getter="" default="Vector3(0, 0, 0)"> Beginning corner. Typically has values lower than [member end]. </member> - <member name="size" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )"> + <member name="size" type="Vector3" setter="" getter="" default="Vector3(0, 0, 0)"> Size from [member position] to [member end]. Typically, all components are positive. If the size is negative, you can use [method abs] to fix it. </member> diff --git a/doc/classes/AESContext.xml b/doc/classes/AESContext.xml index 9dde25028e..e179c97677 100644 --- a/doc/classes/AESContext.xml +++ b/doc/classes/AESContext.xml @@ -101,7 +101,7 @@ </argument> <argument index="1" name="key" type="PackedByteArray"> </argument> - <argument index="2" name="iv" type="PackedByteArray" default="PackedByteArray( )"> + <argument index="2" name="iv" type="PackedByteArray" default="PackedByteArray()"> </argument> <description> Start the AES context in the given [code]mode[/code]. A [code]key[/code] of either 16 or 32 bytes must always be provided, while an [code]iv[/code] (initialization vector) of exactly 16 bytes, is only needed when [code]mode[/code] is either [constant MODE_CBC_ENCRYPT] or [constant MODE_CBC_DECRYPT]. diff --git a/doc/classes/AnimatedSprite2D.xml b/doc/classes/AnimatedSprite2D.xml index d18419f163..7662e8368b 100644 --- a/doc/classes/AnimatedSprite2D.xml +++ b/doc/classes/AnimatedSprite2D.xml @@ -57,7 +57,7 @@ <member name="frames" type="SpriteFrames" setter="set_sprite_frames" getter="get_sprite_frames"> The [SpriteFrames] resource containing the animation(s). </member> - <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2( 0, 0 )"> + <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2(0, 0)"> The texture's drawing offset. </member> <member name="playing" type="bool" setter="_set_playing" getter="_is_playing" default="false"> diff --git a/doc/classes/Animation.xml b/doc/classes/Animation.xml index 02203a3725..894e784397 100644 --- a/doc/classes/Animation.xml +++ b/doc/classes/Animation.xml @@ -213,9 +213,9 @@ </argument> <argument index="2" name="value" type="float"> </argument> - <argument index="3" name="in_handle" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="3" name="in_handle" type="Vector2" default="Vector2(0, 0)"> </argument> - <argument index="4" name="out_handle" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="4" name="out_handle" type="Vector2" default="Vector2(0, 0)"> </argument> <description> Inserts a Bezier Track key at the given [code]time[/code] in seconds. The [code]track_idx[/code] must be the index of a Bezier Track. diff --git a/doc/classes/AnimationNodeBlendSpace2D.xml b/doc/classes/AnimationNodeBlendSpace2D.xml index abbc8cb2e6..1a6d2bd755 100644 --- a/doc/classes/AnimationNodeBlendSpace2D.xml +++ b/doc/classes/AnimationNodeBlendSpace2D.xml @@ -132,13 +132,13 @@ <member name="blend_mode" type="int" setter="set_blend_mode" getter="get_blend_mode" enum="AnimationNodeBlendSpace2D.BlendMode" default="0"> Controls the interpolation between animations. See [enum BlendMode] constants. </member> - <member name="max_space" type="Vector2" setter="set_max_space" getter="get_max_space" default="Vector2( 1, 1 )"> + <member name="max_space" type="Vector2" setter="set_max_space" getter="get_max_space" default="Vector2(1, 1)"> The blend space's X and Y axes' upper limit for the points' position. See [method add_blend_point]. </member> - <member name="min_space" type="Vector2" setter="set_min_space" getter="get_min_space" default="Vector2( -1, -1 )"> + <member name="min_space" type="Vector2" setter="set_min_space" getter="get_min_space" default="Vector2(-1, -1)"> The blend space's X and Y axes' lower limit for the points' position. See [method add_blend_point]. </member> - <member name="snap" type="Vector2" setter="set_snap" getter="get_snap" default="Vector2( 0.1, 0.1 )"> + <member name="snap" type="Vector2" setter="set_snap" getter="get_snap" default="Vector2(0.1, 0.1)"> Position increment to snap to when moving a point. </member> <member name="x_label" type="String" setter="set_x_label" getter="get_x_label" default=""x""> diff --git a/doc/classes/AnimationNodeBlendTree.xml b/doc/classes/AnimationNodeBlendTree.xml index 8f87ce453f..a90e8647bb 100644 --- a/doc/classes/AnimationNodeBlendTree.xml +++ b/doc/classes/AnimationNodeBlendTree.xml @@ -17,7 +17,7 @@ </argument> <argument index="1" name="node" type="AnimationNode"> </argument> - <argument index="2" name="position" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)"> </argument> <description> Adds an [AnimationNode] at the given [code]position[/code]. The [code]name[/code] is used to identify the created sub-node later. @@ -107,7 +107,7 @@ </method> </methods> <members> - <member name="graph_offset" type="Vector2" setter="set_graph_offset" getter="get_graph_offset" default="Vector2( 0, 0 )"> + <member name="graph_offset" type="Vector2" setter="set_graph_offset" getter="get_graph_offset" default="Vector2(0, 0)"> The global offset of all sub-nodes. </member> </members> diff --git a/doc/classes/AnimationNodeStateMachine.xml b/doc/classes/AnimationNodeStateMachine.xml index e08e288c59..8e070142c4 100644 --- a/doc/classes/AnimationNodeStateMachine.xml +++ b/doc/classes/AnimationNodeStateMachine.xml @@ -28,7 +28,7 @@ </argument> <argument index="1" name="node" type="AnimationNode"> </argument> - <argument index="2" name="position" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)"> </argument> <description> Adds a new node to the graph. The [code]position[/code] is used for display in the editor. diff --git a/doc/classes/Area2D.xml b/doc/classes/Area2D.xml index 96333988f8..f52c810ad2 100644 --- a/doc/classes/Area2D.xml +++ b/doc/classes/Area2D.xml @@ -69,7 +69,7 @@ <member name="gravity_point" type="bool" setter="set_gravity_is_point" getter="is_gravity_a_point" default="false"> If [code]true[/code], gravity is calculated from a point (set via [member gravity_vec]). See also [member space_override]. </member> - <member name="gravity_vec" type="Vector2" setter="set_gravity_vector" getter="get_gravity_vector" default="Vector2( 0, 1 )"> + <member name="gravity_vec" type="Vector2" setter="set_gravity_vector" getter="get_gravity_vector" default="Vector2(0, 1)"> The area's gravity vector (not normalized). If gravity is a point (see [member gravity_point]), this will be the point of attraction. </member> <member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp" default="0.1"> diff --git a/doc/classes/Area3D.xml b/doc/classes/Area3D.xml index a2724f3f23..cc31b6c203 100644 --- a/doc/classes/Area3D.xml +++ b/doc/classes/Area3D.xml @@ -67,7 +67,7 @@ <member name="gravity_point" type="bool" setter="set_gravity_is_point" getter="is_gravity_a_point" default="false"> If [code]true[/code], gravity is calculated from a point (set via [member gravity_vec]). See also [member space_override]. </member> - <member name="gravity_vec" type="Vector3" setter="set_gravity_vector" getter="get_gravity_vector" default="Vector3( 0, -1, 0 )"> + <member name="gravity_vec" type="Vector3" setter="set_gravity_vector" getter="get_gravity_vector" default="Vector3(0, -1, 0)"> The area's gravity vector (not normalized). If gravity is a point (see [member gravity_point]), this will be the point of attraction. </member> <member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp" default="0.1"> diff --git a/doc/classes/ArrayMesh.xml b/doc/classes/ArrayMesh.xml index f8cbc942e6..1bbf9bcd93 100644 --- a/doc/classes/ArrayMesh.xml +++ b/doc/classes/ArrayMesh.xml @@ -66,7 +66,7 @@ </argument> <argument index="1" name="arrays" type="Array"> </argument> - <argument index="2" name="blend_shapes" type="Array" default="[ ]"> + <argument index="2" name="blend_shapes" type="Array" default="[]"> </argument> <argument index="3" name="lods" type="Dictionary" default="{ }"> @@ -221,7 +221,7 @@ <member name="blend_shape_mode" type="int" setter="set_blend_shape_mode" getter="get_blend_shape_mode" enum="Mesh.BlendShapeMode" default="1"> Sets the blend shape mode to one of [enum Mesh.BlendShapeMode]. </member> - <member name="custom_aabb" type="AABB" setter="set_custom_aabb" getter="get_custom_aabb" default="AABB( 0, 0, 0, 0, 0, 0 )"> + <member name="custom_aabb" type="AABB" setter="set_custom_aabb" getter="get_custom_aabb" default="AABB(0, 0, 0, 0, 0, 0)"> Overrides the [AABB] with one defined by user for use with frustum culling. Especially useful to avoid unexpected culling when using a shader to offset vertices. </member> <member name="shadow_mesh" type="ArrayMesh" setter="set_shadow_mesh" getter="get_shadow_mesh"> diff --git a/doc/classes/AtlasTexture.xml b/doc/classes/AtlasTexture.xml index 9865319419..b49c0e4278 100644 --- a/doc/classes/AtlasTexture.xml +++ b/doc/classes/AtlasTexture.xml @@ -18,10 +18,10 @@ <member name="filter_clip" type="bool" setter="set_filter_clip" getter="has_filter_clip" default="false"> If [code]true[/code], clips the area outside of the region to avoid bleeding of the surrounding texture pixels. </member> - <member name="margin" type="Rect2" setter="set_margin" getter="get_margin" default="Rect2( 0, 0, 0, 0 )"> + <member name="margin" type="Rect2" setter="set_margin" getter="get_margin" default="Rect2(0, 0, 0, 0)"> The margin around the region. The [Rect2]'s [member Rect2.size] parameter ("w" and "h" in the editor) resizes the texture so it fits within the margin. </member> - <member name="region" type="Rect2" setter="set_region" getter="get_region" default="Rect2( 0, 0, 0, 0 )"> + <member name="region" type="Rect2" setter="set_region" getter="get_region" default="Rect2(0, 0, 0, 0)"> The AtlasTexture's used region. </member> </members> diff --git a/doc/classes/AudioStreamSample.xml b/doc/classes/AudioStreamSample.xml index d07b1ac66d..5a0e71a0f8 100644 --- a/doc/classes/AudioStreamSample.xml +++ b/doc/classes/AudioStreamSample.xml @@ -22,7 +22,7 @@ </method> </methods> <members> - <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray( )"> + <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray()"> Contains the audio data in bytes. [b]Note:[/b] This property expects signed PCM8 data. To convert unsigned PCM8 to signed PCM8, subtract 128 from each byte. </member> diff --git a/doc/classes/BackBufferCopy.xml b/doc/classes/BackBufferCopy.xml index 9a70b8f20c..55ee573811 100644 --- a/doc/classes/BackBufferCopy.xml +++ b/doc/classes/BackBufferCopy.xml @@ -15,7 +15,7 @@ <member name="copy_mode" type="int" setter="set_copy_mode" getter="get_copy_mode" enum="BackBufferCopy.CopyMode" default="1"> Buffer mode. See [enum CopyMode] constants. </member> - <member name="rect" type="Rect2" setter="set_rect" getter="get_rect" default="Rect2( -100, -100, 200, 200 )"> + <member name="rect" type="Rect2" setter="set_rect" getter="get_rect" default="Rect2(-100, -100, 200, 200)"> The area covered by the BackBufferCopy. Only used if [member copy_mode] is [constant COPY_MODE_RECT]. </member> </members> diff --git a/doc/classes/BaseMaterial3D.xml b/doc/classes/BaseMaterial3D.xml index 49edb4c691..abe06bc7e1 100644 --- a/doc/classes/BaseMaterial3D.xml +++ b/doc/classes/BaseMaterial3D.xml @@ -72,7 +72,7 @@ </method> </methods> <members> - <member name="albedo_color" type="Color" setter="set_albedo" getter="get_albedo" default="Color( 1, 1, 1, 1 )"> + <member name="albedo_color" type="Color" setter="set_albedo" getter="get_albedo" default="Color(1, 1, 1, 1)"> The material's base color. </member> <member name="albedo_tex_force_srgb" type="bool" setter="set_flag" getter="get_flag" default="false"> @@ -117,7 +117,7 @@ <member name="ao_texture_channel" type="int" setter="set_ao_texture_channel" getter="get_ao_texture_channel" enum="BaseMaterial3D.TextureChannel" default="0"> Specifies the channel of the [member ao_texture] in which the ambient occlusion information is stored. This is useful when you store the information for multiple effects in a single texture. For example if you stored metallic in the red channel, roughness in the blue, and ambient occlusion in the green you could reduce the number of textures you use. </member> - <member name="backlight" type="Color" setter="set_backlight" getter="get_backlight" default="Color( 0, 0, 0, 1 )"> + <member name="backlight" type="Color" setter="set_backlight" getter="get_backlight" default="Color(0, 0, 0, 1)"> The color used by the backlight effect. Represents the light passing through an object. </member> <member name="backlight_enabled" type="bool" setter="set_feature" getter="get_feature" default="false"> @@ -195,7 +195,7 @@ <member name="distance_fade_mode" type="int" setter="set_distance_fade" getter="get_distance_fade" enum="BaseMaterial3D.DistanceFadeMode" default="0"> Specifies which type of fade to use. Can be any of the [enum DistanceFadeMode]s. </member> - <member name="emission" type="Color" setter="set_emission" getter="get_emission" default="Color( 0, 0, 0, 1 )"> + <member name="emission" type="Color" setter="set_emission" getter="get_emission" default="Color(0, 0, 0, 1)"> The emitted light's color. See [member emission_enabled]. </member> <member name="emission_enabled" type="bool" setter="set_feature" getter="get_feature" default="false"> @@ -345,7 +345,7 @@ </member> <member name="subsurf_scatter_transmittance_boost" type="float" setter="set_transmittance_boost" getter="get_transmittance_boost" default="0.0"> </member> - <member name="subsurf_scatter_transmittance_color" type="Color" setter="set_transmittance_color" getter="get_transmittance_color" default="Color( 1, 1, 1, 1 )"> + <member name="subsurf_scatter_transmittance_color" type="Color" setter="set_transmittance_color" getter="get_transmittance_color" default="Color(1, 1, 1, 1)"> </member> <member name="subsurf_scatter_transmittance_curve" type="float" setter="set_transmittance_curve" getter="get_transmittance_curve" default="1.0"> </member> @@ -370,10 +370,10 @@ If [code]true[/code], render point size can be changed. [b]Note:[/b] this is only effective for objects whose geometry is point-based rather than triangle-based. See also [member point_size]. </member> - <member name="uv1_offset" type="Vector3" setter="set_uv1_offset" getter="get_uv1_offset" default="Vector3( 0, 0, 0 )"> + <member name="uv1_offset" type="Vector3" setter="set_uv1_offset" getter="get_uv1_offset" default="Vector3(0, 0, 0)"> How much to offset the [code]UV[/code] coordinates. This amount will be added to [code]UV[/code] in the vertex function. This can be used to offset a texture. </member> - <member name="uv1_scale" type="Vector3" setter="set_uv1_scale" getter="get_uv1_scale" default="Vector3( 1, 1, 1 )"> + <member name="uv1_scale" type="Vector3" setter="set_uv1_scale" getter="get_uv1_scale" default="Vector3(1, 1, 1)"> How much to scale the [code]UV[/code] coordinates. This is multiplied by [code]UV[/code] in the vertex function. </member> <member name="uv1_triplanar" type="bool" setter="set_flag" getter="get_flag" default="false"> @@ -385,10 +385,10 @@ <member name="uv1_world_triplanar" type="bool" setter="set_flag" getter="get_flag" default="false"> If [code]true[/code], triplanar mapping for [code]UV[/code] is calculated in world space rather than object local space. See also [member uv1_triplanar]. </member> - <member name="uv2_offset" type="Vector3" setter="set_uv2_offset" getter="get_uv2_offset" default="Vector3( 0, 0, 0 )"> + <member name="uv2_offset" type="Vector3" setter="set_uv2_offset" getter="get_uv2_offset" default="Vector3(0, 0, 0)"> How much to offset the [code]UV2[/code] coordinates. This amount will be added to [code]UV2[/code] in the vertex function. This can be used to offset a texture. </member> - <member name="uv2_scale" type="Vector3" setter="set_uv2_scale" getter="get_uv2_scale" default="Vector3( 1, 1, 1 )"> + <member name="uv2_scale" type="Vector3" setter="set_uv2_scale" getter="get_uv2_scale" default="Vector3(1, 1, 1)"> How much to scale the [code]UV2[/code] coordinates. This is multiplied by [code]UV2[/code] in the vertex function. </member> <member name="uv2_triplanar" type="bool" setter="set_flag" getter="get_flag" default="false"> diff --git a/doc/classes/Basis.xml b/doc/classes/Basis.xml index 14fca04672..bd1abe914d 100644 --- a/doc/classes/Basis.xml +++ b/doc/classes/Basis.xml @@ -155,6 +155,24 @@ <description> </description> </method> + <method name="operator *" qualifiers="operator"> + <return type="Basis"> + </return> + <argument index="0" name="right" type="float"> + </argument> + <description> + This operator multiplies all components of the [Basis], which scales it uniformly. + </description> + </method> + <method name="operator *" qualifiers="operator"> + <return type="Basis"> + </return> + <argument index="0" name="right" type="int"> + </argument> + <description> + This operator multiplies all components of the [Basis], which scales it uniformly. + </description> + </method> <method name="operator ==" qualifiers="operator"> <return type="bool"> </return> @@ -245,28 +263,28 @@ </method> </methods> <members> - <member name="x" type="Vector3" setter="" getter="" default="Vector3( 1, 0, 0 )"> + <member name="x" type="Vector3" setter="" getter="" default="Vector3(1, 0, 0)"> The basis matrix's X vector (column 0). Equivalent to array index [code]0[/code]. </member> - <member name="y" type="Vector3" setter="" getter="" default="Vector3( 0, 1, 0 )"> + <member name="y" type="Vector3" setter="" getter="" default="Vector3(0, 1, 0)"> The basis matrix's Y vector (column 1). Equivalent to array index [code]1[/code]. </member> - <member name="z" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 1 )"> + <member name="z" type="Vector3" setter="" getter="" default="Vector3(0, 0, 1)"> The basis matrix's Z vector (column 2). Equivalent to array index [code]2[/code]. </member> </members> <constants> - <constant name="IDENTITY" value="Basis( 1, 0, 0, 0, 1, 0, 0, 0, 1 )"> + <constant name="IDENTITY" value="Basis(1, 0, 0, 0, 1, 0, 0, 0, 1)"> The identity basis, with no rotation or scaling applied. This is identical to calling [code]Basis()[/code] without any parameters. This constant can be used to make your code clearer, and for consistency with C#. </constant> - <constant name="FLIP_X" value="Basis( -1, 0, 0, 0, 1, 0, 0, 0, 1 )"> + <constant name="FLIP_X" value="Basis(-1, 0, 0, 0, 1, 0, 0, 0, 1)"> The basis that will flip something along the X axis when used in a transformation. </constant> - <constant name="FLIP_Y" value="Basis( 1, 0, 0, 0, -1, 0, 0, 0, 1 )"> + <constant name="FLIP_Y" value="Basis(1, 0, 0, 0, -1, 0, 0, 0, 1)"> The basis that will flip something along the Y axis when used in a transformation. </constant> - <constant name="FLIP_Z" value="Basis( 1, 0, 0, 0, 1, 0, 0, 0, -1 )"> + <constant name="FLIP_Z" value="Basis(1, 0, 0, 0, 1, 0, 0, 0, -1)"> The basis that will flip something along the Z axis when used in a transformation. </constant> </constants> diff --git a/doc/classes/Bone2D.xml b/doc/classes/Bone2D.xml index 93744ddad7..b8d5544d59 100644 --- a/doc/classes/Bone2D.xml +++ b/doc/classes/Bone2D.xml @@ -101,7 +101,7 @@ </method> </methods> <members> - <member name="rest" type="Transform2D" setter="set_rest" getter="get_rest" default="Transform2D( 0, 0, 0, 0, 0, 0 )"> + <member name="rest" type="Transform2D" setter="set_rest" getter="get_rest" default="Transform2D(0, 0, 0, 0, 0, 0)"> Rest transform of the bone. You can reset the node's transforms to this value using [method apply_rest]. </member> </members> diff --git a/doc/classes/BoxMesh.xml b/doc/classes/BoxMesh.xml index 1404477b46..dda5e2f1e5 100644 --- a/doc/classes/BoxMesh.xml +++ b/doc/classes/BoxMesh.xml @@ -13,7 +13,7 @@ <methods> </methods> <members> - <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3( 2, 2, 2 )"> + <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(2, 2, 2)"> The box's width, height and depth. </member> <member name="subdivide_depth" type="int" setter="set_subdivide_depth" getter="get_subdivide_depth" default="0"> diff --git a/doc/classes/BoxShape3D.xml b/doc/classes/BoxShape3D.xml index f5051413ce..5704de905b 100644 --- a/doc/classes/BoxShape3D.xml +++ b/doc/classes/BoxShape3D.xml @@ -14,7 +14,7 @@ <methods> </methods> <members> - <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3( 2, 2, 2 )"> + <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(2, 2, 2)"> The box's width, height and depth. </member> </members> diff --git a/doc/classes/Button.xml b/doc/classes/Button.xml index 51c35b15ce..c9078a4de5 100644 --- a/doc/classes/Button.xml +++ b/doc/classes/Button.xml @@ -116,22 +116,22 @@ <theme_item name="font" type="Font"> [Font] of the [Button]'s text. </theme_item> - <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )"> + <theme_item name="font_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> Default text [Color] of the [Button]. </theme_item> - <theme_item name="font_disabled_color" type="Color" default="Color( 0.9, 0.9, 0.9, 0.2 )"> + <theme_item name="font_disabled_color" type="Color" default="Color(0.9, 0.9, 0.9, 0.2)"> Text [Color] used when the [Button] is disabled. </theme_item> - <theme_item name="font_hover_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )"> + <theme_item name="font_hover_color" type="Color" default="Color(0.94, 0.94, 0.94, 1)"> Text [Color] used when the [Button] is being hovered. </theme_item> - <theme_item name="font_hover_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_hover_pressed_color" type="Color" default="Color(1, 1, 1, 1)"> Text [Color] used when the [Button] is being hovered and pressed. </theme_item> - <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)"> The tint of text outline of the [Button]. </theme_item> - <theme_item name="font_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_pressed_color" type="Color" default="Color(1, 1, 1, 1)"> Text [Color] used when the [Button] is being pressed. </theme_item> <theme_item name="font_size" type="int"> @@ -143,19 +143,19 @@ <theme_item name="hseparation" type="int" default="2"> The horizontal space between [Button]'s icon and text. </theme_item> - <theme_item name="icon_disabled_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="icon_disabled_color" type="Color" default="Color(1, 1, 1, 1)"> Icon modulate [Color] used when the [Button] is disabled. </theme_item> - <theme_item name="icon_hover_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="icon_hover_color" type="Color" default="Color(1, 1, 1, 1)"> Icon modulate [Color] used when the [Button] is being hovered. </theme_item> - <theme_item name="icon_hover_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="icon_hover_pressed_color" type="Color" default="Color(1, 1, 1, 1)"> Icon modulate [Color] used when the [Button] is being hovered and pressed. </theme_item> - <theme_item name="icon_normal_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="icon_normal_color" type="Color" default="Color(1, 1, 1, 1)"> Default icon modulate [Color] of the [Button]. </theme_item> - <theme_item name="icon_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="icon_pressed_color" type="Color" default="Color(1, 1, 1, 1)"> Icon modulate [Color] used when the [Button] is being pressed. </theme_item> <theme_item name="normal" type="StyleBox"> diff --git a/doc/classes/CPUParticles2D.xml b/doc/classes/CPUParticles2D.xml index 9e70978db8..9620e9abd1 100644 --- a/doc/classes/CPUParticles2D.xml +++ b/doc/classes/CPUParticles2D.xml @@ -148,7 +148,7 @@ <member name="anim_speed_random" type="float" setter="set_param_randomness" getter="get_param_randomness" default="0.0"> Animation speed randomness ratio. </member> - <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 1, 1, 1, 1 )"> + <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)"> Each particle's initial color. If [member texture] is defined, it will be multiplied by this color. </member> <member name="color_ramp" type="Gradient" setter="set_color_ramp" getter="get_color_ramp"> @@ -163,7 +163,7 @@ <member name="damping_random" type="float" setter="set_param_randomness" getter="get_param_randomness" default="0.0"> Damping randomness ratio. </member> - <member name="direction" type="Vector2" setter="set_direction" getter="get_direction" default="Vector2( 1, 0 )"> + <member name="direction" type="Vector2" setter="set_direction" getter="get_direction" default="Vector2(1, 0)"> Unit vector specifying the particles' emission direction. </member> <member name="draw_order" type="int" setter="set_draw_order" getter="get_draw_order" enum="CPUParticles2D.DrawOrder" default="0"> @@ -199,7 +199,7 @@ <member name="fract_delta" type="bool" setter="set_fractional_delta" getter="get_fractional_delta" default="true"> If [code]true[/code], results in fractional delta calculation which has a smoother particles display effect. </member> - <member name="gravity" type="Vector2" setter="set_gravity" getter="get_gravity" default="Vector2( 0, 980 )"> + <member name="gravity" type="Vector2" setter="set_gravity" getter="get_gravity" default="Vector2(0, 980)"> Gravity applied to every particle. </member> <member name="hue_variation" type="float" setter="set_param" getter="get_param" default="0.0"> diff --git a/doc/classes/CPUParticles3D.xml b/doc/classes/CPUParticles3D.xml index 0512efa8c2..7509775d20 100644 --- a/doc/classes/CPUParticles3D.xml +++ b/doc/classes/CPUParticles3D.xml @@ -147,7 +147,7 @@ <member name="anim_speed_random" type="float" setter="set_param_randomness" getter="get_param_randomness" default="0.0"> Animation speed randomness ratio. </member> - <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 1, 1, 1, 1 )"> + <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)"> Unused for 3D particles. </member> <member name="color_ramp" type="Gradient" setter="set_color_ramp" getter="get_color_ramp"> @@ -162,7 +162,7 @@ <member name="damping_random" type="float" setter="set_param_randomness" getter="get_param_randomness" default="0.0"> Damping randomness ratio. </member> - <member name="direction" type="Vector3" setter="set_direction" getter="get_direction" default="Vector3( 1, 0, 0 )"> + <member name="direction" type="Vector3" setter="set_direction" getter="get_direction" default="Vector3(1, 0, 0)"> Unit vector specifying the particles' emission direction. </member> <member name="draw_order" type="int" setter="set_draw_order" getter="get_draw_order" enum="CPUParticles3D.DrawOrder" default="0"> @@ -171,13 +171,13 @@ <member name="emission_box_extents" type="Vector3" setter="set_emission_box_extents" getter="get_emission_box_extents"> The rectangle's extents if [member emission_shape] is set to [constant EMISSION_SHAPE_BOX]. </member> - <member name="emission_colors" type="PackedColorArray" setter="set_emission_colors" getter="get_emission_colors" default="PackedColorArray( )"> + <member name="emission_colors" type="PackedColorArray" setter="set_emission_colors" getter="get_emission_colors" default="PackedColorArray()"> Sets the [Color]s to modulate particles by when using [constant EMISSION_SHAPE_POINTS] or [constant EMISSION_SHAPE_DIRECTED_POINTS]. </member> <member name="emission_normals" type="PackedVector3Array" setter="set_emission_normals" getter="get_emission_normals"> Sets the direction the particles will be emitted in when using [constant EMISSION_SHAPE_DIRECTED_POINTS]. </member> - <member name="emission_points" type="PackedVector3Array" setter="set_emission_points" getter="get_emission_points" default="PackedVector3Array( )"> + <member name="emission_points" type="PackedVector3Array" setter="set_emission_points" getter="get_emission_points" default="PackedVector3Array()"> Sets the initial positions to spawn particles when using [constant EMISSION_SHAPE_POINTS] or [constant EMISSION_SHAPE_DIRECTED_POINTS]. </member> <member name="emission_shape" type="int" setter="set_emission_shape" getter="get_emission_shape" enum="CPUParticles3D.EmissionShape" default="0"> @@ -201,7 +201,7 @@ <member name="fract_delta" type="bool" setter="set_fractional_delta" getter="get_fractional_delta" default="true"> If [code]true[/code], results in fractional delta calculation which has a smoother particles display effect. </member> - <member name="gravity" type="Vector3" setter="set_gravity" getter="get_gravity" default="Vector3( 0, -9.8, 0 )"> + <member name="gravity" type="Vector3" setter="set_gravity" getter="get_gravity" default="Vector3(0, -9.8, 0)"> Gravity applied to every particle. </member> <member name="hue_variation" type="float" setter="set_param" getter="get_param" default="0.0"> diff --git a/doc/classes/CallbackTweener.xml b/doc/classes/CallbackTweener.xml new file mode 100644 index 0000000000..8ac285c3df --- /dev/null +++ b/doc/classes/CallbackTweener.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="CallbackTweener" inherits="Tweener" version="4.0"> + <brief_description> + Calls the specified method after optional delay. + </brief_description> + <description> + [CallbackTweener] is used to call a method in a tweening sequence. See [method Tween.tween_callback] for more usage information. + [b]Note:[/b] [method Tween.tween_callback] is the only correct way to create [CallbackTweener]. Any [CallbackTweener] created manually will not function correctly. + </description> + <tutorials> + </tutorials> + <methods> + <method name="set_delay"> + <return type="CallbackTweener"> + </return> + <argument index="0" name="delay" type="float"> + </argument> + <description> + Makes the callback call delayed by given time in seconds. Example: + [codeblock] + var tween = get_tree().create_tween() + tween.tween_callback(queue_free).set_delay(2) #this will call queue_free() after 2 seconds + [/codeblock] + </description> + </method> + </methods> + <constants> + </constants> +</class> diff --git a/doc/classes/Camera2D.xml b/doc/classes/Camera2D.xml index d40567bdcb..bf1a9cc929 100644 --- a/doc/classes/Camera2D.xml +++ b/doc/classes/Camera2D.xml @@ -165,7 +165,7 @@ <member name="limit_top" type="int" setter="set_limit" getter="get_limit" default="-10000000"> Top scroll limit in pixels. The camera stops moving when reaching this value. </member> - <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2( 0, 0 )"> + <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2(0, 0)"> The camera's offset, useful for looking around or camera shake animations. </member> <member name="process_callback" type="int" setter="set_process_callback" getter="get_process_callback" enum="Camera2D.Camera2DProcessCallback" default="1"> @@ -180,7 +180,7 @@ <member name="smoothing_speed" type="float" setter="set_follow_smoothing" getter="get_follow_smoothing" default="5.0"> Speed in pixels per second of the camera's smoothing effect when [member smoothing_enabled] is [code]true[/code]. </member> - <member name="zoom" type="Vector2" setter="set_zoom" getter="get_zoom" default="Vector2( 1, 1 )"> + <member name="zoom" type="Vector2" setter="set_zoom" getter="get_zoom" default="Vector2(1, 1)"> The camera's zoom relative to the viewport. Values larger than [code]Vector2(1, 1)[/code] zoom out and smaller values zoom in. For an example, use [code]Vector2(0.5, 0.5)[/code] for a 2× zoom-in, and [code]Vector2(4, 4)[/code] for a 4× zoom-out. </member> </members> diff --git a/doc/classes/Camera3D.xml b/doc/classes/Camera3D.xml index 016eb05308..afba478a20 100644 --- a/doc/classes/Camera3D.xml +++ b/doc/classes/Camera3D.xml @@ -209,7 +209,7 @@ - ~107.51 degrees in a 16:9 viewport - ~121.63 degrees in a 21:9 viewport </member> - <member name="frustum_offset" type="Vector2" setter="set_frustum_offset" getter="get_frustum_offset" default="Vector2( 0, 0 )"> + <member name="frustum_offset" type="Vector2" setter="set_frustum_offset" getter="get_frustum_offset" default="Vector2(0, 0)"> The camera's frustum offset. This can be changed from the default to create "tilted frustum" effects such as [url=https://zdoom.org/wiki/Y-shearing]Y-shearing[/url]. </member> <member name="h_offset" type="float" setter="set_h_offset" getter="get_h_offset" default="0.0"> diff --git a/doc/classes/CanvasItem.xml b/doc/classes/CanvasItem.xml index f15bc14be3..d0950ae741 100644 --- a/doc/classes/CanvasItem.xml +++ b/doc/classes/CanvasItem.xml @@ -75,11 +75,11 @@ </argument> <argument index="4" name="size" type="int" default="-1"> </argument> - <argument index="5" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="5" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> </argument> <argument index="6" name="outline_size" type="int" default="0"> </argument> - <argument index="7" name="outline_modulate" type="Color" default="Color( 1, 1, 1, 0 )"> + <argument index="7" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)"> </argument> <description> Draws a string character using a custom font. Returns the advance, depending on the character width and kerning with an optional next character. @@ -105,7 +105,7 @@ </argument> <argument index="1" name="color" type="Color"> </argument> - <argument index="2" name="uvs" type="PackedVector2Array" default="PackedVector2Array( )"> + <argument index="2" name="uvs" type="PackedVector2Array" default="PackedVector2Array()"> </argument> <argument index="3" name="texture" type="Texture2D" default="null"> </argument> @@ -142,9 +142,9 @@ </argument> <argument index="1" name="texture" type="Texture2D"> </argument> - <argument index="2" name="transform" type="Transform2D" default="Transform2D( 1, 0, 0, 1, 0, 0 )"> + <argument index="2" name="transform" type="Transform2D" default="Transform2D(1, 0, 0, 1, 0, 0)"> </argument> - <argument index="3" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> </argument> <description> Draws a [Mesh] in 2D, using the provided texture. See [MeshInstance2D] for related documentation. @@ -193,11 +193,11 @@ </argument> <argument index="6" name="size" type="int" default="-1"> </argument> - <argument index="7" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="7" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> </argument> <argument index="8" name="outline_size" type="int" default="0"> </argument> - <argument index="9" name="outline_modulate" type="Color" default="Color( 1, 1, 1, 0 )"> + <argument index="9" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)"> </argument> <argument index="10" name="flags" type="int" default="51"> </argument> @@ -223,7 +223,7 @@ </argument> <argument index="1" name="colors" type="PackedColorArray"> </argument> - <argument index="2" name="uvs" type="PackedVector2Array" default="PackedVector2Array( )"> + <argument index="2" name="uvs" type="PackedVector2Array" default="PackedVector2Array()"> </argument> <argument index="3" name="texture" type="Texture2D" default="null"> </argument> @@ -301,7 +301,7 @@ </argument> <argument index="1" name="rotation" type="float" default="0.0"> </argument> - <argument index="2" name="scale" type="Vector2" default="Vector2( 1, 1 )"> + <argument index="2" name="scale" type="Vector2" default="Vector2(1, 1)"> </argument> <description> Sets a custom transform for drawing via components. Anything drawn afterwards will be transformed by this. @@ -331,11 +331,11 @@ </argument> <argument index="5" name="size" type="int" default="-1"> </argument> - <argument index="6" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="6" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> </argument> <argument index="7" name="outline_size" type="int" default="0"> </argument> - <argument index="8" name="outline_modulate" type="Color" default="Color( 1, 1, 1, 0 )"> + <argument index="8" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)"> </argument> <argument index="9" name="flags" type="int" default="3"> </argument> @@ -381,7 +381,7 @@ </argument> <argument index="1" name="position" type="Vector2"> </argument> - <argument index="2" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="2" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> </argument> <description> Draws a texture at a given position. @@ -396,7 +396,7 @@ </argument> <argument index="2" name="tile" type="bool"> </argument> - <argument index="3" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> </argument> <argument index="4" name="transpose" type="bool" default="false"> </argument> @@ -413,7 +413,7 @@ </argument> <argument index="2" name="src_rect" type="Rect2"> </argument> - <argument index="3" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> </argument> <argument index="4" name="transpose" type="bool" default="false"> </argument> @@ -595,10 +595,10 @@ <member name="material" type="Material" setter="set_material" getter="get_material"> The material applied to textures on this [CanvasItem]. </member> - <member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color( 1, 1, 1, 1 )"> + <member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color(1, 1, 1, 1)"> The color applied to textures on this [CanvasItem]. </member> - <member name="self_modulate" type="Color" setter="set_self_modulate" getter="get_self_modulate" default="Color( 1, 1, 1, 1 )"> + <member name="self_modulate" type="Color" setter="set_self_modulate" getter="get_self_modulate" default="Color(1, 1, 1, 1)"> The color applied to textures on this [CanvasItem]. This is not inherited by children [CanvasItem]s. </member> <member name="show_behind_parent" type="bool" setter="set_draw_behind_parent" getter="is_draw_behind_parent_enabled" default="false"> diff --git a/doc/classes/CanvasLayer.xml b/doc/classes/CanvasLayer.xml index 9d952cdba3..f4c04d7bca 100644 --- a/doc/classes/CanvasLayer.xml +++ b/doc/classes/CanvasLayer.xml @@ -33,7 +33,7 @@ <member name="layer" type="int" setter="set_layer" getter="get_layer" default="1"> Layer index for draw order. Lower values are drawn first. </member> - <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2( 0, 0 )"> + <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2(0, 0)"> The layer's base offset. </member> <member name="rotation" type="float" setter="set_rotation" getter="get_rotation" default="0.0"> @@ -42,10 +42,10 @@ <member name="rotation_degrees" type="float" setter="set_rotation_degrees" getter="get_rotation_degrees" default="0.0"> The layer's rotation in degrees. </member> - <member name="scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2( 1, 1 )"> + <member name="scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2(1, 1)"> The layer's scale. </member> - <member name="transform" type="Transform2D" setter="set_transform" getter="get_transform" default="Transform2D( 1, 0, 0, 1, 0, 0 )"> + <member name="transform" type="Transform2D" setter="set_transform" getter="get_transform" default="Transform2D(1, 0, 0, 1, 0, 0)"> The layer's transform. </member> </members> diff --git a/doc/classes/CanvasModulate.xml b/doc/classes/CanvasModulate.xml index 19f8912cd8..3540fa423f 100644 --- a/doc/classes/CanvasModulate.xml +++ b/doc/classes/CanvasModulate.xml @@ -11,7 +11,7 @@ <methods> </methods> <members> - <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 1, 1, 1, 1 )"> + <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)"> The tint color to apply. </member> </members> diff --git a/doc/classes/CanvasTexture.xml b/doc/classes/CanvasTexture.xml index 0ca132746b..f7147d9f0b 100644 --- a/doc/classes/CanvasTexture.xml +++ b/doc/classes/CanvasTexture.xml @@ -13,7 +13,7 @@ </member> <member name="normal_texture" type="Texture2D" setter="set_normal_texture" getter="get_normal_texture"> </member> - <member name="specular_color" type="Color" setter="set_specular_color" getter="get_specular_color" default="Color( 1, 1, 1, 1 )"> + <member name="specular_color" type="Color" setter="set_specular_color" getter="get_specular_color" default="Color(1, 1, 1, 1)"> </member> <member name="specular_shininess" type="float" setter="set_specular_shininess" getter="get_specular_shininess" default="1.0"> </member> diff --git a/doc/classes/CharFXTransform.xml b/doc/classes/CharFXTransform.xml index 7a6a18f532..1f63b530b1 100644 --- a/doc/classes/CharFXTransform.xml +++ b/doc/classes/CharFXTransform.xml @@ -13,7 +13,7 @@ <methods> </methods> <members> - <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 0, 0, 0, 1 )"> + <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(0, 0, 0, 1)"> The color the character will be drawn with. </member> <member name="elapsed_time" type="float" setter="set_elapsed_time" getter="get_elapsed_time" default="0.0"> @@ -33,13 +33,13 @@ <member name="glyph_index" type="int" setter="set_glyph_index" getter="get_glyph_index" default="0"> Font specific glyph index. </member> - <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2( 0, 0 )"> + <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2(0, 0)"> The position offset the character will be drawn with (in pixels). </member> <member name="outline" type="bool" setter="set_outline" getter="is_outline" default="false"> If [code]true[/code], FX transform is called for outline drawing. Setting this property won't affect drawing. </member> - <member name="range" type="Vector2i" setter="set_range" getter="get_range" default="Vector2i( 0, 0 )"> + <member name="range" type="Vector2i" setter="set_range" getter="get_range" default="Vector2i(0, 0)"> Absolute character range in the string, corresponding to the glyph. Setting this property won't affect drawing. </member> <member name="visible" type="bool" setter="set_visibility" getter="is_visible" default="true"> diff --git a/doc/classes/CharacterBody2D.xml b/doc/classes/CharacterBody2D.xml index 0e6ca073a7..fbe5c34d7d 100644 --- a/doc/classes/CharacterBody2D.xml +++ b/doc/classes/CharacterBody2D.xml @@ -107,7 +107,7 @@ <member name="infinite_inertia" type="bool" setter="set_infinite_inertia_enabled" getter="is_infinite_inertia_enabled" default="true"> If [code]true[/code], the body will be able to push [RigidBody2D] nodes when calling [method move_and_slide], but it also won't detect any collisions with them. If [code]false[/code], it will interact with [RigidBody2D] nodes like with [StaticBody2D]. </member> - <member name="linear_velocity" type="Vector2" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector2( 0, 0 )"> + <member name="linear_velocity" type="Vector2" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector2(0, 0)"> Current velocity vector in pixels per second, used and modified during calls to [method move_and_slide]. </member> <member name="max_slides" type="int" setter="set_max_slides" getter="get_max_slides" default="4"> @@ -116,14 +116,14 @@ <member name="motion/sync_to_physics" type="bool" setter="set_sync_to_physics" getter="is_sync_to_physics_enabled" default="false"> If [code]true[/code], the body's movement will be synchronized to the physics frame. This is useful when animating movement via [AnimationPlayer], for example on moving platforms. Do [b]not[/b] use together with [method move_and_slide] or [method PhysicsBody2D.move_and_collide] functions. </member> - <member name="snap" type="Vector2" setter="set_snap" getter="get_snap" default="Vector2( 0, 0 )"> + <member name="snap" type="Vector2" setter="set_snap" getter="get_snap" default="Vector2(0, 0)"> When set to a value different from [code]Vector2(0, 0)[/code], the body is kept attached to slopes when calling [method move_and_slide]. As long as the [code]snap[/code] vector is in contact with the ground, the body will remain attached to the surface. This means you must disable snap in order to jump, for example. You can do this by setting [code]snap[/code] to [code]Vector2(0, 0)[/code]. </member> <member name="stop_on_slope" type="bool" setter="set_stop_on_slope_enabled" getter="is_stop_on_slope_enabled" default="false"> If [code]true[/code], the body will not slide on slopes when you include gravity in [code]linear_velocity[/code] when calling [method move_and_slide] and the body is standing still. </member> - <member name="up_direction" type="Vector2" setter="set_up_direction" getter="get_up_direction" default="Vector2( 0, -1 )"> + <member name="up_direction" type="Vector2" setter="set_up_direction" getter="get_up_direction" default="Vector2(0, -1)"> Direction vector used to determine what is a wall and what is a floor (or a ceiling), rather than a wall, when calling [method move_and_slide]. Defaults to [code]Vector2.UP[/code]. If set to [code]Vector2(0, 0)[/code], everything is considered a wall. This is useful for topdown games. </member> </members> diff --git a/doc/classes/CharacterBody3D.xml b/doc/classes/CharacterBody3D.xml index 790edfcad1..f6c3d68b3c 100644 --- a/doc/classes/CharacterBody3D.xml +++ b/doc/classes/CharacterBody3D.xml @@ -93,20 +93,20 @@ <member name="infinite_inertia" type="bool" setter="set_infinite_inertia_enabled" getter="is_infinite_inertia_enabled" default="true"> If [code]true[/code], the body will be able to push [RigidBody3D] nodes when calling [method move_and_slide], but it also won't detect any collisions with them. If [code]false[/code], it will interact with [RigidBody3D] nodes like with [StaticBody3D]. </member> - <member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector3( 0, 0, 0 )"> + <member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector3(0, 0, 0)"> Current velocity vector (typically meters per second), used and modified during calls to [method move_and_slide]. </member> <member name="max_slides" type="int" setter="set_max_slides" getter="get_max_slides" default="4"> Maximum number of times the body can change direction before it stops when calling [method move_and_slide]. </member> - <member name="snap" type="Vector3" setter="set_snap" getter="get_snap" default="Vector3( 0, 0, 0 )"> + <member name="snap" type="Vector3" setter="set_snap" getter="get_snap" default="Vector3(0, 0, 0)"> When set to a value different from [code]Vector3(0, 0, 0)[/code], the body is kept attached to slopes when calling [method move_and_slide]. As long as the [code]snap[/code] vector is in contact with the ground, the body will remain attached to the surface. This means you must disable snap in order to jump, for example. You can do this by setting [code]snap[/code] to [code]Vector3(0, 0, 0)[/code]. </member> <member name="stop_on_slope" type="bool" setter="set_stop_on_slope_enabled" getter="is_stop_on_slope_enabled" default="false"> If [code]true[/code], the body will not slide on slopes when you include gravity in [code]linear_velocity[/code] when calling [method move_and_slide] and the body is standing still. </member> - <member name="up_direction" type="Vector3" setter="set_up_direction" getter="get_up_direction" default="Vector3( 0, 1, 0 )"> + <member name="up_direction" type="Vector3" setter="set_up_direction" getter="get_up_direction" default="Vector3(0, 1, 0)"> Direction vector used to determine what is a wall and what is a floor (or a ceiling), rather than a wall, when calling [method move_and_slide]. Defaults to [code]Vector3.UP[/code]. If set to [code]Vector3(0, 0, 0)[/code], everything is considered a wall. This is useful for topdown games. </member> </members> diff --git a/doc/classes/CheckBox.xml b/doc/classes/CheckBox.xml index 05e412e9da..90f3725172 100644 --- a/doc/classes/CheckBox.xml +++ b/doc/classes/CheckBox.xml @@ -35,22 +35,22 @@ <theme_item name="font" type="Font"> The [Font] to use for the [CheckBox] text. </theme_item> - <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )"> + <theme_item name="font_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> The [CheckBox] text's font color. </theme_item> - <theme_item name="font_disabled_color" type="Color" default="Color( 0.9, 0.9, 0.9, 0.2 )"> + <theme_item name="font_disabled_color" type="Color" default="Color(0.9, 0.9, 0.9, 0.2)"> The [CheckBox] text's font color when it's disabled. </theme_item> - <theme_item name="font_hover_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )"> + <theme_item name="font_hover_color" type="Color" default="Color(0.94, 0.94, 0.94, 1)"> The [CheckBox] text's font color when it's hovered. </theme_item> - <theme_item name="font_hover_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_hover_pressed_color" type="Color" default="Color(1, 1, 1, 1)"> The [CheckBox] text's font color when it's hovered and pressed. </theme_item> - <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)"> The tint of text outline of the [CheckBox]. </theme_item> - <theme_item name="font_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_pressed_color" type="Color" default="Color(1, 1, 1, 1)"> The [CheckBox] text's font color when it's pressed. </theme_item> <theme_item name="font_size" type="int"> diff --git a/doc/classes/CheckButton.xml b/doc/classes/CheckButton.xml index 46e590a115..7fa7093b32 100644 --- a/doc/classes/CheckButton.xml +++ b/doc/classes/CheckButton.xml @@ -30,22 +30,22 @@ <theme_item name="font" type="Font"> The [Font] to use for the [CheckButton] text. </theme_item> - <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )"> + <theme_item name="font_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> The [CheckButton] text's font color. </theme_item> - <theme_item name="font_disabled_color" type="Color" default="Color( 0.9, 0.9, 0.9, 0.2 )"> + <theme_item name="font_disabled_color" type="Color" default="Color(0.9, 0.9, 0.9, 0.2)"> The [CheckButton] text's font color when it's disabled. </theme_item> - <theme_item name="font_hover_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )"> + <theme_item name="font_hover_color" type="Color" default="Color(0.94, 0.94, 0.94, 1)"> The [CheckButton] text's font color when it's hovered. </theme_item> - <theme_item name="font_hover_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_hover_pressed_color" type="Color" default="Color(1, 1, 1, 1)"> The [CheckButton] text's font color when it's hovered and pressed. </theme_item> - <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)"> The tint of text outline of the [CheckButton]. </theme_item> - <theme_item name="font_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_pressed_color" type="Color" default="Color(1, 1, 1, 1)"> The [CheckButton] text's font color when it's pressed. </theme_item> <theme_item name="font_size" type="int"> diff --git a/doc/classes/CodeEdit.xml b/doc/classes/CodeEdit.xml index 1250350971..c7dbd86c55 100644 --- a/doc/classes/CodeEdit.xml +++ b/doc/classes/CodeEdit.xml @@ -45,7 +45,7 @@ </argument> <argument index="2" name="insert_text" type="String"> </argument> - <argument index="3" name="text_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="3" name="text_color" type="Color" default="Color(1, 1, 1, 1)"> </argument> <argument index="4" name="icon" type="Resource" default="null"> </argument> @@ -456,13 +456,13 @@ <member name="code_completion_enabled" type="bool" setter="set_code_completion_enabled" getter="is_code_completion_enabled" default="false"> Sets whether code completion is allowed. </member> - <member name="code_completion_prefixes" type="String[]" setter="set_code_completion_prefixes" getter="get_code_comletion_prefixes" default="[ ]"> + <member name="code_completion_prefixes" type="String[]" setter="set_code_completion_prefixes" getter="get_code_comletion_prefixes" default="[]"> Sets prefixes that will trigger code completion. </member> - <member name="delimiter_comments" type="String[]" setter="set_comment_delimiters" getter="get_comment_delimiters" default="[ ]"> + <member name="delimiter_comments" type="String[]" setter="set_comment_delimiters" getter="get_comment_delimiters" default="[]"> Sets the comment delimiters. All existing comment delimiters will be removed. </member> - <member name="delimiter_strings" type="String[]" setter="set_string_delimiters" getter="get_string_delimiters" default="[ ]"> + <member name="delimiter_strings" type="String[]" setter="set_string_delimiters" getter="get_string_delimiters" default="[]"> Sets the string delimiters. All existing string delimiters will be removed. </member> <member name="draw_bookmarks" type="bool" setter="set_draw_bookmarks_gutter" getter="is_drawing_bookmarks_gutter" default="false"> @@ -479,7 +479,7 @@ <member name="line_folding" type="bool" setter="set_line_folding_enabled" getter="is_line_folding_enabled" default="true"> Sets whether line folding is allowed. </member> - <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" override="true" default="[ ]" /> + <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" override="true" default="[]" /> <member name="text_direction" type="int" setter="set_text_direction" getter="get_text_direction" override="true" enum="Control.TextDirection" default="1" /> <member name="zero_pad_line_numbers" type="bool" setter="set_line_numbers_zero_padded" getter="is_line_numbers_zero_padded" default="false"> </member> @@ -520,49 +520,49 @@ </constant> </constants> <theme_items> - <theme_item name="background_color" type="Color" default="Color( 0, 0, 0, 0 )"> + <theme_item name="background_color" type="Color" default="Color(0, 0, 0, 0)"> </theme_item> <theme_item name="bookmark" type="Texture2D"> </theme_item> - <theme_item name="bookmark_color" type="Color" default="Color( 0.5, 0.64, 1, 0.8 )"> + <theme_item name="bookmark_color" type="Color" default="Color(0.5, 0.64, 1, 0.8)"> </theme_item> - <theme_item name="brace_mismatch_color" type="Color" default="Color( 1, 0.2, 0.2, 1 )"> + <theme_item name="brace_mismatch_color" type="Color" default="Color(1, 0.2, 0.2, 1)"> </theme_item> <theme_item name="breakpoint" type="Texture2D"> </theme_item> - <theme_item name="breakpoint_color" type="Color" default="Color( 0.9, 0.29, 0.3, 1 )"> + <theme_item name="breakpoint_color" type="Color" default="Color(0.9, 0.29, 0.3, 1)"> </theme_item> <theme_item name="can_fold" type="Texture2D"> </theme_item> - <theme_item name="caret_background_color" type="Color" default="Color( 0, 0, 0, 1 )"> + <theme_item name="caret_background_color" type="Color" default="Color(0, 0, 0, 1)"> </theme_item> - <theme_item name="caret_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )"> + <theme_item name="caret_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> </theme_item> - <theme_item name="code_folding_color" type="Color" default="Color( 0.8, 0.8, 0.8, 0.8 )"> + <theme_item name="code_folding_color" type="Color" default="Color(0.8, 0.8, 0.8, 0.8)"> </theme_item> <theme_item name="completion" type="StyleBox"> </theme_item> - <theme_item name="completion_background_color" type="Color" default="Color( 0.17, 0.16, 0.2, 1 )"> + <theme_item name="completion_background_color" type="Color" default="Color(0.17, 0.16, 0.2, 1)"> </theme_item> - <theme_item name="completion_existing_color" type="Color" default="Color( 0.87, 0.87, 0.87, 0.13 )"> + <theme_item name="completion_existing_color" type="Color" default="Color(0.87, 0.87, 0.87, 0.13)"> </theme_item> - <theme_item name="completion_font_color" type="Color" default="Color( 0.67, 0.67, 0.67, 1 )"> + <theme_item name="completion_font_color" type="Color" default="Color(0.67, 0.67, 0.67, 1)"> </theme_item> <theme_item name="completion_lines" type="int" default="7"> </theme_item> <theme_item name="completion_max_width" type="int" default="50"> </theme_item> - <theme_item name="completion_scroll_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="completion_scroll_color" type="Color" default="Color(1, 1, 1, 1)"> </theme_item> <theme_item name="completion_scroll_width" type="int" default="3"> </theme_item> - <theme_item name="completion_selected_color" type="Color" default="Color( 0.26, 0.26, 0.27, 1 )"> + <theme_item name="completion_selected_color" type="Color" default="Color(0.26, 0.26, 0.27, 1)"> </theme_item> - <theme_item name="current_line_color" type="Color" default="Color( 0.25, 0.25, 0.26, 0.8 )"> + <theme_item name="current_line_color" type="Color" default="Color(0.25, 0.25, 0.26, 0.8)"> </theme_item> <theme_item name="executing_line" type="Texture2D"> </theme_item> - <theme_item name="executing_line_color" type="Color" default="Color( 0.98, 0.89, 0.27, 1 )"> + <theme_item name="executing_line_color" type="Color" default="Color(0.98, 0.89, 0.27, 1)"> </theme_item> <theme_item name="focus" type="StyleBox"> </theme_item> @@ -572,19 +572,19 @@ </theme_item> <theme_item name="font" type="Font"> </theme_item> - <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )"> + <theme_item name="font_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> </theme_item> - <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)"> The tint of text outline of the [CodeEdit]. </theme_item> - <theme_item name="font_readonly_color" type="Color" default="Color( 0.88, 0.88, 0.88, 0.5 )"> + <theme_item name="font_readonly_color" type="Color" default="Color(0.88, 0.88, 0.88, 0.5)"> </theme_item> - <theme_item name="font_selected_color" type="Color" default="Color( 0, 0, 0, 1 )"> + <theme_item name="font_selected_color" type="Color" default="Color(0, 0, 0, 1)"> </theme_item> <theme_item name="font_size" type="int"> Font size of the [CodeEdit]'s text. </theme_item> - <theme_item name="line_number_color" type="Color" default="Color( 0.67, 0.67, 0.67, 0.4 )"> + <theme_item name="line_number_color" type="Color" default="Color(0.67, 0.67, 0.67, 0.4)"> </theme_item> <theme_item name="line_spacing" type="int" default="4"> </theme_item> @@ -595,15 +595,15 @@ </theme_item> <theme_item name="read_only" type="StyleBox"> </theme_item> - <theme_item name="safe_line_number_color" type="Color" default="Color( 0.67, 0.78, 0.67, 0.6 )"> + <theme_item name="safe_line_number_color" type="Color" default="Color(0.67, 0.78, 0.67, 0.6)"> </theme_item> - <theme_item name="selection_color" type="Color" default="Color( 0.49, 0.49, 0.49, 1 )"> + <theme_item name="selection_color" type="Color" default="Color(0.49, 0.49, 0.49, 1)"> </theme_item> <theme_item name="space" type="Texture2D"> </theme_item> <theme_item name="tab" type="Texture2D"> </theme_item> - <theme_item name="word_highlighted_color" type="Color" default="Color( 0.8, 0.9, 0.9, 0.15 )"> + <theme_item name="word_highlighted_color" type="Color" default="Color(0.8, 0.9, 0.9, 0.15)"> </theme_item> </theme_items> </class> diff --git a/doc/classes/CodeHighlighter.xml b/doc/classes/CodeHighlighter.xml index f078e4e5b0..0406c25ffd 100644 --- a/doc/classes/CodeHighlighter.xml +++ b/doc/classes/CodeHighlighter.xml @@ -149,7 +149,7 @@ <member name="color_regions" type="Dictionary" setter="set_color_regions" getter="get_color_regions" default="{}"> Sets the color regions. All existing regions will be removed. The [Dictionary] key is the region start and end key, separated by a space. The value is the region color. </member> - <member name="function_color" type="Color" setter="set_function_color" getter="get_function_color" default="Color( 0, 0, 0, 1 )"> + <member name="function_color" type="Color" setter="set_function_color" getter="get_function_color" default="Color(0, 0, 0, 1)"> Sets color for functions. A function is a non-keyword string followed by a '('. </member> <member name="keyword_colors" type="Dictionary" setter="set_keyword_colors" getter="get_keyword_colors" default="{}"> @@ -158,13 +158,13 @@ <member name="member_keyword_colors" type="Dictionary" setter="set_member_keyword_colors" getter="get_member_keyword_colors" default="{}"> Sets the member keyword colors. All existing member keyword will be removed. The [Dictionary] key is the member keyword. The value is the member keyword color. </member> - <member name="member_variable_color" type="Color" setter="set_member_variable_color" getter="get_member_variable_color" default="Color( 0, 0, 0, 1 )"> + <member name="member_variable_color" type="Color" setter="set_member_variable_color" getter="get_member_variable_color" default="Color(0, 0, 0, 1)"> Sets color for member variables. A member variable is non-keyword, non-function string proceeded with a '.'. </member> - <member name="number_color" type="Color" setter="set_number_color" getter="get_number_color" default="Color( 0, 0, 0, 1 )"> + <member name="number_color" type="Color" setter="set_number_color" getter="get_number_color" default="Color(0, 0, 0, 1)"> Sets the color for numbers. </member> - <member name="symbol_color" type="Color" setter="set_symbol_color" getter="get_symbol_color" default="Color( 0, 0, 0, 1 )"> + <member name="symbol_color" type="Color" setter="set_symbol_color" getter="get_symbol_color" default="Color(0, 0, 0, 1)"> Sets the color for symbols. </member> </members> diff --git a/doc/classes/CollisionPolygon2D.xml b/doc/classes/CollisionPolygon2D.xml index 242cdb8c80..4607ab3fbd 100644 --- a/doc/classes/CollisionPolygon2D.xml +++ b/doc/classes/CollisionPolygon2D.xml @@ -23,7 +23,7 @@ <member name="one_way_collision_margin" type="float" setter="set_one_way_collision_margin" getter="get_one_way_collision_margin" default="1.0"> The margin used for one-way collision (in pixels). Higher values will make the shape thicker, and work better for colliders that enter the polygon at a high velocity. </member> - <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array( )"> + <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array()"> The polygon's list of vertices. The final point will be connected to the first. The returned value is a clone of the [PackedVector2Array], not a reference. </member> </members> diff --git a/doc/classes/CollisionPolygon3D.xml b/doc/classes/CollisionPolygon3D.xml index 38f4c5fe5c..cf0e55e712 100644 --- a/doc/classes/CollisionPolygon3D.xml +++ b/doc/classes/CollisionPolygon3D.xml @@ -20,7 +20,7 @@ <member name="margin" type="float" setter="set_margin" getter="get_margin" default="0.04"> The collision margin for the generated [Shape3D]. See [member Shape3D.margin] for more details. </member> - <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array( )"> + <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array()"> Array of vertices which define the polygon. [b]Note:[/b] The returned value is a copy of the original. Methods which mutate the size or properties of the return value will not impact the original polygon. To change properties of the polygon, assign it to a temporary variable and make changes before reassigning the [code]polygon[/code] member. </member> diff --git a/doc/classes/Color.xml b/doc/classes/Color.xml index ddff92e6fc..29c21b3213 100644 --- a/doc/classes/Color.xml +++ b/doc/classes/Color.xml @@ -139,9 +139,9 @@ <method name="clamp" qualifiers="const"> <return type="Color"> </return> - <argument index="0" name="min" type="Color" default="Color( 0, 0, 0, 0 )"> + <argument index="0" name="min" type="Color" default="Color(0, 0, 0, 0)"> </argument> - <argument index="1" name="max" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="1" name="max" type="Color" default="Color(1, 1, 1, 1)"> </argument> <description> Returns a new color with all components clamped between the components of [code]min[/code] and [code]max[/code], by running [method @GlobalScope.clamp] on each component. @@ -575,442 +575,442 @@ </member> </members> <constants> - <constant name="ALICE_BLUE" value="Color( 0.94, 0.97, 1, 1 )"> + <constant name="ALICE_BLUE" value="Color(0.94, 0.97, 1, 1)"> Alice blue color. </constant> - <constant name="ANTIQUE_WHITE" value="Color( 0.98, 0.92, 0.84, 1 )"> + <constant name="ANTIQUE_WHITE" value="Color(0.98, 0.92, 0.84, 1)"> Antique white color. </constant> - <constant name="AQUA" value="Color( 0, 1, 1, 1 )"> + <constant name="AQUA" value="Color(0, 1, 1, 1)"> Aqua color. </constant> - <constant name="AQUAMARINE" value="Color( 0.5, 1, 0.83, 1 )"> + <constant name="AQUAMARINE" value="Color(0.5, 1, 0.83, 1)"> Aquamarine color. </constant> - <constant name="AZURE" value="Color( 0.94, 1, 1, 1 )"> + <constant name="AZURE" value="Color(0.94, 1, 1, 1)"> Azure color. </constant> - <constant name="BEIGE" value="Color( 0.96, 0.96, 0.86, 1 )"> + <constant name="BEIGE" value="Color(0.96, 0.96, 0.86, 1)"> Beige color. </constant> - <constant name="BISQUE" value="Color( 1, 0.89, 0.77, 1 )"> + <constant name="BISQUE" value="Color(1, 0.89, 0.77, 1)"> Bisque color. </constant> - <constant name="BLACK" value="Color( 0, 0, 0, 1 )"> + <constant name="BLACK" value="Color(0, 0, 0, 1)"> Black color. </constant> - <constant name="BLANCHED_ALMOND" value="Color( 1, 0.92, 0.8, 1 )"> + <constant name="BLANCHED_ALMOND" value="Color(1, 0.92, 0.8, 1)"> Blanched almond color. </constant> - <constant name="BLUE" value="Color( 0, 0, 1, 1 )"> + <constant name="BLUE" value="Color(0, 0, 1, 1)"> Blue color. </constant> - <constant name="BLUE_VIOLET" value="Color( 0.54, 0.17, 0.89, 1 )"> + <constant name="BLUE_VIOLET" value="Color(0.54, 0.17, 0.89, 1)"> Blue violet color. </constant> - <constant name="BROWN" value="Color( 0.65, 0.16, 0.16, 1 )"> + <constant name="BROWN" value="Color(0.65, 0.16, 0.16, 1)"> Brown color. </constant> - <constant name="BURLYWOOD" value="Color( 0.87, 0.72, 0.53, 1 )"> + <constant name="BURLYWOOD" value="Color(0.87, 0.72, 0.53, 1)"> Burlywood color. </constant> - <constant name="CADET_BLUE" value="Color( 0.37, 0.62, 0.63, 1 )"> + <constant name="CADET_BLUE" value="Color(0.37, 0.62, 0.63, 1)"> Cadet blue color. </constant> - <constant name="CHARTREUSE" value="Color( 0.5, 1, 0, 1 )"> + <constant name="CHARTREUSE" value="Color(0.5, 1, 0, 1)"> Chartreuse color. </constant> - <constant name="CHOCOLATE" value="Color( 0.82, 0.41, 0.12, 1 )"> + <constant name="CHOCOLATE" value="Color(0.82, 0.41, 0.12, 1)"> Chocolate color. </constant> - <constant name="CORAL" value="Color( 1, 0.5, 0.31, 1 )"> + <constant name="CORAL" value="Color(1, 0.5, 0.31, 1)"> Coral color. </constant> - <constant name="CORNFLOWER_BLUE" value="Color( 0.39, 0.58, 0.93, 1 )"> + <constant name="CORNFLOWER_BLUE" value="Color(0.39, 0.58, 0.93, 1)"> Cornflower blue color. </constant> - <constant name="CORNSILK" value="Color( 1, 0.97, 0.86, 1 )"> + <constant name="CORNSILK" value="Color(1, 0.97, 0.86, 1)"> Cornsilk color. </constant> - <constant name="CRIMSON" value="Color( 0.86, 0.08, 0.24, 1 )"> + <constant name="CRIMSON" value="Color(0.86, 0.08, 0.24, 1)"> Crimson color. </constant> - <constant name="CYAN" value="Color( 0, 1, 1, 1 )"> + <constant name="CYAN" value="Color(0, 1, 1, 1)"> Cyan color. </constant> - <constant name="DARK_BLUE" value="Color( 0, 0, 0.55, 1 )"> + <constant name="DARK_BLUE" value="Color(0, 0, 0.55, 1)"> Dark blue color. </constant> - <constant name="DARK_CYAN" value="Color( 0, 0.55, 0.55, 1 )"> + <constant name="DARK_CYAN" value="Color(0, 0.55, 0.55, 1)"> Dark cyan color. </constant> - <constant name="DARK_GOLDENROD" value="Color( 0.72, 0.53, 0.04, 1 )"> + <constant name="DARK_GOLDENROD" value="Color(0.72, 0.53, 0.04, 1)"> Dark goldenrod color. </constant> - <constant name="DARK_GRAY" value="Color( 0.66, 0.66, 0.66, 1 )"> + <constant name="DARK_GRAY" value="Color(0.66, 0.66, 0.66, 1)"> Dark gray color. </constant> - <constant name="DARK_GREEN" value="Color( 0, 0.39, 0, 1 )"> + <constant name="DARK_GREEN" value="Color(0, 0.39, 0, 1)"> Dark green color. </constant> - <constant name="DARK_KHAKI" value="Color( 0.74, 0.72, 0.42, 1 )"> + <constant name="DARK_KHAKI" value="Color(0.74, 0.72, 0.42, 1)"> Dark khaki color. </constant> - <constant name="DARK_MAGENTA" value="Color( 0.55, 0, 0.55, 1 )"> + <constant name="DARK_MAGENTA" value="Color(0.55, 0, 0.55, 1)"> Dark magenta color. </constant> - <constant name="DARK_OLIVE_GREEN" value="Color( 0.33, 0.42, 0.18, 1 )"> + <constant name="DARK_OLIVE_GREEN" value="Color(0.33, 0.42, 0.18, 1)"> Dark olive green color. </constant> - <constant name="DARK_ORANGE" value="Color( 1, 0.55, 0, 1 )"> + <constant name="DARK_ORANGE" value="Color(1, 0.55, 0, 1)"> Dark orange color. </constant> - <constant name="DARK_ORCHID" value="Color( 0.6, 0.2, 0.8, 1 )"> + <constant name="DARK_ORCHID" value="Color(0.6, 0.2, 0.8, 1)"> Dark orchid color. </constant> - <constant name="DARK_RED" value="Color( 0.55, 0, 0, 1 )"> + <constant name="DARK_RED" value="Color(0.55, 0, 0, 1)"> Dark red color. </constant> - <constant name="DARK_SALMON" value="Color( 0.91, 0.59, 0.48, 1 )"> + <constant name="DARK_SALMON" value="Color(0.91, 0.59, 0.48, 1)"> Dark salmon color. </constant> - <constant name="DARK_SEA_GREEN" value="Color( 0.56, 0.74, 0.56, 1 )"> + <constant name="DARK_SEA_GREEN" value="Color(0.56, 0.74, 0.56, 1)"> Dark sea green color. </constant> - <constant name="DARK_SLATE_BLUE" value="Color( 0.28, 0.24, 0.55, 1 )"> + <constant name="DARK_SLATE_BLUE" value="Color(0.28, 0.24, 0.55, 1)"> Dark slate blue color. </constant> - <constant name="DARK_SLATE_GRAY" value="Color( 0.18, 0.31, 0.31, 1 )"> + <constant name="DARK_SLATE_GRAY" value="Color(0.18, 0.31, 0.31, 1)"> Dark slate gray color. </constant> - <constant name="DARK_TURQUOISE" value="Color( 0, 0.81, 0.82, 1 )"> + <constant name="DARK_TURQUOISE" value="Color(0, 0.81, 0.82, 1)"> Dark turquoise color. </constant> - <constant name="DARK_VIOLET" value="Color( 0.58, 0, 0.83, 1 )"> + <constant name="DARK_VIOLET" value="Color(0.58, 0, 0.83, 1)"> Dark violet color. </constant> - <constant name="DEEP_PINK" value="Color( 1, 0.08, 0.58, 1 )"> + <constant name="DEEP_PINK" value="Color(1, 0.08, 0.58, 1)"> Deep pink color. </constant> - <constant name="DEEP_SKY_BLUE" value="Color( 0, 0.75, 1, 1 )"> + <constant name="DEEP_SKY_BLUE" value="Color(0, 0.75, 1, 1)"> Deep sky blue color. </constant> - <constant name="DIM_GRAY" value="Color( 0.41, 0.41, 0.41, 1 )"> + <constant name="DIM_GRAY" value="Color(0.41, 0.41, 0.41, 1)"> Dim gray color. </constant> - <constant name="DODGER_BLUE" value="Color( 0.12, 0.56, 1, 1 )"> + <constant name="DODGER_BLUE" value="Color(0.12, 0.56, 1, 1)"> Dodger blue color. </constant> - <constant name="FIREBRICK" value="Color( 0.7, 0.13, 0.13, 1 )"> + <constant name="FIREBRICK" value="Color(0.7, 0.13, 0.13, 1)"> Firebrick color. </constant> - <constant name="FLORAL_WHITE" value="Color( 1, 0.98, 0.94, 1 )"> + <constant name="FLORAL_WHITE" value="Color(1, 0.98, 0.94, 1)"> Floral white color. </constant> - <constant name="FOREST_GREEN" value="Color( 0.13, 0.55, 0.13, 1 )"> + <constant name="FOREST_GREEN" value="Color(0.13, 0.55, 0.13, 1)"> Forest green color. </constant> - <constant name="FUCHSIA" value="Color( 1, 0, 1, 1 )"> + <constant name="FUCHSIA" value="Color(1, 0, 1, 1)"> Fuchsia color. </constant> - <constant name="GAINSBORO" value="Color( 0.86, 0.86, 0.86, 1 )"> + <constant name="GAINSBORO" value="Color(0.86, 0.86, 0.86, 1)"> Gainsboro color. </constant> - <constant name="GHOST_WHITE" value="Color( 0.97, 0.97, 1, 1 )"> + <constant name="GHOST_WHITE" value="Color(0.97, 0.97, 1, 1)"> Ghost white color. </constant> - <constant name="GOLD" value="Color( 1, 0.84, 0, 1 )"> + <constant name="GOLD" value="Color(1, 0.84, 0, 1)"> Gold color. </constant> - <constant name="GOLDENROD" value="Color( 0.85, 0.65, 0.13, 1 )"> + <constant name="GOLDENROD" value="Color(0.85, 0.65, 0.13, 1)"> Goldenrod color. </constant> - <constant name="GRAY" value="Color( 0.75, 0.75, 0.75, 1 )"> + <constant name="GRAY" value="Color(0.75, 0.75, 0.75, 1)"> Gray color. </constant> - <constant name="GREEN" value="Color( 0, 1, 0, 1 )"> + <constant name="GREEN" value="Color(0, 1, 0, 1)"> Green color. </constant> - <constant name="GREEN_YELLOW" value="Color( 0.68, 1, 0.18, 1 )"> + <constant name="GREEN_YELLOW" value="Color(0.68, 1, 0.18, 1)"> Green yellow color. </constant> - <constant name="HONEYDEW" value="Color( 0.94, 1, 0.94, 1 )"> + <constant name="HONEYDEW" value="Color(0.94, 1, 0.94, 1)"> Honeydew color. </constant> - <constant name="HOT_PINK" value="Color( 1, 0.41, 0.71, 1 )"> + <constant name="HOT_PINK" value="Color(1, 0.41, 0.71, 1)"> Hot pink color. </constant> - <constant name="INDIAN_RED" value="Color( 0.8, 0.36, 0.36, 1 )"> + <constant name="INDIAN_RED" value="Color(0.8, 0.36, 0.36, 1)"> Indian red color. </constant> - <constant name="INDIGO" value="Color( 0.29, 0, 0.51, 1 )"> + <constant name="INDIGO" value="Color(0.29, 0, 0.51, 1)"> Indigo color. </constant> - <constant name="IVORY" value="Color( 1, 1, 0.94, 1 )"> + <constant name="IVORY" value="Color(1, 1, 0.94, 1)"> Ivory color. </constant> - <constant name="KHAKI" value="Color( 0.94, 0.9, 0.55, 1 )"> + <constant name="KHAKI" value="Color(0.94, 0.9, 0.55, 1)"> Khaki color. </constant> - <constant name="LAVENDER" value="Color( 0.9, 0.9, 0.98, 1 )"> + <constant name="LAVENDER" value="Color(0.9, 0.9, 0.98, 1)"> Lavender color. </constant> - <constant name="LAVENDER_BLUSH" value="Color( 1, 0.94, 0.96, 1 )"> + <constant name="LAVENDER_BLUSH" value="Color(1, 0.94, 0.96, 1)"> Lavender blush color. </constant> - <constant name="LAWN_GREEN" value="Color( 0.49, 0.99, 0, 1 )"> + <constant name="LAWN_GREEN" value="Color(0.49, 0.99, 0, 1)"> Lawn green color. </constant> - <constant name="LEMON_CHIFFON" value="Color( 1, 0.98, 0.8, 1 )"> + <constant name="LEMON_CHIFFON" value="Color(1, 0.98, 0.8, 1)"> Lemon chiffon color. </constant> - <constant name="LIGHT_BLUE" value="Color( 0.68, 0.85, 0.9, 1 )"> + <constant name="LIGHT_BLUE" value="Color(0.68, 0.85, 0.9, 1)"> Light blue color. </constant> - <constant name="LIGHT_CORAL" value="Color( 0.94, 0.5, 0.5, 1 )"> + <constant name="LIGHT_CORAL" value="Color(0.94, 0.5, 0.5, 1)"> Light coral color. </constant> - <constant name="LIGHT_CYAN" value="Color( 0.88, 1, 1, 1 )"> + <constant name="LIGHT_CYAN" value="Color(0.88, 1, 1, 1)"> Light cyan color. </constant> - <constant name="LIGHT_GOLDENROD" value="Color( 0.98, 0.98, 0.82, 1 )"> + <constant name="LIGHT_GOLDENROD" value="Color(0.98, 0.98, 0.82, 1)"> Light goldenrod color. </constant> - <constant name="LIGHT_GRAY" value="Color( 0.83, 0.83, 0.83, 1 )"> + <constant name="LIGHT_GRAY" value="Color(0.83, 0.83, 0.83, 1)"> Light gray color. </constant> - <constant name="LIGHT_GREEN" value="Color( 0.56, 0.93, 0.56, 1 )"> + <constant name="LIGHT_GREEN" value="Color(0.56, 0.93, 0.56, 1)"> Light green color. </constant> - <constant name="LIGHT_PINK" value="Color( 1, 0.71, 0.76, 1 )"> + <constant name="LIGHT_PINK" value="Color(1, 0.71, 0.76, 1)"> Light pink color. </constant> - <constant name="LIGHT_SALMON" value="Color( 1, 0.63, 0.48, 1 )"> + <constant name="LIGHT_SALMON" value="Color(1, 0.63, 0.48, 1)"> Light salmon color. </constant> - <constant name="LIGHT_SEA_GREEN" value="Color( 0.13, 0.7, 0.67, 1 )"> + <constant name="LIGHT_SEA_GREEN" value="Color(0.13, 0.7, 0.67, 1)"> Light sea green color. </constant> - <constant name="LIGHT_SKY_BLUE" value="Color( 0.53, 0.81, 0.98, 1 )"> + <constant name="LIGHT_SKY_BLUE" value="Color(0.53, 0.81, 0.98, 1)"> Light sky blue color. </constant> - <constant name="LIGHT_SLATE_GRAY" value="Color( 0.47, 0.53, 0.6, 1 )"> + <constant name="LIGHT_SLATE_GRAY" value="Color(0.47, 0.53, 0.6, 1)"> Light slate gray color. </constant> - <constant name="LIGHT_STEEL_BLUE" value="Color( 0.69, 0.77, 0.87, 1 )"> + <constant name="LIGHT_STEEL_BLUE" value="Color(0.69, 0.77, 0.87, 1)"> Light steel blue color. </constant> - <constant name="LIGHT_YELLOW" value="Color( 1, 1, 0.88, 1 )"> + <constant name="LIGHT_YELLOW" value="Color(1, 1, 0.88, 1)"> Light yellow color. </constant> - <constant name="LIME" value="Color( 0, 1, 0, 1 )"> + <constant name="LIME" value="Color(0, 1, 0, 1)"> Lime color. </constant> - <constant name="LIME_GREEN" value="Color( 0.2, 0.8, 0.2, 1 )"> + <constant name="LIME_GREEN" value="Color(0.2, 0.8, 0.2, 1)"> Lime green color. </constant> - <constant name="LINEN" value="Color( 0.98, 0.94, 0.9, 1 )"> + <constant name="LINEN" value="Color(0.98, 0.94, 0.9, 1)"> Linen color. </constant> - <constant name="MAGENTA" value="Color( 1, 0, 1, 1 )"> + <constant name="MAGENTA" value="Color(1, 0, 1, 1)"> Magenta color. </constant> - <constant name="MAROON" value="Color( 0.69, 0.19, 0.38, 1 )"> + <constant name="MAROON" value="Color(0.69, 0.19, 0.38, 1)"> Maroon color. </constant> - <constant name="MEDIUM_AQUAMARINE" value="Color( 0.4, 0.8, 0.67, 1 )"> + <constant name="MEDIUM_AQUAMARINE" value="Color(0.4, 0.8, 0.67, 1)"> Medium aquamarine color. </constant> - <constant name="MEDIUM_BLUE" value="Color( 0, 0, 0.8, 1 )"> + <constant name="MEDIUM_BLUE" value="Color(0, 0, 0.8, 1)"> Medium blue color. </constant> - <constant name="MEDIUM_ORCHID" value="Color( 0.73, 0.33, 0.83, 1 )"> + <constant name="MEDIUM_ORCHID" value="Color(0.73, 0.33, 0.83, 1)"> Medium orchid color. </constant> - <constant name="MEDIUM_PURPLE" value="Color( 0.58, 0.44, 0.86, 1 )"> + <constant name="MEDIUM_PURPLE" value="Color(0.58, 0.44, 0.86, 1)"> Medium purple color. </constant> - <constant name="MEDIUM_SEA_GREEN" value="Color( 0.24, 0.7, 0.44, 1 )"> + <constant name="MEDIUM_SEA_GREEN" value="Color(0.24, 0.7, 0.44, 1)"> Medium sea green color. </constant> - <constant name="MEDIUM_SLATE_BLUE" value="Color( 0.48, 0.41, 0.93, 1 )"> + <constant name="MEDIUM_SLATE_BLUE" value="Color(0.48, 0.41, 0.93, 1)"> Medium slate blue color. </constant> - <constant name="MEDIUM_SPRING_GREEN" value="Color( 0, 0.98, 0.6, 1 )"> + <constant name="MEDIUM_SPRING_GREEN" value="Color(0, 0.98, 0.6, 1)"> Medium spring green color. </constant> - <constant name="MEDIUM_TURQUOISE" value="Color( 0.28, 0.82, 0.8, 1 )"> + <constant name="MEDIUM_TURQUOISE" value="Color(0.28, 0.82, 0.8, 1)"> Medium turquoise color. </constant> - <constant name="MEDIUM_VIOLET_RED" value="Color( 0.78, 0.08, 0.52, 1 )"> + <constant name="MEDIUM_VIOLET_RED" value="Color(0.78, 0.08, 0.52, 1)"> Medium violet red color. </constant> - <constant name="MIDNIGHT_BLUE" value="Color( 0.1, 0.1, 0.44, 1 )"> + <constant name="MIDNIGHT_BLUE" value="Color(0.1, 0.1, 0.44, 1)"> Midnight blue color. </constant> - <constant name="MINT_CREAM" value="Color( 0.96, 1, 0.98, 1 )"> + <constant name="MINT_CREAM" value="Color(0.96, 1, 0.98, 1)"> Mint cream color. </constant> - <constant name="MISTY_ROSE" value="Color( 1, 0.89, 0.88, 1 )"> + <constant name="MISTY_ROSE" value="Color(1, 0.89, 0.88, 1)"> Misty rose color. </constant> - <constant name="MOCCASIN" value="Color( 1, 0.89, 0.71, 1 )"> + <constant name="MOCCASIN" value="Color(1, 0.89, 0.71, 1)"> Moccasin color. </constant> - <constant name="NAVAJO_WHITE" value="Color( 1, 0.87, 0.68, 1 )"> + <constant name="NAVAJO_WHITE" value="Color(1, 0.87, 0.68, 1)"> Navajo white color. </constant> - <constant name="NAVY_BLUE" value="Color( 0, 0, 0.5, 1 )"> + <constant name="NAVY_BLUE" value="Color(0, 0, 0.5, 1)"> Navy blue color. </constant> - <constant name="OLD_LACE" value="Color( 0.99, 0.96, 0.9, 1 )"> + <constant name="OLD_LACE" value="Color(0.99, 0.96, 0.9, 1)"> Old lace color. </constant> - <constant name="OLIVE" value="Color( 0.5, 0.5, 0, 1 )"> + <constant name="OLIVE" value="Color(0.5, 0.5, 0, 1)"> Olive color. </constant> - <constant name="OLIVE_DRAB" value="Color( 0.42, 0.56, 0.14, 1 )"> + <constant name="OLIVE_DRAB" value="Color(0.42, 0.56, 0.14, 1)"> Olive drab color. </constant> - <constant name="ORANGE" value="Color( 1, 0.65, 0, 1 )"> + <constant name="ORANGE" value="Color(1, 0.65, 0, 1)"> Orange color. </constant> - <constant name="ORANGE_RED" value="Color( 1, 0.27, 0, 1 )"> + <constant name="ORANGE_RED" value="Color(1, 0.27, 0, 1)"> Orange red color. </constant> - <constant name="ORCHID" value="Color( 0.85, 0.44, 0.84, 1 )"> + <constant name="ORCHID" value="Color(0.85, 0.44, 0.84, 1)"> Orchid color. </constant> - <constant name="PALE_GOLDENROD" value="Color( 0.93, 0.91, 0.67, 1 )"> + <constant name="PALE_GOLDENROD" value="Color(0.93, 0.91, 0.67, 1)"> Pale goldenrod color. </constant> - <constant name="PALE_GREEN" value="Color( 0.6, 0.98, 0.6, 1 )"> + <constant name="PALE_GREEN" value="Color(0.6, 0.98, 0.6, 1)"> Pale green color. </constant> - <constant name="PALE_TURQUOISE" value="Color( 0.69, 0.93, 0.93, 1 )"> + <constant name="PALE_TURQUOISE" value="Color(0.69, 0.93, 0.93, 1)"> Pale turquoise color. </constant> - <constant name="PALE_VIOLET_RED" value="Color( 0.86, 0.44, 0.58, 1 )"> + <constant name="PALE_VIOLET_RED" value="Color(0.86, 0.44, 0.58, 1)"> Pale violet red color. </constant> - <constant name="PAPAYA_WHIP" value="Color( 1, 0.94, 0.84, 1 )"> + <constant name="PAPAYA_WHIP" value="Color(1, 0.94, 0.84, 1)"> Papaya whip color. </constant> - <constant name="PEACH_PUFF" value="Color( 1, 0.85, 0.73, 1 )"> + <constant name="PEACH_PUFF" value="Color(1, 0.85, 0.73, 1)"> Peach puff color. </constant> - <constant name="PERU" value="Color( 0.8, 0.52, 0.25, 1 )"> + <constant name="PERU" value="Color(0.8, 0.52, 0.25, 1)"> Peru color. </constant> - <constant name="PINK" value="Color( 1, 0.75, 0.8, 1 )"> + <constant name="PINK" value="Color(1, 0.75, 0.8, 1)"> Pink color. </constant> - <constant name="PLUM" value="Color( 0.87, 0.63, 0.87, 1 )"> + <constant name="PLUM" value="Color(0.87, 0.63, 0.87, 1)"> Plum color. </constant> - <constant name="POWDER_BLUE" value="Color( 0.69, 0.88, 0.9, 1 )"> + <constant name="POWDER_BLUE" value="Color(0.69, 0.88, 0.9, 1)"> Powder blue color. </constant> - <constant name="PURPLE" value="Color( 0.63, 0.13, 0.94, 1 )"> + <constant name="PURPLE" value="Color(0.63, 0.13, 0.94, 1)"> Purple color. </constant> - <constant name="REBECCA_PURPLE" value="Color( 0.4, 0.2, 0.6, 1 )"> + <constant name="REBECCA_PURPLE" value="Color(0.4, 0.2, 0.6, 1)"> Rebecca purple color. </constant> - <constant name="RED" value="Color( 1, 0, 0, 1 )"> + <constant name="RED" value="Color(1, 0, 0, 1)"> Red color. </constant> - <constant name="ROSY_BROWN" value="Color( 0.74, 0.56, 0.56, 1 )"> + <constant name="ROSY_BROWN" value="Color(0.74, 0.56, 0.56, 1)"> Rosy brown color. </constant> - <constant name="ROYAL_BLUE" value="Color( 0.25, 0.41, 0.88, 1 )"> + <constant name="ROYAL_BLUE" value="Color(0.25, 0.41, 0.88, 1)"> Royal blue color. </constant> - <constant name="SADDLE_BROWN" value="Color( 0.55, 0.27, 0.07, 1 )"> + <constant name="SADDLE_BROWN" value="Color(0.55, 0.27, 0.07, 1)"> Saddle brown color. </constant> - <constant name="SALMON" value="Color( 0.98, 0.5, 0.45, 1 )"> + <constant name="SALMON" value="Color(0.98, 0.5, 0.45, 1)"> Salmon color. </constant> - <constant name="SANDY_BROWN" value="Color( 0.96, 0.64, 0.38, 1 )"> + <constant name="SANDY_BROWN" value="Color(0.96, 0.64, 0.38, 1)"> Sandy brown color. </constant> - <constant name="SEA_GREEN" value="Color( 0.18, 0.55, 0.34, 1 )"> + <constant name="SEA_GREEN" value="Color(0.18, 0.55, 0.34, 1)"> Sea green color. </constant> - <constant name="SEASHELL" value="Color( 1, 0.96, 0.93, 1 )"> + <constant name="SEASHELL" value="Color(1, 0.96, 0.93, 1)"> Seashell color. </constant> - <constant name="SIENNA" value="Color( 0.63, 0.32, 0.18, 1 )"> + <constant name="SIENNA" value="Color(0.63, 0.32, 0.18, 1)"> Sienna color. </constant> - <constant name="SILVER" value="Color( 0.75, 0.75, 0.75, 1 )"> + <constant name="SILVER" value="Color(0.75, 0.75, 0.75, 1)"> Silver color. </constant> - <constant name="SKY_BLUE" value="Color( 0.53, 0.81, 0.92, 1 )"> + <constant name="SKY_BLUE" value="Color(0.53, 0.81, 0.92, 1)"> Sky blue color. </constant> - <constant name="SLATE_BLUE" value="Color( 0.42, 0.35, 0.8, 1 )"> + <constant name="SLATE_BLUE" value="Color(0.42, 0.35, 0.8, 1)"> Slate blue color. </constant> - <constant name="SLATE_GRAY" value="Color( 0.44, 0.5, 0.56, 1 )"> + <constant name="SLATE_GRAY" value="Color(0.44, 0.5, 0.56, 1)"> Slate gray color. </constant> - <constant name="SNOW" value="Color( 1, 0.98, 0.98, 1 )"> + <constant name="SNOW" value="Color(1, 0.98, 0.98, 1)"> Snow color. </constant> - <constant name="SPRING_GREEN" value="Color( 0, 1, 0.5, 1 )"> + <constant name="SPRING_GREEN" value="Color(0, 1, 0.5, 1)"> Spring green color. </constant> - <constant name="STEEL_BLUE" value="Color( 0.27, 0.51, 0.71, 1 )"> + <constant name="STEEL_BLUE" value="Color(0.27, 0.51, 0.71, 1)"> Steel blue color. </constant> - <constant name="TAN" value="Color( 0.82, 0.71, 0.55, 1 )"> + <constant name="TAN" value="Color(0.82, 0.71, 0.55, 1)"> Tan color. </constant> - <constant name="TEAL" value="Color( 0, 0.5, 0.5, 1 )"> + <constant name="TEAL" value="Color(0, 0.5, 0.5, 1)"> Teal color. </constant> - <constant name="THISTLE" value="Color( 0.85, 0.75, 0.85, 1 )"> + <constant name="THISTLE" value="Color(0.85, 0.75, 0.85, 1)"> Thistle color. </constant> - <constant name="TOMATO" value="Color( 1, 0.39, 0.28, 1 )"> + <constant name="TOMATO" value="Color(1, 0.39, 0.28, 1)"> Tomato color. </constant> - <constant name="TRANSPARENT" value="Color( 1, 1, 1, 0 )"> + <constant name="TRANSPARENT" value="Color(1, 1, 1, 0)"> Transparent color (white with zero alpha). </constant> - <constant name="TURQUOISE" value="Color( 0.25, 0.88, 0.82, 1 )"> + <constant name="TURQUOISE" value="Color(0.25, 0.88, 0.82, 1)"> Turquoise color. </constant> - <constant name="VIOLET" value="Color( 0.93, 0.51, 0.93, 1 )"> + <constant name="VIOLET" value="Color(0.93, 0.51, 0.93, 1)"> Violet color. </constant> - <constant name="WEB_GRAY" value="Color( 0.5, 0.5, 0.5, 1 )"> + <constant name="WEB_GRAY" value="Color(0.5, 0.5, 0.5, 1)"> Web gray color. </constant> - <constant name="WEB_GREEN" value="Color( 0, 0.5, 0, 1 )"> + <constant name="WEB_GREEN" value="Color(0, 0.5, 0, 1)"> Web green color. </constant> - <constant name="WEB_MAROON" value="Color( 0.5, 0, 0, 1 )"> + <constant name="WEB_MAROON" value="Color(0.5, 0, 0, 1)"> Web maroon color. </constant> - <constant name="WEB_PURPLE" value="Color( 0.5, 0, 0.5, 1 )"> + <constant name="WEB_PURPLE" value="Color(0.5, 0, 0.5, 1)"> Web purple color. </constant> - <constant name="WHEAT" value="Color( 0.96, 0.87, 0.7, 1 )"> + <constant name="WHEAT" value="Color(0.96, 0.87, 0.7, 1)"> Wheat color. </constant> - <constant name="WHITE" value="Color( 1, 1, 1, 1 )"> + <constant name="WHITE" value="Color(1, 1, 1, 1)"> White color. </constant> - <constant name="WHITE_SMOKE" value="Color( 0.96, 0.96, 0.96, 1 )"> + <constant name="WHITE_SMOKE" value="Color(0.96, 0.96, 0.96, 1)"> White smoke color. </constant> - <constant name="YELLOW" value="Color( 1, 1, 0, 1 )"> + <constant name="YELLOW" value="Color(1, 1, 0, 1)"> Yellow color. </constant> - <constant name="YELLOW_GREEN" value="Color( 0.6, 0.8, 0.2, 1 )"> + <constant name="YELLOW_GREEN" value="Color(0.6, 0.8, 0.2, 1)"> Yellow green color. </constant> </constants> diff --git a/doc/classes/ColorPicker.xml b/doc/classes/ColorPicker.xml index fddfd27573..2111358ef4 100644 --- a/doc/classes/ColorPicker.xml +++ b/doc/classes/ColorPicker.xml @@ -38,7 +38,7 @@ </method> </methods> <members> - <member name="color" type="Color" setter="set_pick_color" getter="get_pick_color" default="Color( 1, 1, 1, 1 )"> + <member name="color" type="Color" setter="set_pick_color" getter="get_pick_color" default="Color(1, 1, 1, 1)"> The currently selected color. </member> <member name="deferred_mode" type="bool" setter="set_deferred_mode" getter="is_deferred_mode" default="false"> diff --git a/doc/classes/ColorPickerButton.xml b/doc/classes/ColorPickerButton.xml index e49027e61d..09b828366f 100644 --- a/doc/classes/ColorPickerButton.xml +++ b/doc/classes/ColorPickerButton.xml @@ -28,7 +28,7 @@ </method> </methods> <members> - <member name="color" type="Color" setter="set_pick_color" getter="get_pick_color" default="Color( 0, 0, 0, 1 )"> + <member name="color" type="Color" setter="set_pick_color" getter="get_pick_color" default="Color(0, 0, 0, 1)"> The currently selected color. </member> <member name="edit_alpha" type="bool" setter="set_edit_alpha" getter="is_editing_alpha" default="true"> @@ -70,19 +70,19 @@ <theme_item name="font" type="Font"> [Font] of the [ColorPickerButton]'s text. </theme_item> - <theme_item name="font_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_color" type="Color" default="Color(1, 1, 1, 1)"> Default text [Color] of the [ColorPickerButton]. </theme_item> - <theme_item name="font_disabled_color" type="Color" default="Color( 0.9, 0.9, 0.9, 0.3 )"> + <theme_item name="font_disabled_color" type="Color" default="Color(0.9, 0.9, 0.9, 0.3)"> Text [Color] used when the [ColorPickerButton] is disabled. </theme_item> - <theme_item name="font_hover_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_hover_color" type="Color" default="Color(1, 1, 1, 1)"> Text [Color] used when the [ColorPickerButton] is being hovered. </theme_item> - <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)"> The tint of text outline of the [ColorPickerButton]. </theme_item> - <theme_item name="font_pressed_color" type="Color" default="Color( 0.8, 0.8, 0.8, 1 )"> + <theme_item name="font_pressed_color" type="Color" default="Color(0.8, 0.8, 0.8, 1)"> Text [Color] used when the [ColorPickerButton] is being pressed. </theme_item> <theme_item name="font_size" type="int"> diff --git a/doc/classes/ColorRect.xml b/doc/classes/ColorRect.xml index 09ba4c8b26..84955fed8a 100644 --- a/doc/classes/ColorRect.xml +++ b/doc/classes/ColorRect.xml @@ -12,7 +12,7 @@ <methods> </methods> <members> - <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 1, 1, 1, 1 )"> + <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)"> The fill color. [codeblocks] [gdscript] diff --git a/doc/classes/ConcavePolygonShape2D.xml b/doc/classes/ConcavePolygonShape2D.xml index 9999d086da..e6b2e1845d 100644 --- a/doc/classes/ConcavePolygonShape2D.xml +++ b/doc/classes/ConcavePolygonShape2D.xml @@ -12,7 +12,7 @@ <methods> </methods> <members> - <member name="segments" type="PackedVector2Array" setter="set_segments" getter="get_segments" default="PackedVector2Array( )"> + <member name="segments" type="PackedVector2Array" setter="set_segments" getter="get_segments" default="PackedVector2Array()"> The array of points that make up the [ConcavePolygonShape2D]'s line segments. </member> </members> diff --git a/doc/classes/ConfigFile.xml b/doc/classes/ConfigFile.xml index 8b903d8dbc..76855fc19f 100644 --- a/doc/classes/ConfigFile.xml +++ b/doc/classes/ConfigFile.xml @@ -9,7 +9,7 @@ [section] some_key=42 string_example="Hello World3D!" - a_vector=Vector3( 1, 0, 2 ) + a_vector=Vector3(1, 0, 2) [/codeblock] The stored data can be saved to or parsed from a file, though ConfigFile objects can also be used directly without accessing the filesystem. The following example shows how to parse an INI-style file from the system, read its contents and store new values in it: diff --git a/doc/classes/ConfirmationDialog.xml b/doc/classes/ConfirmationDialog.xml index 9d8977cef1..0253ef21df 100644 --- a/doc/classes/ConfirmationDialog.xml +++ b/doc/classes/ConfirmationDialog.xml @@ -27,8 +27,8 @@ </method> </methods> <members> - <member name="min_size" type="Vector2i" setter="set_min_size" getter="get_min_size" override="true" default="Vector2i( 200, 70 )" /> - <member name="size" type="Vector2i" setter="set_size" getter="get_size" override="true" default="Vector2i( 200, 100 )" /> + <member name="min_size" type="Vector2i" setter="set_min_size" getter="get_min_size" override="true" default="Vector2i(200, 70)" /> + <member name="size" type="Vector2i" setter="set_size" getter="get_size" override="true" default="Vector2i(200, 100)" /> <member name="title" type="String" setter="set_title" getter="get_title" override="true" default=""Please Confirm..."" /> </members> <constants> diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index 33969cf4c3..9015caa0b4 100644 --- a/doc/classes/Control.xml +++ b/doc/classes/Control.xml @@ -395,7 +395,7 @@ <method name="get_cursor_shape" qualifiers="const"> <return type="int" enum="Control.CursorShape"> </return> - <argument index="0" name="position" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="0" name="position" type="Vector2" default="Vector2(0, 0)"> </argument> <description> Returns the mouse cursor shape the control displays on mouse hover. See [enum CursorShape]. @@ -549,7 +549,7 @@ <method name="get_tooltip" qualifiers="const"> <return type="String"> </return> - <argument index="0" name="at_position" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="0" name="at_position" type="Vector2" default="Vector2(0, 0)"> </argument> <description> Returns the tooltip, which will appear when the cursor is resting over this control. See [member hint_tooltip]. @@ -1140,13 +1140,13 @@ <member name="rect_global_position" type="Vector2" setter="_set_global_position" getter="get_global_position"> The node's global position, relative to the world (usually to the top-left corner of the window). </member> - <member name="rect_min_size" type="Vector2" setter="set_custom_minimum_size" getter="get_custom_minimum_size" default="Vector2( 0, 0 )"> + <member name="rect_min_size" type="Vector2" setter="set_custom_minimum_size" getter="get_custom_minimum_size" default="Vector2(0, 0)"> The minimum size of the node's bounding rectangle. If you set it to a value greater than (0, 0), the node's bounding rectangle will always have at least this size, even if its content is smaller. If it's set to (0, 0), the node sizes automatically to fit its content, be it a texture or child nodes. </member> - <member name="rect_pivot_offset" type="Vector2" setter="set_pivot_offset" getter="get_pivot_offset" default="Vector2( 0, 0 )"> + <member name="rect_pivot_offset" type="Vector2" setter="set_pivot_offset" getter="get_pivot_offset" default="Vector2(0, 0)"> By default, the node's pivot is its top-left corner. When you change its [member rect_scale], it will scale around this pivot. Set this property to [member rect_size] / 2 to center the pivot in the node's rectangle. </member> - <member name="rect_position" type="Vector2" setter="_set_position" getter="get_position" default="Vector2( 0, 0 )"> + <member name="rect_position" type="Vector2" setter="_set_position" getter="get_position" default="Vector2(0, 0)"> The node's position, relative to its parent. It corresponds to the rectangle's top-left corner. The property is not affected by [member rect_pivot_offset]. </member> <member name="rect_rotation" type="float" setter="set_rotation" getter="get_rotation" default="0.0"> @@ -1155,12 +1155,12 @@ <member name="rect_rotation_degrees" type="float" setter="set_rotation_degrees" getter="get_rotation_degrees" default="0.0"> The node's rotation around its pivot, in degrees. See [member rect_pivot_offset] to change the pivot's position. </member> - <member name="rect_scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2( 1, 1 )"> + <member name="rect_scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2(1, 1)"> The node's scale, relative to its [member rect_size]. Change this property to scale the node around its [member rect_pivot_offset]. The Control's [member hint_tooltip] will also scale according to this value. [b]Note:[/b] This property is mainly intended to be used for animation purposes. Text inside the Control will look pixelated or blurry when the Control is scaled. To support multiple resolutions in your project, use an appropriate viewport stretch mode as described in the [url=https://docs.godotengine.org/en/latest/tutorials/viewports/multiple_resolutions.html]documentation[/url] instead of scaling Controls individually. [b]Note:[/b] If the Control node is a child of a [Container] node, the scale will be reset to [code]Vector2(1, 1)[/code] when the scene is instanced. To set the Control's scale when it's instanced, wait for one frame using [code]yield(get_tree(), "idle_frame")[/code] then set its [member rect_scale] property. </member> - <member name="rect_size" type="Vector2" setter="_set_size" getter="get_size" default="Vector2( 0, 0 )"> + <member name="rect_size" type="Vector2" setter="_set_size" getter="get_size" default="Vector2(0, 0)"> The size of the node's bounding rectangle, in pixels. [Container] nodes update this property automatically. </member> <member name="size_flags_horizontal" type="int" setter="set_h_size_flags" getter="get_h_size_flags" default="1"> diff --git a/doc/classes/ConvexPolygonShape2D.xml b/doc/classes/ConvexPolygonShape2D.xml index 42951e2158..d53900e6c5 100644 --- a/doc/classes/ConvexPolygonShape2D.xml +++ b/doc/classes/ConvexPolygonShape2D.xml @@ -21,7 +21,7 @@ </method> </methods> <members> - <member name="points" type="PackedVector2Array" setter="set_points" getter="get_points" default="PackedVector2Array( )"> + <member name="points" type="PackedVector2Array" setter="set_points" getter="get_points" default="PackedVector2Array()"> The polygon's list of vertices. Can be in either clockwise or counterclockwise order. </member> </members> diff --git a/doc/classes/ConvexPolygonShape3D.xml b/doc/classes/ConvexPolygonShape3D.xml index e18d716255..a5c86526b0 100644 --- a/doc/classes/ConvexPolygonShape3D.xml +++ b/doc/classes/ConvexPolygonShape3D.xml @@ -12,7 +12,7 @@ <methods> </methods> <members> - <member name="points" type="PackedVector3Array" setter="set_points" getter="get_points" default="PackedVector3Array( )"> + <member name="points" type="PackedVector3Array" setter="set_points" getter="get_points" default="PackedVector3Array()"> The list of 3D points forming the convex polygon shape. </member> </members> diff --git a/doc/classes/Curve2D.xml b/doc/classes/Curve2D.xml index b33f3b4ffc..c9fcbd2892 100644 --- a/doc/classes/Curve2D.xml +++ b/doc/classes/Curve2D.xml @@ -15,9 +15,9 @@ </return> <argument index="0" name="position" type="Vector2"> </argument> - <argument index="1" name="in" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="1" name="in" type="Vector2" default="Vector2(0, 0)"> </argument> - <argument index="2" name="out" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="2" name="out" type="Vector2" default="Vector2(0, 0)"> </argument> <argument index="3" name="at_position" type="int" default="-1"> </argument> diff --git a/doc/classes/Curve3D.xml b/doc/classes/Curve3D.xml index fcd150ad57..fdf96b4262 100644 --- a/doc/classes/Curve3D.xml +++ b/doc/classes/Curve3D.xml @@ -15,9 +15,9 @@ </return> <argument index="0" name="position" type="Vector3"> </argument> - <argument index="1" name="in" type="Vector3" default="Vector3( 0, 0, 0 )"> + <argument index="1" name="in" type="Vector3" default="Vector3(0, 0, 0)"> </argument> - <argument index="2" name="out" type="Vector3" default="Vector3( 0, 0, 0 )"> + <argument index="2" name="out" type="Vector3" default="Vector3(0, 0, 0)"> </argument> <argument index="3" name="at_position" type="int" default="-1"> </argument> diff --git a/doc/classes/Decal.xml b/doc/classes/Decal.xml index 14c35ae6d3..e84cea7c30 100644 --- a/doc/classes/Decal.xml +++ b/doc/classes/Decal.xml @@ -79,13 +79,13 @@ <member name="emission_energy" type="float" setter="set_emission_energy" getter="get_emission_energy" default="1.0"> Energy multiplier for the emission texture. This will make the decal emit light at a higher intensity. </member> - <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3( 1, 1, 1 )"> + <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)"> Sets the size of the [AABB] used by the decal. The AABB goes from [code]-extents[/code] to [code]extents[/code]. </member> <member name="lower_fade" type="float" setter="set_lower_fade" getter="get_lower_fade" default="0.3"> Sets the curve over which the decal will fade as the surface gets further from the center of the [AABB]. </member> - <member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color( 1, 1, 1, 1 )"> + <member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color(1, 1, 1, 1)"> Changes the [Color] of the Decal by multiplying it with this value. </member> <member name="normal_fade" type="float" setter="set_normal_fade" getter="get_normal_fade" default="0.0"> diff --git a/doc/classes/DisplayServer.xml b/doc/classes/DisplayServer.xml index 6c1cd37beb..0a4807f046 100644 --- a/doc/classes/DisplayServer.xml +++ b/doc/classes/DisplayServer.xml @@ -46,7 +46,7 @@ </argument> <argument index="1" name="flags" type="int"> </argument> - <argument index="2" name="rect" type="Rect2i" default="Rect2i( 0, 0, 0, 0 )"> + <argument index="2" name="rect" type="Rect2i" default="Rect2i(0, 0, 0, 0)"> </argument> <description> </description> @@ -64,7 +64,7 @@ </argument> <argument index="1" name="shape" type="int" enum="DisplayServer.CursorShape" default="0"> </argument> - <argument index="2" name="hotspot" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="2" name="hotspot" type="Vector2" default="Vector2(0, 0)"> </argument> <description> </description> @@ -650,7 +650,7 @@ </return> <argument index="0" name="existing_text" type="String"> </argument> - <argument index="1" name="position" type="Rect2" default="Rect2i( 0, 0, 0, 0 )"> + <argument index="1" name="position" type="Rect2" default="Rect2i(0, 0, 0, 0)"> </argument> <argument index="2" name="multiline" type="bool" default="false"> </argument> diff --git a/doc/classes/EditorNode3DGizmo.xml b/doc/classes/EditorNode3DGizmo.xml index dcc6d6ef12..221b5e44d6 100644 --- a/doc/classes/EditorNode3DGizmo.xml +++ b/doc/classes/EditorNode3DGizmo.xml @@ -115,7 +115,7 @@ </argument> <argument index="2" name="billboard" type="bool" default="false"> </argument> - <argument index="3" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> </argument> <description> Adds lines to the gizmo (as sets of 2 points), with a given material. The lines are used for visualizing the gizmo. Call this function during [method _redraw]. @@ -143,7 +143,7 @@ </argument> <argument index="1" name="default_scale" type="float" default="1"> </argument> - <argument index="2" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="2" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> </argument> <description> Adds an unscaled billboard for visualization. Call this function during [method _redraw]. diff --git a/doc/classes/EditorNode3DGizmoPlugin.xml b/doc/classes/EditorNode3DGizmoPlugin.xml index 5551326533..41c94cbbc6 100644 --- a/doc/classes/EditorNode3DGizmoPlugin.xml +++ b/doc/classes/EditorNode3DGizmoPlugin.xml @@ -163,7 +163,7 @@ </argument> <argument index="2" name="on_top" type="bool" default="false"> </argument> - <argument index="3" name="color" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)"> </argument> <description> Creates an icon material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with [method get_material] and used in [method EditorNode3DGizmo.add_unscaled_billboard]. Should not be overridden. diff --git a/doc/classes/EditorSceneImporterMesh.xml b/doc/classes/EditorSceneImporterMesh.xml index 9daa3f16bc..90eca9072b 100644 --- a/doc/classes/EditorSceneImporterMesh.xml +++ b/doc/classes/EditorSceneImporterMesh.xml @@ -22,7 +22,7 @@ </argument> <argument index="1" name="arrays" type="Array"> </argument> - <argument index="2" name="blend_shapes" type="Array" default="[ ]"> + <argument index="2" name="blend_shapes" type="Array" default="[]"> </argument> <argument index="3" name="lods" type="Dictionary" default="{ }"> @@ -168,7 +168,7 @@ </method> </methods> <members> - <member name="_data" type="Dictionary" setter="_set_data" getter="_get_data" default="{"surfaces": [ ]}"> + <member name="_data" type="Dictionary" setter="_set_data" getter="_get_data" default="{"surfaces": []}"> </member> </members> <constants> diff --git a/doc/classes/EngineDebugger.xml b/doc/classes/EngineDebugger.xml index 7db36b89d0..50ccb6b075 100644 --- a/doc/classes/EngineDebugger.xml +++ b/doc/classes/EngineDebugger.xml @@ -61,7 +61,7 @@ </argument> <argument index="1" name="enable" type="bool"> </argument> - <argument index="2" name="arguments" type="Array" default="[ ]"> + <argument index="2" name="arguments" type="Array" default="[]"> </argument> <description> Calls the [code]toggle[/code] callable of the profiler with given [code]name[/code] and [code]arguments[/code]. Enables/Disables the same profiler depending on [code]enable[/code] argument. diff --git a/doc/classes/Environment.xml b/doc/classes/Environment.xml index 878535a08d..ae87a62c84 100644 --- a/doc/classes/Environment.xml +++ b/doc/classes/Environment.xml @@ -55,13 +55,13 @@ <member name="adjustment_saturation" type="float" setter="set_adjustment_saturation" getter="get_adjustment_saturation" default="1.0"> The global color saturation value of the rendered scene (default value is 1). Effective only if [code]adjustment_enabled[/code] is [code]true[/code]. </member> - <member name="ambient_light_color" type="Color" setter="set_ambient_light_color" getter="get_ambient_light_color" default="Color( 0, 0, 0, 1 )"> + <member name="ambient_light_color" type="Color" setter="set_ambient_light_color" getter="get_ambient_light_color" default="Color(0, 0, 0, 1)"> The ambient light's [Color]. </member> <member name="ambient_light_energy" type="float" setter="set_ambient_light_energy" getter="get_ambient_light_energy" default="1.0"> The ambient light's energy. The higher the value, the stronger the light. </member> - <member name="ambient_light_occlusion_color" type="Color" setter="set_ao_color" getter="get_ao_color" default="Color( 0, 0, 0, 1 )"> + <member name="ambient_light_occlusion_color" type="Color" setter="set_ao_color" getter="get_ao_color" default="Color(0, 0, 0, 1)"> </member> <member name="ambient_light_sky_contribution" type="float" setter="set_ambient_light_sky_contribution" getter="get_ambient_light_sky_contribution" default="1.0"> Defines the amount of light that the sky brings on the scene. A value of 0 means that the sky's light emission has no effect on the scene illumination, thus all ambient illumination is provided by the ambient light. On the contrary, a value of 1 means that all the light that affects the scene is provided by the sky, thus the ambient light parameter has no effect on the scene. @@ -89,7 +89,7 @@ <member name="background_canvas_max_layer" type="int" setter="set_canvas_max_layer" getter="get_canvas_max_layer" default="0"> The maximum layer ID to display. Only effective when using the [constant BG_CANVAS] background mode. </member> - <member name="background_color" type="Color" setter="set_bg_color" getter="get_bg_color" default="Color( 0, 0, 0, 1 )"> + <member name="background_color" type="Color" setter="set_bg_color" getter="get_bg_color" default="Color(0, 0, 0, 1)"> The [Color] displayed for clear areas of the scene. Only effective when using the [constant BG_COLOR] background mode. </member> <member name="background_energy" type="float" setter="set_bg_energy" getter="get_bg_energy" default="1.0"> @@ -111,7 +111,7 @@ </member> <member name="fog_height_density" type="float" setter="set_fog_height_density" getter="get_fog_height_density" default="0.0"> </member> - <member name="fog_light_color" type="Color" setter="set_fog_light_color" getter="get_fog_light_color" default="Color( 0.5, 0.6, 0.7, 1 )"> + <member name="fog_light_color" type="Color" setter="set_fog_light_color" getter="get_fog_light_color" default="Color(0.5, 0.6, 0.7, 1)"> </member> <member name="fog_light_energy" type="float" setter="set_fog_light_energy" getter="get_fog_light_energy" default="1.0"> </member> @@ -200,7 +200,7 @@ </member> <member name="sky_custom_fov" type="float" setter="set_sky_custom_fov" getter="get_sky_custom_fov" default="0.0"> </member> - <member name="sky_rotation" type="Vector3" setter="set_sky_rotation" getter="get_sky_rotation" default="Vector3( 0, 0, 0 )"> + <member name="sky_rotation" type="Vector3" setter="set_sky_rotation" getter="get_sky_rotation" default="Vector3(0, 0, 0)"> </member> <member name="ss_reflections_depth_tolerance" type="float" setter="set_ssr_depth_tolerance" getter="get_ssr_depth_tolerance" default="0.2"> The depth tolerance for screen-space reflections. @@ -263,7 +263,7 @@ </member> <member name="volumetric_fog_length" type="float" setter="set_volumetric_fog_length" getter="get_volumetric_fog_length" default="64.0"> </member> - <member name="volumetric_fog_light" type="Color" setter="set_volumetric_fog_light" getter="get_volumetric_fog_light" default="Color( 0, 0, 0, 1 )"> + <member name="volumetric_fog_light" type="Color" setter="set_volumetric_fog_light" getter="get_volumetric_fog_light" default="Color(0, 0, 0, 1)"> </member> <member name="volumetric_fog_light_energy" type="float" setter="set_volumetric_fog_light_energy" getter="get_volumetric_fog_light_energy" default="1.0"> </member> diff --git a/doc/classes/Expression.xml b/doc/classes/Expression.xml index 0781d2ffa2..640b45dca4 100644 --- a/doc/classes/Expression.xml +++ b/doc/classes/Expression.xml @@ -54,7 +54,7 @@ <method name="execute"> <return type="Variant"> </return> - <argument index="0" name="inputs" type="Array" default="[ ]"> + <argument index="0" name="inputs" type="Array" default="[]"> </argument> <argument index="1" name="base_instance" type="Object" default="null"> </argument> @@ -84,7 +84,7 @@ </return> <argument index="0" name="expression" type="String"> </argument> - <argument index="1" name="input_names" type="PackedStringArray" default="PackedStringArray( )"> + <argument index="1" name="input_names" type="PackedStringArray" default="PackedStringArray()"> </argument> <description> Parses the expression and returns an [enum Error] code. diff --git a/doc/classes/FileDialog.xml b/doc/classes/FileDialog.xml index 966be0a981..8ccee1c82e 100644 --- a/doc/classes/FileDialog.xml +++ b/doc/classes/FileDialog.xml @@ -72,7 +72,7 @@ <member name="file_mode" type="int" setter="set_file_mode" getter="get_file_mode" enum="FileDialog.FileMode" default="4"> The dialog's open or save mode, which affects the selection behavior. See [enum FileMode]. </member> - <member name="filters" type="PackedStringArray" setter="set_filters" getter="get_filters" default="PackedStringArray( )"> + <member name="filters" type="PackedStringArray" setter="set_filters" getter="get_filters" default="PackedStringArray()"> The available file type filters. For example, this shows only [code].png[/code] and [code].gd[/code] files: [code]set_filters(PackedStringArray(["*.png ; PNG Images","*.gd ; GDScript Files"]))[/code]. </member> <member name="mode_overrides_title" type="bool" setter="set_mode_overrides_title" getter="is_mode_overriding_title" default="true"> @@ -139,16 +139,16 @@ <theme_item name="file" type="Texture2D"> Custom icon for files. </theme_item> - <theme_item name="file_icon_modulate" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="file_icon_modulate" type="Color" default="Color(1, 1, 1, 1)"> The color modulation applied to the file icon. </theme_item> - <theme_item name="files_disabled" type="Color" default="Color( 0, 0, 0, 0.7 )"> + <theme_item name="files_disabled" type="Color" default="Color(0, 0, 0, 0.7)"> The color tint for disabled files (when the [FileDialog] is used in open folder mode). </theme_item> <theme_item name="folder" type="Texture2D"> Custom icon for folders. </theme_item> - <theme_item name="folder_icon_modulate" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="folder_icon_modulate" type="Color" default="Color(1, 1, 1, 1)"> The color modulation applied to the folder icon. </theme_item> <theme_item name="forward_folder" type="Texture2D"> diff --git a/doc/classes/Font.xml b/doc/classes/Font.xml index 20d5b6ce9b..186bfbb931 100644 --- a/doc/classes/Font.xml +++ b/doc/classes/Font.xml @@ -85,11 +85,11 @@ </argument> <argument index="4" name="size" type="int" default="-1"> </argument> - <argument index="5" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="5" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> </argument> <argument index="6" name="outline_size" type="int" default="0"> </argument> - <argument index="7" name="outline_modulate" type="Color" default="Color( 1, 1, 1, 0 )"> + <argument index="7" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)"> </argument> <description> Draw a single Unicode character [code]char[/code] into a canvas item using the font, at a given position, with [code]modulate[/code] color, and optionally kerning if [code]next[/code] is passed. [code]position[/code] specifies the baseline, not the top. To draw from the top, [i]ascent[/i] must be added to the Y axis. @@ -113,11 +113,11 @@ </argument> <argument index="6" name="size" type="int" default="-1"> </argument> - <argument index="7" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="7" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> </argument> <argument index="8" name="outline_size" type="int" default="0"> </argument> - <argument index="9" name="outline_modulate" type="Color" default="Color( 1, 1, 1, 0 )"> + <argument index="9" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)"> </argument> <argument index="10" name="flags" type="int" default="51"> </argument> @@ -141,11 +141,11 @@ </argument> <argument index="5" name="size" type="int" default="-1"> </argument> - <argument index="6" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="6" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> </argument> <argument index="7" name="outline_size" type="int" default="0"> </argument> - <argument index="8" name="outline_modulate" type="Color" default="Color( 1, 1, 1, 0 )"> + <argument index="8" name="outline_modulate" type="Color" default="Color(1, 1, 1, 0)"> </argument> <argument index="9" name="flags" type="int" default="3"> </argument> diff --git a/doc/classes/FontData.xml b/doc/classes/FontData.xml index e426c8fb36..0a2fb03750 100644 --- a/doc/classes/FontData.xml +++ b/doc/classes/FontData.xml @@ -61,7 +61,7 @@ </argument> <argument index="3" name="index" type="int"> </argument> - <argument index="4" name="color" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="4" name="color" type="Color" default="Color(1, 1, 1, 1)"> </argument> <description> Draws single glyph into a canvas item at the position, using [code]font[/code] at the size [code]size[/code]. @@ -82,7 +82,7 @@ </argument> <argument index="4" name="index" type="int"> </argument> - <argument index="5" name="color" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="5" name="color" type="Color" default="Color(1, 1, 1, 1)"> </argument> <description> Draws single glyph outline of size [code]outline_size[/code] into a canvas item at the position, using [code]font[/code] at the size [code]size[/code]. If outline drawing is not supported, nothing is drawn. diff --git a/doc/classes/GPUParticles2D.xml b/doc/classes/GPUParticles2D.xml index ebd6d2b92c..8684a7f41a 100644 --- a/doc/classes/GPUParticles2D.xml +++ b/doc/classes/GPUParticles2D.xml @@ -80,7 +80,7 @@ </member> <member name="trail_sections" type="int" setter="set_trail_sections" getter="get_trail_sections" default="8"> </member> - <member name="visibility_rect" type="Rect2" setter="set_visibility_rect" getter="get_visibility_rect" default="Rect2( -100, -100, 200, 200 )"> + <member name="visibility_rect" type="Rect2" setter="set_visibility_rect" getter="get_visibility_rect" default="Rect2(-100, -100, 200, 200)"> The [Rect2] that determines the node's region which needs to be visible on screen for the particle system to be active. Grow the rect if particles suddenly appear/disappear when the node enters/exits the screen. The [Rect2] can be grown via code or with the [b]Particles → Generate Visibility Rect[/b] editor tool. </member> diff --git a/doc/classes/GPUParticles3D.xml b/doc/classes/GPUParticles3D.xml index 47bdd9d745..55e9b33aa8 100644 --- a/doc/classes/GPUParticles3D.xml +++ b/doc/classes/GPUParticles3D.xml @@ -132,7 +132,7 @@ </member> <member name="transform_align" type="int" setter="set_transform_align" getter="get_transform_align" enum="GPUParticles3D.TransformAlign" default="0"> </member> - <member name="visibility_aabb" type="AABB" setter="set_visibility_aabb" getter="get_visibility_aabb" default="AABB( -4, -4, -4, 8, 8, 8 )"> + <member name="visibility_aabb" type="AABB" setter="set_visibility_aabb" getter="get_visibility_aabb" default="AABB(-4, -4, -4, 8, 8, 8)"> The [AABB] that determines the node's region which needs to be visible on screen for the particle system to be active. Grow the box if particles suddenly appear/disappear when the node enters/exits the screen. The [AABB] can be grown via code or with the [b]Particles → Generate AABB[/b] editor tool. </member> diff --git a/doc/classes/GPUParticlesAttractorBox.xml b/doc/classes/GPUParticlesAttractorBox.xml index 68616f9bbd..49e6111c29 100644 --- a/doc/classes/GPUParticlesAttractorBox.xml +++ b/doc/classes/GPUParticlesAttractorBox.xml @@ -9,7 +9,7 @@ <methods> </methods> <members> - <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3( 1, 1, 1 )"> + <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)"> </member> </members> <constants> diff --git a/doc/classes/GPUParticlesAttractorVectorField.xml b/doc/classes/GPUParticlesAttractorVectorField.xml index cf5e375ea3..7364a4b09f 100644 --- a/doc/classes/GPUParticlesAttractorVectorField.xml +++ b/doc/classes/GPUParticlesAttractorVectorField.xml @@ -9,7 +9,7 @@ <methods> </methods> <members> - <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3( 1, 1, 1 )"> + <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)"> </member> <member name="texture" type="Texture3D" setter="set_texture" getter="get_texture"> </member> diff --git a/doc/classes/GPUParticlesCollisionBox.xml b/doc/classes/GPUParticlesCollisionBox.xml index 17fc124c41..58de18556e 100644 --- a/doc/classes/GPUParticlesCollisionBox.xml +++ b/doc/classes/GPUParticlesCollisionBox.xml @@ -9,7 +9,7 @@ <methods> </methods> <members> - <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3( 1, 1, 1 )"> + <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)"> </member> </members> <constants> diff --git a/doc/classes/GPUParticlesCollisionHeightField.xml b/doc/classes/GPUParticlesCollisionHeightField.xml index c6987515a9..0ddddda8e4 100644 --- a/doc/classes/GPUParticlesCollisionHeightField.xml +++ b/doc/classes/GPUParticlesCollisionHeightField.xml @@ -9,7 +9,7 @@ <methods> </methods> <members> - <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3( 1, 1, 1 )"> + <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)"> </member> <member name="follow_camera_enabled" type="bool" setter="set_follow_camera_mode" getter="is_follow_camera_mode_enabled" default="false"> </member> diff --git a/doc/classes/GPUParticlesCollisionSDF.xml b/doc/classes/GPUParticlesCollisionSDF.xml index c3cbe4b1c6..7ef6f5f3cd 100644 --- a/doc/classes/GPUParticlesCollisionSDF.xml +++ b/doc/classes/GPUParticlesCollisionSDF.xml @@ -9,7 +9,7 @@ <methods> </methods> <members> - <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3( 1, 1, 1 )"> + <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)"> </member> <member name="resolution" type="int" setter="set_resolution" getter="get_resolution" enum="GPUParticlesCollisionSDF.Resolution" default="2"> </member> diff --git a/doc/classes/Gradient.xml b/doc/classes/Gradient.xml index 28c647a1c3..1f1f266c59 100644 --- a/doc/classes/Gradient.xml +++ b/doc/classes/Gradient.xml @@ -87,10 +87,10 @@ </method> </methods> <members> - <member name="colors" type="PackedColorArray" setter="set_colors" getter="get_colors" default="PackedColorArray( 0, 0, 0, 1, 1, 1, 1, 1 )"> + <member name="colors" type="PackedColorArray" setter="set_colors" getter="get_colors" default="PackedColorArray(0, 0, 0, 1, 1, 1, 1, 1)"> Gradient's colors returned as a [PackedColorArray]. </member> - <member name="offsets" type="PackedFloat32Array" setter="set_offsets" getter="get_offsets" default="PackedFloat32Array( 0, 1 )"> + <member name="offsets" type="PackedFloat32Array" setter="set_offsets" getter="get_offsets" default="PackedFloat32Array(0, 1)"> Gradient's offsets returned as a [PackedFloat32Array]. </member> </members> diff --git a/doc/classes/GraphEdit.xml b/doc/classes/GraphEdit.xml index 16fc1ca17a..65701b3a6a 100644 --- a/doc/classes/GraphEdit.xml +++ b/doc/classes/GraphEdit.xml @@ -187,14 +187,14 @@ <member name="minimap_opacity" type="float" setter="set_minimap_opacity" getter="get_minimap_opacity" default="0.65"> The opacity of the minimap rectangle. </member> - <member name="minimap_size" type="Vector2" setter="set_minimap_size" getter="get_minimap_size" default="Vector2( 240, 160 )"> + <member name="minimap_size" type="Vector2" setter="set_minimap_size" getter="get_minimap_size" default="Vector2(240, 160)"> The size of the minimap rectangle. The map itself is based on the size of the grid area and is scaled to fit this rectangle. </member> <member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" override="true" default="true" /> <member name="right_disconnects" type="bool" setter="set_right_disconnects" getter="is_right_disconnects_enabled" default="false"> If [code]true[/code], enables disconnection of existing connections in the GraphEdit by dragging the right end. </member> - <member name="scroll_offset" type="Vector2" setter="set_scroll_ofs" getter="get_scroll_ofs" default="Vector2( 0, 0 )"> + <member name="scroll_offset" type="Vector2" setter="set_scroll_ofs" getter="get_scroll_ofs" default="Vector2(0, 0)"> The scroll offset. </member> <member name="show_zoom_label" type="bool" setter="set_show_zoom_label" getter="is_showing_zoom_label" default="false"> @@ -329,7 +329,7 @@ <constants> </constants> <theme_items> - <theme_item name="activity" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="activity" type="Color" default="Color(1, 1, 1, 1)"> </theme_item> <theme_item name="bezier_len_neg" type="int" default="160"> </theme_item> @@ -338,10 +338,10 @@ <theme_item name="bg" type="StyleBox"> The background drawn under the grid. </theme_item> - <theme_item name="grid_major" type="Color" default="Color( 1, 1, 1, 0.2 )"> + <theme_item name="grid_major" type="Color" default="Color(1, 1, 1, 0.2)"> Color of major grid lines. </theme_item> - <theme_item name="grid_minor" type="Color" default="Color( 1, 1, 1, 0.05 )"> + <theme_item name="grid_minor" type="Color" default="Color(1, 1, 1, 0.05)"> Color of minor grid lines. </theme_item> <theme_item name="minimap" type="Texture2D"> @@ -361,10 +361,10 @@ <theme_item name="reset" type="Texture2D"> The icon for the zoom reset button. </theme_item> - <theme_item name="selection_fill" type="Color" default="Color( 1, 1, 1, 0.3 )"> + <theme_item name="selection_fill" type="Color" default="Color(1, 1, 1, 0.3)"> The fill color of the selection rectangle. </theme_item> - <theme_item name="selection_stroke" type="Color" default="Color( 1, 1, 1, 0.8 )"> + <theme_item name="selection_stroke" type="Color" default="Color(1, 1, 1, 0.8)"> The outline color of the selection rectangle. </theme_item> <theme_item name="snap" type="Texture2D"> diff --git a/doc/classes/GraphNode.xml b/doc/classes/GraphNode.xml index 82ba45f11a..84eda7fcea 100644 --- a/doc/classes/GraphNode.xml +++ b/doc/classes/GraphNode.xml @@ -285,7 +285,7 @@ <member name="overlay" type="int" setter="set_overlay" getter="get_overlay" enum="GraphNode.Overlay" default="0"> Sets the overlay shown above the GraphNode. See [enum Overlay]. </member> - <member name="position_offset" type="Vector2" setter="set_position_offset" getter="get_position_offset" default="Vector2( 0, 0 )"> + <member name="position_offset" type="Vector2" setter="set_position_offset" getter="get_position_offset" default="Vector2(0, 0)"> The offset of the GraphNode, relative to the scroll offset of the [GraphEdit]. [b]Note:[/b] You cannot use position offset directly, as [GraphEdit] is a [Container]. </member> @@ -365,7 +365,7 @@ <theme_item name="close" type="Texture2D"> The icon for the close button, visible when [member show_close] is enabled. </theme_item> - <theme_item name="close_color" type="Color" default="Color( 0, 0, 0, 1 )"> + <theme_item name="close_color" type="Color" default="Color(0, 0, 0, 1)"> The color modulation applied to the close button icon. </theme_item> <theme_item name="close_offset" type="int" default="18"> @@ -396,7 +396,7 @@ <theme_item name="resizer" type="Texture2D"> The icon used for resizer, visible when [member resizable] is enabled. </theme_item> - <theme_item name="resizer_color" type="Color" default="Color( 0, 0, 0, 1 )"> + <theme_item name="resizer_color" type="Color" default="Color(0, 0, 0, 1)"> The color modulation applied to the resizer icon. </theme_item> <theme_item name="selectedframe" type="StyleBox"> @@ -405,7 +405,7 @@ <theme_item name="separation" type="int" default="1"> The vertical distance between ports. </theme_item> - <theme_item name="title_color" type="Color" default="Color( 0, 0, 0, 1 )"> + <theme_item name="title_color" type="Color" default="Color(0, 0, 0, 1)"> Color of the title text. </theme_item> <theme_item name="title_font" type="Font"> diff --git a/doc/classes/HTTPRequest.xml b/doc/classes/HTTPRequest.xml index 25667d8f79..908e355db3 100644 --- a/doc/classes/HTTPRequest.xml +++ b/doc/classes/HTTPRequest.xml @@ -192,7 +192,7 @@ </return> <argument index="0" name="url" type="String"> </argument> - <argument index="1" name="custom_headers" type="PackedStringArray" default="PackedStringArray( )"> + <argument index="1" name="custom_headers" type="PackedStringArray" default="PackedStringArray()"> </argument> <argument index="2" name="ssl_validate_domain" type="bool" default="true"> </argument> @@ -211,13 +211,13 @@ </return> <argument index="0" name="url" type="String"> </argument> - <argument index="1" name="custom_headers" type="PackedStringArray" default="PackedStringArray( )"> + <argument index="1" name="custom_headers" type="PackedStringArray" default="PackedStringArray()"> </argument> <argument index="2" name="ssl_validate_domain" type="bool" default="true"> </argument> <argument index="3" name="method" type="int" enum="HTTPClient.Method" default="0"> </argument> - <argument index="4" name="request_data_raw" type="PackedByteArray" default="PackedByteArray( )"> + <argument index="4" name="request_data_raw" type="PackedByteArray" default="PackedByteArray()"> </argument> <description> Creates request on the underlying [HTTPClient] using a raw array of bytes for the request body. If there is no configuration errors, it tries to connect using [method HTTPClient.connect_to_host] and passes parameters onto [method HTTPClient.request]. diff --git a/doc/classes/HeightMapShape3D.xml b/doc/classes/HeightMapShape3D.xml index f6f2a27891..9a9d3bf8f4 100644 --- a/doc/classes/HeightMapShape3D.xml +++ b/doc/classes/HeightMapShape3D.xml @@ -11,7 +11,7 @@ <methods> </methods> <members> - <member name="map_data" type="PackedFloat32Array" setter="set_map_data" getter="get_map_data" default="PackedFloat32Array( 0, 0, 0, 0 )"> + <member name="map_data" type="PackedFloat32Array" setter="set_map_data" getter="get_map_data" default="PackedFloat32Array(0, 0, 0, 0)"> Height map data, pool array must be of [member map_width] * [member map_depth] size. </member> <member name="map_depth" type="int" setter="set_map_depth" getter="get_map_depth" default="2"> diff --git a/doc/classes/Image.xml b/doc/classes/Image.xml index 91a07f66e0..167b90ea73 100644 --- a/doc/classes/Image.xml +++ b/doc/classes/Image.xml @@ -560,7 +560,7 @@ </method> </methods> <members> - <member name="data" type="Dictionary" setter="_set_data" getter="_get_data" default="{"data": PackedByteArray( ),"format": "Lum8","height": 0,"mipmaps": false,"width": 0}"> + <member name="data" type="Dictionary" setter="_set_data" getter="_get_data" default="{"data": PackedByteArray(),"format": "Lum8","height": 0,"mipmaps": false,"width": 0}"> Holds all the image's color data in a given format. See [enum Format] constants. </member> </members> diff --git a/doc/classes/Input.xml b/doc/classes/Input.xml index ebfd32c5fb..05a8bd268e 100644 --- a/doc/classes/Input.xml +++ b/doc/classes/Input.xml @@ -341,7 +341,7 @@ </argument> <argument index="1" name="shape" type="int" enum="Input.CursorShape" default="0"> </argument> - <argument index="2" name="hotspot" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="2" name="hotspot" type="Vector2" default="Vector2(0, 0)"> </argument> <description> Sets a custom mouse cursor image, which is only visible inside the game window. The hotspot can also be specified. Passing [code]null[/code] to the image parameter resets to the system cursor. See [enum CursorShape] for the list of shapes. diff --git a/doc/classes/InputEvent.xml b/doc/classes/InputEvent.xml index 28c4773f51..c28c4c4282 100644 --- a/doc/classes/InputEvent.xml +++ b/doc/classes/InputEvent.xml @@ -90,20 +90,23 @@ Returns [code]true[/code] if this input event is an echo event (only for events of type [InputEventKey]). </description> </method> - <method name="is_pressed" qualifiers="const"> + <method name="is_match" qualifiers="const"> <return type="bool"> </return> + <argument index="0" name="event" type="InputEvent"> + </argument> + <argument index="1" name="exact_match" type="bool" default="true"> + </argument> <description> - Returns [code]true[/code] if this input event is pressed. Not relevant for events of type [InputEventMouseMotion] or [InputEventScreenDrag]. + Returns [code]true[/code] if the specified [code]event[/code] matches this event. Only valid for action events i.e key ([InputEventKey]), button ([InputEventMouseButton] or [InputEventJoypadButton]), axis [InputEventJoypadMotion] or action ([InputEventAction]) events. + If [code]exact_match[/code] is [code]false[/code], it ignores the input modifiers for [InputEventKey] and [InputEventMouseButton] events, and the direction for [InputEventJoypadMotion] events. </description> </method> - <method name="shortcut_match" qualifiers="const"> + <method name="is_pressed" qualifiers="const"> <return type="bool"> </return> - <argument index="0" name="event" type="InputEvent"> - </argument> <description> - Returns [code]true[/code] if the given input event is checking for the same key ([InputEventKey]), button ([InputEventJoypadButton]) or action ([InputEventAction]). + Returns [code]true[/code] if this input event is pressed. Not relevant for events of type [InputEventMouseMotion] or [InputEventScreenDrag]. </description> </method> <method name="xformed_by" qualifiers="const"> @@ -111,7 +114,7 @@ </return> <argument index="0" name="xform" type="Transform2D"> </argument> - <argument index="1" name="local_ofs" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="1" name="local_ofs" type="Vector2" default="Vector2(0, 0)"> </argument> <description> Returns a copy of the given input event which has been offset by [code]local_ofs[/code] and transformed by [code]xform[/code]. Relevant for events of type [InputEventMouseButton], [InputEventMouseMotion], [InputEventScreenTouch], [InputEventScreenDrag], [InputEventMagnifyGesture] and [InputEventPanGesture]. diff --git a/doc/classes/InputEventGesture.xml b/doc/classes/InputEventGesture.xml index 861ec026cd..fbde318ada 100644 --- a/doc/classes/InputEventGesture.xml +++ b/doc/classes/InputEventGesture.xml @@ -10,7 +10,7 @@ <methods> </methods> <members> - <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2( 0, 0 )"> + <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2(0, 0)"> The local gesture position relative to the [Viewport]. If used in [method Control._gui_input], the position is relative to the current [Control] that received this gesture. </member> </members> diff --git a/doc/classes/InputEventMouse.xml b/doc/classes/InputEventMouse.xml index e54c3224da..b8043118b7 100644 --- a/doc/classes/InputEventMouse.xml +++ b/doc/classes/InputEventMouse.xml @@ -15,10 +15,10 @@ <member name="button_mask" type="int" setter="set_button_mask" getter="get_button_mask" default="0"> The mouse button mask identifier, one of or a bitwise combination of the [enum MouseButton] button masks. </member> - <member name="global_position" type="Vector2" setter="set_global_position" getter="get_global_position" default="Vector2( 0, 0 )"> + <member name="global_position" type="Vector2" setter="set_global_position" getter="get_global_position" default="Vector2(0, 0)"> The global mouse position relative to the current [Viewport] when used in [method Control._gui_input], otherwise is at 0,0. </member> - <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2( 0, 0 )"> + <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2(0, 0)"> The local mouse position relative to the [Viewport]. If used in [method Control._gui_input], the position is relative to the current [Control] which is under the mouse. </member> </members> diff --git a/doc/classes/InputEventMouseMotion.xml b/doc/classes/InputEventMouseMotion.xml index 0f9e71adb4..881d74ac7b 100644 --- a/doc/classes/InputEventMouseMotion.xml +++ b/doc/classes/InputEventMouseMotion.xml @@ -17,14 +17,14 @@ <member name="pressure" type="float" setter="set_pressure" getter="get_pressure" default="0.0"> Represents the pressure the user puts on the pen. Ranges from [code]0.0[/code] to [code]1.0[/code]. </member> - <member name="relative" type="Vector2" setter="set_relative" getter="get_relative" default="Vector2( 0, 0 )"> + <member name="relative" type="Vector2" setter="set_relative" getter="get_relative" default="Vector2(0, 0)"> The mouse position relative to the previous position (position at the last frame). [b]Note:[/b] Since [InputEventMouseMotion] is only emitted when the mouse moves, the last event won't have a relative position of [code]Vector2(0, 0)[/code] when the user stops moving the mouse. </member> - <member name="speed" type="Vector2" setter="set_speed" getter="get_speed" default="Vector2( 0, 0 )"> + <member name="speed" type="Vector2" setter="set_speed" getter="get_speed" default="Vector2(0, 0)"> The mouse speed in pixels per second. </member> - <member name="tilt" type="Vector2" setter="set_tilt" getter="get_tilt" default="Vector2( 0, 0 )"> + <member name="tilt" type="Vector2" setter="set_tilt" getter="get_tilt" default="Vector2(0, 0)"> Represents the angles of tilt of the pen. Positive X-coordinate value indicates a tilt to the right. Positive Y-coordinate value indicates a tilt toward the user. Ranges from [code]-1.0[/code] to [code]1.0[/code] for both axes. </member> </members> diff --git a/doc/classes/InputEventPanGesture.xml b/doc/classes/InputEventPanGesture.xml index 83161cd163..ffb1901dad 100644 --- a/doc/classes/InputEventPanGesture.xml +++ b/doc/classes/InputEventPanGesture.xml @@ -9,7 +9,7 @@ <methods> </methods> <members> - <member name="delta" type="Vector2" setter="set_delta" getter="get_delta" default="Vector2( 0, 0 )"> + <member name="delta" type="Vector2" setter="set_delta" getter="get_delta" default="Vector2(0, 0)"> </member> </members> <constants> diff --git a/doc/classes/InputEventScreenDrag.xml b/doc/classes/InputEventScreenDrag.xml index d69f175be8..079ac03f45 100644 --- a/doc/classes/InputEventScreenDrag.xml +++ b/doc/classes/InputEventScreenDrag.xml @@ -15,13 +15,13 @@ <member name="index" type="int" setter="set_index" getter="get_index" default="0"> The drag event index in the case of a multi-drag event. </member> - <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2( 0, 0 )"> + <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2(0, 0)"> The drag position. </member> - <member name="relative" type="Vector2" setter="set_relative" getter="get_relative" default="Vector2( 0, 0 )"> + <member name="relative" type="Vector2" setter="set_relative" getter="get_relative" default="Vector2(0, 0)"> The drag position relative to its start position. </member> - <member name="speed" type="Vector2" setter="set_speed" getter="get_speed" default="Vector2( 0, 0 )"> + <member name="speed" type="Vector2" setter="set_speed" getter="get_speed" default="Vector2(0, 0)"> The drag speed. </member> </members> diff --git a/doc/classes/InputEventScreenTouch.xml b/doc/classes/InputEventScreenTouch.xml index f497f2fecc..7aa5f62b05 100644 --- a/doc/classes/InputEventScreenTouch.xml +++ b/doc/classes/InputEventScreenTouch.xml @@ -16,7 +16,7 @@ <member name="index" type="int" setter="set_index" getter="get_index" default="0"> The touch index in the case of a multi-touch event. One index = one finger. </member> - <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2( 0, 0 )"> + <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2(0, 0)"> The touch position. </member> <member name="pressed" type="bool" setter="set_pressed" getter="is_pressed" default="false"> diff --git a/doc/classes/IntervalTweener.xml b/doc/classes/IntervalTweener.xml new file mode 100644 index 0000000000..1c59003c70 --- /dev/null +++ b/doc/classes/IntervalTweener.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="IntervalTweener" inherits="Tweener" version="4.0"> + <brief_description> + Creates an idle interval in a [Tween] animation. + </brief_description> + <description> + [IntervalTweener] is used to make delays in a tweening sequence. See [method Tween.tween_interval] for more usage information. + [b]Note:[/b] [method Tween.tween_interval] is the only correct way to create [IntervalTweener]. Any [IntervalTweener] created manually will not function correctly. + </description> + <tutorials> + </tutorials> + <methods> + </methods> + <constants> + </constants> +</class> diff --git a/doc/classes/ItemList.xml b/doc/classes/ItemList.xml index 0020cbf242..c639e0b88e 100644 --- a/doc/classes/ItemList.xml +++ b/doc/classes/ItemList.xml @@ -484,7 +484,7 @@ The width all columns will be adjusted to. A value of zero disables the adjustment, each item will have a width equal to the width of its content and the columns will have an uneven width. </member> - <member name="fixed_icon_size" type="Vector2" setter="set_fixed_icon_size" getter="get_fixed_icon_size" default="Vector2( 0, 0 )"> + <member name="fixed_icon_size" type="Vector2" setter="set_fixed_icon_size" getter="get_fixed_icon_size" default="Vector2(0, 0)"> The size all icons will be adjusted to. If either X or Y component is not greater than zero, icon size won't be affected. </member> @@ -593,19 +593,19 @@ <theme_item name="font" type="Font"> [Font] of the item's text. </theme_item> - <theme_item name="font_color" type="Color" default="Color( 0.63, 0.63, 0.63, 1 )"> + <theme_item name="font_color" type="Color" default="Color(0.63, 0.63, 0.63, 1)"> Default text [Color] of the item. </theme_item> - <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)"> The tint of text outline of the item. </theme_item> - <theme_item name="font_selected_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_selected_color" type="Color" default="Color(1, 1, 1, 1)"> Text [Color] used when the item is selected. </theme_item> <theme_item name="font_size" type="int"> Font size of the item's text. </theme_item> - <theme_item name="guide_color" type="Color" default="Color( 0, 0, 0, 0.1 )"> + <theme_item name="guide_color" type="Color" default="Color(0, 0, 0, 0.1)"> [Color] of the guideline. The guideline is a line drawn between each row of items. </theme_item> <theme_item name="hseparation" type="int" default="4"> diff --git a/doc/classes/JSON.xml b/doc/classes/JSON.xml index 7baff7aa39..b95aaed143 100644 --- a/doc/classes/JSON.xml +++ b/doc/classes/JSON.xml @@ -1,45 +1,88 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="JSON" inherits="Object" version="4.0"> +<class name="JSON" inherits="RefCounted" version="4.0"> <brief_description> - Helper class for parsing JSON data. + Helper class for creating and parsing JSON data. </brief_description> <description> - Helper class for parsing JSON data. For usage example and other important hints, see [JSONParseResult]. + The [JSON] enables all data types to be converted to and from a JSON string. This useful for serializing data to save to a file or send over the network. + [method stringify] is used to convert any data type into a JSON string. + [method parse] is used to convert any existing JSON data into a [Variant] that can be used within Godot. If successfully parsed, use [method get_data] to retrieve the [Variant], and use [code]typeof[/code] to check if the Variant's type is what you expect. JSON Objects are converted into a [Dictionary], but JSON data can be used to store [Array]s, numbers, [String]s and even just a boolean. + [b]Example[/b] + [codeblock] + var data_to_send = ["a", "b", "c"] + var json = JSON.new() + var json_string = json.stringify(data_to_send) + # Save data + # ... + # Retrieve data + var error = json.parse(json_string) + if error == OK: + var data_received = json.get_data() + if typeof(data_received) == TYPE_ARRAY: + print(data_received) # Prints array + else: + print("Unexpected data") + else: + print("JSON Parse Error: ", json.get_error_message(), " in ", json_string, " at line ", json.get_error_line()) + [/codeblock] </description> <tutorials> </tutorials> <methods> + <method name="get_data" qualifiers="const"> + <return type="Variant"> + </return> + <description> + Returns the [Variant] containing the data of a successful [method parse]. + [b]Note:[/b] It will return [code]Null[/code] if the last call to parse was unsuccessful or [method parse] has not yet been called. + </description> + </method> + <method name="get_error_line" qualifiers="const"> + <return type="int"> + </return> + <description> + Returns [code]0[/code] if the last call to [method parse] was successful, or the line number where the parse failed. + </description> + </method> + <method name="get_error_message" qualifiers="const"> + <return type="String"> + </return> + <description> + Returns an empty string if the last call to [method parse] was successful, or the error message if it failed. + </description> + </method> <method name="parse"> - <return type="JSONParseResult"> + <return type="int" enum="Error"> </return> - <argument index="0" name="json" type="String"> + <argument index="0" name="json_string" type="String"> </argument> <description> - Parses a JSON-encoded string and returns a [JSONParseResult] containing the result. + Attempts to parse the [code]json_string[/code] provided. + Returns an [enum Error]. If the parse was successful, it returns [code]OK[/code] and the result can be retrieved using [method get_data]. If unsuccessful, use [method get_error_line] and [method get_error_message] for identifying the source of the failure. </description> </method> - <method name="print"> + <method name="stringify"> <return type="String"> </return> - <argument index="0" name="value" type="Variant"> + <argument index="0" name="data" type="Variant"> </argument> <argument index="1" name="indent" type="String" default=""""> </argument> - <argument index="2" name="sort_keys" type="bool" default="false"> + <argument index="2" name="sort_keys" type="bool" default="true"> </argument> <argument index="3" name="full_precision" type="bool" default="false"> </argument> <description> Converts a [Variant] var to JSON text and returns the result. Useful for serializing data to store or send over the network. [b]Note:[/b] The JSON specification does not define integer or float types, but only a [i]number[/i] type. Therefore, converting a Variant to JSON text will convert all numerical values to [float] types. - [b]Note:[/b] If [code]full_precision[/code] is true, when printing floats, the unreliable digits are printed in addition to the reliable digits to guarantee exact decoding. - Use [code]indent[/code] parameter to pretty print the output. + [b]Note:[/b] If [code]full_precision[/code] is true, when stringifying floats, the unreliable digits are stringified in addition to the reliable digits to guarantee exact decoding. + Use [code]indent[/code] parameter to pretty stringify the output. [b]Example output:[/b] [codeblock] - ## JSON.print(my_dictionary) + ## JSON.stringify(my_dictionary) {"name":"my_dictionary","version":"1.0.0","entities":[{"name":"entity_0","value":"value_0"},{"name":"entity_1","value":"value_1"}]} - ## JSON.print(my_dictionary, "\t") + ## JSON.stringify(my_dictionary, "\t") { "name": "my_dictionary", "version": "1.0.0", diff --git a/doc/classes/JSONParseResult.xml b/doc/classes/JSONParseResult.xml deleted file mode 100644 index 7311343b68..0000000000 --- a/doc/classes/JSONParseResult.xml +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="JSONParseResult" inherits="RefCounted" version="4.0"> - <brief_description> - Data class wrapper for decoded JSON. - </brief_description> - <description> - Returned by [method JSON.parse], [JSONParseResult] contains the decoded JSON or error information if the JSON source wasn't successfully parsed. You can check if the JSON source was successfully parsed with [code]if json_result.error == OK[/code]. - </description> - <tutorials> - </tutorials> - <methods> - </methods> - <members> - <member name="error" type="int" setter="set_error" getter="get_error" enum="Error"> - The error type if the JSON source was not successfully parsed. See the [enum Error] constants. - </member> - <member name="error_line" type="int" setter="set_error_line" getter="get_error_line" default="-1"> - The line number where the error occurred if the JSON source was not successfully parsed. - </member> - <member name="error_string" type="String" setter="set_error_string" getter="get_error_string" default=""""> - The error message if the JSON source was not successfully parsed. See the [enum Error] constants. - </member> - <member name="result" type="Variant" setter="set_result" getter="get_result"> - A [Variant] containing the parsed JSON. Use [method @GlobalScope.typeof] or the [code]is[/code] keyword to check if it is what you expect. For example, if the JSON source starts with curly braces ([code]{}[/code]), a [Dictionary] will be returned. If the JSON source starts with brackets ([code][][/code]), an [Array] will be returned. - [b]Note:[/b] The JSON specification does not define integer or float types, but only a [i]number[/i] type. Therefore, parsing a JSON text will convert all numerical values to [float] types. - [b]Note:[/b] JSON objects do not preserve key order like Godot dictionaries, thus, you should not rely on keys being in a certain order if a dictionary is constructed from JSON. In contrast, JSON arrays retain the order of their elements: - [codeblocks] - [gdscript] - var p = JSON.parse('["hello", "world", "!"]') - if typeof(p.result) == TYPE_ARRAY: - print(p.result[0]) # Prints "hello" - else: - push_error("Unexpected results.") - [/gdscript] - [csharp] - JSONParseResult p = JSON.Parse("[\"hello\"], \"world\", \"!\"]"); - if (p.Result is Godot.Collections.Array) - { - GD.Print((p.Result as Godot.Collections.Array)[0]); // Prints "hello" - } - else - { - GD.PushError("Unexpected results."); - } - [/csharp] - [/codeblocks] - </member> - </members> - <constants> - </constants> -</class> diff --git a/doc/classes/JSONParser.xml b/doc/classes/JSONParser.xml deleted file mode 100644 index 991629f255..0000000000 --- a/doc/classes/JSONParser.xml +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="JSONParser" inherits="RefCounted" version="4.0"> - <brief_description> - </brief_description> - <description> - </description> - <tutorials> - </tutorials> - <methods> - <method name="decode_data"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="data" type="Variant"> - </argument> - <argument index="1" name="indent" type="String" default=""""> - </argument> - <argument index="2" name="sort_keys" type="bool" default="true"> - </argument> - <description> - </description> - </method> - <method name="get_data" qualifiers="const"> - <return type="Variant"> - </return> - <description> - </description> - </method> - <method name="get_error_line" qualifiers="const"> - <return type="int"> - </return> - <description> - </description> - </method> - <method name="get_error_text" qualifiers="const"> - <return type="String"> - </return> - <description> - </description> - </method> - <method name="get_string" qualifiers="const"> - <return type="String"> - </return> - <description> - </description> - </method> - <method name="parse_string"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="json_string" type="String"> - </argument> - <description> - </description> - </method> - </methods> - <constants> - </constants> -</class> diff --git a/doc/classes/KinematicCollision2D.xml b/doc/classes/KinematicCollision2D.xml index 5480d7d55f..d7999f1aa0 100644 --- a/doc/classes/KinematicCollision2D.xml +++ b/doc/classes/KinematicCollision2D.xml @@ -21,28 +21,31 @@ <member name="collider_metadata" type="Variant" setter="" getter="get_collider_metadata"> The colliding body's metadata. See [Object]. </member> + <member name="collider_rid" type="RID" setter="" getter="get_collider_rid"> + The colliding body's [RID] used by the [PhysicsServer2D]. + </member> <member name="collider_shape" type="Object" setter="" getter="get_collider_shape"> The colliding body's shape. </member> <member name="collider_shape_index" type="int" setter="" getter="get_collider_shape_index" default="0"> The colliding shape's index. See [CollisionObject2D]. </member> - <member name="collider_velocity" type="Vector2" setter="" getter="get_collider_velocity" default="Vector2( 0, 0 )"> + <member name="collider_velocity" type="Vector2" setter="" getter="get_collider_velocity" default="Vector2(0, 0)"> The colliding object's velocity. </member> <member name="local_shape" type="Object" setter="" getter="get_local_shape"> The moving object's colliding shape. </member> - <member name="normal" type="Vector2" setter="" getter="get_normal" default="Vector2( 0, 0 )"> + <member name="normal" type="Vector2" setter="" getter="get_normal" default="Vector2(0, 0)"> The colliding body's shape's normal at the point of collision. </member> - <member name="position" type="Vector2" setter="" getter="get_position" default="Vector2( 0, 0 )"> + <member name="position" type="Vector2" setter="" getter="get_position" default="Vector2(0, 0)"> The point of collision, in global coordinates. </member> - <member name="remainder" type="Vector2" setter="" getter="get_remainder" default="Vector2( 0, 0 )"> + <member name="remainder" type="Vector2" setter="" getter="get_remainder" default="Vector2(0, 0)"> The moving object's remaining movement vector. </member> - <member name="travel" type="Vector2" setter="" getter="get_travel" default="Vector2( 0, 0 )"> + <member name="travel" type="Vector2" setter="" getter="get_travel" default="Vector2(0, 0)"> The distance the moving object traveled before collision. </member> </members> diff --git a/doc/classes/KinematicCollision3D.xml b/doc/classes/KinematicCollision3D.xml index 329efab474..abdb5b4f4e 100644 --- a/doc/classes/KinematicCollision3D.xml +++ b/doc/classes/KinematicCollision3D.xml @@ -21,28 +21,31 @@ <member name="collider_metadata" type="Variant" setter="" getter="get_collider_metadata"> The colliding body's metadata. See [Object]. </member> + <member name="collider_rid" type="RID" setter="" getter="get_collider_rid"> + The colliding body's [RID] used by the [PhysicsServer3D]. + </member> <member name="collider_shape" type="Object" setter="" getter="get_collider_shape"> The colliding body's shape. </member> <member name="collider_shape_index" type="int" setter="" getter="get_collider_shape_index" default="0"> The colliding shape's index. See [CollisionObject3D]. </member> - <member name="collider_velocity" type="Vector3" setter="" getter="get_collider_velocity" default="Vector3( 0, 0, 0 )"> + <member name="collider_velocity" type="Vector3" setter="" getter="get_collider_velocity" default="Vector3(0, 0, 0)"> The colliding object's velocity. </member> <member name="local_shape" type="Object" setter="" getter="get_local_shape"> The moving object's colliding shape. </member> - <member name="normal" type="Vector3" setter="" getter="get_normal" default="Vector3( 0, 0, 0 )"> + <member name="normal" type="Vector3" setter="" getter="get_normal" default="Vector3(0, 0, 0)"> The colliding body's shape's normal at the point of collision. </member> - <member name="position" type="Vector3" setter="" getter="get_position" default="Vector3( 0, 0, 0 )"> + <member name="position" type="Vector3" setter="" getter="get_position" default="Vector3(0, 0, 0)"> The point of collision, in global coordinates. </member> - <member name="remainder" type="Vector3" setter="" getter="get_remainder" default="Vector3( 0, 0, 0 )"> + <member name="remainder" type="Vector3" setter="" getter="get_remainder" default="Vector3(0, 0, 0)"> The moving object's remaining movement vector. </member> - <member name="travel" type="Vector3" setter="" getter="get_travel" default="Vector3( 0, 0, 0 )"> + <member name="travel" type="Vector3" setter="" getter="get_travel" default="Vector3(0, 0, 0)"> The distance the moving object traveled before collision. </member> </members> diff --git a/doc/classes/Label.xml b/doc/classes/Label.xml index 76b9686393..ee59f0c85a 100644 --- a/doc/classes/Label.xml +++ b/doc/classes/Label.xml @@ -98,7 +98,7 @@ <member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="Control.StructuredTextParser" default="0"> Set BiDi algorithm override for the structured text. </member> - <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[ ]"> + <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]"> Set additional options for BiDi override. </member> <member name="text" type="String" setter="set_text" getter="get_text" default=""""> @@ -147,13 +147,13 @@ <theme_item name="font" type="Font"> [Font] used for the [Label]'s text. </theme_item> - <theme_item name="font_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_color" type="Color" default="Color(1, 1, 1, 1)"> Default text [Color] of the [Label]. </theme_item> - <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)"> The tint of [Font]'s outline. </theme_item> - <theme_item name="font_shadow_color" type="Color" default="Color( 0, 0, 0, 0 )"> + <theme_item name="font_shadow_color" type="Color" default="Color(0, 0, 0, 0)"> [Color] of the text's shadow effect. </theme_item> <theme_item name="font_size" type="int"> diff --git a/doc/classes/Light2D.xml b/doc/classes/Light2D.xml index f6698352ab..0e71f29b58 100644 --- a/doc/classes/Light2D.xml +++ b/doc/classes/Light2D.xml @@ -30,7 +30,7 @@ <member name="blend_mode" type="int" setter="set_blend_mode" getter="get_blend_mode" enum="Light2D.BlendMode" default="0"> The Light2D's blend mode. See [enum BlendMode] constants for values. </member> - <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 1, 1, 1, 1 )"> + <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)"> The Light2D's [Color]. </member> <member name="editor_only" type="bool" setter="set_editor_only" getter="is_editor_only" default="false"> @@ -57,7 +57,7 @@ <member name="range_z_min" type="int" setter="set_z_range_min" getter="get_z_range_min" default="-1024"> Minimum [code]z[/code] value of objects that are affected by the Light2D. </member> - <member name="shadow_color" type="Color" setter="set_shadow_color" getter="get_shadow_color" default="Color( 0, 0, 0, 0 )"> + <member name="shadow_color" type="Color" setter="set_shadow_color" getter="get_shadow_color" default="Color(0, 0, 0, 0)"> [Color] of shadows cast by the Light2D. </member> <member name="shadow_enabled" type="bool" setter="set_shadow_enabled" getter="is_shadow_enabled" default="false"> diff --git a/doc/classes/Light3D.xml b/doc/classes/Light3D.xml index 42b9ed8ab4..84abf57cb6 100644 --- a/doc/classes/Light3D.xml +++ b/doc/classes/Light3D.xml @@ -42,7 +42,7 @@ <member name="light_bake_mode" type="int" setter="set_bake_mode" getter="get_bake_mode" enum="Light3D.BakeMode" default="1"> The light's bake mode. See [enum BakeMode]. </member> - <member name="light_color" type="Color" setter="set_color" getter="get_color" default="Color( 1, 1, 1, 1 )"> + <member name="light_color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)"> The light's color. An [i]overbright[/i] color can be used to achieve a result equivalent to increasing the light's [member light_energy]. </member> <member name="light_cull_mask" type="int" setter="set_cull_mask" getter="get_cull_mask" default="4294967295"> @@ -72,7 +72,7 @@ <member name="shadow_blur" type="float" setter="set_param" getter="get_param" default="1.0"> Blurs the edges of the shadow. Can be used to hide pixel artifacts in low-resolution shadow maps. A high value can impact performance, make shadows appear grainy and can cause other unwanted artifacts. Try to keep as near default as possible. </member> - <member name="shadow_color" type="Color" setter="set_shadow_color" getter="get_shadow_color" default="Color( 0, 0, 0, 1 )"> + <member name="shadow_color" type="Color" setter="set_shadow_color" getter="get_shadow_color" default="Color(0, 0, 0, 1)"> The color of shadows cast by this light. </member> <member name="shadow_enabled" type="bool" setter="set_shadow" getter="has_shadow" default="false"> diff --git a/doc/classes/Line2D.xml b/doc/classes/Line2D.xml index dec5d60cbb..587d5833b9 100644 --- a/doc/classes/Line2D.xml +++ b/doc/classes/Line2D.xml @@ -74,7 +74,7 @@ <member name="begin_cap_mode" type="int" setter="set_begin_cap_mode" getter="get_begin_cap_mode" enum="Line2D.LineCapMode" default="0"> Controls the style of the line's first point. Use [enum LineCapMode] constants. </member> - <member name="default_color" type="Color" setter="set_default_color" getter="get_default_color" default="Color( 1, 1, 1, 1 )"> + <member name="default_color" type="Color" setter="set_default_color" getter="get_default_color" default="Color(1, 1, 1, 1)"> The line's color. Will not be used if a gradient is set. </member> <member name="end_cap_mode" type="int" setter="set_end_cap_mode" getter="get_end_cap_mode" enum="Line2D.LineCapMode" default="0"> @@ -86,7 +86,7 @@ <member name="joint_mode" type="int" setter="set_joint_mode" getter="get_joint_mode" enum="Line2D.LineJointMode" default="0"> The style for the points between the start and the end. </member> - <member name="points" type="PackedVector2Array" setter="set_points" getter="get_points" default="PackedVector2Array( )"> + <member name="points" type="PackedVector2Array" setter="set_points" getter="get_points" default="PackedVector2Array()"> The points that form the lines. The line is drawn between every point set in this array. Points are interpreted as local vectors. </member> <member name="round_precision" type="int" setter="set_round_precision" getter="get_round_precision" default="8"> diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml index e11ae7969a..f1e7c5f6e1 100644 --- a/doc/classes/LineEdit.xml +++ b/doc/classes/LineEdit.xml @@ -221,7 +221,7 @@ <member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="Control.StructuredTextParser" default="0"> Set BiDi algorithm override for the structured text. </member> - <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[ ]"> + <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]"> Set additional options for BiDi override. </member> <member name="text" type="String" setter="set_text" getter="get_text" default=""""> @@ -359,16 +359,16 @@ </constant> </constants> <theme_items> - <theme_item name="caret_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )"> + <theme_item name="caret_color" type="Color" default="Color(0.94, 0.94, 0.94, 1)"> Color of the [LineEdit]'s caret (text cursor). </theme_item> <theme_item name="clear" type="Texture2D"> Texture for the clear button. See [member clear_button_enabled]. </theme_item> - <theme_item name="clear_button_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )"> + <theme_item name="clear_button_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> Color used as default tint for the clear button. </theme_item> - <theme_item name="clear_button_color_pressed" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="clear_button_color_pressed" type="Color" default="Color(1, 1, 1, 1)"> Color used for the clear button when it's pressed. </theme_item> <theme_item name="focus" type="StyleBox"> @@ -377,19 +377,19 @@ <theme_item name="font" type="Font"> Font used for the text. </theme_item> - <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )"> + <theme_item name="font_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> Default font color. </theme_item> - <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)"> The tint of text outline of the [LineEdit]. </theme_item> - <theme_item name="font_selected_color" type="Color" default="Color( 0, 0, 0, 1 )"> + <theme_item name="font_selected_color" type="Color" default="Color(0, 0, 0, 1)"> Font color for selected text (inside the selection rectangle). </theme_item> <theme_item name="font_size" type="int"> Font size of the [LineEdit]'s text. </theme_item> - <theme_item name="font_uneditable_color" type="Color" default="Color( 0.88, 0.88, 0.88, 0.5 )"> + <theme_item name="font_uneditable_color" type="Color" default="Color(0.88, 0.88, 0.88, 0.5)"> Font color when editing is disabled. </theme_item> <theme_item name="minimum_character_width" type="int" default="4"> @@ -404,7 +404,7 @@ <theme_item name="read_only" type="StyleBox"> Background used when [LineEdit] is in read-only mode ([member editable] is set to [code]false[/code]). </theme_item> - <theme_item name="selection_color" type="Color" default="Color( 0.49, 0.49, 0.49, 1 )"> + <theme_item name="selection_color" type="Color" default="Color(0.49, 0.49, 0.49, 1)"> Color of the selection rectangle. </theme_item> </theme_items> diff --git a/doc/classes/LineShape2D.xml b/doc/classes/LineShape2D.xml index 58caf1b1de..434e6fba8e 100644 --- a/doc/classes/LineShape2D.xml +++ b/doc/classes/LineShape2D.xml @@ -14,8 +14,8 @@ <member name="distance" type="float" setter="set_distance" getter="get_distance" default="0.0"> The line's distance from the origin. </member> - <member name="normal" type="Vector2" setter="set_normal" getter="get_normal" default="Vector2( 0, 1 )"> - The line's normal. + <member name="normal" type="Vector2" setter="set_normal" getter="get_normal" default="Vector2(0, -1)"> + The line's normal. Defaults to [code]Vector2.UP[/code]. </member> </members> <constants> diff --git a/doc/classes/LinkButton.xml b/doc/classes/LinkButton.xml index 6e2f4399b3..51b20cd04d 100644 --- a/doc/classes/LinkButton.xml +++ b/doc/classes/LinkButton.xml @@ -47,7 +47,7 @@ <member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="Control.StructuredTextParser" default="0"> Set BiDi algorithm override for the structured text. </member> - <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[ ]"> + <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]"> Set additional options for BiDi override. </member> <member name="text" type="String" setter="set_text" getter="get_text" default=""""> @@ -78,16 +78,16 @@ <theme_item name="font" type="Font"> [Font] of the [LinkButton]'s text. </theme_item> - <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )"> + <theme_item name="font_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> Default text [Color] of the [LinkButton]. </theme_item> - <theme_item name="font_hover_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )"> + <theme_item name="font_hover_color" type="Color" default="Color(0.94, 0.94, 0.94, 1)"> Text [Color] used when the [LinkButton] is being hovered. </theme_item> - <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)"> The tint of text outline of the [LinkButton]. </theme_item> - <theme_item name="font_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_pressed_color" type="Color" default="Color(1, 1, 1, 1)"> Text [Color] used when the [LinkButton] is being pressed. </theme_item> <theme_item name="font_size" type="int"> diff --git a/doc/classes/MenuButton.xml b/doc/classes/MenuButton.xml index 7cbf9d3dfe..3b37853d70 100644 --- a/doc/classes/MenuButton.xml +++ b/doc/classes/MenuButton.xml @@ -56,19 +56,19 @@ <theme_item name="font" type="Font"> [Font] of the [MenuButton]'s text. </theme_item> - <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )"> + <theme_item name="font_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> Default text [Color] of the [MenuButton]. </theme_item> - <theme_item name="font_disabled_color" type="Color" default="Color( 1, 1, 1, 0.3 )"> + <theme_item name="font_disabled_color" type="Color" default="Color(1, 1, 1, 0.3)"> Text [Color] used when the [MenuButton] is disabled. </theme_item> - <theme_item name="font_hover_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )"> + <theme_item name="font_hover_color" type="Color" default="Color(0.94, 0.94, 0.94, 1)"> Text [Color] used when the [MenuButton] is being hovered. </theme_item> - <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)"> The tint of text outline of the [MenuButton]. </theme_item> - <theme_item name="font_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_pressed_color" type="Color" default="Color(1, 1, 1, 1)"> Text [Color] used when the [MenuButton] is being pressed. </theme_item> <theme_item name="font_size" type="int"> diff --git a/doc/classes/Mesh.xml b/doc/classes/Mesh.xml index ed7c39d4d9..3bbdfbe62e 100644 --- a/doc/classes/Mesh.xml +++ b/doc/classes/Mesh.xml @@ -106,7 +106,7 @@ </method> </methods> <members> - <member name="lightmap_size_hint" type="Vector2i" setter="set_lightmap_size_hint" getter="get_lightmap_size_hint" default="Vector2i( 0, 0 )"> + <member name="lightmap_size_hint" type="Vector2i" setter="set_lightmap_size_hint" getter="get_lightmap_size_hint" default="Vector2i(0, 0)"> Sets a hint to be used for lightmap resolution. </member> </members> diff --git a/doc/classes/MeshTexture.xml b/doc/classes/MeshTexture.xml index bcc9adf90f..57f2397874 100644 --- a/doc/classes/MeshTexture.xml +++ b/doc/classes/MeshTexture.xml @@ -14,7 +14,7 @@ <member name="base_texture" type="Texture2D" setter="set_base_texture" getter="get_base_texture"> Sets the base texture that the Mesh will use to draw. </member> - <member name="image_size" type="Vector2" setter="set_image_size" getter="get_image_size" default="Vector2( 0, 0 )"> + <member name="image_size" type="Vector2" setter="set_image_size" getter="get_image_size" default="Vector2(0, 0)"> Sets the size of the image, needed for reference. </member> <member name="mesh" type="Mesh" setter="set_mesh" getter="get_mesh"> diff --git a/doc/classes/MethodTweener.xml b/doc/classes/MethodTweener.xml new file mode 100644 index 0000000000..42b91abf93 --- /dev/null +++ b/doc/classes/MethodTweener.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="MethodTweener" inherits="Tweener" version="4.0"> + <brief_description> + Interpolates an abstract value and supplies it to a method called over time. + </brief_description> + <description> + [MethodTweener] is similar to a combination of [CallbackTweener] and [PropertyTweener]. It calls a method providing an interpolated value as a paramater. See [method Tween.tween_method] for more usage information. + [b]Note:[/b] [method Tween.tween_method] is the only correct way to create [MethodTweener]. Any [MethodTweener] created manually will not function correctly. + </description> + <tutorials> + </tutorials> + <methods> + <method name="set_delay"> + <return type="MethodTweener"> + </return> + <argument index="0" name="delay" type="float"> + </argument> + <description> + Sets the time in seconds after which the [MethodTweener] will start interpolating. By default there's no delay. + </description> + </method> + <method name="set_ease"> + <return type="MethodTweener"> + </return> + <argument index="0" name="ease" type="int" enum="Tween.EaseType"> + </argument> + <description> + Sets the type of used easing from [enum Tween.EaseType]. If not set, the default easing is used from the [Tween] that contains this Tweener. + </description> + </method> + <method name="set_trans"> + <return type="MethodTweener"> + </return> + <argument index="0" name="trans" type="int" enum="Tween.TransitionType"> + </argument> + <description> + Sets the type of used transition from [enum Tween.TransitionType]. If not set, the default transition is used from the [Tween] that contains this Tweener. + </description> + </method> + </methods> + <constants> + </constants> +</class> diff --git a/doc/classes/MultiMesh.xml b/doc/classes/MultiMesh.xml index 02628f4960..7151e58c5f 100644 --- a/doc/classes/MultiMesh.xml +++ b/doc/classes/MultiMesh.xml @@ -105,7 +105,7 @@ </method> </methods> <members> - <member name="buffer" type="PackedFloat32Array" setter="set_buffer" getter="get_buffer" default="PackedFloat32Array( )"> + <member name="buffer" type="PackedFloat32Array" setter="set_buffer" getter="get_buffer" default="PackedFloat32Array()"> </member> <member name="color_array" type="PackedColorArray" setter="_set_color_array" getter="_get_color_array"> </member> diff --git a/doc/classes/NinePatchRect.xml b/doc/classes/NinePatchRect.xml index d6de0ef4cf..5d59f994d3 100644 --- a/doc/classes/NinePatchRect.xml +++ b/doc/classes/NinePatchRect.xml @@ -53,7 +53,7 @@ <member name="patch_margin_top" type="int" setter="set_patch_margin" getter="get_patch_margin" default="0"> The height of the 9-slice's top row. A margin of 16 means the 9-slice's top corners and side will have a height of 16 pixels. You can set all 4 margin values individually to create panels with non-uniform borders. </member> - <member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2( 0, 0, 0, 0 )"> + <member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2(0, 0, 0, 0)"> Rectangular region of the texture to sample from. If you're working with an atlas, use this property to define the area the 9-slice should use. All other properties are relative to this one. If the rect is empty, NinePatchRect will use the whole texture. </member> <member name="texture" type="Texture2D" setter="set_texture" getter="get_texture"> diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index 1300351e47..87dcfe18cf 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -182,6 +182,16 @@ Returns [code]true[/code] if the node can process while the scene tree is paused (see [member process_mode]). Always returns [code]true[/code] if the scene tree is not paused, and [code]false[/code] if the node is not in the tree. </description> </method> + <method name="create_tween"> + <return type="Tween"> + </return> + <description> + Creates a new [Tween] and binds it to this node. This is equivalent of doing: + [codeblock] + get_tree().create_tween().bind_node(self) + [/codeblock] + </description> + </method> <method name="duplicate" qualifiers="const"> <return type="Node"> </return> @@ -568,7 +578,7 @@ </return> <argument index="0" name="method" type="StringName"> </argument> - <argument index="1" name="args" type="Array" default="[ ]"> + <argument index="1" name="args" type="Array" default="[]"> </argument> <argument index="2" name="parent_first" type="bool" default="false"> </argument> diff --git a/doc/classes/Node2D.xml b/doc/classes/Node2D.xml index 8ca945418c..cc99abf9cb 100644 --- a/doc/classes/Node2D.xml +++ b/doc/classes/Node2D.xml @@ -131,7 +131,7 @@ <member name="global_transform" type="Transform2D" setter="set_global_transform" getter="get_global_transform"> Global [Transform2D]. </member> - <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2( 0, 0 )"> + <member name="position" type="Vector2" setter="set_position" getter="get_position" default="Vector2(0, 0)"> Position, relative to the node's parent. </member> <member name="rotation" type="float" setter="set_rotation" getter="get_rotation" default="0.0"> @@ -140,7 +140,7 @@ <member name="rotation_degrees" type="float" setter="set_rotation_degrees" getter="get_rotation_degrees" default="0.0"> Rotation in degrees, relative to the node's parent. </member> - <member name="scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2( 1, 1 )"> + <member name="scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2(1, 1)"> The node's scale. Unscaled value: [code](1, 1)[/code]. </member> <member name="skew" type="float" setter="set_skew" getter="get_skew" default="0.0"> diff --git a/doc/classes/Node3D.xml b/doc/classes/Node3D.xml index 1c161803db..2dc8659d5d 100644 --- a/doc/classes/Node3D.xml +++ b/doc/classes/Node3D.xml @@ -103,7 +103,7 @@ </return> <argument index="0" name="target" type="Vector3"> </argument> - <argument index="1" name="up" type="Vector3" default="Vector3( 0, 1, 0 )"> + <argument index="1" name="up" type="Vector3" default="Vector3(0, 1, 0)"> </argument> <description> Rotates itself so that the local -Z axis points towards the [code]target[/code] position. @@ -118,7 +118,7 @@ </argument> <argument index="1" name="target" type="Vector3"> </argument> - <argument index="2" name="up" type="Vector3" default="Vector3( 0, 1, 0 )"> + <argument index="2" name="up" type="Vector3" default="Vector3(0, 1, 0)"> </argument> <description> Moves the node to the specified [code]position[/code], and then rotates itself to point toward the [code]target[/code] as per [method look_at]. Operations take place in global space. @@ -291,23 +291,23 @@ <member name="global_transform" type="Transform3D" setter="set_global_transform" getter="get_global_transform"> World3D space (global) [Transform3D] of this node. </member> - <member name="position" type="Vector3" setter="set_position" getter="get_position" default="Vector3( 0, 0, 0 )"> + <member name="position" type="Vector3" setter="set_position" getter="get_position" default="Vector3(0, 0, 0)"> Local position or translation of this node relative to the parent. This is equivalent to [code]transform.origin[/code]. </member> <member name="rotation" type="Vector3" setter="set_rotation" getter="get_rotation"> Rotation part of the local transformation in radians, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle). [b]Note:[/b] In the mathematical sense, rotation is a matrix and not a vector. The three Euler angles, which are the three independent parameters of the Euler-angle parametrization of the rotation matrix, are stored in a [Vector3] data structure not because the rotation is a vector, but only because [Vector3] exists as a convenient data-structure to store 3 floating-point numbers. Therefore, applying affine operations on the rotation "vector" is not meaningful. </member> - <member name="rotation_degrees" type="Vector3" setter="set_rotation_degrees" getter="get_rotation_degrees" default="Vector3( 0, 0, 0 )"> + <member name="rotation_degrees" type="Vector3" setter="set_rotation_degrees" getter="get_rotation_degrees" default="Vector3(0, 0, 0)"> Rotation part of the local transformation in degrees, specified in terms of YXZ-Euler angles in the format (X angle, Y angle, Z angle). </member> - <member name="scale" type="Vector3" setter="set_scale" getter="get_scale" default="Vector3( 1, 1, 1 )"> + <member name="scale" type="Vector3" setter="set_scale" getter="get_scale" default="Vector3(1, 1, 1)"> Scale part of the local transformation. </member> <member name="top_level" type="bool" setter="set_as_top_level" getter="is_set_as_top_level" default="false"> If [code]true[/code], the node will not inherit its transformations from its parent. Node transformations are only in global space. </member> - <member name="transform" type="Transform3D" setter="set_transform" getter="get_transform" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )"> + <member name="transform" type="Transform3D" setter="set_transform" getter="get_transform" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)"> Local space [Transform3D] of this node, with respect to the parent node. </member> <member name="visibility_parent" type="NodePath" setter="set_visibility_parent" getter="get_visibility_parent" default="NodePath("")"> diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index bfcd5b1beb..a9396306f4 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -94,7 +94,7 @@ </argument> <argument index="1" name="arguments" type="PackedStringArray"> </argument> - <argument index="2" name="output" type="Array" default="[ ]"> + <argument index="2" name="output" type="Array" default="[]"> </argument> <argument index="3" name="read_stderr" type="bool" default="false"> </argument> @@ -136,6 +136,14 @@ Returns the keycode of the given string (e.g. "Escape"). </description> </method> + <method name="get_cache_dir" qualifiers="const"> + <return type="String"> + </return> + <description> + Returns the [i]global[/i] cache data directory according to the operating system's standards. On desktop platforms, this path can be overridden by setting the [code]XDG_CACHE_HOME[/code] environment variable before starting the project. See [url=https://docs.godotengine.org/en/latest/tutorials/io/data_paths.html]File paths in Godot projects[/url] in the documentation for more information. See also [method get_config_dir] and [method get_data_dir]. + Not to be confused with [method get_user_data_dir], which returns the [i]project-specific[/i] user data path. + </description> + </method> <method name="get_cmdline_args"> <return type="PackedStringArray"> </return> @@ -167,6 +175,14 @@ [/codeblocks] </description> </method> + <method name="get_config_dir" qualifiers="const"> + <return type="String"> + </return> + <description> + Returns the [i]global[/i] user configuration directory according to the operating system's standards. On desktop platforms, this path can be overridden by setting the [code]XDG_CONFIG_HOME[/code] environment variable before starting the project. See [url=https://docs.godotengine.org/en/latest/tutorials/io/data_paths.html]File paths in Godot projects[/url] in the documentation for more information. See also [method get_cache_dir] and [method get_data_dir]. + Not to be confused with [method get_user_data_dir], which returns the [i]project-specific[/i] user data path. + </description> + </method> <method name="get_connected_midi_inputs"> <return type="PackedStringArray"> </return> @@ -176,6 +192,14 @@ [b]Note:[/b] This method is implemented on Linux, macOS and Windows. </description> </method> + <method name="get_data_dir" qualifiers="const"> + <return type="String"> + </return> + <description> + Returns the [i]global[/i] user data directory according to the operating system's standards. On desktop platforms, this path can be overridden by setting the [code]XDG_DATA_HOME[/code] environment variable before starting the project. See [url=https://docs.godotengine.org/en/latest/tutorials/io/data_paths.html]File paths in Godot projects[/url] in the documentation for more information. See also [method get_cache_dir] and [method get_config_dir]. + Not to be confused with [method get_user_data_dir], which returns the [i]project-specific[/i] user data path. + </description> + </method> <method name="get_environment" qualifiers="const"> <return type="String"> </return> @@ -310,6 +334,7 @@ On macOS, this is [code]~/Library/Application Support/Godot/app_userdata/[project_name][/code], or [code]~/Library/Application Support/[custom_name][/code] if [code]use_custom_user_dir[/code] is set. On Windows, this is [code]%APPDATA%\Godot\app_userdata\[project_name][/code], or [code]%APPDATA%\[custom_name][/code] if [code]use_custom_user_dir[/code] is set. [code]%APPDATA%[/code] expands to [code]%USERPROFILE%\AppData\Roaming[/code]. If the project name is empty, [code]user://[/code] falls back to [code]res://[/code]. + Not to be confused with [method get_data_dir], which returns the [i]global[/i] (non-project-specific) user data directory. </description> </method> <method name="has_environment" qualifiers="const"> diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml index f5dcd6bcdc..cdf76a3a59 100644 --- a/doc/classes/Object.xml +++ b/doc/classes/Object.xml @@ -92,7 +92,7 @@ </return> <argument index="0" name="signal" type="String"> </argument> - <argument index="1" name="arguments" type="Array" default="[ ]"> + <argument index="1" name="arguments" type="Array" default="[]"> </argument> <description> Adds a user-defined [code]signal[/code]. Arguments are optional, but can be added as an [Array] of dictionaries, each containing [code]name: String[/code] and [code]type: int[/code] (see [enum Variant.Type]) entries. @@ -173,7 +173,7 @@ </argument> <argument index="1" name="callable" type="Callable"> </argument> - <argument index="2" name="binds" type="Array" default="[ ]"> + <argument index="2" name="binds" type="Array" default="[]"> </argument> <argument index="3" name="flags" type="int" default="0"> </argument> diff --git a/doc/classes/Occluder3D.xml b/doc/classes/Occluder3D.xml index fc676c2b49..501c4a3ccf 100644 --- a/doc/classes/Occluder3D.xml +++ b/doc/classes/Occluder3D.xml @@ -9,9 +9,9 @@ <methods> </methods> <members> - <member name="indices" type="PackedInt32Array" setter="set_indices" getter="get_indices" default="PackedInt32Array( )"> + <member name="indices" type="PackedInt32Array" setter="set_indices" getter="get_indices" default="PackedInt32Array()"> </member> - <member name="vertices" type="PackedVector3Array" setter="set_vertices" getter="get_vertices" default="PackedVector3Array( )"> + <member name="vertices" type="PackedVector3Array" setter="set_vertices" getter="get_vertices" default="PackedVector3Array()"> </member> </members> <constants> diff --git a/doc/classes/OccluderPolygon2D.xml b/doc/classes/OccluderPolygon2D.xml index 8a59ef5cb4..28d3ed433a 100644 --- a/doc/classes/OccluderPolygon2D.xml +++ b/doc/classes/OccluderPolygon2D.xml @@ -17,7 +17,7 @@ <member name="cull_mode" type="int" setter="set_cull_mode" getter="get_cull_mode" enum="OccluderPolygon2D.CullMode" default="0"> The culling mode to use. </member> - <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array( )"> + <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array()"> A [Vector2] array with the index for polygon's vertices positions. [b]Note:[/b] The returned value is a copy of the underlying array, rather than a reference. </member> diff --git a/doc/classes/OptionButton.xml b/doc/classes/OptionButton.xml index 52da08c02f..4c03c59f8b 100644 --- a/doc/classes/OptionButton.xml +++ b/doc/classes/OptionButton.xml @@ -250,19 +250,19 @@ <theme_item name="font" type="Font"> [Font] of the [OptionButton]'s text. </theme_item> - <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )"> + <theme_item name="font_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> Default text [Color] of the [OptionButton]. </theme_item> - <theme_item name="font_disabled_color" type="Color" default="Color( 0.9, 0.9, 0.9, 0.2 )"> + <theme_item name="font_disabled_color" type="Color" default="Color(0.9, 0.9, 0.9, 0.2)"> Text [Color] used when the [OptionButton] is disabled. </theme_item> - <theme_item name="font_hover_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )"> + <theme_item name="font_hover_color" type="Color" default="Color(0.94, 0.94, 0.94, 1)"> Text [Color] used when the [OptionButton] is being hovered. </theme_item> - <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)"> The tint of text outline of the [OptionButton]. </theme_item> - <theme_item name="font_pressed_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_pressed_color" type="Color" default="Color(1, 1, 1, 1)"> Text [Color] used when the [OptionButton] is being pressed. </theme_item> <theme_item name="font_size" type="int"> diff --git a/doc/classes/PackedDataContainer.xml b/doc/classes/PackedDataContainer.xml index 296f9d3373..f72db514f0 100644 --- a/doc/classes/PackedDataContainer.xml +++ b/doc/classes/PackedDataContainer.xml @@ -23,7 +23,7 @@ </method> </methods> <members> - <member name="__data__" type="PackedByteArray" setter="_set_data" getter="_get_data" default="PackedByteArray( )"> + <member name="__data__" type="PackedByteArray" setter="_set_data" getter="_get_data" default="PackedByteArray()"> </member> </members> <constants> diff --git a/doc/classes/PackedScene.xml b/doc/classes/PackedScene.xml index 1d9be7f165..5887238a32 100644 --- a/doc/classes/PackedScene.xml +++ b/doc/classes/PackedScene.xml @@ -110,7 +110,7 @@ </method> </methods> <members> - <member name="_bundled" type="Dictionary" setter="_set_bundled_scene" getter="_get_bundled_scene" default="{"conn_count": 0,"conns": PackedInt32Array( ),"editable_instances": [ ],"names": PackedStringArray( ),"node_count": 0,"node_paths": [ ],"nodes": PackedInt32Array( ),"variants": [ ],"version": 2}"> + <member name="_bundled" type="Dictionary" setter="_set_bundled_scene" getter="_get_bundled_scene" default="{"conn_count": 0,"conns": PackedInt32Array(),"editable_instances": [],"names": PackedStringArray(),"node_count": 0,"node_paths": [],"nodes": PackedInt32Array(),"variants": [],"version": 2}"> A dictionary representation of the scene contents. Available keys include "rnames" and "variants" for resources, "node_count", "nodes", "node_paths" for nodes, "editable_instances" for base scene children overrides, "conn_count" and "conns" for signal connections, and "version" for the format style of the PackedScene. </member> diff --git a/doc/classes/ParallaxBackground.xml b/doc/classes/ParallaxBackground.xml index 3b730fc4d4..b8097343f4 100644 --- a/doc/classes/ParallaxBackground.xml +++ b/doc/classes/ParallaxBackground.xml @@ -12,22 +12,22 @@ </methods> <members> <member name="layer" type="int" setter="set_layer" getter="get_layer" override="true" default="-100" /> - <member name="scroll_base_offset" type="Vector2" setter="set_scroll_base_offset" getter="get_scroll_base_offset" default="Vector2( 0, 0 )"> + <member name="scroll_base_offset" type="Vector2" setter="set_scroll_base_offset" getter="get_scroll_base_offset" default="Vector2(0, 0)"> The base position offset for all [ParallaxLayer] children. </member> - <member name="scroll_base_scale" type="Vector2" setter="set_scroll_base_scale" getter="get_scroll_base_scale" default="Vector2( 1, 1 )"> + <member name="scroll_base_scale" type="Vector2" setter="set_scroll_base_scale" getter="get_scroll_base_scale" default="Vector2(1, 1)"> The base motion scale for all [ParallaxLayer] children. </member> <member name="scroll_ignore_camera_zoom" type="bool" setter="set_ignore_camera_zoom" getter="is_ignore_camera_zoom" default="false"> If [code]true[/code], elements in [ParallaxLayer] child aren't affected by the zoom level of the camera. </member> - <member name="scroll_limit_begin" type="Vector2" setter="set_limit_begin" getter="get_limit_begin" default="Vector2( 0, 0 )"> + <member name="scroll_limit_begin" type="Vector2" setter="set_limit_begin" getter="get_limit_begin" default="Vector2(0, 0)"> Top-left limits for scrolling to begin. If the camera is outside of this limit, the background will stop scrolling. Must be lower than [member scroll_limit_end] to work. </member> - <member name="scroll_limit_end" type="Vector2" setter="set_limit_end" getter="get_limit_end" default="Vector2( 0, 0 )"> + <member name="scroll_limit_end" type="Vector2" setter="set_limit_end" getter="get_limit_end" default="Vector2(0, 0)"> Bottom-right limits for scrolling to end. If the camera is outside of this limit, the background will stop scrolling. Must be higher than [member scroll_limit_begin] to work. </member> - <member name="scroll_offset" type="Vector2" setter="set_scroll_offset" getter="get_scroll_offset" default="Vector2( 0, 0 )"> + <member name="scroll_offset" type="Vector2" setter="set_scroll_offset" getter="get_scroll_offset" default="Vector2(0, 0)"> The ParallaxBackground's scroll value. Calculated automatically when using a [Camera2D], but can be used to manually manage scrolling when no camera is present. </member> </members> diff --git a/doc/classes/ParallaxLayer.xml b/doc/classes/ParallaxLayer.xml index 7210bee11c..6b1e013851 100644 --- a/doc/classes/ParallaxLayer.xml +++ b/doc/classes/ParallaxLayer.xml @@ -13,13 +13,13 @@ <methods> </methods> <members> - <member name="motion_mirroring" type="Vector2" setter="set_mirroring" getter="get_mirroring" default="Vector2( 0, 0 )"> + <member name="motion_mirroring" type="Vector2" setter="set_mirroring" getter="get_mirroring" default="Vector2(0, 0)"> The ParallaxLayer's [Texture2D] mirroring. Useful for creating an infinite scrolling background. If an axis is set to [code]0[/code], the [Texture2D] will not be mirrored. </member> - <member name="motion_offset" type="Vector2" setter="set_motion_offset" getter="get_motion_offset" default="Vector2( 0, 0 )"> + <member name="motion_offset" type="Vector2" setter="set_motion_offset" getter="get_motion_offset" default="Vector2(0, 0)"> The ParallaxLayer's offset relative to the parent ParallaxBackground's [member ParallaxBackground.scroll_offset]. </member> - <member name="motion_scale" type="Vector2" setter="set_motion_scale" getter="get_motion_scale" default="Vector2( 1, 1 )"> + <member name="motion_scale" type="Vector2" setter="set_motion_scale" getter="get_motion_scale" default="Vector2(1, 1)"> Multiplies the ParallaxLayer's motion. If an axis is set to [code]0[/code], it will not scroll. </member> </members> diff --git a/doc/classes/ParticlesMaterial.xml b/doc/classes/ParticlesMaterial.xml index 3c364b621a..e8fde21032 100644 --- a/doc/classes/ParticlesMaterial.xml +++ b/doc/classes/ParticlesMaterial.xml @@ -141,7 +141,7 @@ </member> <member name="collision_use_scale" type="bool" setter="set_collision_use_scale" getter="is_collision_using_scale" default="false"> </member> - <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 1, 1, 1, 1 )"> + <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)"> Each particle's initial color. If the [GPUParticles2D]'s [code]texture[/code] is defined, it will be multiplied by this color. To have particle display color in a [BaseMaterial3D] make sure to set [member BaseMaterial3D.vertex_color_use_as_albedo] to [code]true[/code]. </member> <member name="color_ramp" type="Texture2D" setter="set_color_ramp" getter="get_color_ramp"> @@ -156,7 +156,7 @@ <member name="damping_random" type="float" setter="set_param_randomness" getter="get_param_randomness" default="0.0"> Damping randomness ratio. </member> - <member name="direction" type="Vector3" setter="set_direction" getter="get_direction" default="Vector3( 1, 0, 0 )"> + <member name="direction" type="Vector3" setter="set_direction" getter="get_direction" default="Vector3(1, 0, 0)"> Unit vector specifying the particles' emission direction. </member> <member name="emission_box_extents" type="Vector3" setter="set_emission_box_extents" getter="get_emission_box_extents"> @@ -183,7 +183,7 @@ <member name="flatness" type="float" setter="set_flatness" getter="get_flatness" default="0.0"> Amount of [member spread] along the Y axis. </member> - <member name="gravity" type="Vector3" setter="set_gravity" getter="get_gravity" default="Vector3( 0, -9.8, 0 )"> + <member name="gravity" type="Vector3" setter="set_gravity" getter="get_gravity" default="Vector3(0, -9.8, 0)"> Gravity applied to every particle. </member> <member name="hue_variation" type="float" setter="set_param" getter="get_param" default="0.0"> diff --git a/doc/classes/Performance.xml b/doc/classes/Performance.xml index 9e9c5063ae..ff73844803 100644 --- a/doc/classes/Performance.xml +++ b/doc/classes/Performance.xml @@ -20,7 +20,7 @@ </argument> <argument index="1" name="callable" type="Callable"> </argument> - <argument index="2" name="arguments" type="Array" default="[ ]"> + <argument index="2" name="arguments" type="Array" default="[]"> </argument> <description> Adds a custom monitor with name same as id. You can specify the category of monitor using '/' in id. If there are more than one '/' then default category is used. Default category is "Custom". diff --git a/doc/classes/PhysicalBone3D.xml b/doc/classes/PhysicalBone3D.xml index 5d15590a3f..736b44ee1c 100644 --- a/doc/classes/PhysicalBone3D.xml +++ b/doc/classes/PhysicalBone3D.xml @@ -20,7 +20,7 @@ </return> <argument index="0" name="impulse" type="Vector3"> </argument> - <argument index="1" name="position" type="Vector3" default="Vector3( 0, 0, 0 )"> + <argument index="1" name="position" type="Vector3" default="Vector3(0, 0, 0)"> </argument> <description> </description> @@ -48,7 +48,7 @@ <member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp" default="-1.0"> Damps the body's rotation if greater than [code]0[/code]. </member> - <member name="body_offset" type="Transform3D" setter="set_body_offset" getter="get_body_offset" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )"> + <member name="body_offset" type="Transform3D" setter="set_body_offset" getter="get_body_offset" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)"> Sets the body's transform. </member> <member name="bounce" type="float" setter="set_bounce" getter="get_bounce" default="0.0"> @@ -63,13 +63,13 @@ <member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale" default="1.0"> This is multiplied by the global 3D gravity setting found in [b]Project > Project Settings > Physics > 3d[/b] to produce the body's gravity. For example, a value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object. </member> - <member name="joint_offset" type="Transform3D" setter="set_joint_offset" getter="get_joint_offset" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )"> + <member name="joint_offset" type="Transform3D" setter="set_joint_offset" getter="get_joint_offset" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)"> Sets the joint's transform. </member> <member name="joint_rotation" type="Vector3" setter="set_joint_rotation" getter="get_joint_rotation"> Sets the joint's rotation in radians. </member> - <member name="joint_rotation_degrees" type="Vector3" setter="set_joint_rotation_degrees" getter="get_joint_rotation_degrees" default="Vector3( 0, 0, 0 )"> + <member name="joint_rotation_degrees" type="Vector3" setter="set_joint_rotation_degrees" getter="get_joint_rotation_degrees" default="Vector3(0, 0, 0)"> Sets the joint's rotation in degrees. </member> <member name="joint_type" type="int" setter="set_joint_type" getter="get_joint_type" enum="PhysicalBone3D.JointType" default="0"> diff --git a/doc/classes/PhysicalSkyMaterial.xml b/doc/classes/PhysicalSkyMaterial.xml index 381371b973..20ab998d35 100644 --- a/doc/classes/PhysicalSkyMaterial.xml +++ b/doc/classes/PhysicalSkyMaterial.xml @@ -19,13 +19,13 @@ <member name="exposure" type="float" setter="set_exposure" getter="get_exposure" default="0.1"> Sets the exposure of the sky. Higher exposure values make the entire sky brighter. </member> - <member name="ground_color" type="Color" setter="set_ground_color" getter="get_ground_color" default="Color( 1, 1, 1, 1 )"> + <member name="ground_color" type="Color" setter="set_ground_color" getter="get_ground_color" default="Color(1, 1, 1, 1)"> Modulates the [Color] on the bottom half of the sky to represent the ground. </member> <member name="mie_coefficient" type="float" setter="set_mie_coefficient" getter="get_mie_coefficient" default="0.005"> Controls the strength of mie scattering for the sky. Mie scattering results from light colliding with larger particles (like water). On earth, mie scattering results in a whitish color around the sun and horizon. </member> - <member name="mie_color" type="Color" setter="set_mie_color" getter="get_mie_color" default="Color( 0.36, 0.56, 0.82, 1 )"> + <member name="mie_color" type="Color" setter="set_mie_color" getter="get_mie_color" default="Color(0.36, 0.56, 0.82, 1)"> Controls the [Color] of the mie scattering effect. While not physically accurate, this allows for the creation of alien looking planets. </member> <member name="mie_eccentricity" type="float" setter="set_mie_eccentricity" getter="get_mie_eccentricity" default="0.8"> @@ -37,7 +37,7 @@ <member name="rayleigh_coefficient" type="float" setter="set_rayleigh_coefficient" getter="get_rayleigh_coefficient" default="2.0"> Controls the strength of the Rayleigh scattering. Rayleigh scattering results from light colliding with small particles. It is responsible for the blue color of the sky. </member> - <member name="rayleigh_color" type="Color" setter="set_rayleigh_color" getter="get_rayleigh_color" default="Color( 0.056, 0.14, 0.3, 1 )"> + <member name="rayleigh_color" type="Color" setter="set_rayleigh_color" getter="get_rayleigh_color" default="Color(0.056, 0.14, 0.3, 1)"> Controls the [Color] of the Rayleigh scattering. While not physically accurate, this allows for the creation of alien looking planets. For example, setting this to a red [Color] results in a Mars looking atmosphere with a corresponding blue sunset. </member> <member name="sun_disk_scale" type="float" setter="set_sun_disk_scale" getter="get_sun_disk_scale" default="1.0"> diff --git a/doc/classes/PhysicsDirectBodyState2D.xml b/doc/classes/PhysicsDirectBodyState2D.xml index 66ff16a3ce..65cb3e7f38 100644 --- a/doc/classes/PhysicsDirectBodyState2D.xml +++ b/doc/classes/PhysicsDirectBodyState2D.xml @@ -24,7 +24,7 @@ </return> <argument index="0" name="force" type="Vector2"> </argument> - <argument index="1" name="position" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="1" name="position" type="Vector2" default="Vector2(0, 0)"> </argument> <description> Adds a positioned force to the body. Both the force and the offset from the body origin are in global coordinates. @@ -53,7 +53,7 @@ </return> <argument index="0" name="impulse" type="Vector2"> </argument> - <argument index="1" name="position" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="1" name="position" type="Vector2" default="Vector2(0, 0)"> </argument> <description> Applies a positioned impulse to the body. An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_force" functions otherwise). The offset uses the rotation of the global coordinate system, but is centered at the object's origin. diff --git a/doc/classes/PhysicsDirectBodyState3D.xml b/doc/classes/PhysicsDirectBodyState3D.xml index 7cb3a56338..85feeef86e 100644 --- a/doc/classes/PhysicsDirectBodyState3D.xml +++ b/doc/classes/PhysicsDirectBodyState3D.xml @@ -12,7 +12,7 @@ <method name="add_central_force"> <return type="void"> </return> - <argument index="0" name="force" type="Vector3" default="Vector3( 0, 0, 0 )"> + <argument index="0" name="force" type="Vector3" default="Vector3(0, 0, 0)"> </argument> <description> Adds a constant directional force without affecting rotation. @@ -24,7 +24,7 @@ </return> <argument index="0" name="force" type="Vector3"> </argument> - <argument index="1" name="position" type="Vector3" default="Vector3( 0, 0, 0 )"> + <argument index="1" name="position" type="Vector3" default="Vector3(0, 0, 0)"> </argument> <description> Adds a positioned force to the body. Both the force and the offset from the body origin are in global coordinates. @@ -42,7 +42,7 @@ <method name="apply_central_impulse"> <return type="void"> </return> - <argument index="0" name="impulse" type="Vector3" default="Vector3( 0, 0, 0 )"> + <argument index="0" name="impulse" type="Vector3" default="Vector3(0, 0, 0)"> </argument> <description> Applies a single directional impulse without affecting rotation. @@ -54,7 +54,7 @@ </return> <argument index="0" name="impulse" type="Vector3"> </argument> - <argument index="1" name="position" type="Vector3" default="Vector3( 0, 0, 0 )"> + <argument index="1" name="position" type="Vector3" default="Vector3(0, 0, 0)"> </argument> <description> Applies a positioned impulse to the body. An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason it should only be used when simulating one-time impacts. The position uses the rotation of the global coordinate system, but is centered at the object's origin. diff --git a/doc/classes/PhysicsDirectSpaceState2D.xml b/doc/classes/PhysicsDirectSpaceState2D.xml index b6f95305ed..6c8c957e5d 100644 --- a/doc/classes/PhysicsDirectSpaceState2D.xml +++ b/doc/classes/PhysicsDirectSpaceState2D.xml @@ -56,7 +56,7 @@ </argument> <argument index="1" name="max_results" type="int" default="32"> </argument> - <argument index="2" name="exclude" type="Array" default="[ ]"> + <argument index="2" name="exclude" type="Array" default="[]"> </argument> <argument index="3" name="collision_layer" type="int" default="2147483647"> </argument> @@ -84,7 +84,7 @@ </argument> <argument index="2" name="max_results" type="int" default="32"> </argument> - <argument index="3" name="exclude" type="Array" default="[ ]"> + <argument index="3" name="exclude" type="Array" default="[]"> </argument> <argument index="4" name="collision_layer" type="int" default="2147483647"> </argument> @@ -102,7 +102,7 @@ </argument> <argument index="1" name="to" type="Vector2"> </argument> - <argument index="2" name="exclude" type="Array" default="[ ]"> + <argument index="2" name="exclude" type="Array" default="[]"> </argument> <argument index="3" name="collision_layer" type="int" default="2147483647"> </argument> diff --git a/doc/classes/PhysicsDirectSpaceState3D.xml b/doc/classes/PhysicsDirectSpaceState3D.xml index 243d071c56..a69b6f07fd 100644 --- a/doc/classes/PhysicsDirectSpaceState3D.xml +++ b/doc/classes/PhysicsDirectSpaceState3D.xml @@ -57,7 +57,7 @@ </argument> <argument index="1" name="to" type="Vector3"> </argument> - <argument index="2" name="exclude" type="Array" default="[ ]"> + <argument index="2" name="exclude" type="Array" default="[]"> </argument> <argument index="3" name="collision_mask" type="int" default="2147483647"> </argument> diff --git a/doc/classes/PhysicsServer2D.xml b/doc/classes/PhysicsServer2D.xml index 4c2abcb087..33cd61eb9c 100644 --- a/doc/classes/PhysicsServer2D.xml +++ b/doc/classes/PhysicsServer2D.xml @@ -16,7 +16,7 @@ </argument> <argument index="1" name="shape" type="RID"> </argument> - <argument index="2" name="transform" type="Transform2D" default="Transform2D( 1, 0, 0, 1, 0, 0 )"> + <argument index="2" name="transform" type="Transform2D" default="Transform2D(1, 0, 0, 1, 0, 0)"> </argument> <argument index="3" name="disabled" type="bool" default="false"> </argument> @@ -333,7 +333,7 @@ </argument> <argument index="1" name="force" type="Vector2"> </argument> - <argument index="2" name="position" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)"> </argument> <description> Adds a positioned force to the applied force and torque. As with [method body_apply_impulse], both the force and the offset from the body origin are in global coordinates. A force differs from an impulse in that, while the two are forces, the impulse clears itself after being applied. @@ -346,7 +346,7 @@ </argument> <argument index="1" name="shape" type="RID"> </argument> - <argument index="2" name="transform" type="Transform2D" default="Transform2D( 1, 0, 0, 1, 0, 0 )"> + <argument index="2" name="transform" type="Transform2D" default="Transform2D(1, 0, 0, 1, 0, 0)"> </argument> <argument index="3" name="disabled" type="bool" default="false"> </argument> @@ -381,7 +381,7 @@ </argument> <argument index="1" name="impulse" type="Vector2"> </argument> - <argument index="2" name="position" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)"> </argument> <description> Adds a positioned impulse to the applied force and torque. Both the force and the offset from the body origin are in global coordinates. diff --git a/doc/classes/PhysicsServer3D.xml b/doc/classes/PhysicsServer3D.xml index 2972d5155c..aa1f7597ea 100644 --- a/doc/classes/PhysicsServer3D.xml +++ b/doc/classes/PhysicsServer3D.xml @@ -16,7 +16,7 @@ </argument> <argument index="1" name="shape" type="RID"> </argument> - <argument index="2" name="transform" type="Transform3D" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )"> + <argument index="2" name="transform" type="Transform3D" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)"> </argument> <argument index="3" name="disabled" type="bool" default="false"> </argument> @@ -325,7 +325,7 @@ </argument> <argument index="1" name="force" type="Vector3"> </argument> - <argument index="2" name="position" type="Vector3" default="Vector3( 0, 0, 0 )"> + <argument index="2" name="position" type="Vector3" default="Vector3(0, 0, 0)"> </argument> <description> </description> @@ -337,7 +337,7 @@ </argument> <argument index="1" name="shape" type="RID"> </argument> - <argument index="2" name="transform" type="Transform3D" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )"> + <argument index="2" name="transform" type="Transform3D" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)"> </argument> <argument index="3" name="disabled" type="bool" default="false"> </argument> @@ -372,7 +372,7 @@ </argument> <argument index="1" name="impulse" type="Vector3"> </argument> - <argument index="2" name="position" type="Vector3" default="Vector3( 0, 0, 0 )"> + <argument index="2" name="position" type="Vector3" default="Vector3(0, 0, 0)"> </argument> <description> Gives the body a push at a [code]position[/code] in the direction of the [code]impulse[/code]. diff --git a/doc/classes/PhysicsShapeQueryParameters2D.xml b/doc/classes/PhysicsShapeQueryParameters2D.xml index 92bd9b136a..321a713e26 100644 --- a/doc/classes/PhysicsShapeQueryParameters2D.xml +++ b/doc/classes/PhysicsShapeQueryParameters2D.xml @@ -20,13 +20,13 @@ <member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="2147483647"> The physics layer(s) the query will take into account (as a bitmask). See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. </member> - <member name="exclude" type="Array" setter="set_exclude" getter="get_exclude" default="[ ]"> + <member name="exclude" type="Array" setter="set_exclude" getter="get_exclude" default="[]"> The list of objects or object [RID]s that will be excluded from collisions. </member> <member name="margin" type="float" setter="set_margin" getter="get_margin" default="0.0"> The collision margin for the shape. </member> - <member name="motion" type="Vector2" setter="set_motion" getter="get_motion" default="Vector2( 0, 0 )"> + <member name="motion" type="Vector2" setter="set_motion" getter="get_motion" default="Vector2(0, 0)"> The motion of the shape being queried for. </member> <member name="shape" type="Resource" setter="set_shape" getter="get_shape"> @@ -63,7 +63,7 @@ [/csharp] [/codeblocks] </member> - <member name="transform" type="Transform2D" setter="set_transform" getter="get_transform" default="Transform2D( 1, 0, 0, 1, 0, 0 )"> + <member name="transform" type="Transform2D" setter="set_transform" getter="get_transform" default="Transform2D(1, 0, 0, 1, 0, 0)"> The queried shape's transform matrix. </member> </members> diff --git a/doc/classes/PhysicsShapeQueryParameters3D.xml b/doc/classes/PhysicsShapeQueryParameters3D.xml index 087c52a650..52916a8418 100644 --- a/doc/classes/PhysicsShapeQueryParameters3D.xml +++ b/doc/classes/PhysicsShapeQueryParameters3D.xml @@ -20,7 +20,7 @@ <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="2147483647"> The physics layer(s) the query will take into account (as a bitmask). See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. </member> - <member name="exclude" type="Array" setter="set_exclude" getter="get_exclude" default="[ ]"> + <member name="exclude" type="Array" setter="set_exclude" getter="get_exclude" default="[]"> The list of objects or object [RID]s that will be excluded from collisions. </member> <member name="margin" type="float" setter="set_margin" getter="get_margin" default="0.0"> @@ -60,7 +60,7 @@ [/csharp] [/codeblocks] </member> - <member name="transform" type="Transform3D" setter="set_transform" getter="get_transform" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )"> + <member name="transform" type="Transform3D" setter="set_transform" getter="get_transform" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)"> The queried shape's transform matrix. </member> </members> diff --git a/doc/classes/PhysicsTestMotionResult2D.xml b/doc/classes/PhysicsTestMotionResult2D.xml index 2744aa17a1..da04ffa86a 100644 --- a/doc/classes/PhysicsTestMotionResult2D.xml +++ b/doc/classes/PhysicsTestMotionResult2D.xml @@ -17,15 +17,15 @@ </member> <member name="collider_shape" type="int" setter="" getter="get_collider_shape" default="0"> </member> - <member name="collider_velocity" type="Vector2" setter="" getter="get_collider_velocity" default="Vector2( 0, 0 )"> + <member name="collider_velocity" type="Vector2" setter="" getter="get_collider_velocity" default="Vector2(0, 0)"> </member> - <member name="collision_normal" type="Vector2" setter="" getter="get_collision_normal" default="Vector2( 0, 0 )"> + <member name="collision_normal" type="Vector2" setter="" getter="get_collision_normal" default="Vector2(0, 0)"> </member> - <member name="collision_point" type="Vector2" setter="" getter="get_collision_point" default="Vector2( 0, 0 )"> + <member name="collision_point" type="Vector2" setter="" getter="get_collision_point" default="Vector2(0, 0)"> </member> - <member name="motion" type="Vector2" setter="" getter="get_motion" default="Vector2( 0, 0 )"> + <member name="motion" type="Vector2" setter="" getter="get_motion" default="Vector2(0, 0)"> </member> - <member name="motion_remainder" type="Vector2" setter="" getter="get_motion_remainder" default="Vector2( 0, 0 )"> + <member name="motion_remainder" type="Vector2" setter="" getter="get_motion_remainder" default="Vector2(0, 0)"> </member> </members> <constants> diff --git a/doc/classes/Plane.xml b/doc/classes/Plane.xml index 2342f00631..cca5793fc7 100644 --- a/doc/classes/Plane.xml +++ b/doc/classes/Plane.xml @@ -204,7 +204,7 @@ The distance from the origin to the plane, in the direction of [member normal]. This value is typically non-negative. In the scalar equation of the plane [code]ax + by + cz = d[/code], this is [code]d[/code], while the [code](a, b, c)[/code] coordinates are represented by the [member normal] property. </member> - <member name="normal" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )"> + <member name="normal" type="Vector3" setter="" getter="" default="Vector3(0, 0, 0)"> The normal of the plane, which must be normalized. In the scalar equation of the plane [code]ax + by + cz = d[/code], this is the vector [code](a, b, c)[/code], where [code]d[/code] is the [member d] property. </member> @@ -219,13 +219,13 @@ </member> </members> <constants> - <constant name="PLANE_YZ" value="Plane( 1, 0, 0, 0 )"> + <constant name="PLANE_YZ" value="Plane(1, 0, 0, 0)"> A plane that extends in the Y and Z axes (normal vector points +X). </constant> - <constant name="PLANE_XZ" value="Plane( 0, 1, 0, 0 )"> + <constant name="PLANE_XZ" value="Plane(0, 1, 0, 0)"> A plane that extends in the X and Z axes (normal vector points +Y). </constant> - <constant name="PLANE_XY" value="Plane( 0, 0, 1, 0 )"> + <constant name="PLANE_XY" value="Plane(0, 0, 1, 0)"> A plane that extends in the X and Y axes (normal vector points +Z). </constant> </constants> diff --git a/doc/classes/PlaneMesh.xml b/doc/classes/PlaneMesh.xml index 333d687e91..c95ba29ea2 100644 --- a/doc/classes/PlaneMesh.xml +++ b/doc/classes/PlaneMesh.xml @@ -12,7 +12,7 @@ <methods> </methods> <members> - <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2( 2, 2 )"> + <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2(2, 2)"> Size of the generated plane. </member> <member name="subdivide_depth" type="int" setter="set_subdivide_depth" getter="get_subdivide_depth" default="0"> diff --git a/doc/classes/PointLight2D.xml b/doc/classes/PointLight2D.xml index 9337bc8351..a7207a3c80 100644 --- a/doc/classes/PointLight2D.xml +++ b/doc/classes/PointLight2D.xml @@ -12,7 +12,7 @@ <member name="height" type="float" setter="set_height" getter="get_height" default="0.0"> The height of the light. Used with 2D normal mapping. </member> - <member name="offset" type="Vector2" setter="set_texture_offset" getter="get_texture_offset" default="Vector2( 0, 0 )"> + <member name="offset" type="Vector2" setter="set_texture_offset" getter="get_texture_offset" default="Vector2(0, 0)"> The offset of the light's [member texture]. </member> <member name="texture" type="Texture2D" setter="set_texture" getter="get_texture"> diff --git a/doc/classes/Polygon2D.xml b/doc/classes/Polygon2D.xml index 3aca83658d..c33a1424a7 100644 --- a/doc/classes/Polygon2D.xml +++ b/doc/classes/Polygon2D.xml @@ -88,9 +88,9 @@ <member name="antialiased" type="bool" setter="set_antialiased" getter="get_antialiased" default="false"> If [code]true[/code], polygon edges will be anti-aliased. </member> - <member name="bones" type="Array" setter="_set_bones" getter="_get_bones" default="[ ]"> + <member name="bones" type="Array" setter="_set_bones" getter="_get_bones" default="[]"> </member> - <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 1, 1, 1, 1 )"> + <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)"> The polygon's fill color. If [code]texture[/code] is defined, it will be multiplied by this color. It will also be the default color for vertices not set in [code]vertex_colors[/code]. </member> <member name="internal_vertex_count" type="int" setter="set_internal_vertex_count" getter="get_internal_vertex_count" default="0"> @@ -101,21 +101,21 @@ <member name="invert_enable" type="bool" setter="set_invert" getter="get_invert" default="false"> If [code]true[/code], polygon will be inverted, containing the area outside the defined points and extending to the [code]invert_border[/code]. </member> - <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2( 0, 0 )"> + <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2(0, 0)"> The offset applied to each vertex. </member> - <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array( )"> + <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array()"> The polygon's list of vertices. The final point will be connected to the first. [b]Note:[/b] This returns a copy of the [PackedVector2Array] rather than a reference. </member> - <member name="polygons" type="Array" setter="set_polygons" getter="get_polygons" default="[ ]"> + <member name="polygons" type="Array" setter="set_polygons" getter="get_polygons" default="[]"> </member> <member name="skeleton" type="NodePath" setter="set_skeleton" getter="get_skeleton" default="NodePath("")"> </member> <member name="texture" type="Texture2D" setter="set_texture" getter="get_texture"> The polygon's fill texture. Use [code]uv[/code] to set texture coordinates. </member> - <member name="texture_offset" type="Vector2" setter="set_texture_offset" getter="get_texture_offset" default="Vector2( 0, 0 )"> + <member name="texture_offset" type="Vector2" setter="set_texture_offset" getter="get_texture_offset" default="Vector2(0, 0)"> Amount to offset the polygon's [code]texture[/code]. If [code](0, 0)[/code] the texture's origin (its top-left corner) will be placed at the polygon's [code]position[/code]. </member> <member name="texture_rotation" type="float" setter="set_texture_rotation" getter="get_texture_rotation"> @@ -124,13 +124,13 @@ <member name="texture_rotation_degrees" type="float" setter="set_texture_rotation_degrees" getter="get_texture_rotation_degrees" default="0.0"> The texture's rotation in degrees. </member> - <member name="texture_scale" type="Vector2" setter="set_texture_scale" getter="get_texture_scale" default="Vector2( 1, 1 )"> + <member name="texture_scale" type="Vector2" setter="set_texture_scale" getter="get_texture_scale" default="Vector2(1, 1)"> Amount to multiply the [code]uv[/code] coordinates when using a [code]texture[/code]. Larger values make the texture smaller, and vice versa. </member> - <member name="uv" type="PackedVector2Array" setter="set_uv" getter="get_uv" default="PackedVector2Array( )"> + <member name="uv" type="PackedVector2Array" setter="set_uv" getter="get_uv" default="PackedVector2Array()"> Texture coordinates for each vertex of the polygon. There should be one [code]uv[/code] per polygon vertex. If there are fewer, undefined vertices will use [code](0, 0)[/code]. </member> - <member name="vertex_colors" type="PackedColorArray" setter="set_vertex_colors" getter="get_vertex_colors" default="PackedColorArray( )"> + <member name="vertex_colors" type="PackedColorArray" setter="set_vertex_colors" getter="get_vertex_colors" default="PackedColorArray()"> Color for each vertex. Colors are interpolated between vertices, resulting in smooth gradients. There should be one per polygon vertex. If there are fewer, undefined vertices will use [code]color[/code]. </member> </members> diff --git a/doc/classes/PopupMenu.xml b/doc/classes/PopupMenu.xml index 418785222e..e448d18d73 100644 --- a/doc/classes/PopupMenu.xml +++ b/doc/classes/PopupMenu.xml @@ -717,22 +717,22 @@ <theme_item name="font" type="Font"> [Font] used for the menu items. </theme_item> - <theme_item name="font_accelerator_color" type="Color" default="Color( 0.7, 0.7, 0.7, 0.8 )"> + <theme_item name="font_accelerator_color" type="Color" default="Color(0.7, 0.7, 0.7, 0.8)"> The text [Color] used for shortcuts and accelerators that show next to the menu item name when defined. See [method get_item_accelerator] for more info on accelerators. </theme_item> - <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )"> + <theme_item name="font_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> The default text [Color] for menu items' names. </theme_item> - <theme_item name="font_disabled_color" type="Color" default="Color( 0.4, 0.4, 0.4, 0.8 )"> + <theme_item name="font_disabled_color" type="Color" default="Color(0.4, 0.4, 0.4, 0.8)"> [Color] used for disabled menu items' text. </theme_item> - <theme_item name="font_hover_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )"> + <theme_item name="font_hover_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> [Color] used for the hovered text. </theme_item> - <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)"> The tint of text outline of the menu item. </theme_item> - <theme_item name="font_separator_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )"> + <theme_item name="font_separator_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> [Color] used for labeled separators' text. See [method add_separator]. </theme_item> <theme_item name="font_size" type="int"> diff --git a/doc/classes/PrimitiveMesh.xml b/doc/classes/PrimitiveMesh.xml index 3892633654..ca41c367c8 100644 --- a/doc/classes/PrimitiveMesh.xml +++ b/doc/classes/PrimitiveMesh.xml @@ -30,7 +30,7 @@ </method> </methods> <members> - <member name="custom_aabb" type="AABB" setter="set_custom_aabb" getter="get_custom_aabb" default="AABB( 0, 0, 0, 0, 0, 0 )"> + <member name="custom_aabb" type="AABB" setter="set_custom_aabb" getter="get_custom_aabb" default="AABB(0, 0, 0, 0, 0, 0)"> Overrides the [AABB] with one defined by user for use with frustum culling. Especially useful to avoid unexpected culling when using a shader to offset vertices. </member> <member name="flip_faces" type="bool" setter="set_flip_faces" getter="get_flip_faces" default="false"> diff --git a/doc/classes/PrismMesh.xml b/doc/classes/PrismMesh.xml index b2e1fdd3f0..0e66281fd1 100644 --- a/doc/classes/PrismMesh.xml +++ b/doc/classes/PrismMesh.xml @@ -14,7 +14,7 @@ <member name="left_to_right" type="float" setter="set_left_to_right" getter="get_left_to_right" default="0.5"> Displacement of the upper edge along the X axis. 0.0 positions edge straight above the bottom-left edge. </member> - <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3( 2, 2, 2 )"> + <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(2, 2, 2)"> Size of the prism. </member> <member name="subdivide_depth" type="int" setter="set_subdivide_depth" getter="get_subdivide_depth" default="0"> diff --git a/doc/classes/ProceduralSkyMaterial.xml b/doc/classes/ProceduralSkyMaterial.xml index d3e1dbca27..c598a2c266 100644 --- a/doc/classes/ProceduralSkyMaterial.xml +++ b/doc/classes/ProceduralSkyMaterial.xml @@ -13,7 +13,7 @@ <methods> </methods> <members> - <member name="ground_bottom_color" type="Color" setter="set_ground_bottom_color" getter="get_ground_bottom_color" default="Color( 0.12, 0.12, 0.13, 1 )"> + <member name="ground_bottom_color" type="Color" setter="set_ground_bottom_color" getter="get_ground_bottom_color" default="Color(0.12, 0.12, 0.13, 1)"> Color of the ground at the bottom. Blends with [member ground_horizon_color]. </member> <member name="ground_curve" type="float" setter="set_ground_curve" getter="get_ground_curve" default="0.02"> @@ -22,7 +22,7 @@ <member name="ground_energy" type="float" setter="set_ground_energy" getter="get_ground_energy" default="1.0"> Amount of energy contribution from the ground. </member> - <member name="ground_horizon_color" type="Color" setter="set_ground_horizon_color" getter="get_ground_horizon_color" default="Color( 0.37, 0.33, 0.31, 1 )"> + <member name="ground_horizon_color" type="Color" setter="set_ground_horizon_color" getter="get_ground_horizon_color" default="Color(0.37, 0.33, 0.31, 1)"> Color of the ground at the horizon. Blends with [member ground_bottom_color]. </member> <member name="sky_curve" type="float" setter="set_sky_curve" getter="get_sky_curve" default="0.09"> @@ -31,10 +31,10 @@ <member name="sky_energy" type="float" setter="set_sky_energy" getter="get_sky_energy" default="1.0"> Amount of energy contribution from the sky. </member> - <member name="sky_horizon_color" type="Color" setter="set_sky_horizon_color" getter="get_sky_horizon_color" default="Color( 0.55, 0.69, 0.81, 1 )"> + <member name="sky_horizon_color" type="Color" setter="set_sky_horizon_color" getter="get_sky_horizon_color" default="Color(0.55, 0.69, 0.81, 1)"> Color of the sky at the horizon. Blends with [member sky_top_color]. </member> - <member name="sky_top_color" type="Color" setter="set_sky_top_color" getter="get_sky_top_color" default="Color( 0.35, 0.46, 0.71, 1 )"> + <member name="sky_top_color" type="Color" setter="set_sky_top_color" getter="get_sky_top_color" default="Color(0.35, 0.46, 0.71, 1)"> Color of the sky at the top. Blends with [member sky_horizon_color]. </member> <member name="sun_angle_max" type="float" setter="set_sun_angle_max" getter="get_sun_angle_max" default="100.0"> diff --git a/doc/classes/ProgressBar.xml b/doc/classes/ProgressBar.xml index 160b61c720..c33f6f636d 100644 --- a/doc/classes/ProgressBar.xml +++ b/doc/classes/ProgressBar.xml @@ -29,13 +29,13 @@ <theme_item name="font" type="Font"> Font used to draw the fill percentage if [member percent_visible] is [code]true[/code]. </theme_item> - <theme_item name="font_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )"> + <theme_item name="font_color" type="Color" default="Color(0.94, 0.94, 0.94, 1)"> The color of the text. </theme_item> - <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)"> The tint of text outline of the [ProgressBar]. </theme_item> - <theme_item name="font_shadow_color" type="Color" default="Color( 0, 0, 0, 1 )"> + <theme_item name="font_shadow_color" type="Color" default="Color(0, 0, 0, 1)"> The color of the text's shadow. </theme_item> <theme_item name="font_size" type="int"> diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 35656d170b..04d1af3f6a 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -226,7 +226,7 @@ </method> </methods> <members> - <member name="application/boot_splash/bg_color" type="Color" setter="" getter="" default="Color( 0.14, 0.14, 0.14, 1 )"> + <member name="application/boot_splash/bg_color" type="Color" setter="" getter="" default="Color(0.14, 0.14, 0.14, 1)"> Background color for the boot splash. </member> <member name="application/boot_splash/fullsize" type="bool" setter="" getter="" default="true"> @@ -461,7 +461,7 @@ <member name="debug/settings/visual_script/max_call_stack" type="int" setter="" getter="" default="1024"> Maximum call stack in visual scripting, to avoid infinite recursion. </member> - <member name="debug/shapes/collision/contact_color" type="Color" setter="" getter="" default="Color( 1, 0.2, 0.1, 0.8 )"> + <member name="debug/shapes/collision/contact_color" type="Color" setter="" getter="" default="Color(1, 0.2, 0.1, 0.8)"> Color of the contact points between collision shapes, visible when "Visible Collision Shapes" is enabled in the Debug menu. </member> <member name="debug/shapes/collision/draw_2d_outlines" type="bool" setter="" getter="" default="true"> @@ -470,22 +470,22 @@ <member name="debug/shapes/collision/max_contacts_displayed" type="int" setter="" getter="" default="10000"> Maximum number of contact points between collision shapes to display when "Visible Collision Shapes" is enabled in the Debug menu. </member> - <member name="debug/shapes/collision/shape_color" type="Color" setter="" getter="" default="Color( 0, 0.6, 0.7, 0.42 )"> + <member name="debug/shapes/collision/shape_color" type="Color" setter="" getter="" default="Color(0, 0.6, 0.7, 0.42)"> Color of the collision shapes, visible when "Visible Collision Shapes" is enabled in the Debug menu. </member> - <member name="debug/shapes/navigation/disabled_geometry_color" type="Color" setter="" getter="" default="Color( 1, 0.7, 0.1, 0.4 )"> + <member name="debug/shapes/navigation/disabled_geometry_color" type="Color" setter="" getter="" default="Color(1, 0.7, 0.1, 0.4)"> Color of the disabled navigation geometry, visible when "Visible Navigation" is enabled in the Debug menu. </member> - <member name="debug/shapes/navigation/geometry_color" type="Color" setter="" getter="" default="Color( 0.1, 1, 0.7, 0.4 )"> + <member name="debug/shapes/navigation/geometry_color" type="Color" setter="" getter="" default="Color(0.1, 1, 0.7, 0.4)"> Color of the navigation geometry, visible when "Visible Navigation" is enabled in the Debug menu. </member> <member name="display/mouse_cursor/custom_image" type="String" setter="" getter="" default=""""> Custom image for the mouse cursor (limited to 256×256). </member> - <member name="display/mouse_cursor/custom_image_hotspot" type="Vector2" setter="" getter="" default="Vector2( 0, 0 )"> + <member name="display/mouse_cursor/custom_image_hotspot" type="Vector2" setter="" getter="" default="Vector2(0, 0)"> Hotspot for the custom mouse cursor image. </member> - <member name="display/mouse_cursor/tooltip_position_offset" type="Vector2" setter="" getter="" default="Vector2( 10, 10 )"> + <member name="display/mouse_cursor/tooltip_position_offset" type="Vector2" setter="" getter="" default="Vector2(10, 10)"> Position offset for tooltips, relative to the mouse cursor's hotspot. </member> <member name="display/window/dpi/allow_hidpi" type="bool" setter="" getter="" default="false"> @@ -551,7 +551,7 @@ prime-run %command% [/codeblock] </member> - <member name="editor/script/search_in_file_extensions" type="PackedStringArray" setter="" getter="" default="PackedStringArray( "gd", "gdshader" )"> + <member name="editor/script/search_in_file_extensions" type="PackedStringArray" setter="" getter="" default="PackedStringArray("gd", "gdshader")"> Text-based file extensions to include in the script editor's "Find in Files" feature. You can add e.g. [code]tscn[/code] if you wish to also parse your scene files, especially if you use built-in scripts which are serialized in the scene files. </member> <member name="editor/script/templates_search_path" type="String" setter="" getter="" default=""res://script_templates""> @@ -1222,7 +1222,7 @@ [/csharp] [/codeblocks] </member> - <member name="physics/2d/default_gravity_vector" type="Vector2" setter="" getter="" default="Vector2( 0, 1 )"> + <member name="physics/2d/default_gravity_vector" type="Vector2" setter="" getter="" default="Vector2(0, 1)"> The default gravity direction in 2D. [b]Note:[/b] This property is only read when the project starts. To change the default gravity vector at runtime, use the following code sample: [codeblocks] @@ -1274,7 +1274,7 @@ [/csharp] [/codeblocks] </member> - <member name="physics/3d/default_gravity_vector" type="Vector3" setter="" getter="" default="Vector3( 0, -1, 0 )"> + <member name="physics/3d/default_gravity_vector" type="Vector3" setter="" getter="" default="Vector3(0, -1, 0)"> The default gravity direction in 3D. [b]Note:[/b] This property is only read when the project starts. To change the default gravity vector at runtime, use the following code sample: [codeblocks] @@ -1366,7 +1366,7 @@ <member name="rendering/driver/threads/thread_model" type="int" setter="" getter="" default="1"> Thread model for rendering. Rendering on a thread can vastly improve performance, but synchronizing to the main thread can cause a bit more jitter. </member> - <member name="rendering/environment/defaults/default_clear_color" type="Color" setter="" getter="" default="Color( 0.3, 0.3, 0.3, 1 )"> + <member name="rendering/environment/defaults/default_clear_color" type="Color" setter="" getter="" default="Color(0.3, 0.3, 0.3, 1)"> Default background clear color. Overridable per [Viewport] using its [Environment]. See [member Environment.background_mode] and [member Environment.background_color] in particular. To change this default color programmatically, use [method RenderingServer.set_default_clear_color]. </member> <member name="rendering/environment/defaults/default_environment" type="String" setter="" getter="" default=""""> diff --git a/doc/classes/PropertyTweener.xml b/doc/classes/PropertyTweener.xml new file mode 100644 index 0000000000..1e77bb33c6 --- /dev/null +++ b/doc/classes/PropertyTweener.xml @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="PropertyTweener" inherits="Tweener" version="4.0"> + <brief_description> + Interpolates an [Object]'s property over time. + </brief_description> + <description> + [PropertyTweener] is used to interpolate a property in an object. See [method Tween.tween_property] for more usage information. + [b]Note:[/b] [method Tween.tween_property] is the only correct way to create [PropertyTweener]. Any [PropertyTweener] created manually will not function correctly. + </description> + <tutorials> + </tutorials> + <methods> + <method name="as_relative"> + <return type="PropertyTweener"> + </return> + <description> + When called, the final value will be used as a relative value instead. Example: + [codeblock] + var tween = get_tree().create_tween() + tween.tween_property(self, "position", Vector2.RIGHT * 100, 1).as_relative() #the node will move by 100 pixels to the right + [/codeblock] + </description> + </method> + <method name="from"> + <return type="PropertyTweener"> + </return> + <argument index="0" name="value" type="Variant"> + </argument> + <description> + Sets a custom initial value to the [PropertyTweener]. Example: + [codeblock] + var tween = get_tree().create_tween() + tween.tween_property(self, "position", Vector2(200, 100), 1).from(Vector2(100, 100) #this will move the node from position (100, 100) to (200, 100) + [/codeblock] + </description> + </method> + <method name="from_current"> + <return type="PropertyTweener"> + </return> + <description> + Makes the [PropertyTweener] use the current property value (i.e. at the time of creating this [PropertyTweener]) as a starting point. This is equivalent of using [method from] with the current value. These two calls will do the same: + [codeblock] + tween.tween_property(self, "position", Vector2(200, 100), 1).from(position) + tween.tween_property(self, "position", Vector2(200, 100), 1).from_current() + [/codeblock] + </description> + </method> + <method name="set_delay"> + <return type="PropertyTweener"> + </return> + <argument index="0" name="delay" type="float"> + </argument> + <description> + Sets the time in seconds after which the [PropertyTweener] will start interpolating. By default there's no delay. + </description> + </method> + <method name="set_ease"> + <return type="PropertyTweener"> + </return> + <argument index="0" name="ease" type="int" enum="Tween.EaseType"> + </argument> + <description> + Sets the type of used easing from [enum Tween.EaseType]. If not set, the default easing is used from the [Tween] that contains this Tweener. + </description> + </method> + <method name="set_trans"> + <return type="PropertyTweener"> + </return> + <argument index="0" name="trans" type="int" enum="Tween.TransitionType"> + </argument> + <description> + Sets the type of used transition from [enum Tween.TransitionType]. If not set, the default transition is used from the [Tween] that contains this Tweener. + </description> + </method> + </methods> + <constants> + </constants> +</class> diff --git a/doc/classes/ProximityGroup3D.xml b/doc/classes/ProximityGroup3D.xml index 512d55c9a0..22e397b832 100644 --- a/doc/classes/ProximityGroup3D.xml +++ b/doc/classes/ProximityGroup3D.xml @@ -23,7 +23,7 @@ <members> <member name="dispatch_mode" type="int" setter="set_dispatch_mode" getter="get_dispatch_mode" enum="ProximityGroup3D.DispatchMode" default="0"> </member> - <member name="grid_radius" type="Vector3" setter="set_grid_radius" getter="get_grid_radius" default="Vector3( 1, 1, 1 )"> + <member name="grid_radius" type="Vector3" setter="set_grid_radius" getter="get_grid_radius" default="Vector3(1, 1, 1)"> </member> <member name="group_name" type="String" setter="set_group_name" getter="get_group_name" default=""""> </member> diff --git a/doc/classes/QuadMesh.xml b/doc/classes/QuadMesh.xml index 24a3d76ee2..94d638888c 100644 --- a/doc/classes/QuadMesh.xml +++ b/doc/classes/QuadMesh.xml @@ -13,7 +13,7 @@ <methods> </methods> <members> - <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2( 1, 1 )"> + <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2(1, 1)"> Size on the X and Y axes. </member> </members> diff --git a/doc/classes/Quaternion.xml b/doc/classes/Quaternion.xml index 678fb0d44d..660204ee7d 100644 --- a/doc/classes/Quaternion.xml +++ b/doc/classes/Quaternion.xml @@ -83,6 +83,16 @@ Constructs a quaternion defined by the given values. </description> </method> + <method name="angle_to" qualifiers="const"> + <return type="float"> + </return> + <argument index="0" name="to" type="Quaternion"> + </argument> + <description> + Returns the angle between this quaternion and [code]to[/code]. This is the magnitude of the angle you would need to rotate by to get from one to the other. + [b]Note:[/b] This method has an abnormally high amount of floating-point error, so methods such as [code]is_zero_approx[/code] will not work reliably. + </description> + </method> <method name="cubic_slerp" qualifiers="const"> <return type="Quaternion"> </return> @@ -301,7 +311,7 @@ </member> </members> <constants> - <constant name="IDENTITY" value="Quaternion( 0, 0, 0, 1 )"> + <constant name="IDENTITY" value="Quaternion(0, 0, 0, 1)"> The identity quaternion, representing no rotation. Equivalent to an identity [Basis] matrix. If a vector is transformed by an identity quaternion, it will not change. </constant> </constants> diff --git a/doc/classes/RDPipelineColorBlendState.xml b/doc/classes/RDPipelineColorBlendState.xml index 1424a0d653..b672a053c7 100644 --- a/doc/classes/RDPipelineColorBlendState.xml +++ b/doc/classes/RDPipelineColorBlendState.xml @@ -9,9 +9,9 @@ <methods> </methods> <members> - <member name="attachments" type="RDPipelineColorBlendStateAttachment[]" setter="set_attachments" getter="get_attachments" default="[ ]"> + <member name="attachments" type="RDPipelineColorBlendStateAttachment[]" setter="set_attachments" getter="get_attachments" default="[]"> </member> - <member name="blend_constant" type="Color" setter="set_blend_constant" getter="get_blend_constant" default="Color( 0, 0, 0, 1 )"> + <member name="blend_constant" type="Color" setter="set_blend_constant" getter="get_blend_constant" default="Color(0, 0, 0, 1)"> </member> <member name="enable_logic_op" type="bool" setter="set_enable_logic_op" getter="get_enable_logic_op" default="false"> </member> diff --git a/doc/classes/RDPipelineMultisampleState.xml b/doc/classes/RDPipelineMultisampleState.xml index 8c90f02301..b4345f1f8b 100644 --- a/doc/classes/RDPipelineMultisampleState.xml +++ b/doc/classes/RDPipelineMultisampleState.xml @@ -19,7 +19,7 @@ </member> <member name="sample_count" type="int" setter="set_sample_count" getter="get_sample_count" enum="RenderingDevice.TextureSamples" default="0"> </member> - <member name="sample_masks" type="int[]" setter="set_sample_masks" getter="get_sample_masks" default="[ ]"> + <member name="sample_masks" type="int[]" setter="set_sample_masks" getter="get_sample_masks" default="[]"> </member> </members> <constants> diff --git a/doc/classes/RDShaderBytecode.xml b/doc/classes/RDShaderBytecode.xml index 7a3501004e..20bf9bdd72 100644 --- a/doc/classes/RDShaderBytecode.xml +++ b/doc/classes/RDShaderBytecode.xml @@ -45,15 +45,15 @@ </method> </methods> <members> - <member name="bytecode_compute" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray( )"> + <member name="bytecode_compute" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray()"> </member> - <member name="bytecode_fragment" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray( )"> + <member name="bytecode_fragment" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray()"> </member> - <member name="bytecode_tesselation_control" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray( )"> + <member name="bytecode_tesselation_control" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray()"> </member> - <member name="bytecode_tesselation_evaluation" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray( )"> + <member name="bytecode_tesselation_evaluation" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray()"> </member> - <member name="bytecode_vertex" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray( )"> + <member name="bytecode_vertex" type="PackedByteArray" setter="set_stage_bytecode" getter="get_stage_bytecode" default="PackedByteArray()"> </member> <member name="compile_error_compute" type="String" setter="set_stage_compile_error" getter="get_stage_compile_error" default=""""> </member> diff --git a/doc/classes/RayCast2D.xml b/doc/classes/RayCast2D.xml index e30d7df63f..14b67b46df 100644 --- a/doc/classes/RayCast2D.xml +++ b/doc/classes/RayCast2D.xml @@ -138,7 +138,7 @@ <member name="exclude_parent" type="bool" setter="set_exclude_parent_body" getter="get_exclude_parent_body" default="true"> If [code]true[/code], the parent node will be excluded from collision detection. </member> - <member name="target_position" type="Vector2" setter="set_target_position" getter="get_target_position" default="Vector2( 0, 50 )"> + <member name="target_position" type="Vector2" setter="set_target_position" getter="get_target_position" default="Vector2(0, 50)"> The ray's destination point, relative to the RayCast's [code]position[/code]. </member> </members> diff --git a/doc/classes/RayCast3D.xml b/doc/classes/RayCast3D.xml index 443890438f..98c8c96403 100644 --- a/doc/classes/RayCast3D.xml +++ b/doc/classes/RayCast3D.xml @@ -136,7 +136,7 @@ <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1"> The ray's collision mask. Only objects in at least one collision layer enabled in the mask will be detected. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information. </member> - <member name="debug_shape_custom_color" type="Color" setter="set_debug_shape_custom_color" getter="get_debug_shape_custom_color" default="Color( 0, 0, 0, 1 )"> + <member name="debug_shape_custom_color" type="Color" setter="set_debug_shape_custom_color" getter="get_debug_shape_custom_color" default="Color(0, 0, 0, 1)"> The custom color to use to draw the shape in the editor and at run-time if [b]Visible Collision Shapes[/b] is enabled in the [b]Debug[/b] menu. This color will be highlighted at run-time if the [RayCast3D] is colliding with something. If set to [code]Color(0.0, 0.0, 0.0)[/code] (by default), the color set in [member ProjectSettings.debug/shapes/collision/shape_color] is used. </member> @@ -149,7 +149,7 @@ <member name="exclude_parent" type="bool" setter="set_exclude_parent_body" getter="get_exclude_parent_body" default="true"> If [code]true[/code], collisions will be ignored for this RayCast3D's immediate parent. </member> - <member name="target_position" type="Vector3" setter="set_target_position" getter="get_target_position" default="Vector3( 0, -1, 0 )"> + <member name="target_position" type="Vector3" setter="set_target_position" getter="get_target_position" default="Vector3(0, -1, 0)"> The ray's destination point, relative to the RayCast's [code]position[/code]. </member> </members> diff --git a/doc/classes/Rect2.xml b/doc/classes/Rect2.xml index 352a18e326..627c488b01 100644 --- a/doc/classes/Rect2.xml +++ b/doc/classes/Rect2.xml @@ -214,13 +214,13 @@ </method> </methods> <members> - <member name="end" type="Vector2" setter="" getter="" default="Vector2( 0, 0 )"> + <member name="end" type="Vector2" setter="" getter="" default="Vector2(0, 0)"> Ending corner. This is calculated as [code]position + size[/code]. Setting this value will change the size. </member> - <member name="position" type="Vector2" setter="" getter="" default="Vector2( 0, 0 )"> + <member name="position" type="Vector2" setter="" getter="" default="Vector2(0, 0)"> Beginning corner. Typically has values lower than [member end]. </member> - <member name="size" type="Vector2" setter="" getter="" default="Vector2( 0, 0 )"> + <member name="size" type="Vector2" setter="" getter="" default="Vector2(0, 0)"> Size from [member position] to [member end]. Typically, all components are positive. If the size is negative, you can use [method abs] to fix it. </member> diff --git a/doc/classes/Rect2i.xml b/doc/classes/Rect2i.xml index 84bef9b406..67d148084f 100644 --- a/doc/classes/Rect2i.xml +++ b/doc/classes/Rect2i.xml @@ -193,13 +193,13 @@ </method> </methods> <members> - <member name="end" type="Vector2i" setter="" getter="" default="Vector2i( 0, 0 )"> + <member name="end" type="Vector2i" setter="" getter="" default="Vector2i(0, 0)"> Ending corner. This is calculated as [code]position + size[/code]. Setting this value will change the size. </member> - <member name="position" type="Vector2i" setter="" getter="" default="Vector2i( 0, 0 )"> + <member name="position" type="Vector2i" setter="" getter="" default="Vector2i(0, 0)"> Beginning corner. Typically has values lower than [member end]. </member> - <member name="size" type="Vector2i" setter="" getter="" default="Vector2i( 0, 0 )"> + <member name="size" type="Vector2i" setter="" getter="" default="Vector2i(0, 0)"> Size from [member position] to [member end]. Typically, all components are positive. If the size is negative, you can use [method abs] to fix it. </member> diff --git a/doc/classes/RectangleShape2D.xml b/doc/classes/RectangleShape2D.xml index 8e37fbad6f..f2795ae4a1 100644 --- a/doc/classes/RectangleShape2D.xml +++ b/doc/classes/RectangleShape2D.xml @@ -13,7 +13,7 @@ <methods> </methods> <members> - <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2( 20, 20 )"> + <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2(20, 20)"> The rectangle's width and height. </member> </members> diff --git a/doc/classes/ReferenceRect.xml b/doc/classes/ReferenceRect.xml index 1a3fbbdfc5..df9a6f0a46 100644 --- a/doc/classes/ReferenceRect.xml +++ b/doc/classes/ReferenceRect.xml @@ -11,7 +11,7 @@ <methods> </methods> <members> - <member name="border_color" type="Color" setter="set_border_color" getter="get_border_color" default="Color( 1, 0, 0, 1 )"> + <member name="border_color" type="Color" setter="set_border_color" getter="get_border_color" default="Color(1, 0, 0, 1)"> Sets the border [Color] of the [ReferenceRect]. </member> <member name="border_width" type="float" setter="set_border_width" getter="get_border_width" default="1.0"> diff --git a/doc/classes/ReflectionProbe.xml b/doc/classes/ReflectionProbe.xml index 13df17cd22..1d32a8b509 100644 --- a/doc/classes/ReflectionProbe.xml +++ b/doc/classes/ReflectionProbe.xml @@ -13,7 +13,7 @@ <methods> </methods> <members> - <member name="ambient_color" type="Color" setter="set_ambient_color" getter="get_ambient_color" default="Color( 0, 0, 0, 1 )"> + <member name="ambient_color" type="Color" setter="set_ambient_color" getter="get_ambient_color" default="Color(0, 0, 0, 1)"> </member> <member name="ambient_color_energy" type="float" setter="set_ambient_color_energy" getter="get_ambient_color_energy" default="1.0"> </member> @@ -28,7 +28,7 @@ <member name="enable_shadows" type="bool" setter="set_enable_shadows" getter="are_shadows_enabled" default="false"> If [code]true[/code], computes shadows in the reflection probe. This makes the reflection probe slower to render; you may want to disable this if using the [constant UPDATE_ALWAYS] [member update_mode]. </member> - <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3( 1, 1, 1 )"> + <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(1, 1, 1)"> The size of the reflection probe. The larger the extents the more space covered by the probe which will lower the perceived resolution. It is best to keep the extents only as large as you need them. </member> <member name="intensity" type="float" setter="set_intensity" getter="get_intensity" default="1.0"> @@ -42,7 +42,7 @@ <member name="max_distance" type="float" setter="set_max_distance" getter="get_max_distance" default="0.0"> Sets the max distance away from the probe an object can be before it is culled. </member> - <member name="origin_offset" type="Vector3" setter="set_origin_offset" getter="get_origin_offset" default="Vector3( 0, 0, 0 )"> + <member name="origin_offset" type="Vector3" setter="set_origin_offset" getter="get_origin_offset" default="Vector3(0, 0, 0)"> Sets the origin offset to be used when this reflection probe is in box project mode. </member> <member name="update_mode" type="int" setter="set_update_mode" getter="get_update_mode" enum="ReflectionProbe.UpdateMode" default="0"> diff --git a/doc/classes/RenderingDevice.xml b/doc/classes/RenderingDevice.xml index 841d2bde72..dc56e6fd5d 100644 --- a/doc/classes/RenderingDevice.xml +++ b/doc/classes/RenderingDevice.xml @@ -196,15 +196,15 @@ </argument> <argument index="4" name="final_depth_action" type="int" enum="RenderingDevice.FinalAction"> </argument> - <argument index="5" name="clear_color_values" type="PackedColorArray" default="PackedColorArray( )"> + <argument index="5" name="clear_color_values" type="PackedColorArray" default="PackedColorArray()"> </argument> <argument index="6" name="clear_depth" type="float" default="1.0"> </argument> <argument index="7" name="clear_stencil" type="int" default="0"> </argument> - <argument index="8" name="region" type="Rect2" default="Rect2i( 0, 0, 0, 0 )"> + <argument index="8" name="region" type="Rect2" default="Rect2i(0, 0, 0, 0)"> </argument> - <argument index="9" name="storage_textures" type="Array" default="[ ]"> + <argument index="9" name="storage_textures" type="Array" default="[]"> </argument> <description> </description> @@ -214,7 +214,7 @@ </return> <argument index="0" name="screen" type="int" default="0"> </argument> - <argument index="1" name="clear_color" type="Color" default="Color( 0, 0, 0, 1 )"> + <argument index="1" name="clear_color" type="Color" default="Color(0, 0, 0, 1)"> </argument> <description> </description> @@ -234,15 +234,15 @@ </argument> <argument index="5" name="final_depth_action" type="int" enum="RenderingDevice.FinalAction"> </argument> - <argument index="6" name="clear_color_values" type="PackedColorArray" default="PackedColorArray( )"> + <argument index="6" name="clear_color_values" type="PackedColorArray" default="PackedColorArray()"> </argument> <argument index="7" name="clear_depth" type="float" default="1.0"> </argument> <argument index="8" name="clear_stencil" type="int" default="0"> </argument> - <argument index="9" name="region" type="Rect2" default="Rect2i( 0, 0, 0, 0 )"> + <argument index="9" name="region" type="Rect2" default="Rect2i(0, 0, 0, 0)"> </argument> - <argument index="10" name="storage_textures" type="RID[]" default="[ ]"> + <argument index="10" name="storage_textures" type="RID[]" default="[]"> </argument> <description> </description> @@ -316,7 +316,7 @@ </return> <argument index="0" name="draw_list" type="int"> </argument> - <argument index="1" name="rect" type="Rect2" default="Rect2i( 0, 0, 0, 0 )"> + <argument index="1" name="rect" type="Rect2" default="Rect2i(0, 0, 0, 0)"> </argument> <description> </description> @@ -488,7 +488,7 @@ </argument> <argument index="1" name="format" type="int" enum="RenderingDevice.IndexBufferFormat"> </argument> - <argument index="2" name="data" type="PackedByteArray" default="PackedByteArray( )"> + <argument index="2" name="data" type="PackedByteArray" default="PackedByteArray()"> </argument> <argument index="3" name="use_restart_indices" type="bool" default="false"> </argument> @@ -606,7 +606,7 @@ </return> <argument index="0" name="size_bytes" type="int"> </argument> - <argument index="1" name="data" type="PackedByteArray" default="PackedByteArray( )"> + <argument index="1" name="data" type="PackedByteArray" default="PackedByteArray()"> </argument> <argument index="2" name="usage" type="int" default="0"> </argument> @@ -632,7 +632,7 @@ </argument> <argument index="1" name="format" type="int" enum="RenderingDevice.DataFormat"> </argument> - <argument index="2" name="data" type="PackedByteArray" default="PackedByteArray( )"> + <argument index="2" name="data" type="PackedByteArray" default="PackedByteArray()"> </argument> <description> </description> @@ -690,7 +690,7 @@ </argument> <argument index="1" name="view" type="RDTextureView"> </argument> - <argument index="2" name="data" type="PackedByteArray[]" default="[ ]"> + <argument index="2" name="data" type="PackedByteArray[]" default="[]"> </argument> <description> </description> @@ -788,7 +788,7 @@ </return> <argument index="0" name="size_bytes" type="int"> </argument> - <argument index="1" name="data" type="PackedByteArray" default="PackedByteArray( )"> + <argument index="1" name="data" type="PackedByteArray" default="PackedByteArray()"> </argument> <description> </description> @@ -818,7 +818,7 @@ </return> <argument index="0" name="size_bytes" type="int"> </argument> - <argument index="1" name="data" type="PackedByteArray" default="PackedByteArray( )"> + <argument index="1" name="data" type="PackedByteArray" default="PackedByteArray()"> </argument> <argument index="2" name="use_as_storage" type="bool" default="false"> </argument> diff --git a/doc/classes/RenderingServer.xml b/doc/classes/RenderingServer.xml index 300108ff77..44e0202307 100644 --- a/doc/classes/RenderingServer.xml +++ b/doc/classes/RenderingServer.xml @@ -620,7 +620,7 @@ </argument> <argument index="5" name="reflection_source" type="int" enum="RenderingServer.EnvironmentReflectionSource" default="0"> </argument> - <argument index="6" name="ao_color" type="Color" default="Color( 0, 0, 0, 1 )"> + <argument index="6" name="ao_color" type="Color" default="Color(0, 0, 0, 1)"> </argument> <description> </description> @@ -2725,7 +2725,7 @@ </return> <argument index="0" name="viewport" type="RID"> </argument> - <argument index="1" name="rect" type="Rect2" default="Rect2( 0, 0, 0, 0 )"> + <argument index="1" name="rect" type="Rect2" default="Rect2(0, 0, 0, 0)"> </argument> <argument index="2" name="screen" type="int" default="0"> </argument> diff --git a/doc/classes/ResourceLoader.xml b/doc/classes/ResourceLoader.xml index c81b21333f..682d7b97f3 100644 --- a/doc/classes/ResourceLoader.xml +++ b/doc/classes/ResourceLoader.xml @@ -84,7 +84,7 @@ </return> <argument index="0" name="path" type="String"> </argument> - <argument index="1" name="progress" type="Array" default="[ ]"> + <argument index="1" name="progress" type="Array" default="[]"> </argument> <description> Returns the status of a threaded loading operation started with [method load_threaded_request] for the resource at [code]path[/code]. See [enum ThreadLoadStatus] for possible return values. diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml index 7ca70f5a7a..623ee7520d 100644 --- a/doc/classes/RichTextLabel.xml +++ b/doc/classes/RichTextLabel.xml @@ -24,7 +24,7 @@ </argument> <argument index="2" name="height" type="int" default="0"> </argument> - <argument index="3" name="color" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)"> </argument> <argument index="4" name="inline_align" type="int" enum="VAlign" default="0"> </argument> @@ -209,13 +209,13 @@ </argument> <argument index="2" name="size" type="int"> </argument> - <argument index="3" name="dropcap_margins" type="Rect2" default="Rect2( 0, 0, 0, 0 )"> + <argument index="3" name="dropcap_margins" type="Rect2" default="Rect2(0, 0, 0, 0)"> </argument> - <argument index="4" name="color" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="4" name="color" type="Color" default="Color(1, 1, 1, 1)"> </argument> <argument index="5" name="outline_size" type="int" default="0"> </argument> - <argument index="6" name="outline_color" type="Color" default="Color( 0, 0, 0, 0 )"> + <argument index="6" name="outline_color" type="Color" default="Color(0, 0, 0, 0)"> </argument> <description> Adds a [code][dropcap][/code] tag to the tag stack. Drop cap (dropped capital) is a decorative element at the beginning of a paragraph that is larger than the rest of the text. @@ -450,7 +450,7 @@ The label's text in BBCode format. Is not representative of manual modifications to the internal tag stack. Erases changes made by other methods when edited. [b]Note:[/b] It is unadvised to use the [code]+=[/code] operator with [code]bbcode_text[/code] (e.g. [code]bbcode_text += "some string"[/code]) as it replaces the whole text and can cause slowdowns. Use [method append_bbcode] for adding text instead, unless you absolutely need to close a tag that was opened in an earlier method call. </member> - <member name="custom_effects" type="Array" setter="set_effects" getter="get_effects" default="[ ]"> + <member name="custom_effects" type="Array" setter="set_effects" getter="get_effects" default="[]"> The currently installed custom effects. This is an array of [RichTextEffect]s. To add a custom effect, it's more convenient to use [method install_effect]. </member> @@ -484,7 +484,7 @@ <member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="Control.StructuredTextParser" default="0"> Set BiDi algorithm override for the structured text. </member> - <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[ ]"> + <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]"> Set additional options for BiDi override. </member> <member name="tab_size" type="int" setter="set_tab_size" getter="get_tab_size" default="4"> @@ -612,19 +612,19 @@ <theme_item name="bold_italics_font_size" type="int"> The font size used for bold italics text. </theme_item> - <theme_item name="default_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="default_color" type="Color" default="Color(1, 1, 1, 1)"> The default text color. </theme_item> <theme_item name="focus" type="StyleBox"> The background The background used when the [RichTextLabel] is focused. </theme_item> - <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)"> The default tint of text outline. </theme_item> - <theme_item name="font_selected_color" type="Color" default="Color( 0, 0, 0, 1 )"> + <theme_item name="font_selected_color" type="Color" default="Color(0, 0, 0, 1)"> The color of selected text, used when [member selection_enabled] is [code]true[/code]. </theme_item> - <theme_item name="font_shadow_color" type="Color" default="Color( 0, 0, 0, 0 )"> + <theme_item name="font_shadow_color" type="Color" default="Color(0, 0, 0, 0)"> The color of the font's shadow. </theme_item> <theme_item name="italics_font" type="Font"> @@ -654,7 +654,7 @@ <theme_item name="outline_size" type="int" default="0"> The size of the text outline. </theme_item> - <theme_item name="selection_color" type="Color" default="Color( 0.1, 0.1, 1, 0.8 )"> + <theme_item name="selection_color" type="Color" default="Color(0.1, 0.1, 1, 0.8)"> The color of the selection box. </theme_item> <theme_item name="shadow_as_outline" type="int" default="0"> @@ -666,16 +666,16 @@ <theme_item name="shadow_offset_y" type="int" default="1"> The vertical offset of the font's shadow. </theme_item> - <theme_item name="table_border" type="Color" default="Color( 0, 0, 0, 0 )"> + <theme_item name="table_border" type="Color" default="Color(0, 0, 0, 0)"> The default cell border color. </theme_item> - <theme_item name="table_even_row_bg" type="Color" default="Color( 0, 0, 0, 0 )"> + <theme_item name="table_even_row_bg" type="Color" default="Color(0, 0, 0, 0)"> The default background color for even rows. </theme_item> <theme_item name="table_hseparation" type="int" default="3"> The horizontal separation of elements in a table. </theme_item> - <theme_item name="table_odd_row_bg" type="Color" default="Color( 0, 0, 0, 0 )"> + <theme_item name="table_odd_row_bg" type="Color" default="Color(0, 0, 0, 0)"> The default background color for odd rows. </theme_item> <theme_item name="table_vseparation" type="int" default="3"> diff --git a/doc/classes/RigidBody2D.xml b/doc/classes/RigidBody2D.xml index 237317daf1..64573b7282 100644 --- a/doc/classes/RigidBody2D.xml +++ b/doc/classes/RigidBody2D.xml @@ -39,7 +39,7 @@ </return> <argument index="0" name="force" type="Vector2"> </argument> - <argument index="1" name="position" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="1" name="position" type="Vector2" default="Vector2(0, 0)"> </argument> <description> Adds a positioned force to the body. Both the force and the offset from the body origin are in global coordinates. @@ -57,7 +57,7 @@ <method name="apply_central_impulse"> <return type="void"> </return> - <argument index="0" name="impulse" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="0" name="impulse" type="Vector2" default="Vector2(0, 0)"> </argument> <description> Applies a directional impulse without affecting rotation. @@ -68,7 +68,7 @@ </return> <argument index="0" name="impulse" type="Vector2"> </argument> - <argument index="1" name="position" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="1" name="position" type="Vector2" default="Vector2(0, 0)"> </argument> <description> Applies a positioned impulse to the body. An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason it should only be used when simulating one-time impacts (use the "_force" functions otherwise). The position uses the rotation of the global coordinate system, but is centered at the object's origin. @@ -109,7 +109,7 @@ <member name="angular_velocity" type="float" setter="set_angular_velocity" getter="get_angular_velocity" default="0.0"> The body's rotational velocity. </member> - <member name="applied_force" type="Vector2" setter="set_applied_force" getter="get_applied_force" default="Vector2( 0, 0 )"> + <member name="applied_force" type="Vector2" setter="set_applied_force" getter="get_applied_force" default="Vector2(0, 0)"> The body's total applied force. </member> <member name="applied_torque" type="float" setter="set_applied_torque" getter="get_applied_torque" default="0.0"> @@ -142,7 +142,7 @@ Damps the body's [member linear_velocity]. If [code]-1[/code], the body will use the [b]Default Linear Damp[/b] in [b]Project > Project Settings > Physics > 2d[/b]. See [member ProjectSettings.physics/2d/default_linear_damp] for more details about damping. </member> - <member name="linear_velocity" type="Vector2" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector2( 0, 0 )"> + <member name="linear_velocity" type="Vector2" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector2(0, 0)"> The body's linear velocity. </member> <member name="mass" type="float" setter="set_mass" getter="get_mass" default="1.0"> diff --git a/doc/classes/RigidBody3D.xml b/doc/classes/RigidBody3D.xml index e3349169ff..fb2b9690a3 100644 --- a/doc/classes/RigidBody3D.xml +++ b/doc/classes/RigidBody3D.xml @@ -40,7 +40,7 @@ </return> <argument index="0" name="force" type="Vector3"> </argument> - <argument index="1" name="position" type="Vector3" default="Vector3( 0, 0, 0 )"> + <argument index="1" name="position" type="Vector3" default="Vector3(0, 0, 0)"> </argument> <description> Adds a constant directional force (i.e. acceleration). @@ -71,7 +71,7 @@ </return> <argument index="0" name="impulse" type="Vector3"> </argument> - <argument index="1" name="position" type="Vector3" default="Vector3( 0, 0, 0 )"> + <argument index="1" name="position" type="Vector3" default="Vector3(0, 0, 0)"> </argument> <description> Applies a positioned impulse to the body. An impulse is time independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason it should only be used when simulating one-time impacts. The position uses the rotation of the global coordinate system, but is centered at the object's origin. @@ -116,7 +116,7 @@ Damps RigidBody3D's rotational forces. See [member ProjectSettings.physics/3d/default_angular_damp] for more details about damping. </member> - <member name="angular_velocity" type="Vector3" setter="set_angular_velocity" getter="get_angular_velocity" default="Vector3( 0, 0, 0 )"> + <member name="angular_velocity" type="Vector3" setter="set_angular_velocity" getter="get_angular_velocity" default="Vector3(0, 0, 0)"> RigidBody3D's rotational velocity. </member> <member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep" default="true"> @@ -143,7 +143,7 @@ The body's linear damp. Cannot be less than -1.0. If this value is different from -1.0, any linear damp derived from the world or areas will be overridden. See [member ProjectSettings.physics/3d/default_linear_damp] for more details about damping. </member> - <member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector3( 0, 0, 0 )"> + <member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity" default="Vector3(0, 0, 0)"> The body's linear velocity. Can be used sporadically, but [b]don't set this every frame[/b], because physics may run in another thread and runs at a different granularity. Use [method _integrate_forces] as your process loop for precise control of the body state. </member> <member name="mass" type="float" setter="set_mass" getter="get_mass" default="1.0"> diff --git a/doc/classes/SceneTree.xml b/doc/classes/SceneTree.xml index 7a15153fc2..d327e8cbca 100644 --- a/doc/classes/SceneTree.xml +++ b/doc/classes/SceneTree.xml @@ -90,6 +90,13 @@ The timer will be automatically freed after its time elapses. </description> </method> + <method name="create_tween"> + <return type="Tween"> + </return> + <description> + Creates and returns a new [Tween]. + </description> + </method> <method name="get_first_node_in_group"> <return type="Node"> </return> @@ -135,6 +142,13 @@ Returns a list of all nodes assigned to the given group. </description> </method> + <method name="get_processed_tweens"> + <return type="Array"> + </return> + <description> + Returns an array of currently exising [Tween]s in the [SceneTree] (both running and paused). + </description> + </method> <method name="get_rpc_sender_id" qualifiers="const"> <return type="int"> </return> diff --git a/doc/classes/SegmentShape2D.xml b/doc/classes/SegmentShape2D.xml index 31c0f7f1f3..341c5e9d20 100644 --- a/doc/classes/SegmentShape2D.xml +++ b/doc/classes/SegmentShape2D.xml @@ -11,10 +11,10 @@ <methods> </methods> <members> - <member name="a" type="Vector2" setter="set_a" getter="get_a" default="Vector2( 0, 0 )"> + <member name="a" type="Vector2" setter="set_a" getter="get_a" default="Vector2(0, 0)"> The segment's first point position. </member> - <member name="b" type="Vector2" setter="set_b" getter="get_b" default="Vector2( 0, 10 )"> + <member name="b" type="Vector2" setter="set_b" getter="get_b" default="Vector2(0, 10)"> The segment's second point position. </member> </members> diff --git a/doc/classes/Signal.xml b/doc/classes/Signal.xml index 84efc974c0..1fd70a43fd 100644 --- a/doc/classes/Signal.xml +++ b/doc/classes/Signal.xml @@ -40,7 +40,7 @@ </return> <argument index="0" name="callable" type="Callable"> </argument> - <argument index="1" name="binds" type="Array" default="[ ]"> + <argument index="1" name="binds" type="Array" default="[]"> </argument> <argument index="2" name="flags" type="int" default="0"> </argument> diff --git a/doc/classes/Skeleton3D.xml b/doc/classes/Skeleton3D.xml index d8b35ad272..136f2f0a63 100644 --- a/doc/classes/Skeleton3D.xml +++ b/doc/classes/Skeleton3D.xml @@ -171,7 +171,7 @@ <method name="physical_bones_start_simulation"> <return type="void"> </return> - <argument index="0" name="bones" type="StringName[]" default="[ ]"> + <argument index="0" name="bones" type="StringName[]" default="[]"> </argument> <description> Tells the [PhysicalBone3D] nodes in the Skeleton to start simulating and reacting to the physics world. diff --git a/doc/classes/SkeletonIK3D.xml b/doc/classes/SkeletonIK3D.xml index dccc45d0ec..138ebe4411 100644 --- a/doc/classes/SkeletonIK3D.xml +++ b/doc/classes/SkeletonIK3D.xml @@ -38,7 +38,7 @@ <members> <member name="interpolation" type="float" setter="set_interpolation" getter="get_interpolation" default="1.0"> </member> - <member name="magnet" type="Vector3" setter="set_magnet_position" getter="get_magnet_position" default="Vector3( 0, 0, 0 )"> + <member name="magnet" type="Vector3" setter="set_magnet_position" getter="get_magnet_position" default="Vector3(0, 0, 0)"> </member> <member name="max_iterations" type="int" setter="set_max_iterations" getter="get_max_iterations" default="10"> </member> @@ -48,7 +48,7 @@ </member> <member name="root_bone" type="StringName" setter="set_root_bone" getter="get_root_bone" default="&"""> </member> - <member name="target" type="Transform3D" setter="set_target_transform" getter="get_target_transform" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )"> + <member name="target" type="Transform3D" setter="set_target_transform" getter="get_target_transform" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)"> </member> <member name="target_node" type="NodePath" setter="set_target_node" getter="get_target_node" default="NodePath("")"> </member> diff --git a/doc/classes/SkeletonModification2DJiggle.xml b/doc/classes/SkeletonModification2DJiggle.xml index 7f8cf2d4d9..ae46acd0d0 100644 --- a/doc/classes/SkeletonModification2DJiggle.xml +++ b/doc/classes/SkeletonModification2DJiggle.xml @@ -208,7 +208,7 @@ <member name="damping" type="float" setter="set_damping" getter="get_damping" default="0.75"> The default amount of dampening applied to the Jiggle joints, if they are not overriden. Higher values lead to more of the calculated velocity being applied. </member> - <member name="gravity" type="Vector2" setter="set_gravity" getter="get_gravity" default="Vector2( 0, 6 )"> + <member name="gravity" type="Vector2" setter="set_gravity" getter="get_gravity" default="Vector2(0, 6)"> The default amount of gravity applied to the Jiggle joints, if they are not overriden. </member> <member name="jiggle_data_chain_length" type="int" setter="set_jiggle_data_chain_length" getter="get_jiggle_data_chain_length" default="0"> diff --git a/doc/classes/SkeletonModification2DPhysicalBones.xml b/doc/classes/SkeletonModification2DPhysicalBones.xml index d8aaf09a8e..2547727097 100644 --- a/doc/classes/SkeletonModification2DPhysicalBones.xml +++ b/doc/classes/SkeletonModification2DPhysicalBones.xml @@ -40,7 +40,7 @@ <method name="start_simulation"> <return type="void"> </return> - <argument index="0" name="bones" type="StringName[]" default="[ ]"> + <argument index="0" name="bones" type="StringName[]" default="[]"> </argument> <description> Tell the [PhysicalBone2D] nodes to start simulating and interacting with the physics world. @@ -50,7 +50,7 @@ <method name="stop_simulation"> <return type="void"> </return> - <argument index="0" name="bones" type="StringName[]" default="[ ]"> + <argument index="0" name="bones" type="StringName[]" default="[]"> </argument> <description> Tell the [PhysicalBone2D] nodes to stop simulating and interacting with the physics world. diff --git a/doc/classes/Sprite2D.xml b/doc/classes/Sprite2D.xml index c320adb1be..b419b003bf 100644 --- a/doc/classes/Sprite2D.xml +++ b/doc/classes/Sprite2D.xml @@ -64,13 +64,13 @@ <member name="frame" type="int" setter="set_frame" getter="get_frame" default="0"> Current frame to display from sprite sheet. [member hframes] or [member vframes] must be greater than 1. </member> - <member name="frame_coords" type="Vector2i" setter="set_frame_coords" getter="get_frame_coords" default="Vector2i( 0, 0 )"> + <member name="frame_coords" type="Vector2i" setter="set_frame_coords" getter="get_frame_coords" default="Vector2i(0, 0)"> Coordinates of the frame to display from sprite sheet. This is as an alias for the [member frame] property. [member hframes] or [member vframes] must be greater than 1. </member> <member name="hframes" type="int" setter="set_hframes" getter="get_hframes" default="1"> The number of columns in the sprite sheet. </member> - <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2( 0, 0 )"> + <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2(0, 0)"> The texture's drawing offset. </member> <member name="region_enabled" type="bool" setter="set_region_enabled" getter="is_region_enabled" default="false"> @@ -79,7 +79,7 @@ <member name="region_filter_clip_enabled" type="bool" setter="set_region_filter_clip_enabled" getter="is_region_filter_clip_enabled" default="false"> If [code]true[/code], the outermost pixels get blurred out. [member region_enabled] must be [code]true[/code]. </member> - <member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2( 0, 0, 0, 0 )"> + <member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2(0, 0, 0, 0)"> The region of the atlas texture to display. [member region_enabled] must be [code]true[/code]. </member> <member name="texture" type="Texture2D" setter="set_texture" getter="get_texture"> diff --git a/doc/classes/Sprite3D.xml b/doc/classes/Sprite3D.xml index 8c4b9e7d10..f7f2ff0de1 100644 --- a/doc/classes/Sprite3D.xml +++ b/doc/classes/Sprite3D.xml @@ -14,7 +14,7 @@ <member name="frame" type="int" setter="set_frame" getter="get_frame" default="0"> Current frame to display from sprite sheet. [member hframes] or [member vframes] must be greater than 1. </member> - <member name="frame_coords" type="Vector2i" setter="set_frame_coords" getter="get_frame_coords" default="Vector2i( 0, 0 )"> + <member name="frame_coords" type="Vector2i" setter="set_frame_coords" getter="get_frame_coords" default="Vector2i(0, 0)"> Coordinates of the frame to display from sprite sheet. This is as an alias for the [member frame] property. [member hframes] or [member vframes] must be greater than 1. </member> <member name="hframes" type="int" setter="set_hframes" getter="get_hframes" default="1"> @@ -23,7 +23,7 @@ <member name="region_enabled" type="bool" setter="set_region_enabled" getter="is_region_enabled" default="false"> If [code]true[/code], texture will be cut from a larger atlas texture. See [member region_rect]. </member> - <member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2( 0, 0, 0, 0 )"> + <member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2(0, 0, 0, 0)"> The region of the atlas texture to display. [member region_enabled] must be [code]true[/code]. </member> <member name="texture" type="Texture2D" setter="set_texture" getter="get_texture"> diff --git a/doc/classes/SpriteBase3D.xml b/doc/classes/SpriteBase3D.xml index 06b9c2b042..3168e2d848 100644 --- a/doc/classes/SpriteBase3D.xml +++ b/doc/classes/SpriteBase3D.xml @@ -66,10 +66,10 @@ <member name="flip_v" type="bool" setter="set_flip_v" getter="is_flipped_v" default="false"> If [code]true[/code], texture is flipped vertically. </member> - <member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color( 1, 1, 1, 1 )"> + <member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color(1, 1, 1, 1)"> A color value that gets multiplied on, could be used for mood-coloring or to simulate the color of light. </member> - <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2( 0, 0 )"> + <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2(0, 0)"> The texture's drawing offset. </member> <member name="opacity" type="float" setter="set_opacity" getter="get_opacity" default="1.0"> diff --git a/doc/classes/StaticBody2D.xml b/doc/classes/StaticBody2D.xml index 298339d5fc..85915a53fe 100644 --- a/doc/classes/StaticBody2D.xml +++ b/doc/classes/StaticBody2D.xml @@ -18,7 +18,7 @@ <member name="constant_angular_velocity" type="float" setter="set_constant_angular_velocity" getter="get_constant_angular_velocity" default="0.0"> The body's constant angular velocity. This does not rotate the body (unless [member kinematic_motion] is enabled), but affects other bodies that touch it, as if it were rotating. </member> - <member name="constant_linear_velocity" type="Vector2" setter="set_constant_linear_velocity" getter="get_constant_linear_velocity" default="Vector2( 0, 0 )"> + <member name="constant_linear_velocity" type="Vector2" setter="set_constant_linear_velocity" getter="get_constant_linear_velocity" default="Vector2(0, 0)"> The body's constant linear velocity. This does not move the body (unless [member kinematic_motion] is enabled), but affects other bodies that touch it, as if it were moving. </member> <member name="kinematic_motion" type="bool" setter="set_kinematic_motion_enabled" getter="is_kinematic_motion_enabled" default="false"> diff --git a/doc/classes/StaticBody3D.xml b/doc/classes/StaticBody3D.xml index 5ffbb71522..f83d440f10 100644 --- a/doc/classes/StaticBody3D.xml +++ b/doc/classes/StaticBody3D.xml @@ -18,10 +18,10 @@ <methods> </methods> <members> - <member name="constant_angular_velocity" type="Vector3" setter="set_constant_angular_velocity" getter="get_constant_angular_velocity" default="Vector3( 0, 0, 0 )"> + <member name="constant_angular_velocity" type="Vector3" setter="set_constant_angular_velocity" getter="get_constant_angular_velocity" default="Vector3(0, 0, 0)"> The body's constant angular velocity. This does not rotate the body (unless [member kinematic_motion] is enabled), but affects other bodies that touch it, as if it were rotating. </member> - <member name="constant_linear_velocity" type="Vector3" setter="set_constant_linear_velocity" getter="get_constant_linear_velocity" default="Vector3( 0, 0, 0 )"> + <member name="constant_linear_velocity" type="Vector3" setter="set_constant_linear_velocity" getter="get_constant_linear_velocity" default="Vector3(0, 0, 0)"> The body's constant linear velocity. This does not move the body (unless [member kinematic_motion] is enabled), but affects other bodies that touch it, as if it were moving. </member> <member name="kinematic_motion" type="bool" setter="set_kinematic_motion_enabled" getter="is_kinematic_motion_enabled" default="false"> diff --git a/doc/classes/StreamPeerBuffer.xml b/doc/classes/StreamPeerBuffer.xml index 41cef9fb55..03a150b90f 100644 --- a/doc/classes/StreamPeerBuffer.xml +++ b/doc/classes/StreamPeerBuffer.xml @@ -49,7 +49,7 @@ </method> </methods> <members> - <member name="data_array" type="PackedByteArray" setter="set_data_array" getter="get_data_array" default="PackedByteArray( )"> + <member name="data_array" type="PackedByteArray" setter="set_data_array" getter="get_data_array" default="PackedByteArray()"> </member> </members> <constants> diff --git a/doc/classes/String.xml b/doc/classes/String.xml index d0c5f0ea86..3bf05e7c92 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -352,7 +352,7 @@ Returns [code]true[/code] if this string is a valid identifier. A valid identifier may contain only letters, digits and underscores ([code]_[/code]) and the first character may not be a digit. </description> </method> - <method name="is_valid_integer" qualifiers="const"> + <method name="is_valid_int" qualifiers="const"> <return type="bool"> </return> <description> diff --git a/doc/classes/StyleBoxFlat.xml b/doc/classes/StyleBoxFlat.xml index d66ae210ec..9e02fb57c3 100644 --- a/doc/classes/StyleBoxFlat.xml +++ b/doc/classes/StyleBoxFlat.xml @@ -156,13 +156,13 @@ <member name="anti_aliasing_size" type="int" setter="set_aa_size" getter="get_aa_size" default="1"> This changes the size of the faded ring. Higher values can be used to achieve a "blurry" effect. </member> - <member name="bg_color" type="Color" setter="set_bg_color" getter="get_bg_color" default="Color( 0.6, 0.6, 0.6, 1 )"> + <member name="bg_color" type="Color" setter="set_bg_color" getter="get_bg_color" default="Color(0.6, 0.6, 0.6, 1)"> The background color of the stylebox. </member> <member name="border_blend" type="bool" setter="set_border_blend" getter="get_border_blend" default="false"> If [code]true[/code], the border will fade into the background color. </member> - <member name="border_color" type="Color" setter="set_border_color" getter="get_border_color" default="Color( 0.8, 0.8, 0.8, 1 )"> + <member name="border_color" type="Color" setter="set_border_color" getter="get_border_color" default="Color(0.8, 0.8, 0.8, 1)"> Sets the color of the border. </member> <member name="border_width_bottom" type="int" setter="set_border_width" getter="get_border_width" default="0"> @@ -209,10 +209,10 @@ <member name="expand_margin_top" type="float" setter="set_expand_margin" getter="get_expand_margin" default="0.0"> Expands the stylebox outside of the control rect on the top edge. Useful in combination with [member border_width_top] to draw a border outside the control rect. </member> - <member name="shadow_color" type="Color" setter="set_shadow_color" getter="get_shadow_color" default="Color( 0, 0, 0, 0.6 )"> + <member name="shadow_color" type="Color" setter="set_shadow_color" getter="get_shadow_color" default="Color(0, 0, 0, 0.6)"> The color of the shadow. This has no effect if [member shadow_size] is lower than 1. </member> - <member name="shadow_offset" type="Vector2" setter="set_shadow_offset" getter="get_shadow_offset" default="Vector2( 0, 0 )"> + <member name="shadow_offset" type="Vector2" setter="set_shadow_offset" getter="get_shadow_offset" default="Vector2(0, 0)"> The shadow offset in pixels. Adjusts the position of the shadow relatively to the stylebox. </member> <member name="shadow_size" type="int" setter="set_shadow_size" getter="get_shadow_size" default="0"> diff --git a/doc/classes/StyleBoxLine.xml b/doc/classes/StyleBoxLine.xml index 4a2dbf60e4..850c656720 100644 --- a/doc/classes/StyleBoxLine.xml +++ b/doc/classes/StyleBoxLine.xml @@ -11,7 +11,7 @@ <methods> </methods> <members> - <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 0, 0, 0, 1 )"> + <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(0, 0, 0, 1)"> The line's color. </member> <member name="grow_begin" type="float" setter="set_grow_begin" getter="get_grow_begin" default="1.0"> diff --git a/doc/classes/StyleBoxTexture.xml b/doc/classes/StyleBoxTexture.xml index f4a1f1f01d..be14048126 100644 --- a/doc/classes/StyleBoxTexture.xml +++ b/doc/classes/StyleBoxTexture.xml @@ -116,10 +116,10 @@ A higher value means more of the source texture is considered to be part of the top border of the 3×3 box. This is also the value used as fallback for [member StyleBox.content_margin_top] if it is negative. </member> - <member name="modulate_color" type="Color" setter="set_modulate" getter="get_modulate" default="Color( 1, 1, 1, 1 )"> + <member name="modulate_color" type="Color" setter="set_modulate" getter="get_modulate" default="Color(1, 1, 1, 1)"> Modulates the color of the texture when this style box is drawn. </member> - <member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2( 0, 0, 0, 0 )"> + <member name="region_rect" type="Rect2" setter="set_region_rect" getter="get_region_rect" default="Rect2(0, 0, 0, 0)"> Species a sub-region of the texture to use. This is equivalent to first wrapping the texture in an [AtlasTexture] with the same region. </member> diff --git a/doc/classes/SubViewport.xml b/doc/classes/SubViewport.xml index f54f22d6fa..9c5610e2c7 100644 --- a/doc/classes/SubViewport.xml +++ b/doc/classes/SubViewport.xml @@ -25,10 +25,10 @@ <member name="render_target_update_mode" type="int" setter="set_update_mode" getter="get_update_mode" enum="SubViewport.UpdateMode" default="2"> The update mode when the sub-viewport is used as a render target. </member> - <member name="size" type="Vector2i" setter="set_size" getter="get_size" default="Vector2i( 512, 512 )"> + <member name="size" type="Vector2i" setter="set_size" getter="get_size" default="Vector2i(512, 512)"> The width and height of the sub-viewport. </member> - <member name="size_2d_override" type="Vector2i" setter="set_size_2d_override" getter="get_size_2d_override" default="Vector2i( 0, 0 )"> + <member name="size_2d_override" type="Vector2i" setter="set_size_2d_override" getter="get_size_2d_override" default="Vector2i(0, 0)"> The 2D size override of the sub-viewport. If either the width or height is [code]0[/code], the override is disabled. </member> <member name="size_2d_override_stretch" type="bool" setter="set_size_2d_override_stretch" getter="is_size_2d_override_stretch_enabled" default="false"> diff --git a/doc/classes/SurfaceTool.xml b/doc/classes/SurfaceTool.xml index 56b47f4a24..22d1b52479 100644 --- a/doc/classes/SurfaceTool.xml +++ b/doc/classes/SurfaceTool.xml @@ -45,15 +45,15 @@ </return> <argument index="0" name="vertices" type="PackedVector3Array"> </argument> - <argument index="1" name="uvs" type="PackedVector2Array" default="PackedVector2Array( )"> + <argument index="1" name="uvs" type="PackedVector2Array" default="PackedVector2Array()"> </argument> - <argument index="2" name="colors" type="PackedColorArray" default="PackedColorArray( )"> + <argument index="2" name="colors" type="PackedColorArray" default="PackedColorArray()"> </argument> - <argument index="3" name="uv2s" type="PackedVector2Array" default="PackedVector2Array( )"> + <argument index="3" name="uv2s" type="PackedVector2Array" default="PackedVector2Array()"> </argument> - <argument index="4" name="normals" type="PackedVector3Array" default="PackedVector3Array( )"> + <argument index="4" name="normals" type="PackedVector3Array" default="PackedVector3Array()"> </argument> - <argument index="5" name="tangents" type="Array" default="[ ]"> + <argument index="5" name="tangents" type="Array" default="[]"> </argument> <description> Inserts a triangle fan made of array data into [Mesh] being constructed. diff --git a/doc/classes/TabContainer.xml b/doc/classes/TabContainer.xml index ddf6b465a4..3f24509ec7 100644 --- a/doc/classes/TabContainer.xml +++ b/doc/classes/TabContainer.xml @@ -198,19 +198,19 @@ <theme_item name="font" type="Font"> The font used to draw tab names. </theme_item> - <theme_item name="font_disabled_color" type="Color" default="Color( 0.9, 0.9, 0.9, 0.2 )"> + <theme_item name="font_disabled_color" type="Color" default="Color(0.9, 0.9, 0.9, 0.2)"> Font color of disabled tabs. </theme_item> - <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)"> The tint of text outline of the tab name. </theme_item> - <theme_item name="font_selected_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )"> + <theme_item name="font_selected_color" type="Color" default="Color(0.94, 0.94, 0.94, 1)"> Font color of the currently selected tab. </theme_item> <theme_item name="font_size" type="int"> Font size of the tab names. </theme_item> - <theme_item name="font_unselected_color" type="Color" default="Color( 0.69, 0.69, 0.69, 1 )"> + <theme_item name="font_unselected_color" type="Color" default="Color(0.69, 0.69, 0.69, 1)"> Font color of the other, unselected tabs. </theme_item> <theme_item name="icon_separation" type="int" default="4"> diff --git a/doc/classes/Tabs.xml b/doc/classes/Tabs.xml index d784585e20..aff104c922 100644 --- a/doc/classes/Tabs.xml +++ b/doc/classes/Tabs.xml @@ -362,19 +362,19 @@ <theme_item name="font" type="Font"> The font used to draw tab names. </theme_item> - <theme_item name="font_disabled_color" type="Color" default="Color( 0.9, 0.9, 0.9, 0.2 )"> + <theme_item name="font_disabled_color" type="Color" default="Color(0.9, 0.9, 0.9, 0.2)"> Font color of disabled tabs. </theme_item> - <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)"> The tint of text outline of the tab name. </theme_item> - <theme_item name="font_selected_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )"> + <theme_item name="font_selected_color" type="Color" default="Color(0.94, 0.94, 0.94, 1)"> Font color of the currently selected tab. </theme_item> <theme_item name="font_size" type="int"> Font size of the tab names. </theme_item> - <theme_item name="font_unselected_color" type="Color" default="Color( 0.69, 0.69, 0.69, 1 )"> + <theme_item name="font_unselected_color" type="Color" default="Color(0.69, 0.69, 0.69, 1)"> Font color of the other, unselected tabs. </theme_item> <theme_item name="hseparation" type="int" default="4"> diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml index 2d6a052fe3..03e4556c92 100644 --- a/doc/classes/TextEdit.xml +++ b/doc/classes/TextEdit.xml @@ -692,7 +692,7 @@ <member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="Control.StructuredTextParser" default="0"> Set BiDi algorithm override for the structured text. </member> - <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[ ]"> + <member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]"> Set additional options for BiDi override. </member> <member name="syntax_highlighter" type="SyntaxHighlighter" setter="set_syntax_highlighter" getter="get_syntax_highlighter"> @@ -881,16 +881,16 @@ </constant> </constants> <theme_items> - <theme_item name="background_color" type="Color" default="Color( 0, 0, 0, 0 )"> + <theme_item name="background_color" type="Color" default="Color(0, 0, 0, 0)"> Sets the background [Color] of this [TextEdit]. </theme_item> - <theme_item name="brace_mismatch_color" type="Color" default="Color( 1, 0.2, 0.2, 1 )"> + <theme_item name="brace_mismatch_color" type="Color" default="Color(1, 0.2, 0.2, 1)"> </theme_item> - <theme_item name="caret_background_color" type="Color" default="Color( 0, 0, 0, 1 )"> + <theme_item name="caret_background_color" type="Color" default="Color(0, 0, 0, 1)"> </theme_item> - <theme_item name="caret_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )"> + <theme_item name="caret_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> </theme_item> - <theme_item name="current_line_color" type="Color" default="Color( 0.25, 0.25, 0.26, 0.8 )"> + <theme_item name="current_line_color" type="Color" default="Color(0.25, 0.25, 0.26, 0.8)"> Sets the [Color] of the breakpoints. [member breakpoint_gutter] has to be enabled. </theme_item> <theme_item name="focus" type="StyleBox"> @@ -898,15 +898,15 @@ <theme_item name="font" type="Font"> Sets the default [Font]. </theme_item> - <theme_item name="font_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )"> + <theme_item name="font_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> Sets the font [Color]. </theme_item> - <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)"> The tint of text outline of the [TextEdit]. </theme_item> - <theme_item name="font_readonly_color" type="Color" default="Color( 0.88, 0.88, 0.88, 0.5 )"> + <theme_item name="font_readonly_color" type="Color" default="Color(0.88, 0.88, 0.88, 0.5)"> </theme_item> - <theme_item name="font_selected_color" type="Color" default="Color( 0, 0, 0, 1 )"> + <theme_item name="font_selected_color" type="Color" default="Color(0, 0, 0, 1)"> Sets the [Color] of the selected text. [member override_selected_font_color] has to be enabled. </theme_item> <theme_item name="font_size" type="int"> @@ -924,7 +924,7 @@ <theme_item name="read_only" type="StyleBox"> Sets the [StyleBox] of this [TextEdit] when [member readonly] is enabled. </theme_item> - <theme_item name="selection_color" type="Color" default="Color( 0.49, 0.49, 0.49, 1 )"> + <theme_item name="selection_color" type="Color" default="Color(0.49, 0.49, 0.49, 1)"> Sets the highlight [Color] of text selections. </theme_item> <theme_item name="space" type="Texture2D"> @@ -933,7 +933,7 @@ <theme_item name="tab" type="Texture2D"> Sets a custom [Texture2D] for tab text characters. </theme_item> - <theme_item name="word_highlighted_color" type="Color" default="Color( 0.8, 0.9, 0.9, 0.15 )"> + <theme_item name="word_highlighted_color" type="Color" default="Color(0.8, 0.9, 0.9, 0.15)"> Sets the highlight [Color] of multiple occurrences. [member highlight_all_occurrences] has to be enabled. </theme_item> </theme_items> diff --git a/doc/classes/TextLine.xml b/doc/classes/TextLine.xml index ddbae0e977..318c3be794 100644 --- a/doc/classes/TextLine.xml +++ b/doc/classes/TextLine.xml @@ -56,7 +56,7 @@ </argument> <argument index="1" name="pos" type="Vector2"> </argument> - <argument index="2" name="color" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="2" name="color" type="Color" default="Color(1, 1, 1, 1)"> </argument> <description> Draw text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box. @@ -71,7 +71,7 @@ </argument> <argument index="2" name="outline_size" type="int" default="1"> </argument> - <argument index="3" name="color" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)"> </argument> <description> Draw text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box. diff --git a/doc/classes/TextParagraph.xml b/doc/classes/TextParagraph.xml index e9afe47ee8..d67a9bcb85 100644 --- a/doc/classes/TextParagraph.xml +++ b/doc/classes/TextParagraph.xml @@ -63,9 +63,9 @@ </argument> <argument index="1" name="pos" type="Vector2"> </argument> - <argument index="2" name="color" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="2" name="color" type="Color" default="Color(1, 1, 1, 1)"> </argument> - <argument index="3" name="dc_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="3" name="dc_color" type="Color" default="Color(1, 1, 1, 1)"> </argument> <description> Draw all lines of the text and drop cap into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box. @@ -78,7 +78,7 @@ </argument> <argument index="1" name="pos" type="Vector2"> </argument> - <argument index="2" name="color" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="2" name="color" type="Color" default="Color(1, 1, 1, 1)"> </argument> <description> Draw drop cap into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box. @@ -93,7 +93,7 @@ </argument> <argument index="2" name="outline_size" type="int" default="1"> </argument> - <argument index="3" name="color" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)"> </argument> <description> Draw drop cap outline into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box. @@ -108,7 +108,7 @@ </argument> <argument index="2" name="line" type="int"> </argument> - <argument index="3" name="color" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)"> </argument> <description> Draw single line of text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box. @@ -125,7 +125,7 @@ </argument> <argument index="3" name="outline_size" type="int" default="1"> </argument> - <argument index="4" name="color" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="4" name="color" type="Color" default="Color(1, 1, 1, 1)"> </argument> <description> Draw outline of the single line of text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box. @@ -140,9 +140,9 @@ </argument> <argument index="2" name="outline_size" type="int" default="1"> </argument> - <argument index="3" name="color" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="3" name="color" type="Color" default="Color(1, 1, 1, 1)"> </argument> - <argument index="4" name="dc_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="4" name="dc_color" type="Color" default="Color(1, 1, 1, 1)"> </argument> <description> Draw outlines of all lines of the text and drop cap into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the top left corner of the bounding box. @@ -344,7 +344,7 @@ </argument> <argument index="2" name="size" type="int"> </argument> - <argument index="3" name="dropcap_margins" type="Rect2" default="Rect2( 0, 0, 0, 0 )"> + <argument index="3" name="dropcap_margins" type="Rect2" default="Rect2(0, 0, 0, 0)"> </argument> <argument index="4" name="opentype_features" type="Dictionary" default="{ }"> diff --git a/doc/classes/TextServer.xml b/doc/classes/TextServer.xml index 9a96d8699c..c943946ab3 100644 --- a/doc/classes/TextServer.xml +++ b/doc/classes/TextServer.xml @@ -149,7 +149,7 @@ </argument> <argument index="4" name="index" type="int"> </argument> - <argument index="5" name="color" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="5" name="color" type="Color" default="Color(1, 1, 1, 1)"> </argument> <description> Draws single glyph into a canvas item at the position, using [code]font[/code] at the size [code]size[/code]. @@ -171,7 +171,7 @@ </argument> <argument index="5" name="index" type="int"> </argument> - <argument index="6" name="color" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="6" name="color" type="Color" default="Color(1, 1, 1, 1)"> </argument> <description> Draws single glyph outline of size [code]outline_size[/code] into a canvas item at the position, using [code]font[/code] at the size [code]size[/code]. @@ -788,7 +788,7 @@ </argument> <argument index="4" name="clip_r" type="float" default="-1"> </argument> - <argument index="5" name="color" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="5" name="color" type="Color" default="Color(1, 1, 1, 1)"> </argument> <description> Draw shaped text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the leftmost point of the baseline (for horizontal layout) or topmost point of the baseline (for vertical layout). @@ -809,7 +809,7 @@ </argument> <argument index="5" name="outline_size" type="int" default="1"> </argument> - <argument index="6" name="color" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="6" name="color" type="Color" default="Color(1, 1, 1, 1)"> </argument> <description> Draw the outline of the shaped text into a canvas item at a given position, with [code]color[/code]. [code]pos[/code] specifies the leftmost point of the baseline (for horizontal layout) or topmost point of the baseline (for vertical layout). diff --git a/doc/classes/Texture2D.xml b/doc/classes/Texture2D.xml index c33f32c9e4..35b719ae48 100644 --- a/doc/classes/Texture2D.xml +++ b/doc/classes/Texture2D.xml @@ -19,7 +19,7 @@ </argument> <argument index="1" name="position" type="Vector2"> </argument> - <argument index="2" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="2" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> </argument> <argument index="3" name="transpose" type="bool" default="false"> </argument> @@ -36,7 +36,7 @@ </argument> <argument index="2" name="tile" type="bool"> </argument> - <argument index="3" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> </argument> <argument index="4" name="transpose" type="bool" default="false"> </argument> @@ -53,7 +53,7 @@ </argument> <argument index="2" name="src_rect" type="Rect2"> </argument> - <argument index="3" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )"> + <argument index="3" name="modulate" type="Color" default="Color(1, 1, 1, 1)"> </argument> <argument index="4" name="transpose" type="bool" default="false"> </argument> diff --git a/doc/classes/TextureProgressBar.xml b/doc/classes/TextureProgressBar.xml index b40759578f..59cde536ad 100644 --- a/doc/classes/TextureProgressBar.xml +++ b/doc/classes/TextureProgressBar.xml @@ -36,7 +36,7 @@ <member name="nine_patch_stretch" type="bool" setter="set_nine_patch_stretch" getter="get_nine_patch_stretch" default="false"> If [code]true[/code], Godot treats the bar's textures like in [NinePatchRect]. Use the [code]stretch_margin_*[/code] properties like [member stretch_margin_bottom] to set up the nine patch's 3×3 grid. When using a radial [member fill_mode], this setting will enable stretching. </member> - <member name="radial_center_offset" type="Vector2" setter="set_radial_center_offset" getter="get_radial_center_offset" default="Vector2( 0, 0 )"> + <member name="radial_center_offset" type="Vector2" setter="set_radial_center_offset" getter="get_radial_center_offset" default="Vector2(0, 0)"> Offsets [member texture_progress] if [member fill_mode] is [constant FILL_CLOCKWISE] or [constant FILL_COUNTER_CLOCKWISE]. </member> <member name="radial_fill_degrees" type="float" setter="set_fill_degrees" getter="get_fill_degrees" default="360.0"> @@ -68,13 +68,13 @@ <member name="texture_under" type="Texture2D" setter="set_under_texture" getter="get_under_texture"> [Texture2D] that draws under the progress bar. The bar's background. </member> - <member name="tint_over" type="Color" setter="set_tint_over" getter="get_tint_over" default="Color( 1, 1, 1, 1 )"> + <member name="tint_over" type="Color" setter="set_tint_over" getter="get_tint_over" default="Color(1, 1, 1, 1)"> Multiplies the color of the bar's [code]texture_over[/code] texture. The effect is similar to [member CanvasItem.modulate], except it only affects this specific texture instead of the entire node. </member> - <member name="tint_progress" type="Color" setter="set_tint_progress" getter="get_tint_progress" default="Color( 1, 1, 1, 1 )"> + <member name="tint_progress" type="Color" setter="set_tint_progress" getter="get_tint_progress" default="Color(1, 1, 1, 1)"> Multiplies the color of the bar's [code]texture_progress[/code] texture. </member> - <member name="tint_under" type="Color" setter="set_tint_under" getter="get_tint_under" default="Color( 1, 1, 1, 1 )"> + <member name="tint_under" type="Color" setter="set_tint_under" getter="get_tint_under" default="Color(1, 1, 1, 1)"> Multiplies the color of the bar's [code]texture_under[/code] texture. </member> </members> diff --git a/doc/classes/TileData.xml b/doc/classes/TileData.xml index efcbdf2e95..1f0f807a08 100644 --- a/doc/classes/TileData.xml +++ b/doc/classes/TileData.xml @@ -219,13 +219,13 @@ </member> <member name="flip_v" type="bool" setter="set_flip_v" getter="get_flip_v" default="false"> </member> - <member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color( 1, 1, 1, 1 )"> + <member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color(1, 1, 1, 1)"> </member> <member name="probability" type="float" setter="set_probability" getter="get_probability" default="1.0"> </member> <member name="terrain_set" type="int" setter="set_terrain_set" getter="get_terrain_set" default="-1"> </member> - <member name="texture_offset" type="Vector2i" setter="set_texture_offset" getter="get_texture_offset" default="Vector2i( 0, 0 )"> + <member name="texture_offset" type="Vector2i" setter="set_texture_offset" getter="get_texture_offset" default="Vector2i(0, 0)"> </member> <member name="transpose" type="bool" setter="set_transpose" getter="get_transpose" default="false"> </member> diff --git a/doc/classes/TileMap.xml b/doc/classes/TileMap.xml index 93d5dd8037..5a4068ec86 100644 --- a/doc/classes/TileMap.xml +++ b/doc/classes/TileMap.xml @@ -103,7 +103,7 @@ </argument> <argument index="1" name="source_id" type="int" default="-1"> </argument> - <argument index="2" name="atlas_coords" type="Vector2i" default="Vector2i( -1, -1 )"> + <argument index="2" name="atlas_coords" type="Vector2i" default="Vector2i(-1, -1)"> </argument> <argument index="3" name="alternative_tile" type="int" default="-1"> </argument> diff --git a/doc/classes/TileSet.xml b/doc/classes/TileSet.xml index 2015b1f1cd..7d8b589f78 100644 --- a/doc/classes/TileSet.xml +++ b/doc/classes/TileSet.xml @@ -287,9 +287,9 @@ </member> <member name="tile_shape" type="int" setter="set_tile_shape" getter="get_tile_shape" enum="TileSet.TileShape" default="0"> </member> - <member name="tile_size" type="Vector2i" setter="set_tile_size" getter="get_tile_size" default="Vector2i( 16, 16 )"> + <member name="tile_size" type="Vector2i" setter="set_tile_size" getter="get_tile_size" default="Vector2i(16, 16)"> </member> - <member name="tile_skew" type="Vector2" setter="set_tile_skew" getter="get_tile_skew" default="Vector2( 0, 0 )"> + <member name="tile_skew" type="Vector2" setter="set_tile_skew" getter="get_tile_skew" default="Vector2(0, 0)"> </member> <member name="uv_clipping" type="bool" setter="set_uv_clipping" getter="is_uv_clipping" default="false"> </member> diff --git a/doc/classes/TileSetAtlasSource.xml b/doc/classes/TileSetAtlasSource.xml index a7a304ca27..8482c356d7 100644 --- a/doc/classes/TileSetAtlasSource.xml +++ b/doc/classes/TileSetAtlasSource.xml @@ -12,9 +12,9 @@ </return> <argument index="0" name="atlas_coords" type="Vector2i"> </argument> - <argument index="1" name="new_atlas_coords" type="Vector2i" default="Vector2i( -1, -1 )"> + <argument index="1" name="new_atlas_coords" type="Vector2i" default="Vector2i(-1, -1)"> </argument> - <argument index="2" name="new_size" type="Vector2i" default="Vector2i( -1, -1 )"> + <argument index="2" name="new_size" type="Vector2i" default="Vector2i(-1, -1)"> </argument> <description> </description> @@ -40,7 +40,7 @@ </return> <argument index="0" name="atlas_coords" type="Vector2i"> </argument> - <argument index="1" name="size" type="Vector2i" default="Vector2i( 1, 1 )"> + <argument index="1" name="size" type="Vector2i" default="Vector2i(1, 1)"> </argument> <description> </description> @@ -154,9 +154,9 @@ </return> <argument index="0" name="atlas_coords" type="Vector2i"> </argument> - <argument index="1" name="new_atlas_coords" type="Vector2i" default="Vector2i( -1, -1 )"> + <argument index="1" name="new_atlas_coords" type="Vector2i" default="Vector2i(-1, -1)"> </argument> - <argument index="2" name="new_size" type="Vector2i" default="Vector2i( -1, -1 )"> + <argument index="2" name="new_size" type="Vector2i" default="Vector2i(-1, -1)"> </argument> <description> </description> @@ -193,13 +193,13 @@ </method> </methods> <members> - <member name="margins" type="Vector2i" setter="set_margins" getter="get_margins" default="Vector2i( 0, 0 )"> + <member name="margins" type="Vector2i" setter="set_margins" getter="get_margins" default="Vector2i(0, 0)"> </member> - <member name="separation" type="Vector2i" setter="set_separation" getter="get_separation" default="Vector2i( 0, 0 )"> + <member name="separation" type="Vector2i" setter="set_separation" getter="get_separation" default="Vector2i(0, 0)"> </member> <member name="texture" type="Texture2D" setter="set_texture" getter="get_texture"> </member> - <member name="tile_size" type="Vector2i" setter="set_texture_region_size" getter="get_texture_region_size" default="Vector2i( 16, 16 )"> + <member name="tile_size" type="Vector2i" setter="set_texture_region_size" getter="get_texture_region_size" default="Vector2i(16, 16)"> </member> </members> <constants> diff --git a/doc/classes/Transform2D.xml b/doc/classes/Transform2D.xml index 0dbf95376a..4f9b59c188 100644 --- a/doc/classes/Transform2D.xml +++ b/doc/classes/Transform2D.xml @@ -132,7 +132,7 @@ <method name="looking_at" qualifiers="const"> <return type="Transform2D"> </return> - <argument index="0" name="target" type="Vector2" default="Transform2D( 1, 0, 0, 1, 0, 0 )"> + <argument index="0" name="target" type="Vector2" default="Transform2D(1, 0, 0, 1, 0, 0)"> </argument> <description> Returns a copy of the transform rotated such that it's rotation on the X-axis points towards the [code]target[/code] position. @@ -148,9 +148,17 @@ </description> </method> <method name="operator *" qualifiers="operator"> - <return type="PackedVector2Array"> + <return type="Vector2"> </return> - <argument index="0" name="right" type="PackedVector2Array"> + <argument index="0" name="right" type="Vector2"> + </argument> + <description> + </description> + </method> + <method name="operator *" qualifiers="operator"> + <return type="Rect2"> + </return> + <argument index="0" name="right" type="Rect2"> </argument> <description> </description> @@ -164,19 +172,29 @@ </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Rect2"> + <return type="PackedVector2Array"> </return> - <argument index="0" name="right" type="Rect2"> + <argument index="0" name="right" type="PackedVector2Array"> </argument> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector2"> + <return type="Transform2D"> </return> - <argument index="0" name="right" type="Vector2"> + <argument index="0" name="right" type="float"> + </argument> + <description> + This operator multiplies all components of the [Transform2D], including the origin vector, which scales it uniformly. + </description> + </method> + <method name="operator *" qualifiers="operator"> + <return type="Transform2D"> + </return> + <argument index="0" name="right" type="int"> </argument> <description> + This operator multiplies all components of the [Transform2D], including the origin vector, which scales it uniformly. </description> </method> <method name="operator ==" qualifiers="operator"> @@ -241,24 +259,24 @@ </method> </methods> <members> - <member name="origin" type="Vector2" setter="" getter="" default="Vector2( 0, 0 )"> + <member name="origin" type="Vector2" setter="" getter="" default="Vector2(0, 0)"> The origin vector (column 2, the third column). Equivalent to array index [code]2[/code]. The origin vector represents translation. </member> - <member name="x" type="Vector2" setter="" getter="" default="Vector2( 1, 0 )"> + <member name="x" type="Vector2" setter="" getter="" default="Vector2(1, 0)"> The basis matrix's X vector (column 0). Equivalent to array index [code]0[/code]. </member> - <member name="y" type="Vector2" setter="" getter="" default="Vector2( 0, 1 )"> + <member name="y" type="Vector2" setter="" getter="" default="Vector2(0, 1)"> The basis matrix's Y vector (column 1). Equivalent to array index [code]1[/code]. </member> </members> <constants> - <constant name="IDENTITY" value="Transform2D( 1, 0, 0, 1, 0, 0 )"> + <constant name="IDENTITY" value="Transform2D(1, 0, 0, 1, 0, 0)"> The identity [Transform2D] with no translation, rotation or scaling applied. When applied to other data structures, [constant IDENTITY] performs no transformation. </constant> - <constant name="FLIP_X" value="Transform2D( -1, 0, 0, 1, 0, 0 )"> + <constant name="FLIP_X" value="Transform2D(-1, 0, 0, 1, 0, 0)"> The [Transform2D] that will flip something along the X axis. </constant> - <constant name="FLIP_Y" value="Transform2D( 1, 0, 0, -1, 0, 0 )"> + <constant name="FLIP_Y" value="Transform2D(1, 0, 0, -1, 0, 0)"> The [Transform2D] that will flip something along the Y axis. </constant> </constants> diff --git a/doc/classes/Transform3D.xml b/doc/classes/Transform3D.xml index 0d49255523..5410cbced7 100644 --- a/doc/classes/Transform3D.xml +++ b/doc/classes/Transform3D.xml @@ -97,7 +97,7 @@ </return> <argument index="0" name="target" type="Vector3"> </argument> - <argument index="1" name="up" type="Vector3" default="Vector3( 0, 1, 0 )"> + <argument index="1" name="up" type="Vector3" default="Vector3(0, 1, 0)"> </argument> <description> Returns a copy of the transform rotated such that its -Z axis points towards the [code]target[/code] position. @@ -145,6 +145,24 @@ <description> </description> </method> + <method name="operator *" qualifiers="operator"> + <return type="Transform3D"> + </return> + <argument index="0" name="right" type="float"> + </argument> + <description> + This operator multiplies all components of the [Transform3D], including the origin vector, which scales it uniformly. + </description> + </method> + <method name="operator *" qualifiers="operator"> + <return type="Transform3D"> + </return> + <argument index="0" name="right" type="int"> + </argument> + <description> + This operator multiplies all components of the [Transform3D], including the origin vector, which scales it uniformly. + </description> + </method> <method name="operator ==" qualifiers="operator"> <return type="bool"> </return> @@ -192,24 +210,24 @@ </method> </methods> <members> - <member name="basis" type="Basis" setter="" getter="" default="Basis( 1, 0, 0, 0, 1, 0, 0, 0, 1 )"> + <member name="basis" type="Basis" setter="" getter="" default="Basis(1, 0, 0, 0, 1, 0, 0, 0, 1)"> The basis is a matrix containing 3 [Vector3] as its columns: X axis, Y axis, and Z axis. These vectors can be interpreted as the basis vectors of local coordinate system traveling with the object. </member> - <member name="origin" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )"> + <member name="origin" type="Vector3" setter="" getter="" default="Vector3(0, 0, 0)"> The translation offset of the transform (column 3, the fourth column). Equivalent to array index [code]3[/code]. </member> </members> <constants> - <constant name="IDENTITY" value="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )"> + <constant name="IDENTITY" value="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)"> [Transform3D] with no translation, rotation or scaling applied. When applied to other data structures, [constant IDENTITY] performs no transformation. </constant> - <constant name="FLIP_X" value="Transform3D( -1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )"> + <constant name="FLIP_X" value="Transform3D(-1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)"> [Transform3D] with mirroring applied perpendicular to the YZ plane. </constant> - <constant name="FLIP_Y" value="Transform3D( 1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0 )"> + <constant name="FLIP_Y" value="Transform3D(1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0)"> [Transform3D] with mirroring applied perpendicular to the XZ plane. </constant> - <constant name="FLIP_Z" value="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0 )"> + <constant name="FLIP_Z" value="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0)"> [Transform3D] with mirroring applied perpendicular to the XY plane. </constant> </constants> diff --git a/doc/classes/Tree.xml b/doc/classes/Tree.xml index fe83bf9c2d..6a65d4ff7d 100644 --- a/doc/classes/Tree.xml +++ b/doc/classes/Tree.xml @@ -533,7 +533,7 @@ <theme_item name="checked" type="Texture2D"> The check icon to display when the [constant TreeItem.CELL_MODE_CHECK] mode cell is checked. </theme_item> - <theme_item name="children_hl_line_color" type="Color" default="Color( 0.27, 0.27, 0.27, 1 )"> + <theme_item name="children_hl_line_color" type="Color" default="Color(0.27, 0.27, 0.27, 1)"> The [Color] of the relationship lines between the selected [TreeItem] and its children. </theme_item> <theme_item name="children_hl_line_width" type="int" default="1"> @@ -548,7 +548,7 @@ <theme_item name="custom_button" type="StyleBox"> Default [StyleBox] for a [constant TreeItem.CELL_MODE_CUSTOM] mode cell. </theme_item> - <theme_item name="custom_button_font_highlight" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )"> + <theme_item name="custom_button_font_highlight" type="Color" default="Color(0.94, 0.94, 0.94, 1)"> Text [Color] for a [constant TreeItem.CELL_MODE_CUSTOM] mode cell when it's hovered. </theme_item> <theme_item name="custom_button_hover" type="StyleBox"> @@ -563,25 +563,25 @@ <theme_item name="draw_relationship_lines" type="int" default="0"> Draws the relationship lines if not zero, this acts as a boolean. Relationship lines are drawn at the start of child items to show hierarchy. </theme_item> - <theme_item name="drop_position_color" type="Color" default="Color( 1, 0.3, 0.2, 1 )"> + <theme_item name="drop_position_color" type="Color" default="Color(1, 0.3, 0.2, 1)"> [Color] used to draw possible drop locations. See [enum DropModeFlags] constants for further description of drop locations. </theme_item> <theme_item name="font" type="Font"> [Font] of the item's text. </theme_item> - <theme_item name="font_color" type="Color" default="Color( 0.69, 0.69, 0.69, 1 )"> + <theme_item name="font_color" type="Color" default="Color(0.69, 0.69, 0.69, 1)"> Default text [Color] of the item. </theme_item> - <theme_item name="font_outline_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_outline_color" type="Color" default="Color(1, 1, 1, 1)"> The tint of text outline of the item. </theme_item> - <theme_item name="font_selected_color" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="font_selected_color" type="Color" default="Color(1, 1, 1, 1)"> Text [Color] used when the item is selected. </theme_item> <theme_item name="font_size" type="int"> Font size of the item's text. </theme_item> - <theme_item name="guide_color" type="Color" default="Color( 0, 0, 0, 0.1 )"> + <theme_item name="guide_color" type="Color" default="Color(0, 0, 0, 0.1)"> [Color] of the guideline. </theme_item> <theme_item name="hseparation" type="int" default="4"> @@ -593,7 +593,7 @@ <theme_item name="outline_size" type="int" default="0"> The size of the text outline. </theme_item> - <theme_item name="parent_hl_line_color" type="Color" default="Color( 0.27, 0.27, 0.27, 1 )"> + <theme_item name="parent_hl_line_color" type="Color" default="Color(0.27, 0.27, 0.27, 1)"> The [Color] of the relationship lines between the selected [TreeItem] and its parents. </theme_item> <theme_item name="parent_hl_line_margin" type="int" default="0"> @@ -602,7 +602,7 @@ <theme_item name="parent_hl_line_width" type="int" default="1"> The width of the relationship lines between the selected [TreeItem] and its parents. </theme_item> - <theme_item name="relationship_line_color" type="Color" default="Color( 0.27, 0.27, 0.27, 1 )"> + <theme_item name="relationship_line_color" type="Color" default="Color(0.27, 0.27, 0.27, 1)"> The default [Color] of the relationship lines. </theme_item> <theme_item name="relationship_line_width" type="int" default="1"> @@ -623,7 +623,7 @@ <theme_item name="selected_focus" type="StyleBox"> [StyleBox] for the selected items, used when the [Tree] is being focused. </theme_item> - <theme_item name="title_button_color" type="Color" default="Color( 0.88, 0.88, 0.88, 1 )"> + <theme_item name="title_button_color" type="Color" default="Color(0.88, 0.88, 0.88, 1)"> Default text [Color] of the title button. </theme_item> <theme_item name="title_button_font" type="Font"> diff --git a/doc/classes/Tween.xml b/doc/classes/Tween.xml index 00cca40093..ed193b9f7e 100644 --- a/doc/classes/Tween.xml +++ b/doc/classes/Tween.xml @@ -1,453 +1,398 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Tween" inherits="Node" version="4.0"> +<class name="Tween" inherits="RefCounted" version="4.0"> <brief_description> - Smoothly animates a node's properties over time. + Lightweight object used for general-purpose animation via script, using [Tweener]s. </brief_description> <description> - Tweens are useful for animations requiring a numerical property to be interpolated over a range of values. The name [i]tween[/i] comes from [i]in-betweening[/i], an animation technique where you specify [i]keyframes[/i] and the computer interpolates the frames that appear between them. - [Tween] is more suited than [AnimationPlayer] for animations where you don't know the final values in advance. For example, interpolating a dynamically-chosen camera zoom value is best done with a [Tween] node; it would be difficult to do the same thing with an [AnimationPlayer] node. - Here is a brief usage example that makes a 2D node move smoothly between two positions: - [codeblocks] - [gdscript] - var tween = get_node("Tween") - tween.interpolate_property($Node2D, "position", - Vector2(0, 0), Vector2(100, 100), 1, - Tween.TRANS_LINEAR, Tween.EASE_IN_OUT) - tween.start() - [/gdscript] - [csharp] - var tween = GetNode<Tween>("Tween"); - tween.InterpolateProperty(GetNode<Node2D>("Node2D"), "position", - new Vector2(0, 0), new Vector2(100, 100), 1, - Tween.TransitionType.Linear, Tween.EaseType.InOut); - tween.Start(); - [/csharp] - [/codeblocks] - Many methods require a property name, such as [code]"position"[/code] above. You can find the correct property name by hovering over the property in the Inspector. You can also provide the components of a property directly by using [code]"property:component"[/code] (e.g. [code]position:x[/code]), where it would only apply to that particular component. - Many of the methods accept [code]trans_type[/code] and [code]ease_type[/code]. The first accepts an [enum TransitionType] constant, and refers to the way the timing of the animation is handled (see [url=https://easings.net/]easings.net[/url] for some examples). The second accepts an [enum EaseType] constant, and controls where the [code]trans_type[/code] is applied to the interpolation (in the beginning, the end, or both). If you don't know which transition and easing to pick, you can try different [enum TransitionType] constants with [constant EASE_IN_OUT], and use the one that looks best. + Tweens are mostly useful for animations requiring a numerical property to be interpolated over a range of values. The name [i]tween[/i] comes from [i]in-betweening[/i], an animation technique where you specify [i]keyframes[/i] and the computer interpolates the frames that appear between them. + [Tween] is more suited than [AnimationPlayer] for animations where you don't know the final values in advance. For example, interpolating a dynamically-chosen camera zoom value is best done with a [Tween]; it would be difficult to do the same thing with an [AnimationPlayer] node. Tweens are also more light-weight than [AnimationPlayer], so they are very much suited for simple animations or general tasks that don't require visual tweaking provided by the editor. They can be used in a fire-and-forget manner for some logic that normally would be done by code. You can e.g. make something shoot periodically by using a looped [CallbackTweener] with a delay. + A [Tween] can be created by using either [method SceneTree.create_tween] or [method Node.create_tween]. [Tween]s created manually (i.e. by using [code]Tween.new()[/code]) are invalid. They can't be used for tweening values, but you can do manual interpolation with [method interpolate_value]. + A [Tween] animation is composed of a sequence of [Tweener]s, which by default are executed one after another. You can create a sequence by appending [Tweener]s to the [Tween]. Animating something with a [Tweener] is called tweening. Example tweening sequence looks like this: + [codeblock] + var tween = get_tree().create_tween() + tween.tween_property($Sprite, "modulate", Color.red, 1) + tween.tween_property($Sprite, "scale", Vector2(), 1) + tween.tween_callback($Sprite.queue_free) + [/codeblock] + This sequence will make the [code]$Sprite[/code] node turn red, then shrink and finally the [method Node.queue_free] is called to remove the sprite. See methods [method tween_property], [method tween_interval], [method tween_callback] and [method tween_method] for more usage information. + When a [Tweener] is created with one of the [code]tween_*[/code] methods, a chained method call can be used to tweak the properties of this [Tweener]. For example, if you want to set different transition type in the above example, you can do: + [codeblock] + var tween = get_tree().create_tween() + tween.tween_property($Sprite, "modulate", Color.red, 1).set_trans(Tween.TRANS_SINE) + tween.tween_property($Sprite, "scale", Vector2(), 1).set_trans(Tween.TRANS_BOUNCE) + tween.tween_callback($Sprite.queue_free) + [/codeblock] + Most of the [Tween] methods can be chained this way too. In this example the [Tween] is bound and have set a default transition: + [codeblock] + var tween = get_tree().create_tween().bind_node(self).set_trans(Tween.TRANS_ELASTIC) + tween.tween_property($Sprite, "modulate", Color.red, 1) + tween.tween_property($Sprite, "scale", Vector2(), 1) + tween.tween_callback($Sprite.queue_free) + [/codeblock] + Another interesting use for [Tween]s is animating arbitrary set of objects: + [codeblock] + var tween = create_tween() + for sprite in get_children(): + tween.tween_property(sprite, "position", Vector2(), 1) + [/codeblock] + In the example above, all children of a node are moved one after another to position (0, 0). + Some [Tweener]s use transitions and eases. The first accepts an [enum TransitionType] constant, and refers to the way the timing of the animation is handled (see [url=https://easings.net/]easings.net[/url] for some examples). The second accepts an [enum EaseType] constant, and controls where the [code]trans_type[/code] is applied to the interpolation (in the beginning, the end, or both). If you don't know which transition and easing to pick, you can try different [enum TransitionType] constants with [constant EASE_IN_OUT], and use the one that looks best. [url=https://raw.githubusercontent.com/godotengine/godot-docs/master/img/tween_cheatsheet.png]Tween easing and transition types cheatsheet[/url] + [b]Note:[/b] All [Tween]s will automatically start by default. To prevent a [Tween] from autostarting, you can call [method stop] immediately after it was created. </description> <tutorials> </tutorials> <methods> - <method name="follow_method"> - <return type="void"> + <method name="bind_node"> + <return type="Tween"> </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="method" type="StringName"> - </argument> - <argument index="2" name="initial_val" type="Variant"> - </argument> - <argument index="3" name="target" type="Object"> - </argument> - <argument index="4" name="target_method" type="StringName"> - </argument> - <argument index="5" name="duration" type="float"> - </argument> - <argument index="6" name="trans_type" type="int" enum="Tween.TransitionType" default="0"> - </argument> - <argument index="7" name="ease_type" type="int" enum="Tween.EaseType" default="2"> - </argument> - <argument index="8" name="delay" type="float" default="0"> + <argument index="0" name="node" type="Node"> </argument> <description> - Follows [code]method[/code] of [code]object[/code] and applies the returned value on [code]target_method[/code] of [code]target[/code], beginning from [code]initial_val[/code] for [code]duration[/code] seconds, [code]delay[/code] later. Methods are called with consecutive values. - Use [enum TransitionType] for [code]trans_type[/code] and [enum EaseType] for [code]ease_type[/code] parameters. These values control the timing and direction of the interpolation. See the class description for more information. + Binds this [Tween] with the given [code]node[/code]. [Tween]s are processed directly by the [SceneTree], so they run independently of the animated nodes. When you bind a [Node] with the [Tween], the [Tween] will halt the animation when the object is not inside tree and the [Tween] will be automatically killed when the bound object is freed. Also [constant TWEEN_PAUSE_BOUND] will make the pausing behavior dependent on the bound node. + For a shorter way to create and bind a [Tween], you can use [method Node.create_tween]. </description> </method> - <method name="follow_property"> - <return type="void"> + <method name="chain"> + <return type="Tween"> </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="property" type="NodePath"> - </argument> - <argument index="2" name="initial_val" type="Variant"> - </argument> - <argument index="3" name="target" type="Object"> - </argument> - <argument index="4" name="target_property" type="NodePath"> - </argument> - <argument index="5" name="duration" type="float"> - </argument> - <argument index="6" name="trans_type" type="int" enum="Tween.TransitionType" default="0"> - </argument> - <argument index="7" name="ease_type" type="int" enum="Tween.EaseType" default="2"> - </argument> - <argument index="8" name="delay" type="float" default="0"> - </argument> <description> - Follows [code]property[/code] of [code]object[/code] and applies it on [code]target_property[/code] of [code]target[/code], beginning from [code]initial_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. - Use [enum TransitionType] for [code]trans_type[/code] and [enum EaseType] for [code]ease_type[/code] parameters. These values control the timing and direction of the interpolation. See the class description for more information. + Used to chain two [Tweener]s after [method set_parallel] is called with [code]true[/code]. + [codeblock] + var tween = create_tween().set_parallel(true) + tween.tween_property(...) + tween.tween_property(...) #will run parallelly with above + tween.chain().tween_property(...) #will run after two above are finished + [/codeblock] </description> </method> - <method name="get_runtime" qualifiers="const"> - <return type="float"> + <method name="custom_step"> + <return type="bool"> </return> + <argument index="0" name="delta" type="float"> + </argument> <description> - Returns the total time needed for all tweens to end. If you have two tweens, one lasting 10 seconds and the other 20 seconds, it would return 20 seconds, as by that time all tweens would have finished. + Processes the [Tween] by given [code]delta[/code] value, in seconds. Mostly useful when the [Tween] is paused, for controlling it manually. + Returns [code]true[/code] if the [Tween] still has [Tweener]s that haven't finished. + [b]Note:[/b] The [Tween] will become invalid after finished, but you can call [method stop] after the step, to keep it and reset. + [b]Note:[/b] [method custom_step] will process only one step of the [Tween]. If the [code]delta[/code] is greater than the remaining time, the excessive time will not have any effect. </description> </method> - <method name="interpolate_callback"> - <return type="void"> + <method name="interpolate_value"> + <return type="Variant"> </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="duration" type="float"> + <argument index="0" name="trans_type" type="Variant"> </argument> - <argument index="2" name="callback" type="String"> + <argument index="1" name="ease_type" type="Variant"> </argument> - <argument index="3" name="arg1" type="Variant" default="null"> + <argument index="2" name="elapsed_time" type="float"> </argument> - <argument index="4" name="arg2" type="Variant" default="null"> + <argument index="3" name="initial_value" type="float"> </argument> - <argument index="5" name="arg3" type="Variant" default="null"> + <argument index="4" name="delta_value" type="int" enum="Tween.TransitionType"> </argument> - <argument index="6" name="arg4" type="Variant" default="null"> - </argument> - <argument index="7" name="arg5" type="Variant" default="null"> + <argument index="5" name="duration" type="int" enum="Tween.EaseType"> </argument> <description> - Calls [code]callback[/code] of [code]object[/code] after [code]duration[/code]. [code]arg1[/code]-[code]arg5[/code] are arguments to be passed to the callback. + This method can be used for manual interpolation of a value, when you don't want [Tween] to do animating for you. It's similar to [method @GlobalScope.lerp], but with support for custom transition and easing. + [code]elapsed_time[/code] is the time in seconds that passed after the interping started and it's used to control the position of the interpolation. E.g. when it's equal to half of the [code]duration[/code], the interpolated value will be halfway between initial and final values. This value can also be greater than [code]duration[/code] or lower than 0, which will extrapolate the value. + [code]initial_value[/code] is the starting value of the interpolation. + [code]delta_value[/code] is the change of the value in the interpolation, i.e. it's equal to [code]final_value - initial_value[/code]. + [code]duration[/code] is the total time of the interpolation. </description> </method> - <method name="interpolate_deferred_callback"> - <return type="void"> + <method name="is_running"> + <return type="bool"> </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="duration" type="float"> - </argument> - <argument index="2" name="callback" type="String"> - </argument> - <argument index="3" name="arg1" type="Variant" default="null"> - </argument> - <argument index="4" name="arg2" type="Variant" default="null"> - </argument> - <argument index="5" name="arg3" type="Variant" default="null"> - </argument> - <argument index="6" name="arg4" type="Variant" default="null"> - </argument> - <argument index="7" name="arg5" type="Variant" default="null"> - </argument> <description> - Calls [code]callback[/code] of [code]object[/code] after [code]duration[/code] on the main thread (similar to [method Object.call_deferred]). [code]arg1[/code]-[code]arg5[/code] are arguments to be passed to the callback. + Returns whether the [Tween] is currently running, i.e. it wasn't paused and it's not finished. </description> </method> - <method name="interpolate_method"> - <return type="void"> + <method name="is_valid"> + <return type="bool"> </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="method" type="StringName"> - </argument> - <argument index="2" name="initial_val" type="Variant"> - </argument> - <argument index="3" name="final_val" type="Variant"> - </argument> - <argument index="4" name="duration" type="float"> - </argument> - <argument index="5" name="trans_type" type="int" enum="Tween.TransitionType" default="0"> - </argument> - <argument index="6" name="ease_type" type="int" enum="Tween.EaseType" default="2"> - </argument> - <argument index="7" name="delay" type="float" default="0"> - </argument> <description> - Animates [code]method[/code] of [code]object[/code] from [code]initial_val[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. Methods are called with consecutive values. - Use [enum TransitionType] for [code]trans_type[/code] and [enum EaseType] for [code]ease_type[/code] parameters. These values control the timing and direction of the interpolation. See the class description for more information. + Returns whether the [Tween] is valid. A valid [Tween] is a [Tween] contained by the scene tree (i.e. the array from [method SceneTree.get_processed_tweens] will contain this [Tween]). [Tween] might become invalid when it has finished tweening or was killed, also when created with [code]Tween.new()[/code]. Invalid [Tween] can't have [Tweener]s appended, because it can't animate them. You can however still use [method interpolate_value]. </description> </method> - <method name="interpolate_property"> + <method name="kill"> <return type="void"> </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="property" type="NodePath"> - </argument> - <argument index="2" name="initial_val" type="Variant"> - </argument> - <argument index="3" name="final_val" type="Variant"> - </argument> - <argument index="4" name="duration" type="float"> - </argument> - <argument index="5" name="trans_type" type="int" enum="Tween.TransitionType" default="0"> - </argument> - <argument index="6" name="ease_type" type="int" enum="Tween.EaseType" default="2"> - </argument> - <argument index="7" name="delay" type="float" default="0"> - </argument> <description> - Animates [code]property[/code] of [code]object[/code] from [code]initial_val[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. Setting the initial value to [code]null[/code] uses the current value of the property. - Use [enum TransitionType] for [code]trans_type[/code] and [enum EaseType] for [code]ease_type[/code] parameters. These values control the timing and direction of the interpolation. See the class description for more information. + Aborts all tweening operations and invalidates the [Tween]. </description> </method> - <method name="is_active" qualifiers="const"> - <return type="bool"> + <method name="parallel"> + <return type="Tween"> </return> <description> - Returns [code]true[/code] if any tweens are currently running. - [b]Note:[/b] This method doesn't consider tweens that have ended. + Makes the next [Tweener] run parallely to the previous one. Example: + [codeblock] + var tween = create_tween() + tween.tween_property(...) + tween.parallel().tween_property(...) + tween.parallel().tween_property(...) + [/codeblock] + All [Tweener]s in the example will run at the same time. + You can make the [Tween] parallel by default by using [method set_parallel]. </description> </method> - <method name="remove"> + <method name="pause"> <return type="void"> </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="key" type="StringName" default=""""> - </argument> <description> - Stops animation and removes a tween, given its object and property/method pair. By default, all tweens are removed, unless [code]key[/code] is specified. + Pauses the tweening. The animation can be resumed by using [method play]. </description> </method> - <method name="remove_all"> + <method name="play"> <return type="void"> </return> <description> - Stops animation and removes all tweens. + Resumes a paused or stopped [Tween]. </description> </method> - <method name="reset"> - <return type="void"> + <method name="set_ease"> + <return type="Tween"> </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="key" type="StringName" default=""""> + <argument index="0" name="ease" type="int" enum="Tween.EaseType"> </argument> <description> - Resets a tween to its initial value (the one given, not the one before the tween), given its object and property/method pair. By default, all tweens are removed, unless [code]key[/code] is specified. + Sets the default ease type for [PropertyTweener]s and [MethodTweener]s animated by this [Tween]. </description> </method> - <method name="reset_all"> - <return type="void"> + <method name="set_loops"> + <return type="Tween"> </return> + <argument index="0" name="loops" type="int" default="0"> + </argument> <description> - Resets all tweens to their initial values (the ones given, not those before the tween). + Sets the number of times the tweening sequence will be repeated, i.e. [code]set_loops(2)[/code] will run the animation twice. + Calling this method without arguments will make the [Tween] run infinitely, until it is either killed by [method kill] or by freeing bound node, or all the animated objects have been freed (which makes further animation impossible). </description> </method> - <method name="resume"> - <return type="void"> + <method name="set_parallel"> + <return type="Tween"> </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="key" type="StringName" default=""""> + <argument index="0" name="parallel" type="bool" default="true"> </argument> <description> - Continues animating a stopped tween, given its object and property/method pair. By default, all tweens are resumed, unless [code]key[/code] is specified. + If [code]parallel[/code] is [code]true[/code], the [Tweener]s appended after this method will by default run simultanously, as opposed to sequentially. </description> </method> - <method name="resume_all"> - <return type="void"> + <method name="set_pause_mode"> + <return type="Tween"> </return> + <argument index="0" name="mode" type="int" enum="Tween.TweenPauseMode"> + </argument> <description> - Continues animating all stopped tweens. + Determines the behavior of the [Tween] when the [SceneTree] is paused. Check [enum TweenPauseMode] for options. + Default value is [constant TWEEN_PAUSE_BOUND]. </description> </method> - <method name="seek"> - <return type="void"> + <method name="set_process_mode"> + <return type="Tween"> </return> - <argument index="0" name="time" type="float"> + <argument index="0" name="mode" type="int" enum="Tween.TweenProcessMode"> </argument> <description> - Sets the interpolation to the given [code]time[/code] in seconds. + Determines whether the [Tween] should run during idle frame (see [method Node._process]) or physics frame (see [method Node._physics_process]. + Default value is [constant TWEEN_PROCESS_IDLE]. </description> </method> - <method name="set_active"> - <return type="void"> + <method name="set_speed_scale"> + <return type="Tween"> </return> - <argument index="0" name="active" type="bool"> + <argument index="0" name="speed" type="float"> </argument> <description> - Activates/deactivates the tween. See also [method stop_all] and [method resume_all]. + Scales the speed of tweening. This affects all [Tweener]s and their delays. </description> </method> - <method name="start"> - <return type="void"> + <method name="set_trans"> + <return type="Tween"> </return> + <argument index="0" name="trans" type="int" enum="Tween.TransitionType"> + </argument> <description> - Starts the tween. You can define animations both before and after this. + Sets the default transition type for [PropertyTweener]s and [MethodTweener]s animated by this [Tween]. </description> </method> <method name="stop"> <return type="void"> </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="key" type="StringName" default=""""> - </argument> <description> - Stops a tween, given its object and property/method pair. By default, all tweens are stopped, unless [code]key[/code] is specified. + Stops the tweening and resets the [Tween] to its initial state. This will not remove any appended [Tweener]s. </description> </method> - <method name="stop_all"> - <return type="void"> + <method name="tween_callback"> + <return type="CallbackTweener"> </return> + <argument index="0" name="callback" type="Callable"> + </argument> <description> - Stops animating all tweens. + Creates and appends a [CallbackTweener]. This method can be used to call an arbitrary method in any object. Use [method Callable.bind] to bind additional arguments for the call. + Example: object that keeps shooting every 1 second. + [codeblock] + var tween = get_tree().create_tween().set_loops() + tween.tween_callback(shoot).set_delay(1) + [/codeblock] + Example: turning a sprite red and then blue, with 2 second delay. + [codeblock] + var tween = get_tree().create_tween() + tween.tween_callback($Sprite.set_modulate.bind(Color.red)).set_delay(2) + tween.tween_callback($Sprite.set_modulate.bind(Color.blue)).set_delay(2) + [/codeblock] </description> </method> - <method name="targeting_method"> - <return type="void"> + <method name="tween_interval"> + <return type="IntervalTweener"> </return> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="method" type="StringName"> - </argument> - <argument index="2" name="initial" type="Object"> - </argument> - <argument index="3" name="initial_method" type="StringName"> - </argument> - <argument index="4" name="final_val" type="Variant"> + <argument index="0" name="time" type="float"> </argument> - <argument index="5" name="duration" type="float"> + <description> + Creates and appends an [IntervalTweener]. This method can be used to create delays in the tween animation, as an alternative for using the delay in other [Tweener]s or when there's no animation (in which case the [Tween] acts as a timer). [code]time[/code] is the length of the interval, in seconds. + Example: creating an interval in code execution. + [codeblock] + #... some code + var tween = create_tween() + tween.tween_interval(2) + await tween.finished + #... more code + [/codeblock] + Example: creating an object that moves back and forth and jumps every few seconds. + [codeblock] + var tween = create_tween().set_loops() + tween.tween_property("position:x", 200, 1).as_relative() + tween.tween_callback(jump) + tween.tween_interval(2) + tween.tween_property("position:x", -200, 1).as_relative() + tween.tween_callback(jump) + tween.tween_interval(2) + [/codeblock] + </description> + </method> + <method name="tween_method"> + <return type="MethodTweener"> + </return> + <argument index="0" name="method" type="Callable"> </argument> - <argument index="6" name="trans_type" type="int" enum="Tween.TransitionType" default="0"> + <argument index="1" name="from" type="float"> </argument> - <argument index="7" name="ease_type" type="int" enum="Tween.EaseType" default="2"> + <argument index="2" name="to" type="float"> </argument> - <argument index="8" name="delay" type="float" default="0"> + <argument index="3" name="duration" type="float"> </argument> <description> - Animates [code]method[/code] of [code]object[/code] from the value returned by [code]initial_method[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. Methods are animated by calling them with consecutive values. - Use [enum TransitionType] for [code]trans_type[/code] and [enum EaseType] for [code]ease_type[/code] parameters. These values control the timing and direction of the interpolation. See the class description for more information. + Creates and appends a [MethodTweener]. This method is similar to a combination of [method tween_callback] and [method tween_property]. It calls a method over time with a tweened value provided as an argument. The value is tweened between [code]from[/code] and [code]to[/code] over the time specified by [code]duration[/code], in seconds. Use [method Callable.bind] to bind additional arguments for the call. You can use [method MethodTweener.set_ease] and [method MethodTweener.set_trans] to tweak the easing and transition of the value or [method MethodTweener.set_delay] to delay the tweening. + Example: making a 3D object look from one point to another point. + [codeblock] + var tween = create_tween() + tween.tween_method(look_at.bind(Vector3.UP), Vector3(-1, 0, -1), Vector3(1, 0, -1), 1) #the look_at() method takes up vector as second argument + [/codeblock] + Example: setting a text of a [Label], using an intermediate method and after a delay. + [codeblock] + func _ready(): + var tween = create_tween() + tween.tween_method(set_label_text, 0, 10, 1).set_delay(1) + + func set_label_text(value: int): + $Label.text = "Counting " + str(value) + [/codeblock] </description> </method> - <method name="targeting_property"> - <return type="void"> + <method name="tween_property"> + <return type="PropertyTweener"> </return> <argument index="0" name="object" type="Object"> </argument> <argument index="1" name="property" type="NodePath"> </argument> - <argument index="2" name="initial" type="Object"> - </argument> - <argument index="3" name="initial_val" type="NodePath"> - </argument> - <argument index="4" name="final_val" type="Variant"> + <argument index="2" name="final_val" type="Variant"> </argument> - <argument index="5" name="duration" type="float"> + <argument index="3" name="duration" type="float"> </argument> - <argument index="6" name="trans_type" type="int" enum="Tween.TransitionType" default="0"> - </argument> - <argument index="7" name="ease_type" type="int" enum="Tween.EaseType" default="2"> - </argument> - <argument index="8" name="delay" type="float" default="0"> - </argument> - <description> - Animates [code]property[/code] of [code]object[/code] from the current value of the [code]initial_val[/code] property of [code]initial[/code] to [code]final_val[/code] for [code]duration[/code] seconds, [code]delay[/code] seconds later. - Use [enum TransitionType] for [code]trans_type[/code] and [enum EaseType] for [code]ease_type[/code] parameters. These values control the timing and direction of the interpolation. See the class description for more information. - </description> - </method> - <method name="tell" qualifiers="const"> - <return type="float"> - </return> <description> - Returns the current time of the tween. + Creates and appends a [PropertyTweener]. This method tweens a [code]property[/code] of an [code]object[/code] between an initial value and [code]final_val[/code] in a span of time equal to [code]duration[/code], in seconds. The initial value by default is a value at the time the tweening of the [PropertyTweener] start. For example: + [codeblock] + var tween = create_tween() + tween.tween_property($Sprite, "position", Vector2(100, 200) + tween.tween_property($Sprite, "position", Vector2(200, 300) + [/codeblock] + will move the sprite to position (100, 200) and then to (200, 300). If you use [method PropertyTweener.from] or [method PropertyTweener.from_current], the starting position will be overwritten by the given value instead. See other methods in [PropertyTweener] to see how the tweening can be tweaked further. + [b]Note:[/b] You can find the correct property name by hovering over the property in the Inspector. You can also provide the components of a property directly by using [code]"property:component"[/code] (eg. [code]position:x[/code]), where it would only apply to that particular component. + Example: moving object twice from the same position, with different transition types. + [codeblock] + var tween = create_tween() + tween.tween_property($Sprite, "position", Vector2.RIGHT * 300).as_relative().set_trans(Tween.TRANS_SINE) + tween.tween_property($Sprite, "position", Vector2.RIGHT * 300).as_relative().from_current().set_trans(Tween.TRANS_EXPO) + [/codeblock] </description> </method> </methods> - <members> - <member name="playback_process_mode" type="int" setter="set_tween_process_mode" getter="get_tween_process_mode" enum="Tween.TweenProcessMode" default="1"> - The tween's animation process thread. See [enum TweenProcessMode]. - </member> - <member name="playback_speed" type="float" setter="set_speed_scale" getter="get_speed_scale" default="1.0"> - The tween's speed multiplier. For example, set it to [code]1.0[/code] for normal speed, [code]2.0[/code] for two times normal speed, or [code]0.5[/code] for half of the normal speed. A value of [code]0[/code] pauses the animation, but see also [method set_active] or [method stop_all] for this. - </member> - <member name="repeat" type="bool" setter="set_repeat" getter="is_repeat" default="false"> - If [code]true[/code], the tween loops. - </member> - </members> <signals> - <signal name="tween_all_completed"> + <signal name="finished"> <description> - Emitted when all processes in a tween end. + Emitted when the [Tween] has finished all tweening. Never emitted when the [Tween] is set to infinite looping (see [method set_loops]). + [b]Note:[/b] The [Tween] is removed (invalidated) after this signal is emitted, but it doesn't happen immediately, but on the next processing frame. Calling [method stop] inside the signal callback will preserve the [Tween]. </description> </signal> - <signal name="tween_completed"> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="key" type="NodePath"> + <signal name="loop_finished"> + <argument index="0" name="loop_count" type="int"> </argument> <description> - Emitted when a tween ends. + Emitted when a full loop is complete (see [method set_loops]), providing the loop index. This signal is not emitted after final loop, use [signal finished] instead for this case. </description> </signal> - <signal name="tween_started"> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="key" type="NodePath"> + <signal name="step_finished"> + <argument index="0" name="idx" type="int"> </argument> <description> - Emitted when a tween starts. - </description> - </signal> - <signal name="tween_step"> - <argument index="0" name="object" type="Object"> - </argument> - <argument index="1" name="key" type="NodePath"> - </argument> - <argument index="2" name="elapsed" type="float"> - </argument> - <argument index="3" name="value" type="Object"> - </argument> - <description> - Emitted at each step of the animation. + Emitted when one step of the [Tween] is complete, providing the step index. One step is either a single [Tweener] or a group of [Tweener]s running parallelly. </description> </signal> </signals> <constants> <constant name="TWEEN_PROCESS_PHYSICS" value="0" enum="TweenProcessMode"> - The tween updates with the [code]_physics_process[/code] callback. + The [Tween] updates during physics frame. </constant> <constant name="TWEEN_PROCESS_IDLE" value="1" enum="TweenProcessMode"> - The tween updates with the [code]_process[/code] callback. + The [Tween] updates during idle + </constant> + <constant name="TWEEN_PAUSE_BOUND" value="0" enum="TweenPauseMode"> + </constant> + <constant name="TWEEN_PAUSE_STOP" value="1" enum="TweenPauseMode"> + </constant> + <constant name="TWEEN_PAUSE_PROCESS" value="2" enum="TweenPauseMode"> </constant> <constant name="TRANS_LINEAR" value="0" enum="TransitionType"> - The animation is interpolated linearly. </constant> <constant name="TRANS_SINE" value="1" enum="TransitionType"> - The animation is interpolated using a sine function. </constant> <constant name="TRANS_QUINT" value="2" enum="TransitionType"> - The animation is interpolated with a quintic (to the power of 5) function. </constant> <constant name="TRANS_QUART" value="3" enum="TransitionType"> - The animation is interpolated with a quartic (to the power of 4) function. </constant> <constant name="TRANS_QUAD" value="4" enum="TransitionType"> - The animation is interpolated with a quadratic (to the power of 2) function. </constant> <constant name="TRANS_EXPO" value="5" enum="TransitionType"> - The animation is interpolated with an exponential (to the power of x) function. </constant> <constant name="TRANS_ELASTIC" value="6" enum="TransitionType"> - The animation is interpolated with elasticity, wiggling around the edges. </constant> <constant name="TRANS_CUBIC" value="7" enum="TransitionType"> - The animation is interpolated with a cubic (to the power of 3) function. </constant> <constant name="TRANS_CIRC" value="8" enum="TransitionType"> - The animation is interpolated with a function using square roots. </constant> <constant name="TRANS_BOUNCE" value="9" enum="TransitionType"> - The animation is interpolated by bouncing at the end. </constant> <constant name="TRANS_BACK" value="10" enum="TransitionType"> - The animation is interpolated backing out at ends. </constant> <constant name="EASE_IN" value="0" enum="EaseType"> - The interpolation starts slowly and speeds up towards the end. </constant> <constant name="EASE_OUT" value="1" enum="EaseType"> - The interpolation starts quickly and slows down towards the end. </constant> <constant name="EASE_IN_OUT" value="2" enum="EaseType"> - A combination of [constant EASE_IN] and [constant EASE_OUT]. The interpolation is slowest at both ends. </constant> <constant name="EASE_OUT_IN" value="3" enum="EaseType"> - A combination of [constant EASE_IN] and [constant EASE_OUT]. The interpolation is fastest at both ends. </constant> </constants> </class> diff --git a/doc/classes/Tweener.xml b/doc/classes/Tweener.xml new file mode 100644 index 0000000000..5cd502ced9 --- /dev/null +++ b/doc/classes/Tweener.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="Tweener" inherits="RefCounted" version="4.0"> + <brief_description> + Abstract class for all Tweeners used by [Tween]. + </brief_description> + <description> + Tweeners are objects that perform a specific animating task, e.g. interpolating a property or calling a method at a given time. A [Tweener] can't be created manually, you need to use a dedicated method from [Tween] or [Node]. + </description> + <tutorials> + </tutorials> + <methods> + </methods> + <signals> + <signal name="finished"> + <description> + Emited when the [Tweener] has just finished its job. + </description> + </signal> + </signals> + <constants> + </constants> +</class> diff --git a/doc/classes/Vector2.xml b/doc/classes/Vector2.xml index 1390a5e45b..07d09c31dc 100644 --- a/doc/classes/Vector2.xml +++ b/doc/classes/Vector2.xml @@ -513,25 +513,25 @@ <constant name="AXIS_Y" value="1"> Enumerated value for the Y axis. </constant> - <constant name="ZERO" value="Vector2( 0, 0 )"> + <constant name="ZERO" value="Vector2(0, 0)"> Zero vector, a vector with all components set to [code]0[/code]. </constant> - <constant name="ONE" value="Vector2( 1, 1 )"> + <constant name="ONE" value="Vector2(1, 1)"> One vector, a vector with all components set to [code]1[/code]. </constant> - <constant name="INF" value="Vector2( inf, inf )"> + <constant name="INF" value="Vector2(inf, inf)"> Infinity vector, a vector with all components set to [constant @GDScript.INF]. </constant> - <constant name="LEFT" value="Vector2( -1, 0 )"> + <constant name="LEFT" value="Vector2(-1, 0)"> Left unit vector. Represents the direction of left. </constant> - <constant name="RIGHT" value="Vector2( 1, 0 )"> + <constant name="RIGHT" value="Vector2(1, 0)"> Right unit vector. Represents the direction of right. </constant> - <constant name="UP" value="Vector2( 0, -1 )"> + <constant name="UP" value="Vector2(0, -1)"> Up unit vector. Y is down in 2D, so this vector points -Y. </constant> - <constant name="DOWN" value="Vector2( 0, 1 )"> + <constant name="DOWN" value="Vector2(0, 1)"> Down unit vector. Y is down in 2D, so this vector points +Y. </constant> </constants> diff --git a/doc/classes/Vector2i.xml b/doc/classes/Vector2i.xml index 6efb52b712..930ec944ba 100644 --- a/doc/classes/Vector2i.xml +++ b/doc/classes/Vector2i.xml @@ -246,22 +246,22 @@ <constant name="AXIS_Y" value="1"> Enumerated value for the Y axis. </constant> - <constant name="ZERO" value="Vector2i( 0, 0 )"> + <constant name="ZERO" value="Vector2i(0, 0)"> Zero vector, a vector with all components set to [code]0[/code]. </constant> - <constant name="ONE" value="Vector2i( 1, 1 )"> + <constant name="ONE" value="Vector2i(1, 1)"> One vector, a vector with all components set to [code]1[/code]. </constant> - <constant name="LEFT" value="Vector2i( -1, 0 )"> + <constant name="LEFT" value="Vector2i(-1, 0)"> Left unit vector. Represents the direction of left. </constant> - <constant name="RIGHT" value="Vector2i( 1, 0 )"> + <constant name="RIGHT" value="Vector2i(1, 0)"> Right unit vector. Represents the direction of right. </constant> - <constant name="UP" value="Vector2i( 0, -1 )"> + <constant name="UP" value="Vector2i(0, -1)"> Up unit vector. Y is down in 2D, so this vector points -Y. </constant> - <constant name="DOWN" value="Vector2i( 0, 1 )"> + <constant name="DOWN" value="Vector2i(0, 1)"> Down unit vector. Y is down in 2D, so this vector points +Y. </constant> </constants> diff --git a/doc/classes/Vector3.xml b/doc/classes/Vector3.xml index b6effd441b..eb1fd5f098 100644 --- a/doc/classes/Vector3.xml +++ b/doc/classes/Vector3.xml @@ -173,7 +173,7 @@ <return type="Vector3"> </return> <description> - Returns the inverse of the vector. This is the same as [code]Vector3( 1.0 / v.x, 1.0 / v.y, 1.0 / v.z )[/code]. + Returns the inverse of the vector. This is the same as [code]Vector3(1.0 / v.x, 1.0 / v.y, 1.0 / v.z)[/code]. </description> </method> <method name="is_equal_approx" qualifiers="const"> @@ -556,31 +556,31 @@ <constant name="AXIS_Z" value="2"> Enumerated value for the Z axis. Returned by [method max_axis] and [method min_axis]. </constant> - <constant name="ZERO" value="Vector3( 0, 0, 0 )"> + <constant name="ZERO" value="Vector3(0, 0, 0)"> Zero vector, a vector with all components set to [code]0[/code]. </constant> - <constant name="ONE" value="Vector3( 1, 1, 1 )"> + <constant name="ONE" value="Vector3(1, 1, 1)"> One vector, a vector with all components set to [code]1[/code]. </constant> - <constant name="INF" value="Vector3( inf, inf, inf )"> + <constant name="INF" value="Vector3(inf, inf, inf)"> Infinity vector, a vector with all components set to [constant @GDScript.INF]. </constant> - <constant name="LEFT" value="Vector3( -1, 0, 0 )"> + <constant name="LEFT" value="Vector3(-1, 0, 0)"> Left unit vector. Represents the local direction of left, and the global direction of west. </constant> - <constant name="RIGHT" value="Vector3( 1, 0, 0 )"> + <constant name="RIGHT" value="Vector3(1, 0, 0)"> Right unit vector. Represents the local direction of right, and the global direction of east. </constant> - <constant name="UP" value="Vector3( 0, 1, 0 )"> + <constant name="UP" value="Vector3(0, 1, 0)"> Up unit vector. </constant> - <constant name="DOWN" value="Vector3( 0, -1, 0 )"> + <constant name="DOWN" value="Vector3(0, -1, 0)"> Down unit vector. </constant> - <constant name="FORWARD" value="Vector3( 0, 0, -1 )"> + <constant name="FORWARD" value="Vector3(0, 0, -1)"> Forward unit vector. Represents the local direction of forward, and the global direction of north. </constant> - <constant name="BACK" value="Vector3( 0, 0, 1 )"> + <constant name="BACK" value="Vector3(0, 0, 1)"> Back unit vector. Represents the local direction of back, and the global direction of south. </constant> </constants> diff --git a/doc/classes/Vector3i.xml b/doc/classes/Vector3i.xml index 6e8a34b692..8b45a62afa 100644 --- a/doc/classes/Vector3i.xml +++ b/doc/classes/Vector3i.xml @@ -260,28 +260,28 @@ <constant name="AXIS_Z" value="2"> Enumerated value for the Z axis. </constant> - <constant name="ZERO" value="Vector3i( 0, 0, 0 )"> + <constant name="ZERO" value="Vector3i(0, 0, 0)"> Zero vector, a vector with all components set to [code]0[/code]. </constant> - <constant name="ONE" value="Vector3i( 1, 1, 1 )"> + <constant name="ONE" value="Vector3i(1, 1, 1)"> One vector, a vector with all components set to [code]1[/code]. </constant> - <constant name="LEFT" value="Vector3i( -1, 0, 0 )"> + <constant name="LEFT" value="Vector3i(-1, 0, 0)"> Left unit vector. Represents the local direction of left, and the global direction of west. </constant> - <constant name="RIGHT" value="Vector3i( 1, 0, 0 )"> + <constant name="RIGHT" value="Vector3i(1, 0, 0)"> Right unit vector. Represents the local direction of right, and the global direction of east. </constant> - <constant name="UP" value="Vector3i( 0, 1, 0 )"> + <constant name="UP" value="Vector3i(0, 1, 0)"> Up unit vector. </constant> - <constant name="DOWN" value="Vector3i( 0, -1, 0 )"> + <constant name="DOWN" value="Vector3i(0, -1, 0)"> Down unit vector. </constant> - <constant name="FORWARD" value="Vector3i( 0, 0, -1 )"> + <constant name="FORWARD" value="Vector3i(0, 0, -1)"> Forward unit vector. Represents the local direction of forward, and the global direction of north. </constant> - <constant name="BACK" value="Vector3i( 0, 0, 1 )"> + <constant name="BACK" value="Vector3i(0, 0, 1)"> Back unit vector. Represents the local direction of back, and the global direction of south. </constant> </constants> diff --git a/doc/classes/VisibleOnScreenNotifier2D.xml b/doc/classes/VisibleOnScreenNotifier2D.xml index f2f3bc9144..daad200ca8 100644 --- a/doc/classes/VisibleOnScreenNotifier2D.xml +++ b/doc/classes/VisibleOnScreenNotifier2D.xml @@ -21,7 +21,7 @@ </method> </methods> <members> - <member name="rect" type="Rect2" setter="set_rect" getter="get_rect" default="Rect2( -10, -10, 20, 20 )"> + <member name="rect" type="Rect2" setter="set_rect" getter="get_rect" default="Rect2(-10, -10, 20, 20)"> The VisibleOnScreenNotifier2D's bounding rectangle. </member> </members> diff --git a/doc/classes/VisibleOnScreenNotifier3D.xml b/doc/classes/VisibleOnScreenNotifier3D.xml index 859dacd716..85ff324fbf 100644 --- a/doc/classes/VisibleOnScreenNotifier3D.xml +++ b/doc/classes/VisibleOnScreenNotifier3D.xml @@ -21,7 +21,7 @@ </method> </methods> <members> - <member name="aabb" type="AABB" setter="set_aabb" getter="get_aabb" default="AABB( -1, -1, -1, 2, 2, 2 )"> + <member name="aabb" type="AABB" setter="set_aabb" getter="get_aabb" default="AABB(-1, -1, -1, 2, 2, 2)"> The VisibleOnScreenNotifier3D's bounding box. </member> </members> diff --git a/doc/classes/VisualShader.xml b/doc/classes/VisualShader.xml index 775ac88eff..19b4acd8f1 100644 --- a/doc/classes/VisualShader.xml +++ b/doc/classes/VisualShader.xml @@ -206,7 +206,7 @@ </method> </methods> <members> - <member name="graph_offset" type="Vector2" setter="set_graph_offset" getter="get_graph_offset" default="Vector2( 0, 0 )"> + <member name="graph_offset" type="Vector2" setter="set_graph_offset" getter="get_graph_offset" default="Vector2(0, 0)"> The offset vector of the whole graph. </member> <member name="version" type="String" setter="set_version" getter="get_version" default=""""> diff --git a/doc/classes/VisualShaderNodeColorConstant.xml b/doc/classes/VisualShaderNodeColorConstant.xml index 8644013ef2..fa1a11c488 100644 --- a/doc/classes/VisualShaderNodeColorConstant.xml +++ b/doc/classes/VisualShaderNodeColorConstant.xml @@ -12,7 +12,7 @@ <methods> </methods> <members> - <member name="constant" type="Color" setter="set_constant" getter="get_constant" default="Color( 1, 1, 1, 1 )"> + <member name="constant" type="Color" setter="set_constant" getter="get_constant" default="Color(1, 1, 1, 1)"> A [Color] constant which represents a state of this node. </member> </members> diff --git a/doc/classes/VisualShaderNodeColorUniform.xml b/doc/classes/VisualShaderNodeColorUniform.xml index 90ef381b76..bdaf301f09 100644 --- a/doc/classes/VisualShaderNodeColorUniform.xml +++ b/doc/classes/VisualShaderNodeColorUniform.xml @@ -11,7 +11,7 @@ <methods> </methods> <members> - <member name="default_value" type="Color" setter="set_default_value" getter="get_default_value" default="Color( 1, 1, 1, 1 )"> + <member name="default_value" type="Color" setter="set_default_value" getter="get_default_value" default="Color(1, 1, 1, 1)"> A default value to be assigned within the shader. </member> <member name="default_value_enabled" type="bool" setter="set_default_value_enabled" getter="is_default_value_enabled" default="false"> diff --git a/doc/classes/VisualShaderNodeResizableBase.xml b/doc/classes/VisualShaderNodeResizableBase.xml index 9f827a96cc..9052f6854b 100644 --- a/doc/classes/VisualShaderNodeResizableBase.xml +++ b/doc/classes/VisualShaderNodeResizableBase.xml @@ -9,7 +9,7 @@ <methods> </methods> <members> - <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2( 0, 0 )"> + <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2(0, 0)"> The size of the node in the visual shader graph. </member> </members> diff --git a/doc/classes/VisualShaderNodeTransformConstant.xml b/doc/classes/VisualShaderNodeTransformConstant.xml index 550ed829c9..30178752d0 100644 --- a/doc/classes/VisualShaderNodeTransformConstant.xml +++ b/doc/classes/VisualShaderNodeTransformConstant.xml @@ -11,7 +11,7 @@ <methods> </methods> <members> - <member name="constant" type="Transform3D" setter="set_constant" getter="get_constant" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )"> + <member name="constant" type="Transform3D" setter="set_constant" getter="get_constant" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)"> A [Transform3D] constant which represents the state of this node. </member> </members> diff --git a/doc/classes/VisualShaderNodeTransformUniform.xml b/doc/classes/VisualShaderNodeTransformUniform.xml index 1f1cc4b630..2f7818ec8a 100644 --- a/doc/classes/VisualShaderNodeTransformUniform.xml +++ b/doc/classes/VisualShaderNodeTransformUniform.xml @@ -11,7 +11,7 @@ <methods> </methods> <members> - <member name="default_value" type="Transform3D" setter="set_default_value" getter="get_default_value" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )"> + <member name="default_value" type="Transform3D" setter="set_default_value" getter="get_default_value" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)"> A default value to be assigned within the shader. </member> <member name="default_value_enabled" type="bool" setter="set_default_value_enabled" getter="is_default_value_enabled" default="false"> diff --git a/doc/classes/VisualShaderNodeVec3Constant.xml b/doc/classes/VisualShaderNodeVec3Constant.xml index b01bb514fe..28c3d22345 100644 --- a/doc/classes/VisualShaderNodeVec3Constant.xml +++ b/doc/classes/VisualShaderNodeVec3Constant.xml @@ -11,7 +11,7 @@ <methods> </methods> <members> - <member name="constant" type="Vector3" setter="set_constant" getter="get_constant" default="Vector3( 0, 0, 0 )"> + <member name="constant" type="Vector3" setter="set_constant" getter="get_constant" default="Vector3(0, 0, 0)"> A [Vector3] constant which represents the state of this node. </member> </members> diff --git a/doc/classes/VisualShaderNodeVec3Uniform.xml b/doc/classes/VisualShaderNodeVec3Uniform.xml index cd1500f5a1..215e2cfbea 100644 --- a/doc/classes/VisualShaderNodeVec3Uniform.xml +++ b/doc/classes/VisualShaderNodeVec3Uniform.xml @@ -11,7 +11,7 @@ <methods> </methods> <members> - <member name="default_value" type="Vector3" setter="set_default_value" getter="get_default_value" default="Vector3( 0, 0, 0 )"> + <member name="default_value" type="Vector3" setter="set_default_value" getter="get_default_value" default="Vector3(0, 0, 0)"> A default value to be assigned within the shader. </member> <member name="default_value_enabled" type="bool" setter="set_default_value_enabled" getter="is_default_value_enabled" default="false"> diff --git a/doc/classes/VoxelGI.xml b/doc/classes/VoxelGI.xml index fa5035349e..5b395becb7 100644 --- a/doc/classes/VoxelGI.xml +++ b/doc/classes/VoxelGI.xml @@ -36,7 +36,7 @@ <member name="data" type="VoxelGIData" setter="set_probe_data" getter="get_probe_data"> The [VoxelGIData] resource that holds the data for this [VoxelGI]. </member> - <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3( 10, 10, 10 )"> + <member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(10, 10, 10)"> The size of the area covered by the [VoxelGI]. If you make the extents larger without increasing the subdivisions with [member subdiv], the size of each cell will increase and result in lower detailed lighting. </member> <member name="subdiv" type="int" setter="set_subdiv" getter="get_subdiv" enum="VoxelGI.Subdiv" default="1"> diff --git a/doc/classes/Window.xml b/doc/classes/Window.xml index 9c320747d1..6ae5a5f449 100644 --- a/doc/classes/Window.xml +++ b/doc/classes/Window.xml @@ -218,7 +218,7 @@ <method name="popup"> <return type="void"> </return> - <argument index="0" name="rect" type="Rect2i" default="Rect2i( 0, 0, 0, 0 )"> + <argument index="0" name="rect" type="Rect2i" default="Rect2i(0, 0, 0, 0)"> </argument> <description> </description> @@ -226,7 +226,7 @@ <method name="popup_centered"> <return type="void"> </return> - <argument index="0" name="minsize" type="Vector2i" default="Vector2i( 0, 0 )"> + <argument index="0" name="minsize" type="Vector2i" default="Vector2i(0, 0)"> </argument> <description> </description> @@ -234,7 +234,7 @@ <method name="popup_centered_clamped"> <return type="void"> </return> - <argument index="0" name="minsize" type="Vector2i" default="Vector2i( 0, 0 )"> + <argument index="0" name="minsize" type="Vector2i" default="Vector2i(0, 0)"> </argument> <argument index="1" name="fallback_ratio" type="float" default="0.75"> </argument> @@ -322,21 +322,21 @@ </member> <member name="content_scale_mode" type="int" setter="set_content_scale_mode" getter="get_content_scale_mode" enum="Window.ContentScaleMode" default="0"> </member> - <member name="content_scale_size" type="Vector2i" setter="set_content_scale_size" getter="get_content_scale_size" default="Vector2i( 0, 0 )"> + <member name="content_scale_size" type="Vector2i" setter="set_content_scale_size" getter="get_content_scale_size" default="Vector2i(0, 0)"> </member> <member name="current_screen" type="int" setter="set_current_screen" getter="get_current_screen" default="0"> </member> <member name="exclusive" type="bool" setter="set_exclusive" getter="is_exclusive" default="false"> </member> - <member name="max_size" type="Vector2i" setter="set_max_size" getter="get_max_size" default="Vector2i( 0, 0 )"> + <member name="max_size" type="Vector2i" setter="set_max_size" getter="get_max_size" default="Vector2i(0, 0)"> </member> - <member name="min_size" type="Vector2i" setter="set_min_size" getter="get_min_size" default="Vector2i( 0, 0 )"> + <member name="min_size" type="Vector2i" setter="set_min_size" getter="get_min_size" default="Vector2i(0, 0)"> </member> <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="Window.Mode" default="0"> </member> - <member name="position" type="Vector2i" setter="set_position" getter="get_position" default="Vector2i( 0, 0 )"> + <member name="position" type="Vector2i" setter="set_position" getter="get_position" default="Vector2i(0, 0)"> </member> - <member name="size" type="Vector2i" setter="set_size" getter="get_size" default="Vector2i( 100, 100 )"> + <member name="size" type="Vector2i" setter="set_size" getter="get_size" default="Vector2i(100, 100)"> </member> <member name="theme" type="Theme" setter="set_theme" getter="get_theme"> </member> @@ -472,7 +472,7 @@ </theme_item> <theme_item name="scaleborder_size" type="int" default="4"> </theme_item> - <theme_item name="title_color" type="Color" default="Color( 0, 0, 0, 1 )"> + <theme_item name="title_color" type="Color" default="Color(0, 0, 0, 1)"> </theme_item> <theme_item name="title_font" type="Font"> </theme_item> @@ -481,7 +481,7 @@ </theme_item> <theme_item name="title_height" type="int" default="20"> </theme_item> - <theme_item name="title_outline_modulate" type="Color" default="Color( 1, 1, 1, 1 )"> + <theme_item name="title_outline_modulate" type="Color" default="Color(1, 1, 1, 1)"> The color of the title outline. </theme_item> <theme_item name="title_outline_size" type="int" default="0"> diff --git a/doc/classes/WorldMarginShape3D.xml b/doc/classes/WorldMarginShape3D.xml index a91447056b..9a26f254f1 100644 --- a/doc/classes/WorldMarginShape3D.xml +++ b/doc/classes/WorldMarginShape3D.xml @@ -11,7 +11,7 @@ <methods> </methods> <members> - <member name="plane" type="Plane" setter="set_plane" getter="get_plane" default="Plane( 0, 1, 0, 0 )"> + <member name="plane" type="Plane" setter="set_plane" getter="get_plane" default="Plane(0, 1, 0, 0)"> The [Plane] used by the [WorldMarginShape3D] for collision. </member> </members> diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index 51c6b473ad..4151c51b26 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -161,21 +161,21 @@ String EditorFeatureProfile::get_feature_description(Feature p_feature) { } Error EditorFeatureProfile::save_to_file(const String &p_path) { - Dictionary json; - json["type"] = "feature_profile"; + Dictionary data; + data["type"] = "feature_profile"; Array dis_classes; for (Set<StringName>::Element *E = disabled_classes.front(); E; E = E->next()) { dis_classes.push_back(String(E->get())); } dis_classes.sort(); - json["disabled_classes"] = dis_classes; + data["disabled_classes"] = dis_classes; Array dis_editors; for (Set<StringName>::Element *E = disabled_editors.front(); E; E = E->next()) { dis_editors.push_back(String(E->get())); } dis_editors.sort(); - json["disabled_editors"] = dis_editors; + data["disabled_editors"] = dis_editors; Array dis_props; @@ -185,7 +185,7 @@ Error EditorFeatureProfile::save_to_file(const String &p_path) { } } - json["disabled_properties"] = dis_props; + data["disabled_properties"] = dis_props; Array dis_features; for (int i = 0; i < FEATURE_MAX; i++) { @@ -194,12 +194,13 @@ Error EditorFeatureProfile::save_to_file(const String &p_path) { } } - json["disabled_features"] = dis_features; + data["disabled_features"] = dis_features; FileAccessRef f = FileAccess::open(p_path, FileAccess::WRITE); ERR_FAIL_COND_V_MSG(!f, ERR_CANT_CREATE, "Cannot create file '" + p_path + "'."); - String text = JSON::print(json, "\t"); + JSON json; + String text = json.stringify(data, "\t"); f->store_string(text); f->close(); return OK; @@ -212,26 +213,24 @@ Error EditorFeatureProfile::load_from_file(const String &p_path) { return err; } - String err_str; - int err_line; - Variant v; - err = JSON::parse(text, v, err_str, err_line); + JSON json; + err = json.parse(text); if (err != OK) { - ERR_PRINT("Error parsing '" + p_path + "' on line " + itos(err_line) + ": " + err_str); + ERR_PRINT("Error parsing '" + p_path + "' on line " + itos(json.get_error_line()) + ": " + json.get_error_message()); return ERR_PARSE_ERROR; } - Dictionary json = v; + Dictionary data = json.get_data(); - if (!json.has("type") || String(json["type"]) != "feature_profile") { + if (!data.has("type") || String(data["type"]) != "feature_profile") { ERR_PRINT("Error parsing '" + p_path + "', it's not a feature profile."); return ERR_PARSE_ERROR; } disabled_classes.clear(); - if (json.has("disabled_classes")) { - Array disabled_classes_arr = json["disabled_classes"]; + if (data.has("disabled_classes")) { + Array disabled_classes_arr = data["disabled_classes"]; for (int i = 0; i < disabled_classes_arr.size(); i++) { disabled_classes.insert(disabled_classes_arr[i]); } @@ -239,8 +238,8 @@ Error EditorFeatureProfile::load_from_file(const String &p_path) { disabled_editors.clear(); - if (json.has("disabled_editors")) { - Array disabled_editors_arr = json["disabled_editors"]; + if (data.has("disabled_editors")) { + Array disabled_editors_arr = data["disabled_editors"]; for (int i = 0; i < disabled_editors_arr.size(); i++) { disabled_editors.insert(disabled_editors_arr[i]); } @@ -248,16 +247,16 @@ Error EditorFeatureProfile::load_from_file(const String &p_path) { disabled_properties.clear(); - if (json.has("disabled_properties")) { - Array disabled_properties_arr = json["disabled_properties"]; + if (data.has("disabled_properties")) { + Array disabled_properties_arr = data["disabled_properties"]; for (int i = 0; i < disabled_properties_arr.size(); i++) { String s = disabled_properties_arr[i]; set_disable_class_property(s.get_slice(":", 0), s.get_slice(":", 1), true); } } - if (json.has("disabled_features")) { - Array disabled_features_arr = json["disabled_features"]; + if (data.has("disabled_features")) { + Array disabled_features_arr = data["disabled_features"]; for (int i = 0; i < FEATURE_MAX; i++) { bool found = false; String f = feature_identifiers[i]; diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index c61b097ccd..3f715c1f93 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -1475,8 +1475,6 @@ void EditorFileSystem::update_file(const String &p_file) { if (cpos == -1) { // The file did not exist, it was added. - - late_added_files.insert(p_file); // Remember that it was added. This mean it will be scanned and imported on editor restart. int idx = 0; String file_name = p_file.get_file(); @@ -1723,9 +1721,6 @@ void EditorFileSystem::_reimport_file(const String &p_file, const Map<StringName } } } - - } else { - late_added_files.insert(p_file); //imported files do not call update_file(), but just in case.. } if (importer_name == "keep") { diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index 04879bad6d..37eee13c16 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -148,7 +148,6 @@ class EditorFileSystem : public Node { void _scan_filesystem(); - Set<String> late_added_files; //keep track of files that were added, these will be re-scanned Set<String> late_update_files; void _save_late_updated_files(); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 32b970b3f3..719d3120da 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2399,11 +2399,13 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } } break; - case FILE_CLOSE_ALL_AND_QUIT: - case FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER: case FILE_CLOSE: { + _scene_tab_closed(editor_data.get_edited_scene()); + } break; + case FILE_CLOSE_ALL_AND_QUIT: + case FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER: { if (!p_confirmed) { - tab_closing = p_option == FILE_CLOSE ? editor_data.get_edited_scene() : _next_unsaved_scene(false); + tab_closing = _next_unsaved_scene(false); _scene_tab_changed(tab_closing); if (unsaved_cache || p_option == FILE_CLOSE_ALL_AND_QUIT || p_option == FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER) { @@ -2416,8 +2418,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { break; } } - } else if (p_option == FILE_CLOSE) { - tab_closing = editor_data.get_edited_scene(); } if (!editor_data.get_edited_scene_root(tab_closing)) { // empty tab diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 1ea8c71f85..b591007a93 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -644,7 +644,7 @@ void EditorResourcePicker::_bind_methods() { ClassDB::add_virtual_method(get_class_static(), MethodInfo("_handle_menu_selected", PropertyInfo(Variant::INT, "id"))); ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type"), "set_base_type", "get_base_type"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "edited_resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource", 0), "set_edited_resource", "get_edited_resource"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "edited_resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource", PROPERTY_USAGE_NONE), "set_edited_resource", "get_edited_resource"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editable"), "set_editable", "is_editable"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "toggle_mode"), "set_toggle_mode", "is_toggle_mode"); @@ -857,7 +857,7 @@ void EditorScriptPicker::_bind_methods() { ClassDB::bind_method(D_METHOD("set_script_owner", "owner_node"), &EditorScriptPicker::set_script_owner); ClassDB::bind_method(D_METHOD("get_script_owner"), &EditorScriptPicker::get_script_owner); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "script_owner", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_script_owner", "get_script_owner"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "script_owner", PROPERTY_HINT_RESOURCE_TYPE, "Node", PROPERTY_USAGE_NONE), "set_script_owner", "get_script_owner"); } EditorScriptPicker::EditorScriptPicker() { diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 3f66326b41..325e0173ab 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -1585,7 +1585,7 @@ void EditorSettings::set_builtin_action_override(const String &p_name, const Arr // Check equality of each event. for (List<Ref<InputEvent>>::Element *E = builtin_events.front(); E; E = E->next()) { - if (!E->get()->shortcut_match(p_events[event_idx])) { + if (!E->get()->is_match(p_events[event_idx])) { same_as_builtin = false; break; } diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index 76c6fcc3d3..dd4ce74406 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -242,10 +242,8 @@ void ExportTemplateManager::_refresh_mirrors_completed(int p_status, int p_code, response_json.parse_utf8((const char *)r, p_data.size()); } - Variant response; - String errs; - int errline; - Error err = JSON::parse(response_json, response, errs, errline); + JSON json; + Error err = json.parse(response_json); if (err != OK) { EditorNode::get_singleton()->show_warning(TTR("Error parsing JSON with the list of mirrors. Please report this issue!")); is_refreshing_mirrors = false; @@ -260,7 +258,7 @@ void ExportTemplateManager::_refresh_mirrors_completed(int p_status, int p_code, mirrors_available = false; - Dictionary data = response; + Dictionary data = json.get_data(); if (data.has("mirrors")) { Array mirrors = data["mirrors"]; diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 93bb170128..f0254e5639 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -1098,11 +1098,9 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const Dictionary d; { - Variant js; - String errs; - int errl; - JSON::parse(str, js, errs, errl); - d = js; + JSON json; + json.parse(str); + d = json.get_data(); } RequestType requested = requesting; diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index a5a3d624ec..af72f59c1c 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -103,17 +103,16 @@ void SpriteFramesEditor::_sheet_preview_draw() { } void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) { - Ref<InputEventMouseButton> mb = p_event; - + const Ref<InputEventMouseButton> mb = p_event; if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) { - Size2i size = split_sheet_preview->get_size(); - int h = split_sheet_h->get_value(); - int v = split_sheet_v->get_value(); + const Size2i size = split_sheet_preview->get_size(); + const int h = split_sheet_h->get_value(); + const int v = split_sheet_v->get_value(); - int x = CLAMP(int(mb->get_position().x) * h / size.width, 0, h - 1); - int y = CLAMP(int(mb->get_position().y) * v / size.height, 0, v - 1); + const int x = CLAMP(int(mb->get_position().x) * h / size.width, 0, h - 1); + const int y = CLAMP(int(mb->get_position().y) * v / size.height, 0, v - 1); - int idx = h * y + x; + const int idx = h * y + x; if (mb->is_shift_pressed() && last_frame_selected >= 0) { //select multiple @@ -124,6 +123,9 @@ void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) { } for (int i = from; i <= to; i++) { + // Prevent double-toggling the same frame when moving the mouse when the mouse button is still held. + frames_toggled_by_mouse_hover.insert(idx); + if (mb->is_ctrl_pressed()) { frames_selected.erase(i); } else { @@ -131,6 +133,9 @@ void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) { } } } else { + // Prevent double-toggling the same frame when moving the mouse when the mouse button is still held. + frames_toggled_by_mouse_hover.insert(idx); + if (frames_selected.has(idx)) { frames_selected.erase(idx); } else { @@ -141,6 +146,39 @@ void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) { last_frame_selected = idx; split_sheet_preview->update(); } + + if (mb.is_valid() && !mb->is_pressed() && mb->get_button_index() == MOUSE_BUTTON_LEFT) { + frames_toggled_by_mouse_hover.clear(); + } + + const Ref<InputEventMouseMotion> mm = p_event; + if (mm.is_valid() && mm->get_button_mask() & MOUSE_BUTTON_MASK_LEFT) { + // Select by holding down the mouse button on frames. + const Size2i size = split_sheet_preview->get_size(); + const int h = split_sheet_h->get_value(); + const int v = split_sheet_v->get_value(); + + const int x = CLAMP(int(mm->get_position().x) * h / size.width, 0, h - 1); + const int y = CLAMP(int(mm->get_position().y) * v / size.height, 0, v - 1); + + const int idx = h * y + x; + + if (!frames_toggled_by_mouse_hover.has(idx)) { + // Only allow toggling each tile once per mouse hold. + // Otherwise, the selection would constantly "flicker" in and out when moving the mouse cursor. + // The mouse button must be released before it can be toggled again. + frames_toggled_by_mouse_hover.insert(idx); + + if (frames_selected.has(idx)) { + frames_selected.erase(idx); + } else { + frames_selected.insert(idx); + } + + last_frame_selected = idx; + split_sheet_preview->update(); + } + } } void SpriteFramesEditor::_sheet_scroll_input(const Ref<InputEvent> &p_event) { diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h index 77cdbb4af6..e6c59e3533 100644 --- a/editor/plugins/sprite_frames_editor_plugin.h +++ b/editor/plugins/sprite_frames_editor_plugin.h @@ -87,6 +87,7 @@ class SpriteFramesEditor : public HSplitContainer { Button *split_sheet_zoom_in; EditorFileDialog *file_split_sheet; Set<int> frames_selected; + Set<int> frames_toggled_by_mouse_hover; int last_frame_selected; float scale_ratio; diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index 61457e3e59..191440bdb3 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -136,7 +136,7 @@ void TileDataOcclusionShapeEditor::draw_over_tile(CanvasItem *p_canvas_item, Tra ERR_FAIL_COND(!tile_data); Vector<String> components = String(p_property).split("/", true); - if (components[0].begins_with("occlusion_layer_") && components[0].trim_prefix("occlusion_layer_").is_valid_integer()) { + if (components[0].begins_with("occlusion_layer_") && components[0].trim_prefix("occlusion_layer_").is_valid_int()) { int occlusion_layer = components[0].trim_prefix("occlusion_layer_").to_int(); if (occlusion_layer >= 0 && occlusion_layer < p_tile_set->get_occlusion_layers_count()) { // Draw all shapes. @@ -158,7 +158,7 @@ void TileDataCollisionShapeEditor::draw_over_tile(CanvasItem *p_canvas_item, Tra ERR_FAIL_COND(!tile_data); Vector<String> components = String(p_property).split("/", true); - if (components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_integer()) { + if (components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) { int physics_layer = components[0].trim_prefix("physics_layer_").to_int(); if (physics_layer >= 0 && physics_layer < p_tile_set->get_physics_layers_count()) { // Draw all shapes. @@ -190,7 +190,7 @@ void TileDataNavigationPolygonEditor::draw_over_tile(CanvasItem *p_canvas_item, ERR_FAIL_COND(!tile_data); Vector<String> components = String(p_property).split("/", true); - if (components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_integer()) { + if (components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) { int navigation_layer = components[0].trim_prefix("navigation_layer_").to_int(); if (navigation_layer >= 0 && navigation_layer < p_tile_set->get_navigation_layers_count()) { // Draw all shapes. diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index 8e7d613027..eb52aff318 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -1040,7 +1040,7 @@ Map<Vector2i, List<const PropertyInfo *>> TileSetAtlasSourceEditor::_group_prope Vector<String> components = String(E_property->get().name).split("/", true, 1); if (components.size() >= 1) { Vector<String> coord_arr = components[0].split(":"); - if (coord_arr.size() == 2 && coord_arr[0].is_valid_integer() && coord_arr[1].is_valid_integer()) { + if (coord_arr.size() == 2 && coord_arr[0].is_valid_int() && coord_arr[1].is_valid_int()) { Vector2i coords = Vector2i(coord_arr[0].to_int(), coord_arr[1].to_int()); per_tile[coords].push_back(&(E_property->get())); } @@ -1088,7 +1088,7 @@ void TileSetAtlasSourceEditor::_menu_option(int p_option) { if (per_tile.has(selected.tile)) { for (List<const PropertyInfo *>::Element *E_property = per_tile[selected.tile].front(); E_property; E_property = E_property->next()) { Vector<String> components = E_property->get()->name.split("/", true, 2); - if (components.size() >= 2 && components[1].is_valid_integer() && components[1].to_int() == selected.alternative) { + if (components.size() >= 2 && components[1].is_valid_int() && components[1].to_int() == selected.alternative) { String property = E_property->get()->name; Variant value = tile_set_atlas_source->get(property); if (value.get_type() != Variant::NIL) { diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp index 11842981f3..ae5620a4e3 100644 --- a/editor/plugins/tiles/tile_set_editor.cpp +++ b/editor/plugins/tiles/tile_set_editor.cpp @@ -356,8 +356,8 @@ void TileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p } } } else if ((p_property == "terrains_sets_count" && tile_data->get_terrain_set() >= (int)p_new_value) || - (components.size() == 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_integer() && components[1] == "mode") || - (components.size() == 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_integer() && components[1] == "terrains_count" && tile_data->get_terrain_set() == components[0].trim_prefix("terrain_set_").to_int() && (int)p_new_value < tile_set->get_terrains_count(tile_data->get_terrain_set()))) { + (components.size() == 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "mode") || + (components.size() == 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int() && components[1] == "terrains_count" && tile_data->get_terrain_set() == components[0].trim_prefix("terrain_set_").to_int() && (int)p_new_value < tile_set->get_terrains_count(tile_data->get_terrain_set()))) { ADD_UNDO(tile_data, "terrain_set"); if (tile_data->is_valid_peering_bit_terrain(TileSet::CELL_NEIGHBOR_RIGHT_SIDE)) { ADD_UNDO(tile_data, "terrains_peering_bit/right_side"); @@ -423,8 +423,8 @@ void TileSetEditor::_undo_redo_inspector_callback(Object *p_undo_redo, Object *p ADD_UNDO(tile_data, vformat("custom_data_%d", custom_data_layer_index)); } } - } else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_integer() && components[1] == "type") { - int custom_data_layer = components[0].trim_prefix("custom_data_layer_").is_valid_integer(); + } else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_int() && components[1] == "type") { + int custom_data_layer = components[0].trim_prefix("custom_data_layer_").is_valid_int(); ADD_UNDO(tile_data, vformat("custom_data_%d", custom_data_layer)); } } diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index c05a3c2f89..c2c99ed17f 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -285,7 +285,7 @@ void EditorSettingsDialog::_update_shortcuts() { event_strings.push_back(I->get()->as_text()); // Only check if the events have been the same so far - once one fails, we don't need to check any more. - if (same_as_defaults && !key_default_events[count]->shortcut_match(I->get())) { + if (same_as_defaults && !key_default_events[count]->is_match(I->get())) { same_as_defaults = false; } count++; diff --git a/modules/csg/doc_classes/CSGBox3D.xml b/modules/csg/doc_classes/CSGBox3D.xml index b1d0454b76..5bb1c4e75b 100644 --- a/modules/csg/doc_classes/CSGBox3D.xml +++ b/modules/csg/doc_classes/CSGBox3D.xml @@ -14,7 +14,7 @@ <member name="material" type="Material" setter="set_material" getter="get_material"> The material used to render the box. </member> - <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3( 2, 2, 2 )"> + <member name="size" type="Vector3" setter="set_size" getter="get_size" default="Vector3(2, 2, 2)"> The box's width, height and depth. </member> </members> diff --git a/modules/csg/doc_classes/CSGPolygon3D.xml b/modules/csg/doc_classes/CSGPolygon3D.xml index c55fa0983e..4f29786779 100644 --- a/modules/csg/doc_classes/CSGPolygon3D.xml +++ b/modules/csg/doc_classes/CSGPolygon3D.xml @@ -38,7 +38,7 @@ <member name="path_rotation" type="int" setter="set_path_rotation" getter="get_path_rotation" enum="CSGPolygon3D.PathRotation"> The method by which each slice is rotated along the path when [member mode] is [constant MODE_PATH]. </member> - <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array( 0, 0, 0, 1, 1, 1, 1, 0 )"> + <member name="polygon" type="PackedVector2Array" setter="set_polygon" getter="get_polygon" default="PackedVector2Array(0, 0, 0, 1, 1, 1, 1, 0)"> Point array that defines the shape that we'll extrude. </member> <member name="smooth_faces" type="bool" setter="set_smooth_faces" getter="get_smooth_faces" default="false"> diff --git a/modules/fbx/tools/validation_tools.h b/modules/fbx/tools/validation_tools.h index 6c15eb7e12..906a721045 100644 --- a/modules/fbx/tools/validation_tools.h +++ b/modules/fbx/tools/validation_tools.h @@ -34,8 +34,7 @@ #ifdef TOOLS_ENABLED #include "core/io/file_access.h" -#include "core/io/json.h" -#include "core/string/ustring.h" +#include "core/string/print_string.h" #include "core/templates/local_vector.h" #include "core/templates/map.h" diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp index e552f443cf..fa11132dd9 100644 --- a/modules/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative.cpp @@ -252,7 +252,7 @@ void GDNativeLibrary::_bind_methods() { ClassDB::bind_method(D_METHOD("set_symbol_prefix", "symbol_prefix"), &GDNativeLibrary::set_symbol_prefix); ClassDB::bind_method(D_METHOD("set_reloadable", "reloadable"), &GDNativeLibrary::set_reloadable); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "config_file", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile", 0), "set_config_file", "get_config_file"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "config_file", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile", PROPERTY_USAGE_NONE), "set_config_file", "get_config_file"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "load_once"), "set_load_once", "should_load_once"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "singleton"), "set_singleton", "is_singleton"); diff --git a/modules/gdnavigation/navigation_mesh_generator.cpp b/modules/gdnavigation/navigation_mesh_generator.cpp index d69c9114b9..b94f4b4c6c 100644 --- a/modules/gdnavigation/navigation_mesh_generator.cpp +++ b/modules/gdnavigation/navigation_mesh_generator.cpp @@ -255,7 +255,7 @@ void NavigationMeshGenerator::_parse_geometry(Transform3D p_accumulated_transfor for (int i = 0; i < meshes.size(); i += 2) { Ref<Mesh> mesh = meshes[i + 1]; if (mesh.is_valid()) { - _add_mesh(mesh, p_accumulated_transform * xform * meshes[i], p_verticies, p_indices); + _add_mesh(mesh, p_accumulated_transform * xform * (Transform3D)meshes[i], p_verticies, p_indices); } } } diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index c3edc813d2..485a4b7b61 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -1779,10 +1779,10 @@ void GDScriptAnalyzer::reduce_binary_op(GDScriptParser::BinaryOpNode *p_binary_o } else { if (p_binary_op->variant_op < Variant::OP_MAX) { bool valid = false; - result = get_operation_type(p_binary_op->variant_op, p_binary_op->left_operand->get_datatype(), right_type, valid, p_binary_op); + result = get_operation_type(p_binary_op->variant_op, left_type, right_type, valid, p_binary_op); if (!valid) { - push_error(vformat(R"(Invalid operands "%s" and "%s" for "%s" operator.)", p_binary_op->left_operand->get_datatype().to_string(), right_type.to_string(), Variant::get_operator_name(p_binary_op->variant_op)), p_binary_op); + push_error(vformat(R"(Invalid operands "%s" and "%s" for "%s" operator.)", left_type.to_string(), right_type.to_string(), Variant::get_operator_name(p_binary_op->variant_op)), p_binary_op); } } else { if (p_binary_op->operation == GDScriptParser::BinaryOpNode::OP_TYPE_TEST) { @@ -2349,6 +2349,7 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod GDScriptParser::DataType result; result.type_source = GDScriptParser::DataType::ANNOTATED_EXPLICIT; result.kind = GDScriptParser::DataType::ENUM_VALUE; + result.builtin_type = base.builtin_type; result.native_type = base.native_type; result.enum_type = name; p_identifier->set_datatype(result); @@ -3446,6 +3447,7 @@ GDScriptParser::DataType GDScriptAnalyzer::get_operation_type(Variant::Operator } r_valid = true; + result.type_source = GDScriptParser::DataType::ANNOTATED_INFERRED; result.kind = GDScriptParser::DataType::BUILTIN; result.builtin_type = Variant::get_operator_return_type(p_operation, a_type, b_type); diff --git a/modules/gdscript/gdscript_byte_codegen.cpp b/modules/gdscript/gdscript_byte_codegen.cpp index 6998cc5bb7..5a297cc50a 100644 --- a/modules/gdscript/gdscript_byte_codegen.cpp +++ b/modules/gdscript/gdscript_byte_codegen.cpp @@ -554,6 +554,14 @@ void GDScriptByteCodeGenerator::write_unary_operator(const Address &p_target, Va void GDScriptByteCodeGenerator::write_binary_operator(const Address &p_target, Variant::Operator p_operator, const Address &p_left_operand, const Address &p_right_operand) { if (HAS_BUILTIN_TYPE(p_left_operand) && HAS_BUILTIN_TYPE(p_right_operand)) { + if (p_target.mode == Address::TEMPORARY) { + Variant::Type result_type = Variant::get_operator_return_type(p_operator, p_left_operand.type.builtin_type, p_right_operand.type.builtin_type); + Variant::Type temp_type = temporaries[p_target.address].type; + if (result_type != temp_type) { + write_type_adjust(p_target, result_type); + } + } + // Gather specific operator. Variant::ValidatedOperatorEvaluator op_func = Variant::get_validated_operator_evaluator(p_operator, p_left_operand.type.builtin_type, p_right_operand.type.builtin_type); diff --git a/modules/gdscript/language_server/gdscript_extend_parser.cpp b/modules/gdscript/language_server/gdscript_extend_parser.cpp index 15236d900d..f817964a3c 100644 --- a/modules/gdscript/language_server/gdscript_extend_parser.cpp +++ b/modules/gdscript/language_server/gdscript_extend_parser.cpp @@ -32,7 +32,6 @@ #include "../gdscript.h" #include "../gdscript_analyzer.h" -#include "core/io/json.h" #include "gdscript_language_protocol.h" #include "gdscript_workspace.h" @@ -183,7 +182,7 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p symbol.detail += ": " + m.get_datatype().to_string(); } if (m.variable->initializer != nullptr && m.variable->initializer->is_constant) { - symbol.detail += " = " + JSON::print(m.variable->initializer->reduced_value); + symbol.detail += " = " + m.variable->initializer->reduced_value.to_json_string(); } symbol.documentation = parse_documentation(LINE_NUMBER_TO_INDEX(m.variable->start_line)); @@ -224,10 +223,10 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p } } } else { - value_text = JSON::print(default_value); + value_text = default_value.to_json_string(); } } else { - value_text = JSON::print(default_value); + value_text = default_value.to_json_string(); } if (!value_text.is_empty()) { symbol.detail += " = " + value_text; @@ -353,8 +352,7 @@ void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionN parameters += ": " + parameter->get_datatype().to_string(); } if (parameter->default_value != nullptr) { - String value = JSON::print(parameter->default_value->reduced_value); - parameters += " = " + value; + parameters += " = " + parameter->default_value->reduced_value.to_json_string(); } } r_symbol.detail += parameters + ")"; diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp index c16a7fa889..42ff8bb5b3 100644 --- a/modules/gdscript/language_server/gdscript_language_protocol.cpp +++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp @@ -31,7 +31,6 @@ #include "gdscript_language_protocol.h" #include "core/config/project_settings.h" -#include "core/io/json.h" #include "editor/doc_tools.h" #include "editor/editor_log.h" #include "editor/editor_node.h" @@ -194,7 +193,7 @@ Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) { vformat("GDScriptLanguageProtocol: Can't initialize invalid peer '%d'.", latest_client_id)); Ref<LSPeer> peer = clients.get(latest_client_id); if (peer != nullptr) { - String msg = JSON::print(request); + String msg = Variant(request).to_json_string(); msg = format_output(msg); (*peer)->res_queue.push_back(msg.utf8()); } @@ -280,7 +279,7 @@ void GDScriptLanguageProtocol::notify_client(const String &p_method, const Varia ERR_FAIL_COND(peer == nullptr); Dictionary message = make_notification(p_method, p_params); - String msg = JSON::print(message); + String msg = Variant(message).to_json_string(); msg = format_output(msg); peer->res_queue.push_back(msg.utf8()); } diff --git a/modules/gltf/doc_classes/GLTFAccessor.xml b/modules/gltf/doc_classes/GLTFAccessor.xml index a1f596f7dd..41a318ce19 100644 --- a/modules/gltf/doc_classes/GLTFAccessor.xml +++ b/modules/gltf/doc_classes/GLTFAccessor.xml @@ -17,9 +17,9 @@ </member> <member name="count" type="int" setter="set_count" getter="get_count" default="0"> </member> - <member name="max" type="PackedFloat64Array" setter="set_max" getter="get_max" default="PackedFloat64Array( )"> + <member name="max" type="PackedFloat64Array" setter="set_max" getter="get_max" default="PackedFloat64Array()"> </member> - <member name="min" type="PackedFloat64Array" setter="set_min" getter="get_min" default="PackedFloat64Array( )"> + <member name="min" type="PackedFloat64Array" setter="set_min" getter="get_min" default="PackedFloat64Array()"> </member> <member name="normalized" type="bool" setter="set_normalized" getter="get_normalized" default="false"> </member> diff --git a/modules/gltf/doc_classes/GLTFLight.xml b/modules/gltf/doc_classes/GLTFLight.xml index bfeaf9a86e..f51d287685 100644 --- a/modules/gltf/doc_classes/GLTFLight.xml +++ b/modules/gltf/doc_classes/GLTFLight.xml @@ -9,7 +9,7 @@ <methods> </methods> <members> - <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 0, 0, 0, 1 )"> + <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(0, 0, 0, 1)"> </member> <member name="inner_cone_angle" type="float" setter="set_inner_cone_angle" getter="get_inner_cone_angle" default="0.0"> </member> diff --git a/modules/gltf/doc_classes/GLTFMesh.xml b/modules/gltf/doc_classes/GLTFMesh.xml index 55f79d2c55..fd7e4a169e 100644 --- a/modules/gltf/doc_classes/GLTFMesh.xml +++ b/modules/gltf/doc_classes/GLTFMesh.xml @@ -9,7 +9,7 @@ <methods> </methods> <members> - <member name="blend_weights" type="PackedFloat32Array" setter="set_blend_weights" getter="get_blend_weights" default="PackedFloat32Array( )"> + <member name="blend_weights" type="PackedFloat32Array" setter="set_blend_weights" getter="get_blend_weights" default="PackedFloat32Array()"> </member> <member name="mesh" type="EditorSceneImporterMesh" setter="set_mesh" getter="get_mesh"> </member> diff --git a/modules/gltf/doc_classes/GLTFNode.xml b/modules/gltf/doc_classes/GLTFNode.xml index 5d84d7088b..bfbb12df4d 100644 --- a/modules/gltf/doc_classes/GLTFNode.xml +++ b/modules/gltf/doc_classes/GLTFNode.xml @@ -11,7 +11,7 @@ <members> <member name="camera" type="int" setter="set_camera" getter="get_camera" default="-1"> </member> - <member name="children" type="PackedInt32Array" setter="set_children" getter="get_children" default="PackedInt32Array( )"> + <member name="children" type="PackedInt32Array" setter="set_children" getter="get_children" default="PackedInt32Array()"> </member> <member name="height" type="int" setter="set_height" getter="get_height" default="-1"> </member> @@ -23,17 +23,17 @@ </member> <member name="parent" type="int" setter="set_parent" getter="get_parent" default="-1"> </member> - <member name="rotation" type="Quaternion" setter="set_rotation" getter="get_rotation" default="Quaternion( 0, 0, 0, 1 )"> + <member name="rotation" type="Quaternion" setter="set_rotation" getter="get_rotation" default="Quaternion(0, 0, 0, 1)"> </member> - <member name="scale" type="Vector3" setter="set_scale" getter="get_scale" default="Vector3( 1, 1, 1 )"> + <member name="scale" type="Vector3" setter="set_scale" getter="get_scale" default="Vector3(1, 1, 1)"> </member> <member name="skeleton" type="int" setter="set_skeleton" getter="get_skeleton" default="-1"> </member> <member name="skin" type="int" setter="set_skin" getter="get_skin" default="-1"> </member> - <member name="translation" type="Vector3" setter="set_translation" getter="get_translation" default="Vector3( 0, 0, 0 )"> + <member name="translation" type="Vector3" setter="set_translation" getter="get_translation" default="Vector3(0, 0, 0)"> </member> - <member name="xform" type="Transform3D" setter="set_xform" getter="get_xform" default="Transform3D( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )"> + <member name="xform" type="Transform3D" setter="set_xform" getter="get_xform" default="Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)"> </member> </members> <constants> diff --git a/modules/gltf/doc_classes/GLTFSkeleton.xml b/modules/gltf/doc_classes/GLTFSkeleton.xml index 9680c27705..40563c9ac6 100644 --- a/modules/gltf/doc_classes/GLTFSkeleton.xml +++ b/modules/gltf/doc_classes/GLTFSkeleton.xml @@ -57,9 +57,9 @@ </method> </methods> <members> - <member name="joints" type="PackedInt32Array" setter="set_joints" getter="get_joints" default="PackedInt32Array( )"> + <member name="joints" type="PackedInt32Array" setter="set_joints" getter="get_joints" default="PackedInt32Array()"> </member> - <member name="roots" type="PackedInt32Array" setter="set_roots" getter="get_roots" default="PackedInt32Array( )"> + <member name="roots" type="PackedInt32Array" setter="set_roots" getter="get_roots" default="PackedInt32Array()"> </member> </members> <constants> diff --git a/modules/gltf/doc_classes/GLTFSkin.xml b/modules/gltf/doc_classes/GLTFSkin.xml index 5a80c7097a..e20e127e52 100644 --- a/modules/gltf/doc_classes/GLTFSkin.xml +++ b/modules/gltf/doc_classes/GLTFSkin.xml @@ -53,13 +53,13 @@ <members> <member name="godot_skin" type="Skin" setter="set_godot_skin" getter="get_godot_skin"> </member> - <member name="joints" type="PackedInt32Array" setter="set_joints" getter="get_joints" default="PackedInt32Array( )"> + <member name="joints" type="PackedInt32Array" setter="set_joints" getter="get_joints" default="PackedInt32Array()"> </member> - <member name="joints_original" type="PackedInt32Array" setter="set_joints_original" getter="get_joints_original" default="PackedInt32Array( )"> + <member name="joints_original" type="PackedInt32Array" setter="set_joints_original" getter="get_joints_original" default="PackedInt32Array()"> </member> - <member name="non_joints" type="PackedInt32Array" setter="set_non_joints" getter="get_non_joints" default="PackedInt32Array( )"> + <member name="non_joints" type="PackedInt32Array" setter="set_non_joints" getter="get_non_joints" default="PackedInt32Array()"> </member> - <member name="roots" type="PackedInt32Array" setter="set_roots" getter="get_roots" default="PackedInt32Array( )"> + <member name="roots" type="PackedInt32Array" setter="set_roots" getter="get_roots" default="PackedInt32Array()"> </member> <member name="skeleton" type="int" setter="set_skeleton" getter="get_skeleton" default="-1"> </member> diff --git a/modules/gltf/doc_classes/GLTFSpecGloss.xml b/modules/gltf/doc_classes/GLTFSpecGloss.xml index 68cc7c845d..6e9c419649 100644 --- a/modules/gltf/doc_classes/GLTFSpecGloss.xml +++ b/modules/gltf/doc_classes/GLTFSpecGloss.xml @@ -9,7 +9,7 @@ <methods> </methods> <members> - <member name="diffuse_factor" type="Color" setter="set_diffuse_factor" getter="get_diffuse_factor" default="Color( 1, 1, 1, 1 )"> + <member name="diffuse_factor" type="Color" setter="set_diffuse_factor" getter="get_diffuse_factor" default="Color(1, 1, 1, 1)"> </member> <member name="diffuse_img" type="Image" setter="set_diffuse_img" getter="get_diffuse_img"> </member> @@ -17,7 +17,7 @@ </member> <member name="spec_gloss_img" type="Image" setter="set_spec_gloss_img" getter="get_spec_gloss_img"> </member> - <member name="specular_factor" type="Color" setter="set_specular_factor" getter="get_specular_factor" default="Color( 1, 1, 1, 1 )"> + <member name="specular_factor" type="Color" setter="set_specular_factor" getter="get_specular_factor" default="Color(1, 1, 1, 1)"> </member> </members> <constants> diff --git a/modules/gltf/doc_classes/GLTFState.xml b/modules/gltf/doc_classes/GLTFState.xml index 8255cd73d0..a7b5b7b43e 100644 --- a/modules/gltf/doc_classes/GLTFState.xml +++ b/modules/gltf/doc_classes/GLTFState.xml @@ -243,9 +243,9 @@ </method> </methods> <members> - <member name="buffers" type="Array" setter="set_buffers" getter="get_buffers" default="[ ]"> + <member name="buffers" type="Array" setter="set_buffers" getter="get_buffers" default="[]"> </member> - <member name="glb_data" type="PackedByteArray" setter="set_glb_data" getter="get_glb_data" default="PackedByteArray( )"> + <member name="glb_data" type="PackedByteArray" setter="set_glb_data" getter="get_glb_data" default="PackedByteArray()"> </member> <member name="json" type="Dictionary" setter="set_json" getter="get_json" default="{}"> </member> @@ -253,7 +253,7 @@ </member> <member name="minor_version" type="int" setter="set_minor_version" getter="get_minor_version" default="0"> </member> - <member name="root_nodes" type="Array" setter="set_root_nodes" getter="get_root_nodes" default="[ ]"> + <member name="root_nodes" type="Array" setter="set_root_nodes" getter="get_root_nodes" default="[]"> </member> <member name="scene_name" type="String" setter="set_scene_name" getter="get_scene_name" default=""""> </member> diff --git a/modules/gltf/doc_classes/PackedSceneGLTF.xml b/modules/gltf/doc_classes/PackedSceneGLTF.xml index a04c6ef0b6..a22111e9b7 100644 --- a/modules/gltf/doc_classes/PackedSceneGLTF.xml +++ b/modules/gltf/doc_classes/PackedSceneGLTF.xml @@ -51,7 +51,7 @@ </method> </methods> <members> - <member name="_bundled" type="Dictionary" setter="_set_bundled_scene" getter="_get_bundled_scene" override="true" default="{"conn_count": 0,"conns": PackedInt32Array( ),"editable_instances": [ ],"names": PackedStringArray( ),"node_count": 0,"node_paths": [ ],"nodes": PackedInt32Array( ),"variants": [ ],"version": 2}" /> + <member name="_bundled" type="Dictionary" setter="_set_bundled_scene" getter="_get_bundled_scene" override="true" default="{"conn_count": 0,"conns": PackedInt32Array(),"editable_instances": [],"names": PackedStringArray(),"node_count": 0,"node_paths": [],"nodes": PackedInt32Array(),"variants": [],"version": 2}" /> </members> <constants> </constants> diff --git a/modules/gltf/editor_scene_importer_gltf.cpp b/modules/gltf/editor_scene_importer_gltf.cpp index 21b4bb75fb..5f220a9e57 100644 --- a/modules/gltf/editor_scene_importer_gltf.cpp +++ b/modules/gltf/editor_scene_importer_gltf.cpp @@ -30,7 +30,6 @@ #include "core/crypto/crypto_core.h" #include "core/io/file_access.h" -#include "core/io/json.h" #include "core/math/disjoint_set.h" #include "core/math/math_defs.h" #include "core/os/os.h" diff --git a/modules/gltf/editor_scene_importer_gltf.h b/modules/gltf/editor_scene_importer_gltf.h index af1a885f2b..566d5cfd34 100644 --- a/modules/gltf/editor_scene_importer_gltf.h +++ b/modules/gltf/editor_scene_importer_gltf.h @@ -32,7 +32,6 @@ #define EDITOR_SCENE_IMPORTER_GLTF_H #include "core/config/project_settings.h" -#include "core/io/json.h" #include "core/object/object.h" #include "core/templates/vector.h" #include "editor/import/resource_importer_scene.h" diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 988a75ac93..40f2116676 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -238,15 +238,13 @@ Error GLTFDocument::_parse_json(const String &p_path, Ref<GLTFState> state) { String text; text.parse_utf8((const char *)array.ptr(), array.size()); - String err_txt; - int err_line; - Variant v; - err = JSON::parse(text, v, err_txt, err_line); + JSON json; + err = json.parse(text); if (err != OK) { - _err_print_error("", p_path.utf8().get_data(), err_line, err_txt.utf8().get_data(), ERR_HANDLER_SCRIPT); + _err_print_error("", p_path.utf8().get_data(), json.get_error_line(), json.get_error_message().utf8().get_data(), ERR_HANDLER_SCRIPT); return err; } - state->json = v; + state->json = json.get_data(); return OK; } @@ -299,16 +297,14 @@ Error GLTFDocument::_parse_glb(const String &p_path, Ref<GLTFState> state) { String text; text.parse_utf8((const char *)json_data.ptr(), json_data.size()); - String err_txt; - int err_line; - Variant v; - err = JSON::parse(text, v, err_txt, err_line); + JSON json; + err = json.parse(text); if (err != OK) { - _err_print_error("", p_path.utf8().get_data(), err_line, err_txt.utf8().get_data(), ERR_HANDLER_SCRIPT); + _err_print_error("", p_path.utf8().get_data(), json.get_error_line(), json.get_error_message().utf8().get_data(), ERR_HANDLER_SCRIPT); return err; } - state->json = v; + state->json = json.get_data(); //data? @@ -6584,7 +6580,7 @@ Error GLTFDocument::_serialize_file(Ref<GLTFState> state, const String p_path) { FileAccessRef f = FileAccess::open(p_path, FileAccess::WRITE, &err); ERR_FAIL_COND_V(!f, FAILED); - String json = JSON::print(state->json); + String json = Variant(state->json).to_json_string(); const uint32_t magic = 0x46546C67; // GLTF const int32_t header_size = 12; @@ -6625,7 +6621,7 @@ Error GLTFDocument::_serialize_file(Ref<GLTFState> state, const String p_path) { ERR_FAIL_COND_V(!f, FAILED); f->create(FileAccess::ACCESS_RESOURCES); - String json = JSON::print(state->json); + String json = Variant(state->json).to_json_string(); f->store_string(json); f->close(); } diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml index fb0a2c9953..a2c8e8eabf 100644 --- a/modules/gridmap/doc_classes/GridMap.xml +++ b/modules/gridmap/doc_classes/GridMap.xml @@ -203,7 +203,7 @@ The scale of the cell items. This does not affect the size of the grid cells themselves, only the items in them. This can be used to make cell items overlap their neighbors. </member> - <member name="cell_size" type="Vector3" setter="set_cell_size" getter="get_cell_size" default="Vector3( 2, 2, 2 )"> + <member name="cell_size" type="Vector3" setter="set_cell_size" getter="get_cell_size" default="Vector3(2, 2, 2)"> The dimensions of the grid's cells. This does not affect the size of the meshes. See [member cell_scale]. </member> diff --git a/modules/jsonrpc/jsonrpc.cpp b/modules/jsonrpc/jsonrpc.cpp index 306c0ff087..3d0759d83e 100644 --- a/modules/jsonrpc/jsonrpc.cpp +++ b/modules/jsonrpc/jsonrpc.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "jsonrpc.h" + #include "core/io/json.h" JSONRPC::JSONRPC() { @@ -156,19 +157,17 @@ String JSONRPC::process_string(const String &p_input) { } Variant ret; - Variant input; - String err_message; - int err_line; - if (OK != JSON::parse(p_input, input, err_message, err_line)) { - ret = make_response_error(JSONRPC::PARSE_ERROR, "Parse error"); + JSON json; + if (json.parse(p_input) == OK) { + ret = process_action(json.get_data(), true); } else { - ret = process_action(input, true); + ret = make_response_error(JSONRPC::PARSE_ERROR, "Parse error"); } if (ret.get_type() == Variant::NIL) { return ""; } - return JSON::print(ret); + return ret.to_json_string(); } void JSONRPC::set_scope(const String &p_scope, Object *p_obj) { diff --git a/modules/minimp3/doc_classes/AudioStreamMP3.xml b/modules/minimp3/doc_classes/AudioStreamMP3.xml index 92e777ca0f..5507329a18 100644 --- a/modules/minimp3/doc_classes/AudioStreamMP3.xml +++ b/modules/minimp3/doc_classes/AudioStreamMP3.xml @@ -11,7 +11,7 @@ <methods> </methods> <members> - <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray( )"> + <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray()"> Contains the audio data in bytes. </member> <member name="loop" type="bool" setter="set_loop" getter="has_loop" default="false"> diff --git a/modules/mono/class_db_api_json.cpp b/modules/mono/class_db_api_json.cpp index bd02ec0eac..25193a1352 100644 --- a/modules/mono/class_db_api_json.cpp +++ b/modules/mono/class_db_api_json.cpp @@ -240,7 +240,8 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) { FileAccessRef f = FileAccess::open(p_output_file, FileAccess::WRITE); ERR_FAIL_COND_MSG(!f, "Cannot open file '" + p_output_file + "'."); - f->store_string(JSON::print(classes_dict, /*indent: */ "\t")); + JSON json; + f->store_string(json.stringify(classes_dict, "\t")); f->close(); print_line(String() + "ClassDB API JSON written to: " + ProjectSettings::get_singleton()->globalize_path(p_output_file)); diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 576256b6ec..b54340a7bc 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -38,7 +38,6 @@ #include "core/debugger/engine_debugger.h" #include "core/debugger/script_debugger.h" #include "core/io/file_access.h" -#include "core/io/json.h" #include "core/os/mutex.h" #include "core/os/os.h" #include "core/os/thread.h" diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs index b087b4c200..817103994a 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Quaternion.cs @@ -114,6 +114,23 @@ namespace Godot } /// <summary> + /// Returns the angle between this quaternion and `to`. + /// This is the magnitude of the angle you would need to rotate + /// by to get from one to the other. + /// + /// Note: This method has an abnormally high amount + /// of floating-point error, so methods such as + /// <see cref="Mathf.IsZeroApprox"/> will not work reliably. + /// </summary> + /// <param name="to">The other quaternion.</param> + /// <returns>The angle between the quaternions.</returns> + public real_t AngleTo(Quaternion to) + { + real_t dot = Dot(to); + return Mathf.Acos(Mathf.Clamp(dot * dot * 2 - 1, -1, 1)); + } + + /// <summary> /// Performs a cubic spherical interpolation between quaternions `preA`, /// this vector, `b`, and `postB`, by the given amount `t`. /// </summary> diff --git a/modules/opensimplex/doc_classes/NoiseTexture.xml b/modules/opensimplex/doc_classes/NoiseTexture.xml index a12412a9cd..2ae7f8cad9 100644 --- a/modules/opensimplex/doc_classes/NoiseTexture.xml +++ b/modules/opensimplex/doc_classes/NoiseTexture.xml @@ -31,7 +31,7 @@ <member name="noise" type="OpenSimplexNoise" setter="set_noise" getter="get_noise"> The [OpenSimplexNoise] instance used to generate the noise. </member> - <member name="noise_offset" type="Vector2" setter="set_noise_offset" getter="get_noise_offset" default="Vector2( 0, 0 )"> + <member name="noise_offset" type="Vector2" setter="set_noise_offset" getter="get_noise_offset" default="Vector2(0, 0)"> An offset used to specify the noise space coordinate of the top left corner of the generated noise. This value is ignored if [member seamless] is enabled. </member> <member name="seamless" type="bool" setter="set_seamless" getter="get_seamless" default="false"> diff --git a/modules/opensimplex/doc_classes/OpenSimplexNoise.xml b/modules/opensimplex/doc_classes/OpenSimplexNoise.xml index 2fdbd61ee7..4d45e41cc3 100644 --- a/modules/opensimplex/doc_classes/OpenSimplexNoise.xml +++ b/modules/opensimplex/doc_classes/OpenSimplexNoise.xml @@ -31,7 +31,7 @@ </argument> <argument index="1" name="height" type="int"> </argument> - <argument index="2" name="noise_offset" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="2" name="noise_offset" type="Vector2" default="Vector2(0, 0)"> </argument> <description> Generate a noise image in [constant Image.FORMAT_L8] format with the requested [code]width[/code] and [code]height[/code], based on the current noise parameters. If [code]noise_offset[/code] is specified, then the offset value is used as the coordinates of the top-left corner of the generated noise. diff --git a/modules/regex/doc_classes/RegExMatch.xml b/modules/regex/doc_classes/RegExMatch.xml index cfe00f83ee..492519d3d9 100644 --- a/modules/regex/doc_classes/RegExMatch.xml +++ b/modules/regex/doc_classes/RegExMatch.xml @@ -51,7 +51,7 @@ <member name="names" type="Dictionary" setter="" getter="get_names" default="{}"> A dictionary of named groups and its corresponding group number. Only groups that were matched are included. If multiple groups have the same name, that name would refer to the first matching one. </member> - <member name="strings" type="Array" setter="" getter="get_strings" default="[ ]"> + <member name="strings" type="Array" setter="" getter="get_strings" default="[]"> An [Array] of the match and its capturing groups. </member> <member name="subject" type="String" setter="" getter="get_subject" default=""""> diff --git a/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml index 8a1bb62e24..94fdff5d43 100644 --- a/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml +++ b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml @@ -11,7 +11,7 @@ <methods> </methods> <members> - <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray( )"> + <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray()"> Contains the audio data in bytes. </member> <member name="loop" type="bool" setter="set_loop" getter="has_loop" default="false"> diff --git a/modules/visual_script/doc_classes/VisualScript.xml b/modules/visual_script/doc_classes/VisualScript.xml index 0798375a96..9d51bd86a2 100644 --- a/modules/visual_script/doc_classes/VisualScript.xml +++ b/modules/visual_script/doc_classes/VisualScript.xml @@ -39,7 +39,7 @@ </argument> <argument index="1" name="node" type="VisualScriptNode"> </argument> - <argument index="2" name="position" type="Vector2" default="Vector2( 0, 0 )"> + <argument index="2" name="position" type="Vector2" default="Vector2(0, 0)"> </argument> <description> Add a node to the VisualScript. diff --git a/modules/visual_script/doc_classes/VisualScriptComment.xml b/modules/visual_script/doc_classes/VisualScriptComment.xml index 243338ea52..02cec97b27 100644 --- a/modules/visual_script/doc_classes/VisualScriptComment.xml +++ b/modules/visual_script/doc_classes/VisualScriptComment.xml @@ -15,7 +15,7 @@ <member name="description" type="String" setter="set_description" getter="get_description" default=""""> The text inside the comment node. </member> - <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2( 150, 150 )"> + <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2(150, 150)"> The comment node's size (in pixels). </member> <member name="title" type="String" setter="set_title" getter="get_title" default=""Comment""> diff --git a/modules/visual_script/doc_classes/VisualScriptFunctionState.xml b/modules/visual_script/doc_classes/VisualScriptFunctionState.xml index 9ed71bf10e..16c1629fe4 100644 --- a/modules/visual_script/doc_classes/VisualScriptFunctionState.xml +++ b/modules/visual_script/doc_classes/VisualScriptFunctionState.xml @@ -28,7 +28,7 @@ <method name="resume"> <return type="Variant"> </return> - <argument index="0" name="args" type="Array" default="[ ]"> + <argument index="0" name="args" type="Array" default="[]"> </argument> <description> </description> diff --git a/modules/websocket/doc_classes/WebSocketClient.xml b/modules/websocket/doc_classes/WebSocketClient.xml index d362bcc10f..6af610c689 100644 --- a/modules/websocket/doc_classes/WebSocketClient.xml +++ b/modules/websocket/doc_classes/WebSocketClient.xml @@ -17,11 +17,11 @@ </return> <argument index="0" name="url" type="String"> </argument> - <argument index="1" name="protocols" type="PackedStringArray" default="PackedStringArray( )"> + <argument index="1" name="protocols" type="PackedStringArray" default="PackedStringArray()"> </argument> <argument index="2" name="gd_mp_api" type="bool" default="false"> </argument> - <argument index="3" name="custom_headers" type="PackedStringArray" default="PackedStringArray( )"> + <argument index="3" name="custom_headers" type="PackedStringArray" default="PackedStringArray()"> </argument> <description> Connects to the given URL requesting one of the given [code]protocols[/code] as sub-protocol. If the list empty (default), no sub-protocol will be requested. diff --git a/modules/websocket/doc_classes/WebSocketServer.xml b/modules/websocket/doc_classes/WebSocketServer.xml index f7805209e2..78f2832770 100644 --- a/modules/websocket/doc_classes/WebSocketServer.xml +++ b/modules/websocket/doc_classes/WebSocketServer.xml @@ -63,7 +63,7 @@ </return> <argument index="0" name="port" type="int"> </argument> - <argument index="1" name="protocols" type="PackedStringArray" default="PackedStringArray( )"> + <argument index="1" name="protocols" type="PackedStringArray" default="PackedStringArray()"> </argument> <argument index="2" name="gd_mp_api" type="bool" default="false"> </argument> diff --git a/modules/websocket/websocket_client.cpp b/modules/websocket/websocket_client.cpp index 1e9183ebfa..27f0f9af6b 100644 --- a/modules/websocket/websocket_client.cpp +++ b/modules/websocket/websocket_client.cpp @@ -123,12 +123,12 @@ void WebSocketClient::_bind_methods() { ClassDB::bind_method(D_METHOD("set_verify_ssl_enabled", "enabled"), &WebSocketClient::set_verify_ssl_enabled); ClassDB::bind_method(D_METHOD("is_verify_ssl_enabled"), &WebSocketClient::is_verify_ssl_enabled); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "verify_ssl", PROPERTY_HINT_NONE, "", 0), "set_verify_ssl_enabled", "is_verify_ssl_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "verify_ssl", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_verify_ssl_enabled", "is_verify_ssl_enabled"); ClassDB::bind_method(D_METHOD("get_trusted_ssl_certificate"), &WebSocketClient::get_trusted_ssl_certificate); ClassDB::bind_method(D_METHOD("set_trusted_ssl_certificate"), &WebSocketClient::set_trusted_ssl_certificate); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "trusted_ssl_certificate", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", 0), "set_trusted_ssl_certificate", "get_trusted_ssl_certificate"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "trusted_ssl_certificate", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", PROPERTY_USAGE_NONE), "set_trusted_ssl_certificate", "get_trusted_ssl_certificate"); ADD_SIGNAL(MethodInfo("data_received")); ADD_SIGNAL(MethodInfo("connection_established", PropertyInfo(Variant::STRING, "protocol"))); diff --git a/modules/websocket/websocket_server.cpp b/modules/websocket/websocket_server.cpp index 7cf68b835c..dfe4471659 100644 --- a/modules/websocket/websocket_server.cpp +++ b/modules/websocket/websocket_server.cpp @@ -55,15 +55,15 @@ void WebSocketServer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_private_key"), &WebSocketServer::get_private_key); ClassDB::bind_method(D_METHOD("set_private_key"), &WebSocketServer::set_private_key); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "private_key", PROPERTY_HINT_RESOURCE_TYPE, "CryptoKey", 0), "set_private_key", "get_private_key"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "private_key", PROPERTY_HINT_RESOURCE_TYPE, "CryptoKey", PROPERTY_USAGE_NONE), "set_private_key", "get_private_key"); ClassDB::bind_method(D_METHOD("get_ssl_certificate"), &WebSocketServer::get_ssl_certificate); ClassDB::bind_method(D_METHOD("set_ssl_certificate"), &WebSocketServer::set_ssl_certificate); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "ssl_certificate", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", 0), "set_ssl_certificate", "get_ssl_certificate"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "ssl_certificate", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", PROPERTY_USAGE_NONE), "set_ssl_certificate", "get_ssl_certificate"); ClassDB::bind_method(D_METHOD("get_ca_chain"), &WebSocketServer::get_ca_chain); ClassDB::bind_method(D_METHOD("set_ca_chain"), &WebSocketServer::set_ca_chain); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "ca_chain", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", 0), "set_ca_chain", "get_ca_chain"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "ca_chain", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", PROPERTY_USAGE_NONE), "set_ca_chain", "get_ca_chain"); ADD_SIGNAL(MethodInfo("client_close_request", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::INT, "code"), PropertyInfo(Variant::STRING, "reason"))); ADD_SIGNAL(MethodInfo("client_disconnected", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::BOOL, "was_clean_close"))); diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 1a0c206e28..4262cc1a50 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1849,7 +1849,7 @@ public: err = OS::get_singleton()->execute(adb, args, &output, &rv, true); print_verbose(output); if (err || rv != 0) { - EditorNode::add_io_error("Could not install to device."); + EditorNode::add_io_error("Could not install to device: " + output); CLEANUP_AND_RETURN(ERR_CANT_CREATE); } diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index 7e49feee61..823f9b8281 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -29,7 +29,6 @@ /*************************************************************************/ #include "core/io/image_loader.h" -#include "core/io/json.h" #include "core/io/stream_peer_ssl.h" #include "core/io/tcp_server.h" #include "core/io/zip_io.h" @@ -465,7 +464,7 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Re } // Replaces HTML string - const String str_config = JSON::print(config); + const String str_config = Variant(config).to_json_string(); const String custom_head_include = p_preset->get("html/head_include"); Map<String, String> replaces; replaces["$GODOT_URL"] = p_name + ".js"; @@ -518,7 +517,7 @@ Error EditorExportPlatformJavaScript::_build_pwa(const Ref<EditorExportPreset> & replaces["@GODOT_NAME@"] = name; replaces["@GODOT_OFFLINE_PAGE@"] = name + ".offline.html"; Array files; - replaces["@GODOT_OPT_CACHE@"] = JSON::print(files); + replaces["@GODOT_OPT_CACHE@"] = Variant(files).to_json_string(); files.push_back(name + ".html"); files.push_back(name + ".js"); files.push_back(name + ".wasm"); @@ -537,7 +536,7 @@ Error EditorExportPlatformJavaScript::_build_pwa(const Ref<EditorExportPreset> & files.push_back(p_shared_objects[i].path.get_file()); } } - replaces["@GODOT_CACHE@"] = JSON::print(files); + replaces["@GODOT_CACHE@"] = Variant(files).to_json_string(); const String sw_path = dir.plus_file(name + ".service.worker.js"); Vector<uint8_t> sw; @@ -605,7 +604,7 @@ Error EditorExportPlatformJavaScript::_build_pwa(const Ref<EditorExportPreset> & } manifest["icons"] = icons_arr; - CharString cs = JSON::print(manifest).utf8(); + CharString cs = Variant(manifest).to_json_string().utf8(); err = _write_or_error((const uint8_t *)cs.get_data(), cs.length(), dir.plus_file(name + ".manifest.json")); if (err != OK) { return err; diff --git a/platform/javascript/javascript_singleton.cpp b/platform/javascript/javascript_singleton.cpp index c441ed0517..9de2edc9a7 100644 --- a/platform/javascript/javascript_singleton.cpp +++ b/platform/javascript/javascript_singleton.cpp @@ -54,6 +54,7 @@ extern int godot_js_wrapper_object_setvar(int p_id, int p_key_type, godot_js_wra extern void godot_js_wrapper_object_set(int p_id, const char *p_name, int p_type, godot_js_wrapper_ex *p_val); extern void godot_js_wrapper_object_unref(int p_id); extern int godot_js_wrapper_create_cb(void *p_ref, void (*p_callback)(void *p_ref, int p_arg_id, int p_argc)); +extern void godot_js_wrapper_object_set_cb_ret(int p_type, godot_js_wrapper_ex *p_val); extern int godot_js_wrapper_create_object(const char *p_method, void **p_args, int p_argc, GodotJSWrapperVariant2JSCallback p_variant2js_callback, godot_js_wrapper_ex *p_cb_rval, void **p_lock, GodotJSWrapperFreeLockCallback p_lock_callback); }; @@ -257,6 +258,16 @@ void JavaScriptObjectImpl::_callback(void *p_ref, int p_args_id, int p_argc) { Callable::CallError err; Variant ret; obj->_callable.call(argv, 1, ret, err); + + // Set return value + godot_js_wrapper_ex exchange; + void *lock = nullptr; + const Variant *v = &ret; + int type = _variant2js((const void **)&v, 0, &exchange, &lock); + godot_js_wrapper_object_set_cb_ret(type, &exchange); + if (lock) { + _free_lock(&lock, type); + } } Ref<JavaScriptObject> JavaScript::create_callback(const Callable &p_callable) { diff --git a/platform/javascript/js/libs/library_godot_javascript_singleton.js b/platform/javascript/js/libs/library_godot_javascript_singleton.js index cb80273ca8..22ce003cd2 100644 --- a/platform/javascript/js/libs/library_godot_javascript_singleton.js +++ b/platform/javascript/js/libs/library_godot_javascript_singleton.js @@ -34,6 +34,7 @@ const GodotJSWrapper = { $GodotJSWrapper__postset: 'GodotJSWrapper.proxies = new Map();', $GodotJSWrapper: { proxies: null, + cb_ret: null, MyProxy: function (val) { const id = IDHandler.add(this); @@ -202,15 +203,27 @@ const GodotJSWrapper = { let id = 0; const cb = function () { if (!GodotJSWrapper.get_proxied_value(id)) { - return; + return undefined; } + // The callback will store the returned value in this variable via + // "godot_js_wrapper_object_set_cb_ret" upon calling the user function. + // This is safe! JavaScript is single threaded (and using it in threads is not a good idea anyway). + GodotJSWrapper.cb_ret = null; const args = Array.from(arguments); func(p_ref, GodotJSWrapper.get_proxied(args), args.length); + const ret = GodotJSWrapper.cb_ret; + GodotJSWrapper.cb_ret = null; + return ret; }; id = GodotJSWrapper.get_proxied(cb); return id; }, + godot_js_wrapper_object_set_cb_ret__sig: 'vii', + godot_js_wrapper_object_set_cb_ret: function (p_val_type, p_val_ex) { + GodotJSWrapper.cb_ret = GodotJSWrapper.variant2js(p_val_type, p_val_ex); + }, + godot_js_wrapper_object_getvar__sig: 'iiii', godot_js_wrapper_object_getvar: function (p_id, p_type, p_exchange) { const obj = GodotJSWrapper.get_proxied_value(p_id); diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index ca4b8d72a1..926997a715 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -724,7 +724,7 @@ void Camera2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "rotating"), "set_rotating", "is_rotating"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "current"), "_set_current", "is_current"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "zoom"), "set_zoom", "get_zoom"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "custom_viewport", PROPERTY_HINT_RESOURCE_TYPE, "Viewport", 0), "set_custom_viewport", "get_custom_viewport"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "custom_viewport", PROPERTY_HINT_RESOURCE_TYPE, "Viewport", PROPERTY_USAGE_NONE), "set_custom_viewport", "get_custom_viewport"); ADD_PROPERTY(PropertyInfo(Variant::INT, "process_callback", PROPERTY_HINT_ENUM, "Physics,Idle"), "set_process_callback", "get_process_callback"); ADD_GROUP("Limit", "limit_"); diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index 049d121213..9d86ec88be 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -458,13 +458,13 @@ void Node2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "skew", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_skew", "get_skew"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "skew_degrees", PROPERTY_HINT_RANGE, "-89.9,89.9,0.1", PROPERTY_USAGE_EDITOR), "set_skew_degrees", "get_skew_degrees"); - ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform", PROPERTY_HINT_NONE, "", 0), "set_transform", "get_transform"); + ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_transform", "get_transform"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_position", PROPERTY_HINT_NONE, "", 0), "set_global_position", "get_global_position"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_rotation", PROPERTY_HINT_NONE, "", 0), "set_global_rotation", "get_global_rotation"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_rotation_degrees", PROPERTY_HINT_NONE, "", 0), "set_global_rotation_degrees", "get_global_rotation_degrees"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_scale", PROPERTY_HINT_NONE, "", 0), "set_global_scale", "get_global_scale"); - ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "global_transform", PROPERTY_HINT_NONE, "", 0), "set_global_transform", "get_global_transform"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_position", "get_global_position"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_rotation", "get_global_rotation"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "global_rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_rotation_degrees", "get_global_rotation_degrees"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_scale", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_scale", "get_global_scale"); + ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "global_transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_transform", "get_global_transform"); ADD_GROUP("Ordering", ""); ADD_PROPERTY(PropertyInfo(Variant::INT, "z_index", PROPERTY_HINT_RANGE, itos(RS::CANVAS_ITEM_Z_MIN) + "," + itos(RS::CANVAS_ITEM_Z_MAX) + ",1"), "set_z_index", "get_z_index"); diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 4b72043a46..ce63b25ce0 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -856,7 +856,7 @@ void RigidBody2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Dynamic,Static,DynamicLocked,Kinematic"), "set_mode", "get_mode"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "mass", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01"), "set_mass", "get_mass"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inertia", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01", 0), "set_inertia", "get_inertia"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inertia", PROPERTY_HINT_EXP_RANGE, "0.01,65535,0.01", PROPERTY_USAGE_NONE), "set_inertia", "get_inertia"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "physics_material_override", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsMaterial"), "set_physics_material_override", "get_physics_material_override"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "gravity_scale", PROPERTY_HINT_RANGE, "-128,128,0.01"), "set_gravity_scale", "get_gravity_scale"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "custom_integrator"), "set_use_custom_integrator", "is_using_custom_integrator"); @@ -1352,6 +1352,10 @@ ObjectID KinematicCollision2D::get_collider_id() const { return result.collider_id; } +RID KinematicCollision2D::get_collider_rid() const { + return result.collider; +} + Object *KinematicCollision2D::get_collider_shape() const { Object *collider = get_collider(); if (collider) { @@ -1385,6 +1389,7 @@ void KinematicCollision2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_local_shape"), &KinematicCollision2D::get_local_shape); ClassDB::bind_method(D_METHOD("get_collider"), &KinematicCollision2D::get_collider); ClassDB::bind_method(D_METHOD("get_collider_id"), &KinematicCollision2D::get_collider_id); + ClassDB::bind_method(D_METHOD("get_collider_rid"), &KinematicCollision2D::get_collider_rid); ClassDB::bind_method(D_METHOD("get_collider_shape"), &KinematicCollision2D::get_collider_shape); ClassDB::bind_method(D_METHOD("get_collider_shape_index"), &KinematicCollision2D::get_collider_shape_index); ClassDB::bind_method(D_METHOD("get_collider_velocity"), &KinematicCollision2D::get_collider_velocity); @@ -1397,6 +1402,7 @@ void KinematicCollision2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "local_shape"), "", "get_local_shape"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "collider"), "", "get_collider"); ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_id"), "", "get_collider_id"); + ADD_PROPERTY(PropertyInfo(Variant::RID, "collider_rid"), "", "get_collider_rid"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "collider_shape"), "", "get_collider_shape"); ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_shape_index"), "", "get_collider_shape_index"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "collider_velocity"), "", "get_collider_velocity"); diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index 423f792132..f084a247aa 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -357,6 +357,7 @@ public: Object *get_local_shape() const; Object *get_collider() const; ObjectID get_collider_id() const; + RID get_collider_rid() const; Object *get_collider_shape() const; int get_collider_shape_index() const; Vector2 get_collider_velocity() const; diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index 21083e6a4b..1eec2a3833 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -658,7 +658,7 @@ void Polygon2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture_offset"), "set_texture_offset", "get_texture_offset"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture_scale"), "set_texture_scale", "get_texture_scale"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "texture_rotation_degrees", PROPERTY_HINT_RANGE, "-360,360,0.1,or_lesser,or_greater"), "set_texture_rotation_degrees", "get_texture_rotation_degrees"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "texture_rotation", PROPERTY_HINT_NONE, "", 0), "set_texture_rotation", "get_texture_rotation"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "texture_rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_texture_rotation", "get_texture_rotation"); ADD_GROUP("Skeleton", ""); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "skeleton", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Skeleton2D"), "set_skeleton", "get_skeleton"); diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp index e96b8ee1f9..f78a2ff14e 100644 --- a/scene/3d/node_3d.cpp +++ b/scene/3d/node_3d.cpp @@ -813,10 +813,10 @@ void Node3D::_bind_methods() { //ADD_PROPERTY( PropertyInfo(Variant::TRANSFORM3D,"transform/global",PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR ), "set_global_transform", "get_global_transform") ; ADD_GROUP("Transform", ""); - ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "global_transform", PROPERTY_HINT_NONE, "", 0), "set_global_transform", "get_global_transform"); + ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "global_transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_transform", "get_global_transform"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_position", "get_position"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_rotation_degrees", "get_rotation_degrees"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation", PROPERTY_HINT_NONE, "", 0), "set_rotation", "get_rotation"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_rotation", "get_rotation"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_scale", "get_scale"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "top_level"), "set_as_top_level", "is_set_as_top_level"); ADD_GROUP("Matrix", ""); @@ -824,7 +824,7 @@ void Node3D::_bind_methods() { ADD_GROUP("Visibility", ""); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "visible"), "set_visible", "is_visible"); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "visibility_parent", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "GeometryInstance3D"), "set_visibility_parent", "get_visibility_parent"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "gizmo", PROPERTY_HINT_RESOURCE_TYPE, "Node3DGizmo", 0), "set_gizmo", "get_gizmo"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "gizmo", PROPERTY_HINT_RESOURCE_TYPE, "Node3DGizmo", PROPERTY_USAGE_NONE), "set_gizmo", "get_gizmo"); ADD_SIGNAL(MethodInfo("visibility_changed")); } diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index 25c7c3d798..28a0c72fe3 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -1337,6 +1337,10 @@ ObjectID KinematicCollision3D::get_collider_id() const { return result.collider_id; } +RID KinematicCollision3D::get_collider_rid() const { + return result.collider; +} + Object *KinematicCollision3D::get_collider_shape() const { Object *collider = get_collider(); if (collider) { @@ -1370,6 +1374,7 @@ void KinematicCollision3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_local_shape"), &KinematicCollision3D::get_local_shape); ClassDB::bind_method(D_METHOD("get_collider"), &KinematicCollision3D::get_collider); ClassDB::bind_method(D_METHOD("get_collider_id"), &KinematicCollision3D::get_collider_id); + ClassDB::bind_method(D_METHOD("get_collider_rid"), &KinematicCollision3D::get_collider_rid); ClassDB::bind_method(D_METHOD("get_collider_shape"), &KinematicCollision3D::get_collider_shape); ClassDB::bind_method(D_METHOD("get_collider_shape_index"), &KinematicCollision3D::get_collider_shape_index); ClassDB::bind_method(D_METHOD("get_collider_velocity"), &KinematicCollision3D::get_collider_velocity); @@ -1382,6 +1387,7 @@ void KinematicCollision3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "local_shape"), "", "get_local_shape"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "collider"), "", "get_collider"); ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_id"), "", "get_collider_id"); + ADD_PROPERTY(PropertyInfo(Variant::RID, "collider_rid"), "", "get_collider_rid"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "collider_shape"), "", "get_collider_shape"); ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_shape_index"), "", "get_collider_shape_index"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "collider_velocity"), "", "get_collider_velocity"); @@ -2187,7 +2193,7 @@ void PhysicalBone3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "joint_type", PROPERTY_HINT_ENUM, "None,PinJoint,ConeJoint,HingeJoint,SliderJoint,6DOFJoint"), "set_joint_type", "get_joint_type"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "joint_offset"), "set_joint_offset", "get_joint_offset"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "joint_rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_joint_rotation_degrees", "get_joint_rotation_degrees"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "joint_rotation", PROPERTY_HINT_NONE, "", 0), "set_joint_rotation", "get_joint_rotation"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "joint_rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_joint_rotation", "get_joint_rotation"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "body_offset"), "set_body_offset", "get_body_offset"); diff --git a/scene/3d/physics_body_3d.h b/scene/3d/physics_body_3d.h index 8df3635be0..7d7adf1624 100644 --- a/scene/3d/physics_body_3d.h +++ b/scene/3d/physics_body_3d.h @@ -358,6 +358,7 @@ public: Object *get_local_shape() const; Object *get_collider() const; ObjectID get_collider_id() const; + RID get_collider_rid() const; Object *get_collider_shape() const; int get_collider_shape_index() const; Vector3 get_collider_velocity() const; diff --git a/scene/3d/ray_cast_3d.cpp b/scene/3d/ray_cast_3d.cpp index db841101e5..dfab3d4a17 100644 --- a/scene/3d/ray_cast_3d.cpp +++ b/scene/3d/ray_cast_3d.cpp @@ -419,6 +419,8 @@ void RayCast3D::_update_debug_shape_material(bool p_check_collision) { debug_material = material; material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + // Use double-sided rendering so that the RayCast can be seen if the camera is inside. + material->set_cull_mode(BaseMaterial3D::CULL_DISABLED); material->set_transparency(BaseMaterial3D::TRANSPARENCY_ALPHA); } diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 2d565fc47a..e3748a4ae1 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -1657,16 +1657,16 @@ void AnimationPlayer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "root_node"), "set_root", "get_root"); ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "current_animation", PROPERTY_HINT_ENUM, "", PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_ANIMATE_AS_TRIGGER), "set_current_animation", "get_current_animation"); - ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "assigned_animation", PROPERTY_HINT_NONE, "", 0), "set_assigned_animation", "get_assigned_animation"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "assigned_animation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_assigned_animation", "get_assigned_animation"); ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "autoplay", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_autoplay", "get_autoplay"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "reset_on_save", PROPERTY_HINT_NONE, ""), "set_reset_on_save_enabled", "is_reset_on_save_enabled"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "current_animation_length", PROPERTY_HINT_NONE, "", 0), "", "get_current_animation_length"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "current_animation_position", PROPERTY_HINT_NONE, "", 0), "", "get_current_animation_position"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "current_animation_length", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_current_animation_length"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "current_animation_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_current_animation_position"); ADD_GROUP("Playback Options", "playback_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Physics,Idle,Manual"), "set_process_callback", "get_process_callback"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "playback_default_blend_time", PROPERTY_HINT_RANGE, "0,4096,0.01"), "set_default_blend_time", "get_default_blend_time"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playback_active", PROPERTY_HINT_NONE, "", 0), "set_active", "is_active"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playback_active", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_active", "is_active"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "playback_speed", PROPERTY_HINT_RANGE, "-64,64,0.01"), "set_speed_scale", "get_speed_scale"); ADD_PROPERTY(PropertyInfo(Variant::INT, "method_call_mode", PROPERTY_HINT_ENUM, "Deferred,Immediate"), "set_method_call_mode", "get_method_call_mode"); diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index b4e597f75e..7bf616e602 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -30,535 +30,407 @@ #include "tween.h" -void Tween::_add_pending_command(StringName p_key, const Variant &p_arg1, const Variant &p_arg2, const Variant &p_arg3, const Variant &p_arg4, const Variant &p_arg5, const Variant &p_arg6, const Variant &p_arg7, const Variant &p_arg8, const Variant &p_arg9, const Variant &p_arg10) { - // Add a new pending command and reference it - pending_commands.push_back(PendingCommand()); - PendingCommand &cmd = pending_commands.back()->get(); - - // Update the command with the target key - cmd.key = p_key; - - // Determine command argument count - int &count = cmd.args; - if (p_arg10.get_type() != Variant::NIL) { - count = 10; - } else if (p_arg9.get_type() != Variant::NIL) { - count = 9; - } else if (p_arg8.get_type() != Variant::NIL) { - count = 8; - } else if (p_arg7.get_type() != Variant::NIL) { - count = 7; - } else if (p_arg6.get_type() != Variant::NIL) { - count = 6; - } else if (p_arg5.get_type() != Variant::NIL) { - count = 5; - } else if (p_arg4.get_type() != Variant::NIL) { - count = 4; - } else if (p_arg3.get_type() != Variant::NIL) { - count = 3; - } else if (p_arg2.get_type() != Variant::NIL) { - count = 2; - } else if (p_arg1.get_type() != Variant::NIL) { - count = 1; - } else { - count = 0; - } +#include "scene/main/node.h" - // Add the specified arguments to the command - if (count > 0) { - cmd.arg[0] = p_arg1; - } - if (count > 1) { - cmd.arg[1] = p_arg2; - } - if (count > 2) { - cmd.arg[2] = p_arg3; - } - if (count > 3) { - cmd.arg[3] = p_arg4; - } - if (count > 4) { - cmd.arg[4] = p_arg5; - } - if (count > 5) { - cmd.arg[5] = p_arg6; - } - if (count > 6) { - cmd.arg[6] = p_arg7; - } - if (count > 7) { - cmd.arg[7] = p_arg8; - } - if (count > 8) { - cmd.arg[8] = p_arg9; +void Tweener::set_tween(Ref<Tween> p_tween) { + tween = p_tween; +} + +void Tweener::_bind_methods() { + ADD_SIGNAL(MethodInfo("finished")); +} + +void Tween::start_tweeners() { + if (tweeners.is_empty()) { + dead = true; + ERR_FAIL_MSG("Tween without commands, aborting."); } - if (count > 9) { - cmd.arg[9] = p_arg10; + + for (List<Ref<Tweener>>::Element *E = tweeners.write[current_step].front(); E; E = E->next()) { + E->get()->start(); } } -void Tween::_process_pending_commands() { - // For each pending command... - for (List<PendingCommand>::Element *E = pending_commands.front(); E; E = E->next()) { - // Get the command - PendingCommand &cmd = E->get(); - Callable::CallError err; - - // Grab all of the arguments for the command - Variant *arg[10] = { - &cmd.arg[0], - &cmd.arg[1], - &cmd.arg[2], - &cmd.arg[3], - &cmd.arg[4], - &cmd.arg[5], - &cmd.arg[6], - &cmd.arg[7], - &cmd.arg[8], - &cmd.arg[9], - }; - - // Execute the command (and retrieve any errors) - this->call(cmd.key, (const Variant **)arg, cmd.args, err); - } +Ref<PropertyTweener> Tween::tween_property(Object *p_target, NodePath p_property, Variant p_to, float p_duration) { + ERR_FAIL_NULL_V(p_target, nullptr); + ERR_FAIL_COND_V_MSG(invalid, nullptr, "Tween was created outside the scene tree, can't use Tweeners."); + ERR_FAIL_COND_V_MSG(started, nullptr, "Can't append to a Tween that has started. Use stop() first."); - // Clear the pending commands - pending_commands.clear(); + Ref<PropertyTweener> tweener = memnew(PropertyTweener(p_target, p_property, p_to, p_duration)); + append(tweener); + return tweener; } -bool Tween::_set(const StringName &p_name, const Variant &p_value) { - // Set the correct attribute based on the given name - String name = p_name; - if (name == "playback/speed" || name == "speed") { // Backwards compatibility - set_speed_scale(p_value); - return true; +Ref<IntervalTweener> Tween::tween_interval(float p_time) { + ERR_FAIL_COND_V_MSG(invalid, nullptr, "Tween was created outside the scene tree, can't use Tweeners."); + ERR_FAIL_COND_V_MSG(started, nullptr, "Can't append to a Tween that has started. Use stop() first."); - } else if (name == "playback/active") { - set_active(p_value); - return true; + Ref<IntervalTweener> tweener = memnew(IntervalTweener(p_time)); + append(tweener); + return tweener; +} - } else if (name == "playback/repeat") { - set_repeat(p_value); - return true; - } - return false; +Ref<CallbackTweener> Tween::tween_callback(Callable p_callback) { + ERR_FAIL_COND_V_MSG(invalid, nullptr, "Tween was created outside the scene tree, can't use Tweeners."); + ERR_FAIL_COND_V_MSG(started, nullptr, "Can't append to a Tween that has started. Use stop() first."); + + Ref<CallbackTweener> tweener = memnew(CallbackTweener(p_callback)); + append(tweener); + return tweener; } -bool Tween::_get(const StringName &p_name, Variant &r_ret) const { - // Get the correct attribute based on the given name - String name = p_name; - if (name == "playback/speed") { // Backwards compatibility - r_ret = speed_scale; - return true; +Ref<MethodTweener> Tween::tween_method(Callable p_callback, float p_from, float p_to, float p_duration) { + ERR_FAIL_COND_V_MSG(invalid, nullptr, "Tween was created outside the scene tree, can't use Tweeners."); + ERR_FAIL_COND_V_MSG(started, nullptr, "Can't append to a Tween that has started. Use stop() first."); - } else if (name == "playback/active") { - r_ret = is_active(); - return true; + Ref<MethodTweener> tweener = memnew(MethodTweener(p_callback, p_from, p_to, p_duration)); + append(tweener); + return tweener; +} - } else if (name == "playback/repeat") { - r_ret = is_repeat(); - return true; +Ref<Tween> Tween::append(Ref<Tweener> p_tweener) { + ERR_FAIL_COND_V_MSG(invalid, nullptr, "Tween was created outside the scene tree, can't use Tweeners."); + ERR_FAIL_COND_V_MSG(started, nullptr, "Can't append to a Tween that has started. Use stop() first."); + p_tweener->set_tween(this); + + if (parallel_enabled) { + current_step = MAX(current_step, 0); + } else { + current_step++; } - return false; -} - -void Tween::_get_property_list(List<PropertyInfo> *p_list) const { - // Add the property info for the Tween object - p_list->push_back(PropertyInfo(Variant::BOOL, "playback/active", PROPERTY_HINT_NONE, "")); - p_list->push_back(PropertyInfo(Variant::BOOL, "playback/repeat", PROPERTY_HINT_NONE, "")); - p_list->push_back(PropertyInfo(Variant::FLOAT, "playback/speed", PROPERTY_HINT_RANGE, "-64,64,0.01")); -} - -void Tween::_notification(int p_what) { - // What notification did we receive? - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - // Are we not already active? - if (!is_active()) { - // Make sure that a previous process state was not saved - // Only process if "processing" is set - set_physics_process_internal(false); - set_process_internal(false); - } - } break; + parallel_enabled = default_parallel; - case NOTIFICATION_READY: { - // Do nothing - } break; + tweeners.resize(current_step + 1); + tweeners.write[current_step].push_back(p_tweener); - case NOTIFICATION_INTERNAL_PROCESS: { - // Are we processing during physics time? - if (tween_process_mode == TWEEN_PROCESS_PHYSICS) { - // Do nothing since we aren't aligned with physics when we should be - break; - } + return this; +} - // Should we update? - if (is_active()) { - // Update the tweens - _tween_process(get_process_delta_time()); - } - } break; +void Tween::stop() { + started = false; + running = false; + dead = false; +} - case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { - // Are we processing during 'regular' time? - if (tween_process_mode == TWEEN_PROCESS_IDLE) { - // Do nothing since we would only process during idle time - break; - } +void Tween::pause() { + running = false; +} - // Should we update? - if (is_active()) { - // Update the tweens - _tween_process(get_physics_process_delta_time()); - } - } break; +void Tween::play() { + ERR_FAIL_COND_MSG(invalid, "Tween invalid, can't play."); + ERR_FAIL_COND_MSG(dead, "Can't play finished Tween, use stop() first to reset its state."); + running = true; +} - case NOTIFICATION_EXIT_TREE: { - // We've left the tree. Stop all tweens - stop_all(); - } break; - } +void Tween::kill() { + running = false; // For the sake of is_running(). + dead = true; } -void Tween::_bind_methods() { - // Bind getters and setters - ClassDB::bind_method(D_METHOD("is_active"), &Tween::is_active); - ClassDB::bind_method(D_METHOD("set_active", "active"), &Tween::set_active); +bool Tween::is_running() { + return running; +} - ClassDB::bind_method(D_METHOD("is_repeat"), &Tween::is_repeat); - ClassDB::bind_method(D_METHOD("set_repeat", "repeat"), &Tween::set_repeat); +void Tween::set_valid(bool p_valid) { + invalid = !p_valid; +} - ClassDB::bind_method(D_METHOD("set_speed_scale", "speed"), &Tween::set_speed_scale); - ClassDB::bind_method(D_METHOD("get_speed_scale"), &Tween::get_speed_scale); - - ClassDB::bind_method(D_METHOD("set_tween_process_mode", "mode"), &Tween::set_tween_process_mode); - ClassDB::bind_method(D_METHOD("get_tween_process_mode"), &Tween::get_tween_process_mode); - - // Bind the various Tween control methods - ClassDB::bind_method(D_METHOD("start"), &Tween::start); - ClassDB::bind_method(D_METHOD("reset", "object", "key"), &Tween::reset, DEFVAL("")); - ClassDB::bind_method(D_METHOD("reset_all"), &Tween::reset_all); - ClassDB::bind_method(D_METHOD("stop", "object", "key"), &Tween::stop, DEFVAL("")); - ClassDB::bind_method(D_METHOD("stop_all"), &Tween::stop_all); - ClassDB::bind_method(D_METHOD("resume", "object", "key"), &Tween::resume, DEFVAL("")); - ClassDB::bind_method(D_METHOD("resume_all"), &Tween::resume_all); - ClassDB::bind_method(D_METHOD("remove", "object", "key"), &Tween::remove, DEFVAL("")); - ClassDB::bind_method(D_METHOD("_remove_by_uid", "uid"), &Tween::_remove_by_uid); - ClassDB::bind_method(D_METHOD("remove_all"), &Tween::remove_all); - ClassDB::bind_method(D_METHOD("seek", "time"), &Tween::seek); - ClassDB::bind_method(D_METHOD("tell"), &Tween::tell); - ClassDB::bind_method(D_METHOD("get_runtime"), &Tween::get_runtime); - - // Bind interpolation and follow methods - ClassDB::bind_method(D_METHOD("interpolate_property", "object", "property", "initial_val", "final_val", "duration", "trans_type", "ease_type", "delay"), &Tween::interpolate_property, DEFVAL(TRANS_LINEAR), DEFVAL(EASE_IN_OUT), DEFVAL(0)); - ClassDB::bind_method(D_METHOD("interpolate_method", "object", "method", "initial_val", "final_val", "duration", "trans_type", "ease_type", "delay"), &Tween::interpolate_method, DEFVAL(TRANS_LINEAR), DEFVAL(EASE_IN_OUT), DEFVAL(0)); - ClassDB::bind_method(D_METHOD("interpolate_callback", "object", "duration", "callback", "arg1", "arg2", "arg3", "arg4", "arg5"), &Tween::interpolate_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant())); - ClassDB::bind_method(D_METHOD("interpolate_deferred_callback", "object", "duration", "callback", "arg1", "arg2", "arg3", "arg4", "arg5"), &Tween::interpolate_deferred_callback, DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant())); - ClassDB::bind_method(D_METHOD("follow_property", "object", "property", "initial_val", "target", "target_property", "duration", "trans_type", "ease_type", "delay"), &Tween::follow_property, DEFVAL(TRANS_LINEAR), DEFVAL(EASE_IN_OUT), DEFVAL(0)); - ClassDB::bind_method(D_METHOD("follow_method", "object", "method", "initial_val", "target", "target_method", "duration", "trans_type", "ease_type", "delay"), &Tween::follow_method, DEFVAL(TRANS_LINEAR), DEFVAL(EASE_IN_OUT), DEFVAL(0)); - ClassDB::bind_method(D_METHOD("targeting_property", "object", "property", "initial", "initial_val", "final_val", "duration", "trans_type", "ease_type", "delay"), &Tween::targeting_property, DEFVAL(TRANS_LINEAR), DEFVAL(EASE_IN_OUT), DEFVAL(0)); - ClassDB::bind_method(D_METHOD("targeting_method", "object", "method", "initial", "initial_method", "final_val", "duration", "trans_type", "ease_type", "delay"), &Tween::targeting_method, DEFVAL(TRANS_LINEAR), DEFVAL(EASE_IN_OUT), DEFVAL(0)); - - // Add the Tween signals - ADD_SIGNAL(MethodInfo("tween_started", PropertyInfo(Variant::OBJECT, "object"), PropertyInfo(Variant::NODE_PATH, "key"))); - ADD_SIGNAL(MethodInfo("tween_step", PropertyInfo(Variant::OBJECT, "object"), PropertyInfo(Variant::NODE_PATH, "key"), PropertyInfo(Variant::FLOAT, "elapsed"), PropertyInfo(Variant::OBJECT, "value"))); - ADD_SIGNAL(MethodInfo("tween_completed", PropertyInfo(Variant::OBJECT, "object"), PropertyInfo(Variant::NODE_PATH, "key"))); - ADD_SIGNAL(MethodInfo("tween_all_completed")); - - // Add the properties and tie them to the getters and setters - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "repeat"), "set_repeat", "is_repeat"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Physics,Idle"), "set_tween_process_mode", "get_tween_process_mode"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "playback_speed", PROPERTY_HINT_RANGE, "-64,64,0.01"), "set_speed_scale", "get_speed_scale"); - - // Bind Idle vs Physics process - BIND_ENUM_CONSTANT(TWEEN_PROCESS_PHYSICS); - BIND_ENUM_CONSTANT(TWEEN_PROCESS_IDLE); +bool Tween::is_valid() { + return invalid; +} - // Bind the Transition type constants - BIND_ENUM_CONSTANT(TRANS_LINEAR); - BIND_ENUM_CONSTANT(TRANS_SINE); - BIND_ENUM_CONSTANT(TRANS_QUINT); - BIND_ENUM_CONSTANT(TRANS_QUART); - BIND_ENUM_CONSTANT(TRANS_QUAD); - BIND_ENUM_CONSTANT(TRANS_EXPO); - BIND_ENUM_CONSTANT(TRANS_ELASTIC); - BIND_ENUM_CONSTANT(TRANS_CUBIC); - BIND_ENUM_CONSTANT(TRANS_CIRC); - BIND_ENUM_CONSTANT(TRANS_BOUNCE); - BIND_ENUM_CONSTANT(TRANS_BACK); +Ref<Tween> Tween::bind_node(Node *p_node) { + bound_node = p_node->get_instance_id(); + is_bound = true; + return this; +} - // Bind the easing constants - BIND_ENUM_CONSTANT(EASE_IN); - BIND_ENUM_CONSTANT(EASE_OUT); - BIND_ENUM_CONSTANT(EASE_IN_OUT); - BIND_ENUM_CONSTANT(EASE_OUT_IN); +Ref<Tween> Tween::set_process_mode(TweenProcessMode p_mode) { + process_mode = p_mode; + return this; } -Variant Tween::_get_initial_val(const InterpolateData &p_data) const { - // What type of data are we interpolating? - switch (p_data.type) { - case INTER_PROPERTY: - case INTER_METHOD: - case FOLLOW_PROPERTY: - case FOLLOW_METHOD: - // Simply use the given initial value - return p_data.initial_val; - - case TARGETING_PROPERTY: - case TARGETING_METHOD: { - // Get the object that is being targeted - Object *object = ObjectDB::get_instance(p_data.target_id); - ERR_FAIL_COND_V(object == nullptr, p_data.initial_val); - - // Are we targeting a property or a method? - Variant initial_val; - if (p_data.type == TARGETING_PROPERTY) { - // Get the property from the target object - bool valid = false; - initial_val = object->get_indexed(p_data.target_key, &valid); - ERR_FAIL_COND_V(!valid, p_data.initial_val); - } else { - // Call the method and get the initial value from it - Callable::CallError error; - initial_val = object->call(p_data.target_key[0], nullptr, 0, error); - ERR_FAIL_COND_V(error.error != Callable::CallError::CALL_OK, p_data.initial_val); - } - return initial_val; - } +Tween::TweenProcessMode Tween::get_process_mode() { + return process_mode; +} + +Ref<Tween> Tween::set_pause_mode(TweenPauseMode p_mode) { + pause_mode = p_mode; + return this; +} + +Tween::TweenPauseMode Tween::get_pause_mode() { + return pause_mode; +} + +Ref<Tween> Tween::set_parallel(bool p_parallel) { + default_parallel = p_parallel; + parallel_enabled = p_parallel; + return this; +} + +Ref<Tween> Tween::set_loops(int p_loops) { + loops = p_loops; + return this; +} + +Ref<Tween> Tween::set_speed_scale(float p_speed) { + speed_scale = p_speed; + return this; +} + +Ref<Tween> Tween::set_trans(TransitionType p_trans) { + default_transition = p_trans; + return this; +} - case INTER_CALLBACK: - // Callback does not have a special initial value - break; +Tween::TransitionType Tween::get_trans() { + return default_transition; +} + +Ref<Tween> Tween::set_ease(EaseType p_ease) { + default_ease = p_ease; + return this; +} + +Tween::EaseType Tween::get_ease() { + return default_ease; +} + +Ref<Tween> Tween::parallel() { + parallel_enabled = true; + return this; +} + +Ref<Tween> Tween::chain() { + parallel_enabled = false; + return this; +} + +bool Tween::custom_step(float p_delta) { + bool r = running; + running = true; + bool ret = step(p_delta); + running = running && r; // Running might turn false when Tween finished. + return ret; +} + +bool Tween::step(float p_delta) { + ERR_FAIL_COND_V_MSG(tweeners.is_empty(), false, "Tween started, but has no Tweeners."); + + if (dead) { + return false; } - // If we've made it here, just return the delta value as the initial value - return p_data.delta_val; -} - -Variant Tween::_get_final_val(const InterpolateData &p_data) const { - switch (p_data.type) { - case FOLLOW_PROPERTY: - case FOLLOW_METHOD: { - // Get the object that is being followed - Object *target = ObjectDB::get_instance(p_data.target_id); - ERR_FAIL_COND_V(target == nullptr, p_data.initial_val); - - // We want to figure out the final value - Variant final_val; - if (p_data.type == FOLLOW_PROPERTY) { - // Read the property as-is - bool valid = false; - final_val = target->get_indexed(p_data.target_key, &valid); - ERR_FAIL_COND_V(!valid, p_data.initial_val); - } else { - // We're looking at a method. Call the method on the target object - Callable::CallError error; - final_val = target->call(p_data.target_key[0], nullptr, 0, error); - ERR_FAIL_COND_V(error.error != Callable::CallError::CALL_OK, p_data.initial_val); - } - // If we're looking at an INT value, instead convert it to a FLOAT - // This is better for interpolation - if (final_val.get_type() == Variant::INT) { - final_val = final_val.operator real_t(); - } + if (!running) { + return true; + } - return final_val; - } - default: { - // If we're not following a final value/method, use the final value from the data - return p_data.final_val; + if (is_bound) { + Object *bound_instance = ObjectDB::get_instance(bound_node); + if (bound_instance) { + Node *bound_node = Object::cast_to<Node>(bound_instance); + // This can't by anything else than Node, so we can omit checking if casting succeeded. + if (!bound_node->is_inside_tree()) { + return true; + } + } else { + return false; } } -} -Variant &Tween::_get_delta_val(InterpolateData &p_data) { - // What kind of data are we interpolating? - switch (p_data.type) { - case INTER_PROPERTY: - case INTER_METHOD: - // Simply return the given delta value - return p_data.delta_val; - - case FOLLOW_PROPERTY: - case FOLLOW_METHOD: { - // We're following an object, so grab that instance - Object *target = ObjectDB::get_instance(p_data.target_id); - ERR_FAIL_COND_V(target == nullptr, p_data.initial_val); - - // We want to figure out the final value - Variant final_val; - if (p_data.type == FOLLOW_PROPERTY) { - // Read the property as-is - bool valid = false; - final_val = target->get_indexed(p_data.target_key, &valid); - ERR_FAIL_COND_V(!valid, p_data.initial_val); - } else { - // We're looking at a method. Call the method on the target object - Callable::CallError error; - final_val = target->call(p_data.target_key[0], nullptr, 0, error); - ERR_FAIL_COND_V(error.error != Callable::CallError::CALL_OK, p_data.initial_val); - } + if (!started) { + current_step = 0; + loops_done = 0; + start_tweeners(); + started = true; + } - // If we're looking at an INT value, instead convert it to a FLOAT - // This is better for interpolation - if (final_val.get_type() == Variant::INT) { - final_val = final_val.operator real_t(); - } + float rem_delta = p_delta * speed_scale; + bool step_active = false; - // Calculate the delta based on the initial value and the final value - _calc_delta_val(p_data.initial_val, final_val, p_data.delta_val); - return p_data.delta_val; + while (rem_delta > 0 && running) { + float step_delta = rem_delta; + step_active = false; + + for (List<Ref<Tweener>>::Element *E = tweeners.write[current_step].front(); E; E = E->next()) { + // Modified inside Tweener.step(). + float temp_delta = rem_delta; + // Turns to true if any Tweener returns true (i.e. is still not finished). + step_active = E->get()->step(temp_delta) || step_active; + step_delta = MIN(temp_delta, rem_delta); } - case TARGETING_PROPERTY: - case TARGETING_METHOD: { - // Grab the initial value from the data to calculate delta - Variant initial_val = _get_initial_val(p_data); + rem_delta = step_delta; - // If we're looking at an INT value, instead convert it to a FLOAT - // This is better for interpolation - if (initial_val.get_type() == Variant::INT) { - initial_val = initial_val.operator real_t(); - } + if (!step_active) { + emit_signal("step_finished", current_step); + current_step++; - // Calculate the delta based on the initial value and the final value - _calc_delta_val(initial_val, p_data.final_val, p_data.delta_val); - return p_data.delta_val; + if (current_step == tweeners.size()) { + loops_done++; + if (loops_done == loops) { + running = false; + dead = true; + emit_signal("finished"); + } else { + emit_signal("loop_finished", loops_done); + current_step = 0; + start_tweeners(); + } + } else { + start_tweeners(); + } } + } + + return true; +} - case INTER_CALLBACK: - // Callbacks have no special delta - break; +bool Tween::should_pause() { + if (is_bound && pause_mode == TWEEN_PAUSE_BOUND) { + Object *bound_instance = ObjectDB::get_instance(bound_node); + if (bound_instance) { + Node *bound_node = Object::cast_to<Node>(bound_instance); + return !bound_node->can_process(); + } } - // If we've made it here, use the initial value as the delta - return p_data.initial_val; + + return pause_mode != TWEEN_PAUSE_PROCESS; } -Variant Tween::_run_equation(InterpolateData &p_data) { - // Get the initial and delta values from the data - Variant initial_val = _get_initial_val(p_data); - Variant &delta_val = _get_delta_val(p_data); - Variant result; +Variant Tween::interpolate_variant(Variant p_initial_val, Variant p_delta_val, float p_time, float p_duration, TransitionType p_trans, EaseType p_ease) { + ERR_FAIL_INDEX_V(p_trans, TransitionType::TRANS_MAX, Variant()); + ERR_FAIL_INDEX_V(p_ease, EaseType::EASE_MAX, Variant()); +// Helper macro to run equation on sub-elements of the value (e.g. x and y of Vector2). #define APPLY_EQUATION(element) \ - r.element = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, i.element, d.element, p_data.duration); + r.element = run_equation(p_trans, p_ease, p_time, i.element, d.element, p_duration); - // What type of data are we interpolating? - switch (initial_val.get_type()) { - case Variant::BOOL: - // Run the boolean specific equation (checking if it is at least 0.5) - result = (_run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, initial_val, delta_val, p_data.duration)) >= 0.5; - break; + switch (p_initial_val.get_type()) { + case Variant::BOOL: { + return (run_equation(p_trans, p_ease, p_time, p_initial_val, p_delta_val, p_duration)) >= 0.5; + } - case Variant::INT: - // Run the integer specific equation - result = (int)_run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (int)initial_val, (int)delta_val, p_data.duration); - break; + case Variant::INT: { + return (int)run_equation(p_trans, p_ease, p_time, (int)p_initial_val, (int)p_delta_val, p_duration); + } - case Variant::FLOAT: - // Run the FLOAT specific equation - result = _run_equation(p_data.trans_type, p_data.ease_type, p_data.elapsed - p_data.delay, (real_t)initial_val, (real_t)delta_val, p_data.duration); - break; + case Variant::FLOAT: { + return run_equation(p_trans, p_ease, p_time, (real_t)p_initial_val, (real_t)p_delta_val, p_duration); + } case Variant::VECTOR2: { - // Get vectors for initial and delta values - Vector2 i = initial_val; - Vector2 d = delta_val; + Vector2 i = p_initial_val; + Vector2 d = p_delta_val; Vector2 r; - // Execute the equation and mutate the r vector - // This uses the custom APPLY_EQUATION macro defined above APPLY_EQUATION(x); APPLY_EQUATION(y); - result = r; - } break; + return r; + } + + case Variant::VECTOR2I: { + Vector2i i = p_initial_val; + Vector2i d = p_delta_val; + Vector2i r; + + APPLY_EQUATION(x); + APPLY_EQUATION(y); + return r; + } case Variant::RECT2: { - // Get the Rect2 for initial and delta value - Rect2 i = initial_val; - Rect2 d = delta_val; + Rect2 i = p_initial_val; + Rect2 d = p_delta_val; Rect2 r; - // Execute the equation for the position and size of Rect2 APPLY_EQUATION(position.x); APPLY_EQUATION(position.y); APPLY_EQUATION(size.x); APPLY_EQUATION(size.y); - result = r; - } break; + return r; + } + + case Variant::RECT2I: { + Rect2i i = p_initial_val; + Rect2i d = p_delta_val; + Rect2i r; + + APPLY_EQUATION(position.x); + APPLY_EQUATION(position.y); + APPLY_EQUATION(size.x); + APPLY_EQUATION(size.y); + return r; + } case Variant::VECTOR3: { - // Get vectors for initial and delta values - Vector3 i = initial_val; - Vector3 d = delta_val; + Vector3 i = p_initial_val; + Vector3 d = p_delta_val; Vector3 r; - // Execute the equation and mutate the r vector - // This uses the custom APPLY_EQUATION macro defined above APPLY_EQUATION(x); APPLY_EQUATION(y); APPLY_EQUATION(z); - result = r; - } break; + return r; + } + + case Variant::VECTOR3I: { + Vector3i i = p_initial_val; + Vector3i d = p_delta_val; + Vector3i r; + + APPLY_EQUATION(x); + APPLY_EQUATION(y); + APPLY_EQUATION(z); + return r; + } case Variant::TRANSFORM2D: { - // Get the transforms for initial and delta values - Transform2D i = initial_val; - Transform2D d = delta_val; + Transform2D i = p_initial_val; + Transform2D d = p_delta_val; Transform2D r; - // Execute the equation on the transforms and mutate the r transform - // This uses the custom APPLY_EQUATION macro defined above APPLY_EQUATION(elements[0][0]); APPLY_EQUATION(elements[0][1]); APPLY_EQUATION(elements[1][0]); APPLY_EQUATION(elements[1][1]); APPLY_EQUATION(elements[2][0]); APPLY_EQUATION(elements[2][1]); - result = r; - } break; + return r; + } case Variant::QUATERNION: { - // Get the quaternian for the initial and delta values - Quaternion i = initial_val; - Quaternion d = delta_val; + Quaternion i = p_initial_val; + Quaternion d = p_delta_val; Quaternion r; - // Execute the equation on the quaternian values and mutate the r quaternian - // This uses the custom APPLY_EQUATION macro defined above APPLY_EQUATION(x); APPLY_EQUATION(y); APPLY_EQUATION(z); APPLY_EQUATION(w); - result = r; - } break; + return r; + } case Variant::AABB: { - // Get the AABB's for the initial and delta values - AABB i = initial_val; - AABB d = delta_val; + AABB i = p_initial_val; + AABB d = p_delta_val; AABB r; - // Execute the equation for the position and size of the AABB's and mutate the r AABB - // This uses the custom APPLY_EQUATION macro defined above APPLY_EQUATION(position.x); APPLY_EQUATION(position.y); APPLY_EQUATION(position.z); APPLY_EQUATION(size.x); APPLY_EQUATION(size.y); APPLY_EQUATION(size.z); - result = r; - } break; + return r; + } case Variant::BASIS: { - // Get the basis for initial and delta values - Basis i = initial_val; - Basis d = delta_val; + Basis i = p_initial_val; + Basis d = p_delta_val; Basis r; - // Execute the equation on all the basis and mutate the r basis - // This uses the custom APPLY_EQUATION macro defined above APPLY_EQUATION(elements[0][0]); APPLY_EQUATION(elements[0][1]); APPLY_EQUATION(elements[0][2]); @@ -568,17 +440,14 @@ Variant Tween::_run_equation(InterpolateData &p_data) { APPLY_EQUATION(elements[2][0]); APPLY_EQUATION(elements[2][1]); APPLY_EQUATION(elements[2][2]); - result = r; - } break; + return r; + } case Variant::TRANSFORM3D: { - // Get the transforms for the initial and delta values - Transform3D i = initial_val; - Transform3D d = delta_val; + Transform3D i = p_initial_val; + Transform3D d = p_delta_val; Transform3D r; - // Execute the equation for each of the transforms and their origin and mutate the r transform - // This uses the custom APPLY_EQUATION macro defined above APPLY_EQUATION(basis.elements[0][0]); APPLY_EQUATION(basis.elements[0][1]); APPLY_EQUATION(basis.elements[0][2]); @@ -591,634 +460,67 @@ Variant Tween::_run_equation(InterpolateData &p_data) { APPLY_EQUATION(origin.x); APPLY_EQUATION(origin.y); APPLY_EQUATION(origin.z); - result = r; - } break; + return r; + } case Variant::COLOR: { - // Get the Color for initial and delta value - Color i = initial_val; - Color d = delta_val; + Color i = p_initial_val; + Color d = p_delta_val; Color r; - // Apply the equation on the Color RGBA, and mutate the r color - // This uses the custom APPLY_EQUATION macro defined above APPLY_EQUATION(r); APPLY_EQUATION(g); APPLY_EQUATION(b); APPLY_EQUATION(a); - result = r; - } break; - - default: { - // If unknown, just return the initial value - result = initial_val; - } break; - }; -#undef APPLY_EQUATION - // Return the result that was computed - return result; -} - -bool Tween::_apply_tween_value(InterpolateData &p_data, Variant &value) { - // Get the object we want to apply the new value to - Object *object = ObjectDB::get_instance(p_data.id); - ERR_FAIL_COND_V(object == nullptr, false); - - // What kind of data are we mutating? - switch (p_data.type) { - case INTER_PROPERTY: - case FOLLOW_PROPERTY: - case TARGETING_PROPERTY: { - // Simply set the property on the object - bool valid = false; - object->set_indexed(p_data.key, value, &valid); - return valid; + return r; } - case INTER_METHOD: - case FOLLOW_METHOD: - case TARGETING_METHOD: { - // We want to call the method on the target object - Callable::CallError error; - - // Do we have a non-nil value passed in? - if (value.get_type() != Variant::NIL) { - // Pass it as an argument to the function call - Variant *arg[1] = { &value }; - object->call(p_data.key[0], (const Variant **)arg, 1, error); - } else { - // Don't pass any argument - object->call(p_data.key[0], nullptr, 0, error); - } - - // Did we get an error from the function call? - return error.error == Callable::CallError::CALL_OK; + default: { + return p_initial_val; } - - case INTER_CALLBACK: - // Nothing to apply for a callback - break; }; - // No issues found! - return true; -} - -void Tween::_tween_process(float p_delta) { - // Process all of the pending commands - _process_pending_commands(); - - // If the scale is 0, make no progress on the tweens - if (speed_scale == 0) { - return; - } - - // Update the delta and whether we are pending an update - p_delta *= speed_scale; - pending_update++; - - // Are we repeating the interpolations? - if (repeat) { - // For each interpolation... - bool repeats_finished = true; - for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) { - // Get the data from it - InterpolateData &data = E->get(); - - // Is not finished? - if (!data.finish) { - // We aren't finished yet, no need to check the rest - repeats_finished = false; - break; - } - } - - // If we are all finished, we can reset all of the tweens - if (repeats_finished) { - reset_all(); - } - } - - // Are all of the tweens complete? - int any_unfinished = 0; - - // For each tween we wish to interpolate... - for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) { - // Get the data from it - InterpolateData &data = E->get(); - - // Is the data not active or already finished? No need to go any further - if (!data.active || data.finish) { - continue; - } - - // Track if we hit one that isn't finished yet - any_unfinished++; - - // Get the target object for this interpolation - Object *object = ObjectDB::get_instance(data.id); - if (object == nullptr) { - continue; - } - - // Are we still delaying this tween? - bool prev_delaying = data.elapsed <= data.delay; - data.elapsed += p_delta; - if (data.elapsed < data.delay) { - continue; - } else if (prev_delaying) { - // We can apply the tween's value to the data and emit that the tween has started - _apply_tween_value(data, data.initial_val); - emit_signal("tween_started", object, NodePath(Vector<StringName>(), data.key, false)); - } - - // Are we at the end of the tween? - if (data.elapsed > (data.delay + data.duration)) { - // Set the elapsed time to the end and mark this one as finished - data.elapsed = data.delay + data.duration; - data.finish = true; - } - - // Are we interpolating a callback? - if (data.type == INTER_CALLBACK) { - // Is the tween completed? - if (data.finish) { - // Are we calling this callback deferred or immediately? - if (data.call_deferred) { - // Run the deferred function callback, applying the correct number of arguments - switch (data.args) { - case 0: - object->call_deferred(data.key[0]); - break; - case 1: - object->call_deferred(data.key[0], data.arg[0]); - break; - case 2: - object->call_deferred(data.key[0], data.arg[0], data.arg[1]); - break; - case 3: - object->call_deferred(data.key[0], data.arg[0], data.arg[1], data.arg[2]); - break; - case 4: - object->call_deferred(data.key[0], data.arg[0], data.arg[1], data.arg[2], data.arg[3]); - break; - case 5: - object->call_deferred(data.key[0], data.arg[0], data.arg[1], data.arg[2], data.arg[3], data.arg[4]); - break; - } - } else { - // Call the function directly with the arguments - Callable::CallError error; - Variant *arg[5] = { - &data.arg[0], - &data.arg[1], - &data.arg[2], - &data.arg[3], - &data.arg[4], - }; - object->call(data.key[0], (const Variant **)arg, data.args, error); - } - } - } else { - // We can apply the value directly - Variant result = _run_equation(data); - _apply_tween_value(data, result); - - // Emit that the tween has taken a step - emit_signal("tween_step", object, NodePath(Vector<StringName>(), data.key, false), data.elapsed, result); - } - - // Is the tween now finished? - if (data.finish) { - // Set it to the final value directly - Variant final_val = _get_final_val(data); - _apply_tween_value(data, final_val); - - // Mark the tween as completed and emit the signal - data.elapsed = 0; - emit_signal("tween_completed", object, NodePath(Vector<StringName>(), data.key, false)); - - // If we are not repeating the tween, remove it - if (!repeat) { - call_deferred("_remove_by_uid", data.uid); - any_unfinished--; - } - } - } - // One less update left to go - pending_update--; - - // If all tweens are completed, we no longer need to be active - if (any_unfinished == 0) { - set_active(false); - emit_signal("tween_all_completed"); - } -} - -void Tween::set_tween_process_mode(TweenProcessMode p_mode) { - tween_process_mode = p_mode; -} - -Tween::TweenProcessMode Tween::get_tween_process_mode() const { - return tween_process_mode; -} - -bool Tween::is_active() const { - return is_processing_internal() || is_physics_processing_internal(); -} - -void Tween::set_active(bool p_active) { - // Do nothing if it's the same active mode that we currently are - if (is_active() == p_active) { - return; - } - - // Depending on physics or idle, set processing - switch (tween_process_mode) { - case TWEEN_PROCESS_IDLE: - set_process_internal(p_active); - break; - case TWEEN_PROCESS_PHYSICS: - set_physics_process_internal(p_active); - break; - } -} - -bool Tween::is_repeat() const { - return repeat; -} - -void Tween::set_repeat(bool p_repeat) { - repeat = p_repeat; -} - -void Tween::set_speed_scale(float p_speed) { - speed_scale = p_speed; -} - -float Tween::get_speed_scale() const { - return speed_scale; -} - -void Tween::start() { - ERR_FAIL_COND_MSG(!is_inside_tree(), "Tween was not added to the SceneTree!"); - - // Are there any pending updates? - if (pending_update != 0) { - // Start the tweens after deferring - call_deferred("start"); - return; - } - - pending_update++; - for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) { - InterpolateData &data = E->get(); - data.active = true; - } - pending_update--; - - // We want to be activated - set_active(true); - - // Don't resume from current position if stop_all() function has been used - if (was_stopped) { - seek(0); - } - was_stopped = false; -} - -void Tween::reset(Object *p_object, StringName p_key) { - // Find all interpolations that use the same object and target string - pending_update++; - for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) { - // Get the target object - InterpolateData &data = E->get(); - Object *object = ObjectDB::get_instance(data.id); - if (object == nullptr) { - continue; - } - - // Do we have the correct object and key? - if (object == p_object && (data.concatenated_key == p_key || p_key == "")) { - // Reset the tween to the initial state - data.elapsed = 0; - data.finish = false; - - // Also apply the initial state if there isn't a delay - if (data.delay == 0) { - _apply_tween_value(data, data.initial_val); - } - } - } - pending_update--; -} - -void Tween::reset_all() { - // Go through all interpolations - pending_update++; - for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) { - // Get the target data and set it back to the initial state - InterpolateData &data = E->get(); - data.elapsed = 0; - data.finish = false; - - // If there isn't a delay, apply the value to the object - if (data.delay == 0) { - _apply_tween_value(data, data.initial_val); - } - } - pending_update--; -} - -void Tween::stop(Object *p_object, StringName p_key) { - // Find the tween that has the given target object and string key - pending_update++; - for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) { - // Get the object the tween is targeting - InterpolateData &data = E->get(); - Object *object = ObjectDB::get_instance(data.id); - if (object == nullptr) { - continue; - } - - // Is this the correct object and does it have the given key? - if (object == p_object && (data.concatenated_key == p_key || p_key == "")) { - // Disable the tween - data.active = false; - } - } - pending_update--; -} - -void Tween::stop_all() { - // We no longer need to be active since all tweens have been stopped - set_active(false); - was_stopped = true; - // For each interpolation... - pending_update++; - for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) { - // Simply set it inactive - InterpolateData &data = E->get(); - data.active = false; - } - pending_update--; -} - -void Tween::resume(Object *p_object, StringName p_key) { - // We need to be activated - // TODO: What if no tween is found?? - set_active(true); - - // Find the tween that uses the given target object and string key - pending_update++; - for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) { - // Grab the object - InterpolateData &data = E->get(); - Object *object = ObjectDB::get_instance(data.id); - if (object == nullptr) { - continue; - } - - // If the object and string key match, activate it - if (object == p_object && (data.concatenated_key == p_key || p_key == "")) { - data.active = true; - } - } - pending_update--; -} - -void Tween::resume_all() { - // Set ourselves active so we can process tweens - // TODO: What if there are no tweens? We get set to active for no reason! - set_active(true); - - // For each interpolation... - pending_update++; - for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) { - // Simply grab it and set it to active - InterpolateData &data = E->get(); - data.active = true; - } - pending_update--; -} - -void Tween::remove(Object *p_object, StringName p_key) { - // If we are still updating, call this function again later - if (pending_update != 0) { - call_deferred("remove", p_object, p_key); - return; - } - - // For each interpolation... - List<List<InterpolateData>::Element *> for_removal; - for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) { - // Get the target object - InterpolateData &data = E->get(); - Object *object = ObjectDB::get_instance(data.id); - if (object == nullptr) { - continue; - } - - // If the target object and string key match, queue it for removal - if (object == p_object && (data.concatenated_key == p_key || p_key == "")) { - for_removal.push_back(E); - } - } - - // For each interpolation we wish to remove... - for (List<List<InterpolateData>::Element *>::Element *E = for_removal.front(); E; E = E->next()) { - // Erase it - interpolates.erase(E->get()); - } -} - -void Tween::_remove_by_uid(int uid) { - // If we are still updating, call this function again later - if (pending_update != 0) { - call_deferred("_remove_by_uid", uid); - return; - } - - // Find the interpolation that matches the given UID - for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) { - if (uid == E->get().uid) { - // It matches, erase it and stop looking - E->erase(); - break; - } - } -} - -void Tween::_push_interpolate_data(InterpolateData &p_data) { - pending_update++; - - // Add the new interpolation - p_data.uid = ++uid; - interpolates.push_back(p_data); - - pending_update--; +#undef APPLY_EQUATION } -void Tween::remove_all() { - // If we are still updating, call this function again later - if (pending_update != 0) { - call_deferred("remove_all"); - return; - } - // We no longer need to be active - set_active(false); - - // Clear out all interpolations and reset the uid - interpolates.clear(); - uid = 0; -} - -void Tween::seek(real_t p_time) { - // Go through each interpolation... - pending_update++; - for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) { - // Get the target data - InterpolateData &data = E->get(); - - // Update the elapsed data to be set to the target time - data.elapsed = p_time; - - // Are we at the end? - if (data.elapsed < data.delay) { - // There is still time left to go - data.finish = false; - continue; - } else if (data.elapsed >= (data.delay + data.duration)) { - // We are past the end of it, set the elapsed time to the end and mark as finished - data.elapsed = (data.delay + data.duration); - data.finish = true; - } else { - // We are not finished with this interpolation yet - data.finish = false; +Variant Tween::calculate_delta_value(Variant p_intial_val, Variant p_final_val) { + switch (p_intial_val.get_type()) { + case Variant::BOOL: { + return (int)p_final_val - (int)p_intial_val; } - // If we are a callback, do nothing special - if (data.type == INTER_CALLBACK) { - continue; + case Variant::RECT2: { + Rect2 i = p_intial_val; + Rect2 f = p_final_val; + return Rect2(f.position - i.position, f.size - i.size); } - // Run the equation on the data and apply the value - Variant result = _run_equation(data); - _apply_tween_value(data, result); - } - pending_update--; -} - -real_t Tween::tell() const { - // We want to grab the position of the furthest along tween - pending_update++; - real_t pos = 0.0; - - // For each interpolation... - for (const List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) { - // Get the data and figure out if its position is further along than the previous ones - const InterpolateData &data = E->get(); - if (data.elapsed > pos) { - // Save it if so - pos = data.elapsed; + case Variant::RECT2I: { + Rect2i i = p_intial_val; + Rect2i f = p_final_val; + return Rect2i(f.position - i.position, f.size - i.size); } - } - pending_update--; - return pos; -} - -real_t Tween::get_runtime() const { - // If the tween isn't moving, it'll last forever - if (speed_scale == 0) { - return INFINITY; - } - - pending_update++; - - // For each interpolation... - real_t runtime = 0.0; - for (const List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) { - // Get the tween data and see if it's runtime is greater than the previous tweens - const InterpolateData &data = E->get(); - real_t t = data.delay + data.duration; - if (t > runtime) { - // This is the longest running tween - runtime = t; - } - } - pending_update--; - - // Adjust the runtime for the current speed scale - return runtime / speed_scale; -} - -bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final_val, Variant &p_delta_val) { - // Get the initial, final, and delta values - const Variant &initial_val = p_initial_val; - const Variant &final_val = p_final_val; - Variant &delta_val = p_delta_val; - - // What kind of data are we interpolating? - switch (initial_val.get_type()) { - case Variant::BOOL: - // We'll treat booleans just like integers - case Variant::INT: - // Compute the integer delta - delta_val = (int)final_val - (int)initial_val; - break; - - case Variant::FLOAT: - // Convert to FLOAT and find the delta - delta_val = (real_t)final_val - (real_t)initial_val; - break; - - case Variant::VECTOR2: - // Convert to Vectors and find the delta - delta_val = final_val.operator Vector2() - initial_val.operator Vector2(); - break; - - case Variant::RECT2: { - // Build a new Rect2 and use the new position and sizes to make a delta - Rect2 i = initial_val; - Rect2 f = final_val; - delta_val = Rect2(f.position - i.position, f.size - i.size); - } break; - - case Variant::VECTOR3: - // Convert to Vectors and find the delta - delta_val = final_val.operator Vector3() - initial_val.operator Vector3(); - break; case Variant::TRANSFORM2D: { - // Build a new transform which is the difference between the initial and final values - Transform2D i = initial_val; - Transform2D f = final_val; - Transform2D d = Transform2D(); - d[0][0] = f.elements[0][0] - i.elements[0][0]; - d[0][1] = f.elements[0][1] - i.elements[0][1]; - d[1][0] = f.elements[1][0] - i.elements[1][0]; - d[1][1] = f.elements[1][1] - i.elements[1][1]; - d[2][0] = f.elements[2][0] - i.elements[2][0]; - d[2][1] = f.elements[2][1] - i.elements[2][1]; - delta_val = d; - } break; - - case Variant::QUATERNION: - // Convert to quaternianls and find the delta - delta_val = final_val.operator Quaternion() - initial_val.operator Quaternion(); - break; + Transform2D i = p_intial_val; + Transform2D f = p_final_val; + return Transform2D(f.elements[0][0] - i.elements[0][0], + f.elements[0][1] - i.elements[0][1], + f.elements[1][0] - i.elements[1][0], + f.elements[1][1] - i.elements[1][1], + f.elements[2][0] - i.elements[2][0], + f.elements[2][1] - i.elements[2][1]); + } case Variant::AABB: { - // Build a new AABB and use the new position and sizes to make a delta - AABB i = initial_val; - AABB f = final_val; - delta_val = AABB(f.position - i.position, f.size - i.size); - } break; + AABB i = p_intial_val; + AABB f = p_final_val; + return AABB(f.position - i.position, f.size - i.size); + } case Variant::BASIS: { - // Build a new basis which is the delta between the initial and final values - Basis i = initial_val; - Basis f = final_val; - delta_val = Basis(f.elements[0][0] - i.elements[0][0], + Basis i = p_intial_val; + Basis f = p_final_val; + return Basis(f.elements[0][0] - i.elements[0][0], f.elements[0][1] - i.elements[0][1], f.elements[0][2] - i.elements[0][2], f.elements[1][0] - i.elements[1][0], @@ -1227,14 +529,12 @@ bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final f.elements[2][0] - i.elements[2][0], f.elements[2][1] - i.elements[2][1], f.elements[2][2] - i.elements[2][2]); - } break; + } case Variant::TRANSFORM3D: { - // Build a new transform which is the difference between the initial and final values - Transform3D i = initial_val; - Transform3D f = final_val; - Transform3D d; - d.set(f.basis.elements[0][0] - i.basis.elements[0][0], + Transform3D i = p_intial_val; + Transform3D f = p_final_val; + return Transform3D(f.basis.elements[0][0] - i.basis.elements[0][0], f.basis.elements[0][1] - i.basis.elements[0][1], f.basis.elements[0][2] - i.basis.elements[0][2], f.basis.elements[1][0] - i.basis.elements[1][0], @@ -1246,569 +546,342 @@ bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final f.origin.x - i.origin.x, f.origin.y - i.origin.y, f.origin.z - i.origin.z); - - delta_val = d; - } break; - - case Variant::COLOR: { - // Make a new color which is the difference between each the color's RGBA attributes - Color i = initial_val; - Color f = final_val; - delta_val = Color(f.r - i.r, f.g - i.g, f.b - i.b, f.a - i.a); - } break; + } default: { - static Variant::Type supported_types[] = { - Variant::BOOL, - Variant::INT, - Variant::FLOAT, - Variant::VECTOR2, - Variant::RECT2, - Variant::VECTOR3, - Variant::TRANSFORM2D, - Variant::QUATERNION, - Variant::AABB, - Variant::BASIS, - Variant::TRANSFORM3D, - Variant::COLOR, - }; - - int length = *(&supported_types + 1) - supported_types; - String error_msg = "Invalid parameter type. Supported types are: "; - for (int i = 0; i < length; i++) { - if (i != 0) { - error_msg += ", "; - } - error_msg += Variant::get_type_name(supported_types[i]); - } - error_msg += "."; - ERR_PRINT(error_msg); - return false; + return Variant::evaluate(Variant::OP_SUBTRACT, p_final_val, p_intial_val); } }; - return true; } -void Tween::_build_interpolation(InterpolateType p_interpolation_type, Object *p_object, NodePath *p_property, StringName *p_method, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) { - // TODO: Add initialization+implementation for remaining interpolation types - // TODO: Fix this method's organization to take advantage of the type - - // Make a new interpolation data - InterpolateData data; - data.active = true; - data.type = p_interpolation_type; - data.finish = false; - data.elapsed = 0; +void Tween::_bind_methods() { + ClassDB::bind_method(D_METHOD("tween_property", "object", "property", "final_val", "duration"), &Tween::tween_property); + ClassDB::bind_method(D_METHOD("tween_interval", "time"), &Tween::tween_interval); + ClassDB::bind_method(D_METHOD("tween_callback", "callback"), &Tween::tween_callback); + ClassDB::bind_method(D_METHOD("tween_method", "method", "from", "to", "duration"), &Tween::tween_method); + + ClassDB::bind_method(D_METHOD("custom_step", "delta"), &Tween::custom_step); + ClassDB::bind_method(D_METHOD("stop"), &Tween::stop); + ClassDB::bind_method(D_METHOD("pause"), &Tween::pause); + ClassDB::bind_method(D_METHOD("play"), &Tween::play); + ClassDB::bind_method(D_METHOD("kill"), &Tween::kill); + + ClassDB::bind_method(D_METHOD("is_running"), &Tween::is_running); + ClassDB::bind_method(D_METHOD("is_valid"), &Tween::is_valid); + ClassDB::bind_method(D_METHOD("bind_node", "node"), &Tween::bind_node); + ClassDB::bind_method(D_METHOD("set_process_mode", "mode"), &Tween::set_process_mode); + ClassDB::bind_method(D_METHOD("set_pause_mode", "mode"), &Tween::set_pause_mode); + + ClassDB::bind_method(D_METHOD("set_parallel", "parallel"), &Tween::set_parallel, DEFVAL(true)); + ClassDB::bind_method(D_METHOD("set_loops", "loops"), &Tween::set_loops, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("set_speed_scale", "speed"), &Tween::set_speed_scale); + ClassDB::bind_method(D_METHOD("set_trans", "trans"), &Tween::set_trans); + ClassDB::bind_method(D_METHOD("set_ease", "ease"), &Tween::set_ease); - // Validate and apply interpolation data + ClassDB::bind_method(D_METHOD("parallel"), &Tween::parallel); + ClassDB::bind_method(D_METHOD("chain"), &Tween::chain); - // Give it the object - ERR_FAIL_COND_MSG(p_object == nullptr, "Invalid object provided to Tween."); - data.id = p_object->get_instance_id(); + ClassDB::bind_method(D_METHOD("interpolate_value", "trans_type", "ease_type", "elapsed_time", "initial_value", "delta_value", "duration"), &Tween::interpolate_variant); - // Validate the initial and final values - ERR_FAIL_COND_MSG(p_initial_val.get_type() != p_final_val.get_type(), "Initial value type '" + Variant::get_type_name(p_initial_val.get_type()) + "' does not match final value type '" + Variant::get_type_name(p_final_val.get_type()) + "'."); - data.initial_val = p_initial_val; - data.final_val = p_final_val; + ADD_SIGNAL(MethodInfo("step_finished", PropertyInfo(Variant::INT, "idx"))); + ADD_SIGNAL(MethodInfo("loop_finished", PropertyInfo(Variant::INT, "loop_count"))); + ADD_SIGNAL(MethodInfo("finished")); - // Check the Duration - ERR_FAIL_COND_MSG(p_duration < 0, "Only non-negative duration values allowed in Tweens."); - data.duration = p_duration; + BIND_ENUM_CONSTANT(TWEEN_PROCESS_PHYSICS); + BIND_ENUM_CONSTANT(TWEEN_PROCESS_IDLE); - // Tween Delay - ERR_FAIL_COND_MSG(p_delay < 0, "Only non-negative delay values allowed in Tweens."); - data.delay = p_delay; + BIND_ENUM_CONSTANT(TWEEN_PAUSE_BOUND); + BIND_ENUM_CONSTANT(TWEEN_PAUSE_STOP); + BIND_ENUM_CONSTANT(TWEEN_PAUSE_PROCESS); - // Transition type - ERR_FAIL_COND_MSG(p_trans_type < 0 || p_trans_type >= TRANS_COUNT, "Invalid transition type provided to Tween."); - data.trans_type = p_trans_type; + BIND_ENUM_CONSTANT(TRANS_LINEAR); + BIND_ENUM_CONSTANT(TRANS_SINE); + BIND_ENUM_CONSTANT(TRANS_QUINT); + BIND_ENUM_CONSTANT(TRANS_QUART); + BIND_ENUM_CONSTANT(TRANS_QUAD); + BIND_ENUM_CONSTANT(TRANS_EXPO); + BIND_ENUM_CONSTANT(TRANS_ELASTIC); + BIND_ENUM_CONSTANT(TRANS_CUBIC); + BIND_ENUM_CONSTANT(TRANS_CIRC); + BIND_ENUM_CONSTANT(TRANS_BOUNCE); + BIND_ENUM_CONSTANT(TRANS_BACK); - // Easing type - ERR_FAIL_COND_MSG(p_ease_type < 0 || p_ease_type >= EASE_COUNT, "Invalid easing type provided to Tween."); - data.ease_type = p_ease_type; + BIND_ENUM_CONSTANT(EASE_IN); + BIND_ENUM_CONSTANT(EASE_OUT); + BIND_ENUM_CONSTANT(EASE_IN_OUT); + BIND_ENUM_CONSTANT(EASE_OUT_IN); +} - // Is the property defined? - if (p_property) { - // Check that the object actually contains the given property - bool prop_valid = false; - p_object->get_indexed(p_property->get_subnames(), &prop_valid); - ERR_FAIL_COND_MSG(!prop_valid, "Tween target object has no property named: " + p_property->get_concatenated_subnames() + "."); +Ref<PropertyTweener> PropertyTweener::from(Variant p_value) { + initial_val = p_value; + do_continue = false; + return this; +} - data.key = p_property->get_subnames(); - data.concatenated_key = p_property->get_concatenated_subnames(); - } +Ref<PropertyTweener> PropertyTweener::from_current() { + do_continue = false; + return this; +} - // Is the method defined? - if (p_method) { - // Does the object even have the requested method? - ERR_FAIL_COND_MSG(!p_object->has_method(*p_method), "Tween target object has no method named: " + *p_method + "."); +Ref<PropertyTweener> PropertyTweener::as_relative() { + relative = true; + return this; +} - data.key.push_back(*p_method); - data.concatenated_key = *p_method; - } +Ref<PropertyTweener> PropertyTweener::set_trans(Tween::TransitionType p_trans) { + trans_type = p_trans; + return this; +} - // Is there not a valid delta? - if (!_calc_delta_val(data.initial_val, data.final_val, data.delta_val)) { - return; - } +Ref<PropertyTweener> PropertyTweener::set_ease(Tween::EaseType p_ease) { + ease_type = p_ease; + return this; +} - // Add this interpolation to the total - _push_interpolate_data(data); +Ref<PropertyTweener> PropertyTweener::set_delay(float p_delay) { + delay = p_delay; + return this; } -void Tween::interpolate_property(Object *p_object, NodePath p_property, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) { - // If we are busy updating, call this function again later - if (pending_update != 0) { - _add_pending_command("interpolate_property", p_object, p_property, p_initial_val, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay); +void PropertyTweener::start() { + elapsed_time = 0; + finished = false; + + Object *target_instance = ObjectDB::get_instance(target); + if (!target_instance) { + WARN_PRINT("Target object freed before starting, aborting Tweener."); return; } - // Check that the target object is valid - ERR_FAIL_COND_MSG(p_object == nullptr, vformat("The Tween \"%s\"'s target node is `null`. Is the node reference correct?", get_name())); - - // Get the property from the node path - p_property = p_property.get_as_property_path(); - - // If no initial value given, grab the initial value from the object - // TODO: Is this documented? This is very useful and removes a lot of clutter from tweens! - if (p_initial_val.get_type() == Variant::NIL) { - p_initial_val = p_object->get_indexed(p_property.get_subnames()); + if (do_continue) { + initial_val = target_instance->get_indexed(property); } - // Convert any integers into REALs as they are better for interpolation - if (p_initial_val.get_type() == Variant::INT) { - p_initial_val = p_initial_val.operator real_t(); - } - if (p_final_val.get_type() == Variant::INT) { - p_final_val = p_final_val.operator real_t(); + if (relative) { + final_val = Variant::evaluate(Variant::Operator::OP_ADD, initial_val, base_final_val); } - // Build the interpolation data - _build_interpolation(INTER_PROPERTY, p_object, &p_property, nullptr, p_initial_val, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay); + delta_val = tween->calculate_delta_value(initial_val, final_val); } -void Tween::interpolate_method(Object *p_object, StringName p_method, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) { - // If we are busy updating, call this function again later - if (pending_update != 0) { - _add_pending_command("interpolate_method", p_object, p_method, p_initial_val, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay); - return; +bool PropertyTweener::step(float &r_delta) { + if (finished) { + // This is needed in case there's a parallel Tweener with longer duration. + return false; } - // Check that the target object is valid - ERR_FAIL_COND_MSG(p_object == nullptr, vformat("The Tween \"%s\"'s target node is `null`. Is the node reference correct?", get_name())); - - // Convert any integers into REALs as they are better for interpolation - if (p_initial_val.get_type() == Variant::INT) { - p_initial_val = p_initial_val.operator real_t(); - } - if (p_final_val.get_type() == Variant::INT) { - p_final_val = p_final_val.operator real_t(); + Object *target_instance = ObjectDB::get_instance(target); + if (!target_instance) { + return false; } + elapsed_time += r_delta; - // Build the interpolation data - _build_interpolation(INTER_METHOD, p_object, nullptr, &p_method, p_initial_val, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay); -} - -void Tween::interpolate_callback(Object *p_object, real_t p_duration, String p_callback, VARIANT_ARG_DECLARE) { - // If we are already updating, call this function again later - if (pending_update != 0) { - _add_pending_command("interpolate_callback", p_object, p_duration, p_callback, p_arg1, p_arg2, p_arg3, p_arg4, p_arg5); - return; + if (elapsed_time < delay) { + r_delta = 0; + return true; } - // Check that the target object is valid - ERR_FAIL_COND(p_object == nullptr); - - // Duration cannot be negative - ERR_FAIL_COND(p_duration < 0); - - // Check whether the object even has the callback - ERR_FAIL_COND_MSG(!p_object->has_method(p_callback), "Object has no callback named: " + p_callback + "."); - - // Build a new InterpolationData - InterpolateData data; - data.active = true; - data.type = INTER_CALLBACK; - data.finish = false; - data.call_deferred = false; - data.elapsed = 0; - - // Give the data it's configuration - data.id = p_object->get_instance_id(); - data.key.push_back(p_callback); - data.concatenated_key = p_callback; - data.duration = p_duration; - data.delay = 0; - - // Add arguments to the interpolation - int args = 0; - if (p_arg5.get_type() != Variant::NIL) { - args = 5; - } else if (p_arg4.get_type() != Variant::NIL) { - args = 4; - } else if (p_arg3.get_type() != Variant::NIL) { - args = 3; - } else if (p_arg2.get_type() != Variant::NIL) { - args = 2; - } else if (p_arg1.get_type() != Variant::NIL) { - args = 1; + float time = MIN(elapsed_time - delay, duration); + target_instance->set_indexed(property, tween->interpolate_variant(initial_val, delta_val, time, duration, trans_type, ease_type)); + + if (time < duration) { + r_delta = 0; + return true; } else { - args = 0; + finished = true; + r_delta = elapsed_time - delay - duration; + emit_signal("finished"); + return false; } - - data.args = args; - data.arg[0] = p_arg1; - data.arg[1] = p_arg2; - data.arg[2] = p_arg3; - data.arg[3] = p_arg4; - data.arg[4] = p_arg5; - - // Add the new interpolation - _push_interpolate_data(data); } -void Tween::interpolate_deferred_callback(Object *p_object, real_t p_duration, String p_callback, VARIANT_ARG_DECLARE) { - // If we are already updating, call this function again later - if (pending_update != 0) { - _add_pending_command("interpolate_deferred_callback", p_object, p_duration, p_callback, p_arg1, p_arg2, p_arg3, p_arg4, p_arg5); - return; +void PropertyTweener::set_tween(Ref<Tween> p_tween) { + tween = p_tween; + if (trans_type == Tween::TRANS_MAX) { + trans_type = tween->get_trans(); } - - // Check that the target object is valid - ERR_FAIL_COND(p_object == nullptr); - - // No negative durations allowed - ERR_FAIL_COND(p_duration < 0); - - // Confirm the callback exists on the object - ERR_FAIL_COND_MSG(!p_object->has_method(p_callback), "Object has no callback named: " + p_callback + "."); - - // Create a new InterpolateData for the callback - InterpolateData data; - data.active = true; - data.type = INTER_CALLBACK; - data.finish = false; - data.call_deferred = true; - data.elapsed = 0; - - // Give the data it's configuration - data.id = p_object->get_instance_id(); - data.key.push_back(p_callback); - data.concatenated_key = p_callback; - data.duration = p_duration; - data.delay = 0; - - // Collect arguments for the callback - int args = 0; - if (p_arg5.get_type() != Variant::NIL) { - args = 5; - } else if (p_arg4.get_type() != Variant::NIL) { - args = 4; - } else if (p_arg3.get_type() != Variant::NIL) { - args = 3; - } else if (p_arg2.get_type() != Variant::NIL) { - args = 2; - } else if (p_arg1.get_type() != Variant::NIL) { - args = 1; - } else { - args = 0; + if (ease_type == Tween::EASE_MAX) { + ease_type = tween->get_ease(); } +} - data.args = args; - data.arg[0] = p_arg1; - data.arg[1] = p_arg2; - data.arg[2] = p_arg3; - data.arg[3] = p_arg4; - data.arg[4] = p_arg5; +void PropertyTweener::_bind_methods() { + ClassDB::bind_method(D_METHOD("from", "value"), &PropertyTweener::from); + ClassDB::bind_method(D_METHOD("from_current"), &PropertyTweener::from_current); + ClassDB::bind_method(D_METHOD("as_relative"), &PropertyTweener::as_relative); + ClassDB::bind_method(D_METHOD("set_trans", "trans"), &PropertyTweener::set_trans); + ClassDB::bind_method(D_METHOD("set_ease", "ease"), &PropertyTweener::set_ease); + ClassDB::bind_method(D_METHOD("set_delay", "delay"), &PropertyTweener::set_delay); +} - // Add the new interpolation - _push_interpolate_data(data); +PropertyTweener::PropertyTweener(Object *p_target, NodePath p_property, Variant p_to, float p_duration) { + target = p_target->get_instance_id(); + property = p_property.get_as_property_path().get_subnames(); + initial_val = p_target->get_indexed(property); + base_final_val = p_to; + final_val = base_final_val; + duration = p_duration; } -void Tween::follow_property(Object *p_object, NodePath p_property, Variant p_initial_val, Object *p_target, NodePath p_target_property, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) { - // If we are already updating, call this function again later - if (pending_update != 0) { - _add_pending_command("follow_property", p_object, p_property, p_initial_val, p_target, p_target_property, p_duration, p_trans_type, p_ease_type, p_delay); - return; - } +PropertyTweener::PropertyTweener() { + ERR_FAIL_MSG("Can't create empty PropertyTweener. Use get_tree().tween_property() or tween_property() instead."); +} - // Get the two properties from their paths - p_property = p_property.get_as_property_path(); - p_target_property = p_target_property.get_as_property_path(); +void IntervalTweener::start() { + elapsed_time = 0; + finished = false; +} - // If no initial value is given, grab it from the source object - // TODO: Is this documented? It's really helpful for decluttering tweens - if (p_initial_val.get_type() == Variant::NIL) { - p_initial_val = p_object->get_indexed(p_property.get_subnames()); +bool IntervalTweener::step(float &r_delta) { + if (finished) { + return false; } - // Convert initial INT values to FLOAT as they are better for interpolation - if (p_initial_val.get_type() == Variant::INT) { - p_initial_val = p_initial_val.operator real_t(); + elapsed_time += r_delta; + + if (elapsed_time < duration) { + r_delta = 0; + return true; + } else { + finished = true; + r_delta = elapsed_time - duration; + emit_signal("finished"); + return false; } +} - // Confirm the source and target objects are valid - ERR_FAIL_COND(p_object == nullptr); - ERR_FAIL_COND(p_target == nullptr); +IntervalTweener::IntervalTweener(float p_time) { + duration = p_time; +} - // No negative durations - ERR_FAIL_COND(p_duration < 0); +IntervalTweener::IntervalTweener() { + ERR_FAIL_MSG("Can't create empty IntervalTweener. Use get_tree().tween_interval() instead."); +} - // Ensure transition and easing types are valid - ERR_FAIL_COND(p_trans_type < 0 || p_trans_type >= TRANS_COUNT); - ERR_FAIL_COND(p_ease_type < 0 || p_ease_type >= EASE_COUNT); +Ref<CallbackTweener> CallbackTweener::set_delay(float p_delay) { + delay = p_delay; + return this; +} - // No negative delays - ERR_FAIL_COND(p_delay < 0); +void CallbackTweener::start() { + elapsed_time = 0; + finished = false; +} - // Confirm the source and target objects have the desired properties - bool prop_valid = false; - p_object->get_indexed(p_property.get_subnames(), &prop_valid); - ERR_FAIL_COND(!prop_valid); +bool CallbackTweener::step(float &r_delta) { + if (finished) { + return false; + } - bool target_prop_valid = false; - Variant target_val = p_target->get_indexed(p_target_property.get_subnames(), &target_prop_valid); - ERR_FAIL_COND(!target_prop_valid); + elapsed_time += r_delta; + if (elapsed_time >= delay) { + Variant result; + Callable::CallError ce; + callback.call(nullptr, 0, result, ce); + if (ce.error != Callable::CallError::CALL_OK) { + ERR_FAIL_V_MSG(false, "Error calling method from CallbackTweener: " + Variant::get_call_error_text(this, callback.get_method(), nullptr, 0, ce)); + } - // Convert target INT to FLOAT since it is better for interpolation - if (target_val.get_type() == Variant::INT) { - target_val = target_val.operator real_t(); + finished = true; + r_delta = elapsed_time - delay; + emit_signal("finished"); + return false; } - // Verify that the target value and initial value are the same type - ERR_FAIL_COND(target_val.get_type() != p_initial_val.get_type()); - - // Create a new InterpolateData - InterpolateData data; - data.active = true; - data.type = FOLLOW_PROPERTY; - data.finish = false; - data.elapsed = 0; - - // Give the InterpolateData it's configuration - data.id = p_object->get_instance_id(); - data.key = p_property.get_subnames(); - data.concatenated_key = p_property.get_concatenated_subnames(); - data.initial_val = p_initial_val; - data.target_id = p_target->get_instance_id(); - data.target_key = p_target_property.get_subnames(); - data.duration = p_duration; - data.trans_type = p_trans_type; - data.ease_type = p_ease_type; - data.delay = p_delay; - - // Add the interpolation - _push_interpolate_data(data); -} - -void Tween::follow_method(Object *p_object, StringName p_method, Variant p_initial_val, Object *p_target, StringName p_target_method, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) { - // If we are currently updating, call this function again later - if (pending_update != 0) { - _add_pending_command("follow_method", p_object, p_method, p_initial_val, p_target, p_target_method, p_duration, p_trans_type, p_ease_type, p_delay); - return; - } - // Convert initial INT values to FLOAT as they are better for interpolation - if (p_initial_val.get_type() == Variant::INT) { - p_initial_val = p_initial_val.operator real_t(); - } + r_delta = 0; + return true; +} - // Verify the source and target objects are valid - ERR_FAIL_COND(p_object == nullptr); - ERR_FAIL_COND(p_target == nullptr); +void CallbackTweener::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_delay", "delay"), &CallbackTweener::set_delay); +} - // No negative durations - ERR_FAIL_COND(p_duration < 0); +CallbackTweener::CallbackTweener(Callable p_callback) { + callback = p_callback; +} - // Ensure that the transition and ease types are valid - ERR_FAIL_COND(p_trans_type < 0 || p_trans_type >= TRANS_COUNT); - ERR_FAIL_COND(p_ease_type < 0 || p_ease_type >= EASE_COUNT); +CallbackTweener::CallbackTweener() { + ERR_FAIL_MSG("Can't create empty CallbackTweener. Use get_tree().tween_callback() instead."); +} - // No negative delays - ERR_FAIL_COND(p_delay < 0); +Ref<MethodTweener> MethodTweener::set_delay(float p_delay) { + delay = p_delay; + return this; +} - // Confirm both objects have the target methods - ERR_FAIL_COND_MSG(!p_object->has_method(p_method), "Object has no method named: " + p_method + "."); - ERR_FAIL_COND_MSG(!p_target->has_method(p_target_method), "Target has no method named: " + p_target_method + "."); +Ref<MethodTweener> MethodTweener::set_trans(Tween::TransitionType p_trans) { + trans_type = p_trans; + return this; +} - // Call the method to get the target value - Callable::CallError error; - Variant target_val = p_target->call(p_target_method, nullptr, 0, error); - ERR_FAIL_COND(error.error != Callable::CallError::CALL_OK); +Ref<MethodTweener> MethodTweener::set_ease(Tween::EaseType p_ease) { + ease_type = p_ease; + return this; +} - // Convert target INT values to FLOAT as they are better for interpolation - if (target_val.get_type() == Variant::INT) { - target_val = target_val.operator real_t(); - } - ERR_FAIL_COND(target_val.get_type() != p_initial_val.get_type()); - - // Make the new InterpolateData for the method follow - InterpolateData data; - data.active = true; - data.type = FOLLOW_METHOD; - data.finish = false; - data.elapsed = 0; - - // Give the data it's configuration - data.id = p_object->get_instance_id(); - data.key.push_back(p_method); - data.concatenated_key = p_method; - data.initial_val = p_initial_val; - data.target_id = p_target->get_instance_id(); - data.target_key.push_back(p_target_method); - data.duration = p_duration; - data.trans_type = p_trans_type; - data.ease_type = p_ease_type; - data.delay = p_delay; - - // Add the new interpolation - _push_interpolate_data(data); -} - -void Tween::targeting_property(Object *p_object, NodePath p_property, Object *p_initial, NodePath p_initial_property, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) { - // If we are currently updating, call this function again later - if (pending_update != 0) { - _add_pending_command("targeting_property", p_object, p_property, p_initial, p_initial_property, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay); - return; - } - // Grab the target property and the target property - p_property = p_property.get_as_property_path(); - p_initial_property = p_initial_property.get_as_property_path(); +void MethodTweener::start() { + elapsed_time = 0; + finished = false; +} - // Convert the initial INT values to FLOAT as they are better for Interpolation - if (p_final_val.get_type() == Variant::INT) { - p_final_val = p_final_val.operator real_t(); +bool MethodTweener::step(float &r_delta) { + if (finished) { + return false; } - // Verify both objects are valid - ERR_FAIL_COND(p_object == nullptr); - ERR_FAIL_COND(p_initial == nullptr); - - // No negative durations - ERR_FAIL_COND(p_duration < 0); - - // Ensure transition and easing types are valid - ERR_FAIL_COND(p_trans_type < 0 || p_trans_type >= TRANS_COUNT); - ERR_FAIL_COND(p_ease_type < 0 || p_ease_type >= EASE_COUNT); - - // No negative delays - ERR_FAIL_COND(p_delay < 0); - - // Ensure the initial and target properties exist on their objects - bool prop_valid = false; - p_object->get_indexed(p_property.get_subnames(), &prop_valid); - ERR_FAIL_COND(!prop_valid); + elapsed_time += r_delta; - bool initial_prop_valid = false; - Variant initial_val = p_initial->get_indexed(p_initial_property.get_subnames(), &initial_prop_valid); - ERR_FAIL_COND(!initial_prop_valid); - - // Convert the initial INT value to FLOAT as it is better for interpolation - if (initial_val.get_type() == Variant::INT) { - initial_val = initial_val.operator real_t(); - } - ERR_FAIL_COND(initial_val.get_type() != p_final_val.get_type()); - - // Build the InterpolateData object - InterpolateData data; - data.active = true; - data.type = TARGETING_PROPERTY; - data.finish = false; - data.elapsed = 0; - - // Give the data it's configuration - data.id = p_object->get_instance_id(); - data.key = p_property.get_subnames(); - data.concatenated_key = p_property.get_concatenated_subnames(); - data.target_id = p_initial->get_instance_id(); - data.target_key = p_initial_property.get_subnames(); - data.initial_val = initial_val; - data.final_val = p_final_val; - data.duration = p_duration; - data.trans_type = p_trans_type; - data.ease_type = p_ease_type; - data.delay = p_delay; - - // Ensure there is a valid delta - if (!_calc_delta_val(data.initial_val, data.final_val, data.delta_val)) { - return; + if (elapsed_time < delay) { + r_delta = 0; + return true; } - // Add the interpolation - _push_interpolate_data(data); -} + float time = MIN(elapsed_time - delay, duration); + Variant current_val = tween->interpolate_variant(initial_val, delta_val, time, duration, trans_type, ease_type); + const Variant **argptr = (const Variant **)alloca(sizeof(Variant *)); + argptr[0] = ¤t_val; -void Tween::targeting_method(Object *p_object, StringName p_method, Object *p_initial, StringName p_initial_method, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) { - // If we are currently updating, call this function again later - if (pending_update != 0) { - _add_pending_command("targeting_method", p_object, p_method, p_initial, p_initial_method, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay); - return; + Variant result; + Callable::CallError ce; + callback.call(argptr, 1, result, ce); + if (ce.error != Callable::CallError::CALL_OK) { + ERR_FAIL_V_MSG(false, "Error calling method from MethodTweener: " + Variant::get_call_error_text(this, callback.get_method(), argptr, 1, ce)); } - // Convert final INT values to FLOAT as they are better for interpolation - if (p_final_val.get_type() == Variant::INT) { - p_final_val = p_final_val.operator real_t(); + if (time < duration) { + r_delta = 0; + return true; + } else { + finished = true; + r_delta = elapsed_time - delay - duration; + emit_signal("finished"); + return false; } +} - // Make sure the given objects are valid - ERR_FAIL_COND(p_object == nullptr); - ERR_FAIL_COND(p_initial == nullptr); - - // No negative durations - ERR_FAIL_COND(p_duration < 0); - - // Ensure transition and easing types are valid - ERR_FAIL_COND(p_trans_type < 0 || p_trans_type >= TRANS_COUNT); - ERR_FAIL_COND(p_ease_type < 0 || p_ease_type >= EASE_COUNT); - - // No negative delays - ERR_FAIL_COND(p_delay < 0); - - // Make sure both objects have the given method - ERR_FAIL_COND_MSG(!p_object->has_method(p_method), "Object has no method named: " + p_method + "."); - ERR_FAIL_COND_MSG(!p_initial->has_method(p_initial_method), "Initial Object has no method named: " + p_initial_method + "."); - - // Call the method to get the initial value - Callable::CallError error; - Variant initial_val = p_initial->call(p_initial_method, nullptr, 0, error); - ERR_FAIL_COND(error.error != Callable::CallError::CALL_OK); - - // Convert initial INT values to FLOAT as they aer better for interpolation - if (initial_val.get_type() == Variant::INT) { - initial_val = initial_val.operator real_t(); +void MethodTweener::set_tween(Ref<Tween> p_tween) { + tween = p_tween; + if (trans_type == Tween::TRANS_MAX) { + trans_type = tween->get_trans(); } - ERR_FAIL_COND(initial_val.get_type() != p_final_val.get_type()); - - // Build the new InterpolateData object - InterpolateData data; - data.active = true; - data.type = TARGETING_METHOD; - data.finish = false; - data.elapsed = 0; - - // Configure the data - data.id = p_object->get_instance_id(); - data.key.push_back(p_method); - data.concatenated_key = p_method; - data.target_id = p_initial->get_instance_id(); - data.target_key.push_back(p_initial_method); - data.initial_val = initial_val; - data.final_val = p_final_val; - data.duration = p_duration; - data.trans_type = p_trans_type; - data.ease_type = p_ease_type; - data.delay = p_delay; - - // Ensure there is a valid delta - if (!_calc_delta_val(data.initial_val, data.final_val, data.delta_val)) { - return; + if (ease_type == Tween::EASE_MAX) { + ease_type = tween->get_ease(); } +} - // Add the interpolation - _push_interpolate_data(data); +void MethodTweener::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_delay", "delay"), &MethodTweener::set_delay); + ClassDB::bind_method(D_METHOD("set_trans", "trans"), &MethodTweener::set_trans); + ClassDB::bind_method(D_METHOD("set_ease", "ease"), &MethodTweener::set_ease); } -Tween::Tween() { +MethodTweener::MethodTweener(Callable p_callback, float p_from, float p_to, float p_duration) { + callback = p_callback; + initial_val = p_from; + delta_val = tween->calculate_delta_value(p_from, p_to); + duration = p_duration; } -Tween::~Tween() { +MethodTweener::MethodTweener() { + ERR_FAIL_MSG("Can't create empty MethodTweener. Use get_tree().tween_method() instead."); } diff --git a/scene/animation/tween.h b/scene/animation/tween.h index 142c0c65e0..947cdb7c2d 100644 --- a/scene/animation/tween.h +++ b/scene/animation/tween.h @@ -31,10 +31,33 @@ #ifndef TWEEN_H #define TWEEN_H -#include "scene/main/node.h" +#include "core/object/ref_counted.h" -class Tween : public Node { - GDCLASS(Tween, Node); +class Tween; +class Node; + +class Tweener : public RefCounted { + GDCLASS(Tweener, RefCounted); + +public: + virtual void set_tween(Ref<Tween> p_tween); + virtual void start() = 0; + virtual bool step(float &r_delta) = 0; + +protected: + static void _bind_methods(); + Ref<Tween> tween; + float elapsed_time = 0; + bool finished = false; +}; + +class PropertyTweener; +class IntervalTweener; +class CallbackTweener; +class MethodTweener; + +class Tween : public RefCounted { + GDCLASS(Tween, RefCounted); public: enum TweenProcessMode { @@ -42,6 +65,12 @@ public: TWEEN_PROCESS_IDLE, }; + enum TweenPauseMode { + TWEEN_PAUSE_BOUND, + TWEEN_PAUSE_STOP, + TWEEN_PAUSE_PROCESS, + }; + enum TransitionType { TRANS_LINEAR, TRANS_SINE, @@ -54,8 +83,7 @@ public: TRANS_CIRC, TRANS_BOUNCE, TRANS_BACK, - - TRANS_COUNT, + TRANS_MAX }; enum EaseType { @@ -63,130 +91,187 @@ public: EASE_OUT, EASE_IN_OUT, EASE_OUT_IN, - - EASE_COUNT, + EASE_MAX }; private: - enum InterpolateType { - INTER_PROPERTY, - INTER_METHOD, - FOLLOW_PROPERTY, - FOLLOW_METHOD, - TARGETING_PROPERTY, - TARGETING_METHOD, - INTER_CALLBACK, - }; + TweenProcessMode process_mode = TweenProcessMode::TWEEN_PROCESS_IDLE; + TweenPauseMode pause_mode = TweenPauseMode::TWEEN_PAUSE_STOP; + TransitionType default_transition = TransitionType::TRANS_LINEAR; + EaseType default_ease = EaseType::EASE_IN_OUT; + ObjectID bound_node; - struct InterpolateData { - bool active = false; - InterpolateType type = INTER_CALLBACK; - bool finish = false; - bool call_deferred = false; - real_t elapsed = 0.0; - ObjectID id; - Vector<StringName> key; - StringName concatenated_key; - Variant initial_val; - Variant delta_val; - Variant final_val; - ObjectID target_id; - Vector<StringName> target_key; - real_t duration = 0.0; - TransitionType trans_type = TransitionType::TRANS_BACK; - EaseType ease_type = EaseType::EASE_COUNT; - real_t delay = 0.0; - int args = 0; - Variant arg[5]; - int uid = 0; - }; + Vector<List<Ref<Tweener>>> tweeners; + int current_step = -1; + int loops = 1; + int loops_done = 0; + float speed_scale = 1; - String autoplay; - TweenProcessMode tween_process_mode = TWEEN_PROCESS_IDLE; - bool repeat = false; - float speed_scale = 1.0; - mutable int pending_update = 0; - int uid = 0; - bool was_stopped = false; + bool is_bound = false; + bool started = false; + bool running = true; + bool dead = false; + bool invalid = true; + bool default_parallel = false; + bool parallel_enabled = false; - List<InterpolateData> interpolates; + typedef real_t (*interpolater)(real_t t, real_t b, real_t c, real_t d); + static interpolater interpolaters[TRANS_MAX][EASE_MAX]; - struct PendingCommand { - StringName key; - int args = 0; - Variant arg[10]; - }; - List<PendingCommand> pending_commands; + void start_tweeners(); - void _add_pending_command(StringName p_key, const Variant &p_arg1 = Variant(), const Variant &p_arg2 = Variant(), const Variant &p_arg3 = Variant(), const Variant &p_arg4 = Variant(), const Variant &p_arg5 = Variant(), const Variant &p_arg6 = Variant(), const Variant &p_arg7 = Variant(), const Variant &p_arg8 = Variant(), const Variant &p_arg9 = Variant(), const Variant &p_arg10 = Variant()); - void _process_pending_commands(); +protected: + static void _bind_methods(); - typedef real_t (*interpolater)(real_t t, real_t b, real_t c, real_t d); - static interpolater interpolaters[TRANS_COUNT][EASE_COUNT]; +public: + Ref<PropertyTweener> tween_property(Object *p_target, NodePath p_property, Variant p_to, float p_duration); + Ref<IntervalTweener> tween_interval(float p_time); + Ref<CallbackTweener> tween_callback(Callable p_callback); + Ref<MethodTweener> tween_method(Callable p_callback, float p_from, float p_to, float p_duration); + Ref<Tween> append(Ref<Tweener> p_tweener); - real_t _run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t t, real_t b, real_t c, real_t d); - Variant &_get_delta_val(InterpolateData &p_data); - Variant _get_initial_val(const InterpolateData &p_data) const; - Variant _get_final_val(const InterpolateData &p_data) const; - Variant _run_equation(InterpolateData &p_data); - bool _calc_delta_val(const Variant &p_initial_val, const Variant &p_final_val, Variant &p_delta_val); - bool _apply_tween_value(InterpolateData &p_data, Variant &value); + bool custom_step(float p_delta); + void stop(); + void pause(); + void play(); + void kill(); - void _tween_process(float p_delta); - void _remove_by_uid(int uid); - void _push_interpolate_data(InterpolateData &p_data); - void _build_interpolation(InterpolateType p_interpolation_type, Object *p_object, NodePath *p_property, StringName *p_method, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay); + bool is_running(); + void set_valid(bool p_valid); + bool is_valid(); -protected: - bool _set(const StringName &p_name, const Variant &p_value); - bool _get(const StringName &p_name, Variant &r_ret) const; - void _get_property_list(List<PropertyInfo> *p_list) const; - void _notification(int p_what); + Ref<Tween> bind_node(Node *p_node); + Ref<Tween> set_process_mode(TweenProcessMode p_mode); + TweenProcessMode get_process_mode(); + Ref<Tween> set_pause_mode(TweenPauseMode p_mode); + TweenPauseMode get_pause_mode(); - static void _bind_methods(); + Ref<Tween> set_parallel(bool p_parallel); + Ref<Tween> set_loops(int p_loops); + Ref<Tween> set_speed_scale(float p_speed); + Ref<Tween> set_trans(TransitionType p_trans); + TransitionType get_trans(); + Ref<Tween> set_ease(EaseType p_ease); + EaseType get_ease(); -public: - bool is_active() const; - void set_active(bool p_active); - - bool is_repeat() const; - void set_repeat(bool p_repeat); - - void set_tween_process_mode(TweenProcessMode p_mode); - TweenProcessMode get_tween_process_mode() const; - - void set_speed_scale(float p_speed); - float get_speed_scale() const; - - void start(); - void reset(Object *p_object, StringName p_key); - void reset_all(); - void stop(Object *p_object, StringName p_key); - void stop_all(); - void resume(Object *p_object, StringName p_key); - void resume_all(); - void remove(Object *p_object, StringName p_key); - void remove_all(); - - void seek(real_t p_time); - real_t tell() const; - real_t get_runtime() const; - - void interpolate_property(Object *p_object, NodePath p_property, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type = TRANS_LINEAR, EaseType p_ease_type = EASE_IN_OUT, real_t p_delay = 0); - void interpolate_method(Object *p_object, StringName p_method, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type = TRANS_LINEAR, EaseType p_ease_type = EASE_IN_OUT, real_t p_delay = 0); - void interpolate_callback(Object *p_object, real_t p_duration, String p_callback, VARIANT_ARG_DECLARE); - void interpolate_deferred_callback(Object *p_object, real_t p_duration, String p_callback, VARIANT_ARG_DECLARE); - void follow_property(Object *p_object, NodePath p_property, Variant p_initial_val, Object *p_target, NodePath p_target_property, real_t p_duration, TransitionType p_trans_type = TRANS_LINEAR, EaseType p_ease_type = EASE_IN_OUT, real_t p_delay = 0); - void follow_method(Object *p_object, StringName p_method, Variant p_initial_val, Object *p_target, StringName p_target_method, real_t p_duration, TransitionType p_trans_type = TRANS_LINEAR, EaseType p_ease_type = EASE_IN_OUT, real_t p_delay = 0); - void targeting_property(Object *p_object, NodePath p_property, Object *p_initial, NodePath p_initial_property, Variant p_final_val, real_t p_duration, TransitionType p_trans_type = TRANS_LINEAR, EaseType p_ease_type = EASE_IN_OUT, real_t p_delay = 0); - void targeting_method(Object *p_object, StringName p_method, Object *p_initial, StringName p_initial_method, Variant p_final_val, real_t p_duration, TransitionType p_trans_type = TRANS_LINEAR, EaseType p_ease_type = EASE_IN_OUT, real_t p_delay = 0); - - Tween(); - ~Tween(); + Ref<Tween> parallel(); + Ref<Tween> chain(); + + real_t run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t t, real_t b, real_t c, real_t d); + Variant interpolate_variant(Variant p_initial_val, Variant p_delta_val, float p_time, float p_duration, Tween::TransitionType p_trans, Tween::EaseType p_ease); + Variant calculate_delta_value(Variant p_intial_val, Variant p_final_val); + + bool step(float p_delta); + bool should_pause(); + + Tween() {} }; +VARIANT_ENUM_CAST(Tween::TweenPauseMode); VARIANT_ENUM_CAST(Tween::TweenProcessMode); VARIANT_ENUM_CAST(Tween::TransitionType); VARIANT_ENUM_CAST(Tween::EaseType); +class PropertyTweener : public Tweener { + GDCLASS(PropertyTweener, Tweener); + +public: + Ref<PropertyTweener> from(Variant p_value); + Ref<PropertyTweener> from_current(); + Ref<PropertyTweener> as_relative(); + Ref<PropertyTweener> set_trans(Tween::TransitionType p_trans); + Ref<PropertyTweener> set_ease(Tween::EaseType p_ease); + Ref<PropertyTweener> set_delay(float p_delay); + + void set_tween(Ref<Tween> p_tween) override; + void start() override; + bool step(float &r_delta) override; + + PropertyTweener(Object *p_target, NodePath p_property, Variant p_to, float p_duration); + PropertyTweener(); + +protected: + static void _bind_methods(); + +private: + ObjectID target; + Vector<StringName> property; + Variant initial_val; + Variant base_final_val; + Variant final_val; + Variant delta_val; + + float duration = 0; + Tween::TransitionType trans_type = Tween::TRANS_MAX; // This is set inside set_tween(); + Tween::EaseType ease_type = Tween::EASE_MAX; + + float delay = 0; + bool do_continue = true; + bool relative = false; +}; + +class IntervalTweener : public Tweener { + GDCLASS(IntervalTweener, Tweener); + +public: + void start() override; + bool step(float &r_delta) override; + + IntervalTweener(float p_time); + IntervalTweener(); + +private: + float duration = 0; +}; + +class CallbackTweener : public Tweener { + GDCLASS(CallbackTweener, Tweener); + +public: + Ref<CallbackTweener> set_delay(float p_delay); + + void start() override; + bool step(float &r_delta) override; + + CallbackTweener(Callable p_callback); + CallbackTweener(); + +protected: + static void _bind_methods(); + +private: + Callable callback; + float delay = 0; +}; + +class MethodTweener : public Tweener { + GDCLASS(MethodTweener, Tweener); + +public: + Ref<MethodTweener> set_trans(Tween::TransitionType p_trans); + Ref<MethodTweener> set_ease(Tween::EaseType p_ease); + Ref<MethodTweener> set_delay(float p_delay); + + void set_tween(Ref<Tween> p_tween) override; + void start() override; + bool step(float &r_delta) override; + + MethodTweener(Callable p_callback, float p_from, float p_to, float p_duration); + MethodTweener(); + +protected: + static void _bind_methods(); + +private: + float duration = 0; + float delay = 0; + Tween::TransitionType trans_type = Tween::TRANS_MAX; + Tween::EaseType ease_type = Tween::EASE_MAX; + + Ref<Tween> tween; + Variant initial_val; + Variant delta_val; + Callable callback; +}; + #endif diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index c84627c21e..64a3f1ca77 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2807,7 +2807,7 @@ void Control::_bind_methods() { ADD_GROUP("Rect", "rect_"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_position", "get_position"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_global_position", PROPERTY_HINT_NONE, "", 0), "_set_global_position", "get_global_position"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_global_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "_set_global_position", "get_global_position"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "_set_size", "get_size"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "rect_min_size"), "set_custom_minimum_size", "get_custom_minimum_size"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rect_rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_rotation", "get_rotation"); diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp index adc1ed67ca..4ea1e1eb9f 100644 --- a/scene/gui/range.cpp +++ b/scene/gui/range.cpp @@ -265,7 +265,7 @@ void Range::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "step"), "set_step", "get_step"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "page"), "set_page", "get_page"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "value"), "set_value", "get_value"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ratio", PROPERTY_HINT_RANGE, "0,1,0.01", 0), "set_as_ratio", "get_as_ratio"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ratio", PROPERTY_HINT_RANGE, "0,1,0.01", PROPERTY_USAGE_NONE), "set_as_ratio", "get_as_ratio"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "exp_edit"), "set_exp_ratio", "is_ratio_exp"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "rounded"), "set_use_rounded_values", "is_using_rounded_values"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_greater"), "set_allow_greater", "is_greater_allowed"); diff --git a/scene/gui/shortcut.cpp b/scene/gui/shortcut.cpp index cbbcf9e069..962c6dcc60 100644 --- a/scene/gui/shortcut.cpp +++ b/scene/gui/shortcut.cpp @@ -42,7 +42,7 @@ Ref<InputEvent> Shortcut::get_shortcut() const { } bool Shortcut::is_shortcut(const Ref<InputEvent> &p_event) const { - return shortcut.is_valid() && shortcut->shortcut_match(p_event); + return shortcut.is_valid() && shortcut->is_match(p_event, true); } String Shortcut::get_as_text() const { diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index 0590ae2415..ed3c0b7a56 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -452,12 +452,12 @@ void VideoPlayer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE, "VideoStream"), "set_stream", "get_stream"); //ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), "set_loop", "has_loop") ; ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volume_db", PROPERTY_HINT_RANGE, "-80,24,0.01"), "set_volume_db", "get_volume_db"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volume", PROPERTY_HINT_EXP_RANGE, "0,15,0.01", 0), "set_volume", "get_volume"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volume", PROPERTY_HINT_EXP_RANGE, "0,15,0.01", PROPERTY_USAGE_NONE), "set_volume", "get_volume"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "has_autoplay"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "paused"), "set_paused", "is_paused"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "expand"), "set_expand", "has_expand"); ADD_PROPERTY(PropertyInfo(Variant::INT, "buffering_msec", PROPERTY_HINT_RANGE, "10,1000"), "set_buffering_msec", "get_buffering_msec"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "stream_position", PROPERTY_HINT_RANGE, "0,1280000,0.1", 0), "set_stream_position", "get_stream_position"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "stream_position", PROPERTY_HINT_RANGE, "0,1280000,0.1", PROPERTY_USAGE_NONE), "set_stream_position", "get_stream_position"); ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus"); } diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp index a4393d682f..361f584a5d 100644 --- a/scene/main/canvas_item.cpp +++ b/scene/main/canvas_item.cpp @@ -1218,7 +1218,7 @@ void CanvasItem::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::COLOR, "self_modulate"), "set_self_modulate", "get_self_modulate"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_behind_parent"), "set_draw_behind_parent", "is_draw_behind_parent_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "top_level"), "set_as_top_level", "is_set_as_top_level"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_on_top", PROPERTY_HINT_NONE, "", 0), "_set_on_top", "_is_on_top"); //compatibility + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_on_top", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "_set_on_top", "_is_on_top"); //compatibility ADD_PROPERTY(PropertyInfo(Variant::BOOL, "clip_children"), "set_clip_children", "is_clipping_children"); ADD_PROPERTY(PropertyInfo(Variant::INT, "light_mask", PROPERTY_HINT_LAYERS_2D_RENDER), "set_light_mask", "get_light_mask"); diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp index 85d7edd64b..f699e68715 100644 --- a/scene/main/canvas_layer.cpp +++ b/scene/main/canvas_layer.cpp @@ -303,7 +303,7 @@ void CanvasLayer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform"), "set_transform", "get_transform"); ADD_GROUP("", ""); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "custom_viewport", PROPERTY_HINT_RESOURCE_TYPE, "Viewport", 0), "set_custom_viewport", "get_custom_viewport"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "custom_viewport", PROPERTY_HINT_RESOURCE_TYPE, "Viewport", PROPERTY_USAGE_NONE), "set_custom_viewport", "get_custom_viewport"); ADD_GROUP("Follow Viewport", "follow_viewport"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "follow_viewport_enable"), "set_follow_viewport", "is_following_viewport"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "follow_viewport_scale", PROPERTY_HINT_RANGE, "0.001,1000,0.001,or_greater,or_lesser"), "set_follow_viewport_scale", "get_follow_viewport_scale"); diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 622c271935..679fca0217 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -35,6 +35,7 @@ #include "core/object/message_queue.h" #include "core/string/print_string.h" #include "instance_placeholder.h" +#include "scene/animation/tween.h" #include "scene/debugger/scene_debugger.h" #include "scene/resources/packed_scene.h" #include "scene/scene_string_names.h" @@ -1686,6 +1687,13 @@ int Node::get_index() const { return data.pos; } +Ref<Tween> Node::create_tween() { + ERR_FAIL_COND_V_MSG(!data.tree, nullptr, "Can't create Tween when not inside scene tree."); + Ref<Tween> tween = get_tree()->create_tween(); + tween->bind_node(this); + return tween; +} + void Node::remove_and_skip() { ERR_FAIL_COND(!data.parent); @@ -2555,6 +2563,7 @@ void Node::_bind_methods() { ClassDB::bind_method(D_METHOD("is_physics_processing_internal"), &Node::is_physics_processing_internal); ClassDB::bind_method(D_METHOD("get_tree"), &Node::get_tree); + ClassDB::bind_method(D_METHOD("create_tween"), &Node::create_tween); ClassDB::bind_method(D_METHOD("duplicate", "flags"), &Node::duplicate, DEFVAL(DUPLICATE_USE_INSTANCING | DUPLICATE_SIGNALS | DUPLICATE_GROUPS | DUPLICATE_SCRIPTS)); ClassDB::bind_method(D_METHOD("replace_by", "node", "keep_groups"), &Node::replace_by, DEFVAL(false)); @@ -2658,11 +2667,11 @@ void Node::_bind_methods() { ADD_SIGNAL(MethodInfo("tree_exiting")); ADD_SIGNAL(MethodInfo("tree_exited")); - ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "name", PROPERTY_HINT_NONE, "", 0), "set_name", "get_name"); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "filename", PROPERTY_HINT_NONE, "", 0), "set_filename", "get_filename"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "owner", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_owner", "get_owner"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multiplayer", PROPERTY_HINT_RESOURCE_TYPE, "MultiplayerAPI", 0), "", "get_multiplayer"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "custom_multiplayer", PROPERTY_HINT_RESOURCE_TYPE, "MultiplayerAPI", 0), "set_custom_multiplayer", "get_custom_multiplayer"); + ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_name", "get_name"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "filename", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_filename", "get_filename"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "owner", PROPERTY_HINT_RESOURCE_TYPE, "Node", PROPERTY_USAGE_NONE), "set_owner", "get_owner"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multiplayer", PROPERTY_HINT_RESOURCE_TYPE, "MultiplayerAPI", PROPERTY_USAGE_NONE), "", "get_multiplayer"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "custom_multiplayer", PROPERTY_HINT_RESOURCE_TYPE, "MultiplayerAPI", PROPERTY_USAGE_NONE), "set_custom_multiplayer", "get_custom_multiplayer"); ADD_GROUP("Process", "process_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "process_mode", PROPERTY_HINT_ENUM, "Inherit,Pausable,When Paused,Always,Disabled"), "set_process_mode", "get_process_mode"); diff --git a/scene/main/node.h b/scene/main/node.h index e7b36f351b..0d1685a2be 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -41,6 +41,9 @@ class Viewport; class SceneState; +class Tween; +class PropertyTweener; + class Node : public Object { GDCLASS(Node, Object); OBJ_CATEGORY("Nodes"); @@ -308,6 +311,8 @@ public: void remove_and_skip(); int get_index() const; + Ref<Tween> create_tween(); + void print_tree(); void print_tree_pretty(); diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index f588e000f9..918eca7def 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -41,6 +41,7 @@ #include "core/os/os.h" #include "core/string/print_string.h" #include "node.h" +#include "scene/animation/tween.h" #include "scene/debugger/scene_debugger.h" #include "scene/resources/font.h" #include "scene/resources/material.h" @@ -412,6 +413,9 @@ bool SceneTree::physics_process(float p_time) { _notify_group_pause("physics_process", Node::NOTIFICATION_PHYSICS_PROCESS); _flush_ugc(); MessageQueue::get_singleton()->flush(); //small little hack + + process_tweens(p_time, true); + flush_transform_notifications(); root_lock--; @@ -476,6 +480,8 @@ bool SceneTree::process(float p_time) { E = N; } + process_tweens(p_time, false); + flush_transform_notifications(); //additional transforms after timers update _call_idle_callbacks(); @@ -510,6 +516,32 @@ bool SceneTree::process(float p_time) { return _quit; } +void SceneTree::process_tweens(float p_delta, bool p_physics) { + // This methods works similarly to how SceneTreeTimers are handled. + List<Ref<Tween>>::Element *L = tweens.back(); + + for (List<Ref<Tween>>::Element *E = tweens.front(); E;) { + List<Ref<Tween>>::Element *N = E->next(); + // Don't process if paused or process mode doesn't match. + if ((paused && E->get()->should_pause()) || (p_physics == (E->get()->get_process_mode() == Tween::TWEEN_PROCESS_IDLE))) { + if (E == L) { + break; + } + E = N; + continue; + } + + if (!E->get()->step(p_delta)) { + E->get()->set_valid(false); + tweens.erase(E); + } + if (E == L) { + break; + } + E = N; + } +} + void SceneTree::finalize() { _flush_delete_queue(); @@ -1089,6 +1121,27 @@ Ref<SceneTreeTimer> SceneTree::create_timer(float p_delay_sec, bool p_process_al return stt; } +Ref<Tween> SceneTree::create_tween() { + Ref<Tween> tween; + tween.instance(); + tween->set_valid(true); + tweens.push_back(tween); + return tween; +} + +Array SceneTree::get_processed_tweens() { + Array ret; + ret.resize(tweens.size()); + + int i = 0; + for (List<Ref<Tween>>::Element *E = tweens.front(); E; E = E->next()) { + ret[i] = E->get(); + i++; + } + + return ret; +} + void SceneTree::_network_peer_connected(int p_id) { emit_signal("network_peer_connected", p_id); } @@ -1197,6 +1250,8 @@ void SceneTree::_bind_methods() { ClassDB::bind_method(D_METHOD("is_paused"), &SceneTree::is_paused); ClassDB::bind_method(D_METHOD("create_timer", "time_sec", "process_always"), &SceneTree::create_timer, DEFVAL(true)); + ClassDB::bind_method(D_METHOD("create_tween"), &SceneTree::create_tween); + ClassDB::bind_method(D_METHOD("get_processed_tweens"), &SceneTree::get_processed_tweens); ClassDB::bind_method(D_METHOD("get_node_count"), &SceneTree::get_node_count); ClassDB::bind_method(D_METHOD("get_frame"), &SceneTree::get_frame); @@ -1257,11 +1312,11 @@ void SceneTree::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "paused"), "set_pause", "is_paused"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "refuse_new_network_connections"), "set_refuse_new_network_connections", "is_refusing_new_network_connections"); ADD_PROPERTY_DEFAULT("refuse_new_network_connections", false); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "edited_scene_root", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_edited_scene_root", "get_edited_scene_root"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "current_scene", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_current_scene", "get_current_scene"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "network_peer", PROPERTY_HINT_RESOURCE_TYPE, "NetworkedMultiplayerPeer", 0), "set_network_peer", "get_network_peer"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "root", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "", "get_root"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multiplayer", PROPERTY_HINT_RESOURCE_TYPE, "MultiplayerAPI", 0), "set_multiplayer", "get_multiplayer"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "edited_scene_root", PROPERTY_HINT_RESOURCE_TYPE, "Node", PROPERTY_USAGE_NONE), "set_edited_scene_root", "get_edited_scene_root"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "current_scene", PROPERTY_HINT_RESOURCE_TYPE, "Node", PROPERTY_USAGE_NONE), "set_current_scene", "get_current_scene"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "network_peer", PROPERTY_HINT_RESOURCE_TYPE, "NetworkedMultiplayerPeer", PROPERTY_USAGE_NONE), "set_network_peer", "get_network_peer"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "root", PROPERTY_HINT_RESOURCE_TYPE, "Node", PROPERTY_USAGE_NONE), "", "get_root"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multiplayer", PROPERTY_HINT_RESOURCE_TYPE, "MultiplayerAPI", PROPERTY_USAGE_NONE), "set_multiplayer", "get_multiplayer"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "multiplayer_poll"), "set_multiplayer_poll_enabled", "is_multiplayer_poll_enabled"); ADD_SIGNAL(MethodInfo("tree_changed")); diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h index 78c4c14e97..0e9ffb0f5f 100644 --- a/scene/main/scene_tree.h +++ b/scene/main/scene_tree.h @@ -47,6 +47,7 @@ class Window; class Material; class Mesh; class SceneDebugger; +class Tween; class SceneTreeTimer : public RefCounted { GDCLASS(SceneTreeTimer, RefCounted); @@ -151,6 +152,7 @@ private: //void _call_group(uint32_t p_call_flags,const StringName& p_group,const StringName& p_function,const Variant& p_arg1,const Variant& p_arg2); List<Ref<SceneTreeTimer>> timers; + List<Ref<Tween>> tweens; ///network/// @@ -171,6 +173,7 @@ private: void node_added(Node *p_node); void node_removed(Node *p_node); void node_renamed(Node *p_node); + void process_tweens(float p_delta, bool p_physics_frame); Group *add_to_group(const StringName &p_group, Node *p_node); void remove_from_group(const StringName &p_group, Node *p_node); @@ -318,6 +321,8 @@ public: Error reload_current_scene(); Ref<SceneTreeTimer> create_timer(float p_delay_sec, bool p_process_always = true); + Ref<Tween> create_tween(); + Array get_processed_tweens(); //used by Main::start, don't use otherwise void add_current_scene(Node *p_current); diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp index 4bc159f6aa..a5ceec9c8b 100644 --- a/scene/main/timer.cpp +++ b/scene/main/timer.cpp @@ -210,8 +210,8 @@ void Timer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wait_time", PROPERTY_HINT_EXP_RANGE, "0.001,4096,0.001,or_greater"), "set_wait_time", "get_wait_time"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "one_shot"), "set_one_shot", "is_one_shot"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autostart"), "set_autostart", "has_autostart"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "paused", PROPERTY_HINT_NONE, "", 0), "set_paused", "is_paused"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "time_left", PROPERTY_HINT_NONE, "", 0), "", "get_time_left"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "paused", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_paused", "is_paused"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "time_left", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_time_left"); BIND_ENUM_CONSTANT(TIMER_PROCESS_PHYSICS); BIND_ENUM_CONSTANT(TIMER_PROCESS_IDLE); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 59ec0e6345..84a6dbe889 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -3576,7 +3576,7 @@ void Viewport::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_xr"), "set_use_xr", "is_using_xr"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "own_world_3d"), "set_use_own_world_3d", "is_using_own_world_3d"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_3d", PROPERTY_HINT_RESOURCE_TYPE, "World3D"), "set_world_3d", "get_world_3d"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_2d", PROPERTY_HINT_RESOURCE_TYPE, "World2D", 0), "set_world_2d", "get_world_2d"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_2d", PROPERTY_HINT_RESOURCE_TYPE, "World2D", PROPERTY_USAGE_NONE), "set_world_2d", "get_world_2d"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "transparent_bg"), "set_transparent_background", "has_transparent_background"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "handle_input_locally"), "set_handle_input_locally", "is_handling_input_locally"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_2d_transforms_to_pixel"), "set_snap_2d_transforms_to_pixel", "is_snap_2d_transforms_to_pixel_enabled"); @@ -3610,8 +3610,8 @@ void Viewport::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::INT, "shadow_atlas_quad_1", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), "set_shadow_atlas_quadrant_subdiv", "get_shadow_atlas_quadrant_subdiv", 1); ADD_PROPERTYI(PropertyInfo(Variant::INT, "shadow_atlas_quad_2", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), "set_shadow_atlas_quadrant_subdiv", "get_shadow_atlas_quadrant_subdiv", 2); ADD_PROPERTYI(PropertyInfo(Variant::INT, "shadow_atlas_quad_3", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), "set_shadow_atlas_quadrant_subdiv", "get_shadow_atlas_quadrant_subdiv", 3); - ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "canvas_transform", PROPERTY_HINT_NONE, "", 0), "set_canvas_transform", "get_canvas_transform"); - ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "global_canvas_transform", PROPERTY_HINT_NONE, "", 0), "set_global_canvas_transform", "get_global_canvas_transform"); + ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "canvas_transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_canvas_transform", "get_canvas_transform"); + ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "global_canvas_transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_global_canvas_transform", "get_global_canvas_transform"); ADD_SIGNAL(MethodInfo("size_changed")); ADD_SIGNAL(MethodInfo("gui_focus_changed", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Control"))); diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 2a97ae3acf..931c81ad65 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -407,6 +407,11 @@ void register_scene_types() { ClassDB::register_class<AnimationPlayer>(); ClassDB::register_class<Tween>(); + ClassDB::register_virtual_class<Tweener>(); + ClassDB::register_class<PropertyTweener>(); + ClassDB::register_class<IntervalTweener>(); + ClassDB::register_class<CallbackTweener>(); + ClassDB::register_class<MethodTweener>(); ClassDB::register_class<AnimationTree>(); ClassDB::register_class<AnimationNode>(); diff --git a/scene/resources/line_shape_2d.h b/scene/resources/line_shape_2d.h index 9f0405ad29..210a1aa9e6 100644 --- a/scene/resources/line_shape_2d.h +++ b/scene/resources/line_shape_2d.h @@ -36,7 +36,8 @@ class LineShape2D : public Shape2D { GDCLASS(LineShape2D, Shape2D); - Vector2 normal = Vector2(0, 1); + // LineShape2D is often used for one-way platforms, where the normal pointing up makes sense. + Vector2 normal = Vector2(0, -1); real_t distance = 0.0; void _update_shape(); diff --git a/scene/resources/multimesh.cpp b/scene/resources/multimesh.cpp index dea5c4e7d3..8894f0bb11 100644 --- a/scene/resources/multimesh.cpp +++ b/scene/resources/multimesh.cpp @@ -349,10 +349,10 @@ void MultiMesh::_bind_methods() { ClassDB::bind_method(D_METHOD("_set_custom_data_array"), &MultiMesh::_set_custom_data_array); ClassDB::bind_method(D_METHOD("_get_custom_data_array"), &MultiMesh::_get_custom_data_array); - ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR3_ARRAY, "transform_array", PROPERTY_HINT_NONE, "", 0), "_set_transform_array", "_get_transform_array"); - ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR2_ARRAY, "transform_2d_array", PROPERTY_HINT_NONE, "", 0), "_set_transform_2d_array", "_get_transform_2d_array"); - ADD_PROPERTY(PropertyInfo(Variant::PACKED_COLOR_ARRAY, "color_array", PROPERTY_HINT_NONE, "", 0), "_set_color_array", "_get_color_array"); - ADD_PROPERTY(PropertyInfo(Variant::PACKED_COLOR_ARRAY, "custom_data_array", PROPERTY_HINT_NONE, "", 0), "_set_custom_data_array", "_get_custom_data_array"); + ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR3_ARRAY, "transform_array", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "_set_transform_array", "_get_transform_array"); + ADD_PROPERTY(PropertyInfo(Variant::PACKED_VECTOR2_ARRAY, "transform_2d_array", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "_set_transform_2d_array", "_get_transform_2d_array"); + ADD_PROPERTY(PropertyInfo(Variant::PACKED_COLOR_ARRAY, "color_array", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "_set_color_array", "_get_color_array"); + ADD_PROPERTY(PropertyInfo(Variant::PACKED_COLOR_ARRAY, "custom_data_array", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "_set_custom_data_array", "_get_custom_data_array"); #endif BIND_ENUM_CONSTANT(TRANSFORM_2D); diff --git a/scene/resources/sprite_frames.cpp b/scene/resources/sprite_frames.cpp index 90c702081b..df80084c5c 100644 --- a/scene/resources/sprite_frames.cpp +++ b/scene/resources/sprite_frames.cpp @@ -228,7 +228,7 @@ void SpriteFrames::_bind_methods() { ClassDB::bind_method(D_METHOD("_set_frames"), &SpriteFrames::_set_frames); ClassDB::bind_method(D_METHOD("_get_frames"), &SpriteFrames::_get_frames); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "frames", PROPERTY_HINT_NONE, "", 0), "_set_frames", "_get_frames"); //compatibility + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "frames", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "_set_frames", "_get_frames"); //compatibility ClassDB::bind_method(D_METHOD("_set_animations"), &SpriteFrames::_set_animations); ClassDB::bind_method(D_METHOD("_get_animations"), &SpriteFrames::_get_animations); diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 064563d4b5..aa85c7116b 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -1904,7 +1904,7 @@ void AnimatedTexture::_bind_methods() { ClassDB::bind_method(D_METHOD("get_frame_delay", "frame"), &AnimatedTexture::get_frame_delay); ADD_PROPERTY(PropertyInfo(Variant::INT, "frames", PROPERTY_HINT_RANGE, "1," + itos(MAX_FRAMES), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_frames", "get_frames"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "current_frame", PROPERTY_HINT_NONE, "", 0), "set_current_frame", "get_current_frame"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "current_frame", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_current_frame", "get_current_frame"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pause"), "set_pause", "get_pause"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "oneshot"), "set_oneshot", "get_oneshot"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fps", PROPERTY_HINT_RANGE, "0,1024,0.1"), "set_fps", "get_fps"); diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index 0d6f3c07f0..0eeea29da4 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -801,7 +801,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) { #ifndef DISABLE_DEPRECATED // TODO: THIS IS HOW WE CHECK IF WE HAVE A DEPRECATED RESOURCE // This should be moved to a dedicated conversion system - if (components.size() >= 1 && components[0].is_valid_integer()) { + if (components.size() >= 1 && components[0].is_valid_int()) { int id = components[0].to_int(); // Get or create the compatibility object @@ -966,7 +966,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) { #endif // DISABLE_DEPRECATED // This is now a new property. - if (components.size() == 2 && components[0].begins_with("occlusion_layer_") && components[0].trim_prefix("occlusion_layer_").is_valid_integer()) { + if (components.size() == 2 && components[0].begins_with("occlusion_layer_") && components[0].trim_prefix("occlusion_layer_").is_valid_int()) { // Occlusion layers. int index = components[0].trim_prefix("occlusion_layer_").to_int(); ERR_FAIL_COND_V(index < 0, false); @@ -985,7 +985,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) { set_occlusion_layer_sdf_collision(index, p_value); return true; } - } else if (components.size() == 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_integer()) { + } else if (components.size() == 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) { // Physics layers. int index = components[0].trim_prefix("physics_layer_").to_int(); ERR_FAIL_COND_V(index < 0, false); @@ -1012,7 +1012,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) { set_physics_layer_physics_material(index, physics_material); return true; } - } else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_integer()) { + } else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int()) { // Terrains. int terrain_set_index = components[0].trim_prefix("terrain_set_").to_int(); ERR_FAIL_COND_V(terrain_set_index < 0, false); @@ -1029,7 +1029,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) { } set_terrains_count(terrain_set_index, p_value); return true; - } else if (components.size() >= 3 && components[1].begins_with("terrain_") && components[1].trim_prefix("terrain_").is_valid_integer()) { + } else if (components.size() >= 3 && components[1].begins_with("terrain_") && components[1].trim_prefix("terrain_").is_valid_int()) { int terrain_index = components[1].trim_prefix("terrain_").to_int(); ERR_FAIL_COND_V(terrain_index < 0, false); if (components[2] == "name") { @@ -1054,7 +1054,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) { return true; } } - } else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_integer()) { + } else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) { // Navigation layers. int index = components[0].trim_prefix("navigation_layer_").to_int(); ERR_FAIL_COND_V(index < 0, false); @@ -1066,7 +1066,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) { set_navigation_layer_layers(index, p_value); return true; } - } else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_integer()) { + } else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_int()) { // Custom data layers. int index = components[0].trim_prefix("custom_data_layer_").to_int(); ERR_FAIL_COND_V(index < 0, false); @@ -1085,8 +1085,8 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) { set_custom_data_type(index, Variant::Type(int(p_value))); return true; } - } else if (components.size() == 2 && components[0] == "sources" && components[1].is_valid_integer()) { - // Create source only if it does not exists. + } else if (components.size() == 2 && components[0] == "sources" && components[1].is_valid_int()) { + // Create source only if it does not exist. int source_id = components[1].to_int(); if (!has_source(source_id)) { @@ -1105,7 +1105,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) { bool TileSet::_get(const StringName &p_name, Variant &r_ret) const { Vector<String> components = String(p_name).split("/", true, 2); - if (components.size() == 2 && components[0].begins_with("occlusion_layer_") && components[0].trim_prefix("occlusion_layer_").is_valid_integer()) { + if (components.size() == 2 && components[0].begins_with("occlusion_layer_") && components[0].trim_prefix("occlusion_layer_").is_valid_int()) { // Occlusion layers. int index = components[0].trim_prefix("occlusion_layer_").to_int(); if (index < 0 || index >= occlusion_layers.size()) { @@ -1118,7 +1118,7 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const { r_ret = get_occlusion_layer_sdf_collision(index); return true; } - } else if (components.size() == 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_integer()) { + } else if (components.size() == 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) { // Physics layers. int index = components[0].trim_prefix("physics_layer_").to_int(); if (index < 0 || index >= physics_layers.size()) { @@ -1134,7 +1134,7 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const { r_ret = get_physics_layer_physics_material(index); return true; } - } else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_integer()) { + } else if (components.size() >= 2 && components[0].begins_with("terrain_set_") && components[0].trim_prefix("terrain_set_").is_valid_int()) { // Terrains. int terrain_set_index = components[0].trim_prefix("terrain_set_").to_int(); if (terrain_set_index < 0 || terrain_set_index >= terrain_sets.size()) { @@ -1146,7 +1146,7 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const { } else if (components[1] == "terrains_count") { r_ret = get_terrains_count(terrain_set_index); return true; - } else if (components.size() >= 3 && components[1].begins_with("terrain_") && components[1].trim_prefix("terrain_").is_valid_integer()) { + } else if (components.size() >= 3 && components[1].begins_with("terrain_") && components[1].trim_prefix("terrain_").is_valid_int()) { int terrain_index = components[1].trim_prefix("terrain_").to_int(); if (terrain_index < 0 || terrain_index >= terrain_sets[terrain_set_index].terrains.size()) { return false; @@ -1159,7 +1159,7 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const { return true; } } - } else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_integer()) { + } else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) { // navigation layers. int index = components[0].trim_prefix("navigation_layer_").to_int(); if (index < 0 || index >= navigation_layers.size()) { @@ -1169,7 +1169,7 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const { r_ret = get_navigation_layer_layers(index); return true; } - } else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_integer()) { + } else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_int()) { // Custom data layers. int index = components[0].trim_prefix("custom_data_layer_").to_int(); if (index < 0 || index >= custom_data_layers.size()) { @@ -1182,7 +1182,7 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const { r_ret = get_custom_data_type(index); return true; } - } else if (components.size() == 2 && components[0] == "sources" && components[1].is_valid_integer()) { + } else if (components.size() == 2 && components[0] == "sources" && components[1].is_valid_int()) { // Atlases data. int source_id = components[1].to_int(); @@ -1534,7 +1534,7 @@ bool TileSetAtlasSource::_set(const StringName &p_name, const Variant &p_value) // Compute the vector2i if we have coordinates. Vector<String> coords_split = components[0].split(":"); Vector2i coords = TileSetSource::INVALID_ATLAS_COORDS; - if (coords_split.size() == 2 && coords_split[0].is_valid_integer() && coords_split[1].is_valid_integer()) { + if (coords_split.size() == 2 && coords_split[0].is_valid_int() && coords_split[1].is_valid_int()) { coords = Vector2i(coords_split[0].to_int(), coords_split[1].to_int()); } @@ -1550,7 +1550,7 @@ bool TileSetAtlasSource::_set(const StringName &p_name, const Variant &p_value) move_tile_in_atlas(coords, coords, p_value); } else if (components[1] == "next_alternative_id") { tiles[coords].next_alternative_id = p_value; - } else if (components[1].is_valid_integer()) { + } else if (components[1].is_valid_int()) { int alternative_id = components[1].to_int(); if (alternative_id != TileSetSource::INVALID_TILE_ALTERNATIVE) { // Create the alternative if needed ? @@ -1584,7 +1584,7 @@ bool TileSetAtlasSource::_get(const StringName &p_name, Variant &r_ret) const { // Properties. Vector<String> coords_split = components[0].split(":"); - if (coords_split.size() == 2 && coords_split[0].is_valid_integer() && coords_split[1].is_valid_integer()) { + if (coords_split.size() == 2 && coords_split[0].is_valid_int() && coords_split[1].is_valid_int()) { Vector2i coords = Vector2i(coords_split[0].to_int(), coords_split[1].to_int()); if (tiles.has(coords)) { if (components.size() >= 2) { @@ -1595,7 +1595,7 @@ bool TileSetAtlasSource::_get(const StringName &p_name, Variant &r_ret) const { } else if (components[1] == "next_alternative_id") { r_ret = tiles[coords].next_alternative_id; return true; - } else if (components[1].is_valid_integer()) { + } else if (components[1].is_valid_int()) { int alternative_id = components[1].to_int(); if (alternative_id != TileSetSource::INVALID_TILE_ALTERNATIVE && tiles[coords].alternatives.has(alternative_id)) { if (components.size() >= 3) { @@ -2160,7 +2160,7 @@ int TileSetScenesCollectionSource::get_next_scene_tile_id() const { bool TileSetScenesCollectionSource::_set(const StringName &p_name, const Variant &p_value) { Vector<String> components = String(p_name).split("/", true, 2); - if (components.size() >= 2 && components[0] == "scenes" && components[1].is_valid_integer()) { + if (components.size() >= 2 && components[0] == "scenes" && components[1].is_valid_int()) { int scene_id = components[1].to_int(); if (components.size() >= 3 && components[2] == "scene") { if (has_scene_tile_id(scene_id)) { @@ -2184,7 +2184,7 @@ bool TileSetScenesCollectionSource::_set(const StringName &p_name, const Variant bool TileSetScenesCollectionSource::_get(const StringName &p_name, Variant &r_ret) const { Vector<String> components = String(p_name).split("/", true, 2); - if (components.size() >= 2 && components[0] == "scenes" && components[1].is_valid_integer() && scenes.has(components[1].to_int())) { + if (components.size() >= 2 && components[0] == "scenes" && components[1].is_valid_int() && scenes.has(components[1].to_int())) { if (components.size() >= 3 && components[2] == "scene") { r_ret = scenes[components[1].to_int()].scene; return true; @@ -2526,7 +2526,7 @@ Variant TileData::get_custom_data_by_layer_id(int p_layer_id) const { bool TileData::_set(const StringName &p_name, const Variant &p_value) { Vector<String> components = String(p_name).split("/", true, 2); - if (components.size() == 2 && components[0].begins_with("occlusion_layer_") && components[0].trim_prefix("occlusion_layer_").is_valid_integer()) { + if (components.size() == 2 && components[0].begins_with("occlusion_layer_") && components[0].trim_prefix("occlusion_layer_").is_valid_int()) { // Occlusion layers. int layer_index = components[0].trim_prefix("occlusion_layer_").to_int(); ERR_FAIL_COND_V(layer_index < 0, false); @@ -2546,7 +2546,7 @@ bool TileData::_set(const StringName &p_name, const Variant &p_value) { set_occluder(layer_index, polygon); return true; } - } else if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_integer()) { + } else if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) { // Physics layers. int layer_index = components[0].trim_prefix("physics_layer_").to_int(); ERR_FAIL_COND_V(layer_index < 0, false); @@ -2564,7 +2564,7 @@ bool TileData::_set(const StringName &p_name, const Variant &p_value) { } set_collision_shapes_count(layer_index, p_value); return true; - } else if (components.size() == 3 && components[1].begins_with("shape_") && components[1].trim_prefix("shape_").is_valid_integer()) { + } else if (components.size() == 3 && components[1].begins_with("shape_") && components[1].trim_prefix("shape_").is_valid_int()) { int shape_index = components[1].trim_prefix("shape_").to_int(); ERR_FAIL_COND_V(shape_index < 0, false); @@ -2593,7 +2593,7 @@ bool TileData::_set(const StringName &p_name, const Variant &p_value) { return true; } } - } else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_integer()) { + } else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) { // Navigation layers. int layer_index = components[0].trim_prefix("navigation_layer_").to_int(); ERR_FAIL_COND_V(layer_index < 0, false); @@ -2651,7 +2651,7 @@ bool TileData::_set(const StringName &p_name, const Variant &p_value) { return false; } return true; - } else if (components.size() == 1 && components[0].begins_with("custom_data_") && components[0].trim_prefix("custom_data_").is_valid_integer()) { + } else if (components.size() == 1 && components[0].begins_with("custom_data_") && components[0].trim_prefix("custom_data_").is_valid_int()) { // Custom data layers. int layer_index = components[0].trim_prefix("custom_data_").to_int(); ERR_FAIL_COND_V(layer_index < 0, false); @@ -2675,7 +2675,7 @@ bool TileData::_get(const StringName &p_name, Variant &r_ret) const { Vector<String> components = String(p_name).split("/", true, 2); if (tile_set) { - if (components.size() == 2 && components[0].begins_with("occlusion_layer") && components[0].trim_prefix("occlusion_layer_").is_valid_integer()) { + if (components.size() == 2 && components[0].begins_with("occlusion_layer") && components[0].trim_prefix("occlusion_layer_").is_valid_int()) { // Occlusion layers. int layer_index = components[0].trim_prefix("occlusion_layer_").to_int(); ERR_FAIL_COND_V(layer_index < 0, false); @@ -2686,7 +2686,7 @@ bool TileData::_get(const StringName &p_name, Variant &r_ret) const { r_ret = get_occluder(layer_index); return true; } - } else if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_integer()) { + } else if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) { // Physics layers. int layer_index = components[0].trim_prefix("physics_layer_").to_int(); ERR_FAIL_COND_V(layer_index < 0, false); @@ -2696,7 +2696,7 @@ bool TileData::_get(const StringName &p_name, Variant &r_ret) const { if (components.size() == 2 && components[1] == "shapes_count") { r_ret = get_collision_shapes_count(layer_index); return true; - } else if (components.size() == 3 && components[1].begins_with("shape_") && components[1].trim_prefix("shape_").is_valid_integer()) { + } else if (components.size() == 3 && components[1].begins_with("shape_") && components[1].trim_prefix("shape_").is_valid_int()) { int shape_index = components[1].trim_prefix("shape_").to_int(); ERR_FAIL_COND_V(shape_index < 0, false); if (shape_index >= physics[layer_index].shapes.size()) { @@ -2751,7 +2751,7 @@ bool TileData::_get(const StringName &p_name, Variant &r_ret) const { return false; } return true; - } else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_integer()) { + } else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) { // Occlusion layers. int layer_index = components[0].trim_prefix("navigation_layer_").to_int(); ERR_FAIL_COND_V(layer_index < 0, false); @@ -2762,7 +2762,7 @@ bool TileData::_get(const StringName &p_name, Variant &r_ret) const { r_ret = get_navigation_polygon(layer_index); return true; } - } else if (components.size() == 1 && components[0].begins_with("custom_data_") && components[0].trim_prefix("custom_data_").is_valid_integer()) { + } else if (components.size() == 1 && components[0].begins_with("custom_data_") && components[0].trim_prefix("custom_data_").is_valid_int()) { // Custom data layers. int layer_index = components[0].trim_prefix("custom_data_").to_int(); ERR_FAIL_COND_V(layer_index < 0, false); diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp index 8af4deda83..eceb42ee14 100644 --- a/scene/resources/world_2d.cpp +++ b/scene/resources/world_2d.cpp @@ -57,10 +57,10 @@ void World2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_direct_space_state"), &World2D::get_direct_space_state); - ADD_PROPERTY(PropertyInfo(Variant::RID, "canvas", PROPERTY_HINT_NONE, "", 0), "", "get_canvas"); - ADD_PROPERTY(PropertyInfo(Variant::RID, "space", PROPERTY_HINT_NONE, "", 0), "", "get_space"); - ADD_PROPERTY(PropertyInfo(Variant::RID, "navigation_map", PROPERTY_HINT_NONE, "", 0), "", "get_navigation_map"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectSpaceState2D", 0), "", "get_direct_space_state"); + ADD_PROPERTY(PropertyInfo(Variant::RID, "canvas", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_canvas"); + ADD_PROPERTY(PropertyInfo(Variant::RID, "space", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_space"); + ADD_PROPERTY(PropertyInfo(Variant::RID, "navigation_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_navigation_map"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectSpaceState2D", PROPERTY_USAGE_NONE), "", "get_direct_space_state"); } PhysicsDirectSpaceState2D *World2D::get_direct_space_state() { diff --git a/scene/resources/world_3d.cpp b/scene/resources/world_3d.cpp index 8d9b1fd6ec..42047f104f 100644 --- a/scene/resources/world_3d.cpp +++ b/scene/resources/world_3d.cpp @@ -130,10 +130,10 @@ void World3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "Environment"), "set_environment", "get_environment"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "fallback_environment", PROPERTY_HINT_RESOURCE_TYPE, "Environment"), "set_fallback_environment", "get_fallback_environment"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "camera_effects", PROPERTY_HINT_RESOURCE_TYPE, "CameraEffects"), "set_camera_effects", "get_camera_effects"); - ADD_PROPERTY(PropertyInfo(Variant::RID, "space", PROPERTY_HINT_NONE, "", 0), "", "get_space"); - ADD_PROPERTY(PropertyInfo(Variant::RID, "navigation_map", PROPERTY_HINT_NONE, "", 0), "", "get_navigation_map"); - ADD_PROPERTY(PropertyInfo(Variant::RID, "scenario", PROPERTY_HINT_NONE, "", 0), "", "get_scenario"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectSpaceState3D", 0), "", "get_direct_space_state"); + ADD_PROPERTY(PropertyInfo(Variant::RID, "space", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_space"); + ADD_PROPERTY(PropertyInfo(Variant::RID, "navigation_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_navigation_map"); + ADD_PROPERTY(PropertyInfo(Variant::RID, "scenario", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_scenario"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectSpaceState3D", PROPERTY_USAGE_NONE), "", "get_direct_space_state"); } World3D::World3D() { diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp index 60c7dbf3b7..e0d0ce76be 100644 --- a/servers/rendering/renderer_scene_cull.cpp +++ b/servers/rendering/renderer_scene_cull.cpp @@ -2578,10 +2578,10 @@ void RendererSceneCull::_scene_cull(CullData &cull_data, InstanceCullResult &cul #define HIDDEN_BY_VISIBILITY_CHECKS (visibility_flags == InstanceData::FLAG_VISIBILITY_DEPENDENCY_HIDDEN_CLOSE_RANGE || visibility_flags == InstanceData::FLAG_VISIBILITY_DEPENDENCY_HIDDEN) #define LAYER_CHECK (cull_data.visible_layers & idata.layer_mask) #define IN_FRUSTUM(f) (cull_data.scenario->instance_aabbs[i].in_frustum(f)) -#define VIS_RANGE_CHECK ((idata.visibility_index == -1) || _visibility_range_check(cull_data.scenario->instance_visibility[idata.visibility_index], cull_data.cam_transform.origin, cull_data.visibility_cull_data->viewport_mask) == 0) +#define VIS_RANGE_CHECK ((idata.visibility_index == -1) || _visibility_range_check(cull_data.scenario->instance_visibility[idata.visibility_index], cull_data.cam_transform.origin, cull_data.visibility_viewport_mask) == 0) #define VIS_PARENT_CHECK ((idata.parent_array_index == -1) || ((cull_data.scenario->instance_data[idata.parent_array_index].flags & InstanceData::FLAG_VISIBILITY_DEPENDENCY_NEEDS_CHECK) == InstanceData::FLAG_VISIBILITY_DEPENDENCY_HIDDEN_CLOSE_RANGE)) #define VIS_CHECK (visibility_check < 0 ? (visibility_check = (visibility_flags != InstanceData::FLAG_VISIBILITY_DEPENDENCY_NEEDS_CHECK || (VIS_RANGE_CHECK && VIS_PARENT_CHECK))) : visibility_check) -#define OCCLUSION_CULLED (cull_data.occlusion_buffer != nullptr && cull_data.scenario->instance_data[i].flags & InstanceData::FLAG_IGNORE_OCCLUSION_CULLING && cull_data.occlusion_buffer->is_occluded(cull_data.scenario->instance_aabbs[i].bounds, cull_data.cam_transform.origin, inv_cam_transform, *cull_data.camera_matrix, z_near)) +#define OCCLUSION_CULLED (cull_data.occlusion_buffer != nullptr && (cull_data.scenario->instance_data[i].flags & InstanceData::FLAG_IGNORE_OCCLUSION_CULLING) == 0 && cull_data.occlusion_buffer->is_occluded(cull_data.scenario->instance_aabbs[i].bounds, cull_data.cam_transform.origin, inv_cam_transform, *cull_data.camera_matrix, z_near)) if (!HIDDEN_BY_VISIBILITY_CHECKS) { if (LAYER_CHECK && IN_FRUSTUM(cull_data.cull->frustum) && VIS_CHECK && !OCCLUSION_CULLED) { @@ -2808,12 +2808,12 @@ void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_c RENDER_TIMESTAMP("Visibility Dependencies"); - VisibilityCullData visibility_cull_data; if (scenario->instance_visibility.get_bin_count() > 0) { if (!scenario->viewport_visibility_masks.has(p_viewport)) { scenario_add_viewport_visibility_mask(scenario->self, p_viewport); } + VisibilityCullData visibility_cull_data; visibility_cull_data.scenario = scenario; visibility_cull_data.viewport_mask = scenario->viewport_visibility_masks[p_viewport]; visibility_cull_data.camera_position = p_camera_data->main_transform.origin; @@ -2924,6 +2924,7 @@ void RendererSceneCull::_render_scene(const RendererSceneRender::CameraData *p_c cull_data.render_reflection_probe = render_reflection_probe; cull_data.occlusion_buffer = RendererSceneOcclusionCull::get_singleton()->buffer_get_ptr(p_viewport); cull_data.camera_matrix = &p_camera_data->main_projection; + cull_data.visibility_viewport_mask = scenario->viewport_visibility_masks.has(p_viewport) ? scenario->viewport_visibility_masks[p_viewport] : 0; //#define DEBUG_CULL_TIME #ifdef DEBUG_CULL_TIME uint64_t time_from = OS::get_singleton()->get_ticks_usec(); diff --git a/servers/rendering/renderer_scene_cull.h b/servers/rendering/renderer_scene_cull.h index d9466d8b04..652d322731 100644 --- a/servers/rendering/renderer_scene_cull.h +++ b/servers/rendering/renderer_scene_cull.h @@ -1016,7 +1016,7 @@ public: Instance *render_reflection_probe; const RendererSceneOcclusionCull::HZBuffer *occlusion_buffer; const CameraMatrix *camera_matrix; - const VisibilityCullData *visibility_cull_data; + uint64_t visibility_viewport_mask; }; void _scene_cull_threaded(uint32_t p_thread, CullData *cull_data); diff --git a/servers/rendering/renderer_scene_render.cpp b/servers/rendering/renderer_scene_render.cpp index 3aa97f4084..3a230ac89d 100644 --- a/servers/rendering/renderer_scene_render.cpp +++ b/servers/rendering/renderer_scene_render.cpp @@ -175,7 +175,7 @@ void RendererSceneRender::CameraData::set_multiview_camera(uint32_t p_view_count ///////////////////////////////////////////////////////////////////////////// // 3. Copy our view data for (uint32_t v = 0; v < view_count; v++) { - view_offset[v] = p_transforms[v] * main_transform_inv; - view_projection[v] = p_projections[v] * CameraMatrix(view_offset[v]); + view_offset[v] = main_transform_inv * p_transforms[v]; + view_projection[v] = p_projections[v] * CameraMatrix(view_offset[v].inverse()); } } diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 8ed774f8e7..9b2ba36358 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -631,7 +631,7 @@ ShaderLanguage::Token ShaderLanguage::_get_token() { if (!_is_number(last_char)) { return _make_token(TK_ERROR, "Invalid (integer) numeric constant"); } - if (!str.is_valid_integer()) { + if (!str.is_valid_int()) { return _make_token(TK_ERROR, "Invalid numeric constant"); } } diff --git a/tests/test_config_file.h b/tests/test_config_file.h index 958341018b..33fd30ffa1 100644 --- a/tests/test_config_file.h +++ b/tests/test_config_file.h @@ -138,8 +138,8 @@ name="Unnamed Player" tagline="Waiting for Godot" -color=Color( 0, 0.5, 1, 1 ) -position=Vector2( 3, 4 ) +color=Color(0, 0.5, 1, 1) +position=Vector2(3, 4) [graphics] diff --git a/tests/test_json.h b/tests/test_json.h index f1cb4799dc..60c4991a57 100644 --- a/tests/test_json.h +++ b/tests/test_json.h @@ -45,75 +45,65 @@ TEST_CASE("[JSON] Parsing single data types") { // Parsing a single data type as JSON is valid per the JSON specification. JSON json; - Variant result; - String err_str; - int err_line; - json.parse("null", result, err_str, err_line); + json.parse("null"); CHECK_MESSAGE( - err_line == 0, + json.get_error_line() == 0, "Parsing `null` as JSON should parse successfully."); CHECK_MESSAGE( - result == Variant(), + json.get_data() == Variant(), "Parsing a double quoted string as JSON should return the expected value."); - json.parse("true", result, err_str, err_line); + json.parse("true"); CHECK_MESSAGE( - err_line == 0, + json.get_error_line() == 0, "Parsing boolean `true` as JSON should parse successfully."); CHECK_MESSAGE( - result, + json.get_data(), "Parsing boolean `true` as JSON should return the expected value."); - json.parse("false", result, err_str, err_line); + json.parse("false"); CHECK_MESSAGE( - err_line == 0, + json.get_error_line() == 0, "Parsing boolean `false` as JSON should parse successfully."); CHECK_MESSAGE( - !result, + !json.get_data(), "Parsing boolean `false` as JSON should return the expected value."); - // JSON only has a floating-point number type, no integer type. - // This is why we use `is_equal_approx()` for the comparison. - json.parse("123456", result, err_str, err_line); + json.parse("123456"); CHECK_MESSAGE( - err_line == 0, + json.get_error_line() == 0, "Parsing an integer number as JSON should parse successfully."); CHECK_MESSAGE( - (int)result == 123'456, + (int)(json.get_data()) == 123456, "Parsing an integer number as JSON should return the expected value."); - json.parse("0.123456", result, err_str, err_line); + json.parse("0.123456"); CHECK_MESSAGE( - err_line == 0, + json.get_error_line() == 0, "Parsing a floating-point number as JSON should parse successfully."); CHECK_MESSAGE( - Math::is_equal_approx(result, 0.123456), + Math::is_equal_approx(json.get_data(), 0.123456), "Parsing a floating-point number as JSON should return the expected value."); - json.parse("\"hello\"", result, err_str, err_line); + json.parse("\"hello\""); CHECK_MESSAGE( - err_line == 0, + json.get_error_line() == 0, "Parsing a double quoted string as JSON should parse successfully."); CHECK_MESSAGE( - result == "hello", + json.get_data() == "hello", "Parsing a double quoted string as JSON should return the expected value."); } TEST_CASE("[JSON] Parsing arrays") { JSON json; - Variant result; - String err_str; - int err_line; // JSON parsing fails if it's split over several lines (even if leading indentation is removed). - json.parse( - R"(["Hello", "world.", "This is",["a","json","array.",[]], "Empty arrays ahoy:", [[["Gotcha!"]]]])", - result, err_str, err_line); + json.parse(R"(["Hello", "world.", "This is",["a","json","array.",[]], "Empty arrays ahoy:", [[["Gotcha!"]]]])"); - const Array array = result; + const Array array = json.get_data(); CHECK_MESSAGE( - err_line == 0, + json.get_error_line() == 0, "Parsing a JSON array should parse successfully."); CHECK_MESSAGE( array[0] == "Hello", @@ -136,15 +126,10 @@ TEST_CASE("[JSON] Parsing arrays") { TEST_CASE("[JSON] Parsing objects (dictionaries)") { JSON json; - Variant result; - String err_str; - int err_line; - json.parse( - R"({"name": "Godot Engine", "is_free": true, "bugs": null, "apples": {"red": 500, "green": 0, "blue": -20}, "empty_object": {}})", - result, err_str, err_line); + json.parse(R"({"name": "Godot Engine", "is_free": true, "bugs": null, "apples": {"red": 500, "green": 0, "blue": -20}, "empty_object": {}})"); - const Dictionary dictionary = result; + const Dictionary dictionary = json.get_data(); CHECK_MESSAGE( dictionary["name"] == "Godot Engine", "The parsed JSON should contain the expected values."); diff --git a/tests/test_string.h b/tests/test_string.h index 7f404a34e8..1982d8de60 100644 --- a/tests/test_string.h +++ b/tests/test_string.h @@ -1317,7 +1317,7 @@ TEST_CASE("[String] Is_*") { for (int i = 0; i < 12; i++) { String s = String(data[i]); CHECK(s.is_numeric() == isnum[i]); - CHECK(s.is_valid_integer() == isint[i]); + CHECK(s.is_valid_int() == isint[i]); CHECK(s.is_valid_hex_number(false) == ishex[i]); CHECK(s.is_valid_hex_number(true) == ishex_p[i]); CHECK(s.is_valid_float() == isflt[i]); diff --git a/thirdparty/misc/easing_equations.cpp b/thirdparty/misc/easing_equations.cpp index af48aaf079..ce32c1a362 100644 --- a/thirdparty/misc/easing_equations.cpp +++ b/thirdparty/misc/easing_equations.cpp @@ -297,7 +297,7 @@ static real_t out_in(real_t t, real_t b, real_t c, real_t d) { } }; // namespace back -Tween::interpolater Tween::interpolaters[Tween::TRANS_COUNT][Tween::EASE_COUNT] = { +Tween::interpolater Tween::interpolaters[Tween::TRANS_MAX][Tween::EASE_MAX] = { { &linear::in, &linear::out, &linear::in_out, &linear::out_in }, { &sine::in, &sine::out, &sine::in_out, &sine::out_in }, { &quint::in, &quint::out, &quint::in_out, &quint::out_in }, @@ -311,7 +311,7 @@ Tween::interpolater Tween::interpolaters[Tween::TRANS_COUNT][Tween::EASE_COUNT] { &back::in, &back::out, &back::in_out, &back::out_in }, }; -real_t Tween::_run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t t, real_t b, real_t c, real_t d) { +real_t Tween::run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t t, real_t b, real_t c, real_t d) { interpolater cb = interpolaters[p_trans_type][p_ease_type]; ERR_FAIL_COND_V(cb == NULL, b); |