Skip to content

Commit 81dd994

Browse files
committed
more windows cleanups
1 parent 0ae9748 commit 81dd994

File tree

3 files changed

+74
-16
lines changed

3 files changed

+74
-16
lines changed

src/core/FileBrowser/ImGuiFileBrowser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ namespace imgui_addons
764764
ImGui::PushItemWidth(ext_box_width);
765765
if(ImGui::BeginCombo("##FileTypes", valid_exts[selected_ext_idx].c_str()))
766766
{
767-
for(int i = 0; i < valid_exts.size(); i++)
767+
for(int i = 0; i < static_cast<int>(valid_exts.size()); i++)
768768
{
769769
if(ImGui::Selectable(valid_exts[i].c_str(), selected_ext_idx == i))
770770
{

src/objects/scripting/LuaScript.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,18 @@ 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
525537
filesystem::path tpa(this->patchFolderPath+tf.getName(i)+"/");
526538
ttf.copyTo(tpa,false,false);
527539
ttf.listDir();
@@ -532,6 +544,8 @@ void LuaScript::openScript(string scriptFile){
532544
ftf.copyTo(tpa,false,false);
533545
}
534546
}
547+
#endif
548+
535549
//ofLog(OF_LOG_NOTICE,"%s - %s",this->patchFolderPath.c_str(),tf.getName(i).c_str());
536550
}
537551
}
@@ -545,7 +559,12 @@ void LuaScript::openScript(string scriptFile){
545559
546560
//--------------------------------------------------------------
547561
void LuaScript::newScript(string scriptFile){
562+
#if defined (TARGET_WIN32)
563+
ofFile fileToRead(ofToDataPath("scripts\empty.lua"));
564+
#else
548565
ofFile fileToRead(ofToDataPath("scripts/empty.lua"));
566+
#endif
567+
549568
ofFile newLuaFile (scriptFile);
550569
ofFile::copyFromTo(fileToRead.getAbsolutePath(),checkFileExtension(newLuaFile.getAbsolutePath(), ofToUpper(newLuaFile.getExtension()), "LUA"),true,true);
551570
filepath = scriptFile;
@@ -596,7 +615,12 @@ void LuaScript::loadScript(string scriptFile){
596615
static_cast<LiveCoding *>(_outletParams[1])->lua.doString(tempstring);
597616
598617
// load lua Mosaic lib
618+
#if defined (TARGET_WIN32)
619+
tempstring = ofBufferFromFile("livecoding\lua_mosaicLib.lua").getText();
620+
#else
599621
tempstring = ofBufferFromFile("livecoding/lua_mosaicLib.lua").getText();
622+
#endif
623+
600624
static_cast<LiveCoding *>(_outletParams[1])->lua.doString(tempstring);
601625
602626
// finally load the script

src/ofxVisualProgramming.cpp

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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(){
457452
void 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){
11761181
void 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

Comments
 (0)