From b5551fa6deeafb9bec9ed31519c8167c68ff4170 Mon Sep 17 00:00:00 2001 From: zach lieberman Date: Thu, 8 Aug 2013 09:18:42 -0400 Subject: [PATCH 1/5] merging all PGs in one place and cleaning up --- projectGenerator.xcodeproj/project.pbxproj | 35 +- src/{ => gui}/textButton.h | 0 src/pages/basePGPage.cpp | 0 src/pages/basePGPage.h | 24 + src/pages/simplePGPage.cpp | 666 +++++++++++++++++++++ src/pages/simplePGPage.h | 91 +++ src/testApp.cpp | 638 +------------------- src/testApp.h | 63 +- src/utils/Utils.cpp | 32 + src/utils/Utils.h | 4 + 10 files changed, 857 insertions(+), 696 deletions(-) rename src/{ => gui}/textButton.h (100%) create mode 100644 src/pages/basePGPage.cpp create mode 100644 src/pages/basePGPage.h create mode 100644 src/pages/simplePGPage.cpp create mode 100644 src/pages/simplePGPage.h diff --git a/projectGenerator.xcodeproj/project.pbxproj b/projectGenerator.xcodeproj/project.pbxproj index ffe0e46..c1b2581 100644 --- a/projectGenerator.xcodeproj/project.pbxproj +++ b/projectGenerator.xcodeproj/project.pbxproj @@ -45,6 +45,8 @@ E4C2424810CC5A17004149E2 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4C2424510CC5A17004149E2 /* Cocoa.framework */; }; E4C2424910CC5A17004149E2 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4C2424610CC5A17004149E2 /* IOKit.framework */; }; E4EB6799138ADC1D00A09F29 /* GLUT.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BBAB23BE13894E4700AA2426 /* GLUT.framework */; }; + FD63DC6817B3CEA90023EEB1 /* basePGPage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD63DC6417B3CEA90023EEB1 /* basePGPage.cpp */; }; + FD63DC6917B3CEA90023EEB1 /* simplePGPage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD63DC6617B3CEA90023EEB1 /* simplePGPage.cpp */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -104,7 +106,6 @@ 116EA81C150E7288004EBBD3 /* CBLinuxProject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CBLinuxProject.h; sourceTree = ""; }; 119B95D714A65CA0001E1E20 /* pugiconfig.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = pugiconfig.hpp; sourceTree = ""; }; 119B95D814A65CA0001E1E20 /* pugixml.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = pugixml.hpp; sourceTree = ""; }; - 11BCDC821607709900FCCD85 /* textButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = textButton.h; sourceTree = ""; }; 27C4A1A9179491920031C6E4 /* ofxBaseGui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxBaseGui.cpp; sourceTree = ""; }; 27C4A1AA179491920031C6E4 /* ofxBaseGui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxBaseGui.h; sourceTree = ""; }; 27C4A1AB179491920031C6E4 /* ofxButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxButton.cpp; sourceTree = ""; }; @@ -143,6 +144,11 @@ E4C2424610CC5A17004149E2 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = ""; }; E4EB691F138AFCF100A09F29 /* CoreOF.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = CoreOF.xcconfig; path = ../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig; sourceTree = SOURCE_ROOT; }; E4EB6923138AFD0F00A09F29 /* Project.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Project.xcconfig; sourceTree = ""; }; + FD63DC6217B3CDF20023EEB1 /* textButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = textButton.h; sourceTree = ""; }; + FD63DC6417B3CEA90023EEB1 /* basePGPage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = basePGPage.cpp; sourceTree = ""; }; + FD63DC6517B3CEA90023EEB1 /* basePGPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = basePGPage.h; sourceTree = ""; }; + FD63DC6617B3CEA90023EEB1 /* simplePGPage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = simplePGPage.cpp; sourceTree = ""; }; + FD63DC6717B3CEA90023EEB1 /* simplePGPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = simplePGPage.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -359,13 +365,14 @@ E4B69E1C0A3A1BDC003C02F2 /* src */ = { isa = PBXGroup; children = ( + FD63DC6317B3CEA90023EEB1 /* pages */, + FD63DC6117B3CDF20023EEB1 /* gui */, 113CAA5614F88EDD00D3906E /* utils */, 1120712314AE3D4F0035CB7E /* projects */, 119B95D214A65CA0001E1E20 /* pugixmlLib */, E4B69E1D0A3A1BDC003C02F2 /* main.cpp */, E4B69E1F0A3A1BDC003C02F2 /* testApp.h */, E4B69E1E0A3A1BDC003C02F2 /* testApp.cpp */, - 11BCDC821607709900FCCD85 /* textButton.h */, 11D6814214A8EC0F008E3E3D /* addons */, ); path = src; @@ -380,6 +387,25 @@ name = openFrameworks; sourceTree = ""; }; + FD63DC6117B3CDF20023EEB1 /* gui */ = { + isa = PBXGroup; + children = ( + FD63DC6217B3CDF20023EEB1 /* textButton.h */, + ); + path = gui; + sourceTree = ""; + }; + FD63DC6317B3CEA90023EEB1 /* pages */ = { + isa = PBXGroup; + children = ( + FD63DC6417B3CEA90023EEB1 /* basePGPage.cpp */, + FD63DC6517B3CEA90023EEB1 /* basePGPage.h */, + FD63DC6617B3CEA90023EEB1 /* simplePGPage.cpp */, + FD63DC6717B3CEA90023EEB1 /* simplePGPage.h */, + ); + path = pages; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -437,8 +463,7 @@ E4328148138ABC890047C5CB /* openFrameworksDebug.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; - name = openFrameworksDebug.a; - path = openFrameworks.a; + path = openFrameworksDebug.a; remoteRef = E4328147138ABC890047C5CB /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -487,6 +512,8 @@ 27C4A1BF179491920031C6E4 /* ofxSlider.cpp in Sources */, 27C4A1C0179491920031C6E4 /* ofxSliderGroup.cpp in Sources */, 27C4A1C1179491920031C6E4 /* ofxToggle.cpp in Sources */, + FD63DC6817B3CEA90023EEB1 /* basePGPage.cpp in Sources */, + FD63DC6917B3CEA90023EEB1 /* simplePGPage.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/textButton.h b/src/gui/textButton.h similarity index 100% rename from src/textButton.h rename to src/gui/textButton.h diff --git a/src/pages/basePGPage.cpp b/src/pages/basePGPage.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/pages/basePGPage.h b/src/pages/basePGPage.h new file mode 100644 index 0000000..952aab8 --- /dev/null +++ b/src/pages/basePGPage.h @@ -0,0 +1,24 @@ +#pragma once + +#include "ofMain.h" + + +class basePGPage { + + public: + + virtual void setup() = 0;; + virtual void update() = 0;; + virtual void draw() = 0;; + + virtual void keyPressed (int key) = 0;; + virtual void keyReleased(int key) = 0;; + virtual void mouseMoved(int x, int y ) = 0;; + virtual void mouseDragged(int x, int y, int button) = 0;; + virtual void mousePressed(int x, int y, int button) = 0;; + virtual void mouseReleased(int x, int y, int button) = 0;; + virtual void windowResized(int w, int h) = 0;; + virtual void dragEvent(ofDragInfo dragInfo) = 0;; + virtual void gotMessage(ofMessage msg) = 0;; + +}; diff --git a/src/pages/simplePGPage.cpp b/src/pages/simplePGPage.cpp new file mode 100644 index 0000000..e9fb8b3 --- /dev/null +++ b/src/pages/simplePGPage.cpp @@ -0,0 +1,666 @@ +#include "simplePGPage.h" +#include "Utils.h" +#include +#include "ofConstants.h" + + +//------------------------------------------------------ +bool simplePGPage::isAddonCore(string addon){ + + + if (bInited == false){ + coreAddons.push_back("ofx3DModelLoader"); + coreAddons.push_back("ofxAssimpModelLoader"); + coreAddons.push_back("ofxDirList"); + coreAddons.push_back("ofxNetwork"); + coreAddons.push_back("ofxOpenCv"); + coreAddons.push_back("ofxOsc"); + coreAddons.push_back("ofxThread"); + coreAddons.push_back("ofxThreadedImageLoader"); + coreAddons.push_back("ofxVectorGraphics"); + coreAddons.push_back("ofxVectorMath"); + coreAddons.push_back("ofxXmlSettings"); + coreAddons.push_back("ofxSvg"); + coreAddons.push_back("ofxGui"); + coreAddons.push_back("ofxKinect"); + bInited = true; + } + + + for (int i = 0; i < coreAddons.size(); i++){ + if (coreAddons[i] == addon){ + return true; + } + } + return false; +} + + + + +//------------------------------------------------------ +string simplePGPage::setupForTarget(int targ){ + + if(project){ + delete project; + } + string target; + switch(targ){ + case OF_TARGET_OSX: + project = new xcodeProject; + target = "osx"; + break; + case OF_TARGET_WINGCC: + project = new CBWinProject; + target = "win_cb"; + break; + case OF_TARGET_WINVS: + project = new visualStudioProject; + target = "vs"; + break; + case OF_TARGET_IPHONE: + project = new xcodeProject(); + target = "ios"; + break; + case OF_TARGET_ANDROID: + break; + case OF_TARGET_LINUX64: + project = new CBLinuxProject; + target = "linux64"; + break; + case OF_TARGET_LINUX: + project = new CBLinuxProject; + target = "linux"; + break; + } + + project->setup(target); + + return target; +} + + + +void simplePGPage::setStatus(string newStatus){ + statusEnergy = 1; + status = newStatus; + statusSetTime = ofGetElapsedTimef(); +} + + + +//-------------------------------------------------------------- +void simplePGPage::setup(){ + ofEnableAlphaBlending(); + ofEnableSmoothing(); + 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(); + +} + + + + + + +//-------------------------------------------------------------- +void simplePGPage::update(){ + + float diff = ofGetElapsedTimef()- statusSetTime; + if (diff > 3){ + statusEnergy *= 0.99;; + } + //------------------------------------- + // if we are in addon mode check + //------------------------------------- + + if (mode == MODE_ADDON ) addonButton.checkMousePressed(ofPoint(ofGetMouseX(), ofGetMouseY())); + + + //------------------------------------- + // layout our normal buttons, check the mouse + //------------------------------------- + + for (int i = 0; i < buttons.size(); i++){ + buttons[i].calculateRect(); + buttons[i].checkMousePressed(ofPoint(ofGetMouseX(), ofGetMouseY())); + } + + generateButton.checkMousePressed(ofPoint(ofGetMouseX(), ofGetMouseY())); + + for (int i = 0; i < buttons.size(); i++){ + if (i != 0){ + buttons[i].topLeftAnchor.y = buttons[i-1].topLeftAnchor.y +buttons[i-1].rect.height + 20; + } + } + + + //------------------------------------- + // addons panels can be really long, so use the mouse pos to move them if we need to + //------------------------------------- + + if (panelCoreAddons.getShape().height > ofGetHeight()){ + float pct = ofMap(ofGetMouseY(), 0,ofGetHeight(), 0,1,true); + float diff = panelCoreAddons.getShape().height - ofGetHeight(); + panelCoreAddons.setPosition(panelCoreAddons.getPosition().x,-diff * pct); + } + + if (panelOtherAddons.getShape().height > ofGetHeight()){ + float pct = ofMap(ofGetMouseY(), 0,ofGetHeight(), 0,1,true); + float diff = panelOtherAddons.getShape().height - ofGetHeight(); + panelOtherAddons.setPosition(panelOtherAddons.getPosition().x,-diff * pct); + } + +} + +//-------------------------------------------------------------- +void simplePGPage::draw(){ + + + + if (mode != MODE_ADDON ) { + + ofSetColor(100); + logo.draw(64, 61,logo.getWidth(),logo.getHeight()); + + //ofSetColor(74,255,203); + titleFont.drawString("PROJECT", 64 + logo.getWidth() + 25, 85); + titleFont.drawString("GENERATOR", 64 + logo.getWidth() + 25, 117); + } + + if (mode == 0){ + for (int i = 0; i < buttons.size(); i++){ + buttons[i].draw(); + } + + generateButton.draw(); + + } else if (mode == 1){ + panelCoreAddons.draw(); + if (bHaveNonCoreAddons){ + panelOtherAddons.draw(); + } + } else if (mode == 2){ + panelPlatforms.draw(); + } + //cout << panelAddons.getShape().height << endl; + + + + + if (mode == 1 ){ + addonButton.draw(); + + ofRectangle rect = secondFont.getStringBoundingBox("select core and non-core addons to add", addonButton.topLeftAnchor.x-200, 60); + ofSetColor(220,220,220); + ofRect(rect.x-10, rect.y-10, rect.width+20, rect.height+20); + ofSetColor(0,0,0); + secondFont.drawString("select core and non-core addons to add", addonButton.topLeftAnchor.x-200, 60); + } + + if (mode == 0){ + ofFill(); + ofSetColor(0 + 220 * (1-statusEnergy),0 + 220 * (1-statusEnergy),0 + 220 * (1-statusEnergy)); + ofRect(0,ofGetHeight(), ofGetWidth(), -25); + ofSetColor(255,255,255, 255 * statusEnergy); + ofDrawBitmapString(status, 10,ofGetHeight()-8); + } +} + +//-------------------------------------------------------------- +void simplePGPage::keyPressed(int key){ + + if (key == ' '){ + + //printf("%s -------- \n", ResultBuffer); + //std::exit(0); + } + + +} + +void simplePGPage::generateProject(){ + + vector targetsToMake; + if( osxToggle ) targetsToMake.push_back(OF_TARGET_OSX); + if( iosToggle ) targetsToMake.push_back(OF_TARGET_IPHONE); + if( wincbToggle ) targetsToMake.push_back(OF_TARGET_WINGCC); + if( winvsToggle ) targetsToMake.push_back(OF_TARGET_WINVS); + if( linuxcbToggle ) targetsToMake.push_back(OF_TARGET_LINUX); + if( linux64cbToggle ) targetsToMake.push_back(OF_TARGET_LINUX64); + + if( targetsToMake.size() == 0 ){ + cout << "Error: makeNewProjectViaDialog - must specifiy a project to generate " <create(path)){ + vector addonsToggles = panelCoreAddons.getControlNames(); + for (int i = 0; i < (int) addonsToggles.size(); i++){ + ofxToggle toggle = panelCoreAddons.getToggle(addonsToggles[i]); + if(toggle){ + ofAddon addon; + addon.pathToOF = getOFRelPath(path); + addon.fromFS(ofFilePath::join(addonsPath, addonsToggles[i]),target); + project->addAddon(addon); + + } + } + + + addonsToggles = panelOtherAddons.getControlNames(); + for (int i = 0; i < (int) addonsToggles.size(); i++){ + ofxToggle toggle = panelOtherAddons.getToggle(addonsToggles[i]); + if(toggle){ + ofAddon addon; + + addon.pathToOF = getOFRelPath(path); + cout << getOFRelPath(path) << " " << path << endl; + addon.fromFS(ofFilePath::join(addonsPath, addonsToggles[i]),target); + project->addAddon(addon); + + } + } + + project->save(true); + } + } + + + printf("done with project generation \n"); + setStatus("generated: " + buttons[1].myText + "/" + buttons[0].myText); + + // go through the control panels, do stuff +} + +//-------------------------------------------------------------- +void simplePGPage::keyReleased(int key){ + + + +} + +//-------------------------------------------------------------- +void simplePGPage::mouseMoved(int x, int y ){ + +} + +//-------------------------------------------------------------- +void simplePGPage::mouseDragged(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void simplePGPage::mousePressed(int x, int y, int button){ + + if (mode == MODE_NORMAL){ + + + // check the mouse for press + + for (int i = 0; i < buttons.size(); i++){ + buttons[i].checkMousePressed(ofPoint(x, y)); + } + + + //------------------------------------- + // 4 = genearate + //------------------------------------- + + + if (generateButton.bMouseOver == true){ + generateProject(); + } + + //------------------------------------- + // 0 = sketch name + //------------------------------------- + + if (buttons[0].bMouseOver == true){ + string text = ofSystemTextBoxDialog("choose sketch name", buttons[0].myText); + fixStringCharacters(text); + setStatus("sketch name set to: " + text); + buttons[0].setText(text); + } + + //------------------------------------- + // 1 = sketch path + //------------------------------------- + + if (buttons[1].bMouseOver == true){ + + string command = ""; + + ofDirectory dir(ofFilePath::join(getOFRoot(),defaultLoc)); + + if (!dir.exists()){ + dir.create(); + } + + + #ifdef TARGET_WIN32 + ofFileDialogResult res = ofSystemLoadDialog("please select sketch folder", true, windowsFromUnixPath(dir.path())); + #else + ofFileDialogResult res = ofSystemLoadDialog("please select sketch folder", true, dir.path()); + #endif + + + if (res.bSuccess){ + string result = res.filePath; + convertWindowsToUnixPath(result); + buttons[1].setText( result ); + + setStatus("path set to: " + result); + } + + + } + + + //------------------------------------- + // 2 = platform (disabled) + //------------------------------------- + + + if (buttons[2].bMouseOver == true){ + // platform is diabled for now + mode = 2; + } + + //------------------------------------- + // 3 = addon + //------------------------------------- + + if (buttons[3].bMouseOver == true){ + mode = MODE_ADDON; + + } + } + + //------------------------------------- + // handle addon mode + //------------------------------------- + + if (mode == MODE_ADDON ){ + + //------------------------------------- + // if we hit he back button, collect the addons for display + //------------------------------------- + + if (addonButton.bMouseOver){ + + string addons = ""; + + for (int i = 0; i < panelCoreAddons.getNumControls(); i++){ + if (*((ofxToggle *)panelCoreAddons.getControl(i))){ + if (addons.length() > 0) addons+=", "; + addons += ((ofxToggle *)panelCoreAddons.getControl(i))->getName(); + + } + + } + for (int i = 0; i < panelOtherAddons.getNumControls(); i++){ + if (*((ofxToggle *)panelOtherAddons.getControl(i))){ + if (addons.length() > 0) addons+=", "; + addons += ((ofxToggle *)panelOtherAddons.getControl(i))->getName(); + + } + + } + buttons[3].setText(addons); + + setStatus("addons set to: " + addons); + + addonButton.bMouseOver = false; + mode = MODE_NORMAL; + } + } + + if (mode == MODE_PLATFORM){ + + } +} + +//-------------------------------------------------------------- +void simplePGPage::mouseReleased(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void simplePGPage::windowResized(int w, int h){ + 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(); + +} + +//-------------------------------------------------------------- +void simplePGPage::gotMessage(ofMessage msg){ + +} + +//-------------------------------------------------------------- +void simplePGPage::dragEvent(ofDragInfo dragInfo){ + +} diff --git a/src/pages/simplePGPage.h b/src/pages/simplePGPage.h new file mode 100644 index 0000000..94213fd --- /dev/null +++ b/src/pages/simplePGPage.h @@ -0,0 +1,91 @@ +#pragma once + + +#include "basePGPage.h" + +#include "ofMain.h" +#include "CBLinuxProject.h" +#include "CBWinProject.h" +#include "visualStudioProject.h" +#include "xcodeProject.h" +#include + +#include "ofxGui.h" +#include "ofAddon.h" +#include "ofxXmlSettings.h" +#include "textButton.h" + + + +class simplePGPage : public basePGPage { + + public: + + void setup(); + void update(); + void draw(); + + void keyPressed (int key); + void keyReleased(int key); + void mouseMoved(int x, int y ); + void mouseDragged(int x, int y, int button); + void mousePressed(int x, int y, int button); + void mouseReleased(int x, int y, int button); + void windowResized(int w, int h); + void dragEvent(ofDragInfo dragInfo); + void gotMessage(ofMessage msg); + + + string sketchName; + string sketchPath; + string addons; + string platform; + + ofxPanel panelCoreAddons; + ofxPanel panelOtherAddons; + bool bHaveNonCoreAddons; + + ofxPanel panelPlatforms; + + ofxToggle osxToggle, iosToggle, wincbToggle, winvsToggle, linuxcbToggle, linux64cbToggle; + + ofTrueTypeFont font; + ofTrueTypeFont titleFont; + ofTrueTypeFont secondFont; + + int mode; + enum { MODE_NORMAL, MODE_ADDON, MODE_PLATFORM }; + + baseProject * project; + + string setupForTarget(int targ); + + void generateProject(); + + string addonsPath; + string status; + + ofxXmlSettings XML; + string appToRoot; + string defaultLoc; + + float uiLeftX; + + + textButton button; + textButton generateButton; + textButton addonButton; + vector < textButton > buttons; + + bool isAddonCore(string addon); + bool bInited; + vector < string > coreAddons; + + + float statusSetTime; + float statusEnergy; + void setStatus(string newStatus); + + ofImage logo; + +}; diff --git a/src/testApp.cpp b/src/testApp.cpp index 9b4d062..a5c5481 100644 --- a/src/testApp.cpp +++ b/src/testApp.cpp @@ -3,527 +3,34 @@ #include #include "ofConstants.h" -void convertWindowsToUnixPath(string & path){ - for (int i = 0; i < path.size(); i++){ - if (path[i] == '\\') path[i] = '/'; - } -} - -string windowsFromUnixPath(string path){ - for (int i = 0; i < path.size(); i++){ - if (path[i] == '/') path[i] = '\\'; - } - return path; -} - -//------------------------------------------------------ -bool testApp::isAddonCore(string addon){ - - - if (bInited == false){ - coreAddons.push_back("ofx3DModelLoader"); - coreAddons.push_back("ofxAssimpModelLoader"); - coreAddons.push_back("ofxDirList"); - coreAddons.push_back("ofxNetwork"); - coreAddons.push_back("ofxOpenCv"); - coreAddons.push_back("ofxOsc"); - coreAddons.push_back("ofxThread"); - coreAddons.push_back("ofxThreadedImageLoader"); - coreAddons.push_back("ofxVectorGraphics"); - coreAddons.push_back("ofxVectorMath"); - coreAddons.push_back("ofxXmlSettings"); - coreAddons.push_back("ofxSvg"); - coreAddons.push_back("ofxGui"); - coreAddons.push_back("ofxKinect"); - bInited = true; - } - - - - for (int i = 0; i < coreAddons.size(); i++){ - - if (coreAddons[i] == addon){ - return true; - } - } - return false; -} - -//------------------------------------------------------ -// for project names, let's fix replace any odd characters with _ -void fixStringCharacters(string &toFix){ - - // replace all non alpha numeric (ascii) characters with _ - for (int i = 0; i < toFix.size(); i++){ - int which = (int)toFix[i]; - if ((which >= 48 && which <= 57) || - (which >= 65 && which <= 90) || - (which >= 97 && which <= 122)){ - } else { - toFix[i] = '_'; - } - } -} - - - -//------------------------------------------------------ -string testApp::setupForTarget(int targ){ - - if(project){ - delete project; - } - string target; - switch(targ){ - case OF_TARGET_OSX: - project = new xcodeProject; - target = "osx"; - break; - case OF_TARGET_WINGCC: - project = new CBWinProject; - target = "win_cb"; - break; - case OF_TARGET_WINVS: - project = new visualStudioProject; - target = "vs"; - break; - case OF_TARGET_IPHONE: - project = new xcodeProject(); - target = "ios"; - break; - case OF_TARGET_ANDROID: - break; - case OF_TARGET_LINUX64: - project = new CBLinuxProject; - target = "linux64"; - break; - case OF_TARGET_LINUX: - project = new CBLinuxProject; - target = "linux"; - break; - } - - project->setup(target); - - return target; -} -void testApp::setStatus(string newStatus){ - statusEnergy = 1; - status = newStatus; - statusSetTime = ofGetElapsedTimef(); -} - - //-------------------------------------------------------------- void testApp::setup(){ - ofEnableAlphaBlending(); - ofEnableSmoothing(); - 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(); - + simple.setup(); } - - - - - //-------------------------------------------------------------- void testApp::update(){ - - float diff = ofGetElapsedTimef()- statusSetTime; - if (diff > 3){ - statusEnergy *= 0.99;; - } - //------------------------------------- - // if we are in addon mode check - //------------------------------------- - - if (mode == MODE_ADDON ) addonButton.checkMousePressed(ofPoint(mouseX, mouseY)); - - - //------------------------------------- - // layout our normal buttons, check the mouse - //------------------------------------- - - for (int i = 0; i < buttons.size(); i++){ - buttons[i].calculateRect(); - buttons[i].checkMousePressed(ofPoint(mouseX, mouseY)); - } - - generateButton.checkMousePressed(ofPoint(mouseX, mouseY)); - - for (int i = 0; i < buttons.size(); i++){ - if (i != 0){ - buttons[i].topLeftAnchor.y = buttons[i-1].topLeftAnchor.y +buttons[i-1].rect.height + 20; - } - } - - - //------------------------------------- - // addons panels can be really long, so use the mouse pos to move them if we need to - //------------------------------------- - - if (panelCoreAddons.getShape().height > ofGetHeight()){ - float pct = ofMap(ofGetMouseY(), 0,ofGetHeight(), 0,1,true); - float diff = panelCoreAddons.getShape().height - ofGetHeight(); - panelCoreAddons.setPosition(panelCoreAddons.getPosition().x,-diff * pct); - } - - if (panelOtherAddons.getShape().height > ofGetHeight()){ - float pct = ofMap(ofGetMouseY(), 0,ofGetHeight(), 0,1,true); - float diff = panelOtherAddons.getShape().height - ofGetHeight(); - panelOtherAddons.setPosition(panelOtherAddons.getPosition().x,-diff * pct); - } - + simple.update(); } //-------------------------------------------------------------- void testApp::draw(){ - - - if (mode != MODE_ADDON ) { - - ofSetColor(100); - logo.draw(64, 61,logo.getWidth(),logo.getHeight()); - - //ofSetColor(74,255,203); - titleFont.drawString("PROJECT", 64 + logo.getWidth() + 25, 85); - titleFont.drawString("GENERATOR", 64 + logo.getWidth() + 25, 117); - } - - if (mode == 0){ - for (int i = 0; i < buttons.size(); i++){ - buttons[i].draw(); - } - - generateButton.draw(); - - } else if (mode == 1){ - panelCoreAddons.draw(); - if (bHaveNonCoreAddons){ - panelOtherAddons.draw(); - } - } else if (mode == 2){ - panelPlatforms.draw(); - } - //cout << panelAddons.getShape().height << endl; - - - - - if (mode == 1 ){ - addonButton.draw(); - - ofRectangle rect = secondFont.getStringBoundingBox("select core and non-core addons to add", addonButton.topLeftAnchor.x-200, 60); - ofSetColor(220,220,220); - ofRect(rect.x-10, rect.y-10, rect.width+20, rect.height+20); - ofSetColor(0,0,0); - secondFont.drawString("select core and non-core addons to add", addonButton.topLeftAnchor.x-200, 60); - } - - if (mode == 0){ - ofFill(); - ofSetColor(0 + 220 * (1-statusEnergy),0 + 220 * (1-statusEnergy),0 + 220 * (1-statusEnergy)); - ofRect(0,ofGetHeight(), ofGetWidth(), -25); - ofSetColor(255,255,255, 255 * statusEnergy); - ofDrawBitmapString(status, 10,ofGetHeight()-8); - } + simple.draw(); } //-------------------------------------------------------------- void testApp::keyPressed(int key){ - - if (key == ' '){ - - //printf("%s -------- \n", ResultBuffer); - //std::exit(0); - } - - -} - -void testApp::generateProject(){ - - vector targetsToMake; - if( osxToggle ) targetsToMake.push_back(OF_TARGET_OSX); - if( iosToggle ) targetsToMake.push_back(OF_TARGET_IPHONE); - if( wincbToggle ) targetsToMake.push_back(OF_TARGET_WINGCC); - if( winvsToggle ) targetsToMake.push_back(OF_TARGET_WINVS); - if( linuxcbToggle ) targetsToMake.push_back(OF_TARGET_LINUX); - if( linux64cbToggle ) targetsToMake.push_back(OF_TARGET_LINUX64); - - if( targetsToMake.size() == 0 ){ - cout << "Error: makeNewProjectViaDialog - must specifiy a project to generate " <create(path)){ - vector addonsToggles = panelCoreAddons.getControlNames(); - for (int i = 0; i < (int) addonsToggles.size(); i++){ - ofxToggle toggle = panelCoreAddons.getToggle(addonsToggles[i]); - if(toggle){ - ofAddon addon; - addon.pathToOF = getOFRelPath(path); - addon.fromFS(ofFilePath::join(addonsPath, addonsToggles[i]),target); - project->addAddon(addon); - - } - } - - - addonsToggles = panelOtherAddons.getControlNames(); - for (int i = 0; i < (int) addonsToggles.size(); i++){ - ofxToggle toggle = panelOtherAddons.getToggle(addonsToggles[i]); - if(toggle){ - ofAddon addon; - - addon.pathToOF = getOFRelPath(path); - cout << getOFRelPath(path) << " " << path << endl; - addon.fromFS(ofFilePath::join(addonsPath, addonsToggles[i]),target); - project->addAddon(addon); - - } - } - - project->save(true); - } - } - - - printf("done with project generation \n"); - setStatus("generated: " + buttons[1].myText + "/" + buttons[0].myText); - - // go through the control panels, do stuff + + simple.keyPressed(key); } //-------------------------------------------------------------- void testApp::keyReleased(int key){ - - - } //-------------------------------------------------------------- @@ -539,132 +46,7 @@ void testApp::mouseDragged(int x, int y, int button){ //-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ - if (mode == MODE_NORMAL){ - - - // check the mouse for press - - for (int i = 0; i < buttons.size(); i++){ - buttons[i].checkMousePressed(ofPoint(x, y)); - } - - - //------------------------------------- - // 4 = genearate - //------------------------------------- - - - if (generateButton.bMouseOver == true){ - generateProject(); - } - - //------------------------------------- - // 0 = sketch name - //------------------------------------- - - if (buttons[0].bMouseOver == true){ - string text = ofSystemTextBoxDialog("choose sketch name", buttons[0].myText); - fixStringCharacters(text); - setStatus("sketch name set to: " + text); - buttons[0].setText(text); - } - - //------------------------------------- - // 1 = sketch path - //------------------------------------- - - if (buttons[1].bMouseOver == true){ - - string command = ""; - - ofDirectory dir(ofFilePath::join(getOFRoot(),defaultLoc)); - - if (!dir.exists()){ - dir.create(); - } - - - #ifdef TARGET_WIN32 - ofFileDialogResult res = ofSystemLoadDialog("please select sketch folder", true, windowsFromUnixPath(dir.path())); - #else - ofFileDialogResult res = ofSystemLoadDialog("please select sketch folder", true, dir.path()); - #endif - - - if (res.bSuccess){ - string result = res.filePath; - convertWindowsToUnixPath(result); - buttons[1].setText( result ); - - setStatus("path set to: " + result); - } - - - } - - - //------------------------------------- - // 2 = platform (disabled) - //------------------------------------- - - - if (buttons[2].bMouseOver == true){ - // platform is diabled for now - mode = 2; - } - - //------------------------------------- - // 3 = addon - //------------------------------------- - - if (buttons[3].bMouseOver == true){ - mode = MODE_ADDON; - - } - } - - //------------------------------------- - // handle addon mode - //------------------------------------- - - if (mode == MODE_ADDON ){ - - //------------------------------------- - // if we hit he back button, collect the addons for display - //------------------------------------- - - if (addonButton.bMouseOver){ - - string addons = ""; - - for (int i = 0; i < panelCoreAddons.getNumControls(); i++){ - if (*((ofxToggle *)panelCoreAddons.getControl(i))){ - if (addons.length() > 0) addons+=", "; - addons += ((ofxToggle *)panelCoreAddons.getControl(i))->getName(); - - } - - } - for (int i = 0; i < panelOtherAddons.getNumControls(); i++){ - if (*((ofxToggle *)panelOtherAddons.getControl(i))){ - if (addons.length() > 0) addons+=", "; - addons += ((ofxToggle *)panelOtherAddons.getControl(i))->getName(); - - } - - } - buttons[3].setText(addons); - - setStatus("addons set to: " + addons); - - addonButton.bMouseOver = false; - mode = MODE_NORMAL; - } - } - - if (mode == MODE_PLATFORM){ - - } + simple.mousePressed(x,y,button); } //-------------------------------------------------------------- @@ -674,13 +56,7 @@ void testApp::mouseReleased(int x, int y, int button){ //-------------------------------------------------------------- void testApp::windowResized(int w, int h){ - 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(); + simple.windowResized(w, h); } diff --git a/src/testApp.h b/src/testApp.h index 76172e6..7a2f269 100644 --- a/src/testApp.h +++ b/src/testApp.h @@ -3,17 +3,7 @@ //#define COMMAND_LINE_ONLY #include "ofMain.h" -#include "CBLinuxProject.h" -#include "CBWinProject.h" -#include "visualStudioProject.h" -#include "xcodeProject.h" -#include - -#include "ofxGui.h" -#include "ofAddon.h" -#include "ofxXmlSettings.h" -#include "textButton.h" - +#include "simplePGPage.h" class testApp : public ofBaseApp{ @@ -33,57 +23,8 @@ class testApp : public ofBaseApp{ void dragEvent(ofDragInfo dragInfo); void gotMessage(ofMessage msg); + simplePGPage simple; - string sketchName; - string sketchPath; - string addons; - string platform; - - ofxPanel panelCoreAddons; - ofxPanel panelOtherAddons; - bool bHaveNonCoreAddons; - - ofxPanel panelPlatforms; - - ofxToggle osxToggle, iosToggle, wincbToggle, winvsToggle, linuxcbToggle, linux64cbToggle; - - ofTrueTypeFont font; - ofTrueTypeFont titleFont; - ofTrueTypeFont secondFont; - - int mode; - enum { MODE_NORMAL, MODE_ADDON, MODE_PLATFORM }; - - baseProject * project; - - string setupForTarget(int targ); - - void generateProject(); - - string addonsPath; - string status; - - ofxXmlSettings XML; - string appToRoot; - string defaultLoc; - - float uiLeftX; - - - textButton button; - textButton generateButton; - textButton addonButton; - vector < textButton > buttons; - - bool isAddonCore(string addon); - bool bInited; - vector < string > coreAddons; - - float statusSetTime; - float statusEnergy; - void setStatus(string newStatus); - - ofImage logo; }; diff --git a/src/utils/Utils.cpp b/src/utils/Utils.cpp index 47f8c28..b123055 100644 --- a/src/utils/Utils.cpp +++ b/src/utils/Utils.cpp @@ -44,6 +44,38 @@ using namespace Poco; #include "ofUtils.h" +void convertWindowsToUnixPath(string & path){ + for (int i = 0; i < path.size(); i++){ + if (path[i] == '\\') path[i] = '/'; + } +} + +string windowsFromUnixPath(string path){ + for (int i = 0; i < path.size(); i++){ + if (path[i] == '/') path[i] = '\\'; + } + return path; +} + +//------------------------------------------------------ +// for project names, let's fix replace any odd characters with _ +void fixStringCharacters(string &toFix){ + + // replace all non alpha numeric (ascii) characters with _ + for (int i = 0; i < toFix.size(); i++){ + int which = (int)toFix[i]; + if ((which >= 48 && which <= 57) || + (which >= 65 && which <= 90) || + (which >= 97 && which <= 122)){ + } else { + toFix[i] = '_'; + } + } +} + + + + string StringToUpper(string strToConvert) { std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(), ::toupper); diff --git a/src/utils/Utils.h b/src/utils/Utils.h index fd6e00e..b693a03 100644 --- a/src/utils/Utils.h +++ b/src/utils/Utils.h @@ -15,6 +15,10 @@ #include "ofMain.h" +void convertWindowsToUnixPath(string & path); +string windowsFromUnixPath(string path); +void fixStringCharacters(string &toFix); + string generateUUID(string input); string getOFRoot(); From c5590381ce10b345fb0dca1d90bf2d792b6c8c91 Mon Sep 17 00:00:00 2001 From: zach lieberman Date: Thu, 8 Aug 2013 09:28:00 -0400 Subject: [PATCH 2/5] make all projects page added --- projectGenerator.xcodeproj/project.pbxproj | 6 + src/pages/makeProjectsPGPage.cpp | 467 +++++++++++++++++++++ src/pages/makeProjectsPGPage.h | 68 +++ src/projects/xcodeProject.cpp | 1 - src/testApp.cpp | 30 +- src/testApp.h | 9 + 6 files changed, 575 insertions(+), 6 deletions(-) create mode 100644 src/pages/makeProjectsPGPage.cpp create mode 100644 src/pages/makeProjectsPGPage.h diff --git a/projectGenerator.xcodeproj/project.pbxproj b/projectGenerator.xcodeproj/project.pbxproj index c1b2581..049f242 100644 --- a/projectGenerator.xcodeproj/project.pbxproj +++ b/projectGenerator.xcodeproj/project.pbxproj @@ -47,6 +47,7 @@ E4EB6799138ADC1D00A09F29 /* GLUT.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BBAB23BE13894E4700AA2426 /* GLUT.framework */; }; FD63DC6817B3CEA90023EEB1 /* basePGPage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD63DC6417B3CEA90023EEB1 /* basePGPage.cpp */; }; FD63DC6917B3CEA90023EEB1 /* simplePGPage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD63DC6617B3CEA90023EEB1 /* simplePGPage.cpp */; }; + FD63DC6C17B3D2C70023EEB1 /* makeProjectsPGPage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD63DC6A17B3D2C70023EEB1 /* makeProjectsPGPage.cpp */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -149,6 +150,8 @@ FD63DC6517B3CEA90023EEB1 /* basePGPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = basePGPage.h; sourceTree = ""; }; FD63DC6617B3CEA90023EEB1 /* simplePGPage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = simplePGPage.cpp; sourceTree = ""; }; FD63DC6717B3CEA90023EEB1 /* simplePGPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = simplePGPage.h; sourceTree = ""; }; + FD63DC6A17B3D2C70023EEB1 /* makeProjectsPGPage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = makeProjectsPGPage.cpp; sourceTree = ""; }; + FD63DC6B17B3D2C70023EEB1 /* makeProjectsPGPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = makeProjectsPGPage.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -398,6 +401,8 @@ FD63DC6317B3CEA90023EEB1 /* pages */ = { isa = PBXGroup; children = ( + FD63DC6A17B3D2C70023EEB1 /* makeProjectsPGPage.cpp */, + FD63DC6B17B3D2C70023EEB1 /* makeProjectsPGPage.h */, FD63DC6417B3CEA90023EEB1 /* basePGPage.cpp */, FD63DC6517B3CEA90023EEB1 /* basePGPage.h */, FD63DC6617B3CEA90023EEB1 /* simplePGPage.cpp */, @@ -514,6 +519,7 @@ 27C4A1C1179491920031C6E4 /* ofxToggle.cpp in Sources */, FD63DC6817B3CEA90023EEB1 /* basePGPage.cpp in Sources */, FD63DC6917B3CEA90023EEB1 /* simplePGPage.cpp in Sources */, + FD63DC6C17B3D2C70023EEB1 /* makeProjectsPGPage.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/pages/makeProjectsPGPage.cpp b/src/pages/makeProjectsPGPage.cpp new file mode 100644 index 0000000..57b9754 --- /dev/null +++ b/src/pages/makeProjectsPGPage.cpp @@ -0,0 +1,467 @@ +#include "makeProjectsPGPage.h" +#include "Utils.h" +#include + +//-------------------------------------------------------------- +void makeProjectsPGPage::setup(){ + //ofSetLogLevel(OF_LOG_VERBOSE); + 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,&makeProjectsPGPage::createProjectPressed); + updateProject.addListener(this,&makeProjectsPGPage::updateProjectPressed); + createAndOpen.addListener(this,&makeProjectsPGPage::createAndOpenPressed); + changeOFRoot.addListener(this,&makeProjectsPGPage::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(linuxarmv6lcbToggle.setup("linuxarmv6l CB projects",ofGetTargetPlatform()==OF_TARGET_LINUXARMV6L)); + examplesPanel.add(linuxarmv7lcbToggle.setup("linuxarmv7l CB projects",ofGetTargetPlatform()==OF_TARGET_LINUXARMV7L)); + examplesPanel.add(osxToggle.setup("osx projects",ofGetTargetPlatform()==OF_TARGET_OSX)); + examplesPanel.add(iosToggle.setup("ios projects",ofGetTargetPlatform()==OF_TARGET_IPHONE)); + + generateButton.addListener(this,&makeProjectsPGPage::generateExamplesCB); + + ofSetVerticalSync(true); + ofEnableAlphaBlending(); + ofSetFrameRate(60); +#else + std::exit(0); +#endif +} + +void makeProjectsPGPage::setupForTarget(int targ){ + + if(project){ + delete project; + } + + switch(targ){ + case OF_TARGET_OSX: + project = new xcodeProject; + target = "osx"; + break; + case OF_TARGET_WINGCC: + project = new CBWinProject; + target = "win_cb"; + break; + case OF_TARGET_WINVS: + project = new visualStudioProject; + target = "vs"; + break; + case OF_TARGET_IPHONE: + project = new xcodeProject(); + target = "ios"; + break; + case OF_TARGET_ANDROID: + break; + case OF_TARGET_LINUX: + project = new CBLinuxProject; + target = "linux"; + break; + case OF_TARGET_LINUX64: + project = new CBLinuxProject; + target = "linux64"; + break; + case OF_TARGET_LINUXARMV6L: + project = new CBLinuxProject; + target = "linuxarmv6l"; + break; + case OF_TARGET_LINUXARMV7L: + project = new CBLinuxProject; + target = "linuxarmv7l"; + break; + } +} + +void makeProjectsPGPage::generateExamplesCB(){ + +#ifndef COMMAND_LINE_ONLY + + targetsToMake.clear(); + if( osxToggle ) targetsToMake.push_back(OF_TARGET_OSX); + if( iosToggle ) targetsToMake.push_back(OF_TARGET_IPHONE); + if( wincbToggle ) targetsToMake.push_back(OF_TARGET_WINGCC); + if( winvsToggle ) targetsToMake.push_back(OF_TARGET_WINVS); + if( linuxcbToggle ) targetsToMake.push_back(OF_TARGET_LINUX); + if( linux64cbToggle ) targetsToMake.push_back(OF_TARGET_LINUX64); + if( linuxarmv6lcbToggle ) targetsToMake.push_back(OF_TARGET_LINUXARMV6L); + if( linuxarmv7lcbToggle ) targetsToMake.push_back(OF_TARGET_LINUXARMV7L); + + if( targetsToMake.size() == 0 ){ + cout << "Error: generateExamplesCB - must specifiy a project to generate " <setup(target); + project->create(subdir.getPath(j)); + vector < string > addons; + parseAddonsDotMake(project->getPath() + "addons.make", addons); + for (int i = 0; i < (int)addons.size(); i++){ + ofAddon addon; + addon.pathToOF = getOFRelPath(subdir.getPath(j)); + addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addons[i]),target); + project->addAddon(addon); + } + project->save(false); + + } + } + ofLogNotice() << " "; + ofLogNotice() << "Finished generating examples for " << target; +} + +ofFileDialogResult makeProjectsPGPage::makeNewProjectViaDialog(){ + +#ifndef COMMAND_LINE_ONLY + ofFileDialogResult res = ofSystemSaveDialog("newProjectName", "choose a folder for a new OF project :)"); + if (res.fileName == "" || res.filePath == "") return res; + //base.pushDirectory(res.fileName); // somehow an extra things here helps? + + vector targetsToMake; + if( osxToggle ) targetsToMake.push_back(OF_TARGET_OSX); + if( iosToggle ) targetsToMake.push_back(OF_TARGET_IPHONE); + if( wincbToggle ) targetsToMake.push_back(OF_TARGET_WINGCC); + if( winvsToggle ) targetsToMake.push_back(OF_TARGET_WINVS); + if( linuxcbToggle ) targetsToMake.push_back(OF_TARGET_LINUX); + if( linux64cbToggle ) targetsToMake.push_back(OF_TARGET_LINUX64); + if( linuxarmv6lcbToggle ) targetsToMake.push_back(OF_TARGET_LINUXARMV6L); + if( linuxarmv7lcbToggle ) targetsToMake.push_back(OF_TARGET_LINUXARMV7L); + + if( targetsToMake.size() == 0 ){ + cout << "Error: makeNewProjectViaDialog - must specifiy a project to generate " <setup(target); + if(project->create(res.filePath)){ + vector addonsToggles = panelAddons.getControlNames(); + for (int i = 0; i < (int) addonsToggles.size(); i++){ + ofxToggle toggle = panelAddons.getToggle(addonsToggles[i]); + if(toggle){ + ofAddon addon; + addon.pathToOF = getOFRelPath(res.filePath); + addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addonsToggles[i]),target); + printf("adding %s addons \n", addonsToggles[i].c_str()); + project->addAddon(addon); + + } + } + project->save(true); + } + } + return res; +#endif + +} + +ofFileDialogResult makeProjectsPGPage::updateProjectViaDialog(){ + +#ifndef COMMAND_LINE_ONLY + ofFileDialogResult res = ofSystemLoadDialog("choose a folder to update an OF project :)",true); + if (res.fileName == "" || res.filePath == "") return res; + //base.pushDirectory(res.fileName); // somehow an extra things here helps? + + vector targetsToMake; + if( osxToggle ) targetsToMake.push_back(OF_TARGET_OSX); + if( iosToggle ) targetsToMake.push_back(OF_TARGET_IPHONE); + if( wincbToggle ) targetsToMake.push_back(OF_TARGET_WINGCC); + if( winvsToggle ) targetsToMake.push_back(OF_TARGET_WINVS); + if( linuxcbToggle ) targetsToMake.push_back(OF_TARGET_LINUX); + if( linux64cbToggle ) targetsToMake.push_back(OF_TARGET_LINUX64); + if( linuxarmv6lcbToggle ) targetsToMake.push_back(OF_TARGET_LINUXARMV6L); + if( linuxarmv7lcbToggle ) targetsToMake.push_back(OF_TARGET_LINUXARMV7L); + + if( targetsToMake.size() == 0 ){ + cout << "Error: updateProjectViaDialog - must specifiy a project to generate " <setup(target); + project->create(res.filePath); + vector addonsToggles = panelAddons.getControlNames(); + for (int i = 0; i < (int)addonsToggles.size(); i++){ + ofxToggle toggle = panelAddons.getToggle(addonsToggles[i]); + // TODO: make this remove existing addons that are unchecked???? + // probably requires a more complex logic chain: loadProject + // (ticks the addons) and then you can untick etc??? + if(toggle){ + ofAddon addon; + addon.pathToOF = getOFRelPath(res.filePath); + addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addonsToggles[i]),target); + printf("adding %s addons \n", addonsToggles[i].c_str()); + project->addAddon(addon); + + } + } + project->save(true); + } + + return res; +#endif + +} + +void makeProjectsPGPage::createProjectPressed(){ + makeNewProjectViaDialog(); +} + +void makeProjectsPGPage::updateProjectPressed(){ + updateProjectViaDialog(); +} + +void makeProjectsPGPage::createAndOpenPressed(){ + ofFileDialogResult res = makeNewProjectViaDialog(); + if(res.bSuccess){ + #ifdef TARGET_LINUX + system(("/usr/bin/codeblocks " + ofFilePath::join(res.filePath, res.fileName+".workspace ") + "&").c_str()); + #elif defined(TARGET_OSX) + system(("open " + ofFilePath::join(res.filePath, res.fileName+".xcodeproj ") + "&").c_str()); + #elif defined(TARGET_WIN32) + system(("open " + ofFilePath::join(res.filePath, res.fileName+".workspace ") + "&").c_str()); + #endif + } +} + +void makeProjectsPGPage::changeOFRootPressed(){ + askOFRoot(); + cout << getOFRootFromConfig()< subdirs = ofSplitString("OF path: " + getOFRoot(), "/"); + int textLength = 0; + int padding = 5; + string path = ""; + int lines=1; + int fontSize = 8; + float leading = 1.7; + + ofPathRect.x = padding; + ofPathRect.y = padding; + ofPathDrawPoint.x = padding*2; + ofPathDrawPoint.y = padding*2 + fontSize * leading; + + for(int i = 0; i < subdirs.size(); i++) { + if (i > 0 && i 1){ + ofPathRect.width = ofGetWidth() - padding*2; + } + ofPathRect.height = lines * fontSize * leading + (padding*2); + + drawableOfPath = path; + + panelAddons.setPosition(panelAddons.getPosition().x, ofPathRect.y + ofPathRect.height + padding); + examplesPanel.setPosition(examplesPanel.getPosition().x, ofPathRect.y + ofPathRect.height + padding); +#endif + + +} diff --git a/src/pages/makeProjectsPGPage.h b/src/pages/makeProjectsPGPage.h new file mode 100644 index 0000000..ca228c3 --- /dev/null +++ b/src/pages/makeProjectsPGPage.h @@ -0,0 +1,68 @@ +#pragma once + +//#define COMMAND_LINE_ONLY + +#include "ofMain.h" +#include "basePGPage.h" + +#include "CBLinuxProject.h" +#include "CBWinProject.h" +#include "visualStudioProject.h" +#include "xcodeProject.h" +#include + +#ifndef COMMAND_LINE_ONLY +#include "ofxGui.h" +#endif + +class makeProjectsPGPage : public basePGPage { + + public: + void setup(); + void update(); + void draw(); + + void keyPressed (int key); + void keyReleased(int key); + void mouseMoved(int x, int y ); + void mouseDragged(int x, int y, int button); + void mousePressed(int x, int y, int button); + void mouseReleased(int x, int y, int button); + void windowResized(int w, int h); + void dragEvent(ofDragInfo dragInfo); + void gotMessage(ofMessage msg); + + void setupForTarget(int targ); + void generateExamplesCB(); + void generateExamples(); + + ofFileDialogResult makeNewProjectViaDialog(); + ofFileDialogResult updateProjectViaDialog(); + + void createProjectPressed(); + void updateProjectPressed(); + void createAndOpenPressed(); + void changeOFRootPressed(); + + void setupDrawableOFPath(); + + baseProject * project; + + string projectPath; + string target; + vector targetsToMake; + bool buildAllExamples; + +#ifndef COMMAND_LINE_ONLY + string drawableOfPath; + ofRectangle ofPathRect; + ofPoint ofPathDrawPoint; + + ofxPanel panelAddons, panelOptions; + ofxButton createProject, updateProject, createAndOpen, changeOFRoot; + + ofxPanel examplesPanel; + ofxToggle osxToggle, iosToggle, wincbToggle, winvsToggle, linuxcbToggle, linux64cbToggle,linuxarmv6lcbToggle,linuxarmv7lcbToggle; + ofxButton generateButton; +#endif +}; diff --git a/src/projects/xcodeProject.cpp b/src/projects/xcodeProject.cpp index b1af746..cf559f4 100644 --- a/src/projects/xcodeProject.cpp +++ b/src/projects/xcodeProject.cpp @@ -749,7 +749,6 @@ void xcodeProject::addInclude(string includeName){ } else { //printf("we don't have HEADER_SEARCH_PATHS, so we're adding them... and calling this function again \n"); - query[255]; sprintf(query, "//key[contains(.,'baseConfigurationReference')]/parent::node()//key[contains(.,'buildSettings')]/following-sibling::node()[1]"); pugi::xpath_node_set dictArray = doc.select_nodes(query); diff --git a/src/testApp.cpp b/src/testApp.cpp index a5c5481..e1569e7 100644 --- a/src/testApp.cpp +++ b/src/testApp.cpp @@ -9,24 +9,41 @@ //-------------------------------------------------------------- void testApp::setup(){ + + mode = MODE_SIMPLE; + simple.setup(); + makeProjects.setup(); } //-------------------------------------------------------------- void testApp::update(){ - simple.update(); + + + if (mode == MODE_SIMPLE) simple.update(); + else if (mode == MODE_MAKE_ALL) makeProjects.update(); } //-------------------------------------------------------------- void testApp::draw(){ - simple.draw(); + + if (mode == MODE_SIMPLE) simple.draw(); + else if (mode == MODE_MAKE_ALL) makeProjects.draw(); + } //-------------------------------------------------------------- void testApp::keyPressed(int key){ + + + - simple.keyPressed(key); + if (mode == MODE_SIMPLE) simple.keyPressed(key); + else if (mode == MODE_MAKE_ALL) makeProjects.keyPressed(key); + + + if (key == OF_KEY_RIGHT){ mode++; mode %= 2; } } //-------------------------------------------------------------- @@ -46,7 +63,8 @@ void testApp::mouseDragged(int x, int y, int button){ //-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ - simple.mousePressed(x,y,button); + if (mode == MODE_SIMPLE) simple.mousePressed(x,y,button); + else if (mode == MODE_MAKE_ALL) makeProjects.mousePressed(x,y,button); } //-------------------------------------------------------------- @@ -56,7 +74,9 @@ void testApp::mouseReleased(int x, int y, int button){ //-------------------------------------------------------------- void testApp::windowResized(int w, int h){ - simple.windowResized(w, h); + + if (mode == MODE_SIMPLE) simple.windowResized(w,h); + //makeProjectsPGPage.windowResized(w, h); } diff --git a/src/testApp.h b/src/testApp.h index 7a2f269..dadcd1d 100644 --- a/src/testApp.h +++ b/src/testApp.h @@ -4,6 +4,8 @@ #include "ofMain.h" #include "simplePGPage.h" +#include "makeProjectsPGPage.h" + class testApp : public ofBaseApp{ @@ -24,7 +26,14 @@ class testApp : public ofBaseApp{ void gotMessage(ofMessage msg); simplePGPage simple; + makeProjectsPGPage makeProjects; + + enum { + MODE_SIMPLE, + MODE_MAKE_ALL + }; + int mode; }; From a228e98adeff97bdb34301cd8302ca387a92ea6a Mon Sep 17 00:00:00 2001 From: zach lieberman Date: Thu, 8 Aug 2013 09:34:38 -0400 Subject: [PATCH 3/5] added linux command line options from main PG --- src/main.cpp | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 390bf81..8d87e26 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,9 +8,106 @@ int main( int argc, char *argv[] ){ + + + cout << "In main." << endl; + cout << "ofGetTargetPlatform=" << ofGetTargetPlatform() << endl; + +#ifdef TARGET_LINUX + if(argc==1){ + + ofAppGlutWindow window; + ofSetupOpenGL(&window, 1024, 610, OF_WINDOW); + testApp * app = new testApp; + ofRunApp( app ); + + }else{ + ofAppNoWindow window; + ofSetupOpenGL(&window, 1024,768, OF_WINDOW); + testApp * app = new testApp; + app->makeProjects.buildAllExamples = false; + app->makeProjects.projectPath = ""; + for(int i=1;imakeProjects.targetsToMake.push_back( OF_TARGET_LINUX ); + }else if(arg=="linux64"){ + app->makeProjects.targetsToMake.push_back( OF_TARGET_LINUX64 ); + }else if(arg=="linuxarmv6l"){ + app->makeProjects.targetsToMake.push_back( OF_TARGET_LINUXARMV6L ); + }else if(arg=="linuxarmv7l"){ + app->makeProjects.targetsToMake.push_back( OF_TARGET_LINUXARMV7L ); + }else if(arg=="win_cb"){ + app->makeProjects.targetsToMake.push_back( OF_TARGET_WINGCC ); + }else if(arg=="vs"){ + app->makeProjects.targetsToMake.push_back( OF_TARGET_WINVS ); + }else if(arg=="osx"){ + app->makeProjects.targetsToMake.push_back( OF_TARGET_OSX ); + }else if(arg=="ios"){ + app->makeProjects.targetsToMake.push_back( OF_TARGET_IPHONE ); + }else if(arg=="android"){ + ofLogError() << "platform not supported yet" << endl; + std::exit(1); + }else if(arg=="allplatforms"){ + app->makeProjects.targetsToMake.push_back( OF_TARGET_LINUX ); + app->makeProjects.targetsToMake.push_back( OF_TARGET_LINUX64 ); + app->makeProjects.targetsToMake.push_back( OF_TARGET_LINUXARMV6L ); + app->makeProjects.targetsToMake.push_back( OF_TARGET_LINUXARMV7L ); + app->makeProjects.targetsToMake.push_back( OF_TARGET_WINGCC ); + app->makeProjects.targetsToMake.push_back( OF_TARGET_WINVS ); + app->makeProjects.targetsToMake.push_back( OF_TARGET_OSX ); + app->makeProjects.targetsToMake.push_back( OF_TARGET_IPHONE ); + }else if(arg=="allexamples"){ + app->makeProjects.buildAllExamples = true; + }else if(arg=="help"){ + cout << "OF Project Generator Usage:" << endl; + cout << "projectGenerator [options] [pathToExample]" << endl; + cout << "Options:" << endl; + cout << "--osx: generate osx project files" << endl; + cout << "--win_cb: generate windows codeblocks project files" << endl; + cout << "--vs: generate windows visual studio project files" << endl; + cout << "--linux: generate linux project files" << endl; + cout << "--linux64: generate linux 64bits project files" << endl; + cout << "--linuxarmv6l: generate linux armv6l project files" << endl; + cout << "--linuxarmv7l: generate linux armv7l project files" << endl; + cout << "--ios: generate iOS project files" << endl; + cout << "--allplatforms: generate project files for all platforms" << endl; + cout << "--allexamples: generate project files for all examples. [pathToExample] is not needed in this case." << endl; + cout << endl; + cout << "default: create project files for current platform for selected path" << endl; + cout << "running over existing example updates project files for selected platforms" << endl; + cout << "without parameters, shows gui" << endl; + std::exit(0); + }else{ + cout << "Error: Unknown argument --" << arg << ". Run \'projectGenerator help\' for details. Aborting." << endl; + std::exit(1); + } + }else if(arg.find("-", 0, 1)==0){ + cout << "Error: Unknown argument " << arg << ". Run \'projectGenerator help\' for details. Aborting." << endl; + std::exit(1); + }else{ + app->makeProjects.projectPath = ofFilePath::removeTrailingSlash(ofFilePath::getPathForDirectory(ofFilePath::getAbsolutePath(arg,false))); + } + } + + if (!(app->makeProjects.buildAllExamples) && app->makeProjects.projectPath.empty()){ + cout << "Error: No target project given. Either run projectGenerator with the --allexamples option or supply a target project folder path. Run \'projectGenerator help\' for details." << endl; + std::exit(1); + } + + if(app->makeProjects.targetsToMake.empty()) + app->makeProjects.targetsToMake.push_back( ofGetTargetPlatform() ); + ofRunApp( app ); + } +#else + ofAppGlutWindow window; ofSetupOpenGL(&window, 1024, 610, OF_WINDOW); testApp * app = new testApp; - //app->buildAllExamples = false; - ofRunApp( app ); + ofRunApp( app ); + +#endif + } From 28572ed0d0eea3043f7249b7f1d6d4fd588fcaf7 Mon Sep 17 00:00:00 2001 From: zach lieberman Date: Sun, 11 Aug 2013 08:47:31 -0400 Subject: [PATCH 4/5] rework --- .../settings/projectGeneratorSettings.xml | 26 +- projectGenerator.xcodeproj/project.pbxproj | 12 +- src/gui/textButton.h | 22 +- src/main.cpp | 7 +- src/pages/basePGPage.h | 12 + src/pages/generateProjects.cpp | 550 ++++++++++++++++++ src/pages/generateProjects.h | 86 +++ src/pages/makeProjectsPGPage.cpp | 319 ++++------ src/pages/makeProjectsPGPage.h | 21 +- src/pages/simplePGPage.cpp | 89 +-- src/pages/simplePGPage.h | 10 +- src/testApp.cpp | 42 ++ src/testApp.h | 10 +- 13 files changed, 929 insertions(+), 277 deletions(-) create mode 100644 src/pages/generateProjects.cpp create mode 100644 src/pages/generateProjects.h diff --git a/bin/data/settings/projectGeneratorSettings.xml b/bin/data/settings/projectGeneratorSettings.xml index 5f488c8..4572ce6 100644 --- a/bin/data/settings/projectGeneratorSettings.xml +++ b/bin/data/settings/projectGeneratorSettings.xml @@ -1,6 +1,24 @@ - -../../../../ + - -apps/myApps + + + + ../../../../ + + + + 1 + + + + + + + apps/myApps + + + + diff --git a/projectGenerator.xcodeproj/project.pbxproj b/projectGenerator.xcodeproj/project.pbxproj index 049f242..5f47102 100644 --- a/projectGenerator.xcodeproj/project.pbxproj +++ b/projectGenerator.xcodeproj/project.pbxproj @@ -47,7 +47,7 @@ E4EB6799138ADC1D00A09F29 /* GLUT.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BBAB23BE13894E4700AA2426 /* GLUT.framework */; }; FD63DC6817B3CEA90023EEB1 /* basePGPage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD63DC6417B3CEA90023EEB1 /* basePGPage.cpp */; }; FD63DC6917B3CEA90023EEB1 /* simplePGPage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD63DC6617B3CEA90023EEB1 /* simplePGPage.cpp */; }; - FD63DC6C17B3D2C70023EEB1 /* makeProjectsPGPage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD63DC6A17B3D2C70023EEB1 /* makeProjectsPGPage.cpp */; }; + FD63DC7217B56EE50023EEB1 /* generateProjects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FD63DC7017B56EE50023EEB1 /* generateProjects.cpp */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -150,8 +150,8 @@ FD63DC6517B3CEA90023EEB1 /* basePGPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = basePGPage.h; sourceTree = ""; }; FD63DC6617B3CEA90023EEB1 /* simplePGPage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = simplePGPage.cpp; sourceTree = ""; }; FD63DC6717B3CEA90023EEB1 /* simplePGPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = simplePGPage.h; sourceTree = ""; }; - FD63DC6A17B3D2C70023EEB1 /* makeProjectsPGPage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = makeProjectsPGPage.cpp; sourceTree = ""; }; - FD63DC6B17B3D2C70023EEB1 /* makeProjectsPGPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = makeProjectsPGPage.h; sourceTree = ""; }; + FD63DC7017B56EE50023EEB1 /* generateProjects.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = generateProjects.cpp; sourceTree = ""; }; + FD63DC7117B56EE50023EEB1 /* generateProjects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = generateProjects.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -401,8 +401,8 @@ FD63DC6317B3CEA90023EEB1 /* pages */ = { isa = PBXGroup; children = ( - FD63DC6A17B3D2C70023EEB1 /* makeProjectsPGPage.cpp */, - FD63DC6B17B3D2C70023EEB1 /* makeProjectsPGPage.h */, + FD63DC7017B56EE50023EEB1 /* generateProjects.cpp */, + FD63DC7117B56EE50023EEB1 /* generateProjects.h */, FD63DC6417B3CEA90023EEB1 /* basePGPage.cpp */, FD63DC6517B3CEA90023EEB1 /* basePGPage.h */, FD63DC6617B3CEA90023EEB1 /* simplePGPage.cpp */, @@ -519,7 +519,7 @@ 27C4A1C1179491920031C6E4 /* ofxToggle.cpp in Sources */, FD63DC6817B3CEA90023EEB1 /* basePGPage.cpp in Sources */, FD63DC6917B3CEA90023EEB1 /* simplePGPage.cpp in Sources */, - FD63DC6C17B3D2C70023EEB1 /* makeProjectsPGPage.cpp in Sources */, + FD63DC7217B56EE50023EEB1 /* generateProjects.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/gui/textButton.h b/src/gui/textButton.h index ff74e2d..77ba73c 100644 --- a/src/gui/textButton.h +++ b/src/gui/textButton.h @@ -21,18 +21,28 @@ class textButton{ ofRectangle rect; bool bSelectable; bool bDrawLong; - string secondaryText; - - string deliminater; int maxWidth; - - bool bMouseOver; ofColor off; ofColor on; - + + + void setup(ofTrueTypeFont * _font, ofTrueTypeFont * _secondFont, string _prefix, string _text, string _secondaryText, ofPoint anchor, string _deliminator = ""){ + + deliminater = _deliminator; + + font = _font; + secondFont = _secondFont; + prefix = _prefix; + topLeftAnchor.set(anchor); //set top button position - others are set relative to this. + setText(_text); + secondaryText = _secondaryText; + + } + + void setText(string newText){ diff --git a/src/main.cpp b/src/main.cpp index 8d87e26..9a14760 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,17 +8,19 @@ int main( int argc, char *argv[] ){ - + cout << "In main." << endl; cout << "ofGetTargetPlatform=" << ofGetTargetPlatform() << endl; #ifdef TARGET_LINUX + cout << "linux " << endl; if(argc==1){ ofAppGlutWindow window; ofSetupOpenGL(&window, 1024, 610, OF_WINDOW); testApp * app = new testApp; + ofRunApp( app ); }else{ @@ -102,10 +104,11 @@ int main( int argc, char *argv[] ){ ofRunApp( app ); } #else - + printf("??"); ofAppGlutWindow window; ofSetupOpenGL(&window, 1024, 610, OF_WINDOW); testApp * app = new testApp; + //app->makeProjects.buildAllExamples = false; ofRunApp( app ); #endif diff --git a/src/pages/basePGPage.h b/src/pages/basePGPage.h index 952aab8..5828956 100644 --- a/src/pages/basePGPage.h +++ b/src/pages/basePGPage.h @@ -21,4 +21,16 @@ class basePGPage { virtual void dragEvent(ofDragInfo dragInfo) = 0;; virtual void gotMessage(ofMessage msg) = 0;; + + typedef struct { + string appRoot; + bool multiplatform; + string defaultNewProjectLocation; + } pgSettings; + + pgSettings settings; + + ofTrueTypeFont * font; + ofTrueTypeFont * titleFont; + ofTrueTypeFont * secondFont; }; diff --git a/src/pages/generateProjects.cpp b/src/pages/generateProjects.cpp new file mode 100644 index 0000000..f732029 --- /dev/null +++ b/src/pages/generateProjects.cpp @@ -0,0 +1,550 @@ +#include "generateProjects.h" +#include "Utils.h" +#include +#include "ofConstants.h" + + + + + +//------------------------------------------------------ +string generateProjects::setupForTarget(int targ){ + + if(project){ + delete project; + } + string target; + switch(targ){ + case OF_TARGET_OSX: + project = new xcodeProject; + target = "osx"; + break; + case OF_TARGET_WINGCC: + project = new CBWinProject; + target = "win_cb"; + break; + case OF_TARGET_WINVS: + project = new visualStudioProject; + target = "vs"; + break; + case OF_TARGET_IPHONE: + project = new xcodeProject(); + target = "ios"; + break; + case OF_TARGET_ANDROID: + break; + case OF_TARGET_LINUX64: + project = new CBLinuxProject; + target = "linux64"; + break; + case OF_TARGET_LINUX: + project = new CBLinuxProject; + target = "linux"; + break; + } + + project->setup(target); + + return target; +} + + + +void generateProjects::setStatus(string newStatus){ + statusEnergy = 1; + status = newStatus; + statusSetTime = ofGetElapsedTimef(); +} + + + +//-------------------------------------------------------------- +void generateProjects::setup(){ + ofEnableAlphaBlending(); + ofEnableSmoothing(); + ofSetLogLevel(OF_LOG_VERBOSE); + ofSetVerticalSync(true); + + + statusEnergy = 0; + + mode = 0; + bInited = false; + project = NULL; + sketchName = "mySketch"; + + + + //------------------------------------- + // 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, settings.appRoot)); + string examplesPath = ofFilePath::join(ofRoot, "examples"); + + 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 + //------------------------------------- + + // Sketch button + // + button.font = font; + button.secondFont = secondFont; + + + // Path button + // + button.topLeftAnchor.set(76, 160+40); + button.deliminater = "/"; + button.prefix = "Base OF 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); + + + button.deliminater = "/"; + button.prefix = "Examples path: "; + button.setText(examplesPath); + 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); + + + // 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(); + + + + //------------------------------------- + // 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(); + +} + + + + + + +//-------------------------------------------------------------- +void generateProjects::update(){ + + float diff = ofGetElapsedTimef()- statusSetTime; + if (diff > 3){ + statusEnergy *= 0.99;; + } + //------------------------------------- + // if we are in addon mode check + //------------------------------------- + + if (mode == MODE_ADDON ) addonButton.checkMousePressed(ofPoint(ofGetMouseX(), ofGetMouseY())); + + + //------------------------------------- + // layout our normal buttons, check the mouse + //------------------------------------- + + for (int i = 0; i < buttons.size(); i++){ + buttons[i].calculateRect(); + buttons[i].checkMousePressed(ofPoint(ofGetMouseX(), ofGetMouseY())); + } + + generateButton.checkMousePressed(ofPoint(ofGetMouseX(), ofGetMouseY())); + + for (int i = 0; i < buttons.size(); i++){ + if (i != 0){ + buttons[i].topLeftAnchor.y = buttons[i-1].topLeftAnchor.y +buttons[i-1].rect.height + 20; + } + } + + + //------------------------------------- + // addons panels can be really long, so use the mouse pos to move them if we need to + //------------------------------------- + + if (panelCoreAddons.getShape().height > ofGetHeight()){ + float pct = ofMap(ofGetMouseY(), 0,ofGetHeight(), 0,1,true); + float diff = panelCoreAddons.getShape().height - ofGetHeight(); + panelCoreAddons.setPosition(panelCoreAddons.getPosition().x,-diff * pct); + } + + if (panelOtherAddons.getShape().height > ofGetHeight()){ + float pct = ofMap(ofGetMouseY(), 0,ofGetHeight(), 0,1,true); + float diff = panelOtherAddons.getShape().height - ofGetHeight(); + panelOtherAddons.setPosition(panelOtherAddons.getPosition().x,-diff * pct); + } + +} + +//-------------------------------------------------------------- +void generateProjects::draw(){ + + + //cout << ofFilePath::join(ofFilePath::join(ofFilePath::getCurrentExeDir(), "../../../"), appToRoot) << endl; + + cout << settings.appRoot << endl; + //cout << ofFilePath::join(ofFilePath::join(ofFilePath::getCurrentExeDir(), "../../../"), appToRoot) << endl; + + if (mode != MODE_ADDON ) { + + ofSetColor(100); + logo.draw(64, 61,logo.getWidth(),logo.getHeight()); + + //ofSetColor(74,255,203); + titleFont->drawString("PROJECT", 64 + logo.getWidth() + 25, 85); + titleFont->drawString("GENERATOR", 64 + logo.getWidth() + 25, 117); + } + + if (mode == 0){ + for (int i = 0; i < buttons.size(); i++){ + buttons[i].draw(); + } + + generateButton.draw(); + + } else if (mode == 1){ + panelCoreAddons.draw(); + if (bHaveNonCoreAddons){ + panelOtherAddons.draw(); + } + } else if (mode == 2){ + panelPlatforms.draw(); + } + //cout << panelAddons.getShape().height << endl; + + + + + if (mode == 1 ){ + addonButton.draw(); + + ofRectangle rect = secondFont->getStringBoundingBox("select core and non-core addons to add", addonButton.topLeftAnchor.x-200, 60); + ofSetColor(220,220,220); + ofRect(rect.x-10, rect.y-10, rect.width+20, rect.height+20); + ofSetColor(0,0,0); + secondFont->drawString("select core and non-core addons to add", addonButton.topLeftAnchor.x-200, 60); + } + + if (mode == 0){ + ofFill(); + ofSetColor(0 + 220 * (1-statusEnergy),0 + 220 * (1-statusEnergy),0 + 220 * (1-statusEnergy)); + ofRect(0,ofGetHeight(), ofGetWidth(), -25); + ofSetColor(255,255,255, 255 * statusEnergy); + ofDrawBitmapString(status, 10,ofGetHeight()-8); + } +} + +//-------------------------------------------------------------- +void generateProjects::keyPressed(int key){ + + if (key == ' '){ + + //printf("%s -------- \n", ResultBuffer); + //std::exit(0); + } + + +} + +void generateProjects::generateProject(){ + + vector targetsToMake; + if( osxToggle ) targetsToMake.push_back(OF_TARGET_OSX); + if( iosToggle ) targetsToMake.push_back(OF_TARGET_IPHONE); + if( wincbToggle ) targetsToMake.push_back(OF_TARGET_WINGCC); + if( winvsToggle ) targetsToMake.push_back(OF_TARGET_WINVS); + if( linuxcbToggle ) targetsToMake.push_back(OF_TARGET_LINUX); + if( linux64cbToggle ) targetsToMake.push_back(OF_TARGET_LINUX64); + + if( targetsToMake.size() == 0 ){ + cout << "Error: makeNewProjectViaDialog - must specifiy a project to generate " <create(path)){ + vector addonsToggles = panelCoreAddons.getControlNames(); + for (int i = 0; i < (int) addonsToggles.size(); i++){ + ofxToggle toggle = panelCoreAddons.getToggle(addonsToggles[i]); + if(toggle){ + ofAddon addon; + addon.pathToOF = getOFRelPath(path); + addon.fromFS(ofFilePath::join(addonsPath, addonsToggles[i]),target); + project->addAddon(addon); + + } + } + + + addonsToggles = panelOtherAddons.getControlNames(); + for (int i = 0; i < (int) addonsToggles.size(); i++){ + ofxToggle toggle = panelOtherAddons.getToggle(addonsToggles[i]); + if(toggle){ + ofAddon addon; + + addon.pathToOF = getOFRelPath(path); + cout << getOFRelPath(path) << " " << path << endl; + addon.fromFS(ofFilePath::join(addonsPath, addonsToggles[i]),target); + project->addAddon(addon); + + } + } + + project->save(true); + } + } + + + printf("done with project generation \n"); + setStatus("generated: " + buttons[1].myText + "/" + buttons[0].myText); + + // go through the control panels, do stuff +} + +//-------------------------------------------------------------- +void generateProjects::keyReleased(int key){ + + + +} + +//-------------------------------------------------------------- +void generateProjects::mouseMoved(int x, int y ){ + +} + +//-------------------------------------------------------------- +void generateProjects::mouseDragged(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void generateProjects::mousePressed(int x, int y, int button){ + + if (mode == MODE_NORMAL){ + + + // check the mouse for press + + for (int i = 0; i < buttons.size(); i++){ + buttons[i].checkMousePressed(ofPoint(x, y)); + } + + + + + + //------------------------------------- + // 0 = OF root + //------------------------------------- + + if (buttons[0].bMouseOver == true){ + + string command = ""; + + ofDirectory dir( getOFRoot() ); + + + #ifdef TARGET_WIN32 + ofFileDialogResult res = ofSystemLoadDialog("please select OF root folder", true, windowsFromUnixPath(dir.path())); + #else + ofFileDialogResult res = ofSystemLoadDialog("please select OF root folder", true, dir.path()); + #endif + + + if (res.bSuccess){ + string result = res.filePath; + convertWindowsToUnixPath(result); + buttons[0].setText( result ); + setStatus("path set to: " + result); + } + + + } + + + //------------------------------------- + // 1 = examples directory + //------------------------------------- + + if (buttons[1].bMouseOver == true){ + + string command = ""; + + ofDirectory dir( ofFilePath::join(getOFRoot(), "examples" )); + + +#ifdef TARGET_WIN32 + ofFileDialogResult res = ofSystemLoadDialog("please select examples folder", true, windowsFromUnixPath(dir.path())); +#else + ofFileDialogResult res = ofSystemLoadDialog("please select examples folder", true, dir.path()); +#endif + + + if (res.bSuccess){ + string result = res.filePath; + convertWindowsToUnixPath(result); + buttons[1].setText( result ); + setStatus("path set to: " + result); + } + } + + + //------------------------------------- + // 2 = platform (disabled) + //------------------------------------- + + + if (buttons[2].bMouseOver == true){ + // platform is diabled for now + mode = 2; + } + + } + + if (mode == MODE_PLATFORM){ + + } +} + +//-------------------------------------------------------------- +void generateProjects::mouseReleased(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void generateProjects::windowResized(int w, int h){ + 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(); + +} + +//-------------------------------------------------------------- +void generateProjects::gotMessage(ofMessage msg){ + +} + +//-------------------------------------------------------------- +void generateProjects::dragEvent(ofDragInfo dragInfo){ + +} diff --git a/src/pages/generateProjects.h b/src/pages/generateProjects.h new file mode 100644 index 0000000..ada179b --- /dev/null +++ b/src/pages/generateProjects.h @@ -0,0 +1,86 @@ +#pragma once + + +#include "basePGPage.h" + +#include "ofMain.h" +#include "CBLinuxProject.h" +#include "CBWinProject.h" +#include "visualStudioProject.h" +#include "xcodeProject.h" +#include + +#include "ofxGui.h" +#include "ofAddon.h" +#include "ofxXmlSettings.h" +#include "textButton.h" + + + +class generateProjects : public basePGPage { + + public: + + void setup(); + void update(); + void draw(); + + void keyPressed (int key); + void keyReleased(int key); + void mouseMoved(int x, int y ); + void mouseDragged(int x, int y, int button); + void mousePressed(int x, int y, int button); + void mouseReleased(int x, int y, int button); + void windowResized(int w, int h); + void dragEvent(ofDragInfo dragInfo); + void gotMessage(ofMessage msg); + + + string sketchName; + string sketchPath; + string addons; + string platform; + + ofxPanel panelCoreAddons; + ofxPanel panelOtherAddons; + bool bHaveNonCoreAddons; + + ofxPanel panelPlatforms; + + ofxToggle osxToggle, iosToggle, wincbToggle, winvsToggle, linuxcbToggle, linux64cbToggle; + + int mode; + enum { MODE_NORMAL, MODE_ADDON, MODE_PLATFORM }; + + baseProject * project; + + string setupForTarget(int targ); + + void generateProject(); + + string addonsPath; + string status; + string defaultLoc; + + float uiLeftX; + + + textButton button; + textButton generateButton; + textButton addonButton; + textButton platformButton; + + vector < textButton > buttons; + + bool isAddonCore(string addon); + bool bInited; + vector < string > coreAddons; + + + float statusSetTime; + float statusEnergy; + void setStatus(string newStatus); + + ofImage logo; + +}; diff --git a/src/pages/makeProjectsPGPage.cpp b/src/pages/makeProjectsPGPage.cpp index 57b9754..16cc377 100644 --- a/src/pages/makeProjectsPGPage.cpp +++ b/src/pages/makeProjectsPGPage.cpp @@ -4,6 +4,59 @@ //-------------------------------------------------------------- void makeProjectsPGPage::setup(){ + + + // Sketch button + // + + textButton 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(""); + + button.secondaryText = "<< CLICK TO CHANGE THE NAME"; + buttons.push_back(button); + + // Path button + // + button.deliminater = "/"; + button.prefix = "Path: "; + button.setText(""); + 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(""); + + 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(""); + + button.topLeftAnchor.set(button.topLeftAnchor.x, button.topLeftAnchor.y + button.rect.height + 20); + buttons.push_back(button); + + + + //ofSetLogLevel(OF_LOG_VERBOSE); project = NULL; @@ -13,8 +66,7 @@ void makeProjectsPGPage::setup(){ setOFRoot(getOFRootFromConfig()); - setupDrawableOFPath(); - + int targ = ofGetTargetPlatform(); //plat = OF_TARGET_IPHONE; @@ -41,28 +93,10 @@ void makeProjectsPGPage::setup(){ } #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,&makeProjectsPGPage::createProjectPressed); - updateProject.addListener(this,&makeProjectsPGPage::updateProjectPressed); - createAndOpen.addListener(this,&makeProjectsPGPage::createAndOpenPressed); - changeOFRoot.addListener(this,&makeProjectsPGPage::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)); @@ -210,134 +244,17 @@ void makeProjectsPGPage::generateExamples(){ ofLogNotice() << "Finished generating examples for " << target; } -ofFileDialogResult makeProjectsPGPage::makeNewProjectViaDialog(){ - -#ifndef COMMAND_LINE_ONLY - ofFileDialogResult res = ofSystemSaveDialog("newProjectName", "choose a folder for a new OF project :)"); - if (res.fileName == "" || res.filePath == "") return res; - //base.pushDirectory(res.fileName); // somehow an extra things here helps? - - vector targetsToMake; - if( osxToggle ) targetsToMake.push_back(OF_TARGET_OSX); - if( iosToggle ) targetsToMake.push_back(OF_TARGET_IPHONE); - if( wincbToggle ) targetsToMake.push_back(OF_TARGET_WINGCC); - if( winvsToggle ) targetsToMake.push_back(OF_TARGET_WINVS); - if( linuxcbToggle ) targetsToMake.push_back(OF_TARGET_LINUX); - if( linux64cbToggle ) targetsToMake.push_back(OF_TARGET_LINUX64); - if( linuxarmv6lcbToggle ) targetsToMake.push_back(OF_TARGET_LINUXARMV6L); - if( linuxarmv7lcbToggle ) targetsToMake.push_back(OF_TARGET_LINUXARMV7L); - - if( targetsToMake.size() == 0 ){ - cout << "Error: makeNewProjectViaDialog - must specifiy a project to generate " <setup(target); - if(project->create(res.filePath)){ - vector addonsToggles = panelAddons.getControlNames(); - for (int i = 0; i < (int) addonsToggles.size(); i++){ - ofxToggle toggle = panelAddons.getToggle(addonsToggles[i]); - if(toggle){ - ofAddon addon; - addon.pathToOF = getOFRelPath(res.filePath); - addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addonsToggles[i]),target); - printf("adding %s addons \n", addonsToggles[i].c_str()); - project->addAddon(addon); - - } - } - project->save(true); - } - } - return res; -#endif - -} - -ofFileDialogResult makeProjectsPGPage::updateProjectViaDialog(){ - -#ifndef COMMAND_LINE_ONLY - ofFileDialogResult res = ofSystemLoadDialog("choose a folder to update an OF project :)",true); - if (res.fileName == "" || res.filePath == "") return res; - //base.pushDirectory(res.fileName); // somehow an extra things here helps? - - vector targetsToMake; - if( osxToggle ) targetsToMake.push_back(OF_TARGET_OSX); - if( iosToggle ) targetsToMake.push_back(OF_TARGET_IPHONE); - if( wincbToggle ) targetsToMake.push_back(OF_TARGET_WINGCC); - if( winvsToggle ) targetsToMake.push_back(OF_TARGET_WINVS); - if( linuxcbToggle ) targetsToMake.push_back(OF_TARGET_LINUX); - if( linux64cbToggle ) targetsToMake.push_back(OF_TARGET_LINUX64); - if( linuxarmv6lcbToggle ) targetsToMake.push_back(OF_TARGET_LINUXARMV6L); - if( linuxarmv7lcbToggle ) targetsToMake.push_back(OF_TARGET_LINUXARMV7L); - - if( targetsToMake.size() == 0 ){ - cout << "Error: updateProjectViaDialog - must specifiy a project to generate " <setup(target); - project->create(res.filePath); - vector addonsToggles = panelAddons.getControlNames(); - for (int i = 0; i < (int)addonsToggles.size(); i++){ - ofxToggle toggle = panelAddons.getToggle(addonsToggles[i]); - // TODO: make this remove existing addons that are unchecked???? - // probably requires a more complex logic chain: loadProject - // (ticks the addons) and then you can untick etc??? - if(toggle){ - ofAddon addon; - addon.pathToOF = getOFRelPath(res.filePath); - addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addonsToggles[i]),target); - printf("adding %s addons \n", addonsToggles[i].c_str()); - project->addAddon(addon); - - } - } - project->save(true); - } - - return res; -#endif - -} - -void makeProjectsPGPage::createProjectPressed(){ - makeNewProjectViaDialog(); -} - -void makeProjectsPGPage::updateProjectPressed(){ - updateProjectViaDialog(); -} - -void makeProjectsPGPage::createAndOpenPressed(){ - ofFileDialogResult res = makeNewProjectViaDialog(); - if(res.bSuccess){ - #ifdef TARGET_LINUX - system(("/usr/bin/codeblocks " + ofFilePath::join(res.filePath, res.fileName+".workspace ") + "&").c_str()); - #elif defined(TARGET_OSX) - system(("open " + ofFilePath::join(res.filePath, res.fileName+".xcodeproj ") + "&").c_str()); - #elif defined(TARGET_WIN32) - system(("open " + ofFilePath::join(res.filePath, res.fileName+".workspace ") + "&").c_str()); - #endif - } -} - -void makeProjectsPGPage::changeOFRootPressed(){ - askOFRoot(); - cout << getOFRootFromConfig()< subdirs = ofSplitString("OF path: " + getOFRoot(), "/"); - int textLength = 0; - int padding = 5; - string path = ""; - int lines=1; - int fontSize = 8; - float leading = 1.7; - - ofPathRect.x = padding; - ofPathRect.y = padding; - ofPathDrawPoint.x = padding*2; - ofPathDrawPoint.y = padding*2 + fontSize * leading; - - for(int i = 0; i < subdirs.size(); i++) { - if (i > 0 && i 1){ - ofPathRect.width = ofGetWidth() - padding*2; - } - ofPathRect.height = lines * fontSize * leading + (padding*2); - - drawableOfPath = path; - - panelAddons.setPosition(panelAddons.getPosition().x, ofPathRect.y + ofPathRect.height + padding); - examplesPanel.setPosition(examplesPanel.getPosition().x, ofPathRect.y + ofPathRect.height + padding); -#endif - - -} +// +////-------------------------------------------------------------- +//void makeProjectsPGPage::setupDrawableOFPath(){ +// +//#ifndef COMMAND_LINE_ONLY +// vector subdirs = ofSplitString("OF path: " + getOFRoot(), "/"); +// int textLength = 0; +// int padding = 5; +// string path = ""; +// int lines=1; +// int fontSize = 8; +// float leading = 1.7; +// +// ofPathRect.x = padding; +// ofPathRect.y = padding; +// ofPathDrawPoint.x = padding*2; +// ofPathDrawPoint.y = padding*2 + fontSize * leading; +// +// for(int i = 0; i < subdirs.size(); i++) { +// if (i > 0 && i 1){ +// ofPathRect.width = ofGetWidth() - padding*2; +// } +// ofPathRect.height = lines * fontSize * leading + (padding*2); +// +// drawableOfPath = path; +// +// examplesPanel.setPosition(examplesPanel.getPosition().x, ofPathRect.y + ofPathRect.height + padding); +//#endif +// +// +//} diff --git a/src/pages/makeProjectsPGPage.h b/src/pages/makeProjectsPGPage.h index ca228c3..ef2a4a8 100644 --- a/src/pages/makeProjectsPGPage.h +++ b/src/pages/makeProjectsPGPage.h @@ -15,6 +15,8 @@ #include "ofxGui.h" #endif +#include "textButton.h" + class makeProjectsPGPage : public basePGPage { public: @@ -35,16 +37,13 @@ class makeProjectsPGPage : public basePGPage { void setupForTarget(int targ); void generateExamplesCB(); void generateExamples(); - - ofFileDialogResult makeNewProjectViaDialog(); - ofFileDialogResult updateProjectViaDialog(); - - void createProjectPressed(); - void updateProjectPressed(); - void createAndOpenPressed(); - void changeOFRootPressed(); - - void setupDrawableOFPath(); + + + + // new: + vector < textButton > buttons; + + baseProject * project; @@ -58,7 +57,7 @@ class makeProjectsPGPage : public basePGPage { ofRectangle ofPathRect; ofPoint ofPathDrawPoint; - ofxPanel panelAddons, panelOptions; + ofxPanel panelOptions; ofxButton createProject, updateProject, createAndOpen, changeOFRoot; ofxPanel examplesPanel; diff --git a/src/pages/simplePGPage.cpp b/src/pages/simplePGPage.cpp index e9fb8b3..82c2d9f 100644 --- a/src/pages/simplePGPage.cpp +++ b/src/pages/simplePGPage.cpp @@ -105,14 +105,8 @@ void simplePGPage::setup(){ 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) //------------------------------------- @@ -137,37 +131,20 @@ void simplePGPage::setup(){ // 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"; + button.setup(font, secondFont, "Name: ", sketchName, "<< CLICK TO CHANGE THE NAME", ofPoint(76, 160+40)); 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); + button.setup(font, secondFont, "Path: ", sketchPath, "<< CLICK TO CHANGE THE DIRECTORY", ofPoint(76, button.topLeftAnchor.y + button.rect.height + 20), "/"); buttons.push_back(button); // Platform text @@ -177,7 +154,7 @@ void simplePGPage::setup(){ button.secondaryText = ""; button.bDrawLong = false; button.secondaryText = ""; - button.bSelectable = false; + button.bSelectable = settings.multiplatform == true; button.setText(platform); button.topLeftAnchor.set(button.topLeftAnchor.x, button.topLeftAnchor.y + button.rect.height + 20); @@ -211,6 +188,12 @@ void simplePGPage::setup(){ addonButton.prefix = "<< BACK"; addonButton.setText(""); addonButton.bDrawLong = false; + + platformButton = button; + platformButton.topLeftAnchor.set(906, 535); + platformButton.prefix = "<< BACK"; + platformButton.setText(""); + platformButton.bDrawLong = false; for (int i = 0; i < buttons.size(); i++){ @@ -218,6 +201,7 @@ void simplePGPage::setup(){ } addonButton.calculateRect(); generateButton.calculateRect(); + platformButton.calculateRect(); //------------------------------------- // addons panels: @@ -318,6 +302,7 @@ void simplePGPage::update(){ //------------------------------------- if (mode == MODE_ADDON ) addonButton.checkMousePressed(ofPoint(ofGetMouseX(), ofGetMouseY())); + if (mode == MODE_PLATFORM) platformButton.checkMousePressed(ofPoint(ofGetMouseX(), ofGetMouseY())); //------------------------------------- @@ -367,8 +352,8 @@ void simplePGPage::draw(){ logo.draw(64, 61,logo.getWidth(),logo.getHeight()); //ofSetColor(74,255,203); - titleFont.drawString("PROJECT", 64 + logo.getWidth() + 25, 85); - titleFont.drawString("GENERATOR", 64 + logo.getWidth() + 25, 117); + titleFont->drawString("PROJECT", 64 + logo.getWidth() + 25, 85); + titleFont->drawString("GENERATOR", 64 + logo.getWidth() + 25, 117); } if (mode == 0){ @@ -391,16 +376,23 @@ void simplePGPage::draw(){ - if (mode == 1 ){ + if (mode == MODE_ADDON ){ addonButton.draw(); - ofRectangle rect = secondFont.getStringBoundingBox("select core and non-core addons to add", addonButton.topLeftAnchor.x-200, 60); + ofRectangle rect = secondFont->getStringBoundingBox("select core and non-core addons to add", addonButton.topLeftAnchor.x-200, 60); ofSetColor(220,220,220); ofRect(rect.x-10, rect.y-10, rect.width+20, rect.height+20); ofSetColor(0,0,0); - secondFont.drawString("select core and non-core addons to add", addonButton.topLeftAnchor.x-200, 60); + secondFont->drawString("select core and non-core addons to add", addonButton.topLeftAnchor.x-200, 60); } + + if (mode == MODE_PLATFORM){ + panelPlatforms.draw(); + platformButton.draw(); + } + + if (mode == 0){ ofFill(); ofSetColor(0 + 220 * (1-statusEnergy),0 + 220 * (1-statusEnergy),0 + 220 * (1-statusEnergy)); @@ -581,7 +573,7 @@ void simplePGPage::mousePressed(int x, int y, int button){ if (buttons[2].bMouseOver == true){ // platform is diabled for now - mode = 2; + mode = MODE_PLATFORM; } //------------------------------------- @@ -634,7 +626,28 @@ void simplePGPage::mousePressed(int x, int y, int button){ } if (mode == MODE_PLATFORM){ - + + if (platformButton.bMouseOver){ + + 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); + + setStatus("platforms set to: " + platforms); + + platformButton.bMouseOver = false; + mode = MODE_NORMAL; + + } } } @@ -653,6 +666,10 @@ void simplePGPage::windowResized(int w, int h){ ofGetHeight() - addonButton.rect.height - 40);// 535); addonButton.calculateRect(); + platformButton.topLeftAnchor.set(ofGetWidth() - buttons[0].rect.x - addonButton.rect.width + 10 , + ofGetHeight() - addonButton.rect.height - 40);// 535); + platformButton.calculateRect(); + } //-------------------------------------------------------------- diff --git a/src/pages/simplePGPage.h b/src/pages/simplePGPage.h index 94213fd..94eb058 100644 --- a/src/pages/simplePGPage.h +++ b/src/pages/simplePGPage.h @@ -49,10 +49,7 @@ class simplePGPage : public basePGPage { ofxToggle osxToggle, iosToggle, wincbToggle, winvsToggle, linuxcbToggle, linux64cbToggle; - ofTrueTypeFont font; - ofTrueTypeFont titleFont; - ofTrueTypeFont secondFont; - + int mode; enum { MODE_NORMAL, MODE_ADDON, MODE_PLATFORM }; @@ -65,7 +62,6 @@ class simplePGPage : public basePGPage { string addonsPath; string status; - ofxXmlSettings XML; string appToRoot; string defaultLoc; @@ -75,6 +71,10 @@ class simplePGPage : public basePGPage { textButton button; textButton generateButton; textButton addonButton; + textButton platformButton; + + + vector < textButton > buttons; bool isAddonCore(string addon); diff --git a/src/testApp.cpp b/src/testApp.cpp index e1569e7..92ca540 100644 --- a/src/testApp.cpp +++ b/src/testApp.cpp @@ -12,8 +12,50 @@ void testApp::setup(){ mode = MODE_SIMPLE; + + //------------------------------------- + // load fonts + + 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); + + + + //------------------------------------- + // load settings + + XML.loadFile("settings/projectGeneratorSettings.xml"); + string appToRoot = XML.getValue("settings:base:appToRoot", "../../../../"); + string defaultLoc = XML.getValue("settings:simplePage:defaultNewProjectLocation", "apps/myApps"); + bool bMultiPlaform = XML.getValue("settings:base:multiplatform", 0) == 0 ? false : true; + basePGPage::pgSettings settings; + settings.appRoot = appToRoot; + settings.defaultNewProjectLocation = defaultLoc; + settings.multiplatform = bMultiPlaform; + + cout << settings.appRoot << endl; + + simple.settings = settings; + makeProjects.settings = settings; + + + + simple.font = &font; + simple.titleFont = &titleFont; + simple.secondFont = &secondFont; + + makeProjects.font = &font; + makeProjects.titleFont = &titleFont; + makeProjects.secondFont = &secondFont; + + //------------------------------------- + simple.setup(); makeProjects.setup(); + + + } //-------------------------------------------------------------- diff --git a/src/testApp.h b/src/testApp.h index dadcd1d..be2d80b 100644 --- a/src/testApp.h +++ b/src/testApp.h @@ -5,7 +5,7 @@ #include "ofMain.h" #include "simplePGPage.h" #include "makeProjectsPGPage.h" - +#include "generateProjects.h" class testApp : public ofBaseApp{ @@ -26,7 +26,13 @@ class testApp : public ofBaseApp{ void gotMessage(ofMessage msg); simplePGPage simple; - makeProjectsPGPage makeProjects; + generateProjects makeProjects; + ofxXmlSettings XML; + + + ofTrueTypeFont font; + ofTrueTypeFont titleFont; + ofTrueTypeFont secondFont; enum { From e3759307cc88cff3f85be8e8e60d9bac863e906d Mon Sep 17 00:00:00 2001 From: zach lieberman Date: Tue, 27 Aug 2013 03:32:05 -0400 Subject: [PATCH 5/5] more mods to a unified pg --- src/pages/generateProjects.cpp | 198 +++++++++++++++++++++++---------- src/pages/generateProjects.h | 3 + src/pages/simplePGPage.cpp | 8 +- 3 files changed, 145 insertions(+), 64 deletions(-) diff --git a/src/pages/generateProjects.cpp b/src/pages/generateProjects.cpp index f732029..48d228a 100644 --- a/src/pages/generateProjects.cpp +++ b/src/pages/generateProjects.cpp @@ -88,7 +88,7 @@ void generateProjects::setup(){ #endif string ofRoot = ofFilePath::getAbsolutePath(ofFilePath::join(binPath, settings.appRoot)); - string examplesPath = ofFilePath::join(ofRoot, "examples"); + examplesPath = ofFilePath::join(ofRoot, "examples"); addonsPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot,"addons")); sketchPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot, defaultLoc)); @@ -341,77 +341,144 @@ void generateProjects::keyPressed(int key){ if (key == ' '){ - //printf("%s -------- \n", ResultBuffer); - //std::exit(0); } } -void generateProjects::generateProject(){ - - vector targetsToMake; - if( osxToggle ) targetsToMake.push_back(OF_TARGET_OSX); - if( iosToggle ) targetsToMake.push_back(OF_TARGET_IPHONE); - if( wincbToggle ) targetsToMake.push_back(OF_TARGET_WINGCC); - if( winvsToggle ) targetsToMake.push_back(OF_TARGET_WINVS); - if( linuxcbToggle ) targetsToMake.push_back(OF_TARGET_LINUX); - if( linux64cbToggle ) targetsToMake.push_back(OF_TARGET_LINUX64); - - if( targetsToMake.size() == 0 ){ - cout << "Error: makeNewProjectViaDialog - must specifiy a project to generate " <create(path)){ - vector addonsToggles = panelCoreAddons.getControlNames(); - for (int i = 0; i < (int) addonsToggles.size(); i++){ - ofxToggle toggle = panelCoreAddons.getToggle(addonsToggles[i]); - if(toggle){ - ofAddon addon; - addon.pathToOF = getOFRelPath(path); - addon.fromFS(ofFilePath::join(addonsPath, addonsToggles[i]),target); - project->addAddon(addon); - - } +void generateProjects::generateExamples(){ + + + + ofDirectory dir; + //string examplesPath = ofFilePath::join(getOFRoot(),"examples"); + ofLogNotice() << "Generating examples (from: " << examplesPath << ")"; + dir.listDir(examplesPath); + + + // vector targetsToMake; + // if( osxToggle ) targetsToMake.push_back(OF_TARGET_OSX); + // if( iosToggle ) targetsToMake.push_back(OF_TARGET_IPHONE); + // if( wincbToggle ) targetsToMake.push_back(OF_TARGET_WINGCC); + // if( winvsToggle ) targetsToMake.push_back(OF_TARGET_WINVS); + // if( linuxcbToggle ) targetsToMake.push_back(OF_TARGET_LINUX); + // if( linux64cbToggle ) targetsToMake.push_back(OF_TARGET_LINUX64); + + + string target = setupForTarget(OF_TARGET_OSX); + + for (int i = 0; i < (int)dir.size(); i++){ + + // don't check subdirectories that aren't directories! (eg., .gitignore etc) + if(!dir.getFile(i).isDirectory()) continue; + + if( target == "ios" ){ + if( dir.getName(i) != "ios" ) continue; + }else{ + if (dir.getName(i) == "android" || dir.getName(i) == "ios") continue; + } + + ofDirectory subdir; + string examplesPath = dir.getPath(i); + + ofLogNotice() << "Generating examples in folder: " << examplesPath; + + subdir.listDir(examplesPath); + + for (int j = 0; j < (int)subdir.size(); j++){ + + // don't create projects that aren't directories! (eg., .gitkeep etc) + if(!subdir.getFile(j).isDirectory()) continue; + + ofLogNotice() << "------------------------------------------------"; + ofLogNotice() << "Generating example: " << subdir.getPath(j); + ofLogNotice() << "------------------------------------------------"; + + project->setup(target); + project->create(subdir.getPath(j)); + vector < string > addons; + parseAddonsDotMake(project->getPath() + "addons.make", addons); + for (int i = 0; i < (int)addons.size(); i++){ + ofAddon addon; + addon.pathToOF = getOFRelPath(subdir.getPath(j)); + addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addons[i]),target); + project->addAddon(addon); } + project->save(false); + + } + } + ofLogNotice() << " "; + ofLogNotice() << "Finished generating examples for " << target; +} - addonsToggles = panelOtherAddons.getControlNames(); - for (int i = 0; i < (int) addonsToggles.size(); i++){ - ofxToggle toggle = panelOtherAddons.getToggle(addonsToggles[i]); - if(toggle){ - ofAddon addon; - - addon.pathToOF = getOFRelPath(path); - cout << getOFRelPath(path) << " " << path << endl; - addon.fromFS(ofFilePath::join(addonsPath, addonsToggles[i]),target); - project->addAddon(addon); - - } - } - - project->save(true); - } - } +void generateProjects::generateProject(){ - printf("done with project generation \n"); - setStatus("generated: " + buttons[1].myText + "/" + buttons[0].myText); +// vector targetsToMake; +// if( osxToggle ) targetsToMake.push_back(OF_TARGET_OSX); +// if( iosToggle ) targetsToMake.push_back(OF_TARGET_IPHONE); +// if( wincbToggle ) targetsToMake.push_back(OF_TARGET_WINGCC); +// if( winvsToggle ) targetsToMake.push_back(OF_TARGET_WINVS); +// if( linuxcbToggle ) targetsToMake.push_back(OF_TARGET_LINUX); +// if( linux64cbToggle ) targetsToMake.push_back(OF_TARGET_LINUX64); +// +// if( targetsToMake.size() == 0 ){ +// cout << "Error: makeNewProjectViaDialog - must specifiy a project to generate " <create(path)){ +// vector addonsToggles = panelCoreAddons.getControlNames(); +// for (int i = 0; i < (int) addonsToggles.size(); i++){ +// ofxToggle toggle = panelCoreAddons.getToggle(addonsToggles[i]); +// if(toggle){ +// ofAddon addon; +// addon.pathToOF = getOFRelPath(path); +// addon.fromFS(ofFilePath::join(addonsPath, addonsToggles[i]),target); +// project->addAddon(addon); +// +// } +// } +// +// +// addonsToggles = panelOtherAddons.getControlNames(); +// for (int i = 0; i < (int) addonsToggles.size(); i++){ +// ofxToggle toggle = panelOtherAddons.getToggle(addonsToggles[i]); +// if(toggle){ +// ofAddon addon; +// +// addon.pathToOF = getOFRelPath(path); +// cout << getOFRelPath(path) << " " << path << endl; +// addon.fromFS(ofFilePath::join(addonsPath, addonsToggles[i]),target); +// project->addAddon(addon); +// +// } +// } +// +// project->save(true); +// } +// } +// +// +// printf("done with project generation \n"); +// setStatus("generated: " + buttons[1].myText + "/" + buttons[0].myText); // go through the control panels, do stuff } @@ -446,6 +513,14 @@ void generateProjects::mousePressed(int x, int y, int button){ } + //------------------------------------- + // 4 = genearate + //------------------------------------- + + + if (generateButton.bMouseOver == true){ + generateExamples(); + } @@ -500,6 +575,7 @@ void generateProjects::mousePressed(int x, int y, int button){ string result = res.filePath; convertWindowsToUnixPath(result); buttons[1].setText( result ); + examplesPath = result; setStatus("path set to: " + result); } } diff --git a/src/pages/generateProjects.h b/src/pages/generateProjects.h index ada179b..184b180 100644 --- a/src/pages/generateProjects.h +++ b/src/pages/generateProjects.h @@ -40,6 +40,7 @@ class generateProjects : public basePGPage { string sketchPath; string addons; string platform; + string examplesPath; ofxPanel panelCoreAddons; ofxPanel panelOtherAddons; @@ -57,6 +58,8 @@ class generateProjects : public basePGPage { string setupForTarget(int targ); void generateProject(); + void generateExamples(); + string addonsPath; string status; diff --git a/src/pages/simplePGPage.cpp b/src/pages/simplePGPage.cpp index 82c2d9f..5fe173f 100644 --- a/src/pages/simplePGPage.cpp +++ b/src/pages/simplePGPage.cpp @@ -118,12 +118,14 @@ void simplePGPage::setup(){ string binPath = ofFilePath::getCurrentExeDir(); #endif - string ofRoot = ofFilePath::getAbsolutePath(ofFilePath::join(binPath, appToRoot)); + string ofRoot = ofFilePath::getAbsolutePath(ofFilePath::join(binPath, settings.appRoot)); addonsPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot,"addons")); - sketchPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot, defaultLoc)); - + sketchPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot, settings.defaultNewProjectLocation)); + + + convertWindowsToUnixPath(ofRoot); convertWindowsToUnixPath(addonsPath); convertWindowsToUnixPath(sketchPath);