summaryrefslogtreecommitdiff
path: root/testDir/src
diff options
context:
space:
mode:
Diffstat (limited to 'testDir/src')
-rw-r--r--testDir/src/dirscanner.cpp71
-rw-r--r--testDir/src/dirscanner.h58
-rw-r--r--testDir/src/main.cpp17
-rw-r--r--testDir/src/ofApp.cpp89
-rw-r--r--testDir/src/ofApp.h34
5 files changed, 269 insertions, 0 deletions
diff --git a/testDir/src/dirscanner.cpp b/testDir/src/dirscanner.cpp
new file mode 100644
index 0000000..feb29c1
--- /dev/null
+++ b/testDir/src/dirscanner.cpp
@@ -0,0 +1,71 @@
+#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(){
+ /*
+ read vector of slots
+ return index of current time
+ naive approach? assuming that the list is valid
+ */
+ int railwaytime=(ofGetHours()*100)+ofGetMinutes();
+
+ for(int i = 0; i < slots.size(); i++){
+ if (slots[i].start<=railwaytime&&slots[i].end>=railwaytime){
+ return i;
+ }
+ }
+ return -1;
+}
+
+void dirPlayer::load(){
+
+}
+
+void dirPlayer::draw(){
+ int slot=scanner->getSlotForTime();
+ if (slot!=currentslot){
+ if (slot>-1){
+ ofLogNotice() << "entering slot "<<slot<<": "<<scanner->slots[slot].path;
+ }
+ else {
+ ofLogNotice() << "leaving slots";
+ }
+ currentslot=slot;
+ }
+
+
+} \ No newline at end of file
diff --git a/testDir/src/dirscanner.h b/testDir/src/dirscanner.h
new file mode 100644
index 0000000..f78c6d5
--- /dev/null
+++ b/testDir/src/dirscanner.h
@@ -0,0 +1,58 @@
+#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();
+ string rootdir;
+ void scan();
+ vector<timeSlot> slots;
+};
+
+class dirPlayer {
+ public:
+ dirPlayer(){
+ currentslot=-1;
+ }
+ dirPlayer(dirScanner *_s){
+ scanner=_s;
+ dirPlayer();
+ }
+ vector<playItem> items;
+ string playdir;
+ int currentslot;
+ dirScanner *scanner;
+ void load();
+ void draw();
+}; \ No newline at end of file
diff --git a/testDir/src/main.cpp b/testDir/src/main.cpp
new file mode 100644
index 0000000..c8c5551
--- /dev/null
+++ b/testDir/src/main.cpp
@@ -0,0 +1,17 @@
+#include "ofMain.h"
+#include "ofApp.h"
+
+//========================================================================
+int main( ){
+
+#ifdef FULLSCREEN
+ ofSetupOpenGL(256,256,OF_FULLSCREEN);
+#else
+ ofSetupOpenGL(256,256,OF_WINDOW); // <-------- setup the GL context
+#endif
+ // this kicks off the running of my app
+ // can be OF_WINDOW or OF_FULLSCREEN
+ // pass in width and height too:
+ ofRunApp( new ofApp());
+
+}
diff --git a/testDir/src/ofApp.cpp b/testDir/src/ofApp.cpp
new file mode 100644
index 0000000..d6fdd4b
--- /dev/null
+++ b/testDir/src/ofApp.cpp
@@ -0,0 +1,89 @@
+#include "ofApp.h"
+
+
+//--------------------------------------------------------------
+void ofApp::setup(){
+
+ scanner=dirScanner(ofFilePath().getUserHomeDir()+"/Dropbox/menugrab");
+
+ scanner.scan();
+
+ player=dirPlayer(&scanner);
+
+ ofSetFrameRate(1);
+}
+
+//--------------------------------------------------------------
+void ofApp::update(){
+ //ofBackground(255);
+}
+
+
+//--------------------------------------------------------------
+void ofApp::draw(){
+ ofSetColor(255,255,255);
+
+
+ player.draw();
+
+}
+
+//--------------------------------------------------------------
+void ofApp::keyPressed(int key){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::keyReleased(int key){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::mouseMoved(int x, int y){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::mouseDragged(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::mousePressed(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::mouseReleased(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::mouseEntered(int x, int y){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::mouseExited(int x, int y){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::windowResized(int w, int h){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::gotMessage(ofMessage msg){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::dragEvent(ofDragInfo dragInfo){
+
+}
+//--------------------------------------------------------------
+void ofApp::exit()
+{
+
+}
diff --git a/testDir/src/ofApp.h b/testDir/src/ofApp.h
new file mode 100644
index 0000000..2b6ed7d
--- /dev/null
+++ b/testDir/src/ofApp.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include "ofMain.h"
+
+#include "dirscanner.h"
+
+
+
+class ofApp : public ofBaseApp{
+
+ public:
+
+ void setup();
+ void update();
+ void draw();
+
+ void keyPressed(int key);
+ void keyReleased(int key);
+ void mouseMoved(int x, int y);
+ void mouseDragged(int x, int y, int button);
+ void mousePressed(int x, int y, int button);
+ void mouseReleased(int x, int y, int button);
+ void mouseEntered(int x, int y);
+ void mouseExited(int x, int y);
+ void windowResized(int w, int h);
+ void dragEvent(ofDragInfo dragInfo);
+ void gotMessage(ofMessage msg);
+ void exit();
+
+ dirScanner scanner;
+ dirPlayer player;
+};
+
+