Merge pull request #42461 from akien-mga/3.2-cherrypicks

Cherry-picks for the 3.2 branch (future 3.2.4) - 3rd batch
This commit is contained in:
Rémi Verschelde 2020-10-01 16:13:17 +02:00 committed by GitHub
commit bdfe93bad2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 82 additions and 89 deletions

View file

@ -68,6 +68,10 @@ void FuncRef::set_function(const StringName &p_func) {
function = p_func;
}
StringName FuncRef::get_function() {
return function;
}
bool FuncRef::is_valid() const {
if (id == 0)
return false;
@ -91,8 +95,12 @@ void FuncRef::_bind_methods() {
ClassDB::bind_method(D_METHOD("call_funcv", "arg_array"), &FuncRef::call_funcv);
ClassDB::bind_method(D_METHOD("set_instance", "instance"), &FuncRef::set_instance);
ClassDB::bind_method(D_METHOD("set_function", "name"), &FuncRef::set_function);
ClassDB::bind_method(D_METHOD("is_valid"), &FuncRef::is_valid);
ClassDB::bind_method(D_METHOD("set_function", "name"), &FuncRef::set_function);
ClassDB::bind_method(D_METHOD("get_function"), &FuncRef::get_function);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "function"), "set_function", "get_function");
}
FuncRef::FuncRef() :

View file

@ -47,6 +47,7 @@ public:
Variant call_funcv(const Array &p_args);
void set_instance(Object *p_obj);
void set_function(const StringName &p_func);
StringName get_function();
bool is_valid() const;
FuncRef();
};

View file

@ -472,13 +472,6 @@
Returns [code]true[/code] if local transform notifications are communicated to children.
</description>
</method>
<method name="is_set_as_toplevel" qualifiers="const">
<return type="bool">
</return>
<description>
Returns [code]true[/code] if the node is set as top-level. See [method set_as_toplevel].
</description>
</method>
<method name="is_transform_notification_enabled" qualifiers="const">
<return type="bool">
</return>
@ -511,15 +504,6 @@
Transformations issued by [code]event[/code]'s inputs are applied in local space instead of global space.
</description>
</method>
<method name="set_as_toplevel">
<return type="void">
</return>
<argument index="0" name="enable" type="bool">
</argument>
<description>
If [code]enable[/code] is [code]true[/code], the node won't inherit its transform from parent canvas items.
</description>
</method>
<method name="set_notify_local_transform">
<return type="void">
</return>
@ -569,6 +553,9 @@
<member name="show_behind_parent" type="bool" setter="set_draw_behind_parent" getter="is_draw_behind_parent_enabled" default="false">
If [code]true[/code], the object draws behind its parent.
</member>
<member name="toplevel" type="bool" setter="set_as_toplevel" getter="is_set_as_toplevel">
If [code]true[/code], the node will not inherit its transform from parent [CanvasItem]s.
</member>
<member name="show_on_top" type="bool" setter="_set_on_top" getter="_is_on_top">
If [code]true[/code], the object draws on top of its parent.
</member>

View file

@ -399,8 +399,7 @@
<argument index="0" name="line" type="String">
</argument>
<description>
Stores the given [String] as a line in the file.
Text will be encoded as UTF-8.
Appends [code]line[/code] to the file followed by a line return character ([code]\n[/code]), encoding the text as UTF-8.
</description>
</method>
<method name="store_pascal_string">
@ -428,8 +427,7 @@
<argument index="0" name="string" type="String">
</argument>
<description>
Stores the given [String] in the file.
Text will be encoded as UTF-8.
Appends [code]string[/code] to the file without a line return, encoding the text as UTF-8.
</description>
</method>
<method name="store_var">

View file

