summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/camera_2d.cpp6
-rw-r--r--scene/2d/node_2d.cpp2
-rw-r--r--scene/2d/parallax_background.cpp10
-rw-r--r--scene/2d/parallax_background.h3
-rw-r--r--scene/2d/parallax_layer.cpp20
-rw-r--r--scene/2d/parallax_layer.h4
-rw-r--r--scene/3d/particles.cpp12
-rw-r--r--scene/animation/animation_cache.cpp95
-rw-r--r--scene/animation/animation_cache.h2
-rw-r--r--scene/animation/animation_player.cpp30
-rw-r--r--scene/animation/animation_player.h2
-rw-r--r--scene/animation/animation_tree_player.cpp20
-rw-r--r--scene/animation/animation_tree_player.h6
-rw-r--r--scene/animation/tween.cpp128
-rw-r--r--scene/animation/tween.h27
-rw-r--r--scene/gui/file_dialog.cpp5
-rw-r--r--scene/gui/graph_edit.cpp22
-rw-r--r--scene/gui/graph_edit.h1
-rw-r--r--scene/gui/item_list.cpp12
-rw-r--r--scene/gui/rich_text_label.cpp10
-rw-r--r--scene/gui/scroll_container.cpp11
-rw-r--r--scene/gui/text_edit.cpp145
-rw-r--r--scene/gui/text_edit.h3
-rw-r--r--scene/gui/tree.cpp6
-rwxr-xr-xscene/main/node.cpp39
-rw-r--r--scene/main/node.h2
-rw-r--r--scene/main/viewport.cpp24
27 files changed, 408 insertions, 239 deletions
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index d65a3bfe80..3164344d15 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -52,7 +52,11 @@ void Camera2D::_update_scroll() {
if (viewport) {
viewport->set_canvas_transform(xform);
}
- get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, group_name, "_camera_moved", xform);
+
+ Size2 screen_size = viewport->get_visible_rect().size;
+ Point2 screen_offset = (anchor_mode == ANCHOR_MODE_DRAG_CENTER ? (screen_size * 0.5) : Point2());
+
+ get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, group_name, "_camera_moved", xform, screen_offset);
};
}
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index 36fbf5fda6..45f780e50e 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -433,8 +433,6 @@ void Node2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_z_as_relative", "enable"), &Node2D::set_z_as_relative);
ClassDB::bind_method(D_METHOD("is_z_relative"), &Node2D::is_z_relative);
- ClassDB::bind_method(D_METHOD("_edit_set_pivot", "pivot"), &Node2D::_edit_set_pivot);
-
ClassDB::bind_method(D_METHOD("get_relative_transform_to_parent", "parent"), &Node2D::get_relative_transform_to_parent);
ADD_GROUP("Transform", "");
diff --git a/scene/2d/parallax_background.cpp b/scene/2d/parallax_background.cpp
index a13ce6278e..b9012e37b2 100644
--- a/scene/2d/parallax_background.cpp
+++ b/scene/2d/parallax_background.cpp
@@ -47,10 +47,12 @@ void ParallaxBackground::_notification(int p_what) {
}
}
-void ParallaxBackground::_camera_moved(const Transform2D &p_transform) {
+void ParallaxBackground::_camera_moved(const Transform2D &p_transform, const Point2 &p_screen_offset) {
+
+ screen_offset = p_screen_offset;
set_scroll_scale(p_transform.get_scale().dot(Vector2(0.5, 0.5)));
- set_scroll_offset(p_transform.get_origin() / p_transform.get_scale());
+ set_scroll_offset(p_transform.get_origin());
}
void ParallaxBackground::set_scroll_scale(float p_scale) {
@@ -106,9 +108,9 @@ void ParallaxBackground::_update_scroll() {
continue;
if (ignore_camera_zoom)
- l->set_base_offset_and_scale(ofs, 1.0);
+ l->set_base_offset_and_scale(ofs, 1.0, screen_offset);
else
- l->set_base_offset_and_scale(ofs, scale);
+ l->set_base_offset_and_scale(ofs, scale, screen_offset);
}
}
diff --git a/scene/2d/parallax_background.h b/scene/2d/parallax_background.h
index 0dad1daeab..e37ec0db99 100644
--- a/scene/2d/parallax_background.h
+++ b/scene/2d/parallax_background.h
@@ -42,6 +42,7 @@ class ParallaxBackground : public CanvasLayer {
float scale;
Point2 base_offset;
Point2 base_scale;
+ Point2 screen_offset;
String group_name;
Point2 limit_begin;
Point2 limit_end;
@@ -51,7 +52,7 @@ class ParallaxBackground : public CanvasLayer {
void _update_scroll();
protected:
- void _camera_moved(const Transform2D &p_transform);
+ void _camera_moved(const Transform2D &p_transform, const Point2 &p_screen_offset);
void _notification(int p_what);
static void _bind_methods();
diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp
index 8fe651cb5f..4a69841975 100644
--- a/scene/2d/parallax_layer.cpp
+++ b/scene/2d/parallax_layer.cpp
@@ -40,7 +40,7 @@ void ParallaxLayer::set_motion_scale(const Size2 &p_scale) {
if (pb && is_inside_tree()) {
Vector2 ofs = pb->get_final_offset();
float scale = pb->get_scroll_scale();
- set_base_offset_and_scale(ofs, scale);
+ set_base_offset_and_scale(ofs, scale, screen_offset);
}
}
@@ -57,7 +57,7 @@ void ParallaxLayer::set_motion_offset(const Size2 &p_offset) {
if (pb && is_inside_tree()) {
Vector2 ofs = pb->get_final_offset();
float scale = pb->get_scroll_scale();
- set_base_offset_and_scale(ofs, scale);
+ set_base_offset_and_scale(ofs, scale, screen_offset);
}
}
@@ -106,26 +106,28 @@ void ParallaxLayer::_notification(int p_what) {
}
}
-void ParallaxLayer::set_base_offset_and_scale(const Point2 &p_offset, float p_scale) {
+void ParallaxLayer::set_base_offset_and_scale(const Point2 &p_offset, float p_scale, const Point2 &p_screen_offset) {
+ screen_offset = p_screen_offset;
if (!is_inside_tree())
return;
if (Engine::get_singleton()->is_editor_hint())
return;
- Point2 new_ofs = ((orig_offset + p_offset) * motion_scale) * p_scale + motion_offset;
+
+ Point2 new_ofs = (screen_offset + (p_offset - screen_offset) * motion_scale) + motion_offset * p_scale + orig_offset * p_scale;
+
+ Vector2 mirror = Vector2(1, 1);
if (mirroring.x) {
- double den = mirroring.x * p_scale;
- new_ofs.x -= den * ceil(new_ofs.x / den);
+ mirror.x = -1;
}
if (mirroring.y) {
- double den = mirroring.y * p_scale;
- new_ofs.y -= den * ceil(new_ofs.y / den);
+ mirror.y = -1;
}
set_position(new_ofs);
- set_scale(Vector2(1, 1) * p_scale);
+ set_scale(mirror * p_scale * orig_scale);
}
String ParallaxLayer::get_configuration_warning() const {
diff --git a/scene/2d/parallax_layer.h b/scene/2d/parallax_layer.h
index 95ca27c41a..6feb1fad67 100644
--- a/scene/2d/parallax_layer.h
+++ b/scene/2d/parallax_layer.h
@@ -43,6 +43,8 @@ class ParallaxLayer : public Node2D {
Vector2 mirroring;
void _update_mirroring();
+ Point2 screen_offset;
+
protected:
void _notification(int p_what);
static void _bind_methods();
@@ -57,7 +59,7 @@ public:
void set_mirroring(const Size2 &p_mirroring);
Size2 get_mirroring() const;
- void set_base_offset_and_scale(const Point2 &p_offset, float p_scale);
+ void set_base_offset_and_scale(const Point2 &p_offset, float p_scale, const Point2 &p_screen_offset);
virtual String get_configuration_warning() const;
ParallaxLayer();
diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp
index 915a10328b..2a032f5d96 100644
--- a/scene/3d/particles.cpp
+++ b/scene/3d/particles.cpp
@@ -836,9 +836,15 @@ void ParticlesMaterial::_update_shader() {
if (flags[FLAG_DISABLE_Z]) {
- code += " TRANSFORM[0] = vec4(cos(CUSTOM.x),-sin(CUSTOM.x),0.0,0.0);\n";
- code += " TRANSFORM[1] = vec4(sin(CUSTOM.x),cos(CUSTOM.x),0.0,0.0);\n";
- code += " TRANSFORM[2] = vec4(0.0,0.0,1.0,0.0);\n";
+ if (flags[FLAG_ALIGN_Y_TO_VELOCITY]) {
+ code += " if (length(VELOCITY) > 0.0) { TRANSFORM[1].xyz = normalize(VELOCITY); } else { TRANSFORM[1].xyz = normalize(TRANSFORM[1].xyz); }\n";
+ code += " TRANSFORM[0].xyz = normalize(cross(TRANSFORM[1].xyz,TRANSFORM[2].xyz));\n";
+ code += " TRANSFORM[2] = vec4(0.0,0.0,1.0,0.0);\n";
+ } else {
+ code += " TRANSFORM[0] = vec4(cos(CUSTOM.x),-sin(CUSTOM.x),0.0,0.0);\n";
+ code += " TRANSFORM[1] = vec4(sin(CUSTOM.x),cos(CUSTOM.x),0.0,0.0);\n";
+ code += " TRANSFORM[2] = vec4(0.0,0.0,1.0,0.0);\n";
+ }
} else {
//orient particle Y towards velocity
diff --git a/scene/animation/animation_cache.cpp b/scene/animation/animation_cache.cpp
index b35b2568d1..fbe2593362 100644
--- a/scene/animation/animation_cache.cpp
+++ b/scene/animation/animation_cache.cpp
@@ -87,95 +87,90 @@ void AnimationCache::_update_cache() {
Ref<Resource> res;
- if (np.get_subname_count()) {
-
- if (animation->track_get_type(i) == Animation::TYPE_TRANSFORM) {
+ if (animation->track_get_type(i) == Animation::TYPE_TRANSFORM) {
+ if (np.get_subname_count() > 1) {
path_cache.push_back(Path());
ERR_EXPLAIN("Transform tracks can't have a subpath: " + np);
ERR_CONTINUE(animation->track_get_type(i) == Animation::TYPE_TRANSFORM);
}
- RES res;
-
- for (int j = 0; j < np.get_subname_count(); j++) {
- res = j == 0 ? node->get(np.get_subname(j)) : res->get(np.get_subname(j));
- if (res.is_null())
- break;
- }
+ Spatial *sp = Object::cast_to<Spatial>(node);
- if (res.is_null()) {
+ if (!sp) {
path_cache.push_back(Path());
- ERR_EXPLAIN("Invalid Track SubPath in Animation: " + np);
- ERR_CONTINUE(res.is_null());
+ ERR_EXPLAIN("Transform track not of type Spatial: " + np);
+ ERR_CONTINUE(!sp);
}
- path.resource = res;
- path.object = res.ptr();
-
- } else {
-
- if (animation->track_get_type(i) == Animation::TYPE_TRANSFORM) {
- StringName property = np.get_property();
+ if (np.get_subname_count() == 1) {
+ StringName property = np.get_subname(0);
String ps = property;
- Spatial *sp = Object::cast_to<Spatial>(node);
+ Skeleton *sk = Object::cast_to<Skeleton>(node);
+ if (!sk) {
- if (!sp) {
+ path_cache.push_back(Path());
+ ERR_EXPLAIN("Property defined in Transform track, but not a Skeleton!: " + np);
+ ERR_CONTINUE(!sk);
+ }
+ int idx = sk->find_bone(ps);
+ if (idx == -1) {
path_cache.push_back(Path());
- ERR_EXPLAIN("Transform track not of type Spatial: " + np);
- ERR_CONTINUE(!sp);
+ ERR_EXPLAIN("Property defined in Transform track, but not a Skeleton Bone!: " + np);
+ ERR_CONTINUE(idx == -1);
}
- if (ps != "") {
+ path.bone_idx = idx;
+ path.skeleton = sk;
+ }
- Skeleton *sk = Object::cast_to<Skeleton>(node);
- if (!sk) {
+ path.spatial = sp;
- path_cache.push_back(Path());
- ERR_EXPLAIN("Property defined in Transform track, but not a Skeleton!: " + np);
- ERR_CONTINUE(!sk);
- }
+ } else {
+ if (np.get_subname_count() > 0) {
- int idx = sk->find_bone(ps);
- if (idx == -1) {
+ RES res;
+ Vector<StringName> leftover_subpath;
- path_cache.push_back(Path());
- ERR_EXPLAIN("Property defined in Transform track, but not a Skeleton Bone!: " + np);
- ERR_CONTINUE(idx == -1);
- }
+ // We don't want to cache the last resource unless it is a method call
+ bool is_method = animation->track_get_type(i) == Animation::TYPE_METHOD;
+ root->get_node_and_resource(np, res, leftover_subpath, is_method);
- path.bone_idx = idx;
- path.skeleton = sk;
+ if (res.is_valid()) {
+ path.resource = res;
+ } else {
+ path.node = node;
}
+ path.object = res.is_valid() ? res.ptr() : (Object *)node;
+ path.subpath = leftover_subpath;
- path.spatial = sp;
- }
+ } else {
- path.node = node;
- path.object = node;
+ path.node = node;
+ path.object = node;
+ path.subpath = np.get_subnames();
+ }
}
if (animation->track_get_type(i) == Animation::TYPE_VALUE) {
- if (np.get_property().operator String() == "") {
+ if (np.get_subname_count() == 0) {
path_cache.push_back(Path());
ERR_EXPLAIN("Value Track lacks property: " + np);
- ERR_CONTINUE(np.get_property().operator String() == "");
+ ERR_CONTINUE(np.get_subname_count() == 0);
}
- path.property = np.get_property();
-
} else if (animation->track_get_type(i) == Animation::TYPE_METHOD) {
- if (np.get_property().operator String() != "") {
+ if (path.subpath.size() != 0) { // Trying to call a method of a non-resource
path_cache.push_back(Path());
ERR_EXPLAIN("Method Track has property: " + np);
- ERR_CONTINUE(np.get_property().operator String() != "");
+ ERR_CONTINUE(path.subpath.size() != 0);
}
}
@@ -226,7 +221,7 @@ void AnimationCache::set_track_value(int p_idx, const Variant &p_value) {
return;
ERR_FAIL_COND(!p.object);
- p.object->set(p.property, p_value);
+ p.object->set_indexed(p.subpath, p_value);
}
void AnimationCache::call_track(int p_idx, const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
diff --git a/scene/animation/animation_cache.h b/scene/animation/animation_cache.h
index e593668df6..481de59730 100644
--- a/scene/animation/animation_cache.h
+++ b/scene/animation/animation_cache.h
@@ -46,7 +46,7 @@ class AnimationCache : public Object {
Spatial *spatial;
int bone_idx;
- StringName property;
+ Vector<StringName> subpath;
bool valid;
Path() {
object = NULL;
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 6be3ff88d9..010f5a586f 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -242,7 +242,8 @@ void AnimationPlayer::_generate_node_caches(AnimationData *p_anim) {
p_anim->node_cache[i] = NULL;
RES resource;
- Node *child = parent->get_node_and_resource(a->track_get_path(i), resource);
+ Vector<StringName> leftover_path;
+ Node *child = parent->get_node_and_resource(a->track_get_path(i), resource, leftover_path);
if (!child) {
ERR_EXPLAIN("On Animation: '" + p_anim->name + "', couldn't resolve track: '" + String(a->track_get_path(i)) + "'");
}
@@ -250,9 +251,9 @@ void AnimationPlayer::_generate_node_caches(AnimationData *p_anim) {
uint32_t id = resource.is_valid() ? resource->get_instance_id() : child->get_instance_id();
int bone_idx = -1;
- if (a->track_get_path(i).get_property() && Object::cast_to<Skeleton>(child)) {
+ if (a->track_get_path(i).get_subname_count() == 1 && Object::cast_to<Skeleton>(child)) {
- bone_idx = Object::cast_to<Skeleton>(child)->find_bone(a->track_get_path(i).get_property());
+ bone_idx = Object::cast_to<Skeleton>(child)->find_bone(a->track_get_path(i).get_subname(0));
if (bone_idx == -1) {
continue;
@@ -289,8 +290,8 @@ void AnimationPlayer::_generate_node_caches(AnimationData *p_anim) {
p_anim->node_cache[i]->skeleton = Object::cast_to<Skeleton>(child);
if (p_anim->node_cache[i]->skeleton) {
- StringName bone_name = a->track_get_path(i).get_property();
- if (bone_name.operator String() != "") {
+ if (a->track_get_path(i).get_subname_count() == 1) {
+ StringName bone_name = a->track_get_path(i).get_subname(0);
p_anim->node_cache[i]->bone_idx = p_anim->node_cache[i]->skeleton->find_bone(bone_name);
if (p_anim->node_cache[i]->bone_idx < 0) {
@@ -311,24 +312,23 @@ void AnimationPlayer::_generate_node_caches(AnimationData *p_anim) {
if (a->track_get_type(i) == Animation::TYPE_VALUE) {
- StringName property = a->track_get_path(i).get_property();
- if (!p_anim->node_cache[i]->property_anim.has(property)) {
+ if (!p_anim->node_cache[i]->property_anim.has(a->track_get_path(i).get_concatenated_subnames())) {
TrackNodeCache::PropertyAnim pa;
- pa.prop = property;
+ pa.subpath = leftover_path;
pa.object = resource.is_valid() ? (Object *)resource.ptr() : (Object *)child;
pa.special = SP_NONE;
pa.owner = p_anim->node_cache[i];
if (false && p_anim->node_cache[i]->node_2d) {
- if (pa.prop == SceneStringNames::get_singleton()->transform_pos)
+ if (leftover_path.size() == 1 && leftover_path[0] == SceneStringNames::get_singleton()->transform_pos)
pa.special = SP_NODE2D_POS;
- else if (pa.prop == SceneStringNames::get_singleton()->transform_rot)
+ else if (leftover_path.size() == 1 && leftover_path[0] == SceneStringNames::get_singleton()->transform_rot)
pa.special = SP_NODE2D_ROT;
- else if (pa.prop == SceneStringNames::get_singleton()->transform_scale)
+ else if (leftover_path.size() == 1 && leftover_path[0] == SceneStringNames::get_singleton()->transform_scale)
pa.special = SP_NODE2D_SCALE;
}
- p_anim->node_cache[i]->property_anim[property] = pa;
+ p_anim->node_cache[i]->property_anim[a->track_get_path(i).get_concatenated_subnames()] = pa;
}
}
}
@@ -396,7 +396,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
//StringName property=a->track_get_path(i).get_property();
- Map<StringName, TrackNodeCache::PropertyAnim>::Element *E = nc->property_anim.find(a->track_get_path(i).get_property());
+ Map<StringName, TrackNodeCache::PropertyAnim>::Element *E = nc->property_anim.find(a->track_get_path(i).get_concatenated_subnames());
ERR_CONTINUE(!E); //should it continue, or create a new one?
TrackNodeCache::PropertyAnim *pa = &E->get();
@@ -434,7 +434,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float
case SP_NONE: {
bool valid;
- pa->object->set(pa->prop, value, &valid); //you are not speshul
+ pa->object->set_indexed(pa->subpath, value, &valid); //you are not speshul
#ifdef DEBUG_ENABLED
if (!valid) {
ERR_PRINTS("Failed setting track value '" + String(pa->owner->path) + "'. Check if property exists or the type of key is valid. Animation '" + a->get_name() + "' at node '" + get_path() + "'.");
@@ -622,7 +622,7 @@ void AnimationPlayer::_animation_update_transforms() {
case SP_NONE: {
bool valid;
- pa->object->set(pa->prop, pa->value_accum, &valid); //you are not speshul
+ pa->object->set_indexed(pa->subpath, pa->value_accum, &valid); //you are not speshul
#ifdef DEBUG_ENABLED
if (!valid) {
ERR_PRINTS("Failed setting key at time " + rtos(playback.current.pos) + " in Animation '" + get_current_animation() + "' at Node '" + get_path() + "', Track '" + String(pa->owner->path) + "'. Check if property exists or the type of key is right for the property");
diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h
index 83da3b2e5c..e4e021c7fe 100644
--- a/scene/animation/animation_player.h
+++ b/scene/animation/animation_player.h
@@ -83,7 +83,7 @@ private:
TrackNodeCache *owner;
SpecialProperty special; //small optimization
- StringName prop;
+ Vector<StringName> subpath;
Object *object;
Variant value_accum;
uint64_t accum_pass;
diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp
index ad5329c94b..23eccec82f 100644
--- a/scene/animation/animation_tree_player.cpp
+++ b/scene/animation/animation_tree_player.cpp
@@ -811,7 +811,7 @@ void AnimationTreePlayer::_process_animation(float p_delta) {
t.scale.y = 0;
t.scale.z = 0;
- t.value = t.object->get(t.property);
+ t.value = t.object->get_indexed(t.subpath);
t.value.zero();
t.skip = false;
@@ -890,8 +890,8 @@ void AnimationTreePlayer::_process_animation(float p_delta) {
if (t.skip || !t.object)
continue;
- if (t.property) { // value track
- t.object->set(t.property, t.value);
+ if (t.subpath.size()) { // value track
+ t.object->set_indexed(t.subpath, t.value);
continue;
}
@@ -1475,7 +1475,8 @@ AnimationTreePlayer::Track *AnimationTreePlayer::_find_track(const NodePath &p_p
ERR_FAIL_COND_V(!parent, NULL);
RES resource;
- Node *child = parent->get_node_and_resource(p_path, resource);
+ Vector<StringName> leftover_path;
+ Node *child = parent->get_node_and_resource(p_path, resource, leftover_path);
if (!child) {
String err = "Animation track references unknown Node: '" + String(p_path) + "'.";
WARN_PRINT(err.ascii().get_data());
@@ -1483,21 +1484,18 @@ AnimationTreePlayer::Track *AnimationTreePlayer::_find_track(const NodePath &p_p
}
ObjectID id = child->get_instance_id();
- StringName property;
int bone_idx = -1;
- if (p_path.get_property()) {
+ if (p_path.get_subname_count()) {
if (Object::cast_to<Skeleton>(child))
- bone_idx = Object::cast_to<Skeleton>(child)->find_bone(p_path.get_property());
- if (bone_idx == -1)
- property = p_path.get_property();
+ bone_idx = Object::cast_to<Skeleton>(child)->find_bone(p_path.get_subname(0));
}
TrackKey key;
key.id = id;
key.bone_idx = bone_idx;
- key.property = property;
+ key.subpath_concatenated = p_path.get_concatenated_subnames();
if (!track_map.has(key)) {
@@ -1507,7 +1505,7 @@ AnimationTreePlayer::Track *AnimationTreePlayer::_find_track(const NodePath &p_p
tr.skeleton = Object::cast_to<Skeleton>(child);
tr.spatial = Object::cast_to<Spatial>(child);
tr.bone_idx = bone_idx;
- tr.property = property;
+ if (bone_idx == -1) tr.subpath = leftover_path;
track_map[key] = tr;
}
diff --git a/scene/animation/animation_tree_player.h b/scene/animation/animation_tree_player.h
index 3e2bb88198..c49b0c4d1b 100644
--- a/scene/animation/animation_tree_player.h
+++ b/scene/animation/animation_tree_player.h
@@ -78,14 +78,14 @@ private:
struct TrackKey {
uint32_t id;
- StringName property;
+ StringName subpath_concatenated;
int bone_idx;
inline bool operator<(const TrackKey &p_right) const {
if (id == p_right.id) {
if (bone_idx == p_right.bone_idx) {
- return property < p_right.property;
+ return subpath_concatenated < p_right.subpath_concatenated;
} else
return bone_idx < p_right.bone_idx;
} else
@@ -99,7 +99,7 @@ private:
Spatial *spatial;
Skeleton *skeleton;
int bone_idx;
- StringName property;
+ Vector<StringName> subpath;
Vector3 loc;
Quat rot;
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index 40d06dc756..151632a0cb 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -264,12 +264,12 @@ Variant &Tween::_get_initial_val(InterpolateData &p_data) {
if (p_data.type == TARGETING_PROPERTY) {
bool valid = false;
- initial_val = object->get(p_data.target_key, &valid);
+ initial_val = object->get_indexed(p_data.target_key, &valid);
ERR_FAIL_COND_V(!valid, p_data.initial_val);
} else {
Variant::CallError error;
- initial_val = object->call(p_data.target_key, NULL, 0, error);
+ initial_val = object->call(p_data.target_key[0], NULL, 0, error);
ERR_FAIL_COND_V(error.error != Variant::CallError::CALL_OK, p_data.initial_val);
}
return initial_val;
@@ -296,12 +296,12 @@ Variant &Tween::_get_delta_val(InterpolateData &p_data) {
if (p_data.type == FOLLOW_PROPERTY) {
bool valid = false;
- final_val = target->get(p_data.target_key, &valid);
+ final_val = target->get_indexed(p_data.target_key, &valid);
ERR_FAIL_COND_V(!valid, p_data.initial_val);
} else {
Variant::CallError error;
- final_val = target->call(p_data.target_key, NULL, 0, error);
+ final_val = target->call(p_data.target_key[0], NULL, 0, error);
ERR_FAIL_COND_V(error.error != Variant::CallError::CALL_OK, p_data.initial_val);
}
@@ -462,6 +462,9 @@ Variant Tween::_run_equation(InterpolateData &p_data) {
result = r;
} break;
+ default: {
+ result = initial_val;
+ } break;
};
#undef APPLY_EQUATION
@@ -479,7 +482,7 @@ bool Tween::_apply_tween_value(InterpolateData &p_data, Variant &value) {
case FOLLOW_PROPERTY:
case TARGETING_PROPERTY: {
bool valid = false;
- object->set(p_data.key, value, &valid);
+ object->set_indexed(p_data.key, value, &valid);
return valid;
}
@@ -489,9 +492,9 @@ bool Tween::_apply_tween_value(InterpolateData &p_data, Variant &value) {
Variant::CallError error;
if (value.get_type() != Variant::NIL) {
Variant *arg[1] = { &value };
- object->call(p_data.key, (const Variant **)arg, 1, error);
+ object->call(p_data.key[0], (const Variant **)arg, 1, error);
} else {
- object->call(p_data.key, NULL, 0, error);
+ object->call(p_data.key[0], NULL, 0, error);
}
if (error.error == Variant::CallError::CALL_OK)
@@ -548,7 +551,7 @@ void Tween::_tween_process(float p_delta) {
continue;
else if (prev_delaying) {
- emit_signal("tween_started", object, data.key);
+ emit_signal("tween_started", object, NodePath(Vector<StringName>(), data.key, false));
_apply_tween_value(data, data.initial_val);
}
@@ -562,7 +565,7 @@ void Tween::_tween_process(float p_delta) {
case INTER_PROPERTY:
case INTER_METHOD: {
Variant result = _run_equation(data);
- emit_signal("tween_step", object, data.key, data.elapsed, result);
+ emit_signal("tween_step", object, NodePath(Vector<StringName>(), data.key, false), data.elapsed, result);
_apply_tween_value(data, result);
if (data.finish)
_apply_tween_value(data, data.final_val);
@@ -574,22 +577,22 @@ void Tween::_tween_process(float p_delta) {
switch (data.args) {
case 0:
- object->call_deferred(data.key);
+ object->call_deferred(data.key[0]);
break;
case 1:
- object->call_deferred(data.key, data.arg[0]);
+ object->call_deferred(data.key[0], data.arg[0]);
break;
case 2:
- object->call_deferred(data.key, data.arg[0], data.arg[1]);
+ object->call_deferred(data.key[0], data.arg[0], data.arg[1]);
break;
case 3:
- object->call_deferred(data.key, data.arg[0], data.arg[1], data.arg[2]);
+ object->call_deferred(data.key[0], data.arg[0], data.arg[1], data.arg[2]);
break;
case 4:
- object->call_deferred(data.key, data.arg[0], data.arg[1], data.arg[2], data.arg[3]);
+ object->call_deferred(data.key[0], data.arg[0], data.arg[1], data.arg[2], data.arg[3]);
break;
case 5:
- object->call_deferred(data.key, data.arg[0], data.arg[1], data.arg[2], data.arg[3], data.arg[4]);
+ object->call_deferred(data.key[0], data.arg[0], data.arg[1], data.arg[2], data.arg[3], data.arg[4]);
break;
}
} else {
@@ -601,17 +604,18 @@ void Tween::_tween_process(float p_delta) {
&data.arg[3],
&data.arg[4],
};
- object->call(data.key, (const Variant **)arg, data.args, error);
+ object->call(data.key[0], (const Variant **)arg, data.args, error);
}
}
break;
+ default: {}
}
if (data.finish) {
- emit_signal("tween_completed", object, data.key);
+ emit_signal("tween_completed", object, NodePath(Vector<StringName>(), data.key, false));
// not repeat mode, remove completed action
if (!repeat)
- call_deferred("_remove", object, data.key, true);
+ call_deferred("_remove", object, NodePath(Vector<StringName>(), data.key, false), true);
}
}
pending_update--;
@@ -690,7 +694,7 @@ bool Tween::start() {
return true;
}
-bool Tween::reset(Object *p_object, String p_key) {
+bool Tween::reset(Object *p_object, StringName p_key) {
pending_update++;
for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
@@ -700,7 +704,7 @@ bool Tween::reset(Object *p_object, String p_key) {
if (object == NULL)
continue;
- if (object == p_object && (data.key == p_key || p_key == "")) {
+ if (object == p_object && (data.concatenated_key == p_key || p_key == "")) {
data.elapsed = 0;
data.finish = false;
@@ -727,7 +731,7 @@ bool Tween::reset_all() {
return true;
}
-bool Tween::stop(Object *p_object, String p_key) {
+bool Tween::stop(Object *p_object, StringName p_key) {
pending_update++;
for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
@@ -736,7 +740,7 @@ bool Tween::stop(Object *p_object, String p_key) {
Object *object = ObjectDB::get_instance(data.id);
if (object == NULL)
continue;
- if (object == p_object && (data.key == p_key || p_key == ""))
+ if (object == p_object && (data.concatenated_key == p_key || p_key == ""))
data.active = false;
}
pending_update--;
@@ -758,7 +762,7 @@ bool Tween::stop_all() {
return true;
}
-bool Tween::resume(Object *p_object, String p_key) {
+bool Tween::resume(Object *p_object, StringName p_key) {
set_active(true);
_set_process(true);
@@ -770,7 +774,7 @@ bool Tween::resume(Object *p_object, String p_key) {
Object *object = ObjectDB::get_instance(data.id);
if (object == NULL)
continue;
- if (object == p_object && (data.key == p_key || p_key == ""))
+ if (object == p_object && (data.concatenated_key == p_key || p_key == ""))
data.active = true;
}
pending_update--;
@@ -792,12 +796,12 @@ bool Tween::resume_all() {
return true;
}
-bool Tween::remove(Object *p_object, String p_key) {
+bool Tween::remove(Object *p_object, StringName p_key) {
_remove(p_object, p_key, false);
return true;
}
-void Tween::_remove(Object *p_object, String p_key, bool first_only) {
+void Tween::_remove(Object *p_object, StringName p_key, bool first_only) {
if (pending_update != 0) {
call_deferred("_remove", p_object, p_key, first_only);
@@ -810,7 +814,7 @@ void Tween::_remove(Object *p_object, String p_key, bool first_only) {
Object *object = ObjectDB::get_instance(data.id);
if (object == NULL)
continue;
- if (object == p_object && (data.key == p_key || p_key == "")) {
+ if (object == p_object && (data.concatenated_key == p_key || p_key == "")) {
for_removal.push_back(E);
if (first_only) {
break;
@@ -850,8 +854,9 @@ bool Tween::seek(real_t p_time) {
data.finish = true;
data.elapsed = (data.delay + data.duration);
- } else
+ } else {
data.finish = false;
+ }
switch (data.type) {
case INTER_PROPERTY:
@@ -993,11 +998,15 @@ bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final
return true;
}
-bool Tween::interpolate_property(Object *p_object, String p_property, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
+bool Tween::interpolate_property(Object *p_object, NodePath p_property, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
if (pending_update != 0) {
_add_pending_command("interpolate_property", p_object, p_property, p_initial_val, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay);
return true;
}
+ p_property = p_property.get_as_property_path();
+
+ if (p_initial_val.get_type() == Variant::NIL) p_initial_val = p_object->get_indexed(p_property.get_subnames());
+
// convert INT to REAL is better for interpolaters
if (p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t();
if (p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t();
@@ -1011,7 +1020,7 @@ bool Tween::interpolate_property(Object *p_object, String p_property, Variant p_
ERR_FAIL_COND_V(p_delay < 0, false);
bool prop_valid = false;
- p_object->get(p_property, &prop_valid);
+ p_object->get_indexed(p_property.get_subnames(), &prop_valid);
ERR_FAIL_COND_V(!prop_valid, false);
InterpolateData data;
@@ -1021,7 +1030,8 @@ bool Tween::interpolate_property(Object *p_object, String p_property, Variant p_
data.elapsed = 0;
data.id = p_object->get_instance_id();
- data.key = p_property;
+ data.key = p_property.get_subnames();
+ data.concatenated_key = p_property.get_concatenated_subnames();
data.initial_val = p_initial_val;
data.final_val = p_final_val;
data.duration = p_duration;
@@ -1036,7 +1046,7 @@ bool Tween::interpolate_property(Object *p_object, String p_property, Variant p_
return true;
}
-bool Tween::interpolate_method(Object *p_object, String p_method, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
+bool Tween::interpolate_method(Object *p_object, StringName p_method, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
if (pending_update != 0) {
_add_pending_command("interpolate_method", p_object, p_method, p_initial_val, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay);
return true;
@@ -1063,7 +1073,8 @@ bool Tween::interpolate_method(Object *p_object, String p_method, Variant p_init
data.elapsed = 0;
data.id = p_object->get_instance_id();
- data.key = p_method;
+ data.key.push_back(p_method);
+ data.concatenated_key = p_method;
data.initial_val = p_initial_val;
data.final_val = p_final_val;
data.duration = p_duration;
@@ -1100,7 +1111,8 @@ bool Tween::interpolate_callback(Object *p_object, real_t p_duration, String p_c
data.elapsed = 0;
data.id = p_object->get_instance_id();
- data.key = p_callback;
+ data.key.push_back(p_callback);
+ data.concatenated_key = p_callback;
data.duration = p_duration;
data.delay = 0;
@@ -1152,7 +1164,8 @@ bool Tween::interpolate_deferred_callback(Object *p_object, real_t p_duration, S
data.elapsed = 0;
data.id = p_object->get_instance_id();
- data.key = p_callback;
+ data.key.push_back(p_callback);
+ data.concatenated_key = p_callback;
data.duration = p_duration;
data.delay = 0;
@@ -1183,11 +1196,16 @@ bool Tween::interpolate_deferred_callback(Object *p_object, real_t p_duration, S
return true;
}
-bool Tween::follow_property(Object *p_object, String p_property, Variant p_initial_val, Object *p_target, String p_target_property, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
+bool Tween::follow_property(Object *p_object, NodePath p_property, Variant p_initial_val, Object *p_target, NodePath p_target_property, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
if (pending_update != 0) {
_add_pending_command("follow_property", p_object, p_property, p_initial_val, p_target, p_target_property, p_duration, p_trans_type, p_ease_type, p_delay);
return true;
}
+ p_property = p_property.get_as_property_path();
+ p_target_property = p_target_property.get_as_property_path();
+
+ if (p_initial_val.get_type() == Variant::NIL) p_initial_val = p_object->get_indexed(p_property.get_subnames());
+
// convert INT to REAL is better for interpolaters
if (p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t();
@@ -1201,11 +1219,11 @@ bool Tween::follow_property(Object *p_object, String p_property, Variant p_initi
ERR_FAIL_COND_V(p_delay < 0, false);
bool prop_valid = false;
- p_object->get(p_property, &prop_valid);
+ p_object->get_indexed(p_property.get_subnames(), &prop_valid);
ERR_FAIL_COND_V(!prop_valid, false);
bool target_prop_valid = false;
- Variant target_val = p_target->get(p_target_property, &target_prop_valid);
+ Variant target_val = p_target->get_indexed(p_target_property.get_subnames(), &target_prop_valid);
ERR_FAIL_COND_V(!target_prop_valid, false);
// convert INT to REAL is better for interpolaters
@@ -1219,10 +1237,11 @@ bool Tween::follow_property(Object *p_object, String p_property, Variant p_initi
data.elapsed = 0;
data.id = p_object->get_instance_id();
- data.key = p_property;
+ data.key = p_property.get_subnames();
+ data.concatenated_key = p_property.get_concatenated_subnames();
data.initial_val = p_initial_val;
data.target_id = p_target->get_instance_id();
- data.target_key = p_target_property;
+ data.target_key = p_target_property.get_subnames();
data.duration = p_duration;
data.trans_type = p_trans_type;
data.ease_type = p_ease_type;
@@ -1232,7 +1251,7 @@ bool Tween::follow_property(Object *p_object, String p_property, Variant p_initi
return true;
}
-bool Tween::follow_method(Object *p_object, String p_method, Variant p_initial_val, Object *p_target, String p_target_method, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
+bool Tween::follow_method(Object *p_object, StringName p_method, Variant p_initial_val, Object *p_target, StringName p_target_method, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
if (pending_update != 0) {
_add_pending_command("follow_method", p_object, p_method, p_initial_val, p_target, p_target_method, p_duration, p_trans_type, p_ease_type, p_delay);
return true;
@@ -1269,10 +1288,11 @@ bool Tween::follow_method(Object *p_object, String p_method, Variant p_initial_v
data.elapsed = 0;
data.id = p_object->get_instance_id();
- data.key = p_method;
+ data.key.push_back(p_method);
+ data.concatenated_key = p_method;
data.initial_val = p_initial_val;
data.target_id = p_target->get_instance_id();
- data.target_key = p_target_method;
+ data.target_key.push_back(p_target_method);
data.duration = p_duration;
data.trans_type = p_trans_type;
data.ease_type = p_ease_type;
@@ -1282,11 +1302,15 @@ bool Tween::follow_method(Object *p_object, String p_method, Variant p_initial_v
return true;
}
-bool Tween::targeting_property(Object *p_object, String p_property, Object *p_initial, String p_initial_property, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
+bool Tween::targeting_property(Object *p_object, NodePath p_property, Object *p_initial, NodePath p_initial_property, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
+
if (pending_update != 0) {
_add_pending_command("targeting_property", p_object, p_property, p_initial, p_initial_property, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay);
return true;
}
+ p_property = p_property.get_as_property_path();
+ p_initial_property = p_initial_property.get_as_property_path();
+
// convert INT to REAL is better for interpolaters
if (p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t();
@@ -1300,11 +1324,11 @@ bool Tween::targeting_property(Object *p_object, String p_property, Object *p_in
ERR_FAIL_COND_V(p_delay < 0, false);
bool prop_valid = false;
- p_object->get(p_property, &prop_valid);
+ p_object->get_indexed(p_property.get_subnames(), &prop_valid);
ERR_FAIL_COND_V(!prop_valid, false);
bool initial_prop_valid = false;
- Variant initial_val = p_initial->get(p_initial_property, &initial_prop_valid);
+ Variant initial_val = p_initial->get_indexed(p_initial_property.get_subnames(), &initial_prop_valid);
ERR_FAIL_COND_V(!initial_prop_valid, false);
// convert INT to REAL is better for interpolaters
@@ -1318,9 +1342,10 @@ bool Tween::targeting_property(Object *p_object, String p_property, Object *p_in
data.elapsed = 0;
data.id = p_object->get_instance_id();
- data.key = p_property;
+ data.key = p_property.get_subnames();
+ data.concatenated_key = p_property.get_concatenated_subnames();
data.target_id = p_initial->get_instance_id();
- data.target_key = p_initial_property;
+ data.target_key = p_initial_property.get_subnames();
data.initial_val = initial_val;
data.final_val = p_final_val;
data.duration = p_duration;
@@ -1335,7 +1360,7 @@ bool Tween::targeting_property(Object *p_object, String p_property, Object *p_in
return true;
}
-bool Tween::targeting_method(Object *p_object, String p_method, Object *p_initial, String p_initial_method, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
+bool Tween::targeting_method(Object *p_object, StringName p_method, Object *p_initial, StringName p_initial_method, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay) {
if (pending_update != 0) {
_add_pending_command("targeting_method", p_object, p_method, p_initial, p_initial_method, p_final_val, p_duration, p_trans_type, p_ease_type, p_delay);
return true;
@@ -1372,9 +1397,10 @@ bool Tween::targeting_method(Object *p_object, String p_method, Object *p_initia
data.elapsed = 0;
data.id = p_object->get_instance_id();
- data.key = p_method;
+ data.key.push_back(p_method);
+ data.concatenated_key = p_method;
data.target_id = p_initial->get_instance_id();
- data.target_key = p_initial_method;
+ data.target_key.push_back(p_initial_method);
data.initial_val = initial_val;
data.final_val = p_final_val;
data.duration = p_duration;
diff --git a/scene/animation/tween.h b/scene/animation/tween.h
index fac1d346b4..44710b25f9 100644
--- a/scene/animation/tween.h
+++ b/scene/animation/tween.h
@@ -86,12 +86,13 @@ private:
bool call_deferred;
real_t elapsed;
ObjectID id;
- StringName key;
+ Vector<StringName> key;
+ StringName concatenated_key;
Variant initial_val;
Variant delta_val;
Variant final_val;
ObjectID target_id;
- StringName target_key;
+ Vector<StringName> target_key;
real_t duration;
TransitionType trans_type;
EaseType ease_type;
@@ -132,7 +133,7 @@ private:
void _tween_process(float p_delta);
void _set_process(bool p_process, bool p_force = false);
- void _remove(Object *p_object, String p_key, bool first_only);
+ void _remove(Object *p_object, StringName p_key, bool first_only);
protected:
bool _set(const StringName &p_name, const Variant &p_value);
@@ -156,34 +157,34 @@ public:
float get_speed_scale() const;
bool start();
- bool reset(Object *p_object, String p_key);
+ bool reset(Object *p_object, StringName p_key);
bool reset_all();
- bool stop(Object *p_object, String p_key);
+ bool stop(Object *p_object, StringName p_key);
bool stop_all();
- bool resume(Object *p_object, String p_key);
+ bool resume(Object *p_object, StringName p_key);
bool resume_all();
- bool remove(Object *p_object, String p_key);
+ bool remove(Object *p_object, StringName p_key);
bool remove_all();
bool seek(real_t p_time);
real_t tell() const;
real_t get_runtime() const;
- bool interpolate_property(Object *p_object, String p_property, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
+ bool interpolate_property(Object *p_object, NodePath p_property, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
- bool interpolate_method(Object *p_object, String p_method, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
+ bool interpolate_method(Object *p_object, StringName p_method, Variant p_initial_val, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
bool interpolate_callback(Object *p_object, real_t p_duration, String p_callback, VARIANT_ARG_DECLARE);
bool interpolate_deferred_callback(Object *p_object, real_t p_duration, String p_callback, VARIANT_ARG_DECLARE);
- bool follow_property(Object *p_object, String p_property, Variant p_initial_val, Object *p_target, String p_target_property, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
+ bool follow_property(Object *p_object, NodePath p_property, Variant p_initial_val, Object *p_target, NodePath p_target_property, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
- bool follow_method(Object *p_object, String p_method, Variant p_initial_val, Object *p_target, String p_target_method, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
+ bool follow_method(Object *p_object, StringName p_method, Variant p_initial_val, Object *p_target, StringName p_target_method, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
- bool targeting_property(Object *p_object, String p_property, Object *p_initial, String p_initial_property, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
+ bool targeting_property(Object *p_object, NodePath p_property, Object *p_initial, NodePath p_initial_property, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
- bool targeting_method(Object *p_object, String p_method, Object *p_initial, String p_initial_method, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
+ bool targeting_method(Object *p_object, StringName p_method, Object *p_initial, StringName p_initial_method, Variant p_final_val, real_t p_duration, TransitionType p_trans_type, EaseType p_ease_type, real_t p_delay = 0);
Tween();
~Tween();
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 6ade4fcc38..6aba535572 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -323,6 +323,9 @@ void FileDialog::update_file_list() {
while ((item = dir_access->get_next(&isdir)) != "") {
+ if (item == ".")
+ continue;
+
ishidden = dir_access->current_is_hidden();
if (show_hidden || !ishidden) {
@@ -344,7 +347,7 @@ void FileDialog::update_file_list() {
while (!dirs.empty()) {
String &dir_name = dirs.front()->get();
TreeItem *ti = tree->create_item(root);
- ti->set_text(0, dir_name + "/");
+ ti->set_text(0, dir_name);
ti->set_icon(0, folder);
Dictionary d;
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 946a8c47a3..da52fb39e0 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -964,6 +964,19 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
emit_signal("delete_nodes_request");
accept_event();
}
+
+ Ref<InputEventMagnifyGesture> magnify_gesture = p_ev;
+ if (magnify_gesture.is_valid()) {
+
+ set_zoom_custom(zoom * magnify_gesture->get_factor(), magnify_gesture->get_position());
+ }
+
+ Ref<InputEventPanGesture> pan_gesture = p_ev;
+ if (pan_gesture.is_valid()) {
+
+ h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * pan_gesture->get_delta().x / 8);
+ v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * pan_gesture->get_delta().y / 8);
+ }
}
void GraphEdit::clear_connections() {
@@ -975,6 +988,11 @@ void GraphEdit::clear_connections() {
void GraphEdit::set_zoom(float p_zoom) {
+ set_zoom_custom(p_zoom, get_size() / 2);
+}
+
+void GraphEdit::set_zoom_custom(float p_zoom, const Vector2 &p_center) {
+
p_zoom = CLAMP(p_zoom, MIN_ZOOM, MAX_ZOOM);
if (zoom == p_zoom)
return;
@@ -982,7 +1000,7 @@ void GraphEdit::set_zoom(float p_zoom) {
zoom_minus->set_disabled(zoom == MIN_ZOOM);
zoom_plus->set_disabled(zoom == MAX_ZOOM);
- Vector2 sbofs = (Vector2(h_scroll->get_value(), v_scroll->get_value()) + get_size() / 2) / zoom;
+ Vector2 sbofs = (Vector2(h_scroll->get_value(), v_scroll->get_value()) + p_center) / zoom;
zoom = p_zoom;
top_layer->update();
@@ -992,7 +1010,7 @@ void GraphEdit::set_zoom(float p_zoom) {
if (is_visible_in_tree()) {
- Vector2 ofs = sbofs * zoom - get_size() / 2;
+ Vector2 ofs = sbofs * zoom - p_center;
h_scroll->set_value(ofs.x);
v_scroll->set_value(ofs.y);
}
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h
index 4656b50133..e8e530848d 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -179,6 +179,7 @@ public:
bool is_valid_connection_type(int p_type, int p_with_type) const;
void set_zoom(float p_zoom);
+ void set_zoom_custom(float p_zoom, const Vector2 &p_center);
float get_zoom() const;
GraphEditFilter *get_top_layer() const { return top_layer; }
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index e9e9dcc859..51ab49e643 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -525,6 +525,11 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
return;
}
+ if (mb->get_button_index() == BUTTON_RIGHT) {
+ emit_signal("rmb_clicked", mb->get_position());
+
+ return;
+ }
}
if (mb.is_valid() && mb->get_button_index() == BUTTON_WHEEL_UP && mb->is_pressed()) {
@@ -708,6 +713,12 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
}
}
}
+
+ Ref<InputEventPanGesture> pan_gesture = p_event;
+ if (pan_gesture.is_valid()) {
+
+ scroll_bar->set_value(scroll_bar->get_value() + scroll_bar->get_page() * pan_gesture->get_delta().y / 8);
+ }
}
void ItemList::ensure_current_is_visible() {
@@ -1397,6 +1408,7 @@ void ItemList::_bind_methods() {
ADD_SIGNAL(MethodInfo("item_rmb_selected", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::VECTOR2, "at_position")));
ADD_SIGNAL(MethodInfo("multi_selected", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::BOOL, "selected")));
ADD_SIGNAL(MethodInfo("item_activated", PropertyInfo(Variant::INT, "index")));
+ ADD_SIGNAL(MethodInfo("rmb_clicked", PropertyInfo(Variant::VECTOR2, "at_position")));
GLOBAL_DEF("gui/timers/incremental_search_max_interval_msec", 2000);
}
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 71e02cb2f7..124c268c8a 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -817,6 +817,16 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
}
}
+ Ref<InputEventPanGesture> pan_gesture = p_event;
+ if (pan_gesture.is_valid()) {
+
+ if (scroll_active)
+
+ vscroll->set_value(vscroll->get_value() + vscroll->get_page() * pan_gesture->get_delta().y * 0.5 / 8);
+
+ return;
+ }
+
Ref<InputEventKey> k = p_event;
if (k.is_valid()) {
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index 9022d67a4a..a71a1c5f92 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -180,6 +180,17 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) {
time_since_motion = 0;
}
}
+
+ Ref<InputEventPanGesture> pan_gesture = p_gui_input;
+ if (pan_gesture.is_valid()) {
+
+ if (h_scroll->is_visible_in_tree()) {
+ h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * pan_gesture->get_delta().x / 8);
+ }
+ if (v_scroll->is_visible_in_tree()) {
+ v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * pan_gesture->get_delta().y / 8);
+ }
+ }
}
void ScrollContainer::_update_scrollbar_position() {
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index c9af7eed0d..26ac4c5a7d 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -303,6 +303,8 @@ void TextEdit::_update_scrollbars() {
int total_rows = (is_hiding_enabled() ? get_total_unhidden_rows() : text.size());
if (scroll_past_end_of_file_enabled) {
total_rows += visible_rows - 1;
+ } else {
+ total_rows -= 1;
}
int vscroll_pixels = v_scroll->get_combined_minimum_size().width;
@@ -355,6 +357,10 @@ void TextEdit::_update_scrollbars() {
}
update_line_scroll_pos();
+ if (fabs(v_scroll->get_value() - get_line_scroll_pos()) >= 1) {
+ cursor.line_ofs += v_scroll->get_value() - get_line_scroll_pos();
+ }
+
} else {
cursor.line_ofs = 0;
line_scroll_pos = 0;
@@ -796,7 +802,9 @@ void TextEdit::_notification(int p_what) {
update_line_scroll_pos();
int line = cursor.line_ofs - 1;
- for (int i = 0; i < visible_rows; i++) {
+ // another row may be visible during smooth scrolling
+ int draw_amount = visible_rows + (smooth_scroll_enabled ? 1 : 0);
+ for (int i = 0; i < draw_amount; i++) {
line++;
@@ -1238,7 +1246,9 @@ void TextEdit::_notification(int p_what) {
char_ofs += char_w;
if (j == str.length() - 1 && is_folded(line)) {
- cache.folded_eol_icon->draw(ci, Point2(char_ofs + char_margin, ofs_y), Color(1, 1, 1, 1), true);
+ int yofs = (get_row_height() - cache.folded_eol_icon->get_height()) / 2;
+ int xofs = cache.folded_eol_icon->get_width() / 2;
+ cache.folded_eol_icon->draw(ci, Point2(char_ofs + char_margin + xofs, ofs_y + yofs), Color(1, 1, 1, 1));
}
}
@@ -1775,46 +1785,10 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (mb->is_pressed()) {
if (mb->get_button_index() == BUTTON_WHEEL_UP && !mb->get_command()) {
- float scroll_factor = 3 * mb->get_factor();
- if (scrolling) {
- target_v_scroll = (target_v_scroll - scroll_factor);
- } else {
- target_v_scroll = (v_scroll->get_value() - scroll_factor);
- }
-
- if (smooth_scroll_enabled) {
- if (target_v_scroll <= 0) {
- target_v_scroll = 0;
- }
- scrolling = true;
- set_physics_process(true);
- } else {
- v_scroll->set_value(target_v_scroll);
- }
+ _scroll_up(3 * mb->get_factor());
}
if (mb->get_button_index() == BUTTON_WHEEL_DOWN && !mb->get_command()) {
- float scroll_factor = 3 * mb->get_factor();
- if (scrolling) {
- target_v_scroll = (target_v_scroll + scroll_factor);
- } else {
- target_v_scroll = (v_scroll->get_value() + scroll_factor);
- }
-
- if (smooth_scroll_enabled) {
- int max_v_scroll = get_total_unhidden_rows();
- if (!scroll_past_end_of_file_enabled) {
- max_v_scroll -= get_visible_rows();
- max_v_scroll = CLAMP(max_v_scroll, 0, get_total_unhidden_rows());
- }
-
- if (target_v_scroll > max_v_scroll) {
- target_v_scroll = max_v_scroll;
- }
- scrolling = true;
- set_physics_process(true);
- } else {
- v_scroll->set_value(target_v_scroll);
- }
+ _scroll_down(3 * mb->get_factor());
}
if (mb->get_button_index() == BUTTON_WHEEL_LEFT) {
h_scroll->set_value(h_scroll->get_value() - (100 * mb->get_factor()));
@@ -1971,6 +1945,19 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
}
+ const Ref<InputEventPanGesture> pan_gesture = p_gui_input;
+ if (pan_gesture.is_valid()) {
+
+ const real_t delta = pan_gesture->get_delta().y;
+ if (delta < 0) {
+ _scroll_up(-delta);
+ } else {
+ _scroll_down(delta);
+ }
+ h_scroll->set_value(h_scroll->get_value() + pan_gesture->get_delta().x * 100);
+ return;
+ }
+
Ref<InputEventMouseMotion> mm = p_gui_input;
if (mm.is_valid()) {
@@ -3064,6 +3051,50 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
}
}
+void TextEdit::_scroll_up(real_t p_delta) {
+
+ if (scrolling) {
+ target_v_scroll = (target_v_scroll - p_delta);
+ } else {
+ target_v_scroll = (v_scroll->get_value() - p_delta);
+ }
+
+ if (smooth_scroll_enabled) {
+ if (target_v_scroll <= 0) {
+ target_v_scroll = 0;
+ }
+ scrolling = true;
+ set_physics_process(true);
+ } else {
+ v_scroll->set_value(target_v_scroll);
+ }
+}
+
+void TextEdit::_scroll_down(real_t p_delta) {
+
+ if (scrolling) {
+ target_v_scroll = (target_v_scroll + p_delta);
+ } else {
+ target_v_scroll = (v_scroll->get_value() + p_delta);
+ }
+
+ if (smooth_scroll_enabled) {
+ int max_v_scroll = get_total_unhidden_rows();
+ if (!scroll_past_end_of_file_enabled) {
+ max_v_scroll -= get_visible_rows() + 1;
+ max_v_scroll = CLAMP(max_v_scroll, 0, get_total_unhidden_rows());
+ }
+
+ if (target_v_scroll > max_v_scroll) {
+ target_v_scroll = max_v_scroll;
+ }
+ scrolling = true;
+ set_physics_process(true);
+ } else {
+ v_scroll->set_value(target_v_scroll);
+ }
+}
+
void TextEdit::_pre_shift_selection() {
if (!selection.active || selection.selecting_mode == Selection::MODE_NONE) {
@@ -3091,12 +3122,12 @@ void TextEdit::_scroll_lines_up() {
scrolling = false;
// adjust the vertical scroll
- if (get_v_scroll() > 0) {
+ if (get_v_scroll() >= 0) {
set_v_scroll(get_v_scroll() - 1);
}
// adjust the cursor
- int num_lines = num_lines_from(CLAMP(cursor.line_ofs, 0, text.size() - 1), get_visible_rows()) - 1;
+ int num_lines = num_lines_from(CLAMP(cursor.line_ofs, 0, text.size() - 1), get_visible_rows());
if (cursor.line >= cursor.line_ofs + num_lines && !selection.active) {
cursor_set_line(cursor.line_ofs + num_lines, false, false);
}
@@ -3108,7 +3139,7 @@ void TextEdit::_scroll_lines_down() {
// calculate the maximum vertical scroll position
int max_v_scroll = get_total_unhidden_rows();
if (!scroll_past_end_of_file_enabled) {
- max_v_scroll -= get_visible_rows();
+ max_v_scroll -= get_visible_rows() + 1;
max_v_scroll = CLAMP(max_v_scroll, 0, get_total_unhidden_rows());
}
@@ -3439,23 +3470,27 @@ void TextEdit::adjust_viewport_to_cursor() {
visible_width -= 20; // give it a little more space
int visible_rows = get_visible_rows();
- if (h_scroll->is_visible_in_tree())
+ if (h_scroll->is_visible_in_tree() && !scroll_past_end_of_file_enabled)
visible_rows -= ((h_scroll->get_combined_minimum_size().height - 1) / get_row_height());
int num_rows = num_lines_from(CLAMP(cursor.line_ofs, 0, text.size() - 1), MIN(visible_rows, text.size() - 1 - cursor.line_ofs));
- // if the cursor is off the screen
- if (cursor.line >= (cursor.line_ofs + MAX(num_rows, visible_rows))) {
- cursor.line_ofs = cursor.line - (num_lines_from(CLAMP(cursor.line, 0, text.size() - 1), -visible_rows) - 1);
+ // make sure the cursor is on the screen
+ if (cursor.line > (cursor.line_ofs + MAX(num_rows, visible_rows))) {
+ cursor.line_ofs = cursor.line - num_lines_from(cursor.line, -visible_rows) + 1;
}
if (cursor.line < cursor.line_ofs) {
cursor.line_ofs = cursor.line;
}
-
- // fixes deleting lines from moving the line ofs in a bad way
- if (!scroll_past_end_of_file_enabled && get_total_unhidden_rows() > visible_rows && num_rows < visible_rows) {
- cursor.line_ofs = text.size() - 1 - (num_lines_from(text.size() - 1, -visible_rows) - 1);
+ int line_ofs_max = text.size() - 1;
+ if (!scroll_past_end_of_file_enabled) {
+ line_ofs_max -= num_lines_from(text.size() - 1, -visible_rows) - 1;
+ line_ofs_max += (h_scroll->is_visible_in_tree() ? 1 : 0);
+ line_ofs_max += (cursor.line == text.size() - 1 ? 1 : 0);
}
+ line_ofs_max = MAX(line_ofs_max, 0);
+ cursor.line_ofs = CLAMP(cursor.line_ofs, 0, line_ofs_max);
+ // adjust x offset
int cursor_x = get_column_x_offset(cursor.column, text[cursor.line]);
if (cursor_x > (cursor.x_ofs + visible_width))
@@ -3464,8 +3499,9 @@ void TextEdit::adjust_viewport_to_cursor() {
if (cursor_x < cursor.x_ofs)
cursor.x_ofs = cursor_x;
+ h_scroll->set_value(cursor.x_ofs);
update_line_scroll_pos();
- v_scroll->set_value(get_line_scroll_pos() + 1);
+ v_scroll->set_value(get_line_scroll_pos());
update();
/*
get_range()->set_max(text.size());
@@ -3504,6 +3540,7 @@ void TextEdit::center_viewport_to_cursor() {
if (cursor_x < cursor.x_ofs)
cursor.x_ofs = cursor_x;
+ h_scroll->set_value(cursor.x_ofs);
update_line_scroll_pos();
v_scroll->set_value(get_line_scroll_pos());
@@ -3937,7 +3974,7 @@ void TextEdit::_update_caches() {
cache.tab_icon = get_icon("tab");
cache.folded_icon = get_icon("GuiTreeArrowRight", "EditorIcons");
cache.can_fold_icon = get_icon("GuiTreeArrowDown", "EditorIcons");
- cache.folded_eol_icon = get_icon("GuiTabMenu", "EditorIcons");
+ cache.folded_eol_icon = get_icon("GuiEllipsis", "EditorIcons");
text.set_font(cache.font);
}
@@ -4422,7 +4459,7 @@ int TextEdit::num_lines_from(int p_line_from, int unhidden_amount) const {
ERR_FAIL_INDEX_V(p_line_from, text.size(), ABS(unhidden_amount));
if (!is_hiding_enabled())
- return unhidden_amount;
+ return ABS(unhidden_amount);
int num_visible = 0;
int num_total = 0;
if (unhidden_amount >= 0) {
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index b1c7b14e58..bb9ca87d06 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -328,6 +328,9 @@ class TextEdit : public Control {
void _update_selection_mode_word();
void _update_selection_mode_line();
+ void _scroll_up(real_t p_delta);
+ void _scroll_down(real_t p_delta);
+
void _pre_shift_selection();
void _post_shift_selection();
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 749ff51f57..9213296c55 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -2612,6 +2612,12 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
} break;
}
}
+
+ Ref<InputEventPanGesture> pan_gesture = p_event;
+ if (pan_gesture.is_valid()) {
+
+ v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * pan_gesture->get_delta().y / 8);
+ }
}
bool Tree::edit_selected() {
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 253084dd99..30b831adfc 100755
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2305,7 +2305,7 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const {
copytarget = target;
if (copy && copytarget) {
- copy->connect(E->get().signal, copytarget, E->get().method, E->get().binds, CONNECT_PERSIST);
+ copy->connect(E->get().signal, copytarget, E->get().method, E->get().binds, E->get().flags);
}
}
}
@@ -2502,24 +2502,19 @@ bool Node::has_node_and_resource(const NodePath &p_path) const {
return false;
Node *node = get_node(p_path);
- if (p_path.get_subname_count()) {
+ bool result = false;
- RES r;
- for (int j = 0; j < p_path.get_subname_count(); j++) {
- r = j == 0 ? node->get(p_path.get_subname(j)) : r->get(p_path.get_subname(j));
- if (r.is_null())
- return false;
- }
- }
+ node->get_indexed(p_path.get_subnames(), &result);
- return true;
+ return result;
}
Array Node::_get_node_and_resource(const NodePath &p_path) {
Node *node;
RES res;
- node = get_node_and_resource(p_path, res);
+ Vector<StringName> leftover_path;
+ node = get_node_and_resource(p_path, res, leftover_path);
Array result;
if (node)
@@ -2532,21 +2527,35 @@ Array Node::_get_node_and_resource(const NodePath &p_path) {
else
result.push_back(Variant());
+ result.push_back(NodePath(Vector<StringName>(), leftover_path, false));
+
return result;
}
-Node *Node::get_node_and_resource(const NodePath &p_path, RES &r_res) const {
+Node *Node::get_node_and_resource(const NodePath &p_path, RES &r_res, Vector<StringName> &r_leftover_subpath, bool p_last_is_property) const {
Node *node = get_node(p_path);
r_res = RES();
+ r_leftover_subpath = Vector<StringName>();
if (!node)
return NULL;
if (p_path.get_subname_count()) {
- for (int j = 0; j < p_path.get_subname_count(); j++) {
- r_res = j == 0 ? node->get(p_path.get_subname(j)) : r_res->get(p_path.get_subname(j));
- ERR_FAIL_COND_V(r_res.is_null(), node);
+ int j = 0;
+ // If not p_last_is_property, we shouldn't consider the last one as part of the resource
+ for (; j < p_path.get_subname_count() - p_last_is_property; j++) {
+ RES new_res = j == 0 ? node->get(p_path.get_subname(j)) : r_res->get(p_path.get_subname(j));
+
+ if (new_res.is_null()) {
+ break;
+ }
+
+ r_res = new_res;
+ }
+ for (; j < p_path.get_subname_count(); j++) {
+ // Put the rest of the subpath in the leftover path
+ r_leftover_subpath.push_back(p_path.get_subname(j));
}
}
diff --git a/scene/main/node.h b/scene/main/node.h
index bd0b18c87a..2b71b71c8d 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -245,7 +245,7 @@ public:
Node *get_node(const NodePath &p_path) const;
Node *find_node(const String &p_mask, bool p_recursive = true, bool p_owned = true) const;
bool has_node_and_resource(const NodePath &p_path) const;
- Node *get_node_and_resource(const NodePath &p_path, RES &r_res) const;
+ Node *get_node_and_resource(const NodePath &p_path, RES &r_res, Vector<StringName> &r_leftover_subpath, bool p_last_is_property = true) const;
Node *get_parent() const;
_FORCE_INLINE_ SceneTree *get_tree() const {
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 0a02f471c1..1f539041fd 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -2013,6 +2013,30 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
}
}
+ Ref<InputEventGesture> gesture_event = p_event;
+ if (gesture_event.is_valid()) {
+
+ Size2 pos = gesture_event->get_position();
+
+ Control *over = _gui_find_control(pos);
+ if (over) {
+
+ if (over->can_process()) {
+
+ gesture_event = gesture_event->xformed_by(Transform2D()); //make a copy
+ if (over == gui.mouse_focus) {
+ pos = gui.focus_inv_xform.xform(pos);
+ } else {
+ pos = over->get_global_transform_with_canvas().affine_inverse().xform(pos);
+ }
+ gesture_event->set_position(pos);
+ _gui_call_input(over, gesture_event);
+ }
+ get_tree()->set_input_as_handled();
+ return;
+ }
+ }
+
Ref<InputEventScreenDrag> drag_event = p_event;
if (drag_event.is_valid()) {