diff options
-rw-r--r-- | core/io/http_client.cpp | 1 | ||||
-rw-r--r-- | doc/base/classes.xml | 164 | ||||
-rw-r--r-- | scene/animation/animation_tree_player.cpp | 90 | ||||
-rw-r--r-- | scene/animation/animation_tree_player.h | 8 | ||||
-rw-r--r-- | scene/gui/button.cpp | 4 | ||||
-rw-r--r-- | scene/gui/button_array.cpp | 27 | ||||
-rw-r--r-- | tools/editor/plugins/animation_tree_editor_plugin.cpp | 52 |
7 files changed, 259 insertions, 87 deletions
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 8c58e0ba5e..d7098b4c43 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -303,6 +303,7 @@ Error HTTPClient::poll(){ chunked=false; body_left=0; chunk_left=0; + response_str.clear(); response_headers.clear(); response_num = RESPONSE_OK; diff --git a/doc/base/classes.xml b/doc/base/classes.xml index de19b1c8ca..68d5b3e071 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -2900,6 +2900,12 @@ </method> </methods> <signals> + <signal name="animation_started"> + <argument index="0" name="name" type="String"> + </argument> + <description> + </description> + </signal> <signal name="animation_changed"> <argument index="0" name="old_name" type="String"> </argument> @@ -3023,6 +3029,16 @@ <description> </description> </method> + <method name="animation_node_set_filter_path"> + <argument index="0" name="id" type="String"> + </argument> + <argument index="1" name="path" type="NodePath"> + </argument> + <argument index="2" name="enable" type="bool"> + </argument> + <description> + </description> + </method> <method name="oneshot_node_set_fadein_time"> <argument index="0" name="id" type="String"> </argument> @@ -5678,12 +5694,14 @@ <argument index="0" name="texture" type="Texture"> </argument> <description> + Set the icon that will be displayed next to the text inside the button area. </description> </method> <method name="get_button_icon" qualifiers="const"> <return type="Texture"> </return> <description> + Return the button icon. </description> </method> <method name="set_flat"> @@ -5711,23 +5729,34 @@ <argument index="0" name="align" type="int"> </argument> <description> + Set the text alignment policy, using one of the ALIGN_* constants. </description> </method> <method name="get_text_align" qualifiers="const"> <return type="int"> </return> <description> + Return the text alignment policy. </description> </method> <method name="is_flat" qualifiers="const"> <return type="bool"> </return> <description> - Return the state of the [i]flat[/i] property (see [method set_flat]) + Return the state of the [i]flat[/i] property (see [method set_flat]). </description> </method> </methods> <constants> + <constant name="ALIGN_LEFT" value="0"> + Align the text to the left. + </constant> + <constant name="ALIGN_CENTER" value="1"> + Center the text. + </constant> + <constant name="ALIGN_RIGHT" value="2"> + Align the text to the right. + </constant> </constants> <theme_items> <theme_item name="hseparation" type="int"> @@ -5759,57 +5788,60 @@ Array of Buttons. </brief_description> <description> - Array of Buttons. A Button array is useful to have an array of buttons laid out vertically or horizontally. Only one can be selected. This is useful for joy pad based interfaces and option menus. + Array of Buttons. A ButtonArray is useful to have an array of buttons laid out vertically or horizontally. Only one button can be selected, and is referenced by its index in the array (first button is 0, second button is 1, etc.). + This is useful [i]e.g.[/i] for joypad-friendly interfaces and option menus. </description> <methods> <method name="add_button"> <argument index="0" name="text" type="String"> </argument> <description> - Add a new button. + Append a new button to the array, with the specified text. </description> </method> <method name="add_icon_button"> - <argument index="0" name="icon" type="Object"> + <argument index="0" name="icon" type="Texture"> </argument> <argument index="1" name="text" type="String" default=""""> </argument> <description> + Append a new button to the array, with the specified icon and text. </description> </method> <method name="set_button_text"> - <argument index="0" name="button" type="int"> + <argument index="0" name="button_idx" type="int"> </argument> <argument index="1" name="text" type="String"> </argument> <description> + Define the text of the specified button. </description> </method> <method name="set_button_icon"> - <argument index="0" name="button" type="int"> + <argument index="0" name="button_idx" type="int"> </argument> - <argument index="1" name="icon" type="Object"> + <argument index="1" name="icon" type="Texture"> </argument> <description> - Set the icon of an existing button. + Set the icon of the specified button. </description> </method> <method name="get_button_text" qualifiers="const"> <return type="String"> </return> - <argument index="0" name="button" type="int"> + <argument index="0" name="button_idx" type="int"> </argument> <description> - Return the text of an existing button. + Return the text of the specified button. </description> </method> <method name="get_button_icon" qualifiers="const"> - <return type="Object"> + <return type="Texture"> </return> - <argument index="0" name="button" type="int"> + <argument index="0" name="button_idx" type="int"> </argument> <description> - Return the icon of an existing button. + Return the icon of the specified button. </description> </method> <method name="get_button_count" qualifiers="const"> @@ -5823,42 +5855,42 @@ <return type="int"> </return> <description> - Return the currently selected button in the array. + Return the index of the currently selected button in the array. </description> </method> <method name="get_hovered" qualifiers="const"> <return type="int"> </return> <description> - Return the currently hovered button in the array. + Return the index of the currently hovered button in the array. </description> </method> <method name="set_selected"> - <argument index="0" name="button" type="int"> + <argument index="0" name="button_idx" type="int"> </argument> <description> - Select a button in the array. + Select a button in the array based on the given index. </description> </method> <method name="erase_button"> - <argument index="0" name="button" type="int"> + <argument index="0" name="button_idx" type="int"> </argument> <description> - Remove a button in the array, by index. + Remove the specified button in the array. </description> </method> <method name="clear"> <description> - Clear the button array. + Remove all buttons from the array. </description> </method> </methods> <signals> <signal name="button_selected"> - <argument index="0" name="button" type="int"> + <argument index="0" name="button_idx" type="int"> </argument> <description> - A Button was selected (returns the index). + A button has been selected, its index is given as the argument. </description> </signal> </signals> @@ -7095,6 +7127,7 @@ <argument index="0" name="enable" type="bool"> </argument> <description> + This function will anchor the container children to the top left corner of the the container boundaries, moving all its children to that position, (the children new center will be the top left corner of the container). </description> </method> <method name="is_using_top_left" qualifiers="const"> @@ -7109,8 +7142,10 @@ </class> <class name="CheckBox" inherits="Button" category="Core"> <brief_description> + Binary choice user interface widget </brief_description> <description> + A checkbox allows the user to make a binary choice (choosing only one of two posible options), for example Answer 'yes' or 'no'. </description> <methods> </methods> @@ -13388,20 +13423,24 @@ Returns an empty String "" at the end of the list. </class> <class name="GridContainer" inherits="Container" category="Core"> <brief_description> + Grid container used to arrange elements in a grid like layout </brief_description> <description> + Grid container will arrange its children in a grid like structure, the grid columns are specified using the [method set_columns] method and the number of rows will be equal to the number of children in the container divided by the number of columns, for example: if the container has 5 children, and 2 columns, there will be 3 rows in the container. Notice that grid layout will preserve the columns and rows for every size of the container. </description> <methods> <method name="set_columns"> <argument index="0" name="columns" type="int"> </argument> <description> + Sets the numbers of columns in the container, then reorder its children to accommodate the new layout </description> </method> <method name="get_columns" qualifiers="const"> <return type="int"> </return> <description> + Returns the number of columns in this container </description> </method> </methods> @@ -13895,6 +13934,12 @@ Returns an empty String "" at the end of the list. <description> </description> </method> + <method name="get_connection" qualifiers="const"> + <return type="StreamPeer"> + </return> + <description> + </description> + </method> <method name="request"> <return type="int"> </return> @@ -19126,6 +19171,14 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) Set the mesh of the item. </description> </method> + <method name="set_item_navmesh"> + <argument index="0" name="id" type="int"> + </argument> + <argument index="1" name="navmesh" type="NavigationMesh"> + </argument> + <description> + </description> + </method> <method name="set_item_shape"> <argument index="0" name="id" type="int"> </argument> @@ -19152,6 +19205,14 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) Return the mesh of the item. </description> </method> + <method name="get_item_navmesh" qualifiers="const"> + <return type="NavigationMesh"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <description> + </description> + </method> <method name="get_item_shape" qualifiers="const"> <return type="Shape"> </return> @@ -27133,80 +27194,94 @@ This method controls whether the position between two cached points is interpola </class> <class name="Polygon2D" inherits="Node2D" category="Core"> <brief_description> + 2D polygon representation </brief_description> <description> + A Polygon2D is defined by a set of n points connected together by line segments, meaning that the point 1 will be connected with point 2, point 2 with point 3 ..., point n-1 with point n and point n with point 1 in order to close the loop and define a plane. </description> <methods> <method name="set_polygon"> <argument index="0" name="polygon" type="Vector2Array"> </argument> <description> + Defines the set of points that will represent the polygon. </description> </method> <method name="get_polygon" qualifiers="const"> <return type="Vector2Array"> </return> <description> + Returns the set of points that defines this polygon </description> </method> <method name="set_uv"> <argument index="0" name="uv" type="Vector2Array"> </argument> <description> + Sets the uv value for every point of the polygon </description> </method> <method name="get_uv" qualifiers="const"> <return type="Vector2Array"> </return> <description> + Returns the uv value associated with every point of the polygon </description> </method> <method name="set_color"> <argument index="0" name="color" type="Color"> </argument> <description> + Sets the polygon fill color, if the polygon has a texture defined, the defined texture will be tinted to the polygon fill color. </description> </method> <method name="get_color" qualifiers="const"> <return type="Color"> </return> <description> + Returns the polygon fill color </description> </method> <method name="set_texture"> <argument index="0" name="texture" type="Object"> </argument> <description> + Sets the polygon texture. </description> </method> <method name="get_texture" qualifiers="const"> <return type="Object"> </return> <description> + Returns the polygon texture </description> </method> <method name="set_texture_offset"> <argument index="0" name="texture_offset" type="Vector2"> </argument> <description> + Sets the offset of the polygon texture. Initially the texture will appear anchored to the polygon position, the offset is used to move the texture location away from that point (notice that the texture origin is set to its top left corner, so when offset is 0,0 the top left corner of the texture is at the polygon position), for example setting the offset to 10, 10 will move the texture 10 units to the left and 10 units to the top. </description> </method> <method name="get_texture_offset" qualifiers="const"> <return type="Vector2"> </return> <description> + Returns the polygon texture offset </description> </method> <method name="set_texture_rotation"> <argument index="0" name="texture_rotation" type="float"> </argument> <description> + Sets the amount of rotation of the polygon texture, [code]texture_rotation[/code] is specified in degrees and clockwise rotation, meaning that if the texture rotation is set to 45 degrees, the texture will be rotated 45 degrees clockwise along the polygon position plus the texture offset. </description> </method> <method name="get_texture_rotation" qualifiers="const"> <return type="float"> </return> <description> + Returns the rotation in degrees of the texture polygon </description> </method> <method name="set_texture_scale"> @@ -27225,12 +27300,14 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="invert" type="bool"> </argument> <description> + Sets the polygon as the defined polygon bounding box minus the defined polygon (the defined polygon will appear as a hole on square that contains the defined polygon). </description> </method> <method name="get_invert" qualifiers="const"> <return type="bool"> </return> <description> + Returns whether this polygon is inverted or not </description> </method> <method name="set_invert_border"> @@ -27249,12 +27326,14 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="offset" type="Vector2"> </argument> <description> + Sets the amount of distance from the polygon points from the polygon position, for example if the offset is set to 10,10 then all the polygon points will move 10 units to the right and 10 units to the bottom. </description> </method> <method name="get_offset" qualifiers="const"> <return type="Vector2"> </return> <description> + Returns the polygon points offset to the polygon position. </description> </method> </methods> @@ -28480,39 +28559,45 @@ This method controls whether the position between two cached points is interpola </class> <class name="RayCast2D" inherits="Node2D" category="Core"> <brief_description> + Query the closest object intersecting a ray </brief_description> <description> + A RayCast2D represents a line from its origin to its destination position [code]cast_to[/code], it is used to query the 2D space in order to find the closest object intersecting with the ray. </description> <methods> <method name="set_enabled"> <argument index="0" name="enabled" type="bool"> </argument> <description> + Enables the RayCast2D. Only enabled raycasts will be able to query the space and report collisions. </description> </method> <method name="is_enabled" qualifiers="const"> <return type="bool"> </return> <description> + Returns whether this raycast is enabled or not </description> </method> <method name="set_cast_to"> <argument index="0" name="local_point" type="Vector2"> </argument> <description> + Sets the ray destination point, so that the ray will test from the ray's origin to [code]local_point[/code] </description> </method> <method name="get_cast_to" qualifiers="const"> <return type="Vector2"> </return> <description> + Return the destination point of this ray object </description> </method> <method name="is_colliding" qualifiers="const"> <return type="bool"> </return> <description> - Return whether the closest object the ray is pointing to is colliding with the vector, with the vector length considered. + Return whether the closest object the ray is pointing to is colliding with the vector (considering the vector length). </description> </method> <method name="get_collider" qualifiers="const"> @@ -28526,18 +28611,21 @@ This method controls whether the position between two cached points is interpola <return type="int"> </return> <description> + Returns the collision shape of the closest object the ray is pointing to. </description> </method> <method name="get_collision_point" qualifiers="const"> <return type="Vector2"> </return> <description> + Returns the collision point in which the ray intersects the closest object. </description> </method> <method name="get_collision_normal" qualifiers="const"> <return type="Vector2"> </return> <description> + Returns the normal of the intersecting object shape face containing the collision point. </description> </method> <method name="add_exception_rid"> @@ -28550,6 +28638,7 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="node" type="Object"> </argument> <description> + Adds a collision exception so the ray does not report collisions with the specified [code]node[/code]. </description> </method> <method name="remove_exception_rid"> @@ -28562,10 +28651,12 @@ This method controls whether the position between two cached points is interpola <argument index="0" name="node" type="Object"> </argument> <description> + Removes a collision exception so the ray does report collisions with the specified [code]node[/code]. </description> </method> <method name="clear_exceptions"> <description> + Removes all collision exception for this ray. </description> </method> <method name="set_layer_mask"> @@ -28578,6 +28669,7 @@ This method controls whether the position between two cached points is interpola <return type="int"> </return> <description> + Returns the layer mask for this ray. </description> </method> <method name="set_type_mask"> @@ -36094,6 +36186,22 @@ This method controls whether the position between two cached points is interpola <description> </description> </method> + <method name="add_triangle_fan"> + <argument index="0" name="vertexes" type="Vector3Array"> + </argument> + <argument index="1" name="uvs" type="Vector2Array" default="[Vector2Array]"> + </argument> + <argument index="2" name="colors" type="ColorArray" default="ColorArray([ColorArray])"> + </argument> + <argument index="3" name="uv2s" type="Vector2Array" default="[Vector2Array]"> + </argument> + <argument index="4" name="normals" type="Vector3Array" default="Vector3Array()"> + </argument> + <argument index="5" name="tangents" type="Array" default="Array()"> + </argument> + <description> + </description> + </method> <method name="set_material"> <argument index="0" name="material" type="Material"> </argument> @@ -37336,6 +37444,12 @@ This method controls whether the position between two cached points is interpola <description> </description> </method> + <method name="get_stylebox_types" qualifiers="const"> + <return type="StringArray"> + </return> + <description> + </description> + </method> <method name="set_font"> <argument index="0" name="name" type="String"> </argument> @@ -40149,6 +40263,7 @@ This method controls whether the position between two cached points is interpola Vector used for 2D Math. </brief_description> <description> + 2-element structure that can be used to represent positions in 2d-space, or any other pair of numeric values. </description> <methods> <method name="angle"> @@ -43248,14 +43363,17 @@ This method controls whether the position between two cached points is interpola </class> <class name="WeakRef" inherits="Reference" category="Core"> <brief_description> + Holds an [Object], but does not contribute to the reference count if the object is a reference. </brief_description> <description> + A weakref can hold a [Reference], without contributing to the reference counter. A weakref can be created from an [Object] using [method @GDScript.weakref]. If this object is not a reference, weakref still works, however, it does not have any effect on the object. Weakrefs are useful in cases where multiple classes have variables that refer to eachother. Without weakrefs, using these classes could lead to memory leaks, since both references keep eachother from being released. Making part of the variables a weakref can prevent this cyclic dependency, and allows the references to be released. </description> <methods> <method name="get_ref" qualifiers="const"> <return type="Object"> </return> <description> + Returns the [Object] this weakref is referring to. </description> </method> </methods> diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp index c732dd54cf..211c5961b0 100644 --- a/scene/animation/animation_tree_player.cpp +++ b/scene/animation/animation_tree_player.cpp @@ -139,6 +139,11 @@ bool AnimationTreePlayer::_set(const StringName& p_name, const Variant& p_value) animation_node_set_master_animation(id,node.get_valid("from")); else animation_node_set_animation(id,node.get_valid("animation")); + Array filters= node.get_valid("filter"); + for(int i=0;i<filters.size();i++) { + + animation_node_set_filter_path(id,filters[i],true); + } } break; case NODE_ONESHOT: { @@ -276,6 +281,15 @@ bool AnimationTreePlayer::_get(const StringName& p_name,Variant &r_ret) const { } else { node["animation"]=an->animation; } + Array k; + List<NodePath> keys; + an->filter.get_key_list(&keys); + k.resize(keys.size()); + int i=0; + for(List<NodePath>::Element *E=keys.front();E;E=E->next()) { + k[i++]=E->get(); + } + node["filter"]=k; } break; case NODE_ONESHOT: { OneShotNode *osn = static_cast<OneShotNode*>(n); @@ -439,7 +453,6 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode //transform to seconds... - switch(nb->type) { case NODE_OUTPUT: { @@ -464,7 +477,7 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode an->time=p_time; an->step=0; } else { - an->time+=p_time; + an->time=MAX(0,an->time+p_time); an->step=p_time; } @@ -482,14 +495,12 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode an->skip=true; for (List<AnimationNode::TrackRef>::Element *E=an->tref.front();E;E=E->next()) { - - if (p_filter && p_filter->has(an->animation->track_get_path(E->get().local_track))) { - - if (p_reverse_weight<0) - E->get().weight=0; - else - E->get().weight=p_reverse_weight; - + NodePath track_path = an->animation->track_get_path(E->get().local_track); + if (p_filter && p_filter->has(track_path)) { + E->get().weight = MAX(0, p_reverse_weight); + } else if(an->filter.has(track_path)) { + E->get().weight = 0; + E->get().track->skip = true; } else { E->get().weight=p_weight; } @@ -552,18 +563,17 @@ float AnimationTreePlayer::_process_node(const StringName& p_node,AnimationNode float main_rem; float os_rem; + float os_reverse_weight = p_reverse_weight; if (!osn->filter.empty()) { - - main_rem = _process_node(osn->inputs[0].node,r_prev_anim,(osn->mix?p_weight:p_weight*(1.0-blend)),p_time,p_seek,&osn->filter,p_weight); - os_rem = _process_node(osn->inputs[1].node,r_prev_anim,p_weight*blend,p_time,os_seek,&osn->filter,-1); - - } else { - - main_rem = _process_node(osn->inputs[0].node,r_prev_anim,(osn->mix?p_weight:p_weight*(1.0-blend)),p_time,p_seek); - os_rem = _process_node(osn->inputs[1].node,r_prev_anim,p_weight*blend,p_time,os_seek); + p_filter = &osn->filter; + p_reverse_weight = p_weight; + os_reverse_weight = -1; } + main_rem = _process_node(osn->inputs[0].node,r_prev_anim,(osn->mix?p_weight:p_weight*(1.0-blend)),p_time,p_seek,p_filter,p_reverse_weight); + os_rem = _process_node(osn->inputs[1].node,r_prev_anim,p_weight*blend,p_time,os_seek,p_filter,os_reverse_weight); + if (osn->start) { osn->remaining=os_rem; osn->start=false; @@ -768,6 +778,8 @@ void AnimationTreePlayer::_process_animation(float p_delta) { t.value = t.object->get(t.property); t.value.zero(); + + t.skip = false; } @@ -816,16 +828,9 @@ void AnimationTreePlayer::_process_animation(float p_delta) { if (a->value_track_is_continuous(tr.local_track)) { Variant value = a->value_track_interpolate(tr.local_track,anim_list->time); Variant::blend(tr.track->value,value,blend,tr.track->value); - tr.track->object->set(tr.track->property,tr.track->value); } else { - - List<int> indices; - a->value_track_get_key_indices(tr.local_track,anim_list->time,anim_list->step,&indices); - for(List<int>::Element *E=indices.front();E;E=E->next()) { - - Variant value = a->track_get_key_value(tr.local_track,E->get()); - tr.track->object->set(tr.track->property,value); - } + int index = a->track_find_key(tr.local_track,anim_list->time); + tr.track->value = a->track_get_key_value(tr.local_track, index); } } break; case Animation::TYPE_METHOD: { ///< Call any method on a specific node. @@ -854,11 +859,13 @@ void AnimationTreePlayer::_process_animation(float p_delta) { Track &t = E->get(); - if (!t.object) + if (t.skip || !t.object) continue; - if(t.property) // value track; was applied in step 2 + if(t.property) { // value track + t.object->set(t.property,t.value); continue; + } Transform xform; xform.basis=t.rot; @@ -983,6 +990,24 @@ void AnimationTreePlayer::animation_node_set_master_animation(const StringName& } +void AnimationTreePlayer::animation_node_set_filter_path(const StringName& p_node,const NodePath& p_track_path,bool p_filter) { + + GET_NODE( NODE_ANIMATION, AnimationNode ); + + if (p_filter) + n->filter[p_track_path]=true; + else + n->filter.erase(p_track_path); + +} + +void AnimationTreePlayer::animation_node_set_get_filtered_paths(const StringName& p_node,List<NodePath> *r_paths) const{ + + GET_NODE( NODE_ANIMATION, AnimationNode ); + + n->filter.get_key_list(r_paths); +} + void AnimationTreePlayer::oneshot_node_set_fadein_time(const StringName& p_node,float p_time) { GET_NODE( NODE_ONESHOT, OneShotNode ); @@ -1210,6 +1235,12 @@ String AnimationTreePlayer::animation_node_get_master_animation(const StringName } +bool AnimationTreePlayer::animation_node_is_path_filtered(const StringName& p_node,const NodePath& p_path) const { + + GET_NODE_V(NODE_ANIMATION, AnimationNode, 0 ); + return n->filter.has(p_path); +} + float AnimationTreePlayer::oneshot_node_get_fadein_time(const StringName& p_node) const { @@ -1750,6 +1781,7 @@ void AnimationTreePlayer::_bind_methods() { ObjectTypeDB::bind_method(_MD("animation_node_set_master_animation","id","source"),&AnimationTreePlayer::animation_node_set_master_animation); ObjectTypeDB::bind_method(_MD("animation_node_get_master_animation","id"),&AnimationTreePlayer::animation_node_get_master_animation); + ObjectTypeDB::bind_method(_MD("animation_node_set_filter_path","id","path","enable"),&AnimationTreePlayer::animation_node_set_filter_path); ObjectTypeDB::bind_method(_MD("oneshot_node_set_fadein_time","id","time_sec"),&AnimationTreePlayer::oneshot_node_set_fadein_time); ObjectTypeDB::bind_method(_MD("oneshot_node_get_fadein_time","id"),&AnimationTreePlayer::oneshot_node_get_fadein_time); diff --git a/scene/animation/animation_tree_player.h b/scene/animation/animation_tree_player.h index 2e44d69aa1..0e78281e4c 100644 --- a/scene/animation/animation_tree_player.h +++ b/scene/animation/animation_tree_player.h @@ -111,6 +111,7 @@ private: Variant value; + bool skip; }; @@ -162,6 +163,9 @@ private: float step; String from; bool skip; + + HashMap<NodePath,bool> filter; + AnimationNode() { type=NODE_ANIMATION; next=NULL; last_version=0; skip=false; } }; @@ -310,6 +314,10 @@ public: void animation_node_set_master_animation(const StringName& p_node,const String& p_master_animation); String animation_node_get_master_animation(const StringName& p_node) const; + void animation_node_set_filter_path(const StringName& p_node,const NodePath& p_filter,bool p_enable); + void animation_node_set_get_filtered_paths(const StringName& p_node,List<NodePath> *r_paths) const; + bool animation_node_is_path_filtered(const StringName& p_node,const NodePath& p_path) const; + /* ONE SHOT NODE */ void oneshot_node_set_fadein_time(const StringName& p_node,float p_time); diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index 0f3f762ba1..0f1622a838 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -227,6 +227,10 @@ void Button::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_text_align"),&Button::get_text_align); ObjectTypeDB::bind_method(_MD("is_flat"),&Button::is_flat); + BIND_CONSTANT( ALIGN_LEFT ); + BIND_CONSTANT( ALIGN_CENTER ); + BIND_CONSTANT( ALIGN_RIGHT ); + ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "text", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT_INTL ), _SCS("set_text"),_SCS("get_text") ); ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture" ), _SCS("set_button_icon"),_SCS("get_button_icon") ); ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flat" ), _SCS("set_flat"),_SCS("is_flat") ); diff --git a/scene/gui/button_array.cpp b/scene/gui/button_array.cpp index de77b83403..be48296110 100644 --- a/scene/gui/button_array.cpp +++ b/scene/gui/button_array.cpp @@ -362,10 +362,10 @@ ButtonArray::Align ButtonArray::get_align() const { } -void ButtonArray::add_button(const String& p_button) { +void ButtonArray::add_button(const String& p_text) { Button button; - button.text=p_button; + button.text=p_text; buttons.push_back(button); update(); @@ -375,10 +375,10 @@ void ButtonArray::add_button(const String& p_button) { minimum_size_changed(); } -void ButtonArray::add_icon_button(const Ref<Texture>& p_icon,const String& p_button) { +void ButtonArray::add_icon_button(const Ref<Texture>& p_icon,const String& p_text) { Button button; - button.text=p_button; + button.text=p_text; button.icon=p_icon; buttons.push_back(button); if (selected==-1) @@ -396,6 +396,7 @@ void ButtonArray::set_button_text(int p_button, const String& p_text) { minimum_size_changed(); } + void ButtonArray::set_button_icon(int p_button, const Ref<Texture>& p_icon) { ERR_FAIL_INDEX(p_button,buttons.size()); @@ -403,11 +404,13 @@ void ButtonArray::set_button_icon(int p_button, const Ref<Texture>& p_icon) { update(); minimum_size_changed(); } + String ButtonArray::get_button_text(int p_button) const { ERR_FAIL_INDEX_V(p_button,buttons.size(),""); return buttons[p_button].text; } + Ref<Texture> ButtonArray::get_button_icon(int p_button) const { ERR_FAIL_INDEX_V(p_button,buttons.size(),Ref<Texture>()); @@ -470,16 +473,16 @@ void ButtonArray::get_translatable_strings(List<String> *p_strings) const { void ButtonArray::_bind_methods() { ObjectTypeDB::bind_method(_MD("add_button","text"),&ButtonArray::add_button); - ObjectTypeDB::bind_method(_MD("add_icon_button","icon","text"),&ButtonArray::add_icon_button,DEFVAL("")); - ObjectTypeDB::bind_method(_MD("set_button_text","button","text"),&ButtonArray::set_button_text); - ObjectTypeDB::bind_method(_MD("set_button_icon","button","icon"),&ButtonArray::set_button_icon); - ObjectTypeDB::bind_method(_MD("get_button_text","button"),&ButtonArray::get_button_text); - ObjectTypeDB::bind_method(_MD("get_button_icon","button"),&ButtonArray::get_button_icon); + ObjectTypeDB::bind_method(_MD("add_icon_button","icon:Texture","text"),&ButtonArray::add_icon_button,DEFVAL("")); + ObjectTypeDB::bind_method(_MD("set_button_text","button_idx","text"),&ButtonArray::set_button_text); + ObjectTypeDB::bind_method(_MD("set_button_icon","button_idx","icon:Texture"),&ButtonArray::set_button_icon); + ObjectTypeDB::bind_method(_MD("get_button_text","button_idx"),&ButtonArray::get_button_text); + ObjectTypeDB::bind_method(_MD("get_button_icon:Texture","button_idx"),&ButtonArray::get_button_icon); ObjectTypeDB::bind_method(_MD("get_button_count"),&ButtonArray::get_button_count); ObjectTypeDB::bind_method(_MD("get_selected"),&ButtonArray::get_selected); ObjectTypeDB::bind_method(_MD("get_hovered"),&ButtonArray::get_hovered); - ObjectTypeDB::bind_method(_MD("set_selected","button"),&ButtonArray::set_selected); - ObjectTypeDB::bind_method(_MD("erase_button","button"),&ButtonArray::erase_button); + ObjectTypeDB::bind_method(_MD("set_selected","button_idx"),&ButtonArray::set_selected); + ObjectTypeDB::bind_method(_MD("erase_button","button_idx"),&ButtonArray::erase_button); ObjectTypeDB::bind_method(_MD("clear"),&ButtonArray::clear); ObjectTypeDB::bind_method(_MD("_input_event"),&ButtonArray::_input_event); @@ -490,7 +493,7 @@ void ButtonArray::_bind_methods() { BIND_CONSTANT( ALIGN_FILL ); BIND_CONSTANT( ALIGN_EXPAND_FILL ); - ADD_SIGNAL( MethodInfo("button_selected",PropertyInfo(Variant::INT,"button"))); + ADD_SIGNAL( MethodInfo("button_selected",PropertyInfo(Variant::INT,"button_idx"))); } diff --git a/tools/editor/plugins/animation_tree_editor_plugin.cpp b/tools/editor/plugins/animation_tree_editor_plugin.cpp index 08c2a1c3ae..7e1214ec83 100644 --- a/tools/editor/plugins/animation_tree_editor_plugin.cpp +++ b/tools/editor/plugins/animation_tree_editor_plugin.cpp @@ -239,8 +239,12 @@ void AnimationTreeEditor::_play_toggled() { void AnimationTreeEditor::_master_anim_menu_item(int p_item) { - String str = master_anim_popup->get_item_text(p_item); - anim_tree->animation_node_set_master_animation(edited_node,str); + if(p_item == 0) _edit_filters(); + else { + + String str = master_anim_popup->get_item_text(p_item); + anim_tree->animation_node_set_master_animation(edited_node,str); + } update(); } @@ -291,6 +295,8 @@ void AnimationTreeEditor::_popup_edit_dialog() { AnimationPlayer *ap = anim_tree->get_node(anim_tree->get_master_player())->cast_to<AnimationPlayer>(); master_anim_popup->clear(); + master_anim_popup->add_item("Edit Filters"); + master_anim_popup->add_separator(); List<StringName> sn; ap->get_animation_list(&sn); sn.sort_custom<StringName::AlphCompare>(); @@ -652,39 +658,35 @@ AnimationTreeEditor::ClickType AnimationTreeEditor::_locate_click(const Point2& float y = pos.y-style->get_offset().height; - if (y<h) - return CLICK_NODE; - y-=h; - - if (y<h) + if (y<2*h) return CLICK_NODE; + y-=2*h; - y-=h; - - int count=0; // title and name int inputs = anim_tree->node_get_input_count(node); - count += inputs?inputs:1; + int count = MAX(inputs,1); - for(int i=0;i<count;i++) { + if (inputs==0 || (pos.x > size.width/2 && type != AnimationTreePlayer::NODE_OUTPUT)) { - if (y<h) { + if (y<count*h) { - if (inputs==0 || ( type!=AnimationTreePlayer::NODE_OUTPUT && pos.x > size.width/2)) { + if (p_slot_index) + *p_slot_index=0; + return CLICK_OUTPUT_SLOT; + } + } - if (p_slot_index) - *p_slot_index=0; - return CLICK_OUTPUT_SLOT; - } else { + for(int i=0;i<count;i++) { - if (p_slot_index) - *p_slot_index=i; - return CLICK_INPUT_SLOT; - } + if (y<h) { + if (p_slot_index) + *p_slot_index=i; + return CLICK_INPUT_SLOT; } y-=h; } - return (type!=AnimationTreePlayer::NODE_OUTPUT && type!=AnimationTreePlayer::NODE_TIMESEEK)?CLICK_PARAMETER:CLICK_NODE; + bool has_parameters = type!=AnimationTreePlayer::NODE_OUTPUT && type!=AnimationTreePlayer::NODE_TIMESEEK; + return has_parameters ? CLICK_PARAMETER : CLICK_NODE; } return CLICK_NONE; @@ -1243,6 +1245,8 @@ void AnimationTreeEditor::_filter_edited() { anim_tree->oneshot_node_set_filter_path(edited_node,ed->get_metadata(0),ed->is_checked(0)); } else if (anim_tree->node_get_type(edited_node)==AnimationTreePlayer::NODE_BLEND2) { anim_tree->blend2_node_set_filter_path(edited_node,ed->get_metadata(0),ed->is_checked(0)); + } else if (anim_tree->node_get_type(edited_node)==AnimationTreePlayer::NODE_ANIMATION) { + anim_tree->animation_node_set_filter_path(edited_node,ed->get_metadata(0),ed->is_checked(0)); } } @@ -1310,6 +1314,8 @@ void AnimationTreeEditor::_edit_filters() { it->set_checked(0, anim_tree->oneshot_node_is_path_filtered(edited_node,E->get())); } else if (anim_tree->node_get_type(edited_node)==AnimationTreePlayer::NODE_BLEND2) { it->set_checked(0, anim_tree->blend2_node_is_path_filtered(edited_node,E->get())); + } else if (anim_tree->node_get_type(edited_node)==AnimationTreePlayer::NODE_ANIMATION) { + it->set_checked(0, anim_tree->animation_node_is_path_filtered(edited_node,E->get())); } pm[E->get()]=it; } |