summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/io/net_socket.h2
-rw-r--r--core/io/packet_peer_udp.cpp11
-rw-r--r--core/io/packet_peer_udp.h2
-rw-r--r--doc/classes/GraphEdit.xml2
-rw-r--r--doc/classes/PacketPeerUDP.xml12
-rw-r--r--drivers/SCsub5
-rw-r--r--drivers/unix/net_socket_posix.cpp16
-rw-r--r--drivers/unix/net_socket_posix.h2
-rw-r--r--editor/groups_editor.cpp2
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp2
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp4
-rw-r--r--modules/gdscript/doc_classes/@GDScript.xml15
-rw-r--r--modules/gdscript/gdscript_functions.cpp2
-rw-r--r--platform/android/SCsub1
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/Godot.java3
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/utils/GodotNetUtils.java84
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/utils/PermissionsUtil.java18
-rw-r--r--platform/android/java_godot_lib_jni.cpp2
-rw-r--r--platform/android/net_socket_android.cpp136
-rw-r--r--platform/android/net_socket_android.h78
-rw-r--r--platform/android/os_android.cpp3
-rw-r--r--scene/3d/physics_body.cpp11
-rw-r--r--scene/3d/physics_body.h3
-rw-r--r--scene/gui/slider.cpp10
-rw-r--r--scene/resources/default_theme/default_theme.cpp6
-rw-r--r--scene/resources/style_box.cpp4
26 files changed, 398 insertions, 38 deletions
diff --git a/core/io/net_socket.h b/core/io/net_socket.h
index 3bc1369487..914e243b65 100644
--- a/core/io/net_socket.h
+++ b/core/io/net_socket.h
@@ -69,7 +69,7 @@ public:
virtual bool is_open() const = 0;
virtual int get_available_bytes() const = 0;
- virtual void set_broadcasting_enabled(bool p_enabled) = 0;
+ virtual Error set_broadcasting_enabled(bool p_enabled) = 0; // Returns OK if the socket option has been set successfully.
virtual void set_blocking_enabled(bool p_enabled) = 0;
virtual void set_ipv6_only_enabled(bool p_enabled) = 0;
virtual void set_tcp_no_delay_enabled(bool p_enabled) = 0;
diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp
index 7e9471c053..80a070cf1c 100644
--- a/core/io/packet_peer_udp.cpp
+++ b/core/io/packet_peer_udp.cpp
@@ -37,6 +37,12 @@ void PacketPeerUDP::set_blocking_mode(bool p_enable) {
blocking = p_enable;
}
+void PacketPeerUDP::set_broadcast_enabled(bool p_enabled) {
+ broadcast = p_enabled;
+ if (_sock.is_valid() && _sock->is_open())
+ _sock->set_broadcasting_enabled(p_enabled);
+}
+
Error PacketPeerUDP::join_multicast_group(IP_Address p_multi_address, String p_if_name) {
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
@@ -47,6 +53,7 @@ Error PacketPeerUDP::join_multicast_group(IP_Address p_multi_address, String p_i
Error err = _sock->open(NetSocket::TYPE_UDP, ip_type);
ERR_FAIL_COND_V(err != OK, err);
_sock->set_blocking_enabled(false);
+ _sock->set_broadcasting_enabled(broadcast);
}
return _sock->join_multicast_group(p_multi_address, p_if_name);
}
@@ -122,6 +129,7 @@ Error PacketPeerUDP::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
err = _sock->open(NetSocket::TYPE_UDP, ip_type);
ERR_FAIL_COND_V(err != OK, err);
_sock->set_blocking_enabled(false);
+ _sock->set_broadcasting_enabled(broadcast);
}
do {
@@ -165,6 +173,7 @@ Error PacketPeerUDP::listen(int p_port, const IP_Address &p_bind_address, int p_
_sock->set_blocking_enabled(false);
_sock->set_reuse_address_enabled(true);
+ _sock->set_broadcasting_enabled(broadcast);
err = _sock->bind(p_bind_address, p_port);
if (err != OK) {
@@ -258,6 +267,7 @@ 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("set_broadcast_enabled", "enabled"), &PacketPeerUDP::set_broadcast_enabled);
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);
}
@@ -267,6 +277,7 @@ PacketPeerUDP::PacketPeerUDP() :
queue_count(0),
peer_port(0),
blocking(true),
+ broadcast(false),
_sock(Ref<NetSocket>(NetSocket::create())) {
rb.resize(16);
}
diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h
index 068bd5cd5a..dc89e129dd 100644
--- a/core/io/packet_peer_udp.h
+++ b/core/io/packet_peer_udp.h
@@ -53,6 +53,7 @@ protected:
IP_Address peer_addr;
int peer_port;
bool blocking;
+ bool broadcast;
Ref<NetSocket> _sock;
static void _bind_methods();
@@ -77,6 +78,7 @@ 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;
+ void set_broadcast_enabled(bool p_enabled);
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);
diff --git a/doc/classes/GraphEdit.xml b/doc/classes/GraphEdit.xml
index 80e9b152ef..7dde030db7 100644
--- a/doc/classes/GraphEdit.xml
+++ b/doc/classes/GraphEdit.xml
@@ -87,6 +87,8 @@
<return type="HBoxContainer">
</return>
<description>
+ Gets the [HBoxContainer] that contains the zooming and grid snap controls in the top left of the graph.
+ Warning: The intended usage of this function is to allow you to reposition or add your own custom controls to the container. This is an internal control and as such should not be freed. If you wish to hide this or any of it's children use their [member CanvasItem.visible] property instead.
</description>
</method>
<method name="is_node_connected">
diff --git a/doc/classes/PacketPeerUDP.xml b/doc/classes/PacketPeerUDP.xml
index 260dbae8e2..3dc83ce8b4 100644
--- a/doc/classes/PacketPeerUDP.xml
+++ b/doc/classes/PacketPeerUDP.xml
@@ -47,6 +47,7 @@
<description>
Joins 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.
+ Note: Some Android devices might require the [code]CHANGE_WIFI_MULTICAST_STATE[/code] permission for multicast to work.
</description>
</method>
<method name="leave_multicast_group">
@@ -76,6 +77,16 @@
If [code]bind_address[/code] is set to any valid address (e.g. [code]"192.168.1.101"[/code], [code]"::1"[/code], etc), the peer will only listen on the interface with that addresses (or fail if no interface with the given address exists).
</description>
</method>
+ <method name="set_broadcast_enabled">
+ <return type="void">
+ </return>
+ <argument index="0" name="enabled" type="bool">
+ </argument>
+ <description>
+ Enable or disable sending of broadcast packets (e.g. [code]set_dest_address("255.255.255.255", 4343)[/code]. This option is disabled by default.
+ Note: Some Android devices might require the [code]CHANGE_WIFI_MULTICAST_STATE[/code] permission and this option to be enabled to receive broadcast packets too.
+ </description>
+ </method>
<method name="set_dest_address">
<return type="int" enum="Error">
</return>
@@ -85,6 +96,7 @@
</argument>
<description>
Sets the destination address and port for sending packets and variables. A hostname will be resolved using DNS if needed.
+ Note: [method set_broadcast_enabled] must be enabled before sending packets to a broadcast address (e.g. [code]255.255.255.255[/code]).
</description>
</method>
<method name="wait">
diff --git a/drivers/SCsub b/drivers/SCsub
index d7003a07ce..d91d98a713 100644
--- a/drivers/SCsub
+++ b/drivers/SCsub
@@ -33,11 +33,6 @@ else:
# Core dependencies
SConscript("png/SCsub")
-# Tools override
-# FIXME: Should likely be integrated in the tools/ codebase
-if env['tools']:
- SConscript("convex_decomp/SCsub")
-
if env['vsproj']:
import os
path = os.getcwd()
diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp
index 5f99a40c79..003c372107 100644
--- a/drivers/unix/net_socket_posix.cpp
+++ b/drivers/unix/net_socket_posix.cpp
@@ -333,9 +333,10 @@ Error NetSocketPosix::open(Type p_sock_type, IP::Type &ip_type) {
set_ipv6_only_enabled(ip_type != IP::TYPE_ANY);
}
- if (protocol == IPPROTO_UDP && ip_type != IP::TYPE_IPV6) {
- // Enable broadcasting for UDP sockets if it's not IPv6 only (IPv6 has no broadcast option).
- set_broadcasting_enabled(true);
+ if (protocol == IPPROTO_UDP) {
+ // Make sure to disable broadcasting for UDP sockets.
+ // Depending on the OS, this option might or might not be enabled by default. Let's normalize it.
+ set_broadcasting_enabled(false);
}
_is_stream = p_sock_type == TYPE_TCP;
@@ -603,15 +604,18 @@ Error NetSocketPosix::sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP
return OK;
}
-void NetSocketPosix::set_broadcasting_enabled(bool p_enabled) {
- ERR_FAIL_COND(!is_open());
+Error NetSocketPosix::set_broadcasting_enabled(bool p_enabled) {
+ ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED);
// IPv6 has no broadcast support.
- ERR_FAIL_COND(_ip_type == IP::TYPE_IPV6);
+ if (_ip_type == IP::TYPE_IPV6)
+ return ERR_UNAVAILABLE;
int par = p_enabled ? 1 : 0;
if (setsockopt(_sock, SOL_SOCKET, SO_BROADCAST, SOCK_CBUF(&par), sizeof(int)) != 0) {
WARN_PRINT("Unable to change broadcast setting");
+ return FAILED;
}
+ return OK;
}
void NetSocketPosix::set_blocking_enabled(bool p_enabled) {
diff --git a/drivers/unix/net_socket_posix.h b/drivers/unix/net_socket_posix.h
index e549ea1d6a..fe5a4858de 100644
--- a/drivers/unix/net_socket_posix.h
+++ b/drivers/unix/net_socket_posix.h
@@ -89,7 +89,7 @@ public:
virtual bool is_open() const;
virtual int get_available_bytes() const;
- virtual void set_broadcasting_enabled(bool p_enabled);
+ virtual Error set_broadcasting_enabled(bool p_enabled);
virtual void set_blocking_enabled(bool p_enabled);
virtual void set_ipv6_only_enabled(bool p_enabled);
virtual void set_tcp_no_delay_enabled(bool p_enabled);
diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp
index 74d81bf561..e7facc56b5 100644
--- a/editor/groups_editor.cpp
+++ b/editor/groups_editor.cpp
@@ -404,7 +404,7 @@ void GroupDialog::_bind_methods() {
}
GroupDialog::GroupDialog() {
- set_custom_minimum_size(Size2(600, 400));
+ set_custom_minimum_size(Size2(600, 400) * EDSCALE);
scene_tree = SceneTree::get_singleton();
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp
index bd532a6418..503e6ac135 100644
--- a/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -1444,7 +1444,7 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) :
uv_mode_hb->add_child(uv_icon_zoom);
uv_zoom = memnew(HSlider);
uv_zoom->set_min(0.01);
- uv_zoom->set_max(4);
+ uv_zoom->set_max(16);
uv_zoom->set_value(1);
uv_zoom->set_step(0.01);
uv_zoom->set_v_size_flags(SIZE_SHRINK_CENTER);
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index 66935d047b..18e076aed6 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -637,8 +637,8 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
tile_names_visible = false;
// Config scale.
- max_scale = 10.0f;
- min_scale = 0.1f;
+ max_scale = 16.0f;
+ min_scale = 0.01f;
scale_ratio = 1.2f;
}
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml
index 502a68cd61..e84f84d788 100644
--- a/modules/gdscript/doc_classes/@GDScript.xml
+++ b/modules/gdscript/doc_classes/@GDScript.xml
@@ -168,14 +168,16 @@
<method name="char">
<return type="String">
</return>
- <argument index="0" name="ascii" type="int">
+ <argument index="0" name="code" type="int">
</argument>
<description>
- Returns a character as a String of the given ASCII code.
+ Returns a character as a String of the given Unicode code point (which is compatible with ASCII code).
[codeblock]
a = char(65) # a is "A"
a = char(65 + 32) # a is "a"
+ a = char(8364) # a is "€"
[/codeblock]
+ This is the inverse of [method ord].
</description>
</method>
<method name="clamp">
@@ -702,6 +704,13 @@
<argument index="0" name="char" type="String">
</argument>
<description>
+ Returns an integer representing the Unicode code point of the given Unicode character [code]char[/code].
+ [codeblock]
+ a = ord("A") # a is 65
+ a = ord("a") # a is 97
+ a = ord("€") # a is 8364
+ [/codeblock]
+ This is the inverse of [method char].
</description>
</method>
<method name="parse_json">
@@ -937,7 +946,7 @@
<return type="int">
</return>
<description>
- Returns a random unsigned 32 bit integer. Use remainder to obtain a random value in the interval [code][0, N][/code] (where N is smaller than 2^32 -1).
+ Returns a random unsigned 32 bit integer. Use remainder to obtain a random value in the interval [code][0, N - 1][/code] (where N is smaller than 2^32).
[codeblock]
randi() # Returns random integer between 0 and 2^32 - 1
randi() % 20 # Returns random integer between 0 and 19
diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp
index 9e05c7b574..5c0573be3f 100644
--- a/modules/gdscript/gdscript_functions.cpp
+++ b/modules/gdscript/gdscript_functions.cpp
@@ -1855,7 +1855,7 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
} break;
case TEXT_CHAR: {
- MethodInfo mi("char", PropertyInfo(Variant::INT, "ascii"));
+ MethodInfo mi("char", PropertyInfo(Variant::INT, "code"));
mi.return_val.type = Variant::STRING;
return mi;
diff --git a/platform/android/SCsub b/platform/android/SCsub
index 65172a12c0..3ff5b8278a 100644
--- a/platform/android/SCsub
+++ b/platform/android/SCsub
@@ -12,6 +12,7 @@ android_files = [
'file_access_jandroid.cpp',
'dir_access_jandroid.cpp',
'thread_jandroid.cpp',
+ 'net_socket_android.cpp',
'audio_driver_jandroid.cpp',
'java_godot_lib_jni.cpp',
'java_class_wrapper.cpp',
diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.java b/platform/android/java/lib/src/org/godotengine/godot/Godot.java
index 4dae2dcc53..d951998632 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/Godot.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.java
@@ -96,6 +96,7 @@ import java.util.Locale;
import javax.microedition.khronos.opengles.GL10;
import org.godotengine.godot.input.GodotEditText;
import org.godotengine.godot.payments.PaymentsManager;
+import org.godotengine.godot.utils.GodotNetUtils;
import org.godotengine.godot.utils.PermissionsUtil;
import org.godotengine.godot.xr.XRMode;
@@ -243,6 +244,7 @@ public abstract class Godot extends Activity implements SensorEventListener, IDo
private Sensor mGyroscope;
public static GodotIO io;
+ public static GodotNetUtils netUtils;
static SingletonBase[] singletons = new SingletonBase[MAX_SINGLETONS];
static int singleton_count = 0;
@@ -502,6 +504,7 @@ public abstract class Godot extends Activity implements SensorEventListener, IDo
io = new GodotIO(this);
io.unique_id = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
GodotLib.io = io;
+ netUtils = new GodotNetUtils(this);
mSensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME);
diff --git a/platform/android/java/lib/src/org/godotengine/godot/utils/GodotNetUtils.java b/platform/android/java/lib/src/org/godotengine/godot/utils/GodotNetUtils.java
new file mode 100644
index 0000000000..0dc6962ca6
--- /dev/null
+++ b/platform/android/java/lib/src/org/godotengine/godot/utils/GodotNetUtils.java
@@ -0,0 +1,84 @@
+/*************************************************************************/
+/* GodotNetUtils.java */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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. */
+/*************************************************************************/
+
+package org.godotengine.godot.utils;
+
+import android.content.Context;
+import android.net.wifi.WifiManager;
+import android.util.Log;
+
+import org.godotengine.godot.Godot;
+
+/**
+ * This class handles Android-specific networking functions.
+ * For now, it only provides access to WifiManager.MulticastLock, which is needed on some devices
+ * to receive broadcast and multicast packets.
+ */
+public class GodotNetUtils {
+
+ /* A single, reference counted, multicast lock, or null if permission CHANGE_WIFI_MULTICAST_STATE is missing */
+ private WifiManager.MulticastLock multicastLock;
+
+ public GodotNetUtils(Godot p_activity) {
+ if (PermissionsUtil.hasManifestPermission(p_activity, "android.permission.CHANGE_WIFI_MULTICAST_STATE")) {
+ WifiManager wifi = (WifiManager)p_activity.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
+ multicastLock = wifi.createMulticastLock("GodotMulticastLock");
+ multicastLock.setReferenceCounted(true);
+ }
+ }
+
+ /**
+ * Acquire the multicast lock. This is required on some devices to receive broadcast/multicast packets.
+ * This is done automatically by Godot when enabling broadcast or joining a multicast group on a socket.
+ */
+ public void multicastLockAcquire() {
+ if (multicastLock == null)
+ return;
+ try {
+ multicastLock.acquire();
+ } catch (RuntimeException e) {
+ Log.e("Godot", "Exception during multicast lock acquire: " + e);
+ }
+ }
+
+ /**
+ * Release the multicast lock.
+ * This is done automatically by Godot when the lock is no longer needed by a socket.
+ */
+ public void multicastLockRelease() {
+ if (multicastLock == null)
+ return;
+ try {
+ multicastLock.release();
+ } catch (RuntimeException e) {
+ Log.e("Godot", "Exception during multicast lock release: " + e);
+ }
+ }
+}
diff --git a/platform/android/java/lib/src/org/godotengine/godot/utils/PermissionsUtil.java b/platform/android/java/lib/src/org/godotengine/godot/utils/PermissionsUtil.java
index 21df5a91b0..7e35417c6a 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/utils/PermissionsUtil.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/utils/PermissionsUtil.java
@@ -162,6 +162,24 @@ public final class PermissionsUtil {
}
/**
+ * Check if the given permission is in the AndroidManifest.xml file.
+ * @param activity the caller activity for this method.
+ * @param permission the permession to look for in the manifest file.
+ * @return "true" if the permission is in the manifest file of the activity, "false" otherwise.
+ */
+ public static boolean hasManifestPermission(Godot activity, String permission) {
+ try {
+ for (String p : getManifestPermissions(activity)) {
+ if (permission.equals(p))
+ return true;
+ }
+ } catch (PackageManager.NameNotFoundException e) {
+ }
+
+ return false;
+ }
+
+ /**
* Returns the permissions defined in the AndroidManifest.xml file.
* @param activity the caller activity for this method.
* @return manifest permissions list
diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp
index a14e0a1960..1ad1fb0afe 100644
--- a/platform/android/java_godot_lib_jni.cpp
+++ b/platform/android/java_godot_lib_jni.cpp
@@ -43,6 +43,7 @@
#include "java_class_wrapper.h"
#include "main/input_default.h"
#include "main/main.h"
+#include "net_socket_android.h"
#include "os_android.h"
#include "string_android.h"
#include "thread_jandroid.h"
@@ -635,6 +636,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en
DirAccessJAndroid::setup(godot_io_java->get_instance());
AudioDriverAndroid::setup(godot_io_java->get_instance());
+ NetSocketAndroid::setup(godot_java->get_member_object("netUtils", "Lorg/godotengine/godot/utils/GodotNetUtils;", env));
os_android = new OS_Android(godot_java, godot_io_java, p_use_apk_expansion);
diff --git a/platform/android/net_socket_android.cpp b/platform/android/net_socket_android.cpp
new file mode 100644
index 0000000000..78ef354c21
--- /dev/null
+++ b/platform/android/net_socket_android.cpp
@@ -0,0 +1,136 @@
+/*************************************************************************/
+/* net_socket_android.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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. */
+/*************************************************************************/
+
+#include "net_socket_android.h"
+
+#include "thread_jandroid.h"
+
+jobject NetSocketAndroid::net_utils = 0;
+jclass NetSocketAndroid::cls = 0;
+jmethodID NetSocketAndroid::_multicast_lock_acquire = 0;
+jmethodID NetSocketAndroid::_multicast_lock_release = 0;
+
+void NetSocketAndroid::setup(jobject p_net_utils) {
+
+ JNIEnv *env = ThreadAndroid::get_env();
+
+ net_utils = env->NewGlobalRef(p_net_utils);
+
+ jclass c = env->GetObjectClass(net_utils);
+ cls = (jclass)env->NewGlobalRef(c);
+
+ _multicast_lock_acquire = env->GetMethodID(cls, "multicastLockAcquire", "()V");
+ _multicast_lock_release = env->GetMethodID(cls, "multicastLockRelease", "()V");
+}
+
+void NetSocketAndroid::multicast_lock_acquire() {
+ if (_multicast_lock_acquire) {
+ JNIEnv *env = ThreadAndroid::get_env();
+ env->CallVoidMethod(net_utils, _multicast_lock_acquire);
+ }
+}
+
+void NetSocketAndroid::multicast_lock_release() {
+ if (_multicast_lock_release) {
+ JNIEnv *env = ThreadAndroid::get_env();
+ env->CallVoidMethod(net_utils, _multicast_lock_release);
+ }
+}
+
+NetSocket *NetSocketAndroid::_create_func() {
+ return memnew(NetSocketAndroid);
+}
+
+void NetSocketAndroid::make_default() {
+ _create = _create_func;
+}
+
+NetSocketAndroid::NetSocketAndroid() :
+ wants_broadcast(false),
+ multicast_groups(0) {
+}
+
+NetSocketAndroid::~NetSocketAndroid() {
+ close();
+}
+
+void NetSocketAndroid::close() {
+ NetSocketPosix::close();
+ if (wants_broadcast)
+ multicast_lock_release();
+ if (multicast_groups)
+ multicast_lock_release();
+ wants_broadcast = false;
+ multicast_groups = 0;
+}
+
+Error NetSocketAndroid::set_broadcasting_enabled(bool p_enabled) {
+ Error err = NetSocketPosix::set_broadcasting_enabled(p_enabled);
+ if (err != OK)
+ return err;
+
+ if (p_enabled != wants_broadcast) {
+ if (p_enabled) {
+ multicast_lock_acquire();
+ } else {
+ multicast_lock_release();
+ }
+
+ wants_broadcast = p_enabled;
+ }
+
+ return OK;
+}
+
+Error NetSocketAndroid::join_multicast_group(const IP_Address &p_multi_address, String p_if_name) {
+ Error err = NetSocketPosix::join_multicast_group(p_multi_address, p_if_name);
+ if (err != OK)
+ return err;
+
+ if (!multicast_groups)
+ multicast_lock_acquire();
+ multicast_groups++;
+
+ return OK;
+}
+
+Error NetSocketAndroid::leave_multicast_group(const IP_Address &p_multi_address, String p_if_name) {
+ Error err = NetSocketPosix::leave_multicast_group(p_multi_address, p_if_name);
+ if (err != OK)
+ return err;
+
+ ERR_FAIL_COND_V(multicast_groups == 0, ERR_BUG);
+
+ multicast_groups--;
+ if (!multicast_groups)
+ multicast_lock_release();
+
+ return OK;
+}
diff --git a/platform/android/net_socket_android.h b/platform/android/net_socket_android.h
new file mode 100644
index 0000000000..1ecbac0c1a
--- /dev/null
+++ b/platform/android/net_socket_android.h
@@ -0,0 +1,78 @@
+/*************************************************************************/
+/* net_socket_android.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 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 NET_SOCKET_ANDROID_H
+#define NET_SOCKET_ANDROID_H
+
+#include "drivers/unix/net_socket_posix.h"
+
+#include <jni.h>
+
+/**
+ * Specialized NetSocket implementation for Android.
+ *
+ * Some devices requires Android-specific code to acquire a MulticastLock
+ * before sockets are allowed to receive broadcast and multicast packets.
+ * This implementation calls into Java code and automatically acquire/release
+ * the lock when broadcasting is enabled/disabled on a socket, or that socket
+ * joins/leaves a multicast group.
+ */
+class NetSocketAndroid : public NetSocketPosix {
+
+private:
+ static jobject net_utils;
+ static jclass cls;
+ static jmethodID _multicast_lock_acquire;
+ static jmethodID _multicast_lock_release;
+
+ bool wants_broadcast;
+ int multicast_groups;
+
+ static void multicast_lock_acquire();
+ static void multicast_lock_release();
+
+protected:
+ static NetSocket *_create_func();
+
+public:
+ static void make_default();
+ static void setup(jobject p_net_utils);
+
+ virtual void close();
+
+ virtual Error set_broadcasting_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);
+
+ NetSocketAndroid();
+ ~NetSocketAndroid();
+};
+
+#endif
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index 9068b76cfb..f08dcc449e 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -43,6 +43,7 @@
#include "dir_access_jandroid.h"
#include "file_access_jandroid.h"
+#include "net_socket_android.h"
#include <dlfcn.h>
@@ -106,6 +107,8 @@ void OS_Android::initialize_core() {
DirAccess::make_default<DirAccessJAndroid>(DirAccess::ACCESS_RESOURCES);
DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_USERDATA);
DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_FILESYSTEM);
+
+ NetSocketAndroid::make_default();
}
void OS_Android::set_opengl_extensions(const char *p_gl_extensions) {
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 6049b6cdb4..dff1b07f3e 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -1554,6 +1554,14 @@ bool PhysicalBone::JointData::_get(const StringName &p_name, Variant &r_ret) con
void PhysicalBone::JointData::_get_property_list(List<PropertyInfo> *p_list) const {
}
+void PhysicalBone::apply_central_impulse(const Vector3 &p_impulse) {
+ PhysicsServer::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse);
+}
+
+void PhysicalBone::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse) {
+ PhysicsServer::get_singleton()->body_apply_impulse(get_rid(), p_pos, p_impulse);
+}
+
bool PhysicalBone::PinJointData::_set(const StringName &p_name, const Variant &p_value, RID j) {
if (JointData::_set(p_name, p_value, j)) {
return true;
@@ -2216,6 +2224,9 @@ void PhysicalBone::_direct_state_changed(Object *p_state) {
}
void PhysicalBone::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &PhysicalBone::apply_central_impulse);
+ ClassDB::bind_method(D_METHOD("apply_impulse", "position", "impulse"), &PhysicalBone::apply_impulse);
+
ClassDB::bind_method(D_METHOD("_direct_state_changed"), &PhysicalBone::_direct_state_changed);
ClassDB::bind_method(D_METHOD("set_joint_type", "joint_type"), &PhysicalBone::set_joint_type);
diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h
index 0967cb9cd5..de1944bdf0 100644
--- a/scene/3d/physics_body.h
+++ b/scene/3d/physics_body.h
@@ -636,6 +636,9 @@ public:
void set_gravity_scale(real_t p_gravity_scale);
real_t get_gravity_scale() const;
+ void apply_central_impulse(const Vector3 &p_impulse);
+ void apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse);
+
PhysicalBone();
~PhysicalBone();
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp
index ba57be1686..cbb2db7788 100644
--- a/scene/gui/slider.cpp
+++ b/scene/gui/slider.cpp
@@ -166,7 +166,6 @@ void Slider::_notification(int p_what) {
RID ci = get_canvas_item();
Size2i size = get_size();
Ref<StyleBox> style = get_stylebox("slider");
- Ref<StyleBox> focus = get_stylebox("focus");
Ref<StyleBox> grabber_area = get_stylebox("grabber_area");
Ref<Texture> grabber = get_icon(editable ? ((mouse_inside || has_focus()) ? "grabber_highlight" : "grabber") : "grabber_disabled");
Ref<Texture> tick = get_icon("tick");
@@ -178,10 +177,7 @@ void Slider::_notification(int p_what) {
float areasize = size.height - grabber->get_size().height;
style->draw(ci, Rect2i(Point2i(size.width / 2 - widget_width / 2, 0), Size2i(widget_width, size.height)));
grabber_area->draw(ci, Rect2i(Point2i((size.width - widget_width) / 2, size.height - areasize * ratio - grabber->get_size().height / 2), Size2i(widget_width, areasize * ratio + grabber->get_size().width / 2)));
- /*
- if (mouse_inside||has_focus())
- focus->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height)));
- */
+
if (ticks > 1) {
int grabber_offset = (grabber->get_size().height / 2 - tick->get_height() / 2);
for (int i = 0; i < ticks; i++) {
@@ -198,10 +194,6 @@ void Slider::_notification(int p_what) {
style->draw(ci, Rect2i(Point2i(0, (size.height - widget_height) / 2), Size2i(size.width, widget_height)));
grabber_area->draw(ci, Rect2i(Point2i(0, (size.height - widget_height) / 2), Size2i(areasize * ratio + grabber->get_size().width / 2, widget_height)));
- /*
- if (mouse_inside||has_focus())
- focus->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height)));
- */
if (ticks > 1) {
int grabber_offset = (grabber->get_size().width / 2 - tick->get_width() / 2);
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index e82819f270..c67e5a928c 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -496,9 +496,6 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_stylebox("slider", "HSlider", make_stylebox(hslider_bg_png, 4, 4, 4, 4));
theme->set_stylebox("grabber_area", "HSlider", make_stylebox(hslider_bg_png, 4, 4, 4, 4));
- theme->set_stylebox("grabber_highlight", "HSlider", make_stylebox(hslider_grabber_hl_png, 6, 6, 6, 6));
- theme->set_stylebox("grabber_disabled", "HSlider", make_stylebox(hslider_grabber_disabled_png, 6, 6, 6, 6));
- theme->set_stylebox("focus", "HSlider", focus);
theme->set_icon("grabber", "HSlider", make_icon(hslider_grabber_png));
theme->set_icon("grabber_highlight", "HSlider", make_icon(hslider_grabber_hl_png));
@@ -509,9 +506,6 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_stylebox("slider", "VSlider", make_stylebox(vslider_bg_png, 4, 4, 4, 4));
theme->set_stylebox("grabber_area", "VSlider", make_stylebox(vslider_bg_png, 4, 4, 4, 4));
- theme->set_stylebox("grabber_highlight", "VSlider", make_stylebox(vslider_grabber_hl_png, 6, 6, 6, 6));
- theme->set_stylebox("grabber_disabled", "VSlider", make_stylebox(vslider_grabber_disabled_png, 6, 6, 6, 6));
- theme->set_stylebox("focus", "VSlider", focus);
theme->set_icon("grabber", "VSlider", make_icon(vslider_grabber_png));
theme->set_icon("grabber_highlight", "VSlider", make_icon(vslider_grabber_hl_png));
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index f26b57b572..d4da98b8a8 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -554,7 +554,7 @@ int StyleBoxFlat::get_aa_size() const {
}
void StyleBoxFlat::set_corner_detail(const int &p_corner_detail) {
- corner_detail = CLAMP(p_corner_detail, 1, 128);
+ corner_detail = CLAMP(p_corner_detail, 1, 20);
emit_changed();
}
int StyleBoxFlat::get_corner_detail() const {
@@ -931,7 +931,7 @@ void StyleBoxFlat::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::INT, "corner_radius_bottom_right", PROPERTY_HINT_RANGE, "0,1024,1"), "set_corner_radius", "get_corner_radius", CORNER_BOTTOM_RIGHT);
ADD_PROPERTYI(PropertyInfo(Variant::INT, "corner_radius_bottom_left", PROPERTY_HINT_RANGE, "0,1024,1"), "set_corner_radius", "get_corner_radius", CORNER_BOTTOM_LEFT);
- ADD_PROPERTY(PropertyInfo(Variant::INT, "corner_detail", PROPERTY_HINT_RANGE, "1,128,1"), "set_corner_detail", "get_corner_detail");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "corner_detail", PROPERTY_HINT_RANGE, "1,20,1"), "set_corner_detail", "get_corner_detail");
ADD_GROUP("Expand Margin", "expand_margin_");
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin_left", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin", "get_expand_margin", MARGIN_LEFT);