From c31d38915cb6643013223a4ed9b4021b3499d71d Mon Sep 17 00:00:00 2001 From: tim Date: Fri, 19 May 2017 01:00:43 +0100 Subject: making dir scanner --- menuApp/src/dirscanner.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++ menuApp/src/dirscanner.h | 52 ++++++++++++++++++++++++++++++++++++++++++ menuApp/src/ofApp.cpp | 4 ++++ menuApp/src/ofApp.h | 4 ++++ 4 files changed, 117 insertions(+) diff --git a/menuApp/src/dirscanner.cpp b/menuApp/src/dirscanner.cpp index e69de29..5798e55 100644 --- a/menuApp/src/dirscanner.cpp +++ b/menuApp/src/dirscanner.cpp @@ -0,0 +1,57 @@ +#include "dirscanner.h" + +void playItem::play(){ + +} +void playItem::draw(){ + +} +bool playItem::isFinished(){ + +} + +void dirScanner::scan(){ + /* + parse directories and create structure + showing which folder to check at which time + */ + slots.clear(); + + ofDirectory dir(rootdir); + + dir.allowExt(""); //get directories + + dir.listDir(); + for(int i = 0; i < dir.size(); i++){ + string d=dir.getName(i); + int start = ofToInt(d.substr(0,4)); + int end = ofToInt(d.substr(5,4)); + + if (start&&end){ + slots.push_back(timeSlot(dir.getPath(i),start,end)); + ofLogNotice() << "item "<=time){ + return i; + } + } + return -1; +} + +void dirPlayer::load(){ + +} + +void dirPlayer::draw(){ + +} \ No newline at end of file diff --git a/menuApp/src/dirscanner.h b/menuApp/src/dirscanner.h index e69de29..1e70ed8 100644 --- a/menuApp/src/dirscanner.h +++ b/menuApp/src/dirscanner.h @@ -0,0 +1,52 @@ +#pragma once + +#include "ofMain.h" + +class timeSlot { + public: + timeSlot(std::string _p,int _s,int _e){ + path=_p; + start=_s; + end=_e; + } + string path; + int start; + int end; +}; + +class playItem { + public: + playItem(std::string _n){ + filename=_n; + } + string filename; + ofImage image; + ofVideoPlayer video; + void play(); + void draw(); + bool isFinished(); + float startTime; +}; + +class dirScanner { + //todo: compare each item in vector for reload + public: + dirScanner(std::string _d=""){ + rootdir=_d; + } + int getSlotForTime(int time); + string rootdir; + void scan(); + vector slots; +}; + +class dirPlayer { + public: + dirPlayer(std::string _d){ + playdir=_d; + } + vector items; + string playdir; + void load(); + void draw(); +}; \ No newline at end of file diff --git a/menuApp/src/ofApp.cpp b/menuApp/src/ofApp.cpp index 8dbf41b..e19e239 100644 --- a/menuApp/src/ofApp.cpp +++ b/menuApp/src/ofApp.cpp @@ -131,6 +131,10 @@ bool ofApp::loadInstagramFeed(){ //-------------------------------------------------------------- void ofApp::setup(){ + Dirscanner=dirScanner("/home/tim/Dropbox/menugrab"); + + Dirscanner.scan(); + /* std::string str ("€"); diff --git a/menuApp/src/ofApp.h b/menuApp/src/ofApp.h index 17a3d93..a85258e 100644 --- a/menuApp/src/ofApp.h +++ b/menuApp/src/ofApp.h @@ -5,6 +5,8 @@ #include "ofxThreadedImageLoader.h" #include "ofxTextSuite.h" +#include "dirscanner.h" + #define IMAGE_SLOTS 5 //#define FACTOR 1.0 //now in config.make #define FONTSIZE 13 @@ -66,6 +68,8 @@ class ofApp : public ofBaseApp{ ofImage background; ofImage overlay; + + dirScanner Dirscanner; }; -- cgit v1.2.3