Example #1
0
void testApp::changeOFRootPressed(bool & pressed){
	if(!pressed){
		askOFRoot();
		cout << getOFRootFromConfig()<<endl;
		setOFRoot(getOFRootFromConfig());
		setupDrawableOFPath();
	}
}
Example #2
0
void ofPg::setup(){
	while(!checkConfigExists()){
		askOFRoot();
	}
	setOFRoot(getOFRootFromConfig());

	addons.open(ofFilePath::join(getOFRoot(),"addons"));
	addons.listDir();
	
	addProject(new CBLinuxProject());
	addProject(new CBWinProject());
	addProject(new visualStudioProject());
	addProject(new xcodeProject());
	addProject(new CodeLiteLinuxProject());
}
//--------------------------------------------------------------
void testApp::setup(){
    ofEnableAlphaBlending();
    ofEnableSmoothing();
    ofSetLogLevel(OF_LOG_VERBOSE);
    ofSetVerticalSync(true);
    
    //  Default Settings
    //
    mode                = MODE_NORMAL;
    project             = NULL;
    statusEnergy        = 0;
    float   margin      = 64;
    string  sketchName  = "mySketch";
    
    ofBackground(230,230,230);
    logo.loadImage("images/ofw-logo.png");
    
    //  XML Settings
    //
    ofxXmlSettings XML;
    XML.loadFile("settings/projectGeneratorSettings.xml");
    appToRoot = XML.getValue("appToRoot", "../../../../");
    defaultLoc = XML.getValue("defaultNewProjectLocation", "apps/myApps");
    
    //-------------------------------------
    // calculate the bin path (../../../ on osx) and the sketch path (bin -> root - > defaultLoc)
    //-------------------------------------
    // if appToRoot is wrong, we have alot of issues.  all these paths are used in this project:
    //
#ifdef TARGET_OSX
    string binPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofFilePath::getCurrentWorkingDirectory(), "../../../"));
#else
    string binPath = ofFilePath::getCurrentExeDir();
#endif
    
    string ofRoot = ofFilePath::getAbsolutePath(ofFilePath::join(binPath, appToRoot));
    addonsPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot,"addons"));
    string sketchPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot, defaultLoc));
    
    convertWindowsToUnixPath(ofRoot);
    convertWindowsToUnixPath(addonsPath);
    convertWindowsToUnixPath(sketchPath);
    
    // there's some issues internally in OF with non unix paths for OF root
    //
    setOFRoot(ofRoot);
    
    //------------------------------------- GUI
    //
    
    //  load font and setup the buttons
    //
    font.loadFont("fonts/Inconsolata.otf", 14, true,false,false,0.3,90);
    titleFont.loadFont("fonts/Inconsolata.otf", 28, true,false,false,0.3,90);
    secondFont.loadFont("fonts/Inconsolata.otf", 11, true,false,false,0.3,90);
    
    //  Sketch button
    //
    textButton  *buttonName = new textButton();
    buttonName->font = &font;
    buttonName->secondFont = &secondFont;
    buttonName->prefix = "Name: ";
    buttonName->enableEditing();
	buttonName->topLeftAnchor.set(margin+12, 160+40); //set top button position - others are set relative to this.
    buttonName->setText(sketchName);
    buttonName->secondaryText = "<< CLICK TO CHANGE THE NAME";
    buttons.push_back(buttonName);
    
    //  Path Button
    //
    textButton  *buttonPath = new textButton();
    buttonPath->font = &font;
    buttonPath->secondFont = &secondFont;
    buttonPath->topLeftAnchor.set(buttons[ buttons.size() -1 ]->topLeftAnchor.x, buttons[ buttons.size() -1 ]->topLeftAnchor.y + buttons[ buttons.size() -1 ]->height + 20);
    buttonPath->deliminater = "/";
    buttonPath->prefix = "Path: ";
    buttonPath->setText(sketchPath);
    buttonPath->secondaryText = "<< CLICK TO CHANGE THE DIRECTORY";
    buttons.push_back(buttonPath);
    
    //  Platform Button
    //
    textButton  *buttonPlat = new textButton();
    buttonPlat->font = &font;
    buttonPlat->secondFont = &secondFont;
    buttonPlat->topLeftAnchor.set(buttons[ buttons.size() -1 ]->topLeftAnchor.x, buttons[ buttons.size() -1 ]->topLeftAnchor.y + buttons[ buttons.size() -1 ]->height + 20);
    buttonPlat->deliminater = ", ";
    buttonPlat->prefix = "Platforms: ";
    buttonPlat->secondaryText = "<< CLICK TO CHANGE THE PLATFORM";
    buttonPlat->setText("");
    buttons.push_back(buttonPlat);
    
    //  Addons Button
    //
    textButton  *buttonAddon = new textButton();
    buttonAddon->font = &font;
    buttonAddon->secondFont = &secondFont;
    buttonAddon->topLeftAnchor.set(buttons[ buttons.size() -1 ]->topLeftAnchor.x, buttons[ buttons.size() -1 ]->topLeftAnchor.y + buttons[ buttons.size() -1 ]->height + 20);
    buttonAddon->deliminater = ", ";
    buttonAddon->prefix = "Addons: ";
    buttonAddon->secondaryText = "<< CLICK TO SELECT ADDONS";
    buttonAddon->setText("");
    buttons.push_back(buttonAddon);
    
    for (int i = 0; i < buttons.size(); i++){
        buttons[i]->calculateRect();
    }
    
    //  Generate Button
    //
    generateButton.font = &font;
    generateButton.secondFont = &secondFont;
    generateButton.deliminater = ",";
    generateButton.prefix = "GENERATE PROJECT";
    generateButton.setText("");
    generateButton.bDrawLong = false;
    generateButton.topLeftAnchor.set(ofGetWidth() - buttons[0]->x - generateButton.width + 10 , ofGetHeight() - generateButton.height - 40);
    generateButton.calculateRect();
    
    //  Addon Button
    //
    backButton = generateButton;
    backButton.prefix = "BACK >>";
    backButton.setText("");
    backButton.bDrawLong = false;
    backButton.calculateRect();
    
    //  LOAD ADDONS
    //
    loadAddons();
    
    //  LOAD PLATFORMS
    //
    platformsList.set(64,12,350,500);
    platformsList.font = &font;
    platformsList.title = "Platforms";
    platformsList.addElement("windows (codeblocks)",ofGetTargetPlatform()==OF_TARGET_WINGCC);
	platformsList.addElement("windows (visualStudio)", ofGetTargetPlatform()==OF_TARGET_WINVS);
	platformsList.addElement("linux (codeblocks)",ofGetTargetPlatform()==OF_TARGET_LINUX);
	platformsList.addElement("linux64 (codeblocks)",ofGetTargetPlatform()==OF_TARGET_LINUX64);

    //#define MAKE_IOS
