Browse Source

fix get_selected_nodes()

Juan Linietsky 9 years ago
parent
commit
2a003d7b4e
3 changed files with 36 additions and 15 deletions
  1. 20 13
      doc/base/classes.xml
  2. 14 2
      tools/editor/editor_data.cpp
  3. 2 0
      tools/editor/editor_data.h

+ 20 - 13
doc/base/classes.xml

@@ -11269,10 +11269,10 @@
 </class>
 <class name="EditorFileSystem" inherits="Node" category="Core">
 	<brief_description>
-	Resource filesystem, as the editor sees it.
+		Resource filesystem, as the editor sees it.
 	</brief_description>
 	<description>
-	This object holds information of all resources in the filesystem, their types, etc. 
+		This object holds information of all resources in the filesystem, their types, etc.
 	</description>
 	<methods>
 		<method name="get_file_type" qualifiers="const">
@@ -11281,14 +11281,14 @@
 			<argument index="0" name="path" type="String">
 			</argument>
 			<description>
-			Get the type of the file, given the full path.
+				Get the type of the file, given the full path.
 			</description>
 		</method>
 		<method name="get_filesystem">
 			<return type="EditorFileSystemDirectory">
 			</return>
 			<description>
-			Get the root directory object.
+				Get the root directory object.
 			</description>
 		</method>
 		<method name="get_path">
@@ -11303,45 +11303,45 @@
 			<return type="float">
 			</return>
 			<description>
-			Return the scan progress for 0 to 1 if the FS is being scanned.
+				Return the scan progress for 0 to 1 if the FS is being scanned.
 			</description>
 		</method>
 		<method name="is_scanning" qualifiers="const">
 			<return type="bool">
 			</return>
 			<description>
-			Return true of the filesystem is being scanned.
+				Return true of the filesystem is being scanned.
 			</description>
 		</method>
 		<method name="scan">
 			<description>
-			Scan the filesystem for changes.
+				Scan the filesystem for changes.
 			</description>
 		</method>
 		<method name="scan_sources">
 			<description>
-			Check if the source of any imported resource changed.
+				Check if the source of any imported resource changed.
 			</description>
 		</method>
 		<method name="update_file">
 			<argument index="0" name="path" type="String">
 			</argument>
 			<description>
-			Update a file information. Call this if an external program (not Godot) modified the file.
+				Update a file information. Call this if an external program (not Godot) modified the file.
 			</description>
 		</method>
 	</methods>
 	<signals>
 		<signal name="filesystem_changed">
 			<description>
-			Emitted if the filesystem changed.
+				Emitted if the filesystem changed.
 			</description>
 		</signal>
 		<signal name="sources_changed">
 			<argument index="0" name="exist" type="bool">
 			</argument>
 			<description>
-			Emitted if the source of any imported file changed.
+				Emitted if the source of any imported file changed.
 			</description>
 		</signal>
 	</signals>
@@ -11350,7 +11350,7 @@
 </class>
 <class name="EditorFileSystemDirectory" inherits="Object" category="Core">
 	<brief_description>
-	A diretory for the resource filesystem.
+		A diretory for the resource filesystem.
 	</brief_description>
 	<description>
 	</description>
@@ -11708,7 +11708,7 @@
 			<return type="EditorFileSystem">
 			</return>
 			<description>
-			Get the filesystem cache for all resources in the project.
+				Get the filesystem cache for all resources in the project.
 			</description>
 		</method>
 		<method name="get_resource_previewer">
@@ -12065,6 +12065,13 @@
 				Get the list of selectes nodes.
 			</description>
 		</method>
+		<method name="get_transformable_selected_nodes">
+			<return type="Array">
+			</return>
+			<description>
+			Get the list of selected nodes, optimized for transform operations (ie, moving them, rotating, etc). This list avoids situations where a node is selected and also chid/grandchild.
+			</description>
+		</method>
 		<method name="remove_node">
 			<argument index="0" name="node" type="Node">
 			</argument>

+ 14 - 2
tools/editor/editor_data.cpp

@@ -877,8 +877,7 @@ bool EditorSelection::is_selected(Node * p_node) const {
 	return selection.has(p_node);
 }
 
-
-Array EditorSelection::_get_selected_nodes() {
+Array EditorSelection::_get_transformable_selected_nodes() {
 
 	Array ret;
 
@@ -890,6 +889,18 @@ Array EditorSelection::_get_selected_nodes() {
 	return ret;
 }
 
+Array EditorSelection::_get_selected_nodes() {
+
+	Array ret;
+
+	for (Map<Node*,Object*>::Element *E=selection.front();E;E=E->next()) {
+
+		ret.push_back(E->key());
+	}
+
+	return ret;
+}
+
 void EditorSelection::_bind_methods() {
 
 	ObjectTypeDB::bind_method(_MD("_node_removed"),&EditorSelection::_node_removed);
@@ -897,6 +908,7 @@ void EditorSelection::_bind_methods() {
 	ObjectTypeDB::bind_method(_MD("add_node","node:Node"),&EditorSelection::add_node);
 	ObjectTypeDB::bind_method(_MD("remove_node","node:Node"),&EditorSelection::remove_node);
 	ObjectTypeDB::bind_method(_MD("get_selected_nodes"),&EditorSelection::_get_selected_nodes);
+	ObjectTypeDB::bind_method(_MD("get_transformable_selected_nodes"),&EditorSelection::_get_transformable_selected_nodes);
 	ADD_SIGNAL( MethodInfo("selection_changed") );
 
 }

+ 2 - 0
tools/editor/editor_data.h

@@ -233,6 +233,8 @@ public:
 
 	void _update_nl();
 	Array _get_selected_nodes();
+	Array _get_transformable_selected_nodes();
+
 protected:
 
 	static void _bind_methods();