12 static bool proc_node(Scene *scn, struct ts_node *node);
13 static struct ts_attr *attr_inscope(struct ts_node *node, const char *name);
15 bool load_scene(Scene *scn, const char *fname)
17 struct ts_node *root = ts_load(fname);
18 if(!root || strcmp(root->name, "scene") != 0) {
20 fprintf(stderr, "failed to load scene metadata: %s\n", fname);
24 bool res = proc_node(scn, root);
29 static bool proc_node(Scene *scn, struct ts_node *node)
31 struct ts_node *c = node->child_list;
33 if(!proc_node(scn, c)) {
39 // do this last to allow other contents of the node to do their thing
40 if(strcmp(node->name, "scenefile") == 0) {
41 const char *fname = ts_get_attr_str(node, "file");
43 struct ts_attr *adpath = attr_inscope(node, "datapath");
44 if(adpath && adpath->val.type == TS_STRING) {
45 printf("adding data path: %s\n", adpath->val.str);
46 datamap_set_path(adpath->val.str);
49 int namesz = datamap_lookup(fname, 0, 0);
50 char *namebuf = (char*)alloca(namesz + 1);
51 if(datamap_lookup(fname, namebuf, namesz + 1)) {
55 if(!(scn->load(fname, SCNLOAD_FLIPTEX))) {
61 } else if(strcmp(node->name, "remap") == 0) {
62 const char *match = ts_get_attr_str(node, "match");
63 const char *replace = ts_get_attr_str(node, "replace");
64 if(match && replace) {
65 datamap_map(match, replace);
72 static struct ts_attr *attr_inscope(struct ts_node *node, const char *name)
74 struct ts_attr *attr = 0;
76 while(node && !(attr = ts_get_attr(node, name))) {