Skip to content

Instantly share code, notes, and snippets.

@dimitre
Created August 3, 2019 02:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimitre/4a933a90258088936d466d350606cd7a to your computer and use it in GitHub Desktop.
Save dimitre/4a933a90258088936d466d350606cd7a to your computer and use it in GitHub Desktop.
openFrameworks drag and drop folder to generate project
#include "ofMain.h"
string pgPath = "../../../apps/projectGenerator/commandLine/bin/projectGenerator";
string command = "";
class ofApp : public ofBaseApp{
public:
void setup() {
ofSetWindowPosition(60, 60);
ofSetFrameRate(10);
}
void draw(){
//ofBackground(230,0,120,255);
ofBackground(80,0,230,255);
ofSetColor(255);
ofDrawBitmapString("Drag and drop\nproject file here\n\n0.10", 30, 40);
}
void keyPressed(int key) {
//cout << "keyPressed" << endl;
if (key == 'n') {
newProj();
}
if (key == 'r') {
if (command != "") {
cout << "command again" << endl;
ofSystem(command);
}
}
}
void mousePressed() {
//newProj();
}
void newProj() {
cout << "mousePressed" << endl;
string newProject = ofSystemTextBoxDialog("New Project Name?", "");
if (newProject != "") {
string c = "cd /Volumes/tool/of_v0.10.0_osx_release/apps/projectGenerator/commandLine/bin/; ./projectGenerator -o\"../../../../\" -a\"ofxXmlSettings, ofxDmtrUI3\" ../../../../apps/myApps/" + newProject;
ofSystem(c);
}
}
void dragEvent(ofDragInfo info) {
if( info.files.size() > 0 ){
string dir = info.files[0];
string f = dir + "/addons.make";
if (ofFile::doesFileExist(f)) {
command = "cd " + dir + "; "+pgPath+" -o\"../../../\" -t\"vscode\" .";
cout << command << endl;
ofSystem(command);
}
}
}
};
int main( ){
ofSetupOpenGL(220,140,OF_WINDOW); // <-------- setup the GL context
ofRunApp(new ofApp());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment