diff options
| author | tim <tim@eclectronics.org> | 2017-06-13 21:57:43 +0100 |
|---|---|---|
| committer | tim <tim@eclectronics.org> | 2017-06-13 21:57:43 +0100 |
| commit | 2c3cdaa27878b6dfa23fae35239037f20f3ae6b1 (patch) | |
| tree | ea23545939d9de02f4d21bb7031c4d915d4061a8 /menuApp | |
| parent | fd37c61cd45c1c7a4786b12db8140680772cb1be (diff) | |
add dirscanner template
Diffstat (limited to 'menuApp')
| -rw-r--r-- | menuApp/src/dirscanner.cpp | 57 | ||||
| -rw-r--r-- | menuApp/src/dirscanner.h | 52 |
2 files changed, 109 insertions, 0 deletions
diff --git a/menuApp/src/dirscanner.cpp b/menuApp/src/dirscanner.cpp new file mode 100644 index 0000000..5798e55 --- /dev/null +++ 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 "<<i<<": "<<start<<" - "<<end<<" "<<dir.getPath(i); + + } + } +} + +int dirScanner::getSlotForTime(int time){ + /* + read vector of slots + return index of requested time + */ + for(int i = 0; i < slots.size(); i++){ + if (slots[i].start<=time&&slots[i].end>=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 new file mode 100644 index 0000000..1e70ed8 --- /dev/null +++ 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<timeSlot> slots; +}; + +class dirPlayer { + public: + dirPlayer(std::string _d){ + playdir=_d; + } + vector<playItem> items; + string playdir; + void load(); + void draw(); +};
\ No newline at end of file |
