-Ability to retrieve state data from PackedScene, closes #3413

This commit is contained in:
Juan Linietsky 2016-01-23 12:01:42 -03:00
parent 5a1593951b
commit d59733bd67
3 changed files with 43 additions and 0 deletions

View file

@ -608,6 +608,7 @@ void register_scene_types() {
OS::get_singleton()->yield(); //may take time to init
ObjectTypeDB::register_virtual_type<SceneState>();
ObjectTypeDB::register_type<PackedScene>();
ObjectTypeDB::register_type<SceneTree>();

View file

@ -1532,7 +1532,39 @@ void SceneState::add_editable_instance(const NodePath& p_path){
editable_instances.push_back(p_path);
}
DVector<String> SceneState::_get_node_groups(int p_idx) const {
Vector<StringName> groups = get_node_groups(p_idx);
DVector<String> ret;
for(int i=0;i<groups.size();i++)
ret.push_back(groups[i]);
return ret;
}
void SceneState::_bind_methods() {
//unbuild API
ObjectTypeDB::bind_method(_MD("get_node_count"),&SceneState::get_node_count);
ObjectTypeDB::bind_method(_MD("get_node_type","idx"),&SceneState::get_node_type);
ObjectTypeDB::bind_method(_MD("get_node_name","idx"),&SceneState::get_node_name);
ObjectTypeDB::bind_method(_MD("get_node_path","idx","for_parent"),&SceneState::get_node_path,DEFVAL(false));
ObjectTypeDB::bind_method(_MD("get_node_owner_path","idx"),&SceneState::get_node_owner_path);
ObjectTypeDB::bind_method(_MD("get_node_instance:PackedScene","idx"),&SceneState::get_node_instance);
ObjectTypeDB::bind_method(_MD("get_node_groups","idx"),&SceneState::_get_node_groups);
ObjectTypeDB::bind_method(_MD("get_node_property_count","idx"),&SceneState::get_node_property_count);
ObjectTypeDB::bind_method(_MD("get_node_property_name","idx","prop_idx"),&SceneState::get_node_property_name);
ObjectTypeDB::bind_method(_MD("get_node_property_value","idx","prop_idx"),&SceneState::get_node_property_value);
ObjectTypeDB::bind_method(_MD("get_connection_count"),&SceneState::get_connection_count);
ObjectTypeDB::bind_method(_MD("get_connection_source","idx"),&SceneState::get_connection_source);
ObjectTypeDB::bind_method(_MD("get_connection_signal","idx"),&SceneState::get_connection_signal);
ObjectTypeDB::bind_method(_MD("get_connection_target","idx"),&SceneState::get_connection_target);
ObjectTypeDB::bind_method(_MD("get_connection_method","idx"),&SceneState::get_connection_method);
ObjectTypeDB::bind_method(_MD("get_connection_flags","idx"),&SceneState::get_connection_flags);
ObjectTypeDB::bind_method(_MD("get_connection_binds","idx"),&SceneState::get_connection_binds);
}
SceneState::SceneState() {
@ -1635,6 +1667,7 @@ void PackedScene::_bind_methods() {
ObjectTypeDB::bind_method(_MD("can_instance"),&PackedScene::can_instance);
ObjectTypeDB::bind_method(_MD("_set_bundled_scene"),&PackedScene::_set_bundled_scene);
ObjectTypeDB::bind_method(_MD("_get_bundled_scene"),&PackedScene::_get_bundled_scene);
ObjectTypeDB::bind_method(_MD("get_state:SceneState"),&PackedScene::get_state);
ADD_PROPERTY( PropertyInfo(Variant::DICTIONARY,"_bundled"),_SCS("_set_bundled_scene"),_SCS("_get_bundled_scene"));

View file

@ -36,6 +36,8 @@
class SceneState : public Reference {
OBJ_TYPE( SceneState, Reference );
Vector<StringName> names;
Vector<Variant> variants;
Vector<NodePath> node_paths;
@ -103,6 +105,13 @@ class SceneState : public Reference {
_FORCE_INLINE_ Ref<SceneState> _get_base_scene_state() const;
static bool disable_placeholders;
DVector<String> _get_node_groups(int p_idx) const;
protected:
static void _bind_methods();
public:
enum {