@ -14,7 +14,7 @@
<return type="Variant">
</return>
<description>
Calls the referenced function previously set by [method set_function] or [method @GDScript.funcref].
Calls the referenced function previously set in [member function] or [method @GDScript.funcref].
</description>
</method>
<method name="call_funcv">
@ -23,23 +23,7 @@
<argument index="0" name="arg_array" type="Array">
</argument>
<description>
Calls the referenced function previously set by [method set_function] or [method @GDScript.funcref]. Contrarily to [method call_func], this method does not support a variable number of arguments but expects all parameters to be passed via a single [Array].
</description>
</method>
<method name="is_valid" qualifiers="const">
<return type="bool">
</return>
<description>
Returns whether the object still exists and has the function assigned.
</description>
</method>
<method name="set_function">
<return type="void">
</return>
<argument index="0" name="name" type="String">
</argument>
<description>
The name of the referenced function to call on the object, without parentheses or any parameters.
Calls the referenced function previously set in [member function] or [method @GDScript.funcref]. Contrarily to [method call_func], this method does not support a variable number of arguments but expects all parameters to be passed via a single [Array].
</description>
</method>
<method name="set_instance">
@ -51,7 +35,19 @@
The object containing the referenced function. This object must be of a type actually inheriting from [Object], not a built-in type such as [int], [Vector2] or [Dictionary].
</description>
</method>
<method name="is_valid" qualifiers="const">
<return type="bool">
</return>
<description>
Returns whether the object still exists and has the function assigned.
</description>
</method>
</methods>
<members>
<member name="function" type="String" setter="set_function" getter="get_function">
The name of the referenced function.
</member>
</members>
<constants>
</constants>
</class>

View file

@ -83,13 +83,6 @@
Returns whether this node uses a scale of [code](1, 1, 1)[/code] or its local transformation scale.
</description>
</method>
<method name="is_set_as_toplevel" qualifiers="const">
<return type="bool">
</return>
<description>
Returns whether this node is set as Toplevel, that is whether it ignores its parent nodes transformations.
</description>
</method>
<method name="is_transform_notification_enabled" qualifiers="const">
<return type="bool">
</return>
@ -195,15 +188,6 @@
Scales the local transformation by given 3D scale factors in object-local coordinate system.
</description>
</method>
<method name="set_as_toplevel">
<return type="void">
</return>
<argument index="0" name="enable" type="bool">
</argument>
<description>
Makes the node ignore its parents transformations. Node transformations are only in global space.
</description>
</method>
<method name="set_disable_scale">
<return type="void">
</return>
@ -316,6 +300,9 @@
<member name="scale" type="Vector3" setter="set_scale" getter="get_scale" default="Vector3( 1, 1, 1 )">
Scale part of the local transformation.
</member>
<member name="toplevel" type="bool" setter="set_as_toplevel" getter="is_set_as_toplevel">
If [code]true[/code], the node will not inherit its transformations from its parent. Node transformations are only in global space.
</member>
<member name="transform" type="Transform" setter="set_transform" getter="get_transform" default="Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )">
Local space [Transform] of this node, with respect to the parent node.
</member>

View file