#ifdef MAKE_IOS
	platformsList.addElement("osx (xcode)",false);
	platformsList.addElement("ios (xcode)",true);
#else
    platformsList.addElement("osx (xcode)",ofGetTargetPlatform()==OF_TARGET_OSX);
	platformsList.addElement("ios (xcode)",ofGetTargetPlatform()==OF_TARGET_IPHONE);
#endif
    
    // update the platforms text in the platform button
    //
    buttons[2]->setText( platformsList.getSelectedAsString() );
}
Example #4
0
//--------------------------------------------------------------
void testApp::setup(){
    ofEnableAlphaBlending();
    ofSetLogLevel(OF_LOG_VERBOSE);
    ofSetVerticalSync(true);

    
    statusEnergy = 0;
    
    mode = 0;
    bInited = false;
    project = NULL;
    sketchName = "mySketch";
	

    //-------------------------------------
    // get settings
    //-------------------------------------

    XML.loadFile("settings/projectGeneratorSettings.xml");
    appToRoot = XML.getValue("appToRoot", "../../../../");
    defaultLoc = XML.getValue("defaultNewProjectLocation", "apps/myApps");
       //-------------------------------------
    // calculate the bin path (../../../ on osx) and the sketch path (bin -> root - > defaultLoc)
    //-------------------------------------

    // if appToRoot is wrong, we have alot of issues.  all these paths are used in this project:

#ifdef TARGET_OSX
    string binPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofFilePath::getCurrentWorkingDirectory(), "../../../"));
#else
    string binPath = ofFilePath::getCurrentExeDir();
