@@ -71,7 +71,12 @@ ofxVisualProgramming::ofxVisualProgramming(){
7171 livePatchingObiID = -1 ;
7272
7373 currentPatchFile = " empty_patch.xml" ;
74+ #if defined (TARGET_WIN32)
75+ currentPatchFolderPath = ofToDataPath (" temp\" );
76+ #else
7477 currentPatchFolderPath = ofToDataPath(" temp/" );
78+ #endif
79+
7580
7681 currentSubpatch = " root" ;
7782
@@ -135,16 +140,6 @@ void ofxVisualProgramming::setup(ofxImGui::Gui* _guiRef, string release){
135140 ofxVPGui = _guiRef;
136141 // Dummy call to IO which will crash if _guiRef is not initialised.
137142 ImGui::GetIO();
138- // Ensure ImGui gets loaded correctly
139- /* if(ImGui::GetCurrentContext()==nullptr || !ImGui::GetCurrentContext()->Initialized){
140- ofxVPGui->setup();
141- }
142- // Manually force shared mode
143- else {
144- ofxVPGui->setSharedMode(true);
145- }*/
146-
147- // ofLogError("ofxVP") << "Setting up ImGui from reference instance." << (ImGui::GetCurrentContext()->Initialized?'1':'0');
148143 }
149144
150145 nodeCanvas.setContext(ImGui::GetCurrentContext());
@@ -457,7 +452,12 @@ void ofxVisualProgramming::resetTempFolder(){
457452void ofxVisualProgramming::cleanPatchDataFolder (){
458453 ofDirectory dir;
459454 // get patch data folder
455+ #if defined (TARGET_WIN32)
456+ dir.listDir (currentPatchFolderPath+" data\" );
457+ #else
460458 dir.listDir(currentPatchFolderPath+" data/" );
459+ #endif
460+
461461
462462 for(size_t i = 0; i < dir.size(); i++){
463463 if(dir.getFile(i).exists()){
@@ -467,7 +467,7 @@ void ofxVisualProgramming::cleanPatchDataFolder(){
467467 // not found in patch scripts map, remove it from patch data folder
468468 //ofLog(OF_LOG_NOTICE," %s" ,dir.getFile(i).getAbsolutePath().c_str());
469469 string fileExt = ofToUpper(dir.getFile(i).getExtension());
470- if (fileExt == " PY " || fileExt == " SH" || fileExt == " FRAG" ){
470+ if(fileExt == " SH" || fileExt == " FRAG" ){
471471 dir.getFile(i).remove();
472472 }
473473 // remove if filename is empty
@@ -893,7 +893,7 @@ void ofxVisualProgramming::clearObjectsMap(){
893893 // remove scripts objects filepath reference from scripts objects files map
894894 ofFile tempsofp(patchObjects.at(eraseIndexes.at(x))->getFilepath());
895895 string fileExt = ofToUpper(tempsofp.getExtension());
896- if (fileExt == " LUA" || fileExt == " PY " || fileExt == " SH" ){
896+ if(fileExt == "LUA" || fileExt == "SH"){
897897 map<string,string>::iterator sofpIT = scriptsObjectsFilesPaths.find(tempsofp.getFileName());
898898 if (sofpIT != scriptsObjectsFilesPaths.end()){
899899 // found it, remove it
@@ -1163,7 +1163,12 @@ void ofxVisualProgramming::newPatch(string release){
11631163 XML.saveFile();
11641164 }
11651165
1166+ #if defined (TARGET_WIN32)
1167+ ofFile newPatchFile(ofToDataPath(" temp\" +newFileName,true));
1168+ #else
11661169 ofFile newPatchFile(ofToDataPath(" temp/" +newFileName,true));
1170+ #endif
1171+
11671172 ofFile::copyFromTo(fileToRead.getAbsolutePath(),newPatchFile.getAbsolutePath(),true,true);
11681173
11691174 newFileCounter++;
@@ -1176,12 +1181,22 @@ void ofxVisualProgramming::newPatch(string release){
11761181void ofxVisualProgramming::newTempPatchFromFile(string patchFile){
11771182 string newFileName = " patch_" +ofGetTimestampString(" %y%m%d" )+alphabet.at(newFileCounter)+" .xml " ;
11781183 ofFile fileToRead(patchFile);
1184+ #if defined (TARGET_WIN32)
1185+ ofFile newPatchFile(ofToDataPath(" temp\" +newFileName,true));
1186+ ofFile::copyFromTo(fileToRead.getAbsolutePath(),newPatchFile.getAbsolutePath(),true,true);
1187+
1188+ ofDirectory dataFolderOrigin;
1189+ dataFolderOrigin.listDir(fileToRead.getEnclosingDirectory()+" \data\" );
1190+ std::filesystem::path tp = ofToDataPath(" temp\data\" ,true);
1191+ #else
11791192 ofFile newPatchFile(ofToDataPath(" temp/" +newFileName,true));
11801193 ofFile::copyFromTo(fileToRead.getAbsolutePath(),newPatchFile.getAbsolutePath(),true,true);
11811194
11821195 ofDirectory dataFolderOrigin;
11831196 dataFolderOrigin.listDir(fileToRead.getEnclosingDirectory()+" /data/" );
11841197 std::filesystem::path tp = ofToDataPath(" temp/data/" ,true);
1198+ #endif
1199+
11851200 dataFolderOrigin.copyTo(tp,true,true);
11861201
11871202 newFileCounter++;
@@ -1231,7 +1246,12 @@ void ofxVisualProgramming::openPatch(string patchFile){
12311246 ofFile temp(currentPatchFile);
12321247 currentPatchFolderPath = temp.getEnclosingDirectory();
12331248
1249+ #if defined (TARGET_WIN32)
1250+ ofFile patchDataFolder(currentPatchFolderPath+" data\" );
1251+ #else
12341252 ofFile patchDataFolder(currentPatchFolderPath+" data/" );
1253+ #endif
1254+
12351255 if(!patchDataFolder.exists()){
12361256 patchDataFolder.create();
12371257 }
@@ -1427,9 +1447,7 @@ void ofxVisualProgramming::loadPatch(string patchFile){
14271447 }
14281448 }
14291449
1430- #if !defined(TARGET_WIN32)
1431- activateDSP ();
1432- #endif
1450+ activateDSP();
14331451
14341452 }
14351453
@@ -1479,16 +1497,32 @@ void ofxVisualProgramming::savePatchAs(string patchFile){
14791497 string newFileName = checkFileExtension(sanitizedPatchFile, ofToUpper(tempFile.getExtension()), " XML" );
14801498 ofFile fileToRead(currentPatchFile);
14811499 ofDirectory dataFolderOrigin;
1500+ #if defined (TARGET_WIN32)
1501+ dataFolderOrigin.listDir(currentPatchFolderPath+" data\" );
1502+ #else
14821503 dataFolderOrigin.listDir(currentPatchFolderPath+" data/" );
1504+ #endif
1505+
14831506 ofFile newPatchFile(newFileName);
14841507
1508+ #if defined (TARGET_WIN32)
1509+ currentPatchFile = newPatchFile.getEnclosingDirectory()+finalTempFileName+" \" +newPatchFile.getFileName();
1510+ ofFile temp(currentPatchFile);
1511+ currentPatchFolderPath = temp.getEnclosingDirectory();
1512+
1513+ ofFile::copyFromTo(fileToRead.getAbsolutePath(),currentPatchFile,true,true);
1514+
1515+ std::filesystem::path tp = currentPatchFolderPath+" \data\" ;
1516+ #else
14851517 currentPatchFile = newPatchFile.getEnclosingDirectory()+finalTempFileName+" /" +newPatchFile.getFileName();
14861518 ofFile temp(currentPatchFile);
14871519 currentPatchFolderPath = temp.getEnclosingDirectory();
14881520
14891521 ofFile::copyFromTo(fileToRead.getAbsolutePath(),currentPatchFile,true,true);
14901522
14911523 std::filesystem::path tp = currentPatchFolderPath+" /data/" ;
1524+ #endif
1525+
14921526 dataFolderOrigin.copyTo(tp,true,true);
14931527
14941528 for(map<int,shared_ptr<PatchObject>>::iterator it = patchObjects.begin(); it != patchObjects.end(); it++ ){
0 commit comments