@@ -7,6 +7,13 @@ void cyrilApp::setup(){
7
7
8
8
ofSoundStreamSetup (0 , 1 , this , 44100 , beat.getBufferSize (), 4 );
9
9
10
+ // Switch back to external data folder
11
+ ofSetDataPathRoot (" ../../../data/" );
12
+ // Directory watcher for data folder
13
+ codeWatcher.registerAllEvents (this );
14
+ std::string folderToWatch = ofToDataPath (" code" , true );
15
+ codeWatcher.addPath (folderToWatch, true , &fileFilter);
16
+
10
17
ofBackground (0 );
11
18
pauseProg = false ;
12
19
lightsOn = true ;
@@ -21,6 +28,7 @@ void cyrilApp::setup(){
21
28
running[6 ] = false ;
22
29
running[7 ] = false ;
23
30
running[8 ] = false ;
31
+ running[9 ] = false ;
24
32
error[0 ] = false ;
25
33
error[1 ] = false ;
26
34
error[2 ] = false ;
@@ -30,6 +38,7 @@ void cyrilApp::setup(){
30
38
error[6 ] = false ;
31
39
error[7 ] = false ;
32
40
error[8 ] = false ;
41
+ error[9 ] = false ;
33
42
34
43
#ifdef FULL_DEBUG
35
44
ofSetLogLevel (" ofxGLEditor" , OF_LOG_VERBOSE);
@@ -174,7 +183,7 @@ void cyrilApp::draw(){
174
183
float Y_SCALE = (*_state.sym )[REG_Y_SCALE];
175
184
float Z_SCALE = (*_state.sym )[REG_Z_SCALE];
176
185
177
- for (int i = 0 ; i < 9 ; ++i) {
186
+ for (int i = 0 ; i < 10 ; ++i) {
178
187
if (running[i]) {
179
188
if (prog[i]->valid ) {
180
189
ofPushMatrix ();
@@ -208,7 +217,7 @@ void cyrilApp::draw(){
208
217
ofPushMatrix ();
209
218
ofPushStyle ();
210
219
ofTranslate (X_MID - 45 , 10 );
211
- for (int i = 0 ; i < 9 ; ++i) {
220
+ for (int i = 0 ; i < 10 ; ++i) {
212
221
if (error[i]) {
213
222
ofSetColor (255 ,0 ,0 );
214
223
}
@@ -265,17 +274,13 @@ void cyrilApp::toggleLights(void * _o) {
265
274
((cyrilApp *)_o)->_state .light ->setAttenuation (1 .f ,0 .f ,0 .f );
266
275
}
267
276
void cyrilApp::loadFile (void * _o) {
268
- int whichEditor = ((cyrilApp *)_o)->editor .currentBuffer ;
269
- ofSetDataPathRoot (" ../../../" );
270
- ((cyrilApp *)_o)->editor .loadFile (ofToString (whichEditor)+" .txt" , whichEditor);
271
- ofSetDataPathRoot (" ../Resources/data" );
272
- ((cyrilApp *)_o)->editor .update ();
277
+ // int whichEditor = ((cyrilApp *)_o)->editor.currentBuffer;
278
+ // ((cyrilApp *)_o)->editor.loadFile(ofToString(whichEditor)+".txt", whichEditor);
279
+ // ((cyrilApp *)_o)->editor.update();
273
280
}
274
281
void cyrilApp::saveFile (void * _o) {
275
- int whichEditor = ((cyrilApp *)_o)->editor .currentBuffer ;
276
- ofSetDataPathRoot (" ../../../" );
277
- ((cyrilApp *)_o)->editor .saveFile (ofToString (whichEditor)+" .txt" , whichEditor);
278
- ofSetDataPathRoot (" ../Resources/data" );
282
+ // int whichEditor = ((cyrilApp *)_o)->editor.currentBuffer;
283
+ // ((cyrilApp *)_o)->editor.saveFile(ofToString(whichEditor)+".txt", whichEditor);
279
284
}
280
285
void cyrilApp::resetTimers (void * _o) {
281
286
((cyrilApp *)_o)->doResetTimers = true ;
@@ -308,6 +313,37 @@ void cyrilApp::runScript(void * _o) {
308
313
}
309
314
310
315
316
+ void cyrilApp::onDirectoryWatcherItemAdded (const DirectoryWatcherManager::DirectoryEvent& evt) {
317
+ ofFile file = ofFile (evt.item .path ());
318
+ if (file.getExtension () == " cy" ) {
319
+ cout << " Load: " << file.getFileName () << endl;
320
+ int whichEditor = editor.currentBuffer ;
321
+ editor.loadFile (evt.item .path (), whichEditor);
322
+ editor.update ();
323
+ }
324
+ }
325
+ void cyrilApp::onDirectoryWatcherItemRemoved (const DirectoryWatcherManager::DirectoryEvent& evt) {
326
+ cout << " Unload: " << evt.item .path () << endl;
327
+ }
328
+ void cyrilApp::onDirectoryWatcherItemModified (const DirectoryWatcherManager::DirectoryEvent& evt) {
329
+ ofFile file = ofFile (evt.item .path ());
330
+ if (file.getExtension () == " cy" ) {
331
+ cout << " Reload: " << evt.item .path () << endl;
332
+ int whichEditor = editor.currentBuffer ;
333
+ editor.loadFile (evt.item .path (), whichEditor);
334
+ // editor.update();
335
+ runScript (this );
336
+ }
337
+ }
338
+ void cyrilApp::onDirectoryWatcherItemMovedFrom (const DirectoryWatcherManager::DirectoryEvent& evt) {
339
+
340
+ }
341
+ void cyrilApp::onDirectoryWatcherItemMovedTo (const DirectoryWatcherManager::DirectoryEvent& evt) {
342
+
343
+ }
344
+ void cyrilApp::onDirectoryWatcherError (const Poco::Exception& exc) {
345
+
346
+ }
311
347
312
348
313
349
// --------------------------------------------------------------
0 commit comments