diff options
| author | tim <tim@eclectronics.org> | 2017-03-30 01:07:57 +0100 |
|---|---|---|
| committer | tim <tim@eclectronics.org> | 2017-03-30 01:07:57 +0100 |
| commit | e89f7750aff2e0a9fe8c4fd7fa60c62e0a02b594 (patch) | |
| tree | 260b3ced4eb049ced5ced148b446fef47ec4aefb /menuApp | |
| parent | d7eefb73403785845c3c6e9d77e09f2f9bdd4ff6 (diff) | |
cleanup
Diffstat (limited to 'menuApp')
| -rw-r--r-- | menuApp/src/ofApp.cpp | 45 | ||||
| -rw-r--r-- | menuApp/src/ofApp.h | 17 |
2 files changed, 26 insertions, 36 deletions
diff --git a/menuApp/src/ofApp.cpp b/menuApp/src/ofApp.cpp index f6f1c2f..6ac2b64 100644 --- a/menuApp/src/ofApp.cpp +++ b/menuApp/src/ofApp.cpp @@ -3,20 +3,14 @@ #define timtoken "3281768761.3dfcaf5.14ca9410c2aa4c00b9b60f36cd09d01a" #define hangdaitoken "3939854844.b31608d.a61a4e49a4dc40a688c22f4e0e81da3a" -/* -0. only display up to first hash -1. get tags - filter on tag -2. reload periodically -3. only reload changed images -*/ - -void ofApp::loadimages(){ +void ofApp::loadInstagramFeed(){ items.clear(); items.resize(IMAGE_SLOTS); instagram.getUserRecentMedia("self"); //instagram.getUserLikedMedia(12); ofLog(OF_LOG_NOTICE) << "instagram self feed -------------------> " << instagram.getImageURL().size() << " items "; + //leave in verbose logging as ofxInstagram does anyway int slot=0; @@ -28,21 +22,18 @@ void ofApp::loadimages(){ { vector <std::string> tokens = ofSplitString(instagram.getImageCaption()[i]," ",true,true); //,ignoreEmpty=false,trim=false); - //ofLog(OF_LOG_NOTICE) <<"got "<<tokens.size()<<" tokens"; - std::string caption; std::string price; - bool interesting=false; - std::string tags; - bool foundTags=false; - bool foundPrice=false; + bool interesting=false; + bool foundTags=false; + bool foundPrice=false; for(auto it = tokens.begin(); it != tokens.end(); it++){ if((*it).at(0)=='#'){ if (!foundPrice){ - price="free"; + price=""; foundPrice=true; } if (*it==menutag){ @@ -66,24 +57,24 @@ void ofApp::loadimages(){ if (interesting){ - items[slot]=menuItem(caption,price); - if (imagepool.find(instagram.getImageID()[i])==imagepool.end()){ - imagepool[instagram.getImageID()[i]]=ofImage(); - getImages.loadFromURL(imagepool[instagram.getImageID()[i]], instagram.getImageURL()[i]); + std::string id=instagram.getImageID()[i]; + + if (imagepool.find(id)==imagepool.end()){ + imagepool[id]=ofImage(); + getImages.loadFromURL(imagepool[id], instagram.getImageURL()[i]); - ofLog(OF_LOG_NOTICE) << menutag << " " << slot << " " << caption << price << instagram.getImageID()[i]; + ofLog(OF_LOG_NOTICE) << menutag << " " << slot << " " << caption << price << " " << id; } else { - ofLog(OF_LOG_NOTICE) << "REUSE " << slot << " " << menutag << " " << instagram.getImageID()[i]; + ofLog(OF_LOG_NOTICE) << "REUSE " << menutag << " " << slot << " " << id; } - items[slot].image=&imagepool[instagram.getImageID()[i]]; + items[slot].image=&imagepool[id]; - //getImages.loadFromURL(items[slot].image, instagram.getImageURL()[i]); slot++; if (slot==IMAGE_SLOTS) break; @@ -162,9 +153,9 @@ ofPopMatrix(); //Restore the coordinate system if (!items.empty()) { for (int i = 0; i < items.size(); i++) { - //for (int i = 0; i < 5; i++) { + if (items[i].image->isAllocated()) { - //ofLog(OF_LOG_NOTICE,"Image %i is %fx%f",i,images[i].getWidth(),images[i].getHeight()); + int imgx=(colinitialoffset+(col*coloffset))*FACTOR; int imgy=(rowinitialoffset+(row*rowoffset))*FACTOR; items[i].image->draw(imgx,imgy,imgsize*FACTOR,imgsize*FACTOR); @@ -187,11 +178,11 @@ ofPopMatrix(); //Restore the coordinate system } ofEnableAlphaBlending(); - overlay.draw(0,0,1080*FACTOR,1920*FACTOR); //ofGetWidth(),ofGetHeight()); + overlay.draw(0,0,1080*FACTOR,1920*FACTOR); //ofGetWidth(),ofGetHeight()); //don't work on a horiz screen?? ofDisableAlphaBlending(); if(ofGetElapsedTimef()-lastPoll>POLL_INTERVAL) { - loadimages(); + loadInstagramFeed(); lastPoll=ofGetElapsedTimef(); } diff --git a/menuApp/src/ofApp.h b/menuApp/src/ofApp.h index 7fd1c5f..1c1f747 100644 --- a/menuApp/src/ofApp.h +++ b/menuApp/src/ofApp.h @@ -30,7 +30,6 @@ class ofApp : public ofBaseApp{ void setup(); void update(); void draw(); - void loadimages(); void keyPressed(int key); void keyReleased(int key); @@ -45,24 +44,24 @@ class ofApp : public ofBaseApp{ void gotMessage(ofMessage msg); void exit(); - float lastPoll; - - ofImage background; - ofImage overlay; - ofxInstagram instagram; ofxThreadedImageLoader getImages; - deque<menuItem> items; + std::string menutag; + void loadInstagramFeed(); + + float lastPoll; + + deque<menuItem> items; map<std::string,ofImage> imagepool; ofTrueTypeFont type14; - //ofImage images[5]; ofxTextBlock myText; TextBlockAlignment alignment; //constants for controlling state - std::string menutag; + ofImage background; + ofImage overlay; }; |
