diff options
65 files changed, 621 insertions, 171 deletions
diff --git a/core/io/ip.cpp b/core/io/ip.cpp index 420e48f839..3d87131b51 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -234,6 +234,41 @@ Array IP::_get_local_addresses() const { return addresses; } +Array IP::_get_local_interfaces() const { + + Array results; + Map<String, Interface_Info> interfaces; + get_local_interfaces(&interfaces); + for (Map<String, Interface_Info>::Element *E = interfaces.front(); E; E = E->next()) { + Interface_Info &c = E->get(); + Dictionary rc; + rc["name"] = c.name; + rc["friendly"] = c.name_friendly; + rc["index"] = c.index; + + Array ips; + for (const List<IP_Address>::Element *F = c.ip_addresses.front(); F; F = F->next()) { + ips.push_front(F->get()); + } + rc["addresses"] = ips; + + results.push_front(rc); + } + + return results; +} + +void IP::get_local_addresses(List<IP_Address> *r_addresses) const { + + Map<String, Interface_Info> interfaces; + get_local_interfaces(&interfaces); + for (Map<String, Interface_Info>::Element *E = interfaces.front(); E; E = E->next()) { + for (const List<IP_Address>::Element *F = E->get().ip_addresses.front(); F; F = F->next()) { + r_addresses->push_front(F->get()); + } + } +} + void IP::_bind_methods() { ClassDB::bind_method(D_METHOD("resolve_hostname", "host", "ip_type"), &IP::resolve_hostname, DEFVAL(IP::TYPE_ANY)); @@ -242,6 +277,7 @@ void IP::_bind_methods() { ClassDB::bind_method(D_METHOD("get_resolve_item_address", "id"), &IP::get_resolve_item_address); ClassDB::bind_method(D_METHOD("erase_resolve_item", "id"), &IP::erase_resolve_item); ClassDB::bind_method(D_METHOD("get_local_addresses"), &IP::_get_local_addresses); + ClassDB::bind_method(D_METHOD("get_local_interfaces"), &IP::_get_local_interfaces); ClassDB::bind_method(D_METHOD("clear_cache", "hostname"), &IP::clear_cache, DEFVAL("")); BIND_ENUM_CONSTANT(RESOLVER_STATUS_NONE); diff --git a/core/io/ip.h b/core/io/ip.h index ead71ebb54..59b18ef986 100644 --- a/core/io/ip.h +++ b/core/io/ip.h @@ -73,16 +73,25 @@ protected: virtual IP_Address _resolve_hostname(const String &p_hostname, Type p_type = TYPE_ANY) = 0; Array _get_local_addresses() const; + Array _get_local_interfaces() const; static IP *(*_create)(); public: + struct Interface_Info { + String name; + String name_friendly; + String index; + List<IP_Address> ip_addresses; + }; + IP_Address resolve_hostname(const String &p_hostname, Type p_type = TYPE_ANY); // async resolver hostname ResolverID resolve_hostname_queue_item(const String &p_hostname, Type p_type = TYPE_ANY); ResolverStatus get_resolve_item_status(ResolverID p_id) const; IP_Address get_resolve_item_address(ResolverID p_id) const; - virtual void get_local_addresses(List<IP_Address> *r_addresses) const = 0; + virtual void get_local_addresses(List<IP_Address> *r_addresses) const; + virtual void get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const = 0; void erase_resolve_item(ResolverID p_id); void clear_cache(const String &p_hostname = ""); diff --git a/core/io/ip_address.cpp b/core/io/ip_address.cpp index 763a5fbb9a..9305afac5f 100644 --- a/core/io/ip_address.cpp +++ b/core/io/ip_address.cpp @@ -40,6 +40,9 @@ IP_Address::operator Variant() const { IP_Address::operator String() const { + if (wildcard) + return "*"; + if (!valid) return ""; diff --git a/core/io/net_socket.h b/core/io/net_socket.h index 94e7ef6f75..3bc1369487 100644 --- a/core/io/net_socket.h +++ b/core/io/net_socket.h @@ -74,6 +74,8 @@ public: virtual void set_ipv6_only_enabled(bool p_enabled) = 0; virtual void set_tcp_no_delay_enabled(bool p_enabled) = 0; virtual void set_reuse_address_enabled(bool p_enabled) = 0; + virtual Error join_multicast_group(const IP_Address &p_multi_address, String p_if_name) = 0; + virtual Error leave_multicast_group(const IP_Address &p_multi_address, String p_if_name) = 0; }; #endif // NET_SOCKET_H diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp index 5912b8df94..7e9471c053 100644 --- a/core/io/packet_peer_udp.cpp +++ b/core/io/packet_peer_udp.cpp @@ -37,6 +37,27 @@ void PacketPeerUDP::set_blocking_mode(bool p_enable) { blocking = p_enable; } +Error PacketPeerUDP::join_multicast_group(IP_Address p_multi_address, String p_if_name) { + + ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE); + ERR_FAIL_COND_V(!p_multi_address.is_valid(), ERR_INVALID_PARAMETER); + + if (!_sock->is_open()) { + IP::Type ip_type = p_multi_address.is_ipv4() ? IP::TYPE_IPV4 : IP::TYPE_IPV6; + Error err = _sock->open(NetSocket::TYPE_UDP, ip_type); + ERR_FAIL_COND_V(err != OK, err); + _sock->set_blocking_enabled(false); + } + return _sock->join_multicast_group(p_multi_address, p_if_name); +} + +Error PacketPeerUDP::leave_multicast_group(IP_Address p_multi_address, String p_if_name) { + + ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE); + ERR_FAIL_COND_V(!_sock->is_open(), ERR_UNCONFIGURED); + return _sock->leave_multicast_group(p_multi_address, p_if_name); +} + String PacketPeerUDP::_get_packet_ip() const { return get_packet_address(); @@ -237,6 +258,8 @@ void PacketPeerUDP::_bind_methods() { ClassDB::bind_method(D_METHOD("get_packet_ip"), &PacketPeerUDP::_get_packet_ip); ClassDB::bind_method(D_METHOD("get_packet_port"), &PacketPeerUDP::get_packet_port); ClassDB::bind_method(D_METHOD("set_dest_address", "host", "port"), &PacketPeerUDP::_set_dest_address); + ClassDB::bind_method(D_METHOD("join_multicast_group", "multicast_address", "interface_name"), &PacketPeerUDP::join_multicast_group); + ClassDB::bind_method(D_METHOD("leave_multicast_group", "multicast_address", "interface_name"), &PacketPeerUDP::leave_multicast_group); } PacketPeerUDP::PacketPeerUDP() : diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h index 0593137604..068bd5cd5a 100644 --- a/core/io/packet_peer_udp.h +++ b/core/io/packet_peer_udp.h @@ -77,6 +77,8 @@ public: Error get_packet(const uint8_t **r_buffer, int &r_buffer_size); int get_available_packet_count() const; int get_max_packet_size() const; + Error join_multicast_group(IP_Address p_multi_address, String p_if_name); + Error leave_multicast_group(IP_Address p_multi_address, String p_if_name); PacketPeerUDP(); ~PacketPeerUDP(); diff --git a/core/os/os.h b/core/os/os.h index 514e1e2ad3..1b19ddff26 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -222,6 +222,8 @@ public: virtual bool is_window_maximized() const { return true; } virtual void set_window_always_on_top(bool p_enabled) {} virtual bool is_window_always_on_top() const { return false; } + virtual void set_console_visible(bool p_enabled) {} + virtual bool is_console_visible() const { return false; } virtual void request_attention() {} virtual void center_window(); diff --git a/doc/classes/AudioEffectPitchShift.xml b/doc/classes/AudioEffectPitchShift.xml index 7d6c5f2b20..8c22afb40f 100644 --- a/doc/classes/AudioEffectPitchShift.xml +++ b/doc/classes/AudioEffectPitchShift.xml @@ -12,10 +12,26 @@ <methods> </methods> <members> + <member name="fft_size" type="int" setter="set_fft_size" getter="get_fft_size" enum="AudioEffectPitchShift.FFT_Size"> + </member> + <member name="oversampling" type="int" setter="set_oversampling" getter="get_oversampling"> + </member> <member name="pitch_scale" type="float" setter="set_pitch_scale" getter="get_pitch_scale"> Pitch value. Can range from 0 (-1 octave) to 16 (+16 octaves). </member> </members> <constants> + <constant name="FFT_SIZE_256" value="0" enum="FFT_Size"> + </constant> + <constant name="FFT_SIZE_512" value="1" enum="FFT_Size"> + </constant> + <constant name="FFT_SIZE_1024" value="2" enum="FFT_Size"> + </constant> + <constant name="FFT_SIZE_2048" value="3" enum="FFT_Size"> + </constant> + <constant name="FFT_SIZE_4096" value="4" enum="FFT_Size"> + </constant> + <constant name="FFT_SIZE_MAX" value="5" enum="FFT_Size"> + </constant> </constants> </class> diff --git a/doc/classes/ColorPicker.xml b/doc/classes/ColorPicker.xml index 1fefc719b7..0ab91e9621 100644 --- a/doc/classes/ColorPicker.xml +++ b/doc/classes/ColorPicker.xml @@ -45,14 +45,14 @@ <member name="edit_alpha" type="bool" setter="set_edit_alpha" getter="is_editing_alpha"> If [code]true[/code], shows an alpha channel slider (transparency). </member> - <member name="presets_enabled" type="bool" setter="set_presets_enabled" getter="are_presets_enabled"> - </member> - <member name="presets_visible" type="bool" setter="set_presets_visible" getter="are_presets_visible"> - </member> <member name="hsv_mode" type="bool" setter="set_hsv_mode" getter="is_hsv_mode"> If [code]true[/code], allows to edit color with Hue/Saturation/Value sliders. [b]Note:[/b] Cannot be enabled if raw mode is on. </member> + <member name="presets_enabled" type="bool" setter="set_presets_enabled" getter="are_presets_enabled"> + </member> + <member name="presets_visible" type="bool" setter="set_presets_visible" getter="are_presets_visible"> + </member> <member name="raw_mode" type="bool" setter="set_raw_mode" getter="is_raw_mode"> If [code]true[/code], allows the color R, G, B component values to go beyond 1.0, which can be used for certain special operations that require it (like tinting without darkening or rendering sprites in HDR). [b]Note:[/b] Cannot be enabled if hsv mode is on. diff --git a/doc/classes/Engine.xml b/doc/classes/Engine.xml index ac46d34198..d446363a83 100644 --- a/doc/classes/Engine.xml +++ b/doc/classes/Engine.xml @@ -85,14 +85,16 @@ </return> <description> Returns the current engine version information in a Dictionary. - "major" - Holds the major version number as an int - "minor" - Holds the minor version number as an int - "patch" - Holds the patch version number as an int - "hex" - Holds the full version number encoded as an hexadecimal int with one byte (2 places) per number (see example below) - "status" - Holds the status (e.g. "beta", "rc1", "rc2", ... "stable") as a String - "build" - Holds the build name (e.g. "custom-build") as a String - "string" - major + minor + patch + status + build in a single String - The "hex" value is encoded as follows, from left to right: one byte for the major, one byte for the minor, one byte for the patch version. For example, "3.1.12" would be [code]0x03010C[/code]. Note that it's still an int internally, and printing it will give you its decimal representation, which is not particularly meaningful. Use hexadecimal literals for easy version comparisons from code: + [code]major[/code] - Holds the major version number as an int + [code]minor[/code] - Holds the minor version number as an int + [code]patch[/code] - Holds the patch version number as an int + [code]hex[/code] - Holds the full version number encoded as an hexadecimal int with one byte (2 places) per number (see example below) + [code]status[/code] - Holds the status (e.g. "beta", "rc1", "rc2", ... "stable") as a String + [code]build[/code] - Holds the build name (e.g. "custom_build") as a String + [code]hash[/code] - Holds the full Git commit hash as a String + [code]year[/code] - Holds the year the version was released in as an int + [code]string[/code] - [code]major[/code] + [code]minor[/code] + [code]patch[/code] + [code]status[/code] + [code]build[/code] in a single String + The [code]hex[/code] value is encoded as follows, from left to right: one byte for the major, one byte for the minor, one byte for the patch version. For example, "3.1.12" would be [code]0x03010C[/code]. Note that it's still an int internally, and printing it will give you its decimal representation, which is not particularly meaningful. Use hexadecimal literals for easy version comparisons from code: [codeblock] if Engine.get_version_info().hex >= 0x030200: # do things specific to version 3.2 or later diff --git a/doc/classes/IP.xml b/doc/classes/IP.xml index 3616a9ec50..65b1700333 100644 --- a/doc/classes/IP.xml +++ b/doc/classes/IP.xml @@ -34,6 +34,22 @@ Returns all of the user's current IPv4 and IPv6 addresses as an array. </description> </method> + <method name="get_local_interfaces" qualifiers="const"> + <return type="Array"> + </return> + <description> + Returns all network adapters as an array. + Each adapter is a dictionary of the form: + [codeblock] + { + "index": "1", # Interface index. + "name": "eth0", # Interface name. + "friendly": "Ethernet One", # A friendly name (might be empty). + "addresses": ["192.168.1.101"], # An array of IP addresses associated to this interface. + } + [/codeblock] + </description> + </method> <method name="get_resolve_item_address" qualifiers="const"> <return type="String"> </return> diff --git a/doc/classes/PacketPeerUDP.xml b/doc/classes/PacketPeerUDP.xml index 9843c16108..376818fb86 100644 --- a/doc/classes/PacketPeerUDP.xml +++ b/doc/classes/PacketPeerUDP.xml @@ -37,6 +37,29 @@ Returns whether this [PacketPeerUDP] is listening. </description> </method> + <method name="join_multicast_group"> + <return type="int" enum="Error"> + </return> + <argument index="0" name="multicast_address" type="String"> + </argument> + <argument index="1" name="interface_name" type="String"> + </argument> + <description> + Join the multicast group specified by [code]multicast_address[/code] using the interface identified by [code]interface_name[/code]. + You can join the same multicast group with multiple interfaces. Use [method IP.get_local_interfaces] to know which are available. + </description> + </method> + <method name="leave_multicast_group"> + <return type="int" enum="Error"> + </return> + <argument index="0" name="multicast_address" type="String"> + </argument> + <argument index="1" name="interface_name" type="String"> + </argument> + <description> + Remove the interface identified by [code]interface_name[/code] from the multicast group specified by [code]multicast_address[/code]. + </description> + </method> <method name="listen"> <return type="int" enum="Error"> </return> diff --git a/doc/classes/String.xml b/doc/classes/String.xml index ff0572f384..6395fe2ce8 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -388,6 +388,18 @@ Converts a string containing a hexadecimal number into an integer. </description> </method> + <method name="http_escape"> + <return type="String"> + </return> + <description> + </description> + </method> + <method name="http_unescape"> + <return type="String"> + </return> + <description> + </description> + </method> <method name="insert"> <return type="String"> </return> diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml index 8139da3a4c..e818d753d8 100644 --- a/doc/classes/TextEdit.xml +++ b/doc/classes/TextEdit.xml @@ -44,6 +44,12 @@ Returns if the given line is foldable, that is, it has indented lines right below it. </description> </method> + <method name="center_viewport_to_cursor"> + <return type="void"> + </return> + <description> + </description> + </method> <method name="clear_colors"> <return type="void"> </return> diff --git a/doc/classes/VisualShaderNodeGroupBase.xml b/doc/classes/VisualShaderNodeGroupBase.xml index 37d48956f6..c2e9b9503b 100644 --- a/doc/classes/VisualShaderNodeGroupBase.xml +++ b/doc/classes/VisualShaderNodeGroupBase.xml @@ -109,6 +109,14 @@ <description> </description> </method> + <method name="is_valid_port_name" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="name" type="String"> + </argument> + <description> + </description> + </method> <method name="remove_input_port"> <return type="void"> </return> diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 0840717d68..96094dd0ad 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -6074,10 +6074,7 @@ void RasterizerStorageGLES3::particles_set_emitting(RID p_particles, bool p_emit Particles *particles = particles_owner.getornull(p_particles); ERR_FAIL_COND(!particles); - if (p_emitting != particles->emitting) { - // Restart is overridden by set_emitting - particles->restart_request = false; - } + particles->emitting = p_emitting; } @@ -6475,7 +6472,6 @@ void RasterizerStorageGLES3::update_particles() { Particles *particles = particle_update_list.first()->self(); if (particles->restart_request) { - particles->emitting = true; //restart from zero particles->prev_ticks = 0; particles->phase = 0; particles->prev_phase = 0; diff --git a/drivers/unix/ip_unix.cpp b/drivers/unix/ip_unix.cpp index b5feaabc32..39ca9a823e 100644 --- a/drivers/unix/ip_unix.cpp +++ b/drivers/unix/ip_unix.cpp @@ -56,6 +56,7 @@ #endif // MINGW hack #endif #else // UNIX +#include <net/if.h> #include <netdb.h> #ifdef ANDROID_ENABLED // We could drop this file once we up our API level to 24, @@ -77,6 +78,7 @@ static IP_Address _sockaddr2ip(struct sockaddr *p_addr) { IP_Address ip; + if (p_addr->sa_family == AF_INET) { struct sockaddr_in *addr = (struct sockaddr_in *)p_addr; ip.set_ipv4((uint8_t *)&(addr->sin_addr)); @@ -129,24 +131,42 @@ IP_Address IP_Unix::_resolve_hostname(const String &p_hostname, Type p_type) { #if defined(UWP_ENABLED) -void IP_Unix::get_local_addresses(List<IP_Address> *r_addresses) const { +void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const { using namespace Windows::Networking; using namespace Windows::Networking::Connectivity; + // Returns addresses, not interfaces. auto hostnames = NetworkInformation::GetHostNames(); for (int i = 0; i < hostnames->Size; i++) { - if (hostnames->GetAt(i)->Type == HostNameType::Ipv4 || hostnames->GetAt(i)->Type == HostNameType::Ipv6 && hostnames->GetAt(i)->IPInformation != nullptr) { + auto hostname = hostnames->GetAt(i); + + if (hostname->Type != HostNameType::Ipv4 && hostname->Type != HostNameType::Ipv6) + continue; - r_addresses->push_back(IP_Address(String(hostnames->GetAt(i)->CanonicalName->Data()))); + String name = hostname->RawName->Data(); + Map<String, Interface_Info>::Element *E = r_interfaces->find(name); + if (!E) { + Interface_Info info; + info.name = name; + info.name_friendly = hostname->DisplayName->Data(); + info.index = 0; + E = r_interfaces->insert(name, info); + ERR_CONTINUE(!E); } + + Interface_Info &info = E->get(); + + IP_Address ip = IP_Address(hostname->CanonicalName->Data()); + info.ip_addresses.push_front(ip); } -}; +} + #else -void IP_Unix::get_local_addresses(List<IP_Address> *r_addresses) const { +void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const { ULONG buf_size = 1024; IP_ADAPTER_ADDRESSES *addrs; @@ -173,29 +193,23 @@ void IP_Unix::get_local_addresses(List<IP_Address> *r_addresses) const { while (adapter != NULL) { + Interface_Info info; + info.name = adapter->AdapterName; + info.name_friendly = adapter->FriendlyName; + info.index = String::num_uint64(adapter->IfIndex); + IP_ADAPTER_UNICAST_ADDRESS *address = adapter->FirstUnicastAddress; while (address != NULL) { - - IP_Address ip; - - if (address->Address.lpSockaddr->sa_family == AF_INET) { - - SOCKADDR_IN *ipv4 = reinterpret_cast<SOCKADDR_IN *>(address->Address.lpSockaddr); - - ip.set_ipv4((uint8_t *)&(ipv4->sin_addr)); - r_addresses->push_back(ip); - - } else if (address->Address.lpSockaddr->sa_family == AF_INET6) { // ipv6 - - SOCKADDR_IN6 *ipv6 = reinterpret_cast<SOCKADDR_IN6 *>(address->Address.lpSockaddr); - - ip.set_ipv6(ipv6->sin6_addr.s6_addr); - r_addresses->push_back(ip); - }; - + int family = address->Address.lpSockaddr->sa_family; + if (family != AF_INET && family != AF_INET6) + continue; + info.ip_addresses.push_front(_sockaddr2ip(address->Address.lpSockaddr)); address = address->Next; - }; + } adapter = adapter->Next; + // Only add interface if it has at least one IP + if (info.ip_addresses.size() > 0) + r_interfaces->insert(info.name, info); }; memfree(addrs); @@ -205,7 +219,7 @@ void IP_Unix::get_local_addresses(List<IP_Address> *r_addresses) const { #else // UNIX -void IP_Unix::get_local_addresses(List<IP_Address> *r_addresses) const { +void IP_Unix::get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const { struct ifaddrs *ifAddrStruct = NULL; struct ifaddrs *ifa = NULL; @@ -222,8 +236,18 @@ void IP_Unix::get_local_addresses(List<IP_Address> *r_addresses) const { if (family != AF_INET && family != AF_INET6) continue; - IP_Address ip = _sockaddr2ip(ifa->ifa_addr); - r_addresses->push_back(ip); + Map<String, Interface_Info>::Element *E = r_interfaces->find(ifa->ifa_name); + if (!E) { + Interface_Info info; + info.name = ifa->ifa_name; + info.name_friendly = ifa->ifa_name; + info.index = String::num_uint64(if_nametoindex(ifa->ifa_name)); + E = r_interfaces->insert(ifa->ifa_name, info); + ERR_CONTINUE(!E); + } + + Interface_Info &info = E->get(); + info.ip_addresses.push_front(_sockaddr2ip(ifa->ifa_addr)); } if (ifAddrStruct != NULL) freeifaddrs(ifAddrStruct); diff --git a/drivers/unix/ip_unix.h b/drivers/unix/ip_unix.h index e36535146e..f9bb626cc4 100644 --- a/drivers/unix/ip_unix.h +++ b/drivers/unix/ip_unix.h @@ -43,7 +43,7 @@ class IP_Unix : public IP { static IP *_create_unix(); public: - virtual void get_local_addresses(List<IP_Address> *r_addresses) const; + virtual void get_local_interfaces(Map<String, Interface_Info> *r_interfaces) const; static void make_default(); IP_Unix(); diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp index fcd1c3be4b..4bde7789e2 100644 --- a/drivers/unix/net_socket_posix.cpp +++ b/drivers/unix/net_socket_posix.cpp @@ -59,6 +59,14 @@ #define MSG_NOSIGNAL SO_NOSIGPIPE #endif +// BSD calls this flag IPV6_JOIN_GROUP +#if !defined(IPV6_ADD_MEMBERSHIP) && defined(IPV6_JOIN_GROUP) +#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP +#endif +#if !defined(IPV6_DROP_MEMBERSHIP) && defined(IPV6_LEAVE_GROUP) +#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP +#endif + // Some custom defines to minimize ifdefs #define SOCK_EMPTY -1 #define SOCK_BUF(x) x @@ -227,6 +235,58 @@ bool NetSocketPosix::_can_use_ip(const IP_Address p_ip, const bool p_for_bind) c return true; } +_FORCE_INLINE_ Error NetSocketPosix::_change_multicast_group(IP_Address p_ip, String p_if_name, bool p_add) { + + ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED); + ERR_FAIL_COND_V(!_can_use_ip(p_ip, false), ERR_INVALID_PARAMETER); + + // Need to force level and af_family to IP(v4) when using dual stacking and provided multicast group is IPv4 + IP::Type type = _ip_type == IP::TYPE_ANY && p_ip.is_ipv4() ? IP::TYPE_IPV4 : _ip_type; + // This needs to be the proper level for the multicast group, no matter if the socket is dual stacking. + int level = type == IP::TYPE_IPV4 ? IPPROTO_IP : IPPROTO_IPV6; + int ret = -1; + + IP_Address if_ip; + uint32_t if_v6id = 0; + Map<String, IP::Interface_Info> if_info; + IP::get_singleton()->get_local_interfaces(&if_info); + for (Map<String, IP::Interface_Info>::Element *E = if_info.front(); E; E = E->next()) { + IP::Interface_Info &c = E->get(); + if (c.name != p_if_name) + continue; + + if_v6id = (uint32_t)c.index.to_int64(); + if (type == IP::TYPE_IPV6) + break; // IPv6 uses index. + + for (List<IP_Address>::Element *F = c.ip_addresses.front(); F; F = F->next()) { + if (!F->get().is_ipv4()) + continue; // Wrong IP type + if_ip = F->get(); + break; + } + break; + } + + if (level == IPPROTO_IP) { + ERR_FAIL_COND_V(!if_ip.is_valid(), ERR_INVALID_PARAMETER); + struct ip_mreq greq; + int sock_opt = p_add ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP; + copymem(&greq.imr_multiaddr, p_ip.get_ipv4(), 4); + copymem(&greq.imr_interface, if_ip.get_ipv4(), 4); + ret = setsockopt(_sock, level, sock_opt, (const char *)&greq, sizeof(greq)); + } else { + struct ipv6_mreq greq; + int sock_opt = p_add ? IPV6_ADD_MEMBERSHIP : IPV6_DROP_MEMBERSHIP; + copymem(&greq.ipv6mr_multiaddr, p_ip.get_ipv6(), 16); + greq.ipv6mr_interface = if_v6id; + ret = setsockopt(_sock, level, sock_opt, (const char *)&greq, sizeof(greq)); + } + ERR_FAIL_COND_V(ret != 0, FAILED); + + return OK; +} + void NetSocketPosix::_set_socket(SOCKET_TYPE p_sock, IP::Type p_ip_type, bool p_is_stream) { _sock = p_sock; _ip_type = p_ip_type; @@ -625,3 +685,11 @@ Ref<NetSocket> NetSocketPosix::accept(IP_Address &r_ip, uint16_t &r_port) { ns->set_blocking_enabled(false); return Ref<NetSocket>(ns); } + +Error NetSocketPosix::join_multicast_group(const IP_Address &p_ip, String p_if_name) { + return _change_multicast_group(p_ip, p_if_name, true); +} + +Error NetSocketPosix::leave_multicast_group(const IP_Address &p_ip, String p_if_name) { + return _change_multicast_group(p_ip, p_if_name, false); +} diff --git a/drivers/unix/net_socket_posix.h b/drivers/unix/net_socket_posix.h index b7fb3fdc94..cf0412311d 100644 --- a/drivers/unix/net_socket_posix.h +++ b/drivers/unix/net_socket_posix.h @@ -60,6 +60,7 @@ private: NetError _get_socket_error(); void _set_socket(SOCKET_TYPE p_sock, IP::Type p_ip_type, bool p_is_stream); + _FORCE_INLINE_ Error _change_multicast_group(IP_Address p_ip, String p_if_name, bool p_add); protected: static NetSocket *_create_func(); @@ -93,6 +94,8 @@ public: virtual void set_tcp_no_delay_enabled(bool p_enabled); virtual void set_reuse_address_enabled(bool p_enabled); virtual void set_reuse_port_enabled(bool p_enabled); + virtual Error join_multicast_group(const IP_Address &p_multi_address, String p_if_name); + virtual Error leave_multicast_group(const IP_Address &p_multi_address, String p_if_name); NetSocketPosix(); ~NetSocketPosix(); diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 6e47fadb20..1bed5a9524 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -1203,7 +1203,9 @@ AnimationTimelineEdit::AnimationTimelineEdit() { //////////////////////////////////// void AnimationTrackEdit::_notification(int p_what) { + if (p_what == NOTIFICATION_DRAW) { + if (animation.is_null()) return; ERR_FAIL_INDEX(track, animation->get_track_count()); @@ -1240,20 +1242,15 @@ void AnimationTrackEdit::_notification(int p_what) { int ofs = in_group ? check->get_width() : 0; //not the best reference for margin but.. check_rect = Rect2(Point2(ofs, int(get_size().height - check->get_height()) / 2), check->get_size()); - draw_texture(check, check_rect.position); - ofs += check->get_width() + hsep; Ref<Texture> type_icon = type_icons[animation->track_get_type(track)]; - draw_texture(type_icon, Point2(ofs, int(get_size().height - type_icon->get_height()) / 2)); ofs += type_icon->get_width() + hsep; NodePath path = animation->track_get_path(track); - Node *node = NULL; - if (root && root->has_node(path)) { node = root->get_node(path); } @@ -1308,12 +1305,11 @@ void AnimationTrackEdit::_notification(int p_what) { draw_line(Point2(limit, 0), Point2(limit, get_size().height), linecolor, Math::round(EDSCALE)); } - // KEYFAMES // + // KEYFRAMES // draw_bg(limit, get_size().width - timeline->get_buttons_width()); { - float scale = timeline->get_zoom_scale(); int limit_end = get_size().width - timeline->get_buttons_width(); @@ -1342,6 +1338,7 @@ void AnimationTrackEdit::_notification(int p_what) { draw_fg(limit, get_size().width - timeline->get_buttons_width()); // BUTTONS // + { Ref<Texture> wrap_icon[2] = { @@ -1566,7 +1563,18 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool if (p_x < p_clip_left || p_x > p_clip_right) return; - Vector2 ofs(p_x - type_icon->get_width() / 2, int(get_size().height - type_icon->get_height()) / 2); + Ref<Texture> icon_to_draw = p_selected ? selected_icon : type_icon; + + // Override type icon for invalid value keys, unless selected. + if (!p_selected && animation->track_get_type(track) == Animation::TYPE_VALUE) { + const Variant &v = animation->track_get_key_value(track, p_index); + Variant::Type valid_type = Variant::NIL; + if (!_is_value_key_valid(v, valid_type)) { + icon_to_draw = get_icon("KeyInvalid", "EditorIcons"); + } + } + + Vector2 ofs(p_x - icon_to_draw->get_width() / 2, int(get_size().height - icon_to_draw->get_height()) / 2); if (animation->track_get_type(track) == Animation::TYPE_METHOD) { Ref<Font> font = get_font("font", "Label"); @@ -1590,16 +1598,13 @@ void AnimationTrackEdit::draw_key(int p_index, float p_pixels_sec, int p_x, bool } text += ")"; - int limit = MAX(0, p_clip_right - p_x - type_icon->get_width()); + int limit = MAX(0, p_clip_right - p_x - icon_to_draw->get_width()); if (limit > 0) { - draw_string(font, Vector2(p_x + type_icon->get_width(), int(get_size().height - font->get_height()) / 2 + font->get_ascent()), text, color, limit); + draw_string(font, Vector2(p_x + icon_to_draw->get_width(), int(get_size().height - font->get_height()) / 2 + font->get_ascent()), text, color, limit); } } - if (p_selected) { - draw_texture(selected_icon, ofs); - } else { - draw_texture(type_icon, ofs); - } + + draw_texture(icon_to_draw, ofs); } //helper @@ -1764,6 +1769,27 @@ void AnimationTrackEdit::_path_entered(const String &p_text) { undo_redo->commit_action(); } +bool AnimationTrackEdit::_is_value_key_valid(const Variant &p_key_value, Variant::Type &r_valid_type) const { + + RES res; + Vector<StringName> leftover_path; + Node *node = root->get_node_and_resource(animation->track_get_path(track), res, leftover_path); + + Object *obj = NULL; + if (res.is_valid()) { + obj = res.ptr(); + } else if (node) { + obj = node; + } + + bool prop_exists = false; + if (obj) { + r_valid_type = obj->get_static_property_type_indexed(leftover_path, &prop_exists); + } + + return (!prop_exists || Variant::can_convert(p_key_value.get_type(), r_valid_type)); +} + String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { if (check_rect.has_point(p_pos)) { @@ -1834,29 +1860,10 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const { } break; case Animation::TYPE_VALUE: { - Variant v = animation->track_get_key_value(track, key_idx); - //text+="value: "+String(v)+"\n"; - - bool prop_exists = false; - Variant::Type valid_type = Variant::NIL; - Object *obj = NULL; - - RES res; - Vector<StringName> leftover_path; - Node *node = root->get_node_and_resource(animation->track_get_path(track), res, leftover_path); - - if (res.is_valid()) { - obj = res.ptr(); - } else if (node) { - obj = node; - } - - if (obj) { - valid_type = obj->get_static_property_type_indexed(leftover_path, &prop_exists); - } - + const Variant &v = animation->track_get_key_value(track, key_idx); text += "Type: " + Variant::get_type_name(v.get_type()) + "\n"; - if (prop_exists && !Variant::can_convert(v.get_type(), valid_type)) { + Variant::Type valid_type = Variant::NIL; + if (!_is_value_key_valid(v, valid_type)) { text += "Value: " + String(v) + " (Invalid, expected type: " + Variant::get_type_name(valid_type) + ")\n"; } else { text += "Value: " + String(v) + "\n"; diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index 1452d5519c..5f05c1de8c 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -31,6 +31,11 @@ #ifndef ANIMATION_TRACK_EDITOR_H #define ANIMATION_TRACK_EDITOR_H +#include "editor/editor_data.h" +#include "editor/editor_spin_slider.h" +#include "editor/property_editor.h" +#include "editor/property_selector.h" +#include "scene/animation/animation_cache.h" #include "scene/gui/control.h" #include "scene/gui/file_dialog.h" #include "scene/gui/menu_button.h" @@ -40,12 +45,6 @@ #include "scene/gui/tab_container.h" #include "scene/gui/texture_rect.h" #include "scene/gui/tool_button.h" - -#include "editor/property_selector.h" -#include "editor_data.h" -#include "editor_spin_slider.h" -#include "property_editor.h" -#include "scene/animation/animation_cache.h" #include "scene/resources/animation.h" #include "scene_tree_editor.h" @@ -175,8 +174,9 @@ class AnimationTrackEdit : public Control { void _path_entered(const String &p_text); void _play_position_draw(); - mutable int dropping_at; + bool _is_value_key_valid(const Variant &p_key_value, Variant::Type &r_valid_type) const; + mutable int dropping_at; float insert_at_pos; bool moving_selection_attempt; int select_single_attempt; diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 8b3c537fe3..848921d870 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -1217,6 +1217,11 @@ void CodeTextEditor::goto_line_selection(int p_line, int p_begin, int p_end) { text_editor->select(p_line, p_begin, p_line, p_end); } +void CodeTextEditor::goto_line_centered(int p_line) { + goto_line(p_line); + text_editor->call_deferred("center_viewport_to_cursor"); +} + void CodeTextEditor::set_executing_line(int p_line) { text_editor->set_executing_line(p_line); } diff --git a/editor/code_editor.h b/editor/code_editor.h index ce219f340c..c0989f9704 100644 --- a/editor/code_editor.h +++ b/editor/code_editor.h @@ -219,6 +219,7 @@ public: void goto_line(int p_line); void goto_line_selection(int p_line, int p_begin, int p_end); + void goto_line_centered(int p_line); void set_executing_line(int p_line); void clear_executing_line(); diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 913eb35f8a..9f0b4250a3 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -789,7 +789,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() { } } - if (!info.is_singleton && !info.in_editor) { + if (!info.is_singleton && !info.in_editor && info.node != NULL) { memdelete(info.node); info.node = NULL; } diff --git a/editor/editor_name_dialog.cpp b/editor/editor_layouts_dialog.cpp index 63a91a594c..01e4762196 100644 --- a/editor/editor_name_dialog.cpp +++ b/editor/editor_layouts_dialog.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* editor_name_dialog.cpp */ +/* editor_layouts_dialog.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,13 +28,15 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "editor_name_dialog.h" - +#include "editor_layouts_dialog.h" #include "core/class_db.h" +#include "core/io/config_file.h" #include "core/os/keyboard.h" +#include "editor/editor_settings.h" +#include "scene/gui/item_list.h" +#include "scene/gui/line_edit.h" -void EditorNameDialog::_line_gui_input(const Ref<InputEvent> &p_event) { - +void EditorLayoutsDialog::_line_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventKey> k = p_event; if (k.is_valid()) { @@ -60,34 +62,77 @@ void EditorNameDialog::_line_gui_input(const Ref<InputEvent> &p_event) { } } -void EditorNameDialog::_post_popup() { +void EditorLayoutsDialog::_bind_methods() { + ClassDB::bind_method("_line_gui_input", &EditorLayoutsDialog::_line_gui_input); - ConfirmationDialog::_post_popup(); - name->clear(); - name->grab_focus(); + ADD_SIGNAL(MethodInfo("name_confirmed", PropertyInfo(Variant::STRING, "name"))); } -void EditorNameDialog::ok_pressed() { +void EditorLayoutsDialog::ok_pressed() { + + if (layout_names->is_anything_selected()) { + + Vector<int> const selected_items = layout_names->get_selected_items(); + for (int i = 0; i < selected_items.size(); ++i) { + + emit_signal("name_confirmed", layout_names->get_item_text(selected_items[i])); + } + } else if (name->is_visible() && name->get_text() != "") { - if (name->get_text() != "") { emit_signal("name_confirmed", name->get_text()); } } -void EditorNameDialog::_bind_methods() { +void EditorLayoutsDialog::_post_popup() { - ClassDB::bind_method("_line_gui_input", &EditorNameDialog::_line_gui_input); + ConfirmationDialog::_post_popup(); + name->clear(); + layout_names->clear(); - ADD_SIGNAL(MethodInfo("name_confirmed", PropertyInfo(Variant::STRING, "name"))); + Ref<ConfigFile> config; + config.instance(); + Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config()); + if (err != OK) { + + return; + } + + List<String> layouts; + config.ptr()->get_sections(&layouts); + + for (List<String>::Element *E = layouts.front(); E; E = E->next()) { + + layout_names->add_item(**E); + } } -EditorNameDialog::EditorNameDialog() { +EditorLayoutsDialog::EditorLayoutsDialog() { + makevb = memnew(VBoxContainer); add_child(makevb); + makevb->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 5); + makevb->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -5); + + layout_names = memnew(ItemList); + makevb->add_child(layout_names); + layout_names->set_visible(true); + layout_names->set_margin(MARGIN_TOP, 5); + layout_names->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 5); + layout_names->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -5); + layout_names->set_v_size_flags(Control::SIZE_EXPAND_FILL); + layout_names->set_select_mode(ItemList::SelectMode::SELECT_MULTI); + layout_names->set_allow_rmb_select(true); + name = memnew(LineEdit); makevb->add_child(name); name->set_margin(MARGIN_TOP, 5); name->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 5); name->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -5); name->connect("gui_input", this, "_line_gui_input"); + name->connect("focus_entered", layout_names, "unselect_all"); +} + +void EditorLayoutsDialog::set_name_line_enabled(bool p_enabled) { + + name->set_visible(p_enabled); } diff --git a/editor/editor_name_dialog.h b/editor/editor_layouts_dialog.h index 314fc27124..5e3a1d5a46 100644 --- a/editor/editor_name_dialog.h +++ b/editor/editor_layouts_dialog.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* editor_name_dialog.h */ +/* editor_layouts_dialog.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,18 +28,21 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef EDITOR_NAME_DIALOG_H -#define EDITOR_NAME_DIALOG_H +#ifndef EDITOR_LAYOUTS_DIALOG_H +#define EDITOR_LAYOUTS_DIALOG_H #include "scene/gui/dialogs.h" -#include "scene/gui/line_edit.h" -class EditorNameDialog : public ConfirmationDialog { +class LineEdit; +class ItemList; - GDCLASS(EditorNameDialog, ConfirmationDialog); +class EditorLayoutsDialog : public ConfirmationDialog { + + GDCLASS(EditorLayoutsDialog, ConfirmationDialog); - VBoxContainer *makevb; LineEdit *name; + ItemList *layout_names; + VBoxContainer *makevb; void _line_gui_input(const Ref<InputEvent> &p_event); @@ -49,9 +52,9 @@ protected: virtual void _post_popup(); public: - LineEdit *get_line_edit() { return name; } + EditorLayoutsDialog(); - EditorNameDialog(); + void set_name_line_enabled(bool p_enabled); }; -#endif // EDITOR_NAME_DIALOG_H +#endif // EDITOR_LAYOUTS_DIALOG_H diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 2d2f67314d..1f08f3d787 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2475,6 +2475,13 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { OS::get_singleton()->set_window_fullscreen(!OS::get_singleton()->is_window_fullscreen()); } break; + case SETTINGS_TOGGLE_CONSOLE: { + + bool was_visible = OS::get_singleton()->is_console_visible(); + OS::get_singleton()->set_console_visible(!was_visible); + EditorSettings::get_singleton()->set_setting("interface/editor/hide_console_window", !was_visible); + + } break; case SETTINGS_PICK_MAIN_SCENE: { file->set_mode(EditorFileDialog::MODE_OPEN_FILE); @@ -4249,6 +4256,7 @@ void EditorNode::_layout_menu_option(int p_id) { layout_dialog->set_title(TTR("Save Layout")); layout_dialog->get_ok()->set_text(TTR("Save")); layout_dialog->popup_centered(); + layout_dialog->set_name_line_enabled(true); } break; case SETTINGS_LAYOUT_DELETE: { @@ -4256,6 +4264,7 @@ void EditorNode::_layout_menu_option(int p_id) { layout_dialog->set_title(TTR("Delete Layout")); layout_dialog->get_ok()->set_text(TTR("Delete")); layout_dialog->popup_centered(); + layout_dialog->set_name_line_enabled(false); } break; case SETTINGS_LAYOUT_DEFAULT: { @@ -5874,6 +5883,9 @@ EditorNode::EditorNode() { #else p->add_shortcut(ED_SHORTCUT("editor/fullscreen_mode", TTR("Toggle Fullscreen"), KEY_MASK_SHIFT | KEY_F11), SETTINGS_TOGGLE_FULLSCREEN); #endif +#ifdef WINDOWS_ENABLED + p->add_item(TTR("Toggle System Console"), SETTINGS_TOGGLE_CONSOLE); +#endif p->add_separator(); if (OS::get_singleton()->get_data_path() == OS::get_singleton()->get_config_path()) { @@ -6019,10 +6031,10 @@ EditorNode::EditorNode() { progress_hb = memnew(BackgroundProgress); - layout_dialog = memnew(EditorNameDialog); + layout_dialog = memnew(EditorLayoutsDialog); gui_base->add_child(layout_dialog); layout_dialog->set_hide_on_ok(false); - layout_dialog->set_size(Size2(175, 70) * EDSCALE); + layout_dialog->set_size(Size2(225, 270) * EDSCALE); layout_dialog->connect("name_confirmed", this, "_dialog_action"); update_menu = memnew(MenuButton); diff --git a/editor/editor_node.h b/editor/editor_node.h index f3bc95c409..46b9befcd6 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -41,8 +41,8 @@ #include "editor/editor_feature_profile.h" #include "editor/editor_folding.h" #include "editor/editor_inspector.h" +#include "editor/editor_layouts_dialog.h" #include "editor/editor_log.h" -#include "editor/editor_name_dialog.h" #include "editor/editor_plugin.h" #include "editor/editor_resource_preview.h" #include "editor/editor_run.h" @@ -85,6 +85,7 @@ #include "scene/gui/tool_button.h" #include "scene/gui/tree.h" #include "scene/gui/viewport_container.h" + /** @author Juan Linietsky <reduzio@gmail.com> */ @@ -193,6 +194,7 @@ private: SETTINGS_MANAGE_EXPORT_TEMPLATES, SETTINGS_MANAGE_FEATURE_PROFILES, SETTINGS_PICK_MAIN_SCENE, + SETTINGS_TOGGLE_CONSOLE, SETTINGS_TOGGLE_FULLSCREEN, SETTINGS_HELP, SCENE_TAB_CLOSE, @@ -307,7 +309,7 @@ private: int overridden_default_layout; Ref<ConfigFile> default_layout; PopupMenu *editor_layouts; - EditorNameDialog *layout_dialog; + EditorLayoutsDialog *layout_dialog; ConfirmationDialog *custom_build_manage_templates; ConfirmationDialog *install_android_build_template; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 58e3cc6fc1..5e04bf4953 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -345,6 +345,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("interface/editor/unfocused_low_processor_mode_sleep_usec", 50000); // 20 FPS hints["interface/editor/unfocused_low_processor_mode_sleep_usec"] = PropertyInfo(Variant::REAL, "interface/editor/unfocused_low_processor_mode_sleep_usec", PROPERTY_HINT_RANGE, "1,100000,1", PROPERTY_USAGE_DEFAULT); _initial_set("interface/editor/separate_distraction_mode", false); + _initial_set("interface/editor/hide_console_window", false); _initial_set("interface/editor/save_each_scene_on_quit", true); // Regression _initial_set("interface/editor/quit_confirmation", true); diff --git a/editor/icons/icon_key_valid.svg b/editor/icons/icon_key_valid.svg deleted file mode 100644 index 4a3fab4754..0000000000 --- a/editor/icons/icon_key_valid.svg +++ /dev/null @@ -1,5 +0,0 @@ -<svg width="8" height="8" version="1.1" viewBox="0 0 8 8" xmlns="http://www.w3.org/2000/svg"> -<g transform="translate(0 -1044.4)"> -<rect transform="rotate(-45)" x="-741.53" y="741.08" width="6.1027" height="6.1027" ry=".76286" fill="#fff"/> -</g> -</svg> diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp index 1622ce17b2..7c2116f06b 100644 --- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp @@ -75,6 +75,10 @@ void CPUParticles2DEditorPlugin::_menu_callback(int p_idx) { emission_mask->popup_centered_minsize(); } break; + case MENU_RESTART: { + + particles->restart(); + } } } @@ -265,6 +269,8 @@ CPUParticles2DEditorPlugin::CPUParticles2DEditorPlugin(EditorNode *p_node) { menu = memnew(MenuButton); menu->get_popup()->add_item(TTR("Load Emission Mask"), MENU_LOAD_EMISSION_MASK); + menu->get_popup()->add_separator(); + menu->get_popup()->add_item(TTR("Restart"), MENU_RESTART); // menu->get_popup()->add_item(TTR("Clear Emission Mask"), MENU_CLEAR_EMISSION_MASK); menu->set_text(TTR("Particles")); menu->set_switch_on_hover(true); diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.h b/editor/plugins/cpu_particles_2d_editor_plugin.h index f715abd87b..84bbfff095 100644 --- a/editor/plugins/cpu_particles_2d_editor_plugin.h +++ b/editor/plugins/cpu_particles_2d_editor_plugin.h @@ -44,7 +44,8 @@ class CPUParticles2DEditorPlugin : public EditorPlugin { enum { MENU_LOAD_EMISSION_MASK, - MENU_CLEAR_EMISSION_MASK + MENU_CLEAR_EMISSION_MASK, + MENU_RESTART }; enum EmissionMode { diff --git a/editor/plugins/cpu_particles_editor_plugin.cpp b/editor/plugins/cpu_particles_editor_plugin.cpp index 70be9b95bb..93ffce41fa 100644 --- a/editor/plugins/cpu_particles_editor_plugin.cpp +++ b/editor/plugins/cpu_particles_editor_plugin.cpp @@ -62,6 +62,12 @@ void CPUParticlesEditor::_menu_option(int p_option) { emission_tree_dialog->popup_centered_ratio(); } break; + + case MENU_OPTION_RESTART: { + + node->restart(); + + } break; } } @@ -108,6 +114,8 @@ CPUParticlesEditor::CPUParticlesEditor() { options->set_text(TTR("CPUParticles")); options->get_popup()->add_item(TTR("Create Emission Points From Mesh"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH); options->get_popup()->add_item(TTR("Create Emission Points From Node"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE); + options->get_popup()->add_separator(); + options->get_popup()->add_item(TTR("Restart"), MENU_OPTION_RESTART); options->get_popup()->connect("id_pressed", this, "_menu_option"); } diff --git a/editor/plugins/cpu_particles_editor_plugin.h b/editor/plugins/cpu_particles_editor_plugin.h index 09b0adbe5d..674f00dc9f 100644 --- a/editor/plugins/cpu_particles_editor_plugin.h +++ b/editor/plugins/cpu_particles_editor_plugin.h @@ -43,6 +43,7 @@ class CPUParticlesEditor : public ParticlesEditorBase { MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE, MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH, MENU_OPTION_CLEAR_EMISSION_VOLUME, + MENU_OPTION_RESTART }; diff --git a/editor/plugins/particles_2d_editor_plugin.cpp b/editor/plugins/particles_2d_editor_plugin.cpp index 6fabdc93c6..e68bca55cb 100644 --- a/editor/plugins/particles_2d_editor_plugin.cpp +++ b/editor/plugins/particles_2d_editor_plugin.cpp @@ -96,12 +96,16 @@ void Particles2DEditorPlugin::_menu_callback(int p_idx) { UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); ur->create_action(TTR("Convert to CPUParticles")); ur->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", particles, cpu_particles, true, false); - ur->add_do_reference(particles); + ur->add_do_reference(cpu_particles); ur->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", cpu_particles, particles, false, false); - ur->add_undo_reference(this); + ur->add_undo_reference(particles); ur->commit_action(); } break; + case MENU_RESTART: { + + particles->restart(); + } } } @@ -380,6 +384,8 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) { // menu->get_popup()->add_item(TTR("Clear Emission Mask"), MENU_CLEAR_EMISSION_MASK); menu->get_popup()->add_separator(); menu->get_popup()->add_item(TTR("Convert to CPUParticles"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES); + menu->get_popup()->add_separator(); + menu->get_popup()->add_item(TTR("Restart"), MENU_RESTART); menu->set_text(TTR("Particles")); menu->set_switch_on_hover(true); toolbar->add_child(menu); diff --git a/editor/plugins/particles_2d_editor_plugin.h b/editor/plugins/particles_2d_editor_plugin.h index 35b874fb25..0f092aaa4f 100644 --- a/editor/plugins/particles_2d_editor_plugin.h +++ b/editor/plugins/particles_2d_editor_plugin.h @@ -47,7 +47,8 @@ class Particles2DEditorPlugin : public EditorPlugin { MENU_GENERATE_VISIBILITY_RECT, MENU_LOAD_EMISSION_MASK, MENU_CLEAR_EMISSION_MASK, - MENU_OPTION_CONVERT_TO_CPU_PARTICLES + MENU_OPTION_CONVERT_TO_CPU_PARTICLES, + MENU_RESTART }; enum EmissionMode { diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp index 3f4f66a26d..f05e7d65d3 100644 --- a/editor/plugins/particles_editor_plugin.cpp +++ b/editor/plugins/particles_editor_plugin.cpp @@ -315,12 +315,17 @@ void ParticlesEditor::_menu_option(int p_option) { UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); ur->create_action(TTR("Convert to CPUParticles")); ur->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", node, cpu_particles, true, false); - ur->add_do_reference(node); + ur->add_do_reference(cpu_particles); ur->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", cpu_particles, node, false, false); - ur->add_undo_reference(this); + ur->add_undo_reference(node); ur->commit_action(); } break; + case MENU_OPTION_RESTART: { + + node->restart(); + + } break; } } @@ -471,6 +476,8 @@ ParticlesEditor::ParticlesEditor() { options->get_popup()->add_item(TTR("Create Emission Points From Node"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE); options->get_popup()->add_separator(); options->get_popup()->add_item(TTR("Convert to CPUParticles"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES); + options->get_popup()->add_separator(); + options->get_popup()->add_item(TTR("Restart"), MENU_OPTION_RESTART); options->get_popup()->connect("id_pressed", this, "_menu_option"); diff --git a/editor/plugins/particles_editor_plugin.h b/editor/plugins/particles_editor_plugin.h index b1c53dcf94..5d05fbd4ac 100644 --- a/editor/plugins/particles_editor_plugin.h +++ b/editor/plugins/particles_editor_plugin.h @@ -86,6 +86,7 @@ class ParticlesEditor : public ParticlesEditorBase { MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH, MENU_OPTION_CLEAR_EMISSION_VOLUME, MENU_OPTION_CONVERT_TO_CPU_PARTICLES, + MENU_OPTION_RESTART, }; diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index d5e21321c3..1b00889e9a 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -306,8 +306,11 @@ void ScriptEditor::_goto_script_line(REF p_script, int p_line) { editor->push_item(p_script.ptr()); ScriptEditorBase *current = _get_current_editor(); - if (current) + if (ScriptTextEditor *script_text_editor = Object::cast_to<ScriptTextEditor>(current)) { + script_text_editor->goto_line_centered(p_line); + } else if (current) { current->goto_line(p_line, true); + } } } } diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index ce0859a1f6..9bf3a9f0eb 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -237,7 +237,7 @@ void ScriptTextEditor::_load_theme_settings() { text_edit->add_color_override("safe_line_number_color", safe_line_number_color); text_edit->add_color_override("caret_color", caret_color); text_edit->add_color_override("caret_background_color", caret_background_color); - text_edit->add_color_override("font_selected_color", text_selected_color); + text_edit->add_color_override("font_color_selected", text_selected_color); text_edit->add_color_override("selection_color", selection_color); text_edit->add_color_override("brace_mismatch_color", brace_mismatch_color); text_edit->add_color_override("current_line_color", current_line_color); @@ -487,6 +487,11 @@ void ScriptTextEditor::goto_line_selection(int p_line, int p_begin, int p_end) { code_editor->goto_line_selection(p_line, p_begin, p_end); } +void ScriptTextEditor::goto_line_centered(int p_line) { + + code_editor->goto_line_centered(p_line); +} + void ScriptTextEditor::set_executing_line(int p_line) { code_editor->set_executing_line(p_line); } diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index 24d40a5eec..89975e061e 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -201,6 +201,7 @@ public: virtual void goto_line(int p_line, bool p_with_error = false); void goto_line_selection(int p_line, int p_begin, int p_end); + void goto_line_centered(int p_line); virtual void set_executing_line(int p_line); virtual void clear_executing_line(); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index f9ca38b919..d02817f6e8 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -124,7 +124,7 @@ void ShaderTextEditor::_load_theme_settings() { get_text_edit()->add_color_override("line_number_color", line_number_color); get_text_edit()->add_color_override("caret_color", caret_color); get_text_edit()->add_color_override("caret_background_color", caret_background_color); - get_text_edit()->add_color_override("font_selected_color", text_selected_color); + get_text_edit()->add_color_override("font_color_selected", text_selected_color); get_text_edit()->add_color_override("selection_color", selection_color); get_text_edit()->add_color_override("brace_mismatch_color", brace_mismatch_color); get_text_edit()->add_color_override("current_line_color", current_line_color); diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index eeef3397d2..787813336d 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -116,7 +116,7 @@ void TextEditor::_load_theme_settings() { text_edit->add_color_override("line_number_color", line_number_color); text_edit->add_color_override("caret_color", caret_color); text_edit->add_color_override("caret_background_color", caret_background_color); - text_edit->add_color_override("font_selected_color", text_selected_color); + text_edit->add_color_override("font_color_selected", text_selected_color); text_edit->add_color_override("selection_color", selection_color); text_edit->add_color_override("brace_mismatch_color", brace_mismatch_color); text_edit->add_color_override("current_line_color", current_line_color); diff --git a/editor/plugins/tile_set_editor_plugin.h b/editor/plugins/tile_set_editor_plugin.h index b417414ae0..04e8d65155 100644 --- a/editor/plugins/tile_set_editor_plugin.h +++ b/editor/plugins/tile_set_editor_plugin.h @@ -31,7 +31,6 @@ #ifndef TILE_SET_EDITOR_PLUGIN_H #define TILE_SET_EDITOR_PLUGIN_H -#include "editor/editor_name_dialog.h" #include "editor/editor_node.h" #include "scene/2d/sprite.h" #include "scene/resources/concave_polygon_shape_2d.h" diff --git a/main/main.cpp b/main/main.cpp index c51ffd9124..c765ff9700 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1797,6 +1797,7 @@ bool Main::start() { pmanager->add_child(progress_dialog); sml->get_root()->add_child(pmanager); OS::get_singleton()->set_context(OS::CONTEXT_PROJECTMAN); + project_manager = true; } if (project_manager || editor) { @@ -1806,6 +1807,10 @@ bool Main::start() { StreamPeerSSL::load_certs_from_file(certs); else StreamPeerSSL::load_certs_from_memory(StreamPeerSSL::get_project_cert_array()); + + // Hide console window if requested (Windows-only) + bool hide_console = EditorSettings::get_singleton()->get_setting("interface/editor/hide_console_window"); + OS::get_singleton()->set_console_visible(!hide_console); } #endif } diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 3caa7b1d12..994a84fbc4 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -241,6 +241,7 @@ Vector3 GridMap::get_cell_size() const { void GridMap::set_octant_size(int p_size) { + ERR_FAIL_COND(p_size == 0); octant_size = p_size; _recreate_octant_data(); } diff --git a/modules/mbedtls/stream_peer_mbed_tls.cpp b/modules/mbedtls/stream_peer_mbed_tls.cpp index 45d3b86919..3541eff25a 100755 --- a/modules/mbedtls/stream_peer_mbed_tls.cpp +++ b/modules/mbedtls/stream_peer_mbed_tls.cpp @@ -122,6 +122,8 @@ Error StreamPeerMbedTLS::_do_handshake() { Error StreamPeerMbedTLS::connect_to_stream(Ref<StreamPeer> p_base, bool p_validate_certs, const String &p_for_hostname) { + ERR_FAIL_COND_V(p_base.is_null(), ERR_INVALID_PARAMETER); + base = p_base; int ret = 0; int authmode = p_validate_certs ? MBEDTLS_SSL_VERIFY_REQUIRED : MBEDTLS_SSL_VERIFY_NONE; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 6e6df08f02..5876a385c6 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1979,6 +1979,17 @@ bool OS_Windows::is_window_always_on_top() const { return video_mode.always_on_top; } +void OS_Windows::set_console_visible(bool p_enabled) { + if (console_visible == p_enabled) + return; + ShowWindow(GetConsoleWindow(), p_enabled ? SW_SHOW : SW_HIDE); + console_visible = p_enabled; +} + +bool OS_Windows::is_console_visible() const { + return console_visible; +} + bool OS_Windows::get_window_per_pixel_transparency_enabled() const { if (!is_layered_allowed()) return false; @@ -3231,6 +3242,7 @@ OS_Windows::OS_Windows(HINSTANCE _hInstance) { control_mem = false; meta_mem = false; minimized = false; + console_visible = IsWindowVisible(GetConsoleWindow()); hInstance = _hInstance; pressrc = 0; diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 4660c16b97..fc8ad1b188 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -210,6 +210,7 @@ protected: bool maximized; bool minimized; bool borderless; + bool console_visible; public: LRESULT WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); @@ -256,6 +257,8 @@ public: virtual bool is_window_maximized() const; virtual void set_window_always_on_top(bool p_enabled); virtual bool is_window_always_on_top() const; + virtual void set_console_visible(bool p_enabled); + virtual bool is_console_visible() const; virtual void request_attention(); virtual void set_borderless_window(bool p_borderless); diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 9365b7eabc..9614104750 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -75,11 +75,7 @@ def get_opts(): def get_flags(): - return [ - ('builtin_freetype', False), - ('builtin_libpng', False), - ('builtin_zlib', False), - ] + return [] def configure(env): diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index a8d72bb774..fba1c26d1c 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -250,6 +250,8 @@ void CPUParticles2D::restart() { frame_remainder = 0; cycle = 0; + set_emitting(true); + { int pc = particles.size(); PoolVector<Particle>::Write w = particles.write(); @@ -1391,10 +1393,10 @@ CPUParticles2D::CPUParticles2D() { set_spread(45); set_flatness(0); - set_param(PARAM_INITIAL_LINEAR_VELOCITY, 1); + set_param(PARAM_INITIAL_LINEAR_VELOCITY, 0); + set_param(PARAM_ANGULAR_VELOCITY, 0); set_param(PARAM_ORBIT_VELOCITY, 0); set_param(PARAM_LINEAR_ACCEL, 0); - set_param(PARAM_ANGULAR_VELOCITY, 0); set_param(PARAM_RADIAL_ACCEL, 0); set_param(PARAM_TANGENTIAL_ACCEL, 0); set_param(PARAM_DAMPING, 0); diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp index 9701998f5d..823794c3ba 100644 --- a/scene/2d/particles_2d.cpp +++ b/scene/2d/particles_2d.cpp @@ -278,6 +278,7 @@ void Particles2D::_validate_property(PropertyInfo &property) const { void Particles2D::restart() { VS::get_singleton()->particles_restart(particles); + VS::get_singleton()->particles_set_emitting(particles, true); } void Particles2D::_notification(int p_what) { diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp index cff147ba74..ee5d416930 100644 --- a/scene/3d/cpu_particles.cpp +++ b/scene/3d/cpu_particles.cpp @@ -225,6 +225,8 @@ void CPUParticles::restart() { frame_remainder = 0; cycle = 0; + set_emitting(true); + { int pc = particles.size(); PoolVector<Particle>::Write w = particles.write(); @@ -1459,7 +1461,8 @@ CPUParticles::CPUParticles() { set_spread(45); set_flatness(0); - set_param(PARAM_INITIAL_LINEAR_VELOCITY, 1); + set_param(PARAM_INITIAL_LINEAR_VELOCITY, 0); + set_param(PARAM_ANGULAR_VELOCITY, 0); set_param(PARAM_ORBIT_VELOCITY, 0); set_param(PARAM_LINEAR_ACCEL, 0); set_param(PARAM_RADIAL_ACCEL, 0); diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp index 156560f802..949de110f5 100644 --- a/scene/3d/particles.cpp +++ b/scene/3d/particles.cpp @@ -278,6 +278,7 @@ String Particles::get_configuration_warning() const { void Particles::restart() { VisualServer::get_singleton()->particles_restart(particles); + VisualServer::get_singleton()->particles_set_emitting(particles, true); } AABB Particles::capture_aabb() const { diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index 36571cc878..7b0836cd28 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -892,6 +892,8 @@ void Tabs::ensure_tab_visible(int p_idx) { } Rect2 Tabs::get_tab_rect(int p_tab) const { + + ERR_FAIL_INDEX_V(p_tab, tabs.size(), Rect2()); return Rect2(tabs[p_tab].ofs_cache, 0, tabs[p_tab].size_cache, get_size().height); } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 36d7dad1d3..4e86e4bb1e 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1178,7 +1178,7 @@ void TextEdit::_notification(int p_what) { if (brace_open_mismatch) color = cache.brace_mismatch_color; - drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); + drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_color_selected : color); } if ((brace_close_match_line == line && brace_close_match_column == last_wrap_column + j) || @@ -1186,7 +1186,7 @@ void TextEdit::_notification(int p_what) { if (brace_close_mismatch) color = cache.brace_mismatch_color; - drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); + drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_color_selected : color); } } @@ -1258,23 +1258,23 @@ void TextEdit::_notification(int p_what) { if (str[j] >= 32) { int yofs = ofs_y + (get_row_height() - cache.font->get_height()) / 2; - int w = drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), str[j], str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); + int w = drawer.draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, yofs + ascent), str[j], str[j + 1], in_selection && override_selected_font_color ? cache.font_color_selected : color); if (underlined) { float line_width = 1.0; #ifdef TOOLS_ENABLED line_width *= EDSCALE; #endif - draw_rect(Rect2(char_ofs + char_margin + ofs_x, yofs + ascent + 2, w, line_width), in_selection && override_selected_font_color ? cache.font_selected_color : color); + draw_rect(Rect2(char_ofs + char_margin + ofs_x, yofs + ascent + 2, w, line_width), in_selection && override_selected_font_color ? cache.font_color_selected : color); } } else if (draw_tabs && str[j] == '\t') { int yofs = (get_row_height() - cache.tab_icon->get_height()) / 2; - cache.tab_icon->draw(ci, Point2(char_ofs + char_margin + ofs_x, ofs_y + yofs), in_selection && override_selected_font_color ? cache.font_selected_color : color); + cache.tab_icon->draw(ci, Point2(char_ofs + char_margin + ofs_x, ofs_y + yofs), in_selection && override_selected_font_color ? cache.font_color_selected : color); } if (draw_spaces && str[j] == ' ') { int yofs = (get_row_height() - cache.space_icon->get_height()) / 2; - cache.space_icon->draw(ci, Point2(char_ofs + char_margin + ofs_x, ofs_y + yofs), in_selection && override_selected_font_color ? cache.font_selected_color : color); + cache.space_icon->draw(ci, Point2(char_ofs + char_margin + ofs_x, ofs_y + yofs), in_selection && override_selected_font_color ? cache.font_color_selected : color); } char_ofs += char_w; @@ -4554,7 +4554,7 @@ void TextEdit::_update_caches() { cache.line_number_color = get_color("line_number_color"); cache.safe_line_number_color = get_color("safe_line_number_color"); cache.font_color = get_color("font_color"); - cache.font_selected_color = get_color("font_selected_color"); + cache.font_color_selected = get_color("font_color_selected"); cache.keyword_color = get_color("keyword_color"); cache.function_color = get_color("function_color"); cache.member_variable_color = get_color("member_variable_color"); @@ -6452,6 +6452,7 @@ void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("get_text"), &TextEdit::get_text); ClassDB::bind_method(D_METHOD("get_line", "line"), &TextEdit::get_line); + ClassDB::bind_method(D_METHOD("center_viewport_to_cursor"), &TextEdit::center_viewport_to_cursor); ClassDB::bind_method(D_METHOD("cursor_set_column", "column", "adjust_viewport"), &TextEdit::cursor_set_column, DEFVAL(true)); ClassDB::bind_method(D_METHOD("cursor_set_line", "line", "adjust_viewport", "can_be_hidden", "wrap_index"), &TextEdit::cursor_set_line, DEFVAL(true), DEFVAL(true), DEFVAL(0)); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 3e852deda6..c721cf992e 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -184,7 +184,7 @@ private: Color line_number_color; Color safe_line_number_color; Color font_color; - Color font_selected_color; + Color font_color_selected; Color keyword_color; Color number_color; Color function_color; diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp index 950518aa6e..cb710dde43 100644 --- a/scene/resources/curve.cpp +++ b/scene/resources/curve.cpp @@ -51,6 +51,7 @@ Curve::Curve() { _baked_cache_dirty = false; _min_value = 0; _max_value = 1; + _minmax_set_once = 0b00; } int Curve::add_point(Vector2 p_pos, real_t left_tangent, real_t right_tangent, TangentMode left_mode, TangentMode right_mode) { @@ -282,20 +283,24 @@ void Curve::update_auto_tangents(int i) { #define MIN_Y_RANGE 0.01 void Curve::set_min_value(float p_min) { - if (p_min > _max_value - MIN_Y_RANGE) + if (_minmax_set_once & 0b11 && p_min > _max_value - MIN_Y_RANGE) { _min_value = _max_value - MIN_Y_RANGE; - else + } else { + _minmax_set_once |= 0b10; // first bit is "min set" _min_value = p_min; + } // Note: min and max are indicative values, // it's still possible that existing points are out of range at this point. emit_signal(SIGNAL_RANGE_CHANGED); } void Curve::set_max_value(float p_max) { - if (p_max < _min_value + MIN_Y_RANGE) + if (_minmax_set_once & 0b11 && p_max < _min_value + MIN_Y_RANGE) { _max_value = _min_value + MIN_Y_RANGE; - else + } else { + _minmax_set_once |= 0b01; // second bit is "max set" _max_value = p_max; + } emit_signal(SIGNAL_RANGE_CHANGED); } diff --git a/scene/resources/curve.h b/scene/resources/curve.h index bb12baca48..b677097e86 100644 --- a/scene/resources/curve.h +++ b/scene/resources/curve.h @@ -143,6 +143,7 @@ private: int _bake_resolution; float _min_value; float _max_value; + int _minmax_set_once; // Encodes whether min and max have been set a first time, first bit for min and second for max. }; VARIANT_ENUM_CAST(Curve::TangentMode) diff --git a/scene/resources/gradient.cpp b/scene/resources/gradient.cpp index 99ce8ef821..1ff02c2f82 100644 --- a/scene/resources/gradient.cpp +++ b/scene/resources/gradient.cpp @@ -143,6 +143,8 @@ void Gradient::set_points(Vector<Gradient::Point> &p_points) { } void Gradient::set_offset(int pos, const float offset) { + + ERR_FAIL_COND(pos < 0); if (points.size() <= pos) points.resize(pos + 1); points.write[pos].offset = offset; @@ -151,12 +153,12 @@ void Gradient::set_offset(int pos, const float offset) { } float Gradient::get_offset(int pos) const { - if (points.size() && points.size() > pos) - return points[pos].offset; - return 0; //TODO: Maybe throw some error instead? + ERR_FAIL_INDEX_V(pos, points.size(), 0.0); + return points[pos].offset; } void Gradient::set_color(int pos, const Color &color) { + ERR_FAIL_COND(pos < 0); if (points.size() <= pos) { points.resize(pos + 1); is_sorted = false; @@ -166,9 +168,8 @@ void Gradient::set_color(int pos, const Color &color) { } Color Gradient::get_color(int pos) const { - if (points.size() && points.size() > pos) - return points[pos].color; - return Color(0, 0, 0, 1); //TODO: Maybe throw some error instead? + ERR_FAIL_INDEX_V(pos, points.size(), Color()); + return points[pos].color; } int Gradient::get_points_count() const { diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp index 758475b75e..a80a57a09c 100644 --- a/scene/resources/particles_material.cpp +++ b/scene/resources/particles_material.cpp @@ -1202,6 +1202,7 @@ ParticlesMaterial::ParticlesMaterial() : set_spread(45); set_flatness(0); set_param(PARAM_INITIAL_LINEAR_VELOCITY, 0); + set_param(PARAM_ANGULAR_VELOCITY, 0); set_param(PARAM_ORBIT_VELOCITY, 0); set_param(PARAM_LINEAR_ACCEL, 0); set_param(PARAM_RADIAL_ACCEL, 0); diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index d09fac47f0..899abfc9f9 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -692,6 +692,8 @@ String TileSet::tile_get_name(int p_id) const { } void TileSet::tile_clear_shapes(int p_id) { + + ERR_FAIL_COND(!tile_map.has(p_id)); tile_map[p_id].shapes_data.clear(); } @@ -711,14 +713,15 @@ void TileSet::tile_add_shape(int p_id, const Ref<Shape2D> &p_shape, const Transf int TileSet::tile_get_shape_count(int p_id) const { ERR_FAIL_COND_V(!tile_map.has(p_id), 0); - return tile_map[p_id].shapes_data.size(); } void TileSet::tile_set_shape(int p_id, int p_shape_id, const Ref<Shape2D> &p_shape) { ERR_FAIL_COND(!tile_map.has(p_id)); - if (tile_map[p_id].shapes_data.size() <= p_shape_id) + ERR_FAIL_COND(p_shape_id < 0); + + if (p_shape_id >= tile_map[p_id].shapes_data.size()) tile_map[p_id].shapes_data.resize(p_shape_id + 1); tile_map[p_id].shapes_data.write[p_shape_id].shape = p_shape; _decompose_convex_shape(p_shape); @@ -728,7 +731,7 @@ void TileSet::tile_set_shape(int p_id, int p_shape_id, const Ref<Shape2D> &p_sha Ref<Shape2D> TileSet::tile_get_shape(int p_id, int p_shape_id) const { ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<Shape2D>()); - if (tile_map[p_id].shapes_data.size() > p_shape_id) + if (p_shape_id < tile_map[p_id].shapes_data.size()) return tile_map[p_id].shapes_data[p_shape_id].shape; return Ref<Shape2D>(); @@ -737,7 +740,8 @@ Ref<Shape2D> TileSet::tile_get_shape(int p_id, int p_shape_id) const { void TileSet::tile_set_shape_transform(int p_id, int p_shape_id, const Transform2D &p_offset) { ERR_FAIL_COND(!tile_map.has(p_id)); - if (tile_map[p_id].shapes_data.size() <= p_shape_id) + + if (p_shape_id >= tile_map[p_id].shapes_data.size()) tile_map[p_id].shapes_data.resize(p_shape_id + 1); tile_map[p_id].shapes_data.write[p_shape_id].shape_transform = p_offset; emit_changed(); @@ -746,7 +750,7 @@ void TileSet::tile_set_shape_transform(int p_id, int p_shape_id, const Transform Transform2D TileSet::tile_get_shape_transform(int p_id, int p_shape_id) const { ERR_FAIL_COND_V(!tile_map.has(p_id), Transform2D()); - if (tile_map[p_id].shapes_data.size() > p_shape_id) + if (p_shape_id < tile_map[p_id].shapes_data.size()) return tile_map[p_id].shapes_data[p_shape_id].shape_transform; return Transform2D(); @@ -765,7 +769,9 @@ Vector2 TileSet::tile_get_shape_offset(int p_id, int p_shape_id) const { void TileSet::tile_set_shape_one_way(int p_id, int p_shape_id, const bool p_one_way) { ERR_FAIL_COND(!tile_map.has(p_id)); - if (tile_map[p_id].shapes_data.size() <= p_shape_id) + ERR_FAIL_COND(p_shape_id < 0); + + if (p_shape_id >= tile_map[p_id].shapes_data.size()) tile_map[p_id].shapes_data.resize(p_shape_id + 1); tile_map[p_id].shapes_data.write[p_shape_id].one_way_collision = p_one_way; emit_changed(); @@ -774,23 +780,27 @@ void TileSet::tile_set_shape_one_way(int p_id, int p_shape_id, const bool p_one_ bool TileSet::tile_get_shape_one_way(int p_id, int p_shape_id) const { ERR_FAIL_COND_V(!tile_map.has(p_id), false); - if (tile_map[p_id].shapes_data.size() > p_shape_id) + if (p_shape_id < tile_map[p_id].shapes_data.size()) return tile_map[p_id].shapes_data[p_shape_id].one_way_collision; return false; } void TileSet::tile_set_shape_one_way_margin(int p_id, int p_shape_id, float p_margin) { + ERR_FAIL_COND(!tile_map.has(p_id)); - if (tile_map[p_id].shapes_data.size() <= p_shape_id) + ERR_FAIL_COND(p_shape_id < 0); + + if (p_shape_id >= tile_map[p_id].shapes_data.size()) tile_map[p_id].shapes_data.resize(p_shape_id + 1); tile_map[p_id].shapes_data.write[p_shape_id].one_way_collision_margin = p_margin; emit_changed(); } float TileSet::tile_get_shape_one_way_margin(int p_id, int p_shape_id) const { + ERR_FAIL_COND_V(!tile_map.has(p_id), 0); - if (tile_map[p_id].shapes_data.size() > p_shape_id) + if (p_shape_id < tile_map[p_id].shapes_data.size()) return tile_map[p_id].shapes_data[p_shape_id].one_way_collision_margin; return 0; @@ -820,7 +830,9 @@ void TileSet::autotile_set_light_occluder(int p_id, const Ref<OccluderPolygon2D> } Ref<OccluderPolygon2D> TileSet::autotile_get_light_occluder(int p_id, const Vector2 &p_coord) const { + ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<OccluderPolygon2D>()); + if (!tile_map[p_id].autotile_data.occluder_map.has(p_coord)) { return Ref<OccluderPolygon2D>(); } else { diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index dd595d9ff8..a3813f8fc6 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -1762,6 +1762,7 @@ void VisualShaderNodeGroupBase::set_inputs(const String &p_inputs) { for (int i = 0; i < input_port_count; i++) { Vector<String> arr = input_strings[i].split(","); + ERR_FAIL_COND(arr.size() != 3); int port_idx = arr[0].to_int(); int port_type = arr[1].to_int(); @@ -1794,6 +1795,7 @@ void VisualShaderNodeGroupBase::set_outputs(const String &p_outputs) { for (int i = 0; i < output_port_count; i++) { Vector<String> arr = output_strings[i].split(","); + ERR_FAIL_COND(arr.size() != 3); int port_idx = arr[0].to_int(); int port_type = arr[1].to_int(); @@ -1810,6 +1812,23 @@ String VisualShaderNodeGroupBase::get_outputs() const { return outputs; } +bool VisualShaderNodeGroupBase::is_valid_port_name(const String &p_name) const { + if (!p_name.is_valid_identifier()) { + return false; + } + for (int i = 0; i < get_input_port_count(); i++) { + if (get_input_port_name(i) == p_name) { + return false; + } + } + for (int i = 0; i < get_output_port_count(); i++) { + if (get_output_port_name(i) == p_name) { + return false; + } + } + return true; +} + void VisualShaderNodeGroupBase::add_input_port(int p_id, int p_type, const String &p_name) { String str = itos(p_id) + "," + itos(p_type) + "," + p_name + ";"; @@ -1849,6 +1868,8 @@ void VisualShaderNodeGroupBase::add_input_port(int p_id, int p_type, const Strin void VisualShaderNodeGroupBase::remove_input_port(int p_id) { + ERR_FAIL_COND(!has_input_port(p_id)); + Vector<String> inputs_strings = inputs.split(";", false); int count = 0; int index = 0; @@ -1917,6 +1938,8 @@ void VisualShaderNodeGroupBase::add_output_port(int p_id, int p_type, const Stri void VisualShaderNodeGroupBase::remove_output_port(int p_id) { + ERR_FAIL_COND(!has_output_port(p_id)); + Vector<String> outputs_strings = outputs.split(";", false); int count = 0; int index = 0; @@ -1956,6 +1979,9 @@ void VisualShaderNodeGroupBase::clear_output_ports() { void VisualShaderNodeGroupBase::set_input_port_type(int p_id, int p_type) { + ERR_FAIL_COND(!has_input_port(p_id)); + ERR_FAIL_COND(p_type < 0 || p_type > PORT_TYPE_TRANSFORM); + if (input_ports[p_id].type == p_type) return; @@ -1986,6 +2012,9 @@ VisualShaderNodeGroupBase::PortType VisualShaderNodeGroupBase::get_input_port_ty void VisualShaderNodeGroupBase::set_input_port_name(int p_id, const String &p_name) { + ERR_FAIL_COND(!has_input_port(p_id)); + ERR_FAIL_COND(!is_valid_port_name(p_name)); + if (input_ports[p_id].name == p_name) return; @@ -2016,6 +2045,9 @@ String VisualShaderNodeGroupBase::get_input_port_name(int p_id) const { void VisualShaderNodeGroupBase::set_output_port_type(int p_id, int p_type) { + ERR_FAIL_COND(!has_output_port(p_id)); + ERR_FAIL_COND(p_type < 0 || p_type > PORT_TYPE_TRANSFORM); + if (output_ports[p_id].type == p_type) return; @@ -2045,6 +2077,10 @@ VisualShaderNodeGroupBase::PortType VisualShaderNodeGroupBase::get_output_port_t } void VisualShaderNodeGroupBase::set_output_port_name(int p_id, const String &p_name) { + + ERR_FAIL_COND(!has_output_port(p_id)); + ERR_FAIL_COND(!is_valid_port_name(p_name)); + if (output_ports[p_id].name == p_name) return; @@ -2125,6 +2161,8 @@ void VisualShaderNodeGroupBase::_bind_methods() { ClassDB::bind_method(D_METHOD("set_outputs", "outputs"), &VisualShaderNodeGroupBase::set_outputs); ClassDB::bind_method(D_METHOD("get_outputs"), &VisualShaderNodeGroupBase::get_outputs); + ClassDB::bind_method(D_METHOD("is_valid_port_name", "name"), &VisualShaderNodeGroupBase::is_valid_port_name); + ClassDB::bind_method(D_METHOD("add_input_port", "id", "type", "name"), &VisualShaderNodeGroupBase::add_input_port); ClassDB::bind_method(D_METHOD("remove_input_port", "id"), &VisualShaderNodeGroupBase::remove_input_port); ClassDB::bind_method(D_METHOD("get_input_port_count"), &VisualShaderNodeGroupBase::get_input_port_count); diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h index 1ab3c0c9cc..a36776e701 100644 --- a/scene/resources/visual_shader.h +++ b/scene/resources/visual_shader.h @@ -355,6 +355,8 @@ public: void set_outputs(const String &p_outputs); String get_outputs() const; + bool is_valid_port_name(const String &p_name) const; + void add_input_port(int p_id, int p_type, const String &p_name); void remove_input_port(int p_id); virtual int get_input_port_count() const; |