summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/class_db.cpp58
-rw-r--r--core/class_db.h5
-rw-r--r--core/io/multiplayer_api.cpp1
-rw-r--r--core/math/a_star.cpp6
-rw-r--r--core/object.h1
-rw-r--r--core/register_core_types.cpp1
-rw-r--r--doc/classes/ConfigFile.xml40
-rw-r--r--doc/classes/GraphEdit.xml22
-rw-r--r--doc/classes/Node.xml3
-rw-r--r--doc/classes/OS.xml2
-rw-r--r--doc/classes/PopupMenu.xml93
-rw-r--r--doc/classes/SpinBox.xml16
-rwxr-xr-xdoc/tools/makerst.py85
-rw-r--r--drivers/unix/ip_unix.cpp2
-rw-r--r--drivers/unix/net_socket_posix.cpp17
-rw-r--r--editor/doc/doc_data.cpp42
-rw-r--r--editor/doc/doc_data.h1
-rw-r--r--editor/editor_help.cpp66
-rw-r--r--editor/editor_node.cpp4
-rw-r--r--editor/editor_properties.cpp51
-rw-r--r--editor/editor_properties.h15
-rw-r--r--editor/editor_settings.cpp13
-rw-r--r--editor/editor_spin_slider.h3
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp5
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp200
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h9
-rwxr-xr-xeditor/translations/extract.py4
-rw-r--r--main/main.cpp20
-rw-r--r--methods.py8
-rw-r--r--modules/enet/networked_multiplayer_enet.cpp4
-rw-r--r--modules/gdnative/arvr/arvr_interface_gdnative.cpp26
-rw-r--r--modules/gdnative/arvr/arvr_interface_gdnative.h2
-rw-r--r--modules/gdnative/gdnative/array.cpp4
-rw-r--r--modules/gdnative/net/multiplayer_peer_gdnative.cpp2
-rw-r--r--modules/gdnative/pluginscript/pluginscript_language.cpp2
-rw-r--r--modules/gdnative/pluginscript/pluginscript_script.cpp18
-rw-r--r--modules/webrtc/webrtc_data_channel_gdnative.cpp1
-rw-r--r--scene/2d/collision_object_2d.cpp7
-rw-r--r--scene/2d/physics_body_2d.cpp2
-rw-r--r--scene/2d/tile_map.cpp215
-rw-r--r--scene/2d/tile_map.h15
-rw-r--r--scene/3d/arvr_nodes.cpp1
-rw-r--r--scene/3d/physics_body.cpp2
-rw-r--r--scene/gui/color_picker.cpp10
-rw-r--r--scene/main/scene_tree.cpp11
-rw-r--r--scene/resources/concave_polygon_shape_2d.cpp2
46 files changed, 822 insertions, 295 deletions
diff --git a/core/class_db.cpp b/core/class_db.cpp
index c9527e3c8f..9fe9b23c68 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -545,6 +545,11 @@ bool ClassDB::can_instance(const StringName &p_class) {
ClassInfo *ti = classes.getptr(p_class);
ERR_FAIL_COND_V(!ti, false);
+#ifdef TOOLS_ENABLED
+ if (ti->api == API_EDITOR && !Engine::get_singleton()->is_editor_hint()) {
+ return false;
+ }
+#endif
return (!ti->disabled && ti->creation_func != NULL);
}
@@ -980,6 +985,13 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons
type->property_setget[p_pinfo.name] = psg;
}
+void ClassDB::set_property_default_value(StringName p_class, const StringName &p_name, const Variant &p_default) {
+ if (!default_values.has(p_class)) {
+ default_values[p_class] = HashMap<StringName, Variant>();
+ }
+ default_values[p_class][p_name] = p_default;
+}
+
void ClassDB::get_property_list(StringName p_class, List<PropertyInfo> *p_list, bool p_no_inheritance, const Object *p_validator) {
OBJTYPE_RLOCK;
@@ -1383,37 +1395,60 @@ void ClassDB::get_extensions_for_type(const StringName &p_class, List<String> *p
}
HashMap<StringName, HashMap<StringName, Variant> > ClassDB::default_values;
+Set<StringName> ClassDB::default_values_cached;
-Variant ClassDB::class_get_default_property_value(const StringName &p_class, const StringName &p_property) {
+Variant ClassDB::class_get_default_property_value(const StringName &p_class, const StringName &p_property, bool *r_valid) {
- if (!default_values.has(p_class)) {
+ if (!default_values_cached.has(p_class)) {
- default_values[p_class] = HashMap<StringName, Variant>();
+ if (!default_values.has(p_class)) {
+ default_values[p_class] = HashMap<StringName, Variant>();
+ }
- if (ClassDB::can_instance(p_class)) {
+ Object *c = NULL;
+ bool cleanup_c = false;
+
+ if (Engine::get_singleton()->has_singleton(p_class)) {
+ c = Engine::get_singleton()->get_singleton_object(p_class);
+ cleanup_c = false;
+ } else if (ClassDB::can_instance(p_class)) {
+ c = ClassDB::instance(p_class);
+ cleanup_c = true;
+ }
+
+ if (c) {
- Object *c = ClassDB::instance(p_class);
List<PropertyInfo> plist;
c->get_property_list(&plist);
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
if (E->get().usage & (PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR)) {
- Variant v = c->get(E->get().name);
- default_values[p_class][E->get().name] = v;
+ if (!default_values[p_class].has(E->get().name)) {
+ Variant v = c->get(E->get().name);
+ default_values[p_class][E->get().name] = v;
+ }
}
}
- memdelete(c);
+
+ if (cleanup_c) {
+ memdelete(c);
+ }
}
+
+ default_values_cached.insert(p_class);
}
if (!default_values.has(p_class)) {
+ if (r_valid != NULL) *r_valid = false;
return Variant();
}
if (!default_values[p_class].has(p_property)) {
+ if (r_valid != NULL) *r_valid = false;
return Variant();
}
+ if (r_valid != NULL) *r_valid = true;
return default_values[p_class][p_property];
}
@@ -1424,6 +1459,12 @@ void ClassDB::init() {
lock = RWLock::create();
}
+void ClassDB::cleanup_defaults() {
+
+ default_values.clear();
+ default_values_cached.clear();
+}
+
void ClassDB::cleanup() {
//OBJTYPE_LOCK; hah not here
@@ -1443,7 +1484,6 @@ void ClassDB::cleanup() {
classes.clear();
resource_base_extensions.clear();
compat_classes.clear();
- default_values.clear();
memdelete(lock);
}
diff --git a/core/class_db.h b/core/class_db.h
index efa1a46866..237ae9b806 100644
--- a/core/class_db.h
+++ b/core/class_db.h
@@ -162,6 +162,7 @@ public:
static void _add_class2(const StringName &p_class, const StringName &p_inherits);
static HashMap<StringName, HashMap<StringName, Variant> > default_values;
+ static Set<StringName> default_values_cached;
public:
// DO NOT USE THIS!!!!!! NEEDS TO BE PUBLIC BUT DO NOT USE NO MATTER WHAT!!!
@@ -329,6 +330,7 @@ public:
static void add_property_group(StringName p_class, const String &p_name, const String &p_prefix = "");
static void add_property(StringName p_class, const PropertyInfo &p_pinfo, const StringName &p_setter, const StringName &p_getter, int p_index = -1);
+ static void set_property_default_value(StringName p_class, const StringName &p_name, const Variant &p_default);
static void get_property_list(StringName p_class, List<PropertyInfo> *p_list, bool p_no_inheritance = false, const Object *p_validator = NULL);
static bool set_property(Object *p_object, const StringName &p_property, const Variant &p_value, bool *r_valid = NULL);
static bool get_property(Object *p_object, const StringName &p_property, Variant &r_value);
@@ -355,7 +357,7 @@ public:
static void get_enum_list(const StringName &p_class, List<StringName> *p_enums, bool p_no_inheritance = false);
static void get_enum_constants(const StringName &p_class, const StringName &p_enum, List<StringName> *p_constants, bool p_no_inheritance = false);
- static Variant class_get_default_property_value(const StringName &p_class, const StringName &p_property);
+ static Variant class_get_default_property_value(const StringName &p_class, const StringName &p_property, bool *r_valid = NULL);
static StringName get_category(const StringName &p_node);
@@ -373,6 +375,7 @@ public:
static void set_current_api(APIType p_api);
static APIType get_current_api();
+ static void cleanup_defaults();
static void cleanup();
};
diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp
index 2779837190..33dc4dbde4 100644
--- a/core/io/multiplayer_api.cpp
+++ b/core/io/multiplayer_api.cpp
@@ -874,6 +874,7 @@ void MultiplayerAPI::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_object_decoding"), "set_allow_object_decoding", "is_object_decoding_allowed");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "refuse_new_network_connections"), "set_refuse_new_network_connections", "is_refusing_new_network_connections");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "network_peer", PROPERTY_HINT_RESOURCE_TYPE, "NetworkedMultiplayerPeer", 0), "set_network_peer", "get_network_peer");
+ ADD_PROPERTY_DEFAULT("refuse_new_network_connections", false);
ADD_SIGNAL(MethodInfo("network_peer_connected", PropertyInfo(Variant::INT, "id")));
ADD_SIGNAL(MethodInfo("network_peer_disconnected", PropertyInfo(Variant::INT, "id")));
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp
index 7ce3824505..b61119d8df 100644
--- a/core/math/a_star.cpp
+++ b/core/math/a_star.cpp
@@ -216,6 +216,8 @@ int AStar::get_closest_point(const Vector3 &p_point) const {
for (const Map<int, Point *>::Element *E = points.front(); E; E = E->next()) {
+ if (!E->get()->enabled)
+ continue; //Disabled points should not be considered
real_t d = p_point.distance_squared_to(E->get()->pos);
if (closest_id < 0 || d < closest_dist) {
closest_dist = d;
@@ -234,6 +236,10 @@ Vector3 AStar::get_closest_position_in_segment(const Vector3 &p_point) const {
for (const Set<Segment>::Element *E = segments.front(); E; E = E->next()) {
+ if (!(E->get().from_point->enabled && E->get().to_point->enabled)) {
+ continue;
+ }
+
Vector3 segment[2] = {
E->get().from_point->pos,
E->get().to_point->pos,
diff --git a/core/object.h b/core/object.h
index 4394c1c3da..1e0b22c086 100644
--- a/core/object.h
+++ b/core/object.h
@@ -130,6 +130,7 @@ enum PropertyUsageFlags {
#define ADD_SIGNAL(m_signal) ClassDB::add_signal(get_class_static(), m_signal)
#define ADD_PROPERTY(m_property, m_setter, m_getter) ClassDB::add_property(get_class_static(), m_property, _scs_create(m_setter), _scs_create(m_getter))
#define ADD_PROPERTYI(m_property, m_setter, m_getter, m_index) ClassDB::add_property(get_class_static(), m_property, _scs_create(m_setter), _scs_create(m_getter), m_index)
+#define ADD_PROPERTY_DEFAULT(m_property, m_default) ClassDB::set_property_default_value(get_class_static(), m_property, m_default)
#define ADD_GROUP(m_name, m_prefix) ClassDB::add_property_group(get_class_static(), m_name, m_prefix)
struct PropertyInfo {
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index 135df4e5bd..af863dd385 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -273,6 +273,7 @@ void unregister_core_types() {
ResourceLoader::finalize();
+ ClassDB::cleanup_defaults();
ObjectDB::cleanup();
unregister_variant_methods();
diff --git a/doc/classes/ConfigFile.xml b/doc/classes/ConfigFile.xml
index 5b8f0c32d1..775ad4c922 100644
--- a/doc/classes/ConfigFile.xml
+++ b/doc/classes/ConfigFile.xml
@@ -97,6 +97,26 @@
Loads the config file specified as a parameter. The file's contents are parsed and loaded in the ConfigFile object which the method was called on. Returns one of the [constant OK], [constant FAILED] or [code]ERR_*[/code] constants listed in [@GlobalScope]. If the load was successful, the return value is [constant OK].
</description>
</method>
+ <method name="load_encrypted">
+ <return type="int" enum="Error">
+ </return>
+ <argument index="0" name="path" type="String">
+ </argument>
+ <argument index="1" name="key" type="PoolByteArray">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="load_encrypted_pass">
+ <return type="int" enum="Error">
+ </return>
+ <argument index="0" name="path" type="String">
+ </argument>
+ <argument index="1" name="pass" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="save">
<return type="int" enum="Error">
</return>
@@ -106,6 +126,26 @@
Saves the contents of the ConfigFile object to the file specified as a parameter. The output file uses an INI-style structure. Returns one of the [constant OK], [constant FAILED] or [code]ERR_*[/code] constants listed in [@GlobalScope]. If the load was successful, the return value is [constant OK].
</description>
</method>
+ <method name="save_encrypted">
+ <return type="int" enum="Error">
+ </return>
+ <argument index="0" name="path" type="String">
+ </argument>
+ <argument index="1" name="key" type="PoolByteArray">
+ </argument>
+ <description>
+ </description>
+ </method>
+ <method name="save_encrypted_pass">
+ <return type="int" enum="Error">
+ </return>
+ <argument index="0" name="path" type="String">
+ </argument>
+ <argument index="1" name="pass" type="String">
+ </argument>
+ <description>
+ </description>
+ </method>
<method name="set_value">
<return type="void">
</return>
diff --git a/doc/classes/GraphEdit.xml b/doc/classes/GraphEdit.xml
index b39b8e9f48..f6cb4ca4d9 100644
--- a/doc/classes/GraphEdit.xml
+++ b/doc/classes/GraphEdit.xml
@@ -198,6 +198,17 @@
Signal sent at the end of a GraphNode movement.
</description>
</signal>
+ <signal name="connection_from_empty">
+ <argument index="0" name="to" type="String">
+ </argument>
+ <argument index="1" name="to_slot" type="int">
+ </argument>
+ <argument index="2" name="release_position" type="Vector2">
+ </argument>
+ <description>
+ Signal sent when user dragging connection from input port into empty space of the graph.
+ </description>
+ </signal>
<signal name="connection_request">
<argument index="0" name="from" type="String">
</argument>
@@ -211,17 +222,6 @@
Signal sent to the GraphEdit when the connection between the [code]from_slot[/code] slot of the [code]from[/code] GraphNode and the [code]to_slot[/code] slot of the [code]to[/code] GraphNode is attempted to be created.
</description>
</signal>
- <signal name="connection_from_empty">
- <argument index="0" name="to" type="String">
- </argument>
- <argument index="1" name="to_slot" type="int">
- </argument>
- <argument index="2" name="release_position" type="Vector2">
- </argument>
- <description>
- Signal sent when user dragging connection from input port into empty space of the graph.
- </description>
- </signal>
<signal name="connection_to_empty">
<argument index="0" name="from" type="String">
</argument>
diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml
index 5956d7a364..d9df2a50c6 100644
--- a/doc/classes/Node.xml
+++ b/doc/classes/Node.xml
@@ -85,6 +85,7 @@
Called when the node is "ready", i.e. when both the node and its children have entered the scene tree. If the node has children, their [method _ready] callbacks get triggered first, and the parent node will receive the ready notification afterwards.
Corresponds to the [constant NOTIFICATION_READY] notification in [method Object._notification]. See also the [code]onready[/code] keyword for variables.
Usually used for initialization. For even earlier initialization, [method Object._init] may be used. See also [method _enter_tree].
+ [b]Note:[/b] [method _ready] may be called only once for each node. After removing a node from the scene tree and adding again, [code]_ready[/code] will not be called for the second time. This can be bypassed with requesting another call with [method request_ready], which may be called anywhere before adding the node again.
</description>
</method>
<method name="_unhandled_input" qualifiers="virtual">
@@ -595,7 +596,7 @@
<return type="void">
</return>
<description>
- Requests that [code]_ready[/code] be called again.
+ Requests that [code]_ready[/code] be called again. Note that the method won't be called immediately, but is scheduled for when the node is added to the scene tree again (see [method _ready]). [code]_ready[/code] is called only for the node which requested it, which means that you need to request ready for each child if you want them to call [code]_ready[/code] too (in which case, [code]_ready[/code] will be called in the same order as it would normally).
</description>
</method>
<method name="rpc" qualifiers="vararg">
diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml
index cd530eddfa..e9b51d03c3 100644
--- a/doc/classes/OS.xml
+++ b/doc/classes/OS.xml
@@ -360,6 +360,7 @@
<return type="int">
</return>
<description>
+ Returns the amount of time in milliseconds it took for the boot logo to appear.
</description>
</method>
<method name="get_static_memory_peak_usage" qualifiers="const">
@@ -493,6 +494,7 @@
<return type="Rect2">
</return>
<description>
+ Returns unobscured area of the window where interactive controls should be rendered.
</description>
</method>
<method name="has_environment" qualifiers="const">
diff --git a/doc/classes/PopupMenu.xml b/doc/classes/PopupMenu.xml
index 0d869fc72f..3ce923e36a 100644
--- a/doc/classes/PopupMenu.xml
+++ b/doc/classes/PopupMenu.xml
@@ -4,7 +4,7 @@
PopupMenu displays a list of options.
</brief_description>
<description>
- PopupMenu is the typical Control that displays a list of options. They are popular in toolbars or context menus.
+ [PopupMenu] is a [Control] that displays a list of options. They are popular in toolbars or context menus.
</description>
<tutorials>
</tutorials>
@@ -19,8 +19,9 @@
<argument index="2" name="accel" type="int" default="0">
</argument>
<description>
- Adds a new checkable item with text [code]label[/code]. An [code]id[/code] can optionally be provided, as well as an accelerator ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index.
- [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually.
+ Adds a new checkable item with text [code]label[/code].
+ An [code]id[/code] can optionally be provided, as well as an accelerator ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index. If no [code]accel[/code] is provided then the default [code]0[/code] will be assigned to it. See [method get_item_accelerator] for more info on accelerators.
+ [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] for more info on how to control it.
</description>
</method>
<method name="add_check_shortcut">
@@ -33,6 +34,9 @@
<argument index="2" name="global" type="bool" default="false">
</argument>
<description>
+ Adds a new checkable item and assigns the specified [ShortCut] to it. Sets the label of the checkbox to the [ShortCut]'s name.
+ An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index.
+ [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] for more info on how to control it.
</description>
</method>
<method name="add_icon_check_item">
@@ -47,8 +51,9 @@
<argument index="3" name="accel" type="int" default="0">
</argument>
<description>
- Adds a new checkable item with text [code]label[/code] and icon [code]texture[/code]. An [code]id[/code] can optionally be provided, as well as an accelerator ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index.
- [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually.
+ Adds a new checkable item with text [code]label[/code] and icon [code]texture[/code].
+ An [code]id[/code] can optionally be provided, as well as an accelerator ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index. If no [code]accel[/code] is provided then the default [code]0[/code] will be assigned to it. See [method get_item_accelerator] for more info on accelerators.
+ [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] for more info on how to control it.
</description>
</method>
<method name="add_icon_check_shortcut">
@@ -63,6 +68,9 @@
<argument index="3" name="global" type="bool" default="false">
</argument>
<description>
+ Adds a new checkable item and assigns the specified [ShortCut] and icon [code]texture[/code] to it. Sets the label of the checkbox to the [ShortCut]'s name.
+ An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index.
+ [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] for more info on how to control it.
</description>
</method>
<method name="add_icon_item">
@@ -77,7 +85,8 @@
<argument index="3" name="accel" type="int" default="0">
</argument>
<description>
- Adds a new item with text [code]label[/code] and icon [code]texture[/code]. An [code]id[/code] can optionally be provided, as well as an accelerator keybinding ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index.
+ Adds a new item with text [code]label[/code] and icon [code]texture[/code].
+ An [code]id[/code] can optionally be provided, as well as an accelerator ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index. If no [code]accel[/code] is provided then the default [code]0[/code] will be assigned to it. See [method get_item_accelerator] for more info on accelerators.
</description>
</method>
<method name="add_icon_shortcut">
@@ -92,6 +101,8 @@
<argument index="3" name="global" type="bool" default="false">
</argument>
<description>
+ Adds a new item and assigns the specified [ShortCut] and icon [code]texture[/code] to it. Sets the label of the checkbox to the [ShortCut]'s name.
+ An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index.
</description>
</method>
<method name="add_item">
@@ -104,7 +115,8 @@
<argument index="2" name="accel" type="int" default="0">
</argument>
<description>
- Adds a new item with text [code]label[/code]. An [code]id[/code] can optionally be provided, as well as an accelerator keybinding ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index.
+ Adds a new item with text [code]label[/code].
+ An [code]id[/code] can optionally be provided, as well as an accelerator ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index. If no [code]accel[/code] is provided then the default [code]0[/code] will be assigned to it. See [method get_item_accelerator] for more info on accelerators.
</description>
</method>
<method name="add_radio_check_item">
@@ -117,8 +129,9 @@
<argument index="2" name="accel" type="int" default="0">
</argument>
<description>
- The same as [method add_check_item], but the inserted item will look as a radio button.
- [b]Note:[/b] This is purely cosmetic; you must add the logic for checking/unchecking items in radio groups.
+ Adds a new radio button with text [code]label[/code].
+ An [code]id[/code] can optionally be provided, as well as an accelerator ([code]accel[/code]). If no [code]id[/code] is provided, one will be created from the index. If no [code]accel[/code] is provided then the default [code]0[/code] will be assigned to it. See [method get_item_accelerator] for more info on accelerators.
+ [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] for more info on how to control it.
</description>
</method>
<method name="add_radio_check_shortcut">
@@ -131,6 +144,9 @@
<argument index="2" name="global" type="bool" default="false">
</argument>
<description>
+ Adds a new radio check button and assigns a [ShortCut] to it. Sets the label of the checkbox to the [ShortCut]'s name.
+ An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index.
+ [b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually. See [method set_item_checked] for more info on how to control it.
</description>
</method>
<method name="add_separator">
@@ -152,6 +168,8 @@
<argument index="2" name="global" type="bool" default="false">
</argument>
<description>
+ Adds a [ShortCut].
+ An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index.
</description>
</method>
<method name="add_submenu_item">
@@ -164,14 +182,15 @@
<argument index="2" name="id" type="int" default="-1">
</argument>
<description>
- Adds an item with a submenu. The submenu is the name of a child PopupMenu node that would be shown when the item is clicked. An id can optionally be provided, but if is isn't provided, one will be created from the index.
+ Adds an item that will act as a submenu of the parent [PopupMenu] node when clicked. The [code]submenu[/code] argument is the name of the child [PopupMenu] node that will be shown when the item is clicked.
+ An [code]id[/code] can optionally be provided. If no [code]id[/code] is provided, one will be created from the index.
</description>
</method>
<method name="clear">
<return type="void">
</return>
<description>
- Clear the popup menu, in effect removing all items.
+ Removes all items from the [PopupMenu].
</description>
</method>
<method name="get_item_accelerator" qualifiers="const">
@@ -187,7 +206,7 @@
<return type="int">
</return>
<description>
- Returns the amount of items.
+ Returns the number of items in the [PopupMenu].
</description>
</method>
<method name="get_item_icon" qualifiers="const">
@@ -205,7 +224,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
- Returns the id of the item at index [code]idx[/code].
+ Returns the id of the item at index [code]idx[/code]. [code]id[/code] can be manually assigned, while index can not.
</description>
</method>
<method name="get_item_index" qualifiers="const">
@@ -214,7 +233,7 @@
<argument index="0" name="id" type="int">
</argument>
<description>
- Finds and return the index of the item containing a given [code]id[/code].
+ Returns the index of the item containing the specified [code]id[/code]. Index is automatically assigned to each item by the engine. Index can not be set manualy.
</description>
</method>
<method name="get_item_metadata" qualifiers="const">
@@ -223,7 +242,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
- Returns the metadata of an item, which might be of any type. You can set it with [method set_item_metadata], which provides a simple way of assigning context data to items.
+ Returns the metadata of the specified item, which might be of any type. You can set it with [method set_item_metadata], which provides a simple way of assigning context data to items.
</description>
</method>
<method name="get_item_shortcut" qualifiers="const">
@@ -232,6 +251,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Returns the [ShortCut] associated with the specified [code]idx[/code] item.
</description>
</method>
<method name="get_item_submenu" qualifiers="const">
@@ -240,7 +260,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
- Returns the submenu name of the item at index [code]idx[/code].
+ Returns the submenu name of the item at index [code]idx[/code]. See [method add_submenu_item] for more info on how to add a submenu.
</description>
</method>
<method name="get_item_text" qualifiers="const">
@@ -258,12 +278,14 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Returns the tooltip associated with the specified index index [code]idx[/code].
</description>
</method>
<method name="is_hide_on_window_lose_focus" qualifiers="const">
<return type="bool">
</return>
<description>
+ Returns whether the popup will be hidden when the window loses focus or not.
</description>
</method>
<method name="is_item_checkable" qualifiers="const">
@@ -292,6 +314,7 @@
</argument>
<description>
Returns [code]true[/code] if the item at index [code]idx[/code] is disabled. When it is disabled it can't be selected, or its action invoked.
+ See [method set_item_disabled] for more info on how to disable an item.
</description>
</method>
<method name="is_item_radio_checkable" qualifiers="const">
@@ -300,7 +323,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
- Returns [code]true[/code] if the item at index [code]idx[/code] has radio-button-style checkability.
+ Returns [code]true[/code] if the item at index [code]idx[/code] has radio button-style checkability.
[b]Note:[/b] This is purely cosmetic; you must add the logic for checking/unchecking items in radio groups.
</description>
</method>
@@ -310,7 +333,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
- Returns [code]true[/code] if the item is a separator. If it is, it will be displayed as a line.
+ Returns [code]true[/code] if the item is a separator. If it is, it will be displayed as a line. See [method add_separator] for more info on how to add a separator.
</description>
</method>
<method name="is_item_shortcut_disabled" qualifiers="const">
@@ -319,6 +342,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Returns whether the shortcut of the specified item [code]idx[/code] is disabled or not.
</description>
</method>
<method name="remove_item">
@@ -337,6 +361,7 @@
<argument index="0" name="enable" type="bool">
</argument>
<description>
+ Hides the [PopupMenu] when the window loses focus.
</description>
</method>
<method name="set_item_accelerator">
@@ -358,7 +383,7 @@
<argument index="1" name="enable" type="bool">
</argument>
<description>
- Sets whether the item at index [code]idx[/code] has a checkbox.
+ Sets whether the item at index [code]idx[/code] has a checkbox. If [code]false[/code], sets the type of the item to plain text.
[b]Note:[/b] Checkable items just display a checkmark, but don't have any built-in checking behavior and must be checked/unchecked manually.
</description>
</method>
@@ -370,8 +395,7 @@
<argument index="1" name="enable" type="bool">
</argument>
<description>
- The same as [method set_item_as_checkable] but placing a radio button in case of enabling. If used for disabling, it's the same.
- Remember this is just cosmetic and you have to add the logic for checking/unchecking items in radio groups.
+ Sets the type of the item at the specified index [code]idx[/code] to radio button. If false, sets the type of the item to plain text.
</description>
</method>
<method name="set_item_as_separator">
@@ -382,7 +406,7 @@
<argument index="1" name="enable" type="bool">
</argument>
<description>
- Mark the item at index [code]idx[/code] as a separator, which means that it would be displayed as a line.
+ Mark the item at index [code]idx[/code] as a separator, which means that it would be displayed as a line. If [code]false[/code], sets the type of the item to plain text.
</description>
</method>
<method name="set_item_checked">
@@ -415,6 +439,7 @@
<argument index="1" name="icon" type="Texture">
</argument>
<description>
+ Replaces the [Texture] icon of the specified [code]idx[/code].
</description>
</method>
<method name="set_item_id">
@@ -459,6 +484,7 @@
<argument index="2" name="global" type="bool" default="false">
</argument>
<description>
+ Sets a [ShortCut] for the specified item [code]idx[/code].
</description>
</method>
<method name="set_item_shortcut_disabled">
@@ -469,6 +495,7 @@
<argument index="1" name="disabled" type="bool">
</argument>
<description>
+ Disables the [ShortCut] of the specified index [code]idx[/code].
</description>
</method>
<method name="set_item_submenu">
@@ -479,7 +506,7 @@
<argument index="1" name="submenu" type="String">
</argument>
<description>
- Sets the submenu of the item at index [code]idx[/code]. The submenu is the name of a child PopupMenu node that would be shown when the item is clicked.
+ Sets the submenu of the item at index [code]idx[/code]. The submenu is the name of a child [PopupMenu] node that would be shown when the item is clicked.
</description>
</method>
<method name="set_item_text">
@@ -501,6 +528,7 @@
<argument index="1" name="tooltip" type="String">
</argument>
<description>
+ Sets the [String] tooltip of the item at the specified index [code]idx[/code].
</description>
</method>
<method name="toggle_item_checked">
@@ -509,6 +537,7 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
+ Toggles the check state of the item of the specified index [code]idx[/code].
</description>
</method>
<method name="toggle_item_multistate">
@@ -525,10 +554,13 @@
If [code]true[/code], allows to navigate [PopupMenu] with letter keys. Default value: [code]false[/code].
</member>
<member name="hide_on_checkable_item_selection" type="bool" setter="set_hide_on_checkable_item_selection" getter="is_hide_on_checkable_item_selection">
+ If [code]true[/code], hides the [PopupMenu] when a checkbox or radio button is selected.
</member>
<member name="hide_on_item_selection" type="bool" setter="set_hide_on_item_selection" getter="is_hide_on_item_selection">
+ If [code]true[/code], hides the [PopupMenu] when an item is selected.
</member>
<member name="hide_on_state_item_selection" type="bool" setter="set_hide_on_state_item_selection" getter="is_hide_on_state_item_selection">
+ If [code]true[/code], hides the [PopupMenu] when a state item is selected.
</member>
<member name="submenu_popup_delay" type="float" setter="set_submenu_popup_delay" getter="get_submenu_popup_delay">
Sets the delay time for the submenu item to popup on mouse hovering. If the popup menu is added as a child of another (acting as a submenu), it will inherit the delay time of the parent menu item. Default value: [code]0.3[/code] seconds.
@@ -561,40 +593,55 @@
</constants>
<theme_items>
<theme_item name="checked" type="Texture">
+ Sets a custom [Texture] icon for [code]checked[/code] state of checkbox items.
</theme_item>
<theme_item name="font" type="Font">
+ Sets a custom [Font].
</theme_item>
<theme_item name="font_color" type="Color">
+ Sets a custom [Color] for the [Font].
</theme_item>
<theme_item name="font_color_accel" type="Color">
</theme_item>
<theme_item name="font_color_disabled" type="Color">
+ Sets a custom [Color] for disabled text.
</theme_item>
<theme_item name="font_color_hover" type="Color">
+ Sets a custom [Color] for the hovered text.
</theme_item>
<theme_item name="hover" type="StyleBox">
+ Sets a custom [StyleBox] when the [PopupMenu] is hovered.
</theme_item>
<theme_item name="hseparation" type="int">
+ Sets the horizontal space separation between each item.
</theme_item>
<theme_item name="labeled_separator_left" type="StyleBox">
</theme_item>
<theme_item name="labeled_separator_right" type="StyleBox">
</theme_item>
<theme_item name="panel" type="StyleBox">
+ Sets a custom [StyleBox] for the panel of the [PopupMenu].
</theme_item>
<theme_item name="panel_disabled" type="StyleBox">
+ Sets a custom [StyleBox] for the panel of the [PopupMenu], when the panel is disabled.
</theme_item>
<theme_item name="radio_checked" type="Texture">
+ Sets a custom [Texture] icon for [code]checked[/code] of radio button items.
</theme_item>
<theme_item name="radio_unchecked" type="Texture">
+ Sets a custom [Texture] icon for [code]unchecked[/code] of radio button items.
</theme_item>
<theme_item name="separator" type="StyleBox">
+ Sets a custom [StyleBox] for separator's.
</theme_item>
<theme_item name="submenu" type="Texture">
+ Sets a custom [Texture] for submenu's.
</theme_item>
<theme_item name="unchecked" type="Texture">
+ Sets a custom [Texture] icon for [code]unchecked[/code] of checkbox items.
</theme_item>
<theme_item name="vseparation" type="int">
+ Sets the vertical space separation between each item.
</theme_item>
</theme_items>
</class>
diff --git a/doc/classes/SpinBox.xml b/doc/classes/SpinBox.xml
index 8e2e2f1baa..3388af2dd0 100644
--- a/doc/classes/SpinBox.xml
+++ b/doc/classes/SpinBox.xml
@@ -5,6 +5,16 @@
</brief_description>
<description>
SpinBox is a numerical input text field. It allows entering integers and floats.
+ [b]Example:[/b]
+ [codeblock]
+ var spin_box = SpinBox.new()
+ add_child(spin_box)
+ var line_edit = spin_box.get_line_edit()
+ line_edit.context_menu_enabled = false
+ spin_box.align = LineEdit.ALIGN_RIGHT
+ [/codeblock]
+ The above code will create a [SpinBox], disable context menu on it and set the text alignment to right.
+ See [Range] class for more options over the [SpinBox].
</description>
<tutorials>
</tutorials>
@@ -13,23 +23,29 @@
<return type="LineEdit">
</return>
<description>
+ Returns the [LineEdit] instance from this [SpinBox]. You can use it to access properties and methods of [LineEdit].
</description>
</method>
</methods>
<members>
<member name="align" type="int" setter="set_align" getter="get_align" enum="LineEdit.Align">
+ Sets the text alignment of the [SpinBox].
</member>
<member name="editable" type="bool" setter="set_editable" getter="is_editable">
+ If [code]true[/code], the [SpinBox] will be editable. Otherwise, it will be read only.
</member>
<member name="prefix" type="String" setter="set_prefix" getter="get_prefix">
+ Adds the specified [code]prefix[/code] string before the numerical value of the [SpinBox].
</member>
<member name="suffix" type="String" setter="set_suffix" getter="get_suffix">
+ Adds the specified [code]prefix[/code] string after the numerical value of the [SpinBox].
</member>
</members>
<constants>
</constants>
<theme_items>
<theme_item name="updown" type="Texture">
+ Sets a custom [Texture] for up and down arrows of the [SpinBox].
</theme_item>
</theme_items>
</class>
diff --git a/doc/tools/makerst.py b/doc/tools/makerst.py
index 454c71d3c7..763c29ab4e 100755
--- a/doc/tools/makerst.py
+++ b/doc/tools/makerst.py
@@ -37,12 +37,13 @@ class TypeName:
class PropertyDef:
- def __init__(self, name, type_name, setter, getter, text): # type: (str, TypeName, Optional[str], Optional[str], Optional[str]) -> None
+ def __init__(self, name, type_name, setter, getter, text, default_value): # type: (str, TypeName, Optional[str], Optional[str], Optional[str], Optional[str]) -> None
self.name = name
self.type_name = type_name
self.setter = setter
self.getter = getter
self.text = text
+ self.default_value = default_value
class ParameterDef:
def __init__(self, name, type_name, default_value): # type: (str, TypeName, Optional[str]) -> None
@@ -81,9 +82,10 @@ class EnumDef:
class ThemeItemDef:
- def __init__(self, name, type_name): # type: (str, TypeName) -> None
+ def __init__(self, name, type_name, default_value): # type: (str, TypeName, Optional[str]) -> None
self.name = name
self.type_name = type_name
+ self.default_value = default_value
class ClassDef:
@@ -144,8 +146,9 @@ class State:
type_name = TypeName.from_element(property)
setter = property.get("setter") or None # Use or None so '' gets turned into None.
getter = property.get("getter") or None
+ default_value = property.get("default") or None
- property_def = PropertyDef(property_name, type_name, setter, getter, property.text)
+ property_def = PropertyDef(property_name, type_name, setter, getter, property.text, default_value)
class_def.properties[property_name] = property_def
methods = class_root.find("methods")
@@ -230,7 +233,8 @@ class State:
assert theme_item.tag == "theme_item"
theme_item_name = theme_item.attrib["name"]
- theme_item_def = ThemeItemDef(theme_item_name, TypeName.from_element(theme_item))
+ default_value = theme_item.get("default") or None
+ theme_item_def = ThemeItemDef(theme_item_name, TypeName.from_element(theme_item), default_value)
if theme_item_name not in class_def.theme_items:
class_def.theme_items[theme_item_name] = []
class_def.theme_items[theme_item_name].append(theme_item_def)
@@ -400,8 +404,9 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S
for property_def in class_def.properties.values():
type_rst = property_def.type_name.to_rst(state)
ref = ":ref:`{0}<class_{1}_property_{0}>`".format(property_def.name, class_name)
- ml.append((type_rst, ref))
- format_table(f, ml)
+ default = property_def.default_value
+ ml.append((type_rst, ref, default))
+ format_table(f, ml, True)
# Methods overview
if len(class_def.methods) > 0:
@@ -415,11 +420,11 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S
# Theme properties
if class_def.theme_items is not None and len(class_def.theme_items) > 0:
f.write(make_heading('Theme Properties', '-'))
- ml = []
+ pl = []
for theme_item_list in class_def.theme_items.values():
for theme_item in theme_item_list:
- ml.append((theme_item.type_name.to_rst(state), theme_item.name))
- format_table(f, ml)
+ pl.append((theme_item.type_name.to_rst(state), theme_item.name, theme_item.default_value))
+ format_table(f, pl, True)
# Signals
if len(class_def.signals) > 0:
@@ -488,14 +493,16 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S
f.write(".. _class_{}_property_{}:\n\n".format(class_name, property_def.name))
f.write('- {} **{}**\n\n'.format(property_def.type_name.to_rst(state), property_def.name))
- setget = []
+ info = []
+ if property_def.default_value is not None:
+ info.append(("*Default*", property_def.default_value))
if property_def.setter is not None and not property_def.setter.startswith("_"):
- setget.append(("*Setter*", property_def.setter + '(value)'))
+ info.append(("*Setter*", property_def.setter + '(value)'))
if property_def.getter is not None and not property_def.getter.startswith("_"):
- setget.append(('*Getter*', property_def.getter + '()'))
+ info.append(('*Getter*', property_def.getter + '()'))
- if len(setget) > 0:
- format_table(f, setget)
+ if len(info) > 0:
+ format_table(f, info)
if property_def.text is not None and property_def.text.strip() != '':
f.write(rstize_text(property_def.text.strip(), state))
@@ -873,33 +880,33 @@ def rstize_text(text, state): # type: (str, State) -> str
return text
-def format_table(f, pp): # type: (TextIO, Iterable[Tuple[str, ...]]) -> None
- longest_t = 0
- longest_s = 0
- for s in pp:
- sl = len(s[0])
- if sl > longest_s:
- longest_s = sl
- tl = len(s[1])
- if tl > longest_t:
- longest_t = tl
-
- sep = "+"
- for i in range(longest_s + 2):
- sep += "-"
- sep += "+"
- for i in range(longest_t + 2):
- sep += "-"
+def format_table(f, data, remove_empty_columns=False): # type: (TextIO, Iterable[Tuple[str, ...]]) -> None
+ if len(data) == 0:
+ return
+
+ column_sizes = [0] * len(data[0])
+ for row in data:
+ for i, text in enumerate(row):
+ text_length = len(text or '')
+ if text_length > column_sizes[i]:
+ column_sizes[i] = text_length
+
+ sep = ""
+ for size in column_sizes:
+ if size == 0 and remove_empty_columns:
+ continue
+ sep += "+" + "-" * (size + 2)
sep += "+\n"
f.write(sep)
- for s in pp:
- rt = s[0]
- while len(rt) < longest_s:
- rt += " "
- st = s[1]
- while len(st) < longest_t:
- st += " "
- f.write("| " + rt + " | " + st + " |\n")
+
+ for row in data:
+ row_text = "|"
+ for i, text in enumerate(row):
+ if column_sizes[i] == 0 and remove_empty_columns:
+ continue
+ row_text += " " + (text or '').ljust(column_sizes[i]) + " |"
+ row_text += "\n"
+ f.write(row_text)
f.write(sep)
f.write('\n')
diff --git a/drivers/unix/ip_unix.cpp b/drivers/unix/ip_unix.cpp
index 39ca9a823e..ce66f07a19 100644
--- a/drivers/unix/ip_unix.cpp
+++ b/drivers/unix/ip_unix.cpp
@@ -56,7 +56,6 @@
#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,
@@ -73,6 +72,7 @@
#ifdef __FreeBSD__
#include <netinet/in.h>
#endif
+#include <net/if.h> // Order is important on OpenBSD, leave as last
#endif
static IP_Address _sockaddr2ip(struct sockaddr *p_addr) {
diff --git a/drivers/unix/net_socket_posix.cpp b/drivers/unix/net_socket_posix.cpp
index c10443acde..16562e2c8f 100644
--- a/drivers/unix/net_socket_posix.cpp
+++ b/drivers/unix/net_socket_posix.cpp
@@ -55,10 +55,6 @@
#include <netinet/tcp.h>
-#if defined(__APPLE__)
-#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
@@ -87,10 +83,6 @@
#define SOCK_IOCTL ioctlsocket
#define SOCK_CLOSE closesocket
-// Windows doesn't have this flag
-#ifndef MSG_NOSIGNAL
-#define MSG_NOSIGNAL 0
-#endif
// Workaround missing flag in MinGW
#if defined(__MINGW32__) && !defined(SIO_UDP_NETRESET)
#define SIO_UDP_NETRESET _WSAIOW(IOC_VENDOR, 15)
@@ -342,6 +334,13 @@ Error NetSocketPosix::open(Type p_sock_type, IP::Type &ip_type) {
}
}
#endif
+#if defined(SO_NOSIGPIPE)
+ // Disable SIGPIPE (should only be relevant to stream sockets, but seems to affect UDP too on iOS)
+ int par = 1;
+ if (setsockopt(_sock, SOL_SOCKET, SO_NOSIGPIPE, SOCK_CBUF(&par), sizeof(int)) != 0) {
+ print_verbose("Unable to turn off SIGPIPE on socket");
+ }
+#endif
return OK;
}
@@ -546,8 +545,10 @@ Error NetSocketPosix::send(const uint8_t *p_buffer, int p_len, int &r_sent) {
ERR_FAIL_COND_V(!is_open(), ERR_UNCONFIGURED);
int flags = 0;
+#ifdef MSG_NOSIGNAL
if (_is_stream)
flags = MSG_NOSIGNAL;
+#endif
r_sent = ::send(_sock, SOCK_CBUF(p_buffer), p_len, flags);
if (r_sent < 0) {
diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp
index 041f81d063..6ee07d3661 100644
--- a/editor/doc/doc_data.cpp
+++ b/editor/doc/doc_data.cpp
@@ -248,6 +248,28 @@ void DocData::generate(bool p_basic_types) {
prop.setter = setter;
prop.getter = getter;
+ Variant default_value = Variant();
+ bool default_value_valid = false;
+
+ if (ClassDB::can_instance(name)) {
+ default_value = ClassDB::class_get_default_property_value(name, E->get().name, &default_value_valid);
+ } else {
+ // Cannot get default value of classes that can't be instanced
+ List<StringName> inheriting_classes;
+ ClassDB::get_direct_inheriters_from_class(name, &inheriting_classes);
+ for (List<StringName>::Element *E2 = inheriting_classes.front(); E2; E2 = E2->next()) {
+ if (ClassDB::can_instance(E2->get())) {
+ default_value = ClassDB::class_get_default_property_value(E2->get(), E->get().name, &default_value_valid);
+ if (default_value_valid)
+ break;
+ }
+ }
+ }
+
+ if (default_value_valid) {
+ prop.default_value = default_value.get_construct_string();
+ }
+
bool found_type = false;
if (getter != StringName()) {
MethodBind *mb = ClassDB::get_method(name, getter);
@@ -412,6 +434,7 @@ void DocData::generate(bool p_basic_types) {
PropertyDoc pd;
pd.name = E->get();
pd.type = "int";
+ pd.default_value = itos(Theme::get_default()->get_constant(E->get(), cname));
c.theme_properties.push_back(pd);
}
@@ -422,6 +445,7 @@ void DocData::generate(bool p_basic_types) {
PropertyDoc pd;
pd.name = E->get();
pd.type = "Color";
+ pd.default_value = Variant(Theme::get_default()->get_color(E->get(), cname)).get_construct_string();
c.theme_properties.push_back(pd);
}
@@ -530,6 +554,7 @@ void DocData::generate(bool p_basic_types) {
PropertyDoc property;
property.name = pi.name;
property.type = Variant::get_type_name(pi.type);
+ property.default_value = v.get(pi.name).get_construct_string();
c.properties.push_back(property);
}
@@ -1063,12 +1088,15 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
for (int i = 0; i < c.properties.size(); i++) {
- String enum_text;
+ String additional_attributes;
if (c.properties[i].enumeration != String()) {
- enum_text = " enum=\"" + c.properties[i].enumeration + "\"";
+ additional_attributes += " enum=\"" + c.properties[i].enumeration + "\"";
+ }
+ if (c.properties[i].default_value != String()) {
+ additional_attributes += " default=\"" + c.properties[i].default_value.xml_escape(true) + "\"";
}
const PropertyDoc &p = c.properties[i];
- _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\"" + enum_text + ">");
+ _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\"" + additional_attributes + ">");
_write_string(f, 3, p.description.strip_edges().xml_escape());
_write_string(f, 2, "</member>");
}
@@ -1125,8 +1153,14 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri
for (int i = 0; i < c.theme_properties.size(); i++) {
const PropertyDoc &p = c.theme_properties[i];
- _write_string(f, 2, "<theme_item name=\"" + p.name + "\" type=\"" + p.type + "\">");
+
+ if (p.default_value != "")
+ _write_string(f, 2, "<theme_item name=\"" + p.name + "\" type=\"" + p.type + "\" default=\"" + p.default_value.xml_escape(true) + "\">");
+ else
+ _write_string(f, 2, "<theme_item name=\"" + p.name + "\" type=\"" + p.type + "\">");
+
_write_string(f, 3, p.description.strip_edges().xml_escape());
+
_write_string(f, 2, "</theme_item>");
}
_write_string(f, 1, "</theme_items>");
diff --git a/editor/doc/doc_data.h b/editor/doc/doc_data.h
index d3844adb7e..3d5867dcca 100644
--- a/editor/doc/doc_data.h
+++ b/editor/doc/doc_data.h
@@ -73,6 +73,7 @@ public:
String enumeration;
String description;
String setter, getter;
+ String default_value;
bool operator<(const PropertyDoc &p_prop) const {
return name < p_prop.name;
}
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 9918b655fb..ff50940842 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -48,9 +48,9 @@ void EditorHelp::_init_colors() {
text_color = get_color("default_color", "RichTextLabel");
headline_color = get_color("headline_color", "EditorHelp");
base_type_color = title_color.linear_interpolate(text_color, 0.5);
- comment_color = text_color * Color(1, 1, 1, 0.6);
+ comment_color = text_color * Color(1, 1, 1, 0.4);
symbol_color = comment_color;
- value_color = text_color * Color(1, 1, 1, 0.4);
+ value_color = text_color * Color(1, 1, 1, 0.6);
qualifier_color = text_color * Color(1, 1, 1, 0.8);
type_color = get_color("accent_color", "Editor").linear_interpolate(text_color, 0.5);
class_desc->add_color_override("selection_color", get_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
@@ -258,9 +258,11 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview
if (p_method.arguments[j].default_value != "") {
class_desc->push_color(symbol_color);
- class_desc->add_text("=");
+ class_desc->add_text(" = ");
class_desc->pop();
+ class_desc->push_color(value_color);
_add_text(_fix_constant(p_method.arguments[j].default_value));
+ class_desc->pop();
}
class_desc->pop();
@@ -471,23 +473,37 @@ void EditorHelp::_update_doc() {
if (cd.properties[i].description != "") {
describe = true;
}
+
class_desc->push_cell();
+ class_desc->push_font(doc_code_font);
+ class_desc->push_color(headline_color);
+
if (describe) {
class_desc->push_meta("@member " + cd.properties[i].name);
}
- class_desc->push_font(doc_code_font);
- class_desc->push_color(headline_color);
_add_text(cd.properties[i].name);
- class_desc->pop();
- class_desc->pop();
-
if (describe) {
class_desc->pop();
property_descr = true;
}
+ if (cd.properties[i].default_value != "") {
+ class_desc->push_color(symbol_color);
+ class_desc->add_text(" [default: ");
+ class_desc->pop();
+ class_desc->push_color(value_color);
+ _add_text(_fix_constant(cd.properties[i].default_value));
+ class_desc->pop();
+ class_desc->push_color(symbol_color);
+ class_desc->add_text("]");
+ class_desc->pop();
+ }
+
+ class_desc->pop();
+ class_desc->pop();
+
class_desc->pop();
}
@@ -613,6 +629,19 @@ void EditorHelp::_update_doc() {
class_desc->push_color(headline_color);
_add_text(cd.theme_properties[i].name);
class_desc->pop();
+
+ if (cd.theme_properties[i].default_value != "") {
+ class_desc->push_color(symbol_color);
+ class_desc->add_text(" [default: ");
+ class_desc->pop();
+ class_desc->push_color(value_color);
+ _add_text(_fix_constant(cd.theme_properties[i].default_value));
+ class_desc->pop();
+ class_desc->push_color(symbol_color);
+ class_desc->add_text("]");
+ class_desc->pop();
+ }
+
class_desc->pop();
if (cd.theme_properties[i].description != "") {
@@ -671,7 +700,7 @@ void EditorHelp::_update_doc() {
if (cd.signals[i].arguments[j].default_value != "") {
class_desc->push_color(symbol_color);
- class_desc->add_text("=");
+ class_desc->add_text(" = ");
class_desc->pop();
_add_text(cd.signals[i].arguments[j].default_value);
}
@@ -777,7 +806,7 @@ void EditorHelp::_update_doc() {
class_desc->add_text(" = ");
class_desc->pop();
class_desc->push_color(value_color);
- _add_text(enum_list[i].value);
+ _add_text(_fix_constant(enum_list[i].value));
class_desc->pop();
class_desc->pop();
if (enum_list[i].description != "") {
@@ -843,7 +872,7 @@ void EditorHelp::_update_doc() {
class_desc->add_text(" = ");
class_desc->pop();
class_desc->push_color(value_color);
- _add_text(constants[i].value);
+ _add_text(_fix_constant(constants[i].value));
class_desc->pop();
class_desc->pop();
@@ -963,6 +992,21 @@ void EditorHelp::_update_doc() {
class_desc->push_color(headline_color);
_add_text(cd.properties[i].name);
class_desc->pop(); // color
+
+ if (cd.properties[i].default_value != "") {
+ class_desc->push_color(symbol_color);
+ class_desc->add_text(" [default: ");
+ class_desc->pop(); // color
+
+ class_desc->push_color(value_color);
+ _add_text(_fix_constant(cd.properties[i].default_value));
+ class_desc->pop(); // color
+
+ class_desc->push_color(symbol_color);
+ class_desc->add_text("]");
+ class_desc->pop(); // color
+ }
+
class_desc->pop(); // font
class_desc->pop(); // cell
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 3d640b4d35..83d820ff0e 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -6342,6 +6342,10 @@ EditorNode::EditorNode() {
Ref<ParticlesMaterialConversionPlugin> particles_mat_convert;
particles_mat_convert.instance();
resource_conversion_plugins.push_back(particles_mat_convert);
+
+ Ref<VisualShaderConversionPlugin> vshader_convert;
+ vshader_convert.instance();
+ resource_conversion_plugins.push_back(vshader_convert);
}
update_spinner_step_msec = OS::get_singleton()->get_ticks_msec();
update_spinner_step_frame = Engine::get_singleton()->get_frames_drawn();
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 8e4ec47435..659893a1b6 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "editor_properties.h"
+
#include "editor/editor_resource_preview.h"
#include "editor_node.h"
#include "editor_properties_array_dict.h"
@@ -925,6 +926,9 @@ void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) {
preset->set_global_position(easing_draw->get_global_transform().xform(mb->get_position()));
preset->popup();
}
+ if (mb.is_valid() && mb->is_doubleclick() && mb->get_button_index() == BUTTON_LEFT) {
+ _setup_spin();
+ }
Ref<InputEventMouseMotion> mm = p_ev;
@@ -963,7 +967,6 @@ void EditorPropertyEasing::_draw_easing() {
Size2 s = easing_draw->get_size();
Rect2 r(Point2(), s);
r = r.grow(3);
- //get_stylebox("normal", "LineEdit")->draw(ci, r);
int points = 48;
@@ -1006,6 +1009,31 @@ void EditorPropertyEasing::_set_preset(int p_preset) {
easing_draw->update();
}
+void EditorPropertyEasing::_setup_spin() {
+ setting = true;
+ spin->setup_and_show();
+ spin->get_line_edit()->set_text(rtos(get_edited_object()->get(get_edited_property())));
+ setting = false;
+ spin->show();
+}
+
+void EditorPropertyEasing::_spin_value_changed(double p_value) {
+ if (setting)
+ return;
+
+ // 0 is a singularity, but both positive and negative values
+ // are otherwise allowed. Enforce 0+ as workaround.
+ if (Math::is_zero_approx(p_value)) {
+ p_value = 0.00001;
+ }
+ emit_changed(get_edited_property(), p_value);
+ _spin_focus_exited();
+}
+
+void EditorPropertyEasing::_spin_focus_exited() {
+ spin->hide();
+}
+
void EditorPropertyEasing::setup(bool p_full, bool p_flip) {
flip = p_flip;
@@ -1028,9 +1056,6 @@ void EditorPropertyEasing::_notification(int p_what) {
}
easing_draw->set_custom_minimum_size(Size2(0, get_font("font", "Label")->get_height() * 2));
} break;
- case NOTIFICATION_RESIZED: {
-
- } break;
}
}
@@ -1039,6 +1064,9 @@ void EditorPropertyEasing::_bind_methods() {
ClassDB::bind_method("_draw_easing", &EditorPropertyEasing::_draw_easing);
ClassDB::bind_method("_drag_easing", &EditorPropertyEasing::_drag_easing);
ClassDB::bind_method("_set_preset", &EditorPropertyEasing::_set_preset);
+
+ ClassDB::bind_method("_spin_value_changed", &EditorPropertyEasing::_spin_value_changed);
+ ClassDB::bind_method("_spin_focus_exited", &EditorPropertyEasing::_spin_focus_exited);
}
EditorPropertyEasing::EditorPropertyEasing() {
@@ -1053,6 +1081,19 @@ EditorPropertyEasing::EditorPropertyEasing() {
add_child(preset);
preset->connect("id_pressed", this, "_set_preset");
+ spin = memnew(EditorSpinSlider);
+ spin->set_flat(true);
+ spin->set_min(-100);
+ spin->set_max(100);
+ spin->set_step(0);
+ spin->set_hide_slider(true);
+ spin->set_allow_lesser(true);
+ spin->set_allow_greater(true);
+ spin->connect("value_changed", this, "_spin_value_changed");
+ spin->get_line_edit()->connect("focus_exited", this, "_spin_focus_exited");
+ spin->hide();
+ add_child(spin);
+
flip = false;
full = false;
}
@@ -2808,6 +2849,7 @@ EditorPropertyResource::EditorPropertyResource() {
assign->set_drag_forwarding(this);
assign->connect("draw", this, "_button_draw");
hbc->add_child(assign);
+ add_focusable(assign);
preview = memnew(TextureRect);
preview->set_expand(true);
@@ -2828,6 +2870,7 @@ EditorPropertyResource::EditorPropertyResource() {
edit->connect("pressed", this, "_update_menu");
hbc->add_child(edit);
edit->connect("gui_input", this, "_button_input");
+ add_focusable(edit);
file = NULL;
scene_tree = NULL;
diff --git a/editor/editor_properties.h b/editor/editor_properties.h
index 02d9349f2d..0a4a07cdc0 100644
--- a/editor/editor_properties.h
+++ b/editor/editor_properties.h
@@ -32,12 +32,12 @@
#define EDITOR_PROPERTIES_H
#include "editor/create_dialog.h"
-#include "editor/editor_file_system.h"
#include "editor/editor_inspector.h"
#include "editor/editor_spin_slider.h"
#include "editor/property_selector.h"
#include "editor/scene_tree_editor.h"
#include "scene/gui/color_picker.h"
+#include "scene/gui/line_edit.h"
class EditorPropertyNil : public EditorProperty {
GDCLASS(EditorPropertyNil, EditorProperty);
@@ -308,7 +308,11 @@ class EditorPropertyEasing : public EditorProperty {
GDCLASS(EditorPropertyEasing, EditorProperty);
Control *easing_draw;
PopupMenu *preset;
+ EditorSpinSlider *spin;
+ bool setting;
+
bool full;
+ bool flip;
enum {
EASING_ZERO,
@@ -321,13 +325,16 @@ class EditorPropertyEasing : public EditorProperty {
};
- bool flip;
-
void _drag_easing(const Ref<InputEvent> &p_ev);
void _draw_easing();
- void _notification(int p_what);
void _set_preset(int);
+ void _setup_spin();
+ void _spin_value_changed(double p_value);
+ void _spin_focus_exited();
+
+ void _notification(int p_what);
+
protected:
static void _bind_methods();
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 8521c0c723..a36163f661 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -1473,6 +1473,10 @@ void EditorSettings::get_shortcut_list(List<String> *r_shortcuts) {
Ref<ShortCut> ED_GET_SHORTCUT(const String &p_path) {
+ if (!EditorSettings::get_singleton()) {
+ return NULL;
+ }
+
Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(p_path);
if (!sc.is_valid()) {
ERR_EXPLAIN("Used ED_GET_SHORTCUT with invalid shortcut: " + p_path);
@@ -1508,6 +1512,15 @@ Ref<ShortCut> ED_SHORTCUT(const String &p_path, const String &p_name, uint32_t p
ie->set_metakey(bool(p_keycode & KEY_MASK_META));
}
+ if (!EditorSettings::get_singleton()) {
+ Ref<ShortCut> sc;
+ sc.instance();
+ sc->set_name(p_name);
+ sc->set_shortcut(ie);
+ sc->set_meta("original", ie);
+ return sc;
+ }
+
Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(p_path);
if (sc.is_valid()) {
diff --git a/editor/editor_spin_slider.h b/editor/editor_spin_slider.h
index 1523c20f48..d91380e175 100644
--- a/editor/editor_spin_slider.h
+++ b/editor/editor_spin_slider.h
@@ -102,6 +102,9 @@ public:
void set_custom_label_color(bool p_use_custom_label_color, Color p_custom_label_color);
+ void setup_and_show() { _focus_entered(); }
+ LineEdit *get_line_edit() { return value_input; }
+
virtual Size2 get_minimum_size() const;
EditorSpinSlider();
};
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index 069d9d25ee..35cfdf15be 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -974,6 +974,7 @@ void TileSetEditor::_on_workspace_draw() {
workspace->draw_rect(region, c, false);
}
}
+ delete tiles;
if (edit_mode == EDITMODE_REGION) {
if (workspace_mode != WORKSPACE_EDIT) {
@@ -1068,6 +1069,7 @@ void TileSetEditor::_on_workspace_overlay_draw() {
c = Color(0.1, 0.1, 0.1);
workspace_overlay->draw_string(font, region.position, tile_id_name, c);
}
+ delete tiles;
}
int t_id = get_current_tile();
@@ -1115,10 +1117,12 @@ void TileSetEditor::_on_workspace_input(const Ref<InputEvent> &p_ie) {
set_current_tile(t_id);
workspace->update();
workspace_overlay->update();
+ delete tiles;
return;
}
}
}
+ delete tiles;
}
}
@@ -3118,6 +3122,7 @@ void TileSetEditor::update_workspace_minsize() {
workspace_min_size.y = region.position.y + region.size.y;
}
}
+ delete tiles;
workspace->set_custom_minimum_size(workspace_min_size + WORKSPACE_MARGIN * 2);
workspace_container->set_custom_minimum_size(workspace_min_size + WORKSPACE_MARGIN * 2);
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index b4200d5662..e1929d7489 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -2049,23 +2049,23 @@ VisualShaderEditor::VisualShaderEditor() {
// INPUT
// SPATIAL-FOR-ALL
-
- add_options.push_back(AddOption("Camera", "Input", "All", "VisualShaderNodeInput", TTR("'camera' input parameter for all shader modes."), "camera", VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("InvCamera", "Input", "All", "VisualShaderNodeInput", TTR("'inv_camera' input parameter for all shader modes."), "inv_camera", VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("InvProjection", "Input", "All", "VisualShaderNodeInput", TTR("'inv_projection' input parameter for all shader modes."), "inv_projection", VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Normal", "Input", "All", "VisualShaderNodeInput", TTR("'normal' input parameter for all shader modes."), "normal", VisualShaderNode::PORT_TYPE_VECTOR, -1, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Projection", "Input", "All", "VisualShaderNodeInput", TTR("'projection' input parameter for all shader modes."), "projection", VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Time", "Input", "All", "VisualShaderNodeInput", TTR("'time' input parameter for all shader modes."), "time", VisualShaderNode::PORT_TYPE_SCALAR, -1, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("ViewportSize", "Input", "All", "VisualShaderNodeInput", TTR("'viewport_size' input parameter for all shader modes."), "viewport_size", VisualShaderNode::PORT_TYPE_VECTOR, -1, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("World", "Input", "All", "VisualShaderNodeInput", TTR("'world' input parameter for all shader modes."), "world", VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL));
+ const String input_param_shader_modes = "'%s' input parameter for all shader modes.";
+ add_options.push_back(AddOption("Camera", "Input", "All", "VisualShaderNodeInput", vformat(TTR(input_param_shader_modes), "camera"), "camera", VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("InvCamera", "Input", "All", "VisualShaderNodeInput", vformat(TTR(input_param_shader_modes), "inv_camera"), "inv_camera", VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("InvProjection", "Input", "All", "VisualShaderNodeInput", vformat(TTR(input_param_shader_modes), "inv_projection"), "inv_projection", VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Normal", "Input", "All", "VisualShaderNodeInput", vformat(TTR(input_param_shader_modes), "normal"), "normal", VisualShaderNode::PORT_TYPE_VECTOR, -1, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Projection", "Input", "All", "VisualShaderNodeInput", vformat(TTR(input_param_shader_modes), "camera"), "projection", VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Time", "Input", "All", "VisualShaderNodeInput", vformat(TTR(input_param_shader_modes), "time"), "time", VisualShaderNode::PORT_TYPE_SCALAR, -1, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("ViewportSize", "Input", "All", "VisualShaderNodeInput", vformat(TTR(input_param_shader_modes), "viewport_size"), "viewport_size", VisualShaderNode::PORT_TYPE_VECTOR, -1, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("World", "Input", "All", "VisualShaderNodeInput", vformat(TTR(input_param_shader_modes), "world"), "world", VisualShaderNode::PORT_TYPE_TRANSFORM, -1, Shader::MODE_SPATIAL));
// CANVASITEM-FOR-ALL
- add_options.push_back(AddOption("Alpha", "Input", "All", "VisualShaderNodeInput", TTR("'alpha' input parameter for all shader modes."), "alpha", VisualShaderNode::PORT_TYPE_SCALAR, -1, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("Color", "Input", "All", "VisualShaderNodeInput", TTR("'color' input parameter for all shader modes."), "color", VisualShaderNode::PORT_TYPE_VECTOR, -1, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("TexturePixelSize", "Input", "All", "VisualShaderNodeInput", TTR("'texture_pixel_size' input parameter for all shader modes."), "texture_pixel_size", VisualShaderNode::PORT_TYPE_VECTOR, -1, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("Time", "Input", "All", "VisualShaderNodeInput", TTR("'time' input parameter for all shader modes."), "time", VisualShaderNode::PORT_TYPE_SCALAR, -1, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("UV", "Input", "All", "VisualShaderNodeInput", TTR("'uv' input parameter for all shader modes."), "uv", VisualShaderNode::PORT_TYPE_VECTOR, -1, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("Alpha", "Input", "All", "VisualShaderNodeInput", vformat(TTR(input_param_shader_modes), "alpha"), "alpha", VisualShaderNode::PORT_TYPE_SCALAR, -1, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("Color", "Input", "All", "VisualShaderNodeInput", vformat(TTR(input_param_shader_modes), "color"), "color", VisualShaderNode::PORT_TYPE_VECTOR, -1, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("TexturePixelSize", "Input", "All", "VisualShaderNodeInput", vformat(TTR(input_param_shader_modes), "texture_pixel_size"), "texture_pixel_size", VisualShaderNode::PORT_TYPE_VECTOR, -1, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("Time", "Input", "All", "VisualShaderNodeInput", vformat(TTR(input_param_shader_modes), "time"), "time", VisualShaderNode::PORT_TYPE_SCALAR, -1, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("UV", "Input", "All", "VisualShaderNodeInput", vformat(TTR(input_param_shader_modes), "uv"), "uv", VisualShaderNode::PORT_TYPE_VECTOR, -1, Shader::MODE_CANVAS_ITEM));
/////////////////
@@ -2073,81 +2073,88 @@ VisualShaderEditor::VisualShaderEditor() {
// SPATIAL INPUTS
- add_options.push_back(AddOption("Alpha", "Input", "Fragment", "VisualShaderNodeInput", TTR("'alpha' input parameter for vertex and fragment shader modes."), "alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Binormal", "Input", "Fragment", "VisualShaderNodeInput", TTR("'binormal' input parameter for vertex and fragment shader modes."), "binormal", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Color", "Input", "Fragment", "VisualShaderNodeInput", TTR("'color' input parameter for vertex and fragment shader modes."), "color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("FragCoord", "Input", "Fragment", "VisualShaderNodeInput", TTR("'fragcoord' input parameter for fragment and light shader modes."), "fragcoord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("PointCoord", "Input", "Fragment", "VisualShaderNodeInput", TTR("'point_coord' input parameter for fragment shader mode."), "point_coord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("ScreenUV", "Input", "Fragment", "VisualShaderNodeInput", TTR("'screen_uv' input parameter for fragment shader mode."), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Side", "Input", "Fragment", "VisualShaderNodeInput", TTR("'side' input parameter for fragment shader mode."), "side", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Tangent", "Input", "Fragment", "VisualShaderNodeInput", TTR("'tangent' input parameter for vertex and fragment shader modes."), "tangent", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("UV", "Input", "Fragment", "VisualShaderNodeInput", TTR("'uv' input parameter for vertex and fragment shader modes."), "uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("UV2", "Input", "Fragment", "VisualShaderNodeInput", TTR("'uv2' input parameter for vertex and fragment shader modes."), "uv2", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Vertex", "Input", "Fragment", "VisualShaderNodeInput", TTR("'vertex' input parameter for vertex and fragment shader modes."), "vertex", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("View", "Input", "Fragment", "VisualShaderNodeInput", TTR("'view' input parameter for fragment and light shader modes."), "view", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
-
- add_options.push_back(AddOption("Albedo", "Input", "Light", "VisualShaderNodeInput", TTR("'albedo' input parameter for light shader mode."), "albedo", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Attenuation", "Input", "Light", "VisualShaderNodeInput", TTR("'attenuation' input parameter for light shader mode."), "attenuation", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Diffuse", "Input", "Light", "VisualShaderNodeInput", TTR("'diffuse' input parameter for light shader mode."), "diffuse", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("FragCoord", "Input", "Light", "VisualShaderNodeInput", TTR("'fragcoord' input parameter for fragment and light shader modes."), "fragcoord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Light", "Input", "Light", "VisualShaderNodeInput", TTR("'light' input parameter for light shader mode."), "light", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("LightColor", "Input", "Light", "VisualShaderNodeInput", TTR("'light_color' input parameter for light shader mode."), "light_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Roughness", "Input", "Light", "VisualShaderNodeInput", TTR("'roughness' input parameter for light shader mode."), "roughness", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Specular", "Input", "Light", "VisualShaderNodeInput", TTR("'specular' input parameter for light shader mode."), "specular", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Transmission", "Input", "Light", "VisualShaderNodeInput", TTR("'transmission' input parameter for light shader mode."), "transmission", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("View", "Input", "Light", "VisualShaderNodeInput", TTR("'view' input parameter for fragment and light shader modes."), "view", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
-
- add_options.push_back(AddOption("Alpha", "Input", "Vertex", "VisualShaderNodeInput", TTR("'alpha' input parameter for vertex and fragment shader modes."), "alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Binormal", "Input", "Vertex", "VisualShaderNodeInput", TTR("'binormal' input parameter for vertex and fragment shader modes."), "binormal", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Color", "Input", "Vertex", "VisualShaderNodeInput", TTR("'color' input parameter for vertex and fragment shader modes."), "color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("ModelView", "Input", "Vertex", "VisualShaderNodeInput", TTR("'modelview' input parameter for vertex shader mode."), "modelview", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("PointSize", "Input", "Vertex", "VisualShaderNodeInput", TTR("'point_size' input parameter for vertex shader mode."), "point_size", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Tangent", "Input", "Vertex", "VisualShaderNodeInput", TTR("'tangent' input parameter for vertex and fragment shader mode."), "tangent", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("UV", "Input", "Vertex", "VisualShaderNodeInput", TTR("'uv' input parameter for vertex and fragment shader modes."), "uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("UV2", "Input", "Vertex", "VisualShaderNodeInput", TTR("'uv2' input parameter for vertex and fragment shader modes."), "uv2", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("Vertex", "Input", "Vertex", "VisualShaderNodeInput", TTR("'vertex' input parameter for vertex and fragment shader modes."), "vertex", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
+ const String input_param_for_vertex_and_fragment_shader_modes = "'%s' input parameter for vertex and fragment shader modes.";
+ const String input_param_for_fragment_and_light_shader_modes = "'%s' input parameter for fragment and light shader modes.";
+ const String input_param_for_fragment_shader_mode = "'%s' input parameter for fragment shader mode.";
+ const String input_param_for_light_shader_mode = "'%s' input parameter for light shader mode.";
+ const String input_param_for_vertex_shader_mode = "'%s' input parameter for vertex shader mode.";
+ const String input_param_for_vertex_and_fragment_shader_mode = "'%s' input parameter for vertex and fragment shader mode.";
+
+ add_options.push_back(AddOption("Alpha", "Input", "Fragment", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_and_fragment_shader_modes), "alpha"), "alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Binormal", "Input", "Fragment", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_and_fragment_shader_modes), "binormal"), "binormal", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Color", "Input", "Fragment", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_and_fragment_shader_modes), "color"), "color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("FragCoord", "Input", "Fragment", "VisualShaderNodeInput", vformat(TTR(input_param_for_fragment_and_light_shader_modes), "fragcoord"), "fragcoord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("PointCoord", "Input", "Fragment", "VisualShaderNodeInput", vformat(TTR(input_param_for_fragment_shader_mode), "point_coord"), "point_coord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("ScreenUV", "Input", "Fragment", "VisualShaderNodeInput", vformat(TTR(input_param_for_fragment_shader_mode), "screen_uv"), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Side", "Input", "Fragment", "VisualShaderNodeInput", vformat(TTR(input_param_for_fragment_shader_mode), "side"), "side", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Tangent", "Input", "Fragment", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_and_fragment_shader_modes), "tangent"), "tangent", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("UV", "Input", "Fragment", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_and_fragment_shader_modes), "uv"), "uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("UV2", "Input", "Fragment", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_and_fragment_shader_modes), "uv2"), "uv2", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Vertex", "Input", "Fragment", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_and_fragment_shader_modes), "vertex"), "vertex", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("View", "Input", "Fragment", "VisualShaderNodeInput", vformat(TTR(input_param_for_fragment_and_light_shader_modes), "view"), "view", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_SPATIAL));
+
+ add_options.push_back(AddOption("Albedo", "Input", "Light", "VisualShaderNodeInput", vformat(TTR(input_param_for_light_shader_mode), "albedo"), "albedo", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Attenuation", "Input", "Light", "VisualShaderNodeInput", vformat(TTR(input_param_for_light_shader_mode), "attenuation"), "attenuation", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Diffuse", "Input", "Light", "VisualShaderNodeInput", vformat(TTR(input_param_for_light_shader_mode), "diffuse"), "diffuse", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("FragCoord", "Input", "Light", "VisualShaderNodeInput", vformat(TTR(input_param_for_fragment_and_light_shader_modes), "fragcoord"), "fragcoord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Light", "Input", "Light", "VisualShaderNodeInput", vformat(TTR(input_param_for_light_shader_mode), "light"), "light", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("LightColor", "Input", "Light", "VisualShaderNodeInput", vformat(TTR(input_param_for_light_shader_mode), "light_color"), "light_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Roughness", "Input", "Light", "VisualShaderNodeInput", vformat(TTR(input_param_for_light_shader_mode), "roughness"), "roughness", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Specular", "Input", "Light", "VisualShaderNodeInput", vformat(TTR(input_param_for_light_shader_mode), "specular"), "specular", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Transmission", "Input", "Light", "VisualShaderNodeInput", vformat(TTR(input_param_for_light_shader_mode), "transmission"), "transmission", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("View", "Input", "Light", "VisualShaderNodeInput", vformat(TTR(input_param_for_fragment_and_light_shader_modes), "view"), "view", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_SPATIAL));
+
+ add_options.push_back(AddOption("Alpha", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_and_fragment_shader_modes), "alpha"), "alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Binormal", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_and_fragment_shader_modes), "binormal"), "binormal", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Color", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_and_fragment_shader_modes), "color"), "color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("ModelView", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_shader_mode), "modelview"), "modelview", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("PointSize", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_shader_mode), "point_size"), "point_size", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Tangent", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_and_fragment_shader_mode), "tangent"), "tangent", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("UV", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_and_fragment_shader_modes), "uv"), "uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("UV2", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_and_fragment_shader_modes), "uv2"), "uv2", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("Vertex", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_and_fragment_shader_modes), "vertex"), "vertex", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_SPATIAL));
// CANVASITEM INPUTS
- add_options.push_back(AddOption("FragCoord", "Input", "Fragment", "VisualShaderNodeInput", TTR("'fragcoord' input parameter for fragment and light shader modes."), "fragcoord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("LightPass", "Input", "Fragment", "VisualShaderNodeInput", TTR("'light_pass' input parameter for vertex and fragment shader modes."), "light_pass", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("PointCoord", "Input", "Fragment", "VisualShaderNodeInput", TTR("'point_coord' input parameter for fragment and light shader modes."), "point_coord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("ScreenPixelSize", "Input", "Fragment", "VisualShaderNodeInput", TTR("'screen_pixel_size' input parameter for fragment shader mode."), "screen_pixel_size", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("ScreenUV", "Input", "Fragment", "VisualShaderNodeInput", TTR("'screen_uv' input parameter for fragment and light shader modes."), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_CANVAS_ITEM));
-
- add_options.push_back(AddOption("FragCoord", "Input", "Light", "VisualShaderNodeInput", TTR("'fragcoord' input parameter for fragment and light shader modes."), "fragcoord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("LightAlpha", "Input", "Light", "VisualShaderNodeInput", TTR("'light_alpha' input parameter for light shader mode."), "light_alpha", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("LightColor", "Input", "Light", "VisualShaderNodeInput", TTR("'light_color' input parameter for light shader mode."), "light_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("LightHeight", "Input", "Light", "VisualShaderNodeInput", TTR("'light_height' input parameter for light shader mode."), "light_height", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("LightUV", "Input", "Light", "VisualShaderNodeInput", TTR("'light_uv' input parameter for light shader mode."), "light_uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("LightVector", "Input", "Light", "VisualShaderNodeInput", TTR("'light_vec' input parameter for light shader mode."), "light_vec", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("Normal", "Input", "Light", "VisualShaderNodeInput", TTR("'normal' input parameter for light shader mode."), "normal", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("PointCoord", "Input", "Light", "VisualShaderNodeInput", TTR("'point_coord' input parameter for fragment and light shader modes."), "point_coord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("ScreenUV", "Input", "Light", "VisualShaderNodeInput", TTR("'screen_uv' input parameter for fragment and light shader modes."), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("ShadowColor", "Input", "Light", "VisualShaderNodeInput", TTR("'shadow_color' input parameter for light shader mode."), "shadow_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
-
- add_options.push_back(AddOption("Extra", "Input", "Vertex", "VisualShaderNodeInput", TTR("'extra' input parameter for vertex shader mode."), "extra", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("LightPass", "Input", "Vertex", "VisualShaderNodeInput", TTR("'light_pass' input parameter for vertex and fragment shader modes."), "light_pass", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("PointSize", "Input", "Vertex", "VisualShaderNodeInput", TTR("'point_size' input parameter for vertex shader mode."), "point_size", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("Projection", "Input", "Vertex", "VisualShaderNodeInput", TTR("'projection' input parameter for vertex shader mode."), "projection", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("Vertex", "Input", "Vertex", "VisualShaderNodeInput", TTR("'vertex' input parameter for vertex shader mode."), "vertex", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_CANVAS_ITEM));
- add_options.push_back(AddOption("World", "Input", "Vertex", "VisualShaderNodeInput", TTR("'world' input parameter for vertex shader mode."), "world", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("FragCoord", "Input", "Fragment", "VisualShaderNodeInput", vformat(TTR(input_param_for_fragment_and_light_shader_modes), "fragcoord"), "fragcoord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("LightPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_and_fragment_shader_modes), "light_pass"), "light_pass", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_FRAGMENT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("PointCoord", "Input", "Fragment", "VisualShaderNodeInput", vformat(TTR(input_param_for_fragment_and_light_shader_modes), "point_coord"), "point_coord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("ScreenPixelSize", "Input", "Fragment", "VisualShaderNodeInput", vformat(TTR(input_param_for_fragment_shader_mode), "screen_pixel_size"), "screen_pixel_size", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("ScreenUV", "Input", "Fragment", "VisualShaderNodeInput", vformat(TTR(input_param_for_fragment_and_light_shader_modes), "screen_uv"), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_FRAGMENT, Shader::MODE_CANVAS_ITEM));
+
+ add_options.push_back(AddOption("FragCoord", "Input", "Light", "VisualShaderNodeInput", vformat(TTR(input_param_for_fragment_and_light_shader_modes), "fragcoord"), "fragcoord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("LightAlpha", "Input", "Light", "VisualShaderNodeInput", vformat(TTR(input_param_for_light_shader_mode), "light_alpha"), "light_alpha", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("LightColor", "Input", "Light", "VisualShaderNodeInput", vformat(TTR(input_param_for_light_shader_mode), "light_color"), "light_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("LightHeight", "Input", "Light", "VisualShaderNodeInput", vformat(TTR(input_param_for_light_shader_mode), "light_height"), "light_height", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("LightUV", "Input", "Light", "VisualShaderNodeInput", vformat(TTR(input_param_for_light_shader_mode), "light_uv"), "light_uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("LightVector", "Input", "Light", "VisualShaderNodeInput", vformat(TTR(input_param_for_light_shader_mode), "light_vec"), "light_vec", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("Normal", "Input", "Light", "VisualShaderNodeInput", vformat(TTR(input_param_for_light_shader_mode), "normal"), "normal", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("PointCoord", "Input", "Light", "VisualShaderNodeInput", vformat(TTR(input_param_for_fragment_and_light_shader_modes), "point_coord"), "point_coord", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("ScreenUV", "Input", "Light", "VisualShaderNodeInput", vformat(TTR(input_param_for_fragment_and_light_shader_modes), "screen_uv"), "screen_uv", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("ShadowColor", "Input", "Light", "VisualShaderNodeInput", vformat(TTR(input_param_for_light_shader_mode), "shadow_color"), "shadow_color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_LIGHT, Shader::MODE_CANVAS_ITEM));
+
+ add_options.push_back(AddOption("Extra", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_shader_mode), "extra"), "extra", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("LightPass", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_and_fragment_shader_modes), "light_pass"), "light_pass", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("PointSize", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_shader_mode), "point_size"), "point_size", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("Projection", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_shader_mode), "projection"), "projection", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("Vertex", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_shader_mode), "vertex"), "vertex", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("World", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_shader_mode), "world"), "world", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_CANVAS_ITEM));
// PARTICLES INPUTS
- add_options.push_back(AddOption("Active", "Input", "Vertex", "VisualShaderNodeInput", TTR("'active' input parameter for vertex shader mode."), "active", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
- add_options.push_back(AddOption("Alpha", "Input", "Vertex", "VisualShaderNodeInput", TTR("'alpha' input parameter for vertex shader mode."), "alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
- add_options.push_back(AddOption("Color", "Input", "Vertex", "VisualShaderNodeInput", TTR("'color' input parameter for vertex shader mode."), "color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
- add_options.push_back(AddOption("Custom", "Input", "Vertex", "VisualShaderNodeInput", TTR("'custom' input parameter for vertex shader mode."), "custom", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
- add_options.push_back(AddOption("CustomAlpha", "Input", "Vertex", "VisualShaderNodeInput", TTR("'custom_alpha' input parameter for vertex shader mode."), "custom_alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
- add_options.push_back(AddOption("Delta", "Input", "Vertex", "VisualShaderNodeInput", TTR("'delta' input parameter for vertex shader mode."), "delta", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
- add_options.push_back(AddOption("EmissionTransform", "Input", "Vertex", "VisualShaderNodeInput", TTR("'emission_transform' input parameter for vertex shader mode."), "emission_transform", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
- add_options.push_back(AddOption("Index", "Input", "Vertex", "VisualShaderNodeInput", TTR("'index' input parameter for vertex shader mode."), "index", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
- add_options.push_back(AddOption("LifeTime", "Input", "Vertex", "VisualShaderNodeInput", TTR("'lifetime' input parameter for vertex shader mode."), "lifetime", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
- add_options.push_back(AddOption("Restart", "Input", "Vertex", "VisualShaderNodeInput", TTR("'restart' input parameter for vertex shader mode."), "restart", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
- add_options.push_back(AddOption("Time", "Input", "Vertex", "VisualShaderNodeInput", TTR("'time' input parameter for vertex shader mode."), "time", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
- add_options.push_back(AddOption("Transform", "Input", "Vertex", "VisualShaderNodeInput", TTR("'transform' input parameter for vertex shader mode."), "transform", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
- add_options.push_back(AddOption("Velocity", "Input", "Vertex", "VisualShaderNodeInput", TTR("'velocity' input parameter for vertex shader mode."), "velocity", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Active", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_shader_mode), "active"), "active", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Alpha", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_shader_mode), "alpha"), "alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Color", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_shader_mode), "color"), "color", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Custom", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_shader_mode), "custom"), "custom", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("CustomAlpha", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_shader_mode), "custom_alpha"), "custom_alpha", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Delta", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_shader_mode), "delta"), "delta", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("EmissionTransform", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_shader_mode), "emission_transform"), "emission_transform", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Index", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_shader_mode), "index"), "index", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("LifeTime", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_shader_mode), "lifetime"), "lifetime", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Restart", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_shader_mode), "restart"), "restart", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Time", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_shader_mode), "time"), "time", VisualShaderNode::PORT_TYPE_SCALAR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Transform", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_shader_mode), "transform"), "transform", VisualShaderNode::PORT_TYPE_TRANSFORM, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
+ add_options.push_back(AddOption("Velocity", "Input", "Vertex", "VisualShaderNodeInput", vformat(TTR(input_param_for_vertex_shader_mode), "velocity"), "velocity", VisualShaderNode::PORT_TYPE_VECTOR, VisualShader::TYPE_VERTEX, Shader::MODE_PARTICLES));
// SCALAR
@@ -2764,3 +2771,30 @@ void VisualShaderNodePortPreview::_bind_methods() {
VisualShaderNodePortPreview::VisualShaderNodePortPreview() {
}
+
+//////////////////////////////////
+
+String VisualShaderConversionPlugin::converts_to() const {
+
+ return "Shader";
+}
+
+bool VisualShaderConversionPlugin::handles(const Ref<Resource> &p_resource) const {
+
+ Ref<VisualShader> vshader = p_resource;
+ return vshader.is_valid();
+}
+
+Ref<Resource> VisualShaderConversionPlugin::convert(const Ref<Resource> &p_resource) const {
+
+ Ref<VisualShader> vshader = p_resource;
+ ERR_FAIL_COND_V(!vshader.is_valid(), Ref<Resource>());
+
+ Ref<Shader> shader;
+ shader.instance();
+
+ String code = vshader->get_code();
+ shader->set_code(code);
+
+ return shader;
+}
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index 49a7a21ea7..fa72b5ec29 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -302,4 +302,13 @@ public:
VisualShaderNodePortPreview();
};
+class VisualShaderConversionPlugin : public EditorResourceConversionPlugin {
+ GDCLASS(VisualShaderConversionPlugin, EditorResourceConversionPlugin);
+
+public:
+ virtual String converts_to() const;
+ virtual bool handles(const Ref<Resource> &p_resource) const;
+ virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const;
+};
+
#endif // VISUAL_SHADER_EDITOR_PLUGIN_H
diff --git a/editor/translations/extract.py b/editor/translations/extract.py
index 70eb15da62..07b34f7562 100755
--- a/editor/translations/extract.py
+++ b/editor/translations/extract.py
@@ -116,7 +116,7 @@ shutil.move("editor.pot", "editor/translations/editor.pot")
# TODO: Make that in a portable way, if we care; if not, kudos to Unix users
if (os.name == "posix"):
- added = subprocess.check_output("git diff editor/translations/editor.pot | grep \+msgid | wc -l", shell=True)
- removed = subprocess.check_output("git diff editor/translations/editor.pot | grep \\\-msgid | wc -l", shell=True)
+ added = subprocess.check_output(r"git diff editor/translations/editor.pot | grep \+msgid | wc -l", shell=True)
+ removed = subprocess.check_output(r"git diff editor/translations/editor.pot | grep \\\-msgid | wc -l", shell=True)
print("\n# Template changes compared to the staged status:")
print("# Additions: %s msgids.\n# Deletions: %s msgids." % (int(added), int(removed)))
diff --git a/main/main.cpp b/main/main.cpp
index 9183dab58c..815e940a0a 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -599,6 +599,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
auto_build_solutions = true;
editor = true;
+ } else if (I->get() == "--export" || I->get() == "--export-debug") { // Export project
+
+ editor = true;
+ main_args.push_back(I->get());
#endif
} else if (I->get() == "--path") { // set path of project to start or edit
@@ -1343,20 +1347,10 @@ bool Main::start() {
removal_docs.push_back(args[j]);
} else if (args[i] == "--export") {
editor = true; //needs editor
- if (i + 1 < args.size()) {
- _export_preset = args[i + 1];
- } else {
- ERR_PRINT("Export preset name not specified");
- return false;
- }
+ _export_preset = args[i + 1];
} else if (args[i] == "--export-debug") {
editor = true; //needs editor
- if (i + 1 < args.size()) {
- _export_preset = args[i + 1];
- } else {
- ERR_PRINT("Export preset name not specified");
- return false;
- }
+ _export_preset = args[i + 1];
export_debug = true;
#endif
} else {
@@ -1375,6 +1369,8 @@ bool Main::start() {
#ifdef TOOLS_ENABLED
if (doc_tool != "") {
+ Engine::get_singleton()->set_editor_hint(true); // Needed to instance editor-only classes for their default values
+
{
DirAccessRef da = DirAccess::open(doc_tool);
if (!da) {
diff --git a/methods.py b/methods.py
index af20619416..3ed44329a7 100644
--- a/methods.py
+++ b/methods.py
@@ -181,7 +181,7 @@ def win32_spawn(sh, escape, cmd, args, env):
env[e] = str(env[e])
proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, startupinfo=startupinfo, shell=False, env=env)
- data, err = proc.communicate()
+ _, err = proc.communicate()
rv = proc.wait()
if rv:
print("=====")
@@ -242,7 +242,7 @@ def use_windows_spawn_fix(self, platform=None):
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, startupinfo=startupinfo, shell=False, env=env)
- data, err = proc.communicate()
+ _, err = proc.communicate()
rv = proc.wait()
if rv:
print("=====")
@@ -487,7 +487,7 @@ def find_visual_c_batch_file(env):
from SCons.Tool.MSCommon.vc import get_default_version, get_host_target, find_batch_file
version = get_default_version(env)
- (host_platform, target_platform,req_target_platform) = get_host_target(env)
+ (host_platform, target_platform, _) = get_host_target(env)
return find_batch_file(env, version, host_platform, target_platform)[0]
def generate_cpp_hint_file(filename):
@@ -598,7 +598,7 @@ def detect_darwin_sdk_path(platform, env):
sdk_path = decode_utf8(subprocess.check_output(['xcrun', '--sdk', sdk_name, '--show-sdk-path']).strip())
if sdk_path:
env[var_name] = sdk_path
- except (subprocess.CalledProcessError, OSError) as e:
+ except (subprocess.CalledProcessError, OSError):
print("Failed to find SDK path while running xcrun --sdk {} --show-sdk-path.".format(sdk_name))
raise
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp
index dcb4b7fd75..a5a356ced2 100644
--- a/modules/enet/networked_multiplayer_enet.cpp
+++ b/modules/enet/networked_multiplayer_enet.cpp
@@ -882,7 +882,9 @@ NetworkedMultiplayerENet::NetworkedMultiplayerENet() {
NetworkedMultiplayerENet::~NetworkedMultiplayerENet() {
- close_connection();
+ if (active) {
+ close_connection();
+ }
}
// Sets IP for ENet to bind when using create_server or create_client
diff --git a/modules/gdnative/arvr/arvr_interface_gdnative.cpp b/modules/gdnative/arvr/arvr_interface_gdnative.cpp
index da01f573ce..64e2c362b2 100644
--- a/modules/gdnative/arvr/arvr_interface_gdnative.cpp
+++ b/modules/gdnative/arvr/arvr_interface_gdnative.cpp
@@ -33,9 +33,13 @@
#include "servers/arvr/arvr_positional_tracker.h"
#include "servers/visual/visual_server_globals.h"
+void ARVRInterfaceGDNative::_bind_methods() {
+ ADD_PROPERTY_DEFAULT("interface_is_initialized", false);
+ ADD_PROPERTY_DEFAULT("ar_is_anchor_detection_enabled", false);
+}
+
ARVRInterfaceGDNative::ARVRInterfaceGDNative() {
- // testing
- printf("Construct gdnative interface\n");
+ print_verbose("Construct gdnative interface\n");
// we won't have our data pointer until our library gets set
data = NULL;
@@ -44,9 +48,9 @@ ARVRInterfaceGDNative::ARVRInterfaceGDNative() {
}
ARVRInterfaceGDNative::~ARVRInterfaceGDNative() {
- printf("Destruct gdnative interface\n");
+ print_verbose("Destruct gdnative interface\n");
- if (is_initialized()) {
+ if (interface != NULL && is_initialized()) {
uninitialize();
};
@@ -99,13 +103,10 @@ int ARVRInterfaceGDNative::get_capabilities() const {
}
bool ARVRInterfaceGDNative::get_anchor_detection_is_enabled() const {
- bool enabled;
ERR_FAIL_COND_V(interface == NULL, false);
- enabled = interface->get_anchor_detection_is_enabled(data);
-
- return enabled;
+ return interface->get_anchor_detection_is_enabled(data);
}
void ARVRInterfaceGDNative::set_anchor_detection_is_enabled(bool p_enable) {
@@ -137,21 +138,16 @@ bool ARVRInterfaceGDNative::is_stereo() {
}
bool ARVRInterfaceGDNative::is_initialized() const {
- bool initialized;
ERR_FAIL_COND_V(interface == NULL, false);
- initialized = interface->is_initialized(data);
-
- return initialized;
+ return interface->is_initialized(data);
}
bool ARVRInterfaceGDNative::initialize() {
- bool initialized;
-
ERR_FAIL_COND_V(interface == NULL, false);
- initialized = interface->initialize(data);
+ bool initialized = interface->initialize(data);
if (initialized) {
// if we successfully initialize our interface and we don't have a primary interface yet, this becomes our primary interface
diff --git a/modules/gdnative/arvr/arvr_interface_gdnative.h b/modules/gdnative/arvr/arvr_interface_gdnative.h
index 651e5c8715..ab7090876a 100644
--- a/modules/gdnative/arvr/arvr_interface_gdnative.h
+++ b/modules/gdnative/arvr/arvr_interface_gdnative.h
@@ -49,6 +49,8 @@ protected:
const godot_arvr_interface_gdnative *interface;
void *data;
+ static void _bind_methods();
+
public:
/** general interface information **/
ARVRInterfaceGDNative();
diff --git a/modules/gdnative/gdnative/array.cpp b/modules/gdnative/gdnative/array.cpp
index 6849ff03d7..1ef8e9f900 100644
--- a/modules/gdnative/gdnative/array.cpp
+++ b/modules/gdnative/gdnative/array.cpp
@@ -305,13 +305,13 @@ void GDAPI godot_array_sort_custom(godot_array *p_self, godot_object *p_obj, con
godot_int GDAPI godot_array_bsearch(godot_array *p_self, const godot_variant *p_value, const godot_bool p_before) {
Array *self = (Array *)p_self;
- return self->bsearch((const Variant *)p_value, p_before);
+ return self->bsearch(*(const Variant *)p_value, p_before);
}
godot_int GDAPI godot_array_bsearch_custom(godot_array *p_self, const godot_variant *p_value, godot_object *p_obj, const godot_string *p_func, const godot_bool p_before) {
Array *self = (Array *)p_self;
const String *func = (const String *)p_func;
- return self->bsearch_custom((const Variant *)p_value, (Object *)p_obj, *func, p_before);
+ return self->bsearch_custom(*(const Variant *)p_value, (Object *)p_obj, *func, p_before);
}
void GDAPI godot_array_destroy(godot_array *p_self) {
diff --git a/modules/gdnative/net/multiplayer_peer_gdnative.cpp b/modules/gdnative/net/multiplayer_peer_gdnative.cpp
index bdeba149d2..d2c95efa77 100644
--- a/modules/gdnative/net/multiplayer_peer_gdnative.cpp
+++ b/modules/gdnative/net/multiplayer_peer_gdnative.cpp
@@ -113,6 +113,8 @@ NetworkedMultiplayerPeer::ConnectionStatus MultiplayerPeerGDNative::get_connecti
}
void MultiplayerPeerGDNative::_bind_methods() {
+ ADD_PROPERTY_DEFAULT("transfer_mode", TRANSFER_MODE_UNRELIABLE);
+ ADD_PROPERTY_DEFAULT("refuse_new_connections", true);
}
extern "C" {
diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp
index 7cb47ec623..4bbadc62e7 100644
--- a/modules/gdnative/pluginscript/pluginscript_language.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_language.cpp
@@ -216,7 +216,7 @@ void PluginScriptLanguage::get_public_constants(List<Pair<String, Variant> > *p_
Dictionary constants;
_desc.get_public_constants(_data, (godot_dictionary *)&constants);
for (const Variant *key = constants.next(); key; key = constants.next(key)) {
- Variant value = constants[key];
+ Variant value = constants[*key];
p_constants->push_back(Pair<String, Variant>(*key, value));
}
}
diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp
index 1d6f9db349..3ecb29404a 100644
--- a/modules/gdnative/pluginscript/pluginscript_script.cpp
+++ b/modules/gdnative/pluginscript/pluginscript_script.cpp
@@ -229,6 +229,8 @@ void PluginScript::set_source_code(const String &p_code) {
}
Error PluginScript::reload(bool p_keep_state) {
+ ERR_FAIL_COND_V(!_language, ERR_UNCONFIGURED);
+
_language->lock();
ERR_FAIL_COND_V(!p_keep_state && _instances.size(), ERR_ALREADY_IN_USE);
_language->unlock();
@@ -284,7 +286,7 @@ Error PluginScript::reload(bool p_keep_state) {
Dictionary *members = (Dictionary *)&manifest.member_lines;
for (const Variant *key = members->next(); key != NULL; key = members->next(key)) {
- _member_lines[*key] = (*members)[key];
+ _member_lines[*key] = (*members)[*key];
}
Array *methods = (Array *)&manifest.methods;
for (int i = 0; i < methods->size(); ++i) {
@@ -473,6 +475,8 @@ MultiplayerAPI::RPCMode PluginScript::get_rset_mode(const StringName &p_variable
PluginScript::PluginScript() :
_data(NULL),
+ _desc(NULL),
+ _language(NULL),
_tool(false),
_valid(false),
_script_list(this) {
@@ -490,11 +494,15 @@ void PluginScript::init(PluginScriptLanguage *language) {
}
PluginScript::~PluginScript() {
- _desc->finish(_data);
+ if (_desc && _data) {
+ _desc->finish(_data);
+ }
#ifdef DEBUG_ENABLED
- _language->lock();
- _language->_script_list.remove(&_script_list);
- _language->unlock();
+ if (_language) {
+ _language->lock();
+ _language->_script_list.remove(&_script_list);
+ _language->unlock();
+ }
#endif
}
diff --git a/modules/webrtc/webrtc_data_channel_gdnative.cpp b/modules/webrtc/webrtc_data_channel_gdnative.cpp
index 4f33491af2..6362634626 100644
--- a/modules/webrtc/webrtc_data_channel_gdnative.cpp
+++ b/modules/webrtc/webrtc_data_channel_gdnative.cpp
@@ -35,6 +35,7 @@
#include "modules/gdnative/nativescript/nativescript.h"
void WebRTCDataChannelGDNative::_bind_methods() {
+ ADD_PROPERTY_DEFAULT("write_mode", WRITE_MODE_BINARY);
}
WebRTCDataChannelGDNative::WebRTCDataChannelGDNative() {
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index 375375285d..36c88e395a 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -218,12 +218,13 @@ void CollisionObject2D::shape_owner_set_transform(uint32_t p_owner, const Transf
ERR_FAIL_COND(!shapes.has(p_owner));
ShapeData &sd = shapes[p_owner];
+
sd.xform = p_transform;
for (int i = 0; i < sd.shapes.size(); i++) {
if (area) {
- Physics2DServer::get_singleton()->area_set_shape_transform(rid, sd.shapes[i].index, p_transform);
+ Physics2DServer::get_singleton()->area_set_shape_transform(rid, sd.shapes[i].index, sd.xform);
} else {
- Physics2DServer::get_singleton()->body_set_shape_transform(rid, sd.shapes[i].index, p_transform);
+ Physics2DServer::get_singleton()->body_set_shape_transform(rid, sd.shapes[i].index, sd.xform);
}
}
}
@@ -387,7 +388,7 @@ String CollisionObject2D::get_configuration_warning() const {
String warning = Node2D::get_configuration_warning();
if (shapes.empty()) {
- if (warning == String()) {
+ if (!warning.empty()) {
warning += "\n";
}
warning += TTR("This node has no shape, so it can't collide or interact with other objects.\nConsider adding a CollisionShape2D or CollisionPolygon2D as a child to define its shape.");
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 2bd9e5e2a2..95acf13fad 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -1541,7 +1541,7 @@ Vector2 KinematicCollision2D::get_remainder() const {
return collision.remainder;
}
Object *KinematicCollision2D::get_local_shape() const {
- ERR_FAIL_COND_V(!owner, NULL);
+ if (!owner) return NULL;
uint32_t ownerid = owner->shape_find_owner(collision.local_shape);
return owner->shape_owner_get_owner(ownerid);
}
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index b3b6f3175d..bf59fa0ba8 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -30,9 +30,11 @@
#include "tile_map.h"
+#include "collision_object_2d.h"
#include "core/io/marshalls.h"
#include "core/method_bind_ext.gen.inc"
#include "core/os/os.h"
+#include "scene/2d/area_2d.h"
#include "servers/physics_2d_server.h"
int TileMap::_get_quadrant_size() const {
@@ -60,14 +62,21 @@ void TileMap::_notification(int p_what) {
c = Object::cast_to<Node2D>(c->get_parent());
}
+ if (use_parent) {
+ _clear_quadrants();
+ collision_parent = Object::cast_to<CollisionObject2D>(get_parent());
+ }
+
pending_update = true;
_recreate_quadrants();
update_dirty_quadrants();
RID space = get_world_2d()->get_space();
_update_quadrant_transform();
_update_quadrant_space(space);
+ update_configuration_warning();
} break;
+
case NOTIFICATION_EXIT_TREE: {
_update_quadrant_space(RID());
@@ -82,30 +91,46 @@ void TileMap::_notification(int p_what) {
q.navpoly_ids.clear();
}
+ if (collision_parent) {
+ collision_parent->remove_shape_owner(q.shape_owner_id);
+ q.shape_owner_id = -1;
+ }
+
for (Map<PosKey, Quadrant::Occluder>::Element *F = q.occluder_instances.front(); F; F = F->next()) {
VS::get_singleton()->free(F->get().id);
}
q.occluder_instances.clear();
}
+ collision_parent = NULL;
navigation = NULL;
} break;
+
case NOTIFICATION_TRANSFORM_CHANGED: {
//move stuff
_update_quadrant_transform();
} break;
+ case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
+
+ if (use_parent) {
+ _recreate_quadrants();
+ }
+
+ } break;
}
}
void TileMap::_update_quadrant_space(const RID &p_space) {
- for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
+ if (!use_parent) {
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
- Quadrant &q = E->get();
- Physics2DServer::get_singleton()->body_set_space(q.body, p_space);
+ Quadrant &q = E->get();
+ Physics2DServer::get_singleton()->body_set_space(q.body, p_space);
+ }
}
}
@@ -116,6 +141,10 @@ void TileMap::_update_quadrant_transform() {
Transform2D global_transform = get_global_transform();
+ Transform2D local_transform;
+ if (collision_parent)
+ local_transform = get_transform();
+
Transform2D nav_rel;
if (navigation)
nav_rel = get_relative_transform_to_parent(navigation);
@@ -125,8 +154,11 @@ void TileMap::_update_quadrant_transform() {
Quadrant &q = E->get();
Transform2D xform;
xform.set_origin(q.pos);
- xform = global_transform * xform;
- Physics2DServer::get_singleton()->body_set_state(q.body, Physics2DServer::BODY_STATE_TRANSFORM, xform);
+
+ if (!use_parent) {
+ xform = global_transform * xform;
+ Physics2DServer::get_singleton()->body_set_state(q.body, Physics2DServer::BODY_STATE_TRANSFORM, xform);
+ }
if (navigation) {
for (Map<PosKey, Quadrant::NavPoly>::Element *F = q.navpoly_ids.front(); F; F = F->next()) {
@@ -225,6 +257,34 @@ void TileMap::_fix_cell_transform(Transform2D &xform, const Cell &p_cell, const
xform.elements[2] += offset;
}
+void TileMap::_add_shape(int &shape_idx, const Quadrant &p_q, const Ref<Shape2D> &p_shape, const TileSet::ShapeData &p_shape_data, const Transform2D &p_xform, const Vector2 &p_metadata) {
+ Physics2DServer *ps = Physics2DServer::get_singleton();
+
+ if (!use_parent) {
+ ps->body_add_shape(p_q.body, p_shape->get_rid(), p_xform);
+ ps->body_set_shape_metadata(p_q.body, shape_idx, p_metadata);
+ ps->body_set_shape_as_one_way_collision(p_q.body, shape_idx, p_shape_data.one_way_collision, p_shape_data.one_way_collision_margin);
+
+ } else if (collision_parent) {
+ Transform2D xform = p_xform;
+ xform.set_origin(xform.get_origin() + p_q.pos);
+
+ collision_parent->shape_owner_add_shape(p_q.shape_owner_id, p_shape);
+
+ int real_index = collision_parent->shape_owner_get_shape_index(p_q.shape_owner_id, shape_idx);
+ RID rid = collision_parent->get_rid();
+
+ if (Object::cast_to<Area2D>(collision_parent) != NULL) {
+ ps->area_set_shape_transform(rid, real_index, get_transform() * xform);
+ } else {
+ ps->body_set_shape_transform(rid, real_index, get_transform() * xform);
+ ps->body_set_shape_metadata(rid, real_index, p_metadata);
+ ps->body_set_shape_as_one_way_collision(rid, real_index, p_shape_data.one_way_collision, p_shape_data.one_way_collision_margin);
+ }
+ }
+ shape_idx++;
+}
+
void TileMap::update_dirty_quadrants() {
if (!pending_update)
@@ -268,7 +328,11 @@ void TileMap::update_dirty_quadrants() {
q.canvas_items.clear();
- ps->body_clear_shapes(q.body);
+ if (!use_parent) {
+ ps->body_clear_shapes(q.body);
+ } else if (collision_parent) {
+ collision_parent->shape_owner_clear_shapes(q.shape_owner_id);
+ }
int shape_idx = 0;
if (navigation) {
@@ -427,10 +491,7 @@ void TileMap::update_dirty_quadrants() {
for (int k = 0; k < _shapes.size(); k++) {
Ref<ConvexPolygonShape2D> convex = _shapes[k];
if (convex.is_valid()) {
- ps->body_add_shape(q.body, convex->get_rid(), xform);
- ps->body_set_shape_metadata(q.body, shape_idx, Vector2(E->key().x, E->key().y));
- ps->body_set_shape_as_one_way_collision(q.body, shape_idx, shapes[j].one_way_collision, shapes[j].one_way_collision_margin);
- shape_idx++;
+ _add_shape(shape_idx, q, convex, shapes[j], xform, Vector2(E->key().x, E->key().y));
#ifdef DEBUG_ENABLED
} else {
print_error("The TileSet assigned to the TileMap " + get_name() + " has an invalid convex shape.");
@@ -438,10 +499,7 @@ void TileMap::update_dirty_quadrants() {
}
}
} else {
- ps->body_add_shape(q.body, shape->get_rid(), xform);
- ps->body_set_shape_metadata(q.body, shape_idx, Vector2(E->key().x, E->key().y));
- ps->body_set_shape_as_one_way_collision(q.body, shape_idx, shapes[j].one_way_collision, shapes[j].one_way_collision_margin);
- shape_idx++;
+ _add_shape(shape_idx, q, shape, shapes[j], xform, Vector2(E->key().x, E->key().y));
}
}
}
@@ -616,22 +674,29 @@ Map<TileMap::PosKey, TileMap::Quadrant>::Element *TileMap::_create_quadrant(cons
xform.set_origin(q.pos);
//q.canvas_item = VisualServer::get_singleton()->canvas_item_create();
- q.body = Physics2DServer::get_singleton()->body_create();
- Physics2DServer::get_singleton()->body_set_mode(q.body, use_kinematic ? Physics2DServer::BODY_MODE_KINEMATIC : Physics2DServer::BODY_MODE_STATIC);
-
- Physics2DServer::get_singleton()->body_attach_object_instance_id(q.body, get_instance_id());
- Physics2DServer::get_singleton()->body_set_collision_layer(q.body, collision_layer);
- Physics2DServer::get_singleton()->body_set_collision_mask(q.body, collision_mask);
- Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_FRICTION, friction);
- Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_BOUNCE, bounce);
-
- if (is_inside_tree()) {
- xform = get_global_transform() * xform;
- RID space = get_world_2d()->get_space();
- Physics2DServer::get_singleton()->body_set_space(q.body, space);
- }
+ if (!use_parent) {
+ q.body = Physics2DServer::get_singleton()->body_create();
+ Physics2DServer::get_singleton()->body_set_mode(q.body, use_kinematic ? Physics2DServer::BODY_MODE_KINEMATIC : Physics2DServer::BODY_MODE_STATIC);
+
+ Physics2DServer::get_singleton()->body_attach_object_instance_id(q.body, get_instance_id());
+ Physics2DServer::get_singleton()->body_set_collision_layer(q.body, collision_layer);
+ Physics2DServer::get_singleton()->body_set_collision_mask(q.body, collision_mask);
+ Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_FRICTION, friction);
+ Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_BOUNCE, bounce);
- Physics2DServer::get_singleton()->body_set_state(q.body, Physics2DServer::BODY_STATE_TRANSFORM, xform);
+ if (is_inside_tree()) {
+ xform = get_global_transform() * xform;
+ RID space = get_world_2d()->get_space();
+ Physics2DServer::get_singleton()->body_set_space(q.body, space);
+ }
+
+ Physics2DServer::get_singleton()->body_set_state(q.body, Physics2DServer::BODY_STATE_TRANSFORM, xform);
+ } else if (collision_parent) {
+ xform = get_transform() * xform;
+ q.shape_owner_id = collision_parent->create_shape_owner(this);
+ } else {
+ q.shape_owner_id = -1;
+ }
rect_cache_dirty = true;
quadrant_order_dirty = true;
@@ -641,7 +706,12 @@ Map<TileMap::PosKey, TileMap::Quadrant>::Element *TileMap::_create_quadrant(cons
void TileMap::_erase_quadrant(Map<PosKey, Quadrant>::Element *Q) {
Quadrant &q = Q->get();
- Physics2DServer::get_singleton()->free(q.body);
+ if (!use_parent) {
+ Physics2DServer::get_singleton()->free(q.body);
+ } else if (collision_parent) {
+ collision_parent->remove_shape_owner(q.shape_owner_id);
+ }
+
for (List<RID>::Element *E = q.canvas_items.front(); E; E = E->next()) {
VisualServer::get_singleton()->free(E->get());
@@ -1135,20 +1205,24 @@ Rect2 TileMap::_edit_get_rect() const {
void TileMap::set_collision_layer(uint32_t p_layer) {
collision_layer = p_layer;
- for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
+ if (!use_parent) {
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
- Quadrant &q = E->get();
- Physics2DServer::get_singleton()->body_set_collision_layer(q.body, collision_layer);
+ Quadrant &q = E->get();
+ Physics2DServer::get_singleton()->body_set_collision_layer(q.body, collision_layer);
+ }
}
}
void TileMap::set_collision_mask(uint32_t p_mask) {
collision_mask = p_mask;
- for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
+ if (!use_parent) {
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
- Quadrant &q = E->get();
- Physics2DServer::get_singleton()->body_set_collision_mask(q.body, collision_mask);
+ Quadrant &q = E->get();
+ Physics2DServer::get_singleton()->body_set_collision_mask(q.body, collision_mask);
+ }
}
}
@@ -1184,13 +1258,40 @@ void TileMap::set_collision_use_kinematic(bool p_use_kinematic) {
_recreate_quadrants();
}
+bool TileMap::get_collision_use_parent() const {
+
+ return use_parent;
+}
+
+void TileMap::set_collision_use_parent(bool p_use_parent) {
+
+ if (use_parent == p_use_parent) return;
+
+ _clear_quadrants();
+
+ use_parent = p_use_parent;
+ set_notify_local_transform(use_parent);
+
+ if (use_parent && is_inside_tree()) {
+ collision_parent = Object::cast_to<CollisionObject2D>(get_parent());
+ } else {
+ collision_parent = NULL;
+ }
+
+ _recreate_quadrants();
+ _change_notify();
+ update_configuration_warning();
+}
+
void TileMap::set_collision_friction(float p_friction) {
friction = p_friction;
- for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
+ if (!use_parent) {
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
- Quadrant &q = E->get();
- Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_FRICTION, p_friction);
+ Quadrant &q = E->get();
+ Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_FRICTION, p_friction);
+ }
}
}
@@ -1202,10 +1303,12 @@ float TileMap::get_collision_friction() const {
void TileMap::set_collision_bounce(float p_bounce) {
bounce = p_bounce;
- for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
+ if (!use_parent) {
+ for (Map<PosKey, Quadrant>::Element *E = quadrant_map.front(); E; E = E->next()) {
- Quadrant &q = E->get();
- Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_BOUNCE, p_bounce);
+ Quadrant &q = E->get();
+ Physics2DServer::get_singleton()->body_set_param(q.body, Physics2DServer::BODY_PARAM_BOUNCE, p_bounce);
+ }
}
}
float TileMap::get_collision_bounce() const {
@@ -1404,6 +1507,12 @@ void TileMap::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(p);
}
+void TileMap::_validate_property(PropertyInfo &property) const {
+ if (use_parent && property.name != "collision_use_parent" && property.name.begins_with("collision_")) {
+ property.usage = PROPERTY_USAGE_NOEDITOR;
+ }
+}
+
Vector2 TileMap::map_to_world(const Vector2 &p_pos, bool p_ignore_ofs) const {
return _map_to_world(p_pos.x, p_pos.y, p_ignore_ofs);
@@ -1552,6 +1661,20 @@ bool TileMap::get_clip_uv() const {
return clip_uv;
}
+String TileMap::get_configuration_warning() const {
+
+ String warning = Node2D::get_configuration_warning();
+
+ if (use_parent && !collision_parent) {
+ if (!warning.empty()) {
+ warning += "\n";
+ }
+ return TTR("TileMap with Use Parent on needs a parent CollisionObject2D to give shapes to. Please use it as a child of Area2D, StaticBody2D, RigidBody2D, KinematicBody2D, etc. to give them a shape.");
+ }
+
+ return warning;
+}
+
void TileMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_tileset", "tileset"), &TileMap::set_tileset);
@@ -1587,6 +1710,9 @@ void TileMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_collision_use_kinematic", "use_kinematic"), &TileMap::set_collision_use_kinematic);
ClassDB::bind_method(D_METHOD("get_collision_use_kinematic"), &TileMap::get_collision_use_kinematic);
+ ClassDB::bind_method(D_METHOD("set_collision_use_parent", "use_parent"), &TileMap::set_collision_use_parent);
+ ClassDB::bind_method(D_METHOD("get_collision_use_parent"), &TileMap::get_collision_use_parent);
+
ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &TileMap::set_collision_layer);
ClassDB::bind_method(D_METHOD("get_collision_layer"), &TileMap::get_collision_layer);
@@ -1652,6 +1778,7 @@ void TileMap::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cell_clip_uv"), "set_clip_uv", "get_clip_uv");
ADD_GROUP("Collision", "collision_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collision_use_parent", PROPERTY_HINT_NONE, ""), "set_collision_use_parent", "get_collision_use_parent");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collision_use_kinematic", PROPERTY_HINT_NONE, ""), "set_collision_use_kinematic", "get_collision_use_kinematic");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "collision_friction", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_collision_friction", "get_collision_friction");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "collision_bounce", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_collision_bounce", "get_collision_bounce");
@@ -1700,7 +1827,8 @@ TileMap::TileMap() {
bounce = 0;
mode = MODE_SQUARE;
half_offset = HALF_OFFSET_DISABLED;
- use_kinematic = false;
+ use_parent = false;
+ collision_parent = NULL;
navigation = NULL;
y_sort_mode = false;
occluder_light_mask = 1;
@@ -1710,6 +1838,7 @@ TileMap::TileMap() {
fp_adjust = 0.00001;
tile_origin = TILE_ORIGIN_TOP_LEFT;
set_notify_transform(true);
+ set_notify_local_transform(false);
}
TileMap::~TileMap() {
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index 6a1467aa48..1caaefa213 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -37,6 +37,8 @@
#include "scene/2d/node_2d.h"
#include "scene/resources/tile_set.h"
+class CollisionObject2D;
+
class TileMap : public Node2D {
GDCLASS(TileMap, Node2D);
@@ -74,6 +76,8 @@ private:
Mode mode;
Transform2D custom_transform;
HalfOffset half_offset;
+ bool use_parent;
+ CollisionObject2D *collision_parent;
bool use_kinematic;
Navigation2D *navigation;
@@ -123,6 +127,7 @@ private:
Vector2 pos;
List<RID> canvas_items;
RID body;
+ uint32_t shape_owner_id;
SelfList<Quadrant> dirty_list;
@@ -145,6 +150,7 @@ private:
pos = q.pos;
canvas_items = q.canvas_items;
body = q.body;
+ shape_owner_id = q.shape_owner_id;
cells = q.cells;
navpoly_ids = q.navpoly_ids;
occluder_instances = q.occluder_instances;
@@ -154,6 +160,7 @@ private:
pos = q.pos;
canvas_items = q.canvas_items;
body = q.body;
+ shape_owner_id = q.shape_owner_id;
cells = q.cells;
occluder_instances = q.occluder_instances;
navpoly_ids = q.navpoly_ids;
@@ -188,6 +195,8 @@ private:
void _fix_cell_transform(Transform2D &xform, const Cell &p_cell, const Vector2 &p_offset, const Size2 &p_sc);
+ void _add_shape(int &shape_idx, const Quadrant &p_q, const Ref<Shape2D> &p_shape, const TileSet::ShapeData &p_shape_data, const Transform2D &p_xform, const Vector2 &p_metadata);
+
Map<PosKey, Quadrant>::Element *_create_quadrant(const PosKey &p_qk);
void _erase_quadrant(Map<PosKey, Quadrant>::Element *Q);
void _make_quadrant_dirty(Map<PosKey, Quadrant>::Element *Q, bool update = true);
@@ -218,6 +227,7 @@ protected:
void _notification(int p_what);
static void _bind_methods();
+ virtual void _validate_property(PropertyInfo &property) const;
virtual void _changed_callback(Object *p_changed, const char *p_prop);
public:
@@ -271,6 +281,9 @@ public:
void set_collision_use_kinematic(bool p_use_kinematic);
bool get_collision_use_kinematic() const;
+ void set_collision_use_parent(bool p_use_parent);
+ bool get_collision_use_parent() const;
+
void set_collision_friction(float p_friction);
float get_collision_friction() const;
@@ -314,6 +327,8 @@ public:
void set_clip_uv(bool p_enable);
bool get_clip_uv() const;
+ String get_configuration_warning() const;
+
void fix_invalid_tiles();
void clear();
diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp
index 95eec41fb2..dfa8fce9be 100644
--- a/scene/3d/arvr_nodes.cpp
+++ b/scene/3d/arvr_nodes.cpp
@@ -264,6 +264,7 @@ void ARVRController::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_rumble"), &ARVRController::get_rumble);
ClassDB::bind_method(D_METHOD("set_rumble", "rumble"), &ARVRController::set_rumble);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rumble", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_rumble", "get_rumble");
+ ADD_PROPERTY_DEFAULT("rumble", 0.0);
ClassDB::bind_method(D_METHOD("get_mesh"), &ARVRController::get_mesh);
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 3624e04434..d3aad7000d 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -1470,7 +1470,7 @@ Vector3 KinematicCollision::get_remainder() const {
return collision.remainder;
}
Object *KinematicCollision::get_local_shape() const {
- ERR_FAIL_COND_V(!owner, NULL);
+ if (!owner) return NULL;
uint32_t ownerid = owner->shape_find_owner(collision.local_shape);
return owner->shape_owner_get_owner(ownerid);
}
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 58a0762469..b197971b61 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -173,7 +173,7 @@ void ColorPicker::_value_changed(double) {
color.set_hsv(scroll[0]->get_value() / 360.0,
scroll[1]->get_value() / 100.0,
scroll[2]->get_value() / 100.0,
- scroll[3]->get_value() / 100.0);
+ scroll[3]->get_value() / 255.0);
} else {
for (int i = 0; i < 4; i++) {
color.components[i] = scroll[i]->get_value() / (raw_mode_enabled ? 1.0 : 255.0);
@@ -209,17 +209,17 @@ void ColorPicker::_update_color(bool p_update_sliders) {
if (hsv_mode_enabled) {
for (int i = 0; i < 4; i++) {
- scroll[i]->set_step(0.1);
+ scroll[i]->set_step(1.0);
}
- scroll[0]->set_max(360);
+ scroll[0]->set_max(359);
scroll[0]->set_value(h * 360.0);
scroll[1]->set_max(100);
scroll[1]->set_value(s * 100.0);
scroll[2]->set_max(100);
scroll[2]->set_value(v * 100.0);
- scroll[3]->set_max(100);
- scroll[3]->set_value(color.components[3] * 100.0);
+ scroll[3]->set_max(255);
+ scroll[3]->set_value(color.components[3] * 255.0);
} else {
for (int i = 0; i < 4; i++) {
if (raw_mode_enabled) {
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 7f0cebd492..0e7cec57a4 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -614,6 +614,7 @@ void SceneTree::finish() {
root->_set_tree(NULL);
root->_propagate_after_exit_tree();
memdelete(root); //delete root
+ root = NULL;
}
}
@@ -1889,6 +1890,7 @@ void SceneTree::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_navigation_hint"), "set_debug_navigation_hint", "is_debugging_navigation_hint");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "paused"), "set_pause", "is_paused");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "refuse_new_network_connections"), "set_refuse_new_network_connections", "is_refusing_new_network_connections");
+ ADD_PROPERTY_DEFAULT("refuse_new_network_connections", false);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_font_oversampling"), "set_use_font_oversampling", "is_using_font_oversampling");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "edited_scene_root", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_edited_scene_root", "get_edited_scene_root");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "current_scene", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_current_scene", "get_current_scene");
@@ -1962,7 +1964,7 @@ bool SceneTree::is_using_font_oversampling() const {
SceneTree::SceneTree() {
- singleton = this;
+ if (singleton == NULL) singleton = this;
_quit = false;
accept_quit = true;
quit_on_go_back = true;
@@ -2107,4 +2109,11 @@ SceneTree::SceneTree() {
}
SceneTree::~SceneTree() {
+ if (root) {
+ root->_set_tree(NULL);
+ root->_propagate_after_exit_tree();
+ memdelete(root);
+ }
+
+ if (singleton == this) singleton = NULL;
}
diff --git a/scene/resources/concave_polygon_shape_2d.cpp b/scene/resources/concave_polygon_shape_2d.cpp
index 51dd91fff5..de853f0c30 100644
--- a/scene/resources/concave_polygon_shape_2d.cpp
+++ b/scene/resources/concave_polygon_shape_2d.cpp
@@ -104,4 +104,6 @@ void ConcavePolygonShape2D::_bind_methods() {
ConcavePolygonShape2D::ConcavePolygonShape2D() :
Shape2D(Physics2DServer::get_singleton()->concave_polygon_shape_create()) {
+ PoolVector<Vector2> empty;
+ set_segments(empty);
}