#endif

    string ofRoot = ofFilePath::getAbsolutePath(ofFilePath::join(binPath, appToRoot));

    addonsPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot,"addons"));
    sketchPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot, defaultLoc));


    convertWindowsToUnixPath(ofRoot);
    convertWindowsToUnixPath(addonsPath);
    convertWindowsToUnixPath(sketchPath);

    // there's some issues internally in OF with non unix paths for OF root
    setOFRoot(ofRoot);



    //-------------------------------------
    // get settings
    //-------------------------------------


    //-------------------------------------
    // load font and setup the buttons
    font.loadFont("fonts/Inconsolata.otf", 14, true,false,false,0.3,90);
    titleFont.loadFont("fonts/Inconsolata.otf", 28, true,false,false,0.3,90);
    secondFont.loadFont("fonts/Inconsolata.otf", 11, true,false,false,0.3,90);
    
    //  Sketch button
    //
    button.font = &font;
    button.secondFont = &secondFont;
    button.prefix = "Name: ";
	button.topLeftAnchor.set(76, 160+40); //set top button position - others are set relative to this.
    button.setText(sketchName);
    
    button.secondaryText = "<< CLICK TO CHANGE THE NAME";
    buttons.push_back(button);

    //  Path button
    //
    button.deliminater = "/";
    button.prefix = "Path: ";
    button.setText(sketchPath);
    button.secondaryText = "<< CLICK TO CHANGE THE DIRECTORY";
	button.topLeftAnchor.set(button.topLeftAnchor.x, button.topLeftAnchor.y + button.rect.height + 20);
    buttons.push_back(button);

    //  Platform text
    //
    button.deliminater = ", ";
    button.prefix = "Platforms: ";
    button.secondaryText = "";
    button.bDrawLong = false;
    button.secondaryText = "";
    button.bSelectable = false;
    button.setText(platform);

    button.topLeftAnchor.set(button.topLeftAnchor.x, button.topLeftAnchor.y + button.rect.height + 20);
    buttons.push_back(button);

    //  Addons button
    //
    button.deliminater = ", ";
    button.bDrawLong = true;
    button.prefix = "Addons: ";
    button.secondaryText = "<< CLICK TO SELECT ADDONS";
    button.bSelectable = true;
    button.setText(addons);

    button.topLeftAnchor.set(button.topLeftAnchor.x, button.topLeftAnchor.y + button.rect.height + 20);
    buttons.push_back(button);

    //  Generate
    //
    generateButton = button;
    generateButton.topLeftAnchor.set(906, 535);
	//generateButton.setColor(ofColor(50, 150, 255));
    generateButton.deliminater = ",";
    generateButton.prefix = "GENERATE PROJECT";
    generateButton.bSelectable = true;
    generateButton.setText("");
    generateButton.bDrawLong = false;
    
    addonButton = button;
    addonButton.topLeftAnchor.set(906, 535);
    addonButton.prefix = "<< BACK";
    addonButton.setText("");
    addonButton.bDrawLong = false;
    

    for (int i = 0; i < buttons.size(); i++){
        buttons[i].calculateRect();
    }
    addonButton.calculateRect();
    generateButton.calculateRect();

    //-------------------------------------
    // addons panels:
    //-------------------------------------

    panelCoreAddons.setup();
    panelOtherAddons.setup();

    ofDirectory addons(addonsPath);

    addons.listDir();
    for(int i=0;i<(int)addons.size();i++){
    	string addon = addons.getName(i);

    	if(addon.find("ofx")==0){

            if (isAddonCore(addon)){
                ofxToggle * toggle = new ofxToggle();
                panelCoreAddons.add(toggle->setup(addon,false,300));
            } else {
                bHaveNonCoreAddons = true;
                ofxToggle * toggle = new ofxToggle();
                panelOtherAddons.add(toggle->setup(addon,false,300));
            }


    	}
    }

    //-------------------------------------
    // platform panel (not used, really, but here just in case)
    //-------------------------------------
    panelPlatforms.setup();
    panelPlatforms.add(wincbToggle.setup("windows (codeblocks)",ofGetTargetPlatform()==OF_TARGET_WINGCC));
	panelPlatforms.add(winvsToggle.setup("windows (visual studio)", ofGetTargetPlatform()==OF_TARGET_WINVS));
	panelPlatforms.add(linuxcbToggle.setup("linux (codeblocks)",ofGetTargetPlatform()==OF_TARGET_LINUX));
	panelPlatforms.add(linux64cbToggle.setup("linux64 (codeblocks)",ofGetTargetPlatform()==OF_TARGET_LINUX64));

//for ios, we need to fake that the target is ios (since we're compiling w/ osx OF)

//#define MAKE_IOS
    
#ifdef MAKE_IOS
	panelPlatforms.add(osxToggle.setup("osx (xcode)",false));
	panelPlatforms.add(iosToggle.setup("ios (xcode)",true));
#else
    panelPlatforms.add(osxToggle.setup("osx (xcode)",ofGetTargetPlatform()==OF_TARGET_OSX));
	panelPlatforms.add(iosToggle.setup("ios (xcode)",ofGetTargetPlatform()==OF_TARGET_IPHONE));
