4 #include "blob_exhibit.h"
7 static Exhibit *create_exhibit(const char *type);
9 ExhibitManager::ExhibitManager()
13 ExhibitManager::~ExhibitManager()
15 int num = (int)items.size();
16 for(int i=0; i<num; i++) {
22 void ExhibitManager::add(Exhibit *ex)
24 std::vector<Exhibit*>::iterator it = std::find(items.begin(), items.end(), ex);
25 if(it == items.end()) {
30 bool ExhibitManager::remove(Exhibit *ex)
32 std::vector<Exhibit*>::iterator it = std::find(items.begin(), items.end(), ex);
33 if(it != items.end()) {
40 bool ExhibitManager::load(MetaScene *mscn, const char *fname)
42 struct ts_node *root = ts_load(fname);
43 if(!root || strcmp(root->name, "exhibits") != 0) {
45 error_log("failed to load exhibits\n");
49 struct ts_node *iter = root->child_list;
51 struct ts_node *node = iter;
54 if(strcmp(node->name, "item") == 0) {
57 const char *amatch = ts_get_attr_str(node, "match_node");
58 if(!amatch || !(snode = mscn->match_node(amatch))) {
59 error_log("regexp \"%s\" didn't match any nodes\n", amatch ? amatch : "");
64 const char *atype = ts_get_attr_str(node, "type");
65 if(!atype || !(ex = create_exhibit(atype))) {
66 error_log("failed to create exhibit of type: %s\n", atype);
79 void ExhibitManager::update(float dt)
81 int num = items.size();
82 for(int i=0; i<num; i++) {
87 static Exhibit *create_exhibit(const char *type)
89 if(strcmp(type, "static") == 0) {
91 } else if(strcmp(type, "blobs") == 0) {
92 return new BlobExhibit;
94 error_log("unknown exhibit type: %s\n", type);