summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-02-20 11:30:56 +0100
committerGitHub <noreply@github.com>2020-02-20 11:30:56 +0100
commitbd61281a5f515065b05be008dd3d6b73a03f5a7c (patch)
tree0add52fc270f808b4b2ad0bf7c970d72338c667e /scene/resources
parent1a4be2cd8fdd9ba26f016f3e2d83febfe8ae141c (diff)
parent69c95f4b4c128a22777af1e155bc24c7033decca (diff)
Merge pull request #36368 from reduz/variant-rework
Reworked signal system, added support for Callable and Signal
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/material.cpp4
-rw-r--r--scene/resources/packed_scene.cpp14
-rw-r--r--scene/resources/texture.cpp10
-rw-r--r--scene/resources/theme.cpp28
-rw-r--r--scene/resources/visual_shader.cpp8
5 files changed, 32 insertions, 32 deletions
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 341a63e9e0..246b372eb0 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -197,7 +197,7 @@ void ShaderMaterial::set_shader(const Ref<Shader> &p_shader) {
// This can be a slow operation, and `_change_notify()` (which is called by `_shader_changed()`)
// does nothing in non-editor builds anyway. See GH-34741 for details.
if (shader.is_valid() && Engine::get_singleton()->is_editor_hint()) {
- shader->disconnect("changed", this, "_shader_changed");
+ shader->disconnect_compat("changed", this, "_shader_changed");
}
shader = p_shader;
@@ -207,7 +207,7 @@ void ShaderMaterial::set_shader(const Ref<Shader> &p_shader) {
rid = shader->get_rid();
if (Engine::get_singleton()->is_editor_hint()) {
- shader->connect("changed", this, "_shader_changed");
+ shader->connect_compat("changed", this, "_shader_changed");
}
}
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index c018ab2029..910f61b956 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -331,7 +331,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
binds.write[j] = props[c.binds[j]];
}
- cfrom->connect(snames[c.signal], cto, snames[c.method], binds, CONNECT_PERSIST | c.flags);
+ cfrom->connect_compat(snames[c.signal], cto, snames[c.method], binds, CONNECT_PERSIST | c.flags);
}
//Node *s = ret_nodes[0];
@@ -702,7 +702,7 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName
// only connections that originate or end into main saved scene are saved
// everything else is discarded
- Node *target = Object::cast_to<Node>(c.target);
+ Node *target = Object::cast_to<Node>(c.callable.get_object());
if (!target) {
continue;
@@ -734,7 +734,7 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName
NodePath signal_from = common_parent->get_path_to(p_node);
NodePath signal_to = common_parent->get_path_to(target);
- if (ps->has_connection(signal_from, c.signal, signal_to, c.method)) {
+ if (ps->has_connection(signal_from, c.signal.get_name(), signal_to, c.callable.get_method())) {
exists = true;
break;
}
@@ -766,7 +766,7 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName
if (from_node >= 0 && to_node >= 0) {
//this one has state for this node, save
- if (state->is_connection(from_node, c.signal, to_node, c.method)) {
+ if (state->is_connection(from_node, c.signal.get_name(), to_node, c.callable.get_method())) {
exists2 = true;
break;
}
@@ -784,7 +784,7 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName
if (from_node >= 0 && to_node >= 0) {
//this one has state for this node, save
- if (state->is_connection(from_node, c.signal, to_node, c.method)) {
+ if (state->is_connection(from_node, c.signal.get_name(), to_node, c.callable.get_method())) {
exists2 = true;
break;
}
@@ -831,8 +831,8 @@ Error SceneState::_parse_connections(Node *p_owner, Node *p_node, Map<StringName
ConnectionData cd;
cd.from = src_id;
cd.to = target_id;
- cd.method = _nm_get_string(c.method, name_map);
- cd.signal = _nm_get_string(c.signal, name_map);
+ cd.method = _nm_get_string(c.callable.get_method(), name_map);
+ cd.signal = _nm_get_string(c.signal.get_name(), name_map);
cd.flags = c.flags;
for (int i = 0; i < c.binds.size(); i++) {
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 7fb3ba5155..160061ed05 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -1409,11 +1409,11 @@ void CurveTexture::ensure_default_setup(float p_min, float p_max) {
void CurveTexture::set_curve(Ref<Curve> p_curve) {
if (_curve != p_curve) {
if (_curve.is_valid()) {
- _curve->disconnect(CoreStringNames::get_singleton()->changed, this, "_update");
+ _curve->disconnect_compat(CoreStringNames::get_singleton()->changed, this, "_update");
}
_curve = p_curve;
if (_curve.is_valid()) {
- _curve->connect(CoreStringNames::get_singleton()->changed, this, "_update");
+ _curve->connect_compat(CoreStringNames::get_singleton()->changed, this, "_update");
}
_update();
}
@@ -1514,11 +1514,11 @@ void GradientTexture::set_gradient(Ref<Gradient> p_gradient) {
if (p_gradient == gradient)
return;
if (gradient.is_valid()) {
- gradient->disconnect(CoreStringNames::get_singleton()->changed, this, "_update");
+ gradient->disconnect_compat(CoreStringNames::get_singleton()->changed, this, "_update");
}
gradient = p_gradient;
if (gradient.is_valid()) {
- gradient->connect(CoreStringNames::get_singleton()->changed, this, "_update");
+ gradient->connect_compat(CoreStringNames::get_singleton()->changed, this, "_update");
}
_update();
emit_changed();
@@ -1867,7 +1867,7 @@ AnimatedTexture::AnimatedTexture() {
fps = 4;
prev_ticks = 0;
current_frame = 0;
- VisualServer::get_singleton()->connect("frame_pre_draw", this, "_update_proxy");
+ VisualServer::get_singleton()->connect_compat("frame_pre_draw", this, "_update_proxy");
#ifndef NO_THREADS
rw_lock = RWLock::create();
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index aa05e41b16..5db521bc20 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -302,13 +302,13 @@ void Theme::set_default_theme_font(const Ref<Font> &p_default_font) {
return;
if (default_theme_font.is_valid()) {
- default_theme_font->disconnect("changed", this, "_emit_theme_changed");
+ default_theme_font->disconnect_compat("changed", this, "_emit_theme_changed");
}
default_theme_font = p_default_font;
if (default_theme_font.is_valid()) {
- default_theme_font->connect("changed", this, "_emit_theme_changed", varray(), CONNECT_REFERENCE_COUNTED);
+ default_theme_font->connect_compat("changed", this, "_emit_theme_changed", varray(), CONNECT_REFERENCE_COUNTED);
}
_change_notify();
@@ -366,13 +366,13 @@ void Theme::set_icon(const StringName &p_name, const StringName &p_type, const R
bool new_value = !icon_map.has(p_type) || !icon_map[p_type].has(p_name);
if (icon_map[p_type].has(p_name) && icon_map[p_type][p_name].is_valid()) {
- icon_map[p_type][p_name]->disconnect("changed", this, "_emit_theme_changed");
+ icon_map[p_type][p_name]->disconnect_compat("changed", this, "_emit_theme_changed");
}
icon_map[p_type][p_name] = p_icon;
if (p_icon.is_valid()) {
- icon_map[p_type][p_name]->connect("changed", this, "_emit_theme_changed", varray(), CONNECT_REFERENCE_COUNTED);
+ icon_map[p_type][p_name]->connect_compat("changed", this, "_emit_theme_changed", varray(), CONNECT_REFERENCE_COUNTED);
}
if (new_value) {
@@ -401,7 +401,7 @@ void Theme::clear_icon(const StringName &p_name, const StringName &p_type) {
ERR_FAIL_COND(!icon_map[p_type].has(p_name));
if (icon_map[p_type][p_name].is_valid()) {
- icon_map[p_type][p_name]->disconnect("changed", this, "_emit_theme_changed");
+ icon_map[p_type][p_name]->disconnect_compat("changed", this, "_emit_theme_changed");
}
icon_map[p_type].erase(p_name);
@@ -479,13 +479,13 @@ void Theme::set_stylebox(const StringName &p_name, const StringName &p_type, con
bool new_value = !style_map.has(p_type) || !style_map[p_type].has(p_name);
if (style_map[p_type].has(p_name) && style_map[p_type][p_name].is_valid()) {
- style_map[p_type][p_name]->disconnect("changed", this, "_emit_theme_changed");
+ style_map[p_type][p_name]->disconnect_compat("changed", this, "_emit_theme_changed");
}
style_map[p_type][p_name] = p_style;
if (p_style.is_valid()) {
- style_map[p_type][p_name]->connect("changed", this, "_emit_theme_changed", varray(), CONNECT_REFERENCE_COUNTED);
+ style_map[p_type][p_name]->connect_compat("changed", this, "_emit_theme_changed", varray(), CONNECT_REFERENCE_COUNTED);
}
if (new_value)
@@ -514,7 +514,7 @@ void Theme::clear_stylebox(const StringName &p_name, const StringName &p_type) {
ERR_FAIL_COND(!style_map[p_type].has(p_name));
if (style_map[p_type][p_name].is_valid()) {
- style_map[p_type][p_name]->disconnect("changed", this, "_emit_theme_changed");
+ style_map[p_type][p_name]->disconnect_compat("changed", this, "_emit_theme_changed");
}
style_map[p_type].erase(p_name);
@@ -554,13 +554,13 @@ void Theme::set_font(const StringName &p_name, const StringName &p_type, const R
bool new_value = !font_map.has(p_type) || !font_map[p_type].has(p_name);
if (font_map[p_type][p_name].is_valid()) {
- font_map[p_type][p_name]->disconnect("changed", this, "_emit_theme_changed");
+ font_map[p_type][p_name]->disconnect_compat("changed", this, "_emit_theme_changed");
}
font_map[p_type][p_name] = p_font;
if (p_font.is_valid()) {
- font_map[p_type][p_name]->connect("changed", this, "_emit_theme_changed", varray(), CONNECT_REFERENCE_COUNTED);
+ font_map[p_type][p_name]->connect_compat("changed", this, "_emit_theme_changed", varray(), CONNECT_REFERENCE_COUNTED);
}
if (new_value) {
@@ -589,7 +589,7 @@ void Theme::clear_font(const StringName &p_name, const StringName &p_type) {
ERR_FAIL_COND(!font_map[p_type].has(p_name));
if (font_map[p_type][p_name].is_valid()) {
- font_map[p_type][p_name]->disconnect("changed", this, "_emit_theme_changed");
+ font_map[p_type][p_name]->disconnect_compat("changed", this, "_emit_theme_changed");
}
font_map[p_type].erase(p_name);
@@ -722,7 +722,7 @@ void Theme::clear() {
while ((L = icon_map[*K].next(L))) {
Ref<Texture2D> icon = icon_map[*K][*L];
if (icon.is_valid()) {
- icon->disconnect("changed", this, "_emit_theme_changed");
+ icon->disconnect_compat("changed", this, "_emit_theme_changed");
}
}
}
@@ -735,7 +735,7 @@ void Theme::clear() {
while ((L = style_map[*K].next(L))) {
Ref<StyleBox> style = style_map[*K][*L];
if (style.is_valid()) {
- style->disconnect("changed", this, "_emit_theme_changed");
+ style->disconnect_compat("changed", this, "_emit_theme_changed");
}
}
}
@@ -748,7 +748,7 @@ void Theme::clear() {
while ((L = font_map[*K].next(L))) {
Ref<Font> font = font_map[*K][*L];
if (font.is_valid()) {
- font->disconnect("changed", this, "_emit_theme_changed");
+ font->disconnect_compat("changed", this, "_emit_theme_changed");
}
}
}
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 38b7c5cda0..3f31dc13f8 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -305,10 +305,10 @@ void VisualShader::add_node(Type p_type, const Ref<VisualShaderNode> &p_node, co
if (input.is_valid()) {
input->shader_mode = shader_mode;
input->shader_type = p_type;
- input->connect("input_type_changed", this, "_input_type_changed", varray(p_type, p_id));
+ input->connect_compat("input_type_changed", this, "_input_type_changed", varray(p_type, p_id));
}
- n.node->connect("changed", this, "_queue_update");
+ n.node->connect_compat("changed", this, "_queue_update");
Ref<VisualShaderNodeCustom> custom = n.node;
if (custom.is_valid()) {
@@ -375,10 +375,10 @@ void VisualShader::remove_node(Type p_type, int p_id) {
Ref<VisualShaderNodeInput> input = g->nodes[p_id].node;
if (input.is_valid()) {
- input->disconnect("input_type_changed", this, "_input_type_changed");
+ input->disconnect_compat("input_type_changed", this, "_input_type_changed");
}
- g->nodes[p_id].node->disconnect("changed", this, "_queue_update");
+ g->nodes[p_id].node->disconnect_compat("changed", this, "_queue_update");
g->nodes.erase(p_id);