From 87c535995a59391b50a242a9a71bc0c420da399c Mon Sep 17 00:00:00 2001 From: tim Date: Tue, 13 Jun 2017 23:34:14 +0100 Subject: looking good --- menuApp/src/dirscanner.cpp | 107 +++++++++++++++++++++++---- menuApp/src/dirscanner.h | 26 +++++-- menuApp/src/ofApp.cpp | 175 +++++++++++++++++++++++---------------------- menuApp/src/ofApp.h | 3 +- 4 files changed, 207 insertions(+), 104 deletions(-) (limited to 'menuApp') diff --git a/menuApp/src/dirscanner.cpp b/menuApp/src/dirscanner.cpp index 5798e55..d0f80a0 100644 --- a/menuApp/src/dirscanner.cpp +++ b/menuApp/src/dirscanner.cpp @@ -1,13 +1,56 @@ #include "dirscanner.h" void playItem::play(){ - + //ofLogNotice() << "playing----->"<0; } void playItem::draw(){ + if (image.isAllocated()){ -} -bool playItem::isFinished(){ + //ofEnableAlphaBlending(); + //ofSetColor(255,255,255,1.0); + image.draw(0,0,ofGetWidth(),ofGetHeight()); + //ofDisableAlphaBlending(); + if (ofGetElapsedTimef()-startTime>5.0){ + isFinished=true; + } + } + if (video.isLoaded()){ + video.update(); + video.draw(0,0,ofGetWidth(),ofGetHeight()); + //ofLogNotice() << "position: "<=time){ + if (slots[i].start<=railwaytime&&slots[i].end>=railwaytime){ return i; } } return -1; } -void dirPlayer::load(){ - +void dirPlayer::load(std::string path){ + items.clear(); + ofDirectory dir(path); + dir.allowExt("mp4"); + dir.allowExt("mov"); + dir.allowExt("jpg"); + dir.allowExt("png"); + dir.listDir(); + for(int i = 0; i < dir.size(); i++){ + string d=dir.getPath(i); + playItem item; + if (item.load(d)){ + ofLogNotice() << "pushing back: "<getSlotForTime(); + if(slot==-1) return false; + if (slot!=currentslot){ + if (slot>-1){ + ofLogNotice() << "entering slot "<slots[slot].path; + load(scanner->slots[slot].path); + } + else { + ofLogNotice() << "leaving slot"; + } + currentslot=slot; + } + if (items[currentItem].isFinished){ + items[currentItem].isFinished=false; + currentItem=(currentItem+1)%items.size(); + items[currentItem].play(); + ofLogNotice() << "playing clip "< slots; @@ -42,11 +49,18 @@ class dirScanner { class dirPlayer { public: - dirPlayer(std::string _d){ - playdir=_d; + dirPlayer(){ + currentslot=-1; + } + dirPlayer(dirScanner *_s){ + scanner=_s; + dirPlayer(); } vector items; string playdir; - void load(); - void draw(); + int currentslot; + dirScanner *scanner; + void load(std::string path); + bool draw(); + int currentItem; }; \ No newline at end of file diff --git a/menuApp/src/ofApp.cpp b/menuApp/src/ofApp.cpp index 47e0967..14ce45f 100644 --- a/menuApp/src/ofApp.cpp +++ b/menuApp/src/ofApp.cpp @@ -131,9 +131,11 @@ bool ofApp::loadInstagramFeed(){ //-------------------------------------------------------------- void ofApp::setup(){ - //Dirscanner=dirScanner("/home/tim/Dropbox/menugrab"); + scanner=dirScanner(ofFilePath().getUserHomeDir()+"/Dropbox/menugrab"); - //Dirscanner.scan(); + scanner.scan(); + + player=dirPlayer(&scanner); /* std::string str ("€"); @@ -186,96 +188,99 @@ void ofApp::update(){ void ofApp::draw(){ ofSetColor(255,255,255); - if(ofGetElapsedTimef()-lastPoll>POLL_INTERVAL) { - loadInstagramFeed(); - } + if (!player.draw()){ -ofPushMatrix(); + if(ofGetElapsedTimef()-lastPoll>POLL_INTERVAL) { + loadInstagramFeed(); + } - if(ROTATION>0){ - ofTranslate(540*FACTOR,960*FACTOR); - ofRotate(-ROTATION); - ofTranslate(-120*FACTOR,-540*FACTOR); - } - -ofPushMatrix(); //Store the coordinate system nexessary for some reason - background.draw(0,0,1080*FACTOR,1920*FACTOR); //ofGetWidth(),ofGetHeight()); -ofPopMatrix(); //Restore the coordinate system - - int colinitialoffset=40; - int rowinitialoffset=60; - int coloffset=520; - int imgsize=480; - int rowoffset=615; - int col=0; - int row=0; - int cols=2; - int textcolinset=10; - int textrowinset=50; + ofPushMatrix(); - - //some kind of rendering bug with textsuite means it has to go last or everything is dim - - bool imageWaiting=false; - - if (!items.empty()) { - for (int i = 0; i < items.size(); i++) { - - if (items[i].image->isAllocated()) { - - int imgx=(colinitialoffset+(col*coloffset))*FACTOR; - int imgy=(rowinitialoffset+(row*rowoffset))*FACTOR; - items[i].image->draw(imgx,imgy,imgsize*FACTOR,imgsize*FACTOR); - myText.setText(items[i].caption); - myText.wrapTextX(imgsize*FACTOR); - myText.setColor(255,255,255,255); - myText.drawCenter(imgx+((imgsize*FACTOR)/2),imgy+((imgsize+textcolinset)*FACTOR),2); - - myText.setText(items[i].price); - myText.wrapTextX(imgsize*FACTOR); - myText.setColor(255,255,255,255); - myText.drawCenter(imgx+((imgsize*FACTOR)/2),imgy+((imgsize+textcolinset+(FONTSPACING*2))*FACTOR),2); - } - else imageWaiting=true; - - col++; - if (col==cols){ - col=0; - row++; - } - } - } + if(ROTATION>0){ + ofTranslate(540*FACTOR,960*FACTOR); + ofRotate(-ROTATION); + ofTranslate(-120*FACTOR,-540*FACTOR); + } + + ofPushMatrix(); //Store the coordinate system nexessary for some reason + background.draw(0,0,1080*FACTOR,1920*FACTOR); //ofGetWidth(),ofGetHeight()); + ofPopMatrix(); //Restore the coordinate system + + int colinitialoffset=40; + int rowinitialoffset=60; + int coloffset=520; + int imgsize=480; + int rowoffset=615; + int col=0; + int row=0; + int cols=2; + int textcolinset=10; + int textrowinset=50; + + + //some kind of rendering bug with textsuite means it has to go last or everything is dim + + bool imageWaiting=false; + + if (!items.empty()) { + for (int i = 0; i < items.size(); i++) { + + if (items[i].image->isAllocated()) { + + int imgx=(colinitialoffset+(col*coloffset))*FACTOR; + int imgy=(rowinitialoffset+(row*rowoffset))*FACTOR; + items[i].image->draw(imgx,imgy,imgsize*FACTOR,imgsize*FACTOR); + myText.setText(items[i].caption); + myText.wrapTextX(imgsize*FACTOR); + myText.setColor(255,255,255,255); + myText.drawCenter(imgx+((imgsize*FACTOR)/2),imgy+((imgsize+textcolinset)*FACTOR),2); + + myText.setText(items[i].price); + myText.wrapTextX(imgsize*FACTOR); + myText.setColor(255,255,255,255); + myText.drawCenter(imgx+((imgsize*FACTOR)/2),imgy+((imgsize+textcolinset+(FONTSPACING*2))*FACTOR),2); + } + else imageWaiting=true; + + col++; + if (col==cols){ + col=0; + row++; + } + } + } + + ofEnableAlphaBlending(); + overlay.draw(0,0,1080*FACTOR,1920*FACTOR); //ofGetWidth(),ofGetHeight()); //don't work on a horiz screen?? + ofDisableAlphaBlending(); + + //for some reason the final is only drawn on the frame AFTER all 5 images become allocated + //hence the "primed" mechanism + if (primed){ + ofImage img; + //float rotation=ofDegToRad(ROTATION); + //int width=(1920*FACTOR*sin(rotation))+(1080*FACTOR*cos(rotation)); + //int height=(1920*FACTOR*cos(rotation))+(1080*FACTOR*sin(rotation)); + img.grabScreen(0, 0,1920*FACTOR,1920*FACTOR); + if(ROTATION>0){ + img.rotate90(1); + img.crop(860*FACTOR,0,1080*FACTOR,1920*FACTOR); + } + else { + img.crop(0,0,1080*FACTOR,1920*FACTOR); + } + img.save(SCREENGRABFILEPATH); + primed=false; + } - ofEnableAlphaBlending(); - overlay.draw(0,0,1080*FACTOR,1920*FACTOR); //ofGetWidth(),ofGetHeight()); //don't work on a horiz screen?? - ofDisableAlphaBlending(); - - //for some reason the final is only drawn on the frame AFTER all 5 images become allocated - //hence the "primed" mechanism - if (primed){ - ofImage img; - //float rotation=ofDegToRad(ROTATION); - //int width=(1920*FACTOR*sin(rotation))+(1080*FACTOR*cos(rotation)); - //int height=(1920*FACTOR*cos(rotation))+(1080*FACTOR*sin(rotation)); - img.grabScreen(0, 0,1920*FACTOR,1920*FACTOR); - if(ROTATION>0){ - img.rotate90(1); - img.crop(860*FACTOR,0,1080*FACTOR,1920*FACTOR); - } - else { - img.crop(0,0,1080*FACTOR,1920*FACTOR); - } - img.save(SCREENGRABFILEPATH); - primed=false; - } + if (!isGrabbed&&!imageWaiting) { + primed=true; + isGrabbed=true; + } - if (!isGrabbed&&!imageWaiting) { - primed=true; - isGrabbed=true; + ofPopMatrix(); } -ofPopMatrix(); - } //-------------------------------------------------------------- diff --git a/menuApp/src/ofApp.h b/menuApp/src/ofApp.h index 1b94c06..0cb3705 100644 --- a/menuApp/src/ofApp.h +++ b/menuApp/src/ofApp.h @@ -69,7 +69,8 @@ class ofApp : public ofBaseApp{ ofImage background; ofImage overlay; - //dirScanner Dirscanner; + dirScanner scanner; + dirPlayer player; }; -- cgit v1.2.3