summaryrefslogtreecommitdiff
path: root/sunkenEngine/src/playlist.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2015-03-29 22:33:39 +0100
committerTim Redfern <tim@eclectronics.org>2015-03-29 22:33:39 +0100
commita28770084787abd086c30b0ed4483fe22c19dca4 (patch)
treeee798bc2a464181ddf37999118420164d207f131 /sunkenEngine/src/playlist.cpp
parent1aef8df9feeff8c76411bb4f4faa2e51d3ee252e (diff)
working for parlour OSX
Diffstat (limited to 'sunkenEngine/src/playlist.cpp')
-rwxr-xr-xsunkenEngine/src/playlist.cpp127
1 files changed, 127 insertions, 0 deletions
diff --git a/sunkenEngine/src/playlist.cpp b/sunkenEngine/src/playlist.cpp
new file mode 100755
index 0000000..eac895f
--- /dev/null
+++ b/sunkenEngine/src/playlist.cpp
@@ -0,0 +1,127 @@
+#include "playlist.h"
+
+playlist::playlist()
+{
+ name="";
+
+}
+
+void playlist::load(string _name){
+ //printf("loading %s\n",_name.c_str());
+ thumbnail.allocate(128,128,GL_RGB); //segfault here orig 128,128,GL_RGB
+ thumbnailed=false;
+
+ if( !XML.loadFile(_name) ){
+ printf("unable to load %s check data/ folder\n",_name.c_str());
+ }else {
+ //printf("starting loader thread\n");
+ loadimg(); //how to do this from the worker thread???
+ startThread(false, false); //blocking, verbose
+ }
+
+
+
+}
+
+void playlist::threadedFunction(){
+ if( lock() ){
+ loadLayers();
+ unlock();
+ printf("unlocking thread\n");
+ }
+}
+
+void playlist::loadLayers(){
+ int numLayers=0;
+ layers.clear();
+ name=XML.getAttribute("playlist", "name", "");
+ float speed=XML.getAttribute("playlist", "speed", 0);
+ if(XML.pushTag("playlist")) {
+ numLayers=XML.getNumTags("svglayer");
+ if(numLayers) {
+ for (int i=0;i<numLayers;i++) {
+ string s=XML.getAttribute("svglayer", "file", "",i);
+ printf("loading %s: \n",s.c_str());
+ layers[XML.getAttribute("svglayer", "note", 0,i)]=new svglayer(s);
+ }
+ thumbnailed=false;
+ }
+ numLayers=XML.getNumTags("movlayer");
+ if(numLayers) {
+ for (int i=0;i<numLayers;i++) {
+ string s=XML.getAttribute("movlayer", "file", "",i);
+ printf("loading %s: \n",s.c_str());
+ int note=XML.getAttribute("movlayer", "note", 0,i);
+ int endnote=XML.getAttribute("movlayer", "endnote", 0,i);
+ layers[note]=new videolayer(XML.getAttribute("movlayer", "file", "",i),note,endnote,speed);
+ if (endnote>note) {
+ for (int j=note+1;j<endnote;j++) {
+ layers[j]=layers[note];
+ }
+ }
+ }
+ thumbnailed=false;
+ }
+ numLayers=XML.getNumTags("imglayer");
+ if(numLayers) {
+ for (int i=0;i<numLayers;i++) {
+ string s=XML.getAttribute("imglayer", "files", "",i);
+ printf("loading %s: \n",s.c_str());
+ int note=XML.getAttribute("imglayer", "note", 0,i);
+ int endnote=XML.getAttribute("imglayer", "endnote", 0,i);
+ float rate=XML.getAttribute("imglayer", "rate", 0.0,i);
+ int frames=XML.getAttribute("imglayer", "frames", 0,i);
+ int start=XML.getAttribute("imglayer", "start", 1,i);
+ layers[note]=new imglayer(s,frames,start,rate,note,endnote);
+ if (endnote>note) {
+ for (int j=note+1;j<=endnote;j++) {
+ layers[j]=layers[note];
+ }
+ }
+ }
+ thumbnailed=false;
+ }
+ XML.popTag();
+ }
+
+}
+
+void playlist::makeThumbnail(){
+ if (layers.size()) {
+ thumbnail.begin();
+ ofBackground(0,0,0);
+ ofPushMatrix();
+ ofTranslate(64,64);
+ ofScale(0.2,0.2,0.2);
+ ofTranslate(-64,-64);
+ map<int,layer*>::iterator i=layers.begin();
+ i->second->draw(1.0,64,64,0.0);
+ ofPopMatrix();
+ thumbnail.end();
+ thumbnailed=true;
+ }
+}
+
+
+void playlist::loadimg(){
+ int numLayers=0;
+ layers.clear();
+ if(XML.pushTag("playlist")) {
+ numLayers=XML.getNumTags("imglayer");
+ if(numLayers) {
+ for (int i=0;i<numLayers;i++) {
+ string s=XML.getAttribute("imglayer", "file", "",i);
+ printf("%s: ",s.c_str());
+ layers[XML.getAttribute("imglayer", "note", 0,i)]=new imglayer(XML.getAttribute("imglayer", "file", "",i));
+ }
+ }
+ else printf("no IMG layers loaded!\n");
+ XML.popTag();
+ }
+
+}
+
+playlist::~playlist()
+{
+ //dtor
+}