#endif
    
    
    // update the platforms text in the platform button
    string platforms = "";
    for (int i = 0; i < panelPlatforms.getNumControls(); i++){
        if (*((ofxToggle *)panelPlatforms.getControl(i))){
            if (platforms.length() > 0) platforms+=", ";
            platforms += ((ofxToggle *)panelPlatforms.getControl(i))->getName();

        };
    }
    buttons[2].setText(platforms);


    panelPlatforms.setPosition(10,40);
    panelCoreAddons.setPosition(10,40);
    panelOtherAddons.setPosition(330,40);
   

    logo.loadImage("images/ofw-logo.png");

    ofBackground(230,230,230);
    
    
    generateButton.topLeftAnchor.set(ofGetWidth() - buttons[0].rect.x - generateButton.rect.width + 10 ,
                                     ofGetHeight() - generateButton.rect.height - 40);// 535);
    generateButton.calculateRect();
    
    addonButton.topLeftAnchor.set(ofGetWidth() - buttons[0].rect.x - addonButton.rect.width + 10 ,
                                  ofGetHeight() - addonButton.rect.height - 40);// 535);
    addonButton.calculateRect();

}
Example #5
0
//--------------------------------------------------------------
void testApp::setup(){
    //ofSetLogLevel(OF_LOG_NOTICE);
	project = NULL;

	while(!checkConfigExists()){
		askOFRoot();
	}

	setOFRoot(getOFRootFromConfig());

	setupDrawableOFPath();

	int targ = ofGetTargetPlatform();
	//plat = OF_TARGET_IPHONE;

    setupForTarget(targ);
    if(projectPath!="" || buildAllExamples){
    	for(int i = 0; i < (int)targetsToMake.size(); i++){
			setupForTarget(targetsToMake[i]);
			if(buildAllExamples){
				generateExamples();
			}else{
				project->setup(target);
				project->create(projectPath);
				vector < string > addons;
				parseAddonsDotMake(project->getPath() + "addons.make", addons);
				for (int i = 0; i < (int)addons.size(); i++){
					ofAddon addon;
					addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addons[i]),target);
					project->addAddon(addon);
				}
				project->save(false);
			}
    	}
        std::exit(0);
    }

#ifndef COMMAND_LINE_ONLY
    panelAddons.setup();
    ofDirectory addons(ofFilePath::join(getOFRoot(),"addons"));
    addons.listDir();
    for(int i=0;i<(int)addons.size();i++){
    	string addon = addons.getName(i);
    	if(addon.find("ofx")==0){
    		ofxToggle * toggle = new ofxToggle();
    		panelAddons.add(toggle->setup(addon,false,300));
    	}
    }

    panelOptions.setup("","settings.xml",ofGetWidth()-panelAddons.getWidth()-10,120);
    panelOptions.add(createProject.setup("create project",300));
    panelOptions.add(updateProject.setup("update project",300));
    panelOptions.add(createAndOpen.setup("create and open project",300));
    panelOptions.add(changeOFRoot.setup("change OF path",300));

    createProject.addListener(this,&testApp::createProjectPressed);
    updateProject.addListener(this,&testApp::updateProjectPressed);
    createAndOpen.addListener(this,&testApp::createAndOpenPressed);
    changeOFRoot.addListener(this,&testApp::changeOFRootPressed);

	examplesPanel.setup("generate examples", "examples.xml", 400, 10);
	examplesPanel.add(generateButton.setup("<--Generate"));
	examplesPanel.add(wincbToggle.setup("win CB projects",ofGetTargetPlatform()==OF_TARGET_WINGCC));
	examplesPanel.add(winvsToggle.setup("win VS projects", ofGetTargetPlatform()==OF_TARGET_WINVS));
	examplesPanel.add(linuxcbToggle.setup("linux CB projects",ofGetTargetPlatform()==OF_TARGET_LINUX));
	examplesPanel.add(linux64cbToggle.setup("linux64 CB projects",ofGetTargetPlatform()==OF_TARGET_LINUX64));
	examplesPanel.add(osxToggle.setup("osx projects",ofGetTargetPlatform()==OF_TARGET_OSX));
	examplesPanel.add(iosToggle.setup("ios projects",ofGetTargetPlatform()==OF_TARGET_IPHONE));

	generateButton.addListener(this,&testApp::generateExamplesCB);

    ofSetVerticalSync(true);
    ofEnableAlphaBlending();
	ofSetFrameRate(60);
#else
	std::exit(0);
