diff options
Diffstat (limited to 'scene/resources/packed_scene.cpp')
-rw-r--r-- | scene/resources/packed_scene.cpp | 88 |
1 files changed, 48 insertions, 40 deletions
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 625cc6a596..5e3347687a 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -27,7 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "packed_scene.h" -#include "globals.h" +#include "global_config.h" #include "io/resource_loader.h" #include "scene/3d/spatial.h" #include "scene/gui/control.h" @@ -177,6 +177,9 @@ Node *SceneState::instance(GenEditState p_edit_state) const { node = obj->cast_to<Node>(); + } else { + print_line("wtf class is disabled for: "+itos(n.type)); + print_line("name: "+String(snames[n.type])); } @@ -196,6 +199,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const { ERR_FAIL_INDEX_V( nprops[j].name, sname_count, NULL ); ERR_FAIL_INDEX_V( nprops[j].value, prop_count, NULL ); + if (snames[ nprops[j].name ]==CoreStringNames::get_singleton()->_script) { //work around to avoid old script variables from disappearing, should be the proper fix to: //https://github.com/godotengine/godot/issues/2958 @@ -332,7 +336,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const { //remove nodes that could not be added, likely as a result that while(stray_instances.size()) { memdelete(stray_instances.front()->get()); - stray_instances.pop_front();; + stray_instances.pop_front(); } for(int i=0;i<editable_instances.size();i++) { @@ -357,7 +361,7 @@ static int _nm_get_string(const String& p_string, Map<StringName,int> &name_map) return idx; } -static int _vm_get_variant(const Variant& p_variant, HashMap<Variant,int,VariantHasher> &variant_map) { +static int _vm_get_variant(const Variant& p_variant, HashMap<Variant,int,VariantHasher,VariantComparator> &variant_map) { if (variant_map.has(p_variant)) return variant_map[p_variant]; @@ -367,7 +371,7 @@ static int _vm_get_variant(const Variant& p_variant, HashMap<Variant,int,Variant return idx; } -Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map) { +Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher,VariantComparator> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map) { // this function handles all the work related to properly packing scenes, be it @@ -529,9 +533,11 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S bool isdefault = ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO) && value.is_zero()) || ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONONE) && value.is_one()); -// if (nd.instance<0 && ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO) && value.is_zero()) || ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONONE) && value.is_one())) { -// continue; -// } + /* + if (nd.instance<0 && ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONZERO) && value.is_zero()) || ((E->get().usage & PROPERTY_USAGE_STORE_IF_NONONE) && value.is_one())) { + continue; + } + */ @@ -614,8 +620,10 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S if (!gi.persistent) continue; -// if (instance_state_node>=0 && instance_state->is_node_in_group(instance_state_node,gi.name)) -// continue; //group was instanced, don't add here + /* + if (instance_state_node>=0 && instance_state->is_node_in_group(instance_state_node,gi.name)) + continue; //group was instanced, don't add here + */ bool skip=false; for (List<PackState>::Element *F=pack_state_stack.front();F;F=F->next()) { @@ -739,7 +747,7 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S } -Error SceneState::_parse_connections(Node *p_owner,Node *p_node, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map) { +Error SceneState::_parse_connections(Node *p_owner,Node *p_node, Map<StringName,int> &name_map,HashMap<Variant,int,VariantHasher,VariantComparator> &variant_map,Map<Node*,int> &node_map,Map<Node*,int> &nodepath_map) { if (p_node!=p_owner && p_node->get_owner() && p_node->get_owner()!=p_owner && !p_owner->is_editable_instance(p_node->get_owner())) return OK; @@ -944,7 +952,7 @@ Error SceneState::pack(Node *p_scene) { Node *scene = p_scene; Map<StringName,int> name_map; - HashMap<Variant,int,VariantHasher> variant_map; + HashMap<Variant,int,VariantHasher,VariantComparator> variant_map; Map<Node*,int> node_map; Map<Node*,int> nodepath_map; @@ -1166,7 +1174,7 @@ void SceneState::set_bundled_scene(const Dictionary& d) { ERR_FAIL_COND( !d.has("nodes")); ERR_FAIL_COND( !d.has("conn_count")); ERR_FAIL_COND( !d.has("conns")); -// ERR_FAIL_COND( !d.has("path")); + //ERR_FAIL_COND( !d.has("path")); int version=1; if (d.has("version")) @@ -1277,7 +1285,7 @@ void SceneState::set_bundled_scene(const Dictionary& d) { editable_instances[i]=ei[i]; } -// path=d["path"]; + //path=d["path"]; } @@ -1362,7 +1370,7 @@ Dictionary SceneState::get_bundled_scene() const { d["version"]=PACK_VERSION; -// d["path"]=path; + //d["path"]=path; return d; @@ -1712,25 +1720,25 @@ void SceneState::_bind_methods() { //unbuild API - ClassDB::bind_method(_MD("get_node_count"),&SceneState::get_node_count); - ClassDB::bind_method(_MD("get_node_type","idx"),&SceneState::get_node_type); - ClassDB::bind_method(_MD("get_node_name","idx"),&SceneState::get_node_name); - ClassDB::bind_method(_MD("get_node_path","idx","for_parent"),&SceneState::get_node_path,DEFVAL(false)); - ClassDB::bind_method(_MD("get_node_owner_path","idx"),&SceneState::get_node_owner_path); - ClassDB::bind_method(_MD("is_node_instance_placeholder","idx"),&SceneState::is_node_instance_placeholder); - ClassDB::bind_method(_MD("get_node_instance_placeholder","idx"),&SceneState::get_node_instance_placeholder); - ClassDB::bind_method(_MD("get_node_instance:PackedScene","idx"),&SceneState::get_node_instance); - ClassDB::bind_method(_MD("get_node_groups","idx"),&SceneState::_get_node_groups); - ClassDB::bind_method(_MD("get_node_property_count","idx"),&SceneState::get_node_property_count); - ClassDB::bind_method(_MD("get_node_property_name","idx","prop_idx"),&SceneState::get_node_property_name); - ClassDB::bind_method(_MD("get_node_property_value","idx","prop_idx"),&SceneState::get_node_property_value); - ClassDB::bind_method(_MD("get_connection_count"),&SceneState::get_connection_count); - ClassDB::bind_method(_MD("get_connection_source","idx"),&SceneState::get_connection_source); - ClassDB::bind_method(_MD("get_connection_signal","idx"),&SceneState::get_connection_signal); - ClassDB::bind_method(_MD("get_connection_target","idx"),&SceneState::get_connection_target); - ClassDB::bind_method(_MD("get_connection_method","idx"),&SceneState::get_connection_method); - ClassDB::bind_method(_MD("get_connection_flags","idx"),&SceneState::get_connection_flags); - ClassDB::bind_method(_MD("get_connection_binds","idx"),&SceneState::get_connection_binds); + ClassDB::bind_method(D_METHOD("get_node_count"),&SceneState::get_node_count); + ClassDB::bind_method(D_METHOD("get_node_type","idx"),&SceneState::get_node_type); + ClassDB::bind_method(D_METHOD("get_node_name","idx"),&SceneState::get_node_name); + ClassDB::bind_method(D_METHOD("get_node_path","idx","for_parent"),&SceneState::get_node_path,DEFVAL(false)); + ClassDB::bind_method(D_METHOD("get_node_owner_path","idx"),&SceneState::get_node_owner_path); + ClassDB::bind_method(D_METHOD("is_node_instance_placeholder","idx"),&SceneState::is_node_instance_placeholder); + ClassDB::bind_method(D_METHOD("get_node_instance_placeholder","idx"),&SceneState::get_node_instance_placeholder); + ClassDB::bind_method(D_METHOD("get_node_instance:PackedScene","idx"),&SceneState::get_node_instance); + ClassDB::bind_method(D_METHOD("get_node_groups","idx"),&SceneState::_get_node_groups); + ClassDB::bind_method(D_METHOD("get_node_property_count","idx"),&SceneState::get_node_property_count); + ClassDB::bind_method(D_METHOD("get_node_property_name","idx","prop_idx"),&SceneState::get_node_property_name); + ClassDB::bind_method(D_METHOD("get_node_property_value","idx","prop_idx"),&SceneState::get_node_property_value); + ClassDB::bind_method(D_METHOD("get_connection_count"),&SceneState::get_connection_count); + ClassDB::bind_method(D_METHOD("get_connection_source","idx"),&SceneState::get_connection_source); + ClassDB::bind_method(D_METHOD("get_connection_signal","idx"),&SceneState::get_connection_signal); + ClassDB::bind_method(D_METHOD("get_connection_target","idx"),&SceneState::get_connection_target); + ClassDB::bind_method(D_METHOD("get_connection_method","idx"),&SceneState::get_connection_method); + ClassDB::bind_method(D_METHOD("get_connection_flags","idx"),&SceneState::get_connection_flags); + ClassDB::bind_method(D_METHOD("get_connection_binds","idx"),&SceneState::get_connection_binds); BIND_CONSTANT( GEN_EDIT_STATE_DISABLED ); BIND_CONSTANT( GEN_EDIT_STATE_INSTANCE ); @@ -1833,14 +1841,14 @@ void PackedScene::set_path(const String& p_path,bool p_take_over) { void PackedScene::_bind_methods() { - ClassDB::bind_method(_MD("pack","path:Node"),&PackedScene::pack); - ClassDB::bind_method(_MD("instance:Node","edit_state"),&PackedScene::instance,DEFVAL(false)); - ClassDB::bind_method(_MD("can_instance"),&PackedScene::can_instance); - ClassDB::bind_method(_MD("_set_bundled_scene"),&PackedScene::_set_bundled_scene); - ClassDB::bind_method(_MD("_get_bundled_scene"),&PackedScene::_get_bundled_scene); - ClassDB::bind_method(_MD("get_state:SceneState"),&PackedScene::get_state); + ClassDB::bind_method(D_METHOD("pack","path:Node"),&PackedScene::pack); + ClassDB::bind_method(D_METHOD("instance:Node","edit_state"),&PackedScene::instance,DEFVAL(false)); + ClassDB::bind_method(D_METHOD("can_instance"),&PackedScene::can_instance); + ClassDB::bind_method(D_METHOD("_set_bundled_scene"),&PackedScene::_set_bundled_scene); + ClassDB::bind_method(D_METHOD("_get_bundled_scene"),&PackedScene::_get_bundled_scene); + ClassDB::bind_method(D_METHOD("get_state:SceneState"),&PackedScene::get_state); - ADD_PROPERTY( PropertyInfo(Variant::DICTIONARY,"_bundled"),_SCS("_set_bundled_scene"),_SCS("_get_bundled_scene")); + ADD_PROPERTY( PropertyInfo(Variant::DICTIONARY,"_bundled"),"_set_bundled_scene","_get_bundled_scene"); BIND_CONSTANT( GEN_EDIT_STATE_DISABLED ); BIND_CONSTANT( GEN_EDIT_STATE_INSTANCE ); |