summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/http_request.cpp34
-rw-r--r--scene/main/http_request.h28
-rw-r--r--scene/main/instance_placeholder.cpp28
-rw-r--r--scene/main/instance_placeholder.h28
-rw-r--r--scene/main/misc.cpp40
-rw-r--r--scene/main/misc.h45
-rw-r--r--scene/main/node.cpp88
-rw-r--r--scene/main/node.h6
-rw-r--r--scene/main/scene_main_loop.cpp28
-rw-r--r--scene/main/scene_main_loop.h11
-rw-r--r--scene/main/scene_singleton.cpp30
-rw-r--r--scene/main/scene_singleton.h36
-rw-r--r--scene/main/viewport.cpp159
-rw-r--r--scene/main/viewport.h17
14 files changed, 351 insertions, 227 deletions
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index 90e3713799..040d509286 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* http_request.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
#include "http_request.h"
void HTTPRequest::_redirect_request(const String& p_new_url) {
@@ -480,8 +508,9 @@ void HTTPRequest::_bind_methods() {
BIND_CONSTANT( RESULT_NO_RESPONSE );
BIND_CONSTANT( RESULT_BODY_SIZE_LIMIT_EXCEEDED );
BIND_CONSTANT( RESULT_REQUEST_FAILED );
- BIND_CONSTANT( RESULT_REDIRECT_LIMIT_REACHED );
+ BIND_CONSTANT( RESULT_DOWNLOAD_FILE_CANT_OPEN );
BIND_CONSTANT( RESULT_DOWNLOAD_FILE_WRITE_ERROR );
+ BIND_CONSTANT( RESULT_REDIRECT_LIMIT_REACHED );
}
@@ -494,10 +523,11 @@ HTTPRequest::HTTPRequest()
max_redirects=8;
body_len=-1;
got_response=false;
- validate_ssl=false;
+ validate_ssl=false;
use_ssl=false;
response_code=0;
request_sent=false;
+ requesting=false;
client.instance();
use_threads=false;
body_size_limit=-1;
diff --git a/scene/main/http_request.h b/scene/main/http_request.h
index 7659d9e6d6..7c3ccb2eb9 100644
--- a/scene/main/http_request.h
+++ b/scene/main/http_request.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* http_request.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
#ifndef HTTPREQUEST_H
#define HTTPREQUEST_H
diff --git a/scene/main/instance_placeholder.cpp b/scene/main/instance_placeholder.cpp
index f822107918..fb047ea5e4 100644
--- a/scene/main/instance_placeholder.cpp
+++ b/scene/main/instance_placeholder.cpp
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* instance_placeholder.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
#include "instance_placeholder.h"
#include "scene/resources/packed_scene.h"
diff --git a/scene/main/instance_placeholder.h b/scene/main/instance_placeholder.h
index 9c47655ce7..ef76686196 100644
--- a/scene/main/instance_placeholder.h
+++ b/scene/main/instance_placeholder.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* instance_placeholder.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
#ifndef INSTANCE_PLACEHOLDER_H
#define INSTANCE_PLACEHOLDER_H
diff --git a/scene/main/misc.cpp b/scene/main/misc.cpp
deleted file mode 100644
index 35d8b4cdfb..0000000000
--- a/scene/main/misc.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*************************************************************************/
-/* misc.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "misc.h"
-
-Misc::Misc()
-{
-}
-
-
-Misc::~Misc()
-{
-}
-
-
diff --git a/scene/main/misc.h b/scene/main/misc.h
deleted file mode 100644
index d5db8c3247..0000000000
--- a/scene/main/misc.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*************************************************************************/
-/* misc.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef MISC_H
-#define MISC_H
-
-#include "scene/main/node.h"
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
-class Misc : public Node {
-
- OBJ_TYPE( Misc, Node );
-public:
- Misc();
- ~Misc();
-
-};
-
-#endif
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index f261693841..50b0fe224e 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -168,11 +168,8 @@ void Node::_propagate_enter_tree() {
data.inside_tree=true;
- const StringName *K=NULL;
-
- while ((K=data.grouped.next(K))) {
-
- data.tree->add_to_group(*K,this);
+ for (Map< StringName, GroupData>::Element *E=data.grouped.front();E;E=E->next()) {
+ E->get().group=data.tree->add_to_group(E->key(),this);
}
@@ -257,13 +254,13 @@ void Node::_propagate_exit_tree() {
data.tree->node_removed(this);
// exit groups
- const StringName *K=NULL;
-
- while ((K=data.grouped.next(K))) {
- data.tree->remove_from_group(*K,this);
+ for (Map< StringName, GroupData>::Element *E=data.grouped.front();E;E=E->next()) {
+ data.tree->remove_from_group(E->key(),this);
+ E->get().group=NULL;
}
+
data.viewport = NULL;
if (data.tree)
@@ -286,7 +283,11 @@ void Node::move_child(Node *p_child,int p_pos) {
ERR_FAIL_INDEX( p_pos, data.children.size()+1 );
ERR_EXPLAIN("child is not a child of this node.");
ERR_FAIL_COND(p_child->data.parent!=this);
- ERR_FAIL_COND(data.blocked>0);
+ if (data.blocked>0) {
+ ERR_EXPLAIN("Parent node is busy setting up children, move_child() failed. Consider using call_deferred(\"move_child\") instead (or \"popup\" if this is from a popup).");
+ ERR_FAIL_COND(data.blocked>0);
+ }
+
data.children.remove( p_child->data.pos );
data.children.insert( p_pos, p_child );
@@ -307,6 +308,9 @@ void Node::move_child(Node *p_child,int p_pos) {
data.children[i]->notification( NOTIFICATION_MOVED_IN_PARENT );
}
+ for (const Map< StringName, GroupData>::Element *E=p_child->data.grouped.front();E;E=E->next()) {
+ E->get().group->changed=true;
+ }
data.blocked--;
@@ -739,6 +743,12 @@ void Node::add_child(Node *p_child, bool p_legible_unique_name) {
}
ERR_EXPLAIN("Can't add child, already has a parent");
ERR_FAIL_COND( p_child->data.parent );
+
+ if (data.blocked>0) {
+ ERR_EXPLAIN("Parent node is busy setting up children, add_node() failed. Consider using call_deferred(\"add_child\",child) instead.");
+ ERR_FAIL_COND(data.blocked>0);
+ }
+
ERR_EXPLAIN("Can't add child while a notification is happening");
ERR_FAIL_COND( data.blocked > 0 );
@@ -800,7 +810,10 @@ void Node::_propagate_validate_owner() {
void Node::remove_child(Node *p_child) {
ERR_FAIL_NULL(p_child);
- ERR_FAIL_COND( data.blocked > 0 );
+ if (data.blocked>0) {
+ ERR_EXPLAIN("Parent node is busy setting up children, remove_node() failed. Consider using call_deferred(\"remove_child\",child) instead.");
+ ERR_FAIL_COND(data.blocked>0);
+ }
int idx=-1;
for (int i=0;i<data.children.size();i++) {
@@ -1193,8 +1206,12 @@ void Node::add_to_group(const StringName& p_identifier,bool p_persistent) {
GroupData gd;
- if (data.tree)
- data.tree->add_to_group(p_identifier,this);
+ SceneTree::Group *gptr=NULL;
+ if (data.tree) {
+ gd.group=data.tree->add_to_group(p_identifier,this);
+ } else {
+ gd.group=NULL;
+ }
gd.persistent=p_persistent;
@@ -1207,14 +1224,15 @@ void Node::remove_from_group(const StringName& p_identifier) {
ERR_FAIL_COND(!data.grouped.has(p_identifier) );
- GroupData *g=data.grouped.getptr(p_identifier);
- ERR_FAIL_COND(!g);
+ Map< StringName, GroupData>::Element *E=data.grouped.find(p_identifier);
+
+ ERR_FAIL_COND(!E);
if (data.tree)
- data.tree->remove_from_group(p_identifier,this);
+ data.tree->remove_from_group(E->key(),this);
- data.grouped.erase(p_identifier);
+ data.grouped.erase(E);
}
@@ -1232,19 +1250,29 @@ Array Node::_get_groups() const {
void Node::get_groups(List<GroupInfo> *p_groups) const {
- const StringName *K=NULL;
-
- while ((K=data.grouped.next(K))) {
+ for (const Map< StringName, GroupData>::Element *E=data.grouped.front();E;E=E->next()) {
GroupInfo gi;
- gi.name=*K;
- gi.persistent=data.grouped[*K].persistent;
+ gi.name=E->key();
+ gi.persistent=E->get().persistent;
p_groups->push_back(gi);
}
}
+bool Node::has_persistent_groups() const {
+
+ for (const Map< StringName, GroupData>::Element *E=data.grouped.front();E;E=E->next()) {
+ if (E->get().persistent)
+ return true;
+ }
+
+
+ return false;
+
+
+}
void Node::_print_tree(const Node *p_node) {
print_line(String(p_node->get_path_to(this)));
@@ -1755,6 +1783,8 @@ void Node::replace_by(Node* p_node,bool p_keep_data) {
}
}
+ _replace_connections_target(p_node);
+
if (data.owner) {
for(int i=0;i<get_child_count();i++)
find_owned_by(data.owner,get_child(i),&owned_by_owner);
@@ -1793,6 +1823,20 @@ void Node::replace_by(Node* p_node,bool p_keep_data) {
}
+void Node::_replace_connections_target(Node* p_new_target) {
+
+ List<Connection> cl;
+ get_signals_connected_to_this(&cl);
+
+ for(List<Connection>::Element *E=cl.front();E;E=E->next()) {
+
+ Connection &c=E->get();
+
+ c.source->disconnect(c.signal,this,c.method);
+ c.source->connect(c.signal,p_new_target,c.method,c.binds,c.flags);
+ }
+}
+
Vector<Variant> Node::make_binds(VARIANT_ARG_DECLARE) {
diff --git a/scene/main/node.h b/scene/main/node.h
index a4683e602f..a3b8d8de81 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -64,6 +64,7 @@ private:
struct GroupData {
bool persistent;
+ SceneTree::Group *group;
GroupData() { persistent=false; }
};
@@ -91,7 +92,7 @@ private:
Viewport *viewport;
- HashMap< StringName, GroupData,StringNameHasher> grouped;
+ Map< StringName, GroupData> grouped;
List<Node*>::Element *OW; // owned element
List<Node*> owned;
@@ -120,7 +121,7 @@ private:
Node *_get_node(const NodePath& p_path) const;
Node *_get_child_by_name(const StringName& p_name) const;
-
+ void _replace_connections_target(Node* p_new_target);
void _validate_child_name(Node *p_name, bool p_force_human_readable=false);
@@ -223,6 +224,7 @@ public:
};
void get_groups(List<GroupInfo> *p_groups) const;
+ bool has_persistent_groups() const;
void move_child(Node *p_child,int p_pos);
void raise();
diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp
index b83ad7381e..a7ef7ca7c1 100644
--- a/scene/main/scene_main_loop.cpp
+++ b/scene/main/scene_main_loop.cpp
@@ -64,7 +64,7 @@ void SceneTree::node_removed(Node *p_node) {
}
-void SceneTree::add_to_group(const StringName& p_group, Node *p_node) {
+SceneTree::Group *SceneTree::add_to_group(const StringName& p_group, Node *p_node) {
Map<StringName,Group>::Element *E=group_map.find(p_group);
if (!E) {
@@ -73,10 +73,12 @@ void SceneTree::add_to_group(const StringName& p_group, Node *p_node) {
if (E->get().nodes.find(p_node)!=-1) {
ERR_EXPLAIN("Already in group: "+p_group);
- ERR_FAIL();
+ ERR_FAIL_V(&E->get());
}
E->get().nodes.push_back(p_node);
- E->get().last_tree_version=0;
+ //E->get().last_tree_version=0;
+ E->get().changed=true;
+ return &E->get();
}
void SceneTree::remove_from_group(const StringName& p_group, Node *p_node) {
@@ -125,7 +127,7 @@ void SceneTree::_flush_ugc() {
void SceneTree::_update_group_order(Group& g) {
- if (g.last_tree_version==tree_version)
+ if (!g.changed)
return;
if (g.nodes.empty())
return;
@@ -135,7 +137,8 @@ void SceneTree::_update_group_order(Group& g) {
SortArray<Node*,Node::Comparator> node_sort;
node_sort.sort(nodes,node_count);
- g.last_tree_version=tree_version;
+ g.changed=false;
+
}
@@ -148,8 +151,6 @@ void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const
if (g.nodes.empty())
return;
- _update_group_order(g);
-
if (p_call_flags&GROUP_CALL_UNIQUE && !(p_call_flags&GROUP_CALL_REALTIME)) {
@@ -175,6 +176,8 @@ void SceneTree::call_group(uint32_t p_call_flags,const StringName& p_group,const
return;
}
+ _update_group_order(g);
+
Vector<Node*> nodes_copy = g.nodes;
Node **nodes = &nodes_copy[0];
int node_count=nodes_copy.size();
@@ -1002,6 +1005,7 @@ static void _fill_array(Node *p_node, Array& array, int p_level) {
array.push_back(p_level);
array.push_back(p_node->get_name());
array.push_back(p_node->get_type());
+ array.push_back(p_node->get_instance_ID());
for(int i=0;i<p_node->get_child_count();i++) {
_fill_array(p_node->get_child(i),array,p_level+1);
@@ -1592,6 +1596,14 @@ void SceneTree::_live_edit_reparent_node_func(const NodePath& p_at,const NodePat
#endif
+
+
+void SceneTree::drop_files(const Vector<String>& p_files,int p_from_screen) {
+
+ emit_signal("files_dropped",p_files,p_from_screen);
+ MainLoop::drop_files(p_files,p_from_screen);
+}
+
void SceneTree::_bind_methods() {
@@ -1665,6 +1677,8 @@ void SceneTree::_bind_methods() {
ADD_SIGNAL( MethodInfo("idle_frame"));
ADD_SIGNAL( MethodInfo("fixed_frame"));
+ ADD_SIGNAL( MethodInfo("files_dropped",PropertyInfo(Variant::STRING_ARRAY,"files"),PropertyInfo(Variant::INT,"screen")) );
+
BIND_CONSTANT( GROUP_CALL_DEFAULT );
BIND_CONSTANT( GROUP_CALL_REVERSE );
BIND_CONSTANT( GROUP_CALL_REALTIME );
diff --git a/scene/main/scene_main_loop.h b/scene/main/scene_main_loop.h
index b6a015c9ed..38d13c0447 100644
--- a/scene/main/scene_main_loop.h
+++ b/scene/main/scene_main_loop.h
@@ -33,7 +33,6 @@
#include "os/main_loop.h"
#include "scene/resources/world.h"
#include "scene/resources/world_2d.h"
-#include "scene/main/scene_singleton.h"
#include "os/thread_safe.h"
#include "self_list.h"
/**
@@ -76,8 +75,9 @@ private:
struct Group {
Vector<Node*> nodes;
- uint64_t last_tree_version;
- Group() { last_tree_version=0; };
+ //uint64_t last_tree_version;
+ bool changed;
+ Group() { changed=false; };
};
Viewport *root;
@@ -135,7 +135,7 @@ private:
void _flush_ugc();
void _flush_transform_notifications();
- void _update_group_order(Group& g);
+ _FORCE_INLINE_ void _update_group_order(Group& g);
void _update_listener();
Array _get_nodes_in_group(const StringName& p_group);
@@ -162,7 +162,7 @@ friend class Node;
void node_removed(Node *p_node);
- void add_to_group(const StringName& p_group, Node *p_node);
+ Group* add_to_group(const StringName& p_group, Node *p_node);
void remove_from_group(const StringName& p_group, Node *p_node);
void _notify_group_pause(const StringName& p_group,int p_notification);
@@ -344,6 +344,7 @@ public:
static SceneTree* get_singleton() { return singleton; }
+ void drop_files(const Vector<String>& p_files,int p_from_screen=0);
SceneTree();
~SceneTree();
diff --git a/scene/main/scene_singleton.cpp b/scene/main/scene_singleton.cpp
deleted file mode 100644
index 3dcc6b1204..0000000000
--- a/scene/main/scene_singleton.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/*************************************************************************/
-/* scene_singleton.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "scene_singleton.h"
-
diff --git a/scene/main/scene_singleton.h b/scene/main/scene_singleton.h
deleted file mode 100644
index 0b209f7944..0000000000
--- a/scene/main/scene_singleton.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*************************************************************************/
-/* scene_singleton.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef SCENE_SINGLETON_H
-#define SCENE_SINGLETON_H
-
-
-#include "reference.h"
-
-
-#endif // SCENE_SINGLETON_H
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index c9f61beba7..79502c74ce 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -37,6 +37,7 @@
#include "servers/spatial_sound_2d_server.h"
#include "scene/gui/control.h"
#include "scene/3d/camera.h"
+#include "scene/3d/listener.h"
#include "scene/resources/mesh.h"
#include "scene/3d/spatial_indexer.h"
#include "scene/3d/collision_object.h"
@@ -388,6 +389,19 @@ void Viewport::_notification(int p_what) {
} break;
case NOTIFICATION_READY: {
#ifndef _3D_DISABLED
+ if (listeners.size() && !listener) {
+ Listener *first=NULL;
+ for(Set<Listener*>::Element *E=listeners.front();E;E=E->next()) {
+
+ if (first==NULL || first->is_greater_than(E->get())) {
+ first=E->get();
+ }
+ }
+
+ if (first)
+ first->make_current();
+ }
+
if (cameras.size() && !camera) {
//there are cameras but no current camera, pick first in tree and make it current
Camera *first=NULL;
@@ -414,7 +428,7 @@ void Viewport::_notification(int p_what) {
_vp_exit_tree();
VisualServer::get_singleton()->viewport_set_scenario(viewport,RID());
- SpatialSoundServer::get_singleton()->listener_set_space(listener,RID());
+ SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, RID());
VisualServer::get_singleton()->viewport_remove_canvas(viewport,current_canvas);
if (contact_2d_debug.is_valid()) {
VisualServer::get_singleton()->free(contact_2d_debug);
@@ -486,7 +500,7 @@ void Viewport::_notification(int p_what) {
- if (physics_object_picking) {
+ if (physics_object_picking && (render_target || Input::get_singleton()->get_mouse_mode()!=Input::MOUSE_MODE_CAPTURED)) {
Vector2 last_pos(1e20,1e20);
CollisionObject *last_object;
@@ -740,10 +754,10 @@ Rect2 Viewport::get_rect() const {
void Viewport::_update_listener() {
- if (is_inside_tree() && audio_listener && camera && (!get_parent() || (get_parent()->cast_to<Control>() && get_parent()->cast_to<Control>()->is_visible()))) {
- SpatialSoundServer::get_singleton()->listener_set_space(listener,find_world()->get_sound_space());
+ if (is_inside_tree() && audio_listener && (camera || listener) && (!get_parent() || (get_parent()->cast_to<Control>() && get_parent()->cast_to<Control>()->is_visible()))) {
+ SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, find_world()->get_sound_space());
} else {
- SpatialSoundServer::get_singleton()->listener_set_space(listener,RID());
+ SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, RID());
}
@@ -752,9 +766,9 @@ void Viewport::_update_listener() {
void Viewport::_update_listener_2d() {
if (is_inside_tree() && audio_listener && (!get_parent() || (get_parent()->cast_to<Control>() && get_parent()->cast_to<Control>()->is_visible())))
- SpatialSound2DServer::get_singleton()->listener_set_space(listener_2d,find_world_2d()->get_sound_space());
+ SpatialSound2DServer::get_singleton()->listener_set_space(internal_listener_2d, find_world_2d()->get_sound_space());
else
- SpatialSound2DServer::get_singleton()->listener_set_space(listener_2d,RID());
+ SpatialSound2DServer::get_singleton()->listener_set_space(internal_listener_2d, RID());
}
@@ -798,11 +812,11 @@ void Viewport::set_canvas_transform(const Matrix32& p_transform) {
Matrix32 xform = (global_canvas_transform * canvas_transform).affine_inverse();
Size2 ss = get_visible_rect().size;
- SpatialSound2DServer::get_singleton()->listener_set_transform(listener_2d,Matrix32(0,xform.xform(ss*0.5)));
+ SpatialSound2DServer::get_singleton()->listener_set_transform(internal_listener_2d, Matrix32(0, xform.xform(ss*0.5)));
Vector2 ss2 = ss*xform.get_scale();
float panrange = MAX(ss2.x,ss2.y);
- SpatialSound2DServer::get_singleton()->listener_set_param(listener_2d,SpatialSound2DServer::LISTENER_PARAM_PAN_RANGE,panrange);
+ SpatialSound2DServer::get_singleton()->listener_set_param(internal_listener_2d, SpatialSound2DServer::LISTENER_PARAM_PAN_RANGE, panrange);
}
@@ -823,11 +837,11 @@ void Viewport::_update_global_transform() {
Matrix32 xform = (sxform * canvas_transform).affine_inverse();
Size2 ss = get_visible_rect().size;
- SpatialSound2DServer::get_singleton()->listener_set_transform(listener_2d,Matrix32(0,xform.xform(ss*0.5)));
+ SpatialSound2DServer::get_singleton()->listener_set_transform(internal_listener_2d, Matrix32(0, xform.xform(ss*0.5)));
Vector2 ss2 = ss*xform.get_scale();
float panrange = MAX(ss2.x,ss2.y);
- SpatialSound2DServer::get_singleton()->listener_set_param(listener_2d,SpatialSound2DServer::LISTENER_PARAM_PAN_RANGE,panrange);
+ SpatialSound2DServer::get_singleton()->listener_set_param(internal_listener_2d, SpatialSound2DServer::LISTENER_PARAM_PAN_RANGE, panrange);
}
@@ -846,12 +860,75 @@ Matrix32 Viewport::get_global_canvas_transform() const{
return global_canvas_transform;
}
+void Viewport::_listener_transform_changed_notify() {
+
+#ifndef _3D_DISABLED
+ if (listener)
+ SpatialSoundServer::get_singleton()->listener_set_transform(internal_listener, listener->get_listener_transform());
+#endif
+}
+
+void Viewport::_listener_set(Listener* p_listener) {
+
+#ifndef _3D_DISABLED
+
+ if (listener == p_listener)
+ return;
+
+ listener = p_listener;
+
+ _update_listener();
+ _listener_transform_changed_notify();
+#endif
+}
+
+bool Viewport::_listener_add(Listener* p_listener) {
+
+ listeners.insert(p_listener);
+ return listeners.size() == 1;
+}
+
+void Viewport::_listener_remove(Listener* p_listener) {
+
+ listeners.erase(p_listener);
+ if (listener == p_listener) {
+ listener = NULL;
+ }
+}
+
+#ifndef _3D_DISABLED
+void Viewport::_listener_make_next_current(Listener* p_exclude) {
+
+ if (listeners.size() > 0) {
+ for (Set<Listener*>::Element *E = listeners.front(); E; E = E->next()) {
+
+ if (p_exclude == E->get())
+ continue;
+ if (!E->get()->is_inside_tree())
+ continue;
+ if (listener != NULL)
+ return;
+
+ E->get()->make_current();
+
+ }
+ }
+ else {
+ // Attempt to reset listener to the camera position
+ if (camera != NULL) {
+ _update_listener();
+ _camera_transform_changed_notify();
+ }
+ }
+}
+#endif
void Viewport::_camera_transform_changed_notify() {
#ifndef _3D_DISABLED
- if (camera)
- SpatialSoundServer::get_singleton()->listener_set_transform(listener,camera->get_camera_transform());
+ // If there is an active listener in the scene, it takes priority over the camera
+ if (camera && !listener)
+ SpatialSoundServer::get_singleton()->listener_set_transform(internal_listener, camera->get_camera_transform());
#endif
}
@@ -1076,6 +1153,11 @@ Ref<World> Viewport::find_world() const{
return Ref<World>();
}
+Listener* Viewport::get_listener() const {
+
+ return listener;
+}
+
Camera* Viewport::get_camera() const {
return camera;
@@ -1128,7 +1210,7 @@ void Viewport::set_size_override_stretch(bool p_enable) {
bool Viewport::is_size_override_stretch_enabled() const {
- return size_override;
+ return size_override_stretch;
}
void Viewport::set_as_render_target(bool p_enable){
@@ -1358,7 +1440,6 @@ void Viewport::_vp_unhandled_input(const InputEvent& p_ev) {
if (disable_input)
return;
-
#ifdef TOOLS_ENABLED
if (get_tree()->is_editor_hint() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) {
return;
@@ -1493,22 +1574,29 @@ void Viewport::_gui_call_input(Control *p_control,const InputEvent& p_input) {
// _block();
- while(p_control) {
+ CanvasItem *ci=p_control;
+ while(ci) {
- p_control->call_multilevel(SceneStringNames::get_singleton()->_input_event,p_input);
- if (gui.key_event_accepted)
- break;
- if (!p_control->is_inside_tree())
- break;
- p_control->emit_signal(SceneStringNames::get_singleton()->input_event,p_input);
- if (!p_control->is_inside_tree() || p_control->is_set_as_toplevel()) {
- break;
+ Control *control = ci->cast_to<Control>();
+ if (control) {
+ control->call_multilevel(SceneStringNames::get_singleton()->_input_event,p_input);
+ if (gui.key_event_accepted)
+ break;
+ if (!control->is_inside_tree())
+ break;
+ control->emit_signal(SceneStringNames::get_singleton()->input_event,p_input);
+ if (!control->is_inside_tree() || control->is_set_as_toplevel())
+ break;
+ if (gui.key_event_accepted)
+ break;
+ if (control->data.stop_mouse && (p_input.type==InputEvent::MOUSE_BUTTON || p_input.type==InputEvent::MOUSE_MOTION))
+ break;
}
- if (gui.key_event_accepted)
- break;
- if (p_control->data.stop_mouse && (p_input.type==InputEvent::MOUSE_BUTTON || p_input.type==InputEvent::MOUSE_MOTION))
+
+ if (ci->is_set_as_toplevel())
break;
- p_control=p_control->data.parent;
+
+ ci=ci->get_parent_item();
}
//_unblock();
@@ -1842,6 +1930,8 @@ void Viewport::_gui_input_event(InputEvent p_event) {
if (gui.mouse_over)
gui.mouse_over->notification(Control::NOTIFICATION_MOUSE_EXIT);
+ _gui_cancel_tooltip();
+
if (over)
over->notification(Control::NOTIFICATION_MOUSE_ENTER);
@@ -1849,8 +1939,6 @@ void Viewport::_gui_input_event(InputEvent p_event) {
gui.mouse_over=over;
- _gui_cancel_tooltip();
-
if (gui.drag_preview) {
gui.drag_preview->set_pos(mpos);
}
@@ -2407,7 +2495,7 @@ 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 TTR("This viewport is not set as render target. If you intend for it to display its 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 its internal texture to some node for display.");
}
return String();
@@ -2540,12 +2628,13 @@ Viewport::Viewport() {
world_2d = Ref<World2D>( memnew( World2D ));
viewport = VisualServer::get_singleton()->viewport_create();
- listener=SpatialSoundServer::get_singleton()->listener_create();
+ internal_listener = SpatialSoundServer::get_singleton()->listener_create();
audio_listener=false;
- listener_2d=SpatialSound2DServer::get_singleton()->listener_create();
+ internal_listener_2d = SpatialSound2DServer::get_singleton()->listener_create();
audio_listener_2d=false;
transparent_bg=false;
parent=NULL;
+ listener=NULL;
camera=NULL;
size_override=false;
size_override_stretch=false;
@@ -2593,8 +2682,8 @@ Viewport::Viewport() {
Viewport::~Viewport() {
VisualServer::get_singleton()->free( viewport );
- SpatialSoundServer::get_singleton()->free(listener);
- SpatialSound2DServer::get_singleton()->free(listener_2d);
+ SpatialSoundServer::get_singleton()->free(internal_listener);
+ SpatialSound2DServer::get_singleton()->free(internal_listener_2d);
if (render_target_texture.is_valid())
render_target_texture->vp=NULL; //so if used, will crash
}
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 6ae9e421eb..545020dfc7 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -39,6 +39,7 @@
*/
class Camera;
+class Listener;
class Control;
class CanvasItem;
class Panel;
@@ -92,6 +93,9 @@ friend class RenderTargetTexture;
Control *parent_control;
Viewport *parent;
+ Listener *listener;
+ Set<Listener*> listeners;
+
Camera *camera;
Set<Camera*> cameras;
@@ -100,10 +104,10 @@ friend class RenderTargetTexture;
RID current_canvas;
bool audio_listener;
- RID listener;
+ RID internal_listener;
bool audio_listener_2d;
- RID listener_2d;
+ RID internal_listener_2d;
Matrix32 canvas_transform;
Matrix32 global_canvas_transform;
@@ -263,6 +267,13 @@ friend class Control;
Control *_gui_get_focus_owner();
+friend class Listener;
+ void _listener_transform_changed_notify();
+ void _listener_set(Listener* p_listener);
+ bool _listener_add(Listener* p_listener); //true if first
+ void _listener_remove(Listener* p_listener);
+ void _listener_make_next_current(Listener* p_exclude);
+
friend class Camera;
void _camera_transform_changed_notify();
void _camera_set(Camera* p_camera);
@@ -276,7 +287,7 @@ protected:
static void _bind_methods();
public:
-
+ Listener* get_listener() const;
Camera* get_camera() const;
void set_as_audio_listener(bool p_enable);