adding exhibit data, starting with descriptions
authorJohn Tsiombikas <nuclear@member.fsf.org>
Wed, 10 Jan 2018 07:08:39 +0000 (09:08 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Wed, 10 Jan 2018 07:08:39 +0000 (09:08 +0200)
src/exhibit.cc
src/exhibit.h
src/exman.cc

index d76b291..eaa2251 100644 (file)
@@ -11,6 +11,8 @@ public:
        ExhibitPriv();
 };
 
+
+// selection
 ExSelection::ExSelection(Exhibit *ex)
 {
        this->ex = ex;
@@ -23,11 +25,24 @@ ExSelection::operator bool() const
        return ex != 0;
 }
 
+// Exhibit data
+ExData::ExData()
+{
+       voice = 0;
+}
+
+ExData::~ExData()
+{
+       delete voice;
+}
+
+// private data for each exhibit type
 ExhibitPriv::ExhibitPriv()
 {
        orig_node = 0;
 }
 
+// exhibit class
 Exhibit::Exhibit()
 {
        priv = new ExhibitPriv;
index 63b2898..0f98b05 100644 (file)
@@ -1,9 +1,11 @@
 #ifndef EXHIBIT_H_
 #define EXHIBIT_H_
 
+#include <string>
 #include <gmath/gmath.h>
 #include "object.h"
 #include "geom.h"
+#include "audio/stream.h"
 
 class Exhibit;
 class ExhibitPriv;
@@ -28,6 +30,24 @@ public:
        operator bool() const;
 };
 
+enum {
+       EXDATA_INFO,
+       EXDATA_VIDEO
+};
+
+class ExData {
+public:
+       int type;
+
+       std::string text;
+       AudioStream *voice;
+       // TODO: video stream
+
+       ExData();
+       ~ExData();
+};
+
+
 /* TODO
 - select me aktina kai select me sfaira, epistrefei Selection
 - hover me aktina kai hover me sfaira
@@ -38,6 +58,8 @@ private:
        ExhibitPriv *priv;
 
 public:
+       std::vector<ExData> data;
+
        Exhibit();
        virtual ~Exhibit();
 
index 900d860..6517b65 100644 (file)
@@ -73,6 +73,25 @@ bool ExhibitManager::load(MetaScene *mscn, const char *fname)
                                continue;
                        }
 
+                       const char *desc = ts_get_attr_str(node, "description");
+                       const char *voice = ts_get_attr_str(node, "voiceover");
+                       if(desc || voice) {
+                               ExData exd;
+
+                               if(desc) {
+                                       exd.text = std::string(desc);
+                               }
+                               if(voice) {
+                                       exd.voice = new OggVorbisStream;
+                                       if(!exd.voice->open(voice)) {
+                                               error_log("failed to open voiceover: %s\n", voice);
+                                               delete exd.voice;
+                                               exd.voice = 0;
+                                       }
+                               }
+                               ex->data.push_back(exd);
+                       }
+
                        ex->set_node(snode);
                        items.push_back(ex);
                }