@ -270,7 +270,10 @@
<argument index="0" name="to" type="String">
</argument>
<description>
Performs a case-sensitive comparison to another string. Returns [code]-1[/code] if less than, [code]+1[/code] if greater than, or [code]0[/code] if equal.
Performs a case-sensitive comparison to another string. Returns [code]-1[/code] if less than, [code]1[/code] if greater than, or [code]0[/code] if equal. "less than" or "greater than" are determined by the [url=https://en.wikipedia.org/wiki/List_of_Unicode_characters]Unicode code points[/code] of each string, which roughly matches the alphabetical order.
[b]Behavior with different string lengths:[/b] Returns [code]1[/code] if the "base" string is longer than the [code]to[/code] string or [code]-1[/code] if the "base" string is shorter than the [code]to[/code] string. Keep in mind this length is determined by the number of Unicode codepoints, [i]not[/i] the actual visible characters.
[b]Behavior with empty strings:[/b] Returns [code]-1[/code] if the "base" string is empty, [code]1[/code] if the [code]to[/code] string is empty or [code]0[/code] if both strings are empty.
To get a boolean result from a string comparison, use the [code]==[/code] operator instead. See also [method nocasecmp_to].
</description>
</method>
<method name="count">
@ -550,7 +553,7 @@
<return type="bool">
</return>
<description>
Returns [code]true[/code] if this string contains a valid IP address.
Returns [code]true[/code] if this string contains only a well-formatted IPv4 or IPv6 address. This method considers [url=https://en.wikipedia.org/wiki/Reserved_IP_addresses]reserved IP addresses[/url] such as [code]0.0.0.0[/code] as valid.
</description>
</method>
<method name="json_escape">
@ -623,7 +626,10 @@
<argument index="0" name="to" type="String">
</argument>
<description>
Performs a case-insensitive comparison to another string. Returns [code]-1[/code] if less than, [code]+1[/code] if greater than, or [code]0[/code] if equal.
Performs a case-insensitive comparison to another string. Returns [code]-1[/code] if less than, [code]1[/code] if greater than, or [code]0[/code] if equal. "less than" or "greater than" are determined by the [url=https://en.wikipedia.org/wiki/List_of_Unicode_characters]Unicode code points[/code] of each string, which roughly matches the alphabetical order. Internally, lowercase characters will be converted to uppercase during the comparison.
[b]Behavior with different string lengths:[/b] Returns [code]1[/code] if the "base" string is longer than the [code]to[/code] string or [code]-1[/code] if the "base" string is shorter than the [code]to[/code] string. Keep in mind this length is determined by the number of Unicode codepoints, [i]not[/i] the actual visible characters.
[b]Behavior with empty strings:[/b] Returns [code]-1[/code] if the "base" string is empty, [code]1[/code] if the [code]to[/code] string is empty or [code]0[/code] if both strings are empty.
To get a boolean result from a string comparison, use the [code]==[/code] operator instead. See also [method casecmp_to].
</description>
</method>
<method name="ord_at">

View file

@ -172,7 +172,6 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref<
return;
int small_thumbnail_size = EditorNode::get_singleton()->get_theme_base()->get_icon("Object", "EditorIcons")->get_width(); // Kind of a workaround to retrieve the default icon size
small_thumbnail_size *= EDSCALE;
if (preview_generators[i]->can_generate_small_preview()) {
Ref<Texture> generated_small;

View file

@ -2487,13 +2487,28 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
// Handles the mouse hovering
_gui_input_hover(p_event);
// Change the cursor
CursorShape c = CURSOR_ARROW;
bool should_switch = false;
if (drag_selection.size() != 0) {
float angle = drag_selection[0]->_edit_get_rotation();
should_switch = abs(Math::cos(angle)) < Math_SQRT12;
// Compute an eventual rotation of the cursor
CursorShape rotation_array[4] = { CURSOR_HSIZE, CURSOR_BDIAGSIZE, CURSOR_VSIZE, CURSOR_FDIAGSIZE };
int rotation_array_index = 0;
List<CanvasItem *> selection = _get_edited_canvas_items();
if (selection.size() == 1) {
float angle = Math::fposmod((double)selection[0]->get_global_transform_with_canvas().get_rotation(), Math_PI);
if (angle > Math_PI * 7.0 / 8.0) {
rotation_array_index = 0;
} else if (angle > Math_PI * 5.0 / 8.0) {
rotation_array_index = 1;
} else if (angle > Math_PI * 3.0 / 8.0) {
rotation_array_index = 2;
} else if (angle > Math_PI * 1.0 / 8.0) {
rotation_array_index = 3;
} else {
rotation_array_index = 0;
}
}
// Choose the correct cursor
CursorShape c = CURSOR_ARROW;
switch (drag_type) {
case DRAG_NONE:
switch (tool) {
@ -2515,38 +2530,28 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) {
break;
case DRAG_LEFT:
case DRAG_RIGHT:
c = rotation_array[rotation_array_index];
break;
case DRAG_V_GUIDE:
if (should_switch) {
c = CURSOR_VSIZE;
} else {
c = CURSOR_HSIZE;
}
c = CURSOR_HSIZE;
break;
case DRAG_TOP:
case DRAG_BOTTOM:
c = rotation_array[(rotation_array_index + 2) % 4];
break;
case DRAG_H_GUIDE:
if (should_switch) {
c = CURSOR_HSIZE;
} else {
c = CURSOR_VSIZE;
}
c = CURSOR_VSIZE;
break;
case DRAG_TOP_LEFT:
case DRAG_BOTTOM_RIGHT:
c = rotation_array[(rotation_array_index + 3) % 4];
break;
case DRAG_DOUBLE_GUIDE:
if (should_switch) {
c = CURSOR_BDIAGSIZE;
} else {
c = CURSOR_FDIAGSIZE;
}
c = CURSOR_FDIAGSIZE;
break;
case DRAG_TOP_RIGHT:
case DRAG_BOTTOM_LEFT:
if (should_switch) {
c = CURSOR_FDIAGSIZE;
} else {
c = CURSOR_BDIAGSIZE;
}
c = rotation_array[(rotation_array_index + 1) % 4];
break;
case DRAG_MOVE:
c = CURSOR_MOVE;
@ -3898,6 +3903,12 @@ void CanvasItemEditor::_notification(int p_what) {
key_scale_button->set_icon(get_icon("KeyScale", "EditorIcons"));
key_insert_button->set_icon(get_icon("Key", "EditorIcons"));
key_auto_insert_button->set_icon(get_icon("AutoKey", "EditorIcons"));
// Use a different color for the active autokey icon to make them easier
// to distinguish from the other key icons at the top. On a light theme,
// the icon will be dark, so we need to lighten it before blending it
// with the red color.
const Color key_auto_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25);
key_auto_insert_button->add_color_override("icon_color_pressed", key_auto_color.linear_interpolate(Color(1, 0, 0), 0.55));
animation_menu->set_icon(get_icon("GuiTabMenuHl", "EditorIcons"));
zoom_minus->set_icon(get_icon("ZoomLess", "EditorIcons"));

View file

@ -2608,14 +2608,14 @@ bool CSharpScript::_get_member_export(IMonoClassMember *p_member, bool p_inspect
if (!property->has_getter()) {
#ifdef TOOLS_ENABLED
if (exported)
ERR_PRINTS("Read-only property cannot be exported: '" + MEMBER_FULL_QUALIFIED_NAME(p_member) + "'.");
ERR_PRINT("Cannot export a property without a getter: '" + MEMBER_FULL_QUALIFIED_NAME(p_member) + "'.");
#endif
return false;
}
if (!property->has_setter()) {
#ifdef TOOLS_ENABLED
if (exported)
ERR_PRINTS("Write-only property (without getter) cannot be exported: '" + MEMBER_FULL_QUALIFIED_NAME(p_member) + "'.");
ERR_PRINT("Cannot export a property without a setter: '" + MEMBER_FULL_QUALIFIED_NAME(p_member) + "'.");
#endif
return false;
}

View file

@ -1228,14 +1228,13 @@ void CanvasItem::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "modulate"), "set_modulate", "get_modulate");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "self_modulate"), "set_self_modulate", "get_self_modulate");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_behind_parent"), "set_draw_behind_parent", "is_draw_behind_parent_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "toplevel"), "set_as_toplevel", "is_set_as_toplevel");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_on_top", PROPERTY_HINT_NONE, "", 0), "_set_on_top", "_is_on_top"); //compatibility
ADD_PROPERTY(PropertyInfo(Variant::INT, "light_mask", PROPERTY_HINT_LAYERS_2D_RENDER), "set_light_mask", "get_light_mask");
ADD_GROUP("Material", "");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,CanvasItemMaterial"), "set_material", "get_material");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_parent_material"), "set_use_parent_material", "get_use_parent_material");
//exporting these things doesn't really make much sense i think
// ADD_PROPERTY(PropertyInfo(Variant::BOOL, "toplevel", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_as_toplevel", "is_set_as_toplevel");
// ADD_PROPERTY(PropertyInfo(Variant::BOOL,"transform/notify"),"set_transform_notify","is_transform_notify_enabled");
ADD_SIGNAL(MethodInfo("draw"));

View file

@ -810,6 +810,7 @@ void Spatial::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_rotation_degrees", "get_rotation_degrees");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation", PROPERTY_HINT_NONE, "", 0), "set_rotation", "get_rotation");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_scale", "get_scale");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "toplevel"), "set_as_toplevel", "is_set_as_toplevel");
ADD_GROUP("Matrix", "");
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "transform", PROPERTY_HINT_NONE, ""), "set_transform", "get_transform");
ADD_GROUP("Visibility", "");