aboutsummaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
authorJuan Linietsky2016-05-17 18:27:15 -0300
committerJuan Linietsky2016-05-17 18:28:44 -0300
commitc195c0df6b36debc870216dd42e49fbda70fa861 (patch)
tree194a26e39ace86d7a471f3e86159c2aed6be261c /scene/main
parent3a26e14a2bab777c9ba6aedceff6e4ef2666faf0 (diff)
downloadgodot-c195c0d.tar.gz
godot-c195c0d.tar.zst
godot-c195c0d.zip
-Added configuration warning system for nodes
-Added a new "add" and "instance" buttons for scene tree -Added a vformat() function to ease translation work
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/node.cpp21
-rw-r--r--scene/main/node.h4
-rw-r--r--scene/main/scene_main_loop.cpp1
-rw-r--r--scene/main/viewport.cpp14
-rw-r--r--scene/main/viewport.h2
5 files changed, 42 insertions, 0 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index e85b3698c..f26169384 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2020,6 +2020,23 @@ void Node::clear_internal_tree_resource_paths() {
}
+String Node::get_configuration_warning() const {
+
+ return String();
+}
+
+void Node::update_configuration_warning() {
+
+#ifdef TOOLS_ENABLED
+ if (!is_inside_tree())
+ return;
+ if (get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root()==this || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) {
+ get_tree()->emit_signal(SceneStringNames::get_singleton()->node_configuration_warning_changed,this);
+ }
+#endif
+
+}
+
void Node::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_add_child_below_node","node:Node","child_node:Node","legible_unique_name"),&Node::add_child_below_node,DEFVAL(false));
@@ -2088,6 +2105,10 @@ void Node::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_viewport"),&Node::get_viewport);
ObjectTypeDB::bind_method(_MD("queue_free"),&Node::queue_delete);
+
+
+
+
#ifdef TOOLS_ENABLED
ObjectTypeDB::bind_method(_MD("_set_import_path","import_path"),&Node::set_import_path);
ObjectTypeDB::bind_method(_MD("_get_import_path"),&Node::get_import_path);
diff --git a/scene/main/node.h b/scene/main/node.h
index 4756909e2..a4683e602 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -317,6 +317,10 @@ public:
_FORCE_INLINE_ Viewport *get_viewport() const { return data.viewport; }
+ virtual String get_configuration_warning() const;
+
+ void update_configuration_warning();
+
/* CANVAS */
Node();
diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp
index cc103b511..b83ad7381 100644
--- a/scene/main/scene_main_loop.cpp
+++ b/scene/main/scene_main_loop.cpp
@@ -1660,6 +1660,7 @@ void SceneTree::_bind_methods() {
ADD_SIGNAL( MethodInfo("tree_changed") );
ADD_SIGNAL( MethodInfo("node_removed",PropertyInfo( Variant::OBJECT, "node") ) );
ADD_SIGNAL( MethodInfo("screen_resized") );
+ ADD_SIGNAL( MethodInfo("node_configuration_warning_changed",PropertyInfo( Variant::OBJECT, "node")) );
ADD_SIGNAL( MethodInfo("idle_frame"));
ADD_SIGNAL( MethodInfo("fixed_frame"));
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 265ee53e5..c9f61beba 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1157,6 +1157,8 @@ void Viewport::set_as_render_target(bool p_enable){
render_target_texture->set_flags(render_target_texture->flags);
render_target_texture->emit_changed();
+
+ update_configuration_warning();
}
bool Viewport::is_set_as_render_target() const{
@@ -2399,6 +2401,18 @@ bool Viewport::is_input_disabled() const {
Variant Viewport::gui_get_drag_data() const {
return gui.drag_data;
}
+
+
+String Viewport::get_configuration_warning() const {
+
+ if (get_parent() && !get_parent()->cast_to<Control>() && !render_target) {
+
+ return TTR("This viewport is not set as render target. If you intend for it to display it's contents directly to the screen, make it a child of a Control so it can obtain a size. Otherwise, make it a RenderTarget and assign it's internal texture to some node for display.");
+ }
+
+ return String();
+}
+
void Viewport::_bind_methods() {
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 6107cf570..6ae9e421e 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -364,6 +364,8 @@ public:
Variant gui_get_drag_data() const;
+ virtual String get_configuration_warning() const;
+
Viewport();
~Viewport();