Skip to content

Commit d4feab4

Browse files
committed
some cleanup and cleaner code
1 parent 81dd994 commit d4feab4

File tree

7 files changed

+12
-62
lines changed

7 files changed

+12
-62
lines changed

src/PatchObject.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ PatchObject::PatchObject(const std::string& _customUID ) : ofxVPHasUID(_customUI
5858
isAudioOUTObject = false;
5959
isPDSPPatchableObject = false;
6060
isTextureObject = false;
61+
isHardwareObject = false;
6162
isResizable = false;
6263
willErase = false;
6364

src/PatchObject.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class PatchObject : public ofxVPHasUID {
155155
bool getIsAudioOUTObject() const { return isAudioOUTObject; }
156156
bool getIsPDSPPatchableObject() const { return isPDSPPatchableObject; }
157157
bool getIsTextureObject() const { return isTextureObject; }
158+
bool getIsHardwareObject() const { return isHardwareObject; }
158159
int getInletType(int iid) const { return inletsType[iid]; }
159160
string getInletTypeName(const int& iid) const;
160161
ofColor getInletColor(const int& iid) const;
@@ -185,6 +186,7 @@ class PatchObject : public ofxVPHasUID {
185186
void setPatchfile(string pf);
186187

187188
void setIsTextureObj(bool it) { isTextureObject = it; }
189+
void setIsHardwareObj(bool ih) { isHardwareObject = ih; }
188190
void setIsResizable(bool ir) { isResizable = ir; }
189191
void setIsRetina(bool ir) { isRetina = ir; if(isRetina) scaleFactor = 2.0f; }
190192
void setIsActive(bool ia) { bActive = ia; }
@@ -263,6 +265,7 @@ class PatchObject : public ofxVPHasUID {
263265
bool isAudioOUTObject;
264266
bool isPDSPPatchableObject;
265267
bool isTextureObject;
268+
bool isHardwareObject;
266269
bool isResizable;
267270
bool willErase;
268271

src/objects/scripting/LuaScript.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -522,18 +522,6 @@ void LuaScript::openScript(string scriptFile){
522522
for(int i = 0; i < (int)tf.size(); i++){
523523
ofDirectory ttf(tf.getPath(i));
524524
if(ttf.isDirectory() && tf.getName(i) != "data"){
525-
#if defined (TARGET_WIN32)
526-
filesystem::path tpa(this->patchFolderPath+tf.getName(i)+"\");
527-
ttf.copyTo(tpa,false,false);
528-
ttf.listDir();
529-
for(int j = 0; j < (int)ttf.size(); j++){
530-
ofFile ftf(ttf.getPath(j));
531-
if(ftf.isFile()){
532-
filesystem::path tpa(this->patchFolderPath+tf.getName(i)+"\"+ftf.getFileName());
533-
ftf.copyTo(tpa,false,false);
534-
}
535-
}
536-
#else
537525
filesystem::path tpa(this->patchFolderPath+tf.getName(i)+"/");
538526
ttf.copyTo(tpa,false,false);
539527
ttf.listDir();
@@ -544,8 +532,6 @@ void LuaScript::openScript(string scriptFile){
544532
ftf.copyTo(tpa,false,false);
545533
}
546534
}
547-
#endif
548-
549535
//ofLog(OF_LOG_NOTICE,"%s - %s",this->patchFolderPath.c_str(),tf.getName(i).c_str());
550536
}
551537
}
@@ -559,11 +545,7 @@ void LuaScript::openScript(string scriptFile){
559545

560546
//--------------------------------------------------------------
561547
void LuaScript::newScript(string scriptFile){
562-
#if defined (TARGET_WIN32)
563-
ofFile fileToRead(ofToDataPath("scripts\empty.lua"));
564-
#else
565548
ofFile fileToRead(ofToDataPath("scripts/empty.lua"));
566-
#endif
567549

568550
ofFile newLuaFile (scriptFile);
569551
ofFile::copyFromTo(fileToRead.getAbsolutePath(),checkFileExtension(newLuaFile.getAbsolutePath(), ofToUpper(newLuaFile.getExtension()), "LUA"),true,true);
@@ -615,11 +597,7 @@ void LuaScript::loadScript(string scriptFile){
615597
static_cast<LiveCoding *>(_outletParams[1])->lua.doString(tempstring);
616598

617599
// load lua Mosaic lib
618-
#if defined (TARGET_WIN32)
619-
tempstring = ofBufferFromFile("livecoding\lua_mosaicLib.lua").getText();
620-
#else
621600
tempstring = ofBufferFromFile("livecoding/lua_mosaicLib.lua").getText();
622-
#endif
623601

624602
static_cast<LiveCoding *>(_outletParams[1])->lua.doString(tempstring);
625603

src/objects/sound/AudioDevice.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ AudioDevice::AudioDevice() : PatchObject("audio device"){
5858
posX = posY = drawW = drawH = 0.0f;
5959

6060
this->setIsTextureObj(true);
61+
this->setIsHardwareObj(true);
6162

6263
}
6364

src/objects/video/KinectGrabber.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ KinectGrabber::KinectGrabber() : PatchObject("kinect grabber"){
6767

6868
this->setIsResizable(true);
6969
this->setIsTextureObj(true);
70+
this->setIsHardwareObj(true);
7071

7172
prevW = this->width;
7273
prevH = this->height;

src/objects/windowing/LivePatching.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ LivePatching::LivePatching() : PatchObject("live patching"){
5252
posX = posY = drawW = drawH = 0.0f;
5353

5454
this->setIsTextureObj(true);
55+
this->setIsHardwareObj(true);
5556

5657
alpha = 127.0f;
5758

src/ofxVisualProgramming.cpp

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,7 @@ ofxVisualProgramming::ofxVisualProgramming(){
7171
livePatchingObiID = -1;
7272

7373
currentPatchFile = "empty_patch.xml";
74-
#if defined (TARGET_WIN32)
75-
currentPatchFolderPath = ofToDataPath("temp\");
76-
#else
7774
currentPatchFolderPath = ofToDataPath("temp/");
78-
#endif
7975

8076

8177
currentSubpatch = "root";
@@ -452,11 +448,7 @@ void ofxVisualProgramming::resetTempFolder(){
452448
void ofxVisualProgramming::cleanPatchDataFolder(){
453449
ofDirectory dir;
454450
// get patch data folder
455-
#if defined (TARGET_WIN32)
456-
dir.listDir(currentPatchFolderPath+"data\");
457-
#else
458451
dir.listDir(currentPatchFolderPath+"data/");
459-
#endif
460452

461453

462454
for(size_t i = 0; i < dir.size(); i++){
@@ -503,9 +495,12 @@ void ofxVisualProgramming::exit(){
503495
deactivateDSP();
504496
}
505497

498+
#ifndef TARGET_WIN32
506499
cleanPatchDataFolder();
507500

508501
resetTempFolder();
502+
#endif
503+
509504
}
510505

511506
//--------------------------------------------------------------
@@ -1023,7 +1018,8 @@ void ofxVisualProgramming::removeObject(int &id){
10231018
//--------------------------------------------------------------
10241019
void ofxVisualProgramming::duplicateObject(int &id){
10251020
// disable duplicate for hardware&system related objects
1026-
if(patchObjects[id]->getName() != "audio device" && patchObjects[id]->getName() != "video grabber" && patchObjects[id]->getName() != "kinect grabber" && patchObjects[id]->getName() != "live patching" && patchObjects[id]->getName() != "projection mapping"){
1021+
if(!patchObjects[id]->getIsHardwareObject()){
1022+
//if(patchObjects[id]->getName() != "audio device" && patchObjects[id]->getName() != "kinect grabber" && patchObjects[id]->getName() != "live patching"){
10271023
//ofVec2f newPos = ofVec2f(patchObjects[id]->getPos().x + patchObjects[id]->getObjectWidth(),patchObjects[id]->getPos().y);
10281024
addObject(patchObjects[id]->getName(),patchObjects[id]->getPos());
10291025
}else{
@@ -1163,11 +1159,7 @@ void ofxVisualProgramming::newPatch(string release){
11631159
XML.saveFile();
11641160
}
11651161

1166-
#if defined (TARGET_WIN32)
1167-
ofFile newPatchFile(ofToDataPath("temp\"+newFileName,true));
1168-
#else
11691162
ofFile newPatchFile(ofToDataPath("temp/"+newFileName,true));
1170-
#endif
11711163

11721164
ofFile::copyFromTo(fileToRead.getAbsolutePath(),newPatchFile.getAbsolutePath(),true,true);
11731165

@@ -1181,21 +1173,12 @@ void ofxVisualProgramming::newPatch(string release){
11811173
void ofxVisualProgramming::newTempPatchFromFile(string patchFile){
11821174
string newFileName = "patch_"+ofGetTimestampString("%y%m%d")+alphabet.at(newFileCounter)+".xml";
11831175
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
11921176
ofFile newPatchFile(ofToDataPath("temp/"+newFileName,true));
11931177
ofFile::copyFromTo(fileToRead.getAbsolutePath(),newPatchFile.getAbsolutePath(),true,true);
11941178

11951179
ofDirectory dataFolderOrigin;
11961180
dataFolderOrigin.listDir(fileToRead.getEnclosingDirectory()+"/data/");
11971181
std::filesystem::path tp = ofToDataPath("temp/data/",true);
1198-
#endif
11991182

12001183
dataFolderOrigin.copyTo(tp,true,true);
12011184

@@ -1246,11 +1229,7 @@ void ofxVisualProgramming::openPatch(string patchFile){
12461229
ofFile temp(currentPatchFile);
12471230
currentPatchFolderPath = temp.getEnclosingDirectory();
12481231

1249-
#if defined (TARGET_WIN32)
1250-
ofFile patchDataFolder(currentPatchFolderPath+"data\");
1251-
#else
12521232
ofFile patchDataFolder(currentPatchFolderPath+"data/");
1253-
#endif
12541233

12551234
if(!patchDataFolder.exists()){
12561235
patchDataFolder.create();
@@ -1497,31 +1476,17 @@ void ofxVisualProgramming::savePatchAs(string patchFile){
14971476
string newFileName = checkFileExtension(sanitizedPatchFile, ofToUpper(tempFile.getExtension()), "XML");
14981477
ofFile fileToRead(currentPatchFile);
14991478
ofDirectory dataFolderOrigin;
1500-
#if defined (TARGET_WIN32)
1501-
dataFolderOrigin.listDir(currentPatchFolderPath+"data\");
1502-
#else
15031479
dataFolderOrigin.listDir(currentPatchFolderPath+"data/");
1504-
#endif
15051480

15061481
ofFile newPatchFile(newFileName);
15071482

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
15171483
currentPatchFile = newPatchFile.getEnclosingDirectory()+finalTempFileName+"/"+newPatchFile.getFileName();
15181484
ofFile temp(currentPatchFile);
15191485
currentPatchFolderPath = temp.getEnclosingDirectory();
15201486

15211487
ofFile::copyFromTo(fileToRead.getAbsolutePath(),currentPatchFile,true,true);
15221488

15231489
std::filesystem::path tp = currentPatchFolderPath+"/data/";
1524-
#endif
15251490

15261491
dataFolderOrigin.copyTo(tp,true,true);
15271492

0 commit comments

Comments
 (0)