#endif
}
//--------------------------------------------------------------
void testApp::setup(){
    ofSetLogLevel(OF_LOG_VERBOSE);
    ofSetVerticalSync(true);


    mode = 0;
    bInited = false;
    project = NULL;
    sketchName = "mySketch";


    //-------------------------------------
    // get settings
    //-------------------------------------

    XML.loadFile("projectGeneratorSettings.xml");
    appToRoot = XML.getValue("appToRoot", "../../../../");
    defaultLoc = XML.getValue("defaultNewProjectLocation", "apps/myApps");
       //-------------------------------------
    // calculate the bin path (../../../ on osx) and the sketch path (bin -> root - > defaultLoc)
    //-------------------------------------

    // if appToRoot is wrong, we have alot of issues.  all these paths are used in this project:

#ifdef TARGET_OSX
    string binPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofFilePath::getCurrentWorkingDirectory(), "../../../"));
#else
    string binPath = ofFilePath::getCurrentExeDir();
#endif

    string ofRoot = ofFilePath::getAbsolutePath(ofFilePath::join(binPath, appToRoot));
    setOFRoot(ofRoot);

    addonsPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot,"addons"));
    sketchPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot, defaultLoc));




    //-------------------------------------
    // get settings
    //-------------------------------------


    //-------------------------------------
    // load font and setup the buttons
    font.loadFont("frabk.ttf", 12, false, false);

    // sketch button
    button.font = &font;
    button.prefix = "name: ";
    button.setText(sketchName);
    buttons.push_back(button);

    // path button
    button.deliminater = "/";
    button.prefix = "path: ";
    button.setText(sketchPath);
    buttons.push_back(button);

    button.deliminater = ", ";
    button.prefix = "platforms: ";
    button.bSelectable = false;
    button.setText(platform);

    button.topLeftAnchor.set(button.topLeftAnchor.x, button.topLeftAnchor.y + button.rect.height + 20);
    buttons.push_back(button);


    button.deliminater = ", ";
    button.prefix = "addons: ";
    button.bSelectable = true;
    button.setText(addons);

    button.topLeftAnchor.set(button.topLeftAnchor.x, button.topLeftAnchor.y + button.rect.height + 20);
    buttons.push_back(button);

    button.deliminater = ",";
    button.prefix = "generate";
    button.bSelectable = true;
    button.setText("");
    button.topLeftAnchor.set(50,ofGetHeight()-80);
    buttons.push_back(button);

    addonButton = button;
    addonButton.prefix = "< back";
    addonButton.setText("");

     for (int i = 0; i < buttons.size(); i++){
         buttons[i].calculateRect();
     }

    addonButton.calculateRect();

    //-------------------------------------
    // addons panels:
    //-------------------------------------

    panelCoreAddons.setup();
    panelOtherAddons.setup();

    ofDirectory addons(addonsPath);

    addons.listDir();
    for(int i=0;i<(int)addons.size();i++){
    	string addon = addons.getName(i);
    	cout << "adding addon " << addon << endl;
    	if(addon.find("ofx")==0){

            if (isAddonCore(addon)){
                ofxToggle * toggle = new ofxToggle();
                panelCoreAddons.add(toggle->setup(addon,false,300));
            } else {
                ofxToggle * toggle = new ofxToggle();
                panelOtherAddons.add(toggle->setup(addon,false,300));
            }


    	}
    }

    //-------------------------------------
    // platform panel (not used, really, but here just in case)
    //-------------------------------------

    panelPlatforms.setup();
    panelPlatforms.add(wincbToggle.setup("windows (codeblocks)",ofGetTargetPlatform()==OF_TARGET_WINGCC));
	panelPlatforms.add(winvsToggle.setup("windows (visualStudio)", ofGetTargetPlatform()==OF_TARGET_WINVS));
	panelPlatforms.add(linuxcbToggle.setup("linux (codeblocks)",ofGetTargetPlatform()==OF_TARGET_LINUX));
	panelPlatforms.add(linux64cbToggle.setup("linux64 (codeblocks)",ofGetTargetPlatform()==OF_TARGET_LINUX64));
	panelPlatforms.add(osxToggle.setup("osx (xcode)",ofGetTargetPlatform()==OF_TARGET_OSX));
	panelPlatforms.add(iosToggle.setup("ios (xcode)",ofGetTargetPlatform()==OF_TARGET_IPHONE));

    // update the platforms text in the platform button
    string platforms = "";
    for (int i = 0; i < panelPlatforms.getNumControls(); i++){
        if (*((ofxToggle *)panelPlatforms.getControl(i))){
            if (platforms.length() > 0) platforms+=", ";
            platforms += ((ofxToggle *)panelPlatforms.getControl(i))->getName();

        };
    }
    buttons[2].setText(platforms);


    panelPlatforms.setPosition(300,0);
    panelCoreAddons.setPosition(300,0);
    panelOtherAddons.setPosition(750,0);




}