2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* scene_preloader.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 14:11:45 +02:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
2018-01-02 11:27:24 +01:00
|
|
|
/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
|
2014-02-10 02:10:30 +01:00
|
|
|
/* */
|
|
|
|
/* 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. */
|
|
|
|
/*************************************************************************/
|
2014-10-07 06:31:49 +02:00
|
|
|
#include "scene_preloader.h"
|
|
|
|
#include "globals.h"
|
|
|
|
|
|
|
|
bool ScenePreloader::can_instance() const {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
return nodes.size() > 0;
|
2014-10-07 06:31:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Node *ScenePreloader::instance() const {
|
|
|
|
|
|
|
|
int nc = nodes.size();
|
2017-03-19 00:36:26 +01:00
|
|
|
ERR_FAIL_COND_V(nc == 0, NULL);
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
const StringName *snames = NULL;
|
|
|
|
int sname_count = names.size();
|
2014-10-07 06:31:49 +02:00
|
|
|
if (sname_count)
|
2017-03-19 00:36:26 +01:00
|
|
|
snames = &names[0];
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
const Variant *props = NULL;
|
|
|
|
int prop_count = variants.size();
|
2014-10-07 06:31:49 +02:00
|
|
|
if (prop_count)
|
2017-03-19 00:36:26 +01:00
|
|
|
props = &variants[0];
|
2014-10-07 06:31:49 +02:00
|
|
|
|
|
|
|
Vector<Variant> properties;
|
|
|
|
|
|
|
|
const NodeData *nd = &nodes[0];
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
Node **ret_nodes = (Node **)alloca(sizeof(Node *) * nc);
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < nc; i++) {
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
const NodeData &n = nd[i];
|
2014-10-07 06:31:49 +02:00
|
|
|
|
|
|
|
if (!ObjectTypeDB::is_type_enabled(snames[n.type])) {
|
2017-03-19 00:36:26 +01:00
|
|
|
ret_nodes[i] = NULL;
|
2014-10-07 06:31:49 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
Object *obj = ObjectTypeDB::instance(snames[n.type]);
|
|
|
|
ERR_FAIL_COND_V(!obj, NULL);
|
2014-10-07 06:31:49 +02:00
|
|
|
Node *node = obj->cast_to<Node>();
|
2017-03-19 00:36:26 +01:00
|
|
|
ERR_FAIL_COND_V(!node, NULL);
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
int nprop_count = n.properties.size();
|
2014-10-07 06:31:49 +02:00
|
|
|
if (nprop_count) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
const NodeData::Property *nprops = &n.properties[0];
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int j = 0; j < nprop_count; j++) {
|
2014-10-07 06:31:49 +02:00
|
|
|
|
|
|
|
bool valid;
|
2017-03-19 00:36:26 +01:00
|
|
|
node->set(snames[nprops[j].name], props[nprops[j].value], &valid);
|
2014-10-07 06:31:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
node->set_name(snames[n.name]);
|
|
|
|
ret_nodes[i] = node;
|
|
|
|
if (i > 0) {
|
|
|
|
ERR_FAIL_INDEX_V(n.parent, i, NULL);
|
|
|
|
ERR_FAIL_COND_V(!ret_nodes[n.parent], NULL);
|
2014-10-07 06:31:49 +02:00
|
|
|
ret_nodes[n.parent]->add_child(node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//do connections
|
|
|
|
|
|
|
|
int cc = connections.size();
|
|
|
|
const ConnectionData *cdata = connections.ptr();
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < cc; i++) {
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
const ConnectionData &c = cdata[i];
|
|
|
|
ERR_FAIL_INDEX_V(c.from, nc, NULL);
|
|
|
|
ERR_FAIL_INDEX_V(c.to, nc, NULL);
|
2014-10-07 06:31:49 +02:00
|
|
|
|
|
|
|
Vector<Variant> binds;
|
|
|
|
if (c.binds.size()) {
|
|
|
|
binds.resize(c.binds.size());
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int j = 0; j < c.binds.size(); j++)
|
|
|
|
binds[j] = props[c.binds[j]];
|
2014-10-07 06:31:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!ret_nodes[c.from] || !ret_nodes[c.to])
|
|
|
|
continue;
|
2017-03-19 00:36:26 +01:00
|
|
|
ret_nodes[c.from]->connect(snames[c.signal], ret_nodes[c.to], snames[c.method], binds, CONNECT_PERSIST);
|
2014-10-07 06:31:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret_nodes[0];
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
static int _nm_get_string(const String &p_string, Map<StringName, int> &name_map) {
|
2014-10-07 06:31:49 +02:00
|
|
|
|
|
|
|
if (name_map.has(p_string))
|
|
|
|
return name_map[p_string];
|
|
|
|
|
|
|
|
int idx = name_map.size();
|
2017-03-19 00:36:26 +01:00
|
|
|
name_map[p_string] = idx;
|
2014-10-07 06:31:49 +02:00
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
static int _vm_get_variant(const Variant &p_variant, HashMap<Variant, int, VariantHasher> &variant_map) {
|
2014-10-07 06:31:49 +02:00
|
|
|
|
|
|
|
if (variant_map.has(p_variant))
|
|
|
|
return variant_map[p_variant];
|
|
|
|
|
|
|
|
int idx = variant_map.size();
|
2017-03-19 00:36:26 +01:00
|
|
|
variant_map[p_variant] = idx;
|
2014-10-07 06:31:49 +02:00
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void ScenePreloader::_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) {
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (p_node != p_owner && !p_node->get_owner())
|
2014-10-07 06:31:49 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
NodeData nd;
|
2017-03-19 00:36:26 +01:00
|
|
|
nd.name = _nm_get_string(p_node->get_name(), name_map);
|
|
|
|
nd.type = _nm_get_string(p_node->get_type(), name_map);
|
|
|
|
nd.parent = p_parent_idx;
|
2014-10-07 06:31:49 +02:00
|
|
|
|
|
|
|
List<PropertyInfo> plist;
|
|
|
|
p_node->get_property_list(&plist);
|
2017-03-19 00:36:26 +01:00
|
|
|
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
|
2014-10-07 06:31:49 +02:00
|
|
|
|
|
|
|
if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
NodeData::Property prop;
|
2017-03-19 00:36:26 +01:00
|
|
|
prop.name = _nm_get_string(E->get().name, name_map);
|
|
|
|
prop.value = _vm_get_variant(p_node->get(E->get().name), variant_map);
|
2014-10-07 06:31:49 +02:00
|
|
|
nd.properties.push_back(prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
int idx = nodes.size();
|
2017-03-19 00:36:26 +01:00
|
|
|
node_map[p_node] = idx;
|
2014-10-07 06:31:49 +02:00
|
|
|
nodes.push_back(nd);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < p_node->get_child_count(); i++) {
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
Node *c = p_node->get_child(i);
|
|
|
|
_parse_node(p_owner, c, idx, name_map, variant_map, node_map);
|
2014-10-07 06:31:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void ScenePreloader::_parse_connections(Node *p_node, Map<StringName, int> &name_map, HashMap<Variant, int, VariantHasher> &variant_map, Map<Node *, int> &node_map, bool p_instance) {
|
2014-10-07 06:31:49 +02:00
|
|
|
|
|
|
|
List<MethodInfo> signals;
|
|
|
|
p_node->get_signal_list(&signals);
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (List<MethodInfo>::Element *E = signals.front(); E; E = E->next()) {
|
2014-10-07 06:31:49 +02:00
|
|
|
|
|
|
|
List<Node::Connection> conns;
|
2017-03-19 00:36:26 +01:00
|
|
|
p_node->get_signal_connection_list(E->get().name, &conns);
|
|
|
|
for (List<Node::Connection>::Element *F = conns.front(); F; F = F->next()) {
|
2014-10-07 06:31:49 +02:00
|
|
|
|
|
|
|
const Node::Connection &c = F->get();
|
2017-03-19 00:36:26 +01:00
|
|
|
if (!(c.flags & CONNECT_PERSIST))
|
2014-10-07 06:31:49 +02:00
|
|
|
continue;
|
2017-03-19 00:36:26 +01:00
|
|
|
Node *n = c.target->cast_to<Node>();
|
2014-10-07 06:31:49 +02:00
|
|
|
if (!n)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!node_map.has(n))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ConnectionData cd;
|
2017-03-19 00:36:26 +01:00
|
|
|
cd.from = node_map[p_node];
|
|
|
|
cd.to = node_map[n];
|
|
|
|
cd.method = _nm_get_string(c.method, name_map);
|
|
|
|
cd.signal = _nm_get_string(c.signal, name_map);
|
|
|
|
for (int i = 0; i < c.binds.size(); i++) {
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
cd.binds.push_back(_vm_get_variant(c.binds[i], variant_map));
|
2014-10-07 06:31:49 +02:00
|
|
|
}
|
|
|
|
connections.push_back(cd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
Error ScenePreloader::load_scene(const String &p_path) {
|
2014-10-07 06:31:49 +02:00
|
|
|
|
|
|
|
return ERR_CANT_OPEN;
|
|
|
|
#if 0
|
|
|
|
if (path==p_path)
|
|
|
|
return OK;
|
|
|
|
|
|
|
|
String p=Globals::get_singleton()->localize_path(p_path);
|
|
|
|
clear();
|
|
|
|
|
|
|
|
Node *scene = SceneLoader::load(p);
|
|
|
|
|
|
|
|
ERR_FAIL_COND_V(!scene,ERR_CANT_OPEN);
|
|
|
|
|
|
|
|
path=p;
|
|
|
|
|
|
|
|
Map<StringName,int> name_map;
|
|
|
|
HashMap<Variant,int,VariantHasher> variant_map;
|
|
|
|
Map<Node*,int> node_map;
|
|
|
|
|
|
|
|
_parse_node(scene,scene,-1,name_map,variant_map,node_map);
|
|
|
|
|
|
|
|
|
|
|
|
names.resize(name_map.size());
|
|
|
|
|
|
|
|
for(Map<StringName,int>::Element *E=name_map.front();E;E=E->next()) {
|
|
|
|
|
|
|
|
names[E->get()]=E->key();
|
|
|
|
}
|
|
|
|
|
|
|
|
variants.resize(variant_map.size());
|
|
|
|
const Variant *K=NULL;
|
|
|
|
while((K=variant_map.next(K))) {
|
|
|
|
|
|
|
|
int idx = variant_map[*K];
|
|
|
|
variants[idx]=*K;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
memdelete(scene); // <- me falto esto :(
|
|
|
|
return OK;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
String ScenePreloader::get_scene_path() const {
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScenePreloader::clear() {
|
|
|
|
|
|
|
|
names.clear();
|
|
|
|
variants.clear();
|
|
|
|
nodes.clear();
|
|
|
|
connections.clear();
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void ScenePreloader::_set_bundled_scene(const Dictionary &d) {
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ERR_FAIL_COND(!d.has("names"));
|
|
|
|
ERR_FAIL_COND(!d.has("variants"));
|
|
|
|
ERR_FAIL_COND(!d.has("node_count"));
|
|
|
|
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"));
|
2014-10-07 06:31:49 +02:00
|
|
|
|
|
|
|
DVector<String> snames = d["names"];
|
|
|
|
if (snames.size()) {
|
|
|
|
|
|
|
|
int namecount = snames.size();
|
|
|
|
names.resize(namecount);
|
2017-03-19 00:36:26 +01:00
|
|
|
DVector<String>::Read r = snames.read();
|
|
|
|
for (int i = 0; i < names.size(); i++)
|
|
|
|
names[i] = r[i];
|
2014-10-07 06:31:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Array svariants = d["variants"];
|
|
|
|
|
|
|
|
if (svariants.size()) {
|
2017-03-19 00:36:26 +01:00
|
|
|
int varcount = svariants.size();
|
2014-10-07 06:31:49 +02:00
|
|
|
variants.resize(varcount);
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < varcount; i++) {
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
variants[i] = svariants[i];
|
2014-10-07 06:31:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
variants.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
nodes.resize(d["node_count"]);
|
2017-03-19 00:36:26 +01:00
|
|
|
int nc = nodes.size();
|
2014-10-07 06:31:49 +02:00
|
|
|
if (nc) {
|
|
|
|
DVector<int> snodes = d["nodes"];
|
|
|
|
DVector<int>::Read r = snodes.read();
|
2017-03-19 00:36:26 +01:00
|
|
|
int idx = 0;
|
|
|
|
for (int i = 0; i < nc; i++) {
|
2014-10-07 06:31:49 +02:00
|
|
|
NodeData &nd = nodes[i];
|
2017-03-19 00:36:26 +01:00
|
|
|
nd.parent = r[idx++];
|
|
|
|
nd.type = r[idx++];
|
|
|
|
nd.name = r[idx++];
|
2014-10-07 06:31:49 +02:00
|
|
|
nd.properties.resize(r[idx++]);
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int j = 0; j < nd.properties.size(); j++) {
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
nd.properties[j].name = r[idx++];
|
|
|
|
nd.properties[j].value = r[idx++];
|
2014-10-07 06:31:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
connections.resize(d["conn_count"]);
|
2017-03-19 00:36:26 +01:00
|
|
|
int cc = connections.size();
|
2014-10-07 06:31:49 +02:00
|
|
|
|
|
|
|
if (cc) {
|
|
|
|
|
|
|
|
DVector<int> sconns = d["conns"];
|
|
|
|
DVector<int>::Read r = sconns.read();
|
2017-03-19 00:36:26 +01:00
|
|
|
int idx = 0;
|
|
|
|
for (int i = 0; i < nc; i++) {
|
2014-10-07 06:31:49 +02:00
|
|
|
ConnectionData &cd = connections[nc];
|
2017-03-19 00:36:26 +01:00
|
|
|
cd.from = r[idx++];
|
|
|
|
cd.to = r[idx++];
|
|
|
|
cd.signal = r[idx++];
|
|
|
|
cd.method = r[idx++];
|
2014-10-07 06:31:49 +02:00
|
|
|
cd.binds.resize(r[idx++]);
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int j = 0; j < cd.binds.size(); j++) {
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
cd.binds[j] = r[idx++];
|
2014-10-07 06:31:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
path = d["path"];
|
2014-10-07 06:31:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary ScenePreloader::_get_bundled_scene() const {
|
|
|
|
|
|
|
|
DVector<String> rnames;
|
|
|
|
rnames.resize(names.size());
|
|
|
|
|
|
|
|
if (names.size()) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
DVector<String>::Write r = rnames.write();
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < names.size(); i++)
|
|
|
|
r[i] = names[i];
|
2014-10-07 06:31:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Dictionary d;
|
2017-03-19 00:36:26 +01:00
|
|
|
d["names"] = rnames;
|
|
|
|
d["variants"] = variants;
|
2014-10-07 06:31:49 +02:00
|
|
|
|
|
|
|
Vector<int> rnodes;
|
2017-03-19 00:36:26 +01:00
|
|
|
d["node_count"] = nodes.size();
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < nodes.size(); i++) {
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
const NodeData &nd = nodes[i];
|
2014-10-07 06:31:49 +02:00
|
|
|
rnodes.push_back(nd.parent);
|
|
|
|
rnodes.push_back(nd.type);
|
|
|
|
rnodes.push_back(nd.name);
|
|
|
|
rnodes.push_back(nd.properties.size());
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int j = 0; j < nd.properties.size(); j++) {
|
2014-10-07 06:31:49 +02:00
|
|
|
|
|
|
|
rnodes.push_back(nd.properties[j].name);
|
|
|
|
rnodes.push_back(nd.properties[j].value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
d["nodes"] = rnodes;
|
2014-10-07 06:31:49 +02:00
|
|
|
|
|
|
|
Vector<int> rconns;
|
2017-03-19 00:36:26 +01:00
|
|
|
d["conn_count"] = connections.size();
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < connections.size(); i++) {
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
const ConnectionData &cd = connections[i];
|
2014-10-07 06:31:49 +02:00
|
|
|
rconns.push_back(cd.from);
|
|
|
|
rconns.push_back(cd.to);
|
|
|
|
rconns.push_back(cd.signal);
|
|
|
|
rconns.push_back(cd.method);
|
|
|
|
rconns.push_back(cd.binds.size());
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int j = 0; j < cd.binds.size(); j++)
|
2014-10-07 06:31:49 +02:00
|
|
|
rconns.push_back(cd.binds[j]);
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
d["conns"] = rconns;
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
d["path"] = path;
|
2014-10-07 06:31:49 +02:00
|
|
|
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScenePreloader::_bind_methods() {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ObjectTypeDB::bind_method(_MD("load_scene", "path"), &ScenePreloader::load_scene);
|
|
|
|
ObjectTypeDB::bind_method(_MD("get_scene_path"), &ScenePreloader::get_scene_path);
|
|
|
|
ObjectTypeDB::bind_method(_MD("instance:Node"), &ScenePreloader::instance);
|
|
|
|
ObjectTypeDB::bind_method(_MD("can_instance"), &ScenePreloader::can_instance);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_set_bundled_scene"), &ScenePreloader::_set_bundled_scene);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_get_bundled_scene"), &ScenePreloader::_get_bundled_scene);
|
2014-10-07 06:31:49 +02:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "_bundled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_BUNDLE), _SCS("_set_bundled_scene"), _SCS("_get_bundled_scene"));
|
2014-10-07 06:31:49 +02:00
|
|
|
#if 0
|
|
|
|
List<String> extensions;
|
|
|
|
SceneLoader::get_recognized_extensions(&extensions);
|
|
|
|
String exthint;
|
|
|
|
for (List<String>::Element*E=extensions.front();E;E=E->next()) {
|
|
|
|
|
|
|
|
if (exthint!="")
|
|
|
|
exthint+=",";
|
|
|
|
exthint+="*."+E->get();
|
|
|
|
}
|
|
|
|
|
|
|
|
exthint+="; Scenes";
|
|
|
|
|
|
|
|
ADD_PROPERTY( PropertyInfo(Variant::STRING,"scene",PROPERTY_HINT_FILE,exthint),_SCS("load_scene"),_SCS("get_scene_path"));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
ScenePreloader::ScenePreloader() {
|
|
|
|
}
|