├── addons.make ├── OFPlay.ai ├── OFPlay.icns ├── ofplay_main.png ├── froebelGuiRef.png ├── ofplay_intro.png ├── bin └── data │ ├── OFPlay.icns │ ├── OFPlay.png │ ├── Inconsolata.otf │ ├── intro-ofbb.png │ ├── intro-ofide.png │ ├── intro-ofplay.png │ ├── intro-offolder.png │ ├── config.xml │ ├── ofplay.xml │ └── intro.xml ├── src ├── main.cpp ├── projectGenerator │ ├── src │ │ ├── projectGenerator.h │ │ ├── CBLinuxProject.h │ │ ├── CBWinProject.h │ │ ├── visualStudioProject.h │ │ ├── ofAddon.h │ │ ├── xcodeProject.h │ │ ├── baseProject.h │ │ ├── Utils.h │ │ ├── CBLinuxProject.cpp │ │ ├── CBWinProject.cpp │ │ ├── baseProject.cpp │ │ ├── ofAddon.cpp │ │ ├── visualStudioProject.cpp │ │ └── Utils.cpp │ └── libs │ │ └── pugixml │ │ ├── contrib │ │ └── foreach.hpp │ │ ├── readme.txt │ │ └── src │ │ └── pugiconfig.hpp ├── froebelGui │ ├── froebelGui.h │ ├── froebelShape.h │ ├── froebelShapeButton.h │ ├── froebelFolderElement.h │ ├── froebelListBox.h │ ├── froebelColor.h │ ├── froebelEditBox.h │ ├── froebelTab.h │ ├── froebelContainer.h │ ├── froebelShapeButton.cpp │ ├── froebelTextBox.h │ ├── froebelColor.cpp │ ├── froebelShape.cpp │ ├── froebelTab.cpp │ ├── froebelListBox.cpp │ ├── froebelContainer.cpp │ ├── froebelFolderElement.cpp │ ├── froebelEditBox.cpp │ └── froebelTextBox.cpp ├── ofApp.h ├── intro │ ├── SlideSequencer.h │ ├── TextBlock.h │ ├── SlideSequencer.cpp │ └── TextBlock.cpp ├── mainScreenOFPlay.h ├── ofApp.cpp └── mainScreenOFPlay.cpp ├── Makefile ├── OFPlay.workspace ├── Project.xcconfig ├── openFrameworks-Info.plist ├── .gitignore ├── README.md ├── OFPlay.xcodeproj └── xcshareddata │ └── xcschemes │ ├── OFPlay Debug.xcscheme │ └── OFPlay Release.xcscheme ├── config.make └── OFPlay.cbp /addons.make: -------------------------------------------------------------------------------- 1 | ofxXmlSettings 2 | -------------------------------------------------------------------------------- /OFPlay.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patriciogonzalezvivo/OFPlay/HEAD/OFPlay.ai -------------------------------------------------------------------------------- /OFPlay.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patriciogonzalezvivo/OFPlay/HEAD/OFPlay.icns -------------------------------------------------------------------------------- /ofplay_main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patriciogonzalezvivo/OFPlay/HEAD/ofplay_main.png -------------------------------------------------------------------------------- /froebelGuiRef.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patriciogonzalezvivo/OFPlay/HEAD/froebelGuiRef.png -------------------------------------------------------------------------------- /ofplay_intro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patriciogonzalezvivo/OFPlay/HEAD/ofplay_intro.png -------------------------------------------------------------------------------- /bin/data/OFPlay.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patriciogonzalezvivo/OFPlay/HEAD/bin/data/OFPlay.icns -------------------------------------------------------------------------------- /bin/data/OFPlay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patriciogonzalezvivo/OFPlay/HEAD/bin/data/OFPlay.png -------------------------------------------------------------------------------- /bin/data/Inconsolata.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patriciogonzalezvivo/OFPlay/HEAD/bin/data/Inconsolata.otf -------------------------------------------------------------------------------- /bin/data/intro-ofbb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patriciogonzalezvivo/OFPlay/HEAD/bin/data/intro-ofbb.png -------------------------------------------------------------------------------- /bin/data/intro-ofide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patriciogonzalezvivo/OFPlay/HEAD/bin/data/intro-ofide.png -------------------------------------------------------------------------------- /bin/data/intro-ofplay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patriciogonzalezvivo/OFPlay/HEAD/bin/data/intro-ofplay.png -------------------------------------------------------------------------------- /bin/data/intro-offolder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patriciogonzalezvivo/OFPlay/HEAD/bin/data/intro-offolder.png -------------------------------------------------------------------------------- /bin/data/config.xml: -------------------------------------------------------------------------------- 1 | ../../../../ 2 | /Users/Patricio/Desktop/openFrameworks/ 3 | apps/myApps 4 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ofMain.h" 2 | #include "ofApp.h" 3 | #include "ofAppGlutWindow.h" 4 | 5 | //======================================================================== 6 | int main( int argc, char *argv[] ){ 7 | ofAppGlutWindow window; 8 | window.setGlutDisplayString("rgba double samples>=4"); 9 | ofSetupOpenGL(&window, 1024, 768, OF_WINDOW); 10 | testApp * app = new testApp; 11 | ofRunApp( app ); 12 | } 13 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Attempt to load a config.make file. 2 | # If none is found, project defaults in config.project.make will be used. 3 | ifneq ($(wildcard config.make),) 4 | include config.make 5 | endif 6 | 7 | # make sure the the OF_ROOT location is defined 8 | ifndef OF_ROOT 9 | OF_ROOT=../../.. 10 | endif 11 | 12 | # call the project makefile! 13 | include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk 14 | -------------------------------------------------------------------------------- /OFPlay.workspace: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/projectGenerator/src/projectGenerator.h: -------------------------------------------------------------------------------- 1 | // 2 | // projectGenerator.h 3 | // OFPlay 4 | // 5 | // Created by Patricio Gonzalez Vivo on 12/4/12. 6 | // 7 | // 8 | 9 | #ifndef OFPlay_projectGenerator_h 10 | #define OFPlay_projectGenerator_h 11 | 12 | #include "ofAddon.h" 13 | #include "CBLinuxProject.h" 14 | #include "CBWinProject.h" 15 | #include "visualStudioProject.h" 16 | #include "xcodeProject.h" 17 | #include 18 | 19 | #include "Utils.h" 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /src/froebelGui/froebelGui.h: -------------------------------------------------------------------------------- 1 | // 2 | // froebelGui.h 3 | // OFPlay 4 | // 5 | // Created by Patricio Gonzalez Vivo on 12/3/12. 6 | // http://www.patriciogonzalezvivo.com 7 | // 8 | 9 | #ifndef FROEBELGUI 10 | #define FROEBELGUI 11 | 12 | // Basic Elements 13 | // 14 | #include "froebelColor.h" 15 | #include "froebelShape.h" 16 | 17 | // GUI elements 18 | // 19 | #include "froebelShapeButton.h" 20 | 21 | #include "froebelTextBox.h" 22 | #include "froebelEditBox.h" 23 | 24 | #include "froebelContainer.h" 25 | 26 | #include "froebelListBox.h" 27 | #include "froebelFolderElement.h" 28 | 29 | #include "froebelTab.h" 30 | #endif 31 | -------------------------------------------------------------------------------- /src/froebelGui/froebelShape.h: -------------------------------------------------------------------------------- 1 | // 2 | // froebelShape.h 3 | // OFPlay 4 | // 5 | // Created by Patricio Gonzalez Vivo on 12/2/12. 6 | // http://www.patriciogonzalezvivo.com 7 | // 8 | 9 | #ifndef FROEBELSHAPE 10 | #define FROEBELSHAPE 11 | 12 | #include "ofMain.h" 13 | 14 | #include "froebelColor.h" 15 | 16 | class froebelShape : public ofPoint { 17 | public: 18 | 19 | froebelShape(); 20 | 21 | void setShape(int _shapeNum, float _size); 22 | 23 | virtual void draw(); 24 | 25 | froebelColor color; 26 | 27 | float size; 28 | 29 | ofPolyline shape; 30 | protected: 31 | int type; 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /Project.xcconfig: -------------------------------------------------------------------------------- 1 | //THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. 2 | //THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED 3 | OF_PATH = ../../.. 4 | 5 | //THIS HAS ALL THE HEADER AND LIBS FOR OF CORE 6 | #include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" 7 | 8 | //ICONS - NEW IN 0072 9 | ICON_NAME_DEBUG = icon-debug.icns 10 | ICON_NAME_RELEASE = icon.icns 11 | ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/ 12 | 13 | //IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to: 14 | //ICON_FILE_PATH = bin/data/ 15 | 16 | OTHER_LDFLAGS = $(OF_CORE_LIBS) 17 | HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) 18 | -------------------------------------------------------------------------------- /src/projectGenerator/src/CBLinuxProject.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CBLinuxProject.h 3 | * 4 | * Created on: 28/12/2011 5 | * Author: arturo 6 | */ 7 | 8 | #ifndef CBLINUXPROJECT_H_ 9 | #define CBLINUXPROJECT_H_ 10 | 11 | #include "ofConstants.h" 12 | #include "pugixml.hpp" 13 | #include "ofAddon.h" 14 | #include "CBWinProject.h" 15 | 16 | class CBLinuxProject: public CBWinProject { 17 | public: 18 | 19 | enum Arch{ 20 | Linux, 21 | Linux64 22 | }; 23 | 24 | void setup(); 25 | 26 | bool createProjectFile(); 27 | void addInclude(string includeName){}; 28 | void addLibrary(string libraryName, LibType libType = RELEASE_LIB){}; 29 | 30 | static string LOG_NAME; 31 | 32 | private: 33 | 34 | Arch arch; 35 | }; 36 | 37 | #endif /* CBLINUXPROJECT_H_ */ 38 | -------------------------------------------------------------------------------- /openFrameworks-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | OFPlay 11 | CFBundleIdentifier 12 | com.yourcompany.openFrameworks 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundlePackageType 16 | APPL 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1.0 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/projectGenerator/src/CBWinProject.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CBLinuxProject.h 3 | * 4 | * Created on: 28/12/2011 5 | * Author: arturo 6 | */ 7 | 8 | #ifndef CBWINPROJECT_H_ 9 | #define CBWINPROJECT_H_ 10 | 11 | #include "ofConstants.h" 12 | #include "pugixml.hpp" 13 | #include "ofAddon.h" 14 | #include "baseProject.h" 15 | 16 | class CBWinProject: virtual public baseProject { 17 | public: 18 | 19 | void setup(); 20 | 21 | bool createProjectFile(); 22 | bool loadProjectFile(); 23 | bool saveProjectFile(); 24 | 25 | void addSrc(string srcName, string folder); 26 | void addInclude(string includeName); 27 | void addLibrary(string libraryName, LibType libType = RELEASE_LIB); 28 | 29 | string getName(); 30 | string getPath(); 31 | 32 | static string LOG_NAME; 33 | 34 | private: 35 | 36 | }; 37 | 38 | #endif /* CBLINUXPROJECT_H_ */ 39 | -------------------------------------------------------------------------------- /src/projectGenerator/src/visualStudioProject.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef VSWINPROJECT_H_ 3 | #define VSWINPROJECT_H_ 4 | 5 | #include "ofConstants.h" 6 | #include "pugixml.hpp" 7 | #include "ofAddon.h" 8 | #include "baseProject.h" 9 | 10 | class visualStudioProject : public baseProject { 11 | 12 | public: 13 | 14 | void setup(string ofRoot= "../../../"); 15 | 16 | void setup(); 17 | 18 | bool createProjectFile(); 19 | bool loadProjectFile(); 20 | bool saveProjectFile(); 21 | 22 | void addSrc(string srcFile, string folder); 23 | void addInclude(string includeName); 24 | void addLibrary(string libraryName, LibType libType); 25 | 26 | void addAddon(ofAddon & addon); 27 | 28 | static string LOG_NAME; 29 | 30 | pugi::xml_document filterXmlDoc; 31 | 32 | 33 | void appendFilter(string folderName); 34 | 35 | private: 36 | 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/froebelGui/froebelShapeButton.h: -------------------------------------------------------------------------------- 1 | // 2 | // froebelShapeButton.h 3 | // OFPlay 4 | // 5 | // Created by Patricio Gonzalez Vivo on 12/7/12. 6 | // http://www.patriciogonzalezvivo.com 7 | // 8 | 9 | #ifndef FROEBELSHAPEBUTTON 10 | #define FROEBELSHAPEBUTTON 11 | 12 | #include "ofMain.h" 13 | #include "froebelShape.h" 14 | 15 | class froebelShapeButton : public froebelShape { 16 | public: 17 | 18 | froebelShapeButton(); 19 | 20 | virtual bool checkMousePressed(ofPoint _mouse); 21 | 22 | virtual void update(); 23 | virtual void draw(); 24 | 25 | ofEvent clicked; 26 | 27 | string text; 28 | froebelColor textColor; 29 | ofTrueTypeFont *font; 30 | 31 | enum { STATE_DISABLE, STATE_ENABLE, STATE_HOVER }; 32 | int nState; 33 | bool bEnable; 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/froebelGui/froebelFolderElement.h: -------------------------------------------------------------------------------- 1 | // 2 | // froebelDirElement.h 3 | // OFPlay 4 | // 5 | // Created by Patricio Gonzalez Vivo on 12/5/12. 6 | // http://www.patriciogonzalezvivo.com 7 | // 8 | 9 | #ifndef FROEBELFOLDERELEMENT 10 | #define FROEBELFOLDERELEMENT 11 | 12 | #include "ofMain.h" 13 | #include "froebelTextBox.h" 14 | #include "froebelContainer.h" 15 | 16 | class froebelFolderElement : public froebelTextBox { 17 | public: 18 | 19 | froebelFolderElement(); 20 | 21 | void reset(); 22 | virtual string getText(); 23 | virtual ofRectangle getBoundingBox(); 24 | 25 | virtual bool checkMousePressed(ofPoint _mouse); 26 | 27 | virtual void update(); 28 | virtual void draw(); 29 | 30 | froebelContainer *father; 31 | froebelContainer containerBox; 32 | 33 | string rootPath; 34 | 35 | protected: 36 | 37 | }; 38 | #endif 39 | -------------------------------------------------------------------------------- /src/froebelGui/froebelListBox.h: -------------------------------------------------------------------------------- 1 | // 2 | // froebelListBox.h 3 | // OFPlay 4 | // 5 | // Created by Patricio Gonzalez Vivo on 12/2/12. 6 | // http://www.patriciogonzalezvivo.com 7 | // 8 | 9 | #ifndef FROEBELLISTBOX 10 | #define FROEBELLISTBOX 11 | 12 | #include "ofMain.h" 13 | #include "froebelTextBox.h" 14 | #include "froebelContainer.h" 15 | #include "froebelFolderElement.h" 16 | 17 | class froebelListBox : public froebelTextBox { 18 | public: 19 | 20 | froebelListBox(); 21 | 22 | void addElement(string _value, bool _defVal = false, int _iconShape = -1, int _edgeCoorner = -1); 23 | bool select(string _value); 24 | string getSelectedAsString(); 25 | void reset(); 26 | 27 | virtual ofRectangle getBoundingBox(); 28 | bool checkMousePressed(ofPoint _mouse); 29 | 30 | void update(); 31 | void draw(); 32 | 33 | froebelContainer containerBox; 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/froebelGui/froebelColor.h: -------------------------------------------------------------------------------- 1 | // 2 | // froebelColor.h 3 | // OFPlay 4 | // 5 | // Created by Patricio Gonzalez Vivo on 12/3/12. 6 | // http://www.patriciogonzalezvivo.com 7 | // 8 | 9 | #ifndef FROEBELCOLOR 10 | #define FROEBELCOLOR 11 | 12 | #include "ofMain.h" 13 | 14 | class froebelColor : public ofFloatColor { 15 | public: 16 | 17 | froebelColor(); 18 | 19 | void setFromPalet( unsigned int _palletN ); 20 | ofFloatColor getFromPalet( unsigned int _palletN ); 21 | 22 | void clear(); 23 | void addState( unsigned int _palletN ); 24 | void addState( ofFloatColor _color); 25 | void linktToColor( ofFloatColor *_color ); 26 | 27 | void setState( unsigned int _stateN ); 28 | 29 | void update(); 30 | 31 | float damp; 32 | private: 33 | vector states; 34 | ofFloatColor *pointerToColor; 35 | 36 | int dstStateN; 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/projectGenerator/src/ofAddon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ofAddon.h 3 | * 4 | * Created on: 28/12/2011 5 | * Author: arturo 6 | */ 7 | 8 | #ifndef OFADDON_H_ 9 | #define OFADDON_H_ 10 | 11 | #include 12 | #include "ofConstants.h" 13 | 14 | class ofAddon { 15 | 16 | public: 17 | 18 | ofAddon(); 19 | 20 | void fromFS(string path, string platform); 21 | void fromXML(string installXmlName); 22 | void clear(); 23 | 24 | // this is source files: 25 | map < string, string > filesToFolders; //the addons has had, for each file, 26 | //sometimes a listing of what folder to put it in, such as "addons/ofxOsc/src" 27 | 28 | vector < string > srcFiles; 29 | vector < string > libs; 30 | vector < string > includePaths; 31 | 32 | string name; 33 | string pathToOF; 34 | 35 | bool operator <(const ofAddon & addon) const{ 36 | return addon.name < name; 37 | } 38 | 39 | }; 40 | 41 | #endif /* OFADDON_H_ */ 42 | -------------------------------------------------------------------------------- /src/froebelGui/froebelEditBox.h: -------------------------------------------------------------------------------- 1 | // 2 | // froebelEditBox.h 3 | // OFPlay 4 | // 5 | // Created by Patricio Gonzalez Vivo on 12/2/12. 6 | // http://www.patriciogonzalezvivo.com 7 | // 8 | 9 | #ifndef FROEBELEDITBOX 10 | #define FROEBELEDITBOX 11 | 12 | #include "ofMain.h" 13 | #include "froebelTextBox.h" 14 | 15 | class froebelEditBox : public froebelTextBox { 16 | public: 17 | froebelEditBox(); 18 | 19 | void enable(); 20 | void disable(); 21 | 22 | void beginEditing(); 23 | void endEditing(); 24 | 25 | void draw(); 26 | 27 | protected: 28 | ofEvent textChanged; 29 | 30 | void keyPressed(ofKeyEventArgs &a); 31 | void mousePressed(ofMouseEventArgs& args); 32 | void mouseReleased(ofMouseEventArgs& args); 33 | 34 | int cursorPosition; 35 | int cursorx, cursory; 36 | 37 | bool bEnabled; 38 | bool bEditing; 39 | bool bDrawCursor; 40 | 41 | bool mouseDownInRect; 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/ofApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ofMain.h" 4 | 5 | #include "ofxXmlSettings.h" 6 | 7 | #include "SlideSequencer.h" 8 | #include "mainScreenOFPlay.h" 9 | 10 | class testApp : public ofBaseApp{ 11 | public: 12 | void setup(); 13 | void update(); 14 | void draw(); 15 | 16 | void keyPressed (int key); 17 | void keyReleased(int key); 18 | void mouseMoved(int x, int y ); 19 | void mouseDragged(int x, int y, int button); 20 | void mousePressed(int x, int y, int button); 21 | void mouseReleased(int x, int y, int button); 22 | void windowResized(int w, int h); 23 | void dragEvent(ofDragInfo dragInfo); 24 | void gotMessage(ofMessage msg); 25 | 26 | void searchForOF(); 27 | 28 | enum { INSTALL_OF, INSTALL_GIT, INSTALL_XCODE, OFPLAY_INTRO }; 29 | int nStep; 30 | 31 | ofImage logo; 32 | ofTrueTypeFont font; 33 | 34 | // SlideSequencer textSeq; 35 | 36 | mainScreenOFPlay *mScreen; 37 | 38 | bool bXcodeInstalled; 39 | }; 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Some general ignore patterns 2 | build/ 3 | obj/ 4 | *.o 5 | Debug*/ 6 | Release*/ 7 | *.mode* 8 | *.app/ 9 | *.pyc 10 | .svn/ 11 | 12 | 13 | #XCode 14 | *.pbxuser 15 | *.perspective 16 | *.perspectivev3 17 | *.mode1v3 18 | *.mode2v3 19 | #XCode 4 20 | xcuserdata 21 | *.xcworkspace 22 | 23 | #Code::Blocks 24 | *.depend 25 | *.layout 26 | 27 | #Visual Studio 28 | *.sdf 29 | *.opensdf 30 | *.suo 31 | ipch/ 32 | 33 | #Eclipse 34 | .metadata 35 | local.properties 36 | .externalToolBuilders 37 | 38 | 39 | # OS-specific ignore patterns 40 | 41 | #Linux 42 | *~ 43 | # KDE 44 | .directory 45 | 46 | #OSX 47 | .DS_Store 48 | *.swp 49 | *~.nib 50 | # Thumbnails 51 | ._* 52 | 53 | #Windows 54 | # Windows image file caches 55 | Thumbs.db 56 | # Folder config file 57 | Desktop.ini 58 | 59 | #Android 60 | .csettings 61 | /libs/openFrameworksCompiled/project/android/paths.make 62 | 63 | # Miscellaneous 64 | .mailmap 65 | 66 | /week1-movingRec/bin/data/park6/ 67 | /week1-movingRec/bin/data/park5/ 68 | /week1-movingRec/bin/data/park4/ 69 | /week1-movingRec/bin/data/park3/ 70 | /week1-movingRec/bin/data/park2/ 71 | /week1-movingRec/bin/data/park1/ 72 | /week1-movingRec/bin/data/Archive.zip -------------------------------------------------------------------------------- /src/froebelGui/froebelTab.h: -------------------------------------------------------------------------------- 1 | // 2 | // froebelTab.h 3 | // OFPlay 4 | // 5 | // Created by Patricio Gonzalez Vivo on 12/12/12. 6 | // 7 | // 8 | 9 | #ifndef FROEBELTAB 10 | #define FROEBELTAB 11 | 12 | #include "ofMain.h" 13 | 14 | #include "froebelColor.h" 15 | #include "froebelShapeButton.h" 16 | 17 | class froebelTab : public ofRectangle{ 18 | public: 19 | 20 | froebelTab(); 21 | 22 | void addElement(string _title); 23 | bool checkMousePressed(ofPoint _mouse); 24 | 25 | int size(){ return buttons.size(); } 26 | void setElement( unsigned int _nLine); 27 | void setPrev(); 28 | void setNext(); 29 | 30 | int getElementNumber() { return currentElement; } 31 | string getElementText() { return text; }; 32 | 33 | void update(); 34 | void draw(); 35 | 36 | ofTrueTypeFont font; 37 | froebelColor textColor; 38 | 39 | private: 40 | vector buttons; 41 | 42 | string text; 43 | float buttonSize; 44 | int desiredElement; 45 | int currentElement; 46 | int countDown; 47 | 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/projectGenerator/src/xcodeProject.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #pragma once 4 | 5 | #include "baseProject.h" 6 | 7 | 8 | 9 | class xcodeProject : public baseProject { 10 | 11 | public: 12 | 13 | xcodeProject(){}; 14 | 15 | void setup(); 16 | 17 | private: 18 | 19 | bool createProjectFile(); 20 | bool loadProjectFile(); 21 | bool saveProjectFile(); 22 | 23 | public: 24 | 25 | void addSrc(string srcFile, string folder); 26 | void addInclude(string includeName); 27 | void addLibrary(string libraryName, LibType libType = RELEASE_LIB); 28 | 29 | void addAddon(ofAddon & addon); 30 | 31 | void saveWorkspaceXML(); 32 | void saveScheme(); 33 | void renameProject(); 34 | 35 | string srcUUID; 36 | string addonUUID; 37 | string resourcesUUID; 38 | string buildPhaseUUID; 39 | 40 | pugi::xml_node findOrMakeFolderSet( pugi::xml_node nodeToAddTo, vector < string > & folders, string pathForHash); 41 | pugi::xml_node insertPoint; // where are we inserting items (at the second dict tag, 42 | // /plist[1]/dict[1]/dict[2]) 43 | bool findArrayForUUID(string UUID, pugi::xml_node & nodeMe); 44 | 45 | }; 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/froebelGui/froebelContainer.h: -------------------------------------------------------------------------------- 1 | // 2 | // froebelContainer.h 3 | // OFPlay 4 | // 5 | // Created by Patricio Gonzalez Vivo on 12/5/12. 6 | // http://www.patriciogonzalezvivo.com 7 | // 8 | 9 | #ifndef FROEBELCONTAINER 10 | #define FROEBELCONTAINER 11 | 12 | #include "ofMain.h" 13 | #include "froebelTextBox.h" 14 | 15 | class froebelContainer : public ofRectangle { 16 | public: 17 | 18 | froebelContainer(); 19 | ~froebelContainer(); 20 | 21 | void addElement( froebelTextBox *_newElement); 22 | bool select(string _value); 23 | vector getSelected(); 24 | 25 | void adjustShape(); 26 | void clear(); 27 | void reset(); 28 | 29 | virtual bool checkMousePressed(ofPoint _mouse); 30 | 31 | vector elements; 32 | 33 | void update(); 34 | void draw(); 35 | 36 | froebelColor bgColor; 37 | 38 | ofRectangle slider; 39 | froebelColor sliderColor; 40 | 41 | int size; 42 | int maxHeight; 43 | bool bEnable; 44 | bool bCheckList; 45 | 46 | private: 47 | float offsetY; 48 | float damp; 49 | float totalBoxHeight; 50 | float totalLenght; 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OFPlay 2 | 3 | This is a modify version of [Zachary Lieberman's Project Generator](https://github.com/ofZach/projectGeneratorSimple) to be very playful and intuitive for beginners. 4 | 5 | ![intor](https://raw.github.com/patriciogonzalezvivo/OFPlay/master/ofplay_intro.png) 6 | ![main](https://raw.github.com/patriciogonzalezvivo/OFPlay/master/ofplay_main.png) 7 | 8 | Borns as a Major Studio project after a [brief research](http://www.patriciogonzalezvivo.com/blog/?p=821) exploring the difficult learning process of openFrameworks. 9 | 10 | ##Features 11 | * Guides new users on the Xcode installation 12 | * Colorful and friendly interface that re enforce the building-block metaphor. 13 | * Simple UX/UI experience 14 | * File navigation 15 | * Drag&drop capabilities. Just drag and drop the folder of the project you want to make 16 | * Once the project is generated open it on XCode 17 | 18 | ##Download Compiled Version 19 | 20 | 21 | * [Beta Version 0.4 - MacSO 10.6 or > ](https://dl.dropbox.com/u/335522/OFPlay-0.4.zip) 22 | 23 | 24 | ##TODO 25 | * windows and linux implementation 26 | * git integration for downloading suggested addons at demand 27 | 28 | ##Thanks 29 | Special thanks to Zachary Lieberman, Ted Byfield, Navit Keren, Kyle McDonnald, Quincy Bock and the 44 students that fill the forms of the [initial questionary for the research](http://www.patriciogonzalezvivo.com/blog/?p=821) -------------------------------------------------------------------------------- /bin/data/ofplay.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ofxCanon 4 | git://github.com/roxlu/ofxCanon.git 5 | 6 | 7 | ofxCv 8 | git://github.com/kylemcdonald/ofxCv.git 9 | 10 | 11 | ofxFaceTracker 12 | git://github.com/kylemcdonald/ofxFaceTracker.git 13 | 14 | 15 | ofxFft 16 | git://github.com/kylemcdonald/ofxFft.git 17 | 18 | 19 | ofxFX 20 | git://github.com/patriciogonzalezvivo/ofxFX.git 21 | 22 | 23 | ofxGameCamera 24 | https://github.com/Flightphase/ofxGameCamera 25 | 26 | 27 | ofxGrabCam 28 | git://github.com/elliotwoods/ofxGrabCam.git 29 | 30 | 31 | ofxKinect 32 | git://github.com/ofTheo/ofxKinect.git 33 | 34 | 35 | ofxOpenNI 36 | git://github.com/gameoverhack/ofxOpenNI.git 37 | 38 | 39 | ofxPlaymodes 40 | git://github.com/arturoc/ofxPlaymodes.git 41 | 42 | 43 | ofxTriangleMesh 44 | git://github.com/ofZach/ofxTriangleMesh.git 45 | 46 | 47 | ofxTUIO 48 | git://github.com/patriciogonzalezvivo/ofxTuio.git 49 | 50 | 51 | ofxUI 52 | git://github.com/rezaali/ofxUI.git 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/intro/SlideSequencer.h: -------------------------------------------------------------------------------- 1 | // 2 | // SlideSequencer.h 3 | // 4 | // Created by Patricio Gonzalez Vivo on 4/1/12. 5 | // Copyright (c) 2012 http://PatricioGonzalezVivo.com All rights reserved. 6 | // 7 | 8 | #ifndef SLIDESEQUENCER 9 | #define SLIDESEQUENCER 10 | 11 | #include "ofMain.h" 12 | 13 | #include "TextBlock.h" 14 | 15 | #include "froebelColor.h" 16 | #include "froebelShapeButton.h" 17 | 18 | #include "ofxXmlSettings.h" 19 | 20 | typedef struct { 21 | string image; 22 | vector text; 23 | horizontalAlignment hAlign; 24 | verticalAlignment vAlign; 25 | } Slide; 26 | 27 | class SlideSequencer: public ofRectangle { 28 | public: 29 | SlideSequencer(); 30 | 31 | bool loadSequence(string _xmlFile); 32 | 33 | int size(){ return slides.size(); } 34 | void setLine( unsigned int _nLine); 35 | void setNextPhrase(Slide &_slide ); 36 | 37 | void setPrevLine(); 38 | void setNextLine(); 39 | 40 | int getLineNumber() { return currentLine; } 41 | 42 | void update(); 43 | void draw(); 44 | 45 | vector buttons; 46 | 47 | bool bFinish; 48 | 49 | protected: 50 | vector slides; 51 | 52 | ofImage image; 53 | string imagePath; 54 | 55 | TextBlock *text; 56 | froebelColor textColor; 57 | 58 | verticalAlignment defaultVertAlign; 59 | horizontalAlignment defaultHoriAlign; 60 | 61 | int desiredLine; 62 | int currentLine; 63 | int countDown; 64 | }; 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /src/froebelGui/froebelShapeButton.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // froebelShapeButton.cpp 3 | // OFPlay 4 | // 5 | // Created by Patricio Gonzalez Vivo on 12/7/12. 6 | // http://www.patriciogonzalezvivo.com 7 | // 8 | 9 | #include "froebelShapeButton.h" 10 | 11 | froebelShapeButton::froebelShapeButton(){ 12 | size = 40; 13 | type = 0; 14 | color.set(1.0f); 15 | 16 | text = ""; 17 | textColor.set(0.0); 18 | font = NULL; 19 | 20 | bEnable = true; 21 | } 22 | 23 | void froebelShapeButton::update(){ 24 | ofPoint mouse(ofGetMouseX()-x, ofGetMouseY()-y); 25 | 26 | if ( bEnable ){ 27 | if ( shape.inside(mouse) ){ 28 | nState = STATE_HOVER; 29 | } else { 30 | nState = STATE_ENABLE; 31 | } 32 | } else { 33 | nState = STATE_DISABLE; 34 | } 35 | 36 | color.setState(nState); 37 | textColor.setState(nState); 38 | } 39 | 40 | void froebelShapeButton::draw(){ 41 | froebelShape::draw(); 42 | textColor.update(); 43 | 44 | if (font != NULL){ 45 | 46 | ofPushMatrix(); 47 | ofPushStyle(); 48 | 49 | ofTranslate(x, y); 50 | ofSetColor(textColor); 51 | 52 | ofRectangle textBoundingBox = font->getStringBoundingBox( text , 0, 0); 53 | font->drawString(text, -textBoundingBox.width*0.5, textBoundingBox.height*0.5); 54 | 55 | ofPopStyle(); 56 | ofPopMatrix(); 57 | } 58 | } 59 | 60 | bool froebelShapeButton::checkMousePressed(ofPoint _mouse){ 61 | if ( bEnable ){ 62 | _mouse.x -= x; 63 | _mouse.y -= y; 64 | 65 | if ( shape.inside(_mouse)){ 66 | ofNotifyEvent(clicked, text); 67 | return true; 68 | } 69 | } 70 | return false; 71 | } -------------------------------------------------------------------------------- /src/mainScreenOFPlay.h: -------------------------------------------------------------------------------- 1 | // 2 | // mainScreen.h 3 | // OFPlay 4 | // 5 | // Created by Patricio Gonzalez Vivo on 12/7/12. 6 | // 7 | // 8 | 9 | #ifndef MAINSCREEN 10 | #define MAINSCREEN 11 | 12 | #include "ofMain.h" 13 | 14 | #include "froebelGui.h" 15 | #include "projectGenerator.h" 16 | 17 | class mainScreenOFPlay { 18 | public: 19 | 20 | mainScreenOFPlay(); 21 | 22 | void setup(string _ofpath, string _path, string _name ); 23 | void update(); 24 | void draw(); 25 | 26 | void keyPressed(int key); 27 | void mousePressed(ofPoint _mouse); 28 | void resized(); 29 | 30 | // GUI 31 | // 32 | ofImage logo; 33 | ofTrueTypeFont font; 34 | float defaultHeight; 35 | froebelTab tab; 36 | 37 | // Basic Paths 38 | // 39 | string ofRoot; 40 | string addonsPath; 41 | string sketchPath; 42 | 43 | // Project Generator 44 | // 45 | void loadAddons(); 46 | void loadFolder(string _path); 47 | void loadProject(string _path); 48 | // void checkProjectState(); 49 | 50 | void pathChange(string &_path); 51 | void nameChange(string &_path); 52 | 53 | string setTarget(int targ); 54 | void generateProject(); 55 | 56 | froebelEditBox projectName; 57 | froebelListBox projectPath; 58 | froebelListBox platformsList; 59 | froebelListBox addonsList; 60 | 61 | froebelShapeButton button; 62 | 63 | baseProject *project; 64 | 65 | // Status 66 | // 67 | void setStatus(string newStatus); 68 | float statusSetTime, statusEnergy; 69 | string status; 70 | }; 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /src/projectGenerator/src/baseProject.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #pragma once 4 | 5 | #include 6 | 7 | #include "ofMain.h" 8 | #include "pugixml.hpp" 9 | #include "ofAddon.h" 10 | #include "Utils.h" 11 | 12 | class baseProject { 13 | 14 | public: 15 | 16 | enum LibType{ 17 | DEBUG_LIB = 0, 18 | RELEASE_LIB 19 | }; 20 | 21 | bool bTemplateSet; 22 | 23 | baseProject(){ 24 | bLoaded = false; 25 | bTemplateSet = false; 26 | }; 27 | 28 | 29 | void setTemplatePath(string _path){ 30 | templatePath = _path; 31 | bTemplateSet = true; 32 | } 33 | 34 | virtual ~baseProject(){}; 35 | 36 | void setup(string _target); 37 | 38 | bool create(string path); 39 | bool save(bool createMakeFile); 40 | 41 | // this shouldn't be called by anyone. call "create(...), save" etc 42 | private: 43 | 44 | virtual void setup()=0; 45 | virtual bool createProjectFile()=0; 46 | virtual bool loadProjectFile()=0; 47 | virtual bool saveProjectFile()=0; 48 | 49 | // virtual void renameProject(); 50 | // this should get called at the end. 51 | 52 | public: 53 | 54 | virtual void addSrc(string srcFile, string folder) = 0; 55 | virtual void addInclude(string includeName) = 0; 56 | virtual void addLibrary(string libraryName, LibType libType = RELEASE_LIB) = 0; 57 | 58 | virtual void addAddon(ofAddon & addon); 59 | 60 | string getName() { return projectName;}; 61 | string getPath() { return projectDir; }; 62 | 63 | pugi::xml_document doc; 64 | bool bLoaded; 65 | 66 | string projectDir; 67 | string projectName; 68 | string templatePath; 69 | string target; 70 | 71 | private: 72 | 73 | void parseAddons(); 74 | 75 | protected: 76 | 77 | vector addons; 78 | }; 79 | 80 | 81 | -------------------------------------------------------------------------------- /src/projectGenerator/libs/pugixml/contrib/foreach.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Boost.Foreach support for pugixml classes. 3 | * This file is provided to the public domain. 4 | * Written by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) 5 | */ 6 | 7 | #ifndef HEADER_PUGIXML_FOREACH_HPP 8 | #define HEADER_PUGIXML_FOREACH_HPP 9 | 10 | #include "pugixml.hpp" 11 | 12 | /* 13 | * These types add support for BOOST_FOREACH macro to xml_node and xml_document classes (child iteration only). 14 | * Example usage: 15 | * BOOST_FOREACH(xml_node n, doc) {} 16 | */ 17 | 18 | namespace boost 19 | { 20 | template struct range_mutable_iterator; 21 | template struct range_const_iterator; 22 | 23 | template<> struct range_mutable_iterator 24 | { 25 | typedef pugi::xml_node::iterator type; 26 | }; 27 | 28 | template<> struct range_const_iterator 29 | { 30 | typedef pugi::xml_node::iterator type; 31 | }; 32 | 33 | template<> struct range_mutable_iterator 34 | { 35 | typedef pugi::xml_document::iterator type; 36 | }; 37 | 38 | template<> struct range_const_iterator 39 | { 40 | typedef pugi::xml_document::iterator type; 41 | }; 42 | } 43 | 44 | /* 45 | * These types add support for BOOST_FOREACH macro to xml_node and xml_document classes (child/attribute iteration). 46 | * Example usage: 47 | * BOOST_FOREACH(xml_node n, children(doc)) {} 48 | * BOOST_FOREACH(xml_node n, attributes(doc)) {} 49 | */ 50 | 51 | namespace pugi 52 | { 53 | inline xml_object_range children(const pugi::xml_node& node) 54 | { 55 | return node.children(); 56 | } 57 | 58 | inline xml_object_range attributes(const pugi::xml_node& node) 59 | { 60 | return node.attributes(); 61 | } 62 | } 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/froebelGui/froebelTextBox.h: -------------------------------------------------------------------------------- 1 | // 2 | // froebelTextBox.h 3 | // OFPlay 4 | // 5 | // Created by Patricio Gonzalez Vivo on 12/2/12. 6 | // http://www.patriciogonzalezvivo.com 7 | // 8 | 9 | #ifndef FROEBELTEXTBOX 10 | #define FROEBELTEXTBOX 11 | 12 | #include "ofMain.h" 13 | 14 | #include "froebelColor.h" 15 | #include "froebelShape.h" 16 | 17 | class froebelTextBox: public ofRectangle { 18 | public: 19 | froebelTextBox(); 20 | 21 | void setSizeAndShapes(float _size, int _endingShape = -1, int _iconShape = -1); 22 | void setSubInfo(string _comment); 23 | 24 | virtual bool checkMousePressed(ofPoint _mouse); 25 | 26 | virtual void setPrefix( string _prefix ); 27 | virtual void setDivider( string _deliminater ); 28 | virtual void setText(string _text ); 29 | 30 | virtual void reset(); 31 | virtual string getText(); 32 | virtual float getVerticalMargins(); 33 | virtual ofRectangle getTextBoundingBox(); 34 | virtual ofRectangle getBoundingBox(); 35 | 36 | virtual void update(); 37 | virtual void draw(); 38 | 39 | ofEvent focusLost; 40 | 41 | froebelColor fgColor; 42 | froebelColor bgColor; 43 | 44 | ofTrueTypeFont *font; 45 | froebelTextBox *subInfo; 46 | 47 | enum { STATE_PASIVE, STATE_HOVER, STATE_ACTIVE }; 48 | int nState; 49 | 50 | int minWidth; 51 | int maxWidth; 52 | 53 | bool bChange; 54 | bool bSelected; 55 | bool bLeftAlign; 56 | bool bFixedSize; 57 | bool bEdge; 58 | bool bIcon; 59 | bool bFill; 60 | 61 | protected: 62 | string text; 63 | string prefix; 64 | string deliminater; 65 | 66 | froebelShape endingShape; 67 | froebelShape iconShape; 68 | 69 | string displayText; 70 | 71 | ofRectangle textBox; 72 | 73 | float size; 74 | int nEdges; 75 | }; 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /bin/data/intro.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | intro-ofplay.png 4 | Welcome to openFrameworks 5 | This program will assist you with the installation process and help you to manage your projects. 6 | 7 | 8 | 9 | intro-ofbb.png 10 | As you probably know, openFrameworks isn't an application in itself. 11 | It's what is called a "library". 12 | 13 | 14 | 15 | intro-ofbb.png 16 | Think of it as a construction kit of building blocks. 17 | You will use these blocks to design and develop your own creative applications. 18 | 19 | 20 | 21 | intro-ofide.png 22 | Before we can start coding we need to install the default IDE for your platform. 23 | 24 | 25 | 26 | intro-ofide.png 27 | An IDE is a special type of text editor specially designed to work with code. 28 | For OS X the default IDE is called XCode, and it's free. 29 | 30 | 31 | 32 | intro-ofide.png 33 | Please go to the App Store and install it. 34 | 35 | 36 | 37 | intro-ofide.png 38 | If you would like to download new addons automatically, you need to install git. 39 | Go to XCode Preferences -> Downloads -> Components -> and click on "Install Command Line Tools". 40 | 41 | 42 | 43 | intro-ofplay.png 44 | Everything is almost ready. 45 | Unless you already did it, please go to openFrameworks.cc/download to get a copy of openFrameworks for your operating system 46 | 47 | 48 | 49 | intro-offolder.png 50 | After downloading, unzip it anywhere safe, like "Documents". 51 | OFPlay needs to know where you unzipped openFrameworks, so it will ask you where it is. 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/projectGenerator/libs/pugixml/readme.txt: -------------------------------------------------------------------------------- 1 | pugixml 1.2 - an XML processing library 2 | 3 | Copyright (C) 2006-2012, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) 4 | Report bugs and download new versions at http://pugixml.org/ 5 | 6 | This is the distribution of pugixml, which is a C++ XML processing library, 7 | which consists of a DOM-like interface with rich traversal/modification 8 | capabilities, an extremely fast XML parser which constructs the DOM tree from 9 | an XML file/buffer, and an XPath 1.0 implementation for complex data-driven 10 | tree queries. Full Unicode support is also available, with Unicode interface 11 | variants and conversions between different Unicode encodings (which happen 12 | automatically during parsing/saving). 13 | 14 | The distribution contains the following folders: 15 | 16 | contrib/ - various contributions to pugixml 17 | 18 | docs/ - documentation 19 | docs/samples - pugixml usage examples 20 | docs/quickstart.html - quick start guide 21 | docs/manual.html - complete manual 22 | 23 | scripts/ - project files for IDE/build systems 24 | 25 | src/ - header and source files 26 | 27 | readme.txt - this file. 28 | 29 | This library is distributed under the MIT License: 30 | 31 | Copyright (c) 2006-2012 Arseny Kapoulkine 32 | 33 | Permission is hereby granted, free of charge, to any person 34 | obtaining a copy of this software and associated documentation 35 | files (the "Software"), to deal in the Software without 36 | restriction, including without limitation the rights to use, 37 | copy, modify, merge, publish, distribute, sublicense, and/or sell 38 | copies of the Software, and to permit persons to whom the 39 | Software is furnished to do so, subject to the following 40 | conditions: 41 | 42 | The above copyright notice and this permission notice shall be 43 | included in all copies or substantial portions of the Software. 44 | 45 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 46 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 47 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 48 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 49 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 50 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 51 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 52 | OTHER DEALINGS IN THE SOFTWARE. 53 | -------------------------------------------------------------------------------- /src/projectGenerator/src/Utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Utils.h 3 | * 4 | * Created on: 28/12/2011 5 | * Author: arturo 6 | */ 7 | 8 | #ifndef UTILS_H_ 9 | #define UTILS_H_ 10 | 11 | #include "ofConstants.h" 12 | 13 | #include "pugixml.hpp" 14 | 15 | #include "ofMain.h" 16 | 17 | 18 | string generateUUID(string input); 19 | 20 | string getOFRoot(); 21 | string getAddonsRoot(); 22 | void setOFRoot(string path); 23 | void findandreplace( std::string& tInput, std::string tFind, std::string tReplace ); 24 | void findandreplaceInTexfile (string fileName, string tFind, string tReplace ); 25 | 26 | 27 | bool doesTagAndAttributeExist(pugi::xml_document & doc, string tag, string attribute, string newValue); 28 | pugi::xml_node appendValue(pugi::xml_document & doc, string tag, string attribute, string newValue, bool addMultiple = false); 29 | 30 | void getFoldersRecursively(const string & path, vector < string > & folderNames, string platform); 31 | void getFilesRecursively(const string & path, vector < string > & fileNames); 32 | void getLibsRecursively(const string & path, vector < string > & libFiles, vector < string > & libLibs, string platform = "" ); 33 | 34 | void splitFromLast(string toSplit, string deliminator, string & first, string & second); 35 | void splitFromFirst(string toSplit, string deliminator, string & first, string & second); 36 | 37 | void parseAddonsDotMake(string path, vector < string > & addons); 38 | 39 | void fixSlashOrder(string & toFix); 40 | string unsplitString (vector < string > strings, string deliminator ); 41 | 42 | string getOFRelPath(string from); 43 | 44 | bool checkConfigExists(); 45 | bool askOFRoot(); 46 | string getOFRootFromConfig(); 47 | 48 | template 49 | inline bool isInVector(T item, vector & vec){ 50 | bool bIsInVector = false; 51 | for(int i=0;i 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /OFPlay.xcodeproj/xcshareddata/xcschemes/OFPlay Release.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /src/projectGenerator/src/CBWinProject.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * CBWinProject.cpp 3 | * 4 | * Created on: 28/12/2011 5 | * Author: arturo 6 | */ 7 | 8 | #include "CBWinProject.h" 9 | #include "ofFileUtils.h" 10 | #include "ofLog.h" 11 | #include "Utils.h" 12 | 13 | string CBWinProject::LOG_NAME = "CBWinProject"; 14 | 15 | void CBWinProject::setup() { 16 | ; 17 | } 18 | 19 | bool CBWinProject::createProjectFile(){ 20 | 21 | string project = projectDir + projectName + ".cbp"; 22 | string workspace = projectDir + projectName + ".workspace"; 23 | 24 | 25 | ofFile::copyFromTo(ofFilePath::join(templatePath,"emptyExample.cbp"),project, false, true); 26 | 27 | ofFile::copyFromTo(ofFilePath::join(templatePath,"emptyExample.workspace"),workspace, false, true); 28 | 29 | //let's do some renaming: 30 | string relRoot = getOFRelPath(ofFilePath::removeTrailingSlash(projectDir)); 31 | 32 | if (relRoot != "../../../"){ 33 | 34 | string relRootWindows = relRoot; 35 | // let's make it windows friendly: 36 | for(int i = 0; i < relRootWindows.length(); i++) { 37 | if( relRootWindows[i] == '/' ) 38 | relRootWindows[i] = '\\'; 39 | } 40 | 41 | findandreplaceInTexfile(workspace, "../../../", relRoot); 42 | findandreplaceInTexfile(project, "../../../", relRoot); 43 | 44 | findandreplaceInTexfile(workspace, "..\\..\\..\\", relRootWindows); 45 | findandreplaceInTexfile(project, "..\\..\\..\\", relRootWindows); 46 | } 47 | 48 | return true; 49 | } 50 | 51 | bool CBWinProject::loadProjectFile(){ 52 | 53 | //project.open(ofFilePath::join(projectDir , projectName + ".cbp")); 54 | 55 | ofFile project(projectDir + projectName + ".cbp"); 56 | if(!project.exists()){ 57 | ofLogError(LOG_NAME) << "error loading" << project.path() << "doesn't exist"; 58 | return false; 59 | } 60 | pugi::xml_parse_result result = doc.load(project); 61 | bLoaded =result.status==pugi::status_ok; 62 | return bLoaded; 63 | } 64 | 65 | bool CBWinProject::saveProjectFile(){ 66 | 67 | findandreplaceInTexfile(ofFilePath::join(projectDir , projectName + ".workspace"),"emptyExample",projectName); 68 | pugi::xpath_node_set title = doc.select_nodes("//Option[@title]"); 69 | if(!title.empty()){ 70 | if(!title[0].node().attribute("title").set_value(projectName.c_str())){ 71 | ofLogError(LOG_NAME) << "can't set title"; 72 | } 73 | } 74 | return doc.save_file((projectDir + projectName + ".cbp").c_str()); 75 | } 76 | 77 | void CBWinProject::addSrc(string srcName, string folder){ 78 | pugi::xml_node node = appendValue(doc, "Unit", "filename", srcName); 79 | if(!node.empty()){ 80 | node.child("Option").attribute("virtualFolder").set_value(folder.c_str()); 81 | } 82 | doc.save_file((projectDir + projectName + ".cbp").c_str()); 83 | } 84 | 85 | void CBWinProject::addInclude(string includeName){ 86 | ofLogNotice() << "adding include " << includeName; 87 | appendValue(doc, "Add", "directory", includeName); 88 | } 89 | 90 | void CBWinProject::addLibrary(string libraryName, LibType libType){ 91 | ofLogNotice() << "adding library " << libraryName; 92 | appendValue(doc, "Add", "library", libraryName, true); 93 | // overwriteMultiple for a lib if it's there (so libsorder.make will work) 94 | // this is because we might need to say libosc, then ws2_32 95 | } 96 | 97 | string CBWinProject::getName(){ 98 | return projectName; 99 | } 100 | 101 | string CBWinProject::getPath(){ 102 | return projectDir; 103 | } 104 | -------------------------------------------------------------------------------- /src/froebelGui/froebelTab.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // froebelTab.cpp 3 | // OFPlay 4 | // 5 | // Created by Patricio Gonzalez Vivo on 12/12/12. 6 | // 7 | // 8 | 9 | #include "froebelTab.h" 10 | 11 | 12 | froebelTab::froebelTab(){ 13 | currentElement = 0; 14 | desiredElement = 0; 15 | countDown = 0; 16 | 17 | text = ""; 18 | buttonSize = 12; 19 | 20 | textColor.addState(ofFloatColor(0.0,0.0)); 21 | textColor.addState(5); 22 | 23 | set(0,0,ofGetWidth(),34*2.0); 24 | } 25 | 26 | 27 | void froebelTab::addElement(string _title){ 28 | froebelShapeButton newButton; 29 | newButton.setShape(0, buttonSize); 30 | newButton.color.addState(ofFloatColor(0.686274)); 31 | newButton.color.addState(0); 32 | newButton.color.addState(0); 33 | newButton.text = _title; 34 | newButton.font = &font; 35 | newButton.textColor.set(0.0,0.0); 36 | buttons.push_back(newButton); 37 | 38 | float totalWidth = buttons.size()*2.0*buttonSize; 39 | for(int i = 0; i < buttons.size(); i++){ 40 | buttons[i].x = - totalWidth*0.5 + buttonSize + buttonSize*i*2.0; 41 | buttons[i].y = 0;//y + height + buttonSize*0.5; 42 | } 43 | 44 | desiredElement = 1; 45 | setElement(0); 46 | } 47 | 48 | void froebelTab::setPrev(){ 49 | if ( currentElement > 0){ 50 | setElement(currentElement-1); 51 | } 52 | } 53 | 54 | void froebelTab::setNext(){ 55 | setElement(currentElement+1); 56 | } 57 | 58 | void froebelTab::setElement( unsigned int _nElement){ 59 | if ( _nElement < size() ){ 60 | 61 | if (_nElement != desiredElement ){ 62 | textColor.setState(0); 63 | desiredElement = _nElement; 64 | countDown = ofGetFrameRate(); 65 | 66 | for(int i = 0; i < buttons.size(); i++){ 67 | if (i == desiredElement){ 68 | buttons[i].bEnable = false; 69 | } else { 70 | buttons[i].bEnable = true; 71 | } 72 | } 73 | } 74 | 75 | } 76 | } 77 | 78 | bool froebelTab::checkMousePressed(ofPoint _mouse){ 79 | bool rta = false; 80 | 81 | _mouse.x -= x+width*0.5; 82 | _mouse.y -= y+height; 83 | 84 | for(int i = 0; i < buttons.size(); i++){ 85 | if (buttons[i].checkMousePressed(_mouse)){ 86 | rta = true; 87 | setElement(i); 88 | break; 89 | } 90 | } 91 | 92 | return rta; 93 | } 94 | 95 | void froebelTab::update(){ 96 | 97 | if ( buttons.size() > 0 ){ 98 | textColor.update(); 99 | 100 | if (countDown == 0){ 101 | text = buttons[desiredElement].text; 102 | currentElement = desiredElement; 103 | countDown = -1; 104 | textColor.setState(1); 105 | } else if ( countDown > 0){ 106 | countDown--; 107 | } 108 | 109 | for(int i = 0; i < buttons.size(); i++){ 110 | buttons[i].update(); 111 | } 112 | } 113 | } 114 | 115 | void froebelTab::draw(){ 116 | ofPushStyle(); 117 | ofPushMatrix(); 118 | 119 | ofTranslate(x+width*0.5, y+height*0.5); 120 | ofSetColor(textColor); 121 | ofRectangle textBox = font.getStringBoundingBox(text, 0, 0); 122 | font.drawString(text, -textBox.width*0.5, textBox.height*0.5); 123 | 124 | ofTranslate(0, height*0.5); 125 | ofFill(); 126 | ofSetColor(255); 127 | for(int i = 0; i < buttons.size(); i++){ 128 | buttons[i].draw(); 129 | } 130 | 131 | ofPopMatrix(); 132 | 133 | ofPushStyle(); 134 | } -------------------------------------------------------------------------------- /src/froebelGui/froebelListBox.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // froebelListBox.cpp 3 | // OFPlay 4 | // 5 | // Created by Patricio Gonzalez Vivo on 12/2/12. 6 | // http://www.patriciogonzalezvivo.com 7 | // 8 | 9 | #include "froebelListBox.h" 10 | 11 | froebelListBox::froebelListBox(){ 12 | subInfo = NULL; 13 | 14 | bLeftAlign = true; 15 | bChange = true; 16 | bEdge = false; 17 | bIcon = false; 18 | bSelected = false; 19 | bFixedSize = false; 20 | 21 | text = ""; 22 | prefix = ""; 23 | deliminater = ""; 24 | 25 | minWidth = 0; 26 | maxWidth = 600; 27 | size = 40; 28 | nState = 0; 29 | 30 | containerBox.bCheckList = true; 31 | 32 | // STATE_PASSIVE 33 | // 34 | fgColor.addState(2); 35 | bgColor.addState(5); 36 | 37 | // STATE_HOVER 38 | // 39 | fgColor.addState(4); 40 | bgColor.addState(5); 41 | 42 | // STATE_ACTIVE 43 | // 44 | fgColor.addState(3); 45 | bgColor.addState(4); 46 | } 47 | 48 | void froebelListBox::addElement(string _value, bool _defVal, int _iconShape, int _edgeCoorner){ 49 | 50 | // Create new element 51 | // 52 | froebelTextBox *newElement = new froebelTextBox(); 53 | newElement->font = font; 54 | newElement->setSizeAndShapes(size,_edgeCoorner,_iconShape); 55 | newElement->setText(_value); 56 | newElement->bSelected = _defVal; 57 | 58 | newElement->fgColor.clear(); 59 | newElement->fgColor.addState(5); 60 | newElement->fgColor.addState(5); 61 | newElement->fgColor.addState(9); 62 | newElement->bgColor.clear(); 63 | newElement->bgColor.addState(0); 64 | newElement->bgColor.addState(1); 65 | newElement->bgColor.addState(5); 66 | 67 | newElement->update(); 68 | 69 | // recalculate the container box 70 | // 71 | containerBox.x = x; 72 | containerBox.y = y + height; 73 | containerBox.width = width-( bEdge? size: 0); 74 | containerBox.height = 0; 75 | containerBox.size = size; 76 | containerBox.addElement(newElement); 77 | 78 | bChange = true; 79 | } 80 | 81 | ofRectangle froebelListBox::getBoundingBox(){ 82 | ofRectangle rta; 83 | 84 | rta.set(*this); 85 | 86 | if (subInfo != NULL) 87 | rta.growToInclude(*subInfo); 88 | 89 | rta.growToInclude(containerBox); 90 | 91 | for (int i = 0; i < containerBox.elements.size(); i++){ 92 | 93 | if ((containerBox.elements[i]->bSelected) && 94 | (containerBox.inside(containerBox.elements[i]->getCenter())) ){ 95 | rta.growToInclude( containerBox.elements[i]->getBoundingBox() ); 96 | } 97 | 98 | } 99 | 100 | return rta; 101 | } 102 | 103 | void froebelListBox::reset(){ 104 | froebelTextBox::reset(); 105 | containerBox.reset(); 106 | } 107 | 108 | bool froebelListBox::select(string _value){ 109 | return bChange = containerBox.select(_value); 110 | } 111 | 112 | string froebelListBox::getSelectedAsString(){ 113 | string list; 114 | 115 | for (int i = 0; i < containerBox.elements.size(); i++){ 116 | if ( containerBox.elements[i]->bSelected ){ 117 | 118 | if (list.length() > 0) 119 | list += deliminater; 120 | 121 | list += containerBox.elements[i]->getText(); 122 | } 123 | } 124 | 125 | return list; 126 | } 127 | 128 | bool froebelListBox::checkMousePressed(ofPoint _mouse){ 129 | 130 | if ( !bSelected ){ 131 | 132 | return froebelTextBox::checkMousePressed(_mouse); 133 | 134 | } else { 135 | 136 | if ( containerBox.checkMousePressed(_mouse)){ 137 | text = getSelectedAsString(); 138 | bChange = true; 139 | bSelected = true; 140 | return true; 141 | } else { 142 | if (!inside(_mouse)){ 143 | string rta = getText(); 144 | ofNotifyEvent(focusLost, rta); 145 | } else { 146 | bSelected = !bSelected; 147 | } 148 | } 149 | } 150 | } 151 | 152 | void froebelListBox::update(){ 153 | if ( bChange ){ 154 | minWidth = containerBox.width + size * 0.5; 155 | } 156 | 157 | froebelTextBox::update(); 158 | 159 | containerBox.x = x; 160 | containerBox.y = y + height; 161 | containerBox.bEnable = bSelected; 162 | containerBox.update(); 163 | 164 | } 165 | 166 | void froebelListBox::draw(){ 167 | 168 | if (bEdge) 169 | endingShape.color.set(bgColor); 170 | 171 | if (bIcon) 172 | iconShape.color.set(fgColor); 173 | 174 | 175 | // Render Elements 176 | // 177 | if ( bSelected ){ 178 | containerBox.draw(); 179 | } 180 | 181 | froebelTextBox::draw(); 182 | } -------------------------------------------------------------------------------- /src/intro/TextBlock.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | 3 | Copyright (c) 2009, Luke Malcolm, www.lukemalcolm.com 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | ***********************************************************************/ 19 | 20 | #ifndef TEXTBLOCK_H 21 | #define TEXTBLOCK_H 22 | 23 | #include "ofMain.h" 24 | #include 25 | 26 | enum horizontalAlignment { 27 | OF_TEXT_ALIGN_LEFT, 28 | OF_TEXT_ALIGN_RIGHT, 29 | OF_TEXT_ALIGN_JUSTIFIED, 30 | OF_TEXT_ALIGN_CENTER 31 | }; 32 | 33 | enum verticalAlignment { 34 | OF_TEXT_ALIGN_TOP, 35 | OF_TEXT_ALIGN_BOTTOM, 36 | OF_TEXT_ALIGN_MIDDLE 37 | }; 38 | 39 | typedef struct{ 40 | string character; 41 | string code; 42 | } charSubstitution; 43 | 44 | typedef struct { 45 | string rawWord; 46 | float width; 47 | float height; 48 | } wordBlock; 49 | 50 | typedef struct { 51 | vector wordsID; 52 | float width; 53 | float height; 54 | } lineBlock; 55 | 56 | class textFont: public ofTrueTypeFont { 57 | public: 58 | textFont(){ 59 | } 60 | 61 | float getCharacterWidth(char ch){ 62 | if (ch=='\n') 63 | return 10.0; 64 | else { 65 | if (ch==' ') ch='i'; 66 | if (ch=='\xE0') ch='a'; //ˆ 67 | if (ch=='\xE1') ch='a'; //‡ 68 | if (ch=='\xE2') ch='a'; //‰ 69 | if (ch=='\xE3') ch='a'; //‹ 70 | if (ch=='\xE4') ch='a'; //Š 71 | if (ch=='\xE6') ch='a'; //¾ 72 | if (ch=='\xE8') ch='e'; // 73 | if (ch=='\xE9') ch='e'; //Ž 74 | if (ch=='\xEA') ch='e'; // 75 | if (ch=='\xEB') ch='e'; //‘ 76 | if (ch=='\xEC') ch='i'; //“ 77 | if (ch=='\xED') ch='i'; //’ 78 | if (ch=='\xEE') ch='i'; //” 79 | if (ch=='\xEF') ch='i'; //• 80 | if (ch=='\xF2') ch='o'; //˜ 81 | if (ch=='\xF3') ch='o'; //— 82 | if (ch=='\xF4') ch='o'; //™ 83 | if (ch=='\xF5') ch='o'; //› 84 | if (ch=='\xF6') ch='o'; //š 85 | if (ch=='\xF9') ch='u'; // 86 | if (ch=='\xFA') ch='u'; //œ 87 | if (ch=='\xFB') ch='u'; //ž 88 | if (ch=='\xFC') ch='u'; //Ÿ 89 | if (ch=='\xC7') ch='c'; // 90 | return cps[ch-NUM_CHARACTER_TO_START].setWidth; 91 | } 92 | } 93 | }; 94 | 95 | class TextBlock : public ofRectangle{ 96 | public: 97 | TextBlock(); 98 | 99 | void loadFont(string _fontLocation, float _fontSize, int _dpi = 90); 100 | void setAlignment(horizontalAlignment _hAlignment , verticalAlignment _vAlignment = OF_TEXT_ALIGN_TOP); 101 | 102 | float getTextWidth(); 103 | float getTextHeight(); 104 | 105 | void setText(string _inputText); 106 | void setText(vector _inputText); 107 | void appendText(string _inputText); 108 | string getText()const{return rawText;}; 109 | 110 | void draw(); 111 | void draw(float _x, float _y, float _w = -1, float _h = -1); 112 | 113 | protected: 114 | void _loadWords(); 115 | void _subsChars(string & origString){ 116 | 117 | static charSubstitution chars[]={ {"à ","\xE0"}, {"á","\xE1"}, {"â","\xE2"}, {"ã","\xE3"}, {"ä","\xE4"}, {"æ","\xE6"}, {"ò","\xF2"},{"ó","\xF3"}, {"ô","\xF4"}, {"õ","\xF5"}, {"ö","\xF6"}, {"ù","\xF9"}, {"ú","\xFA"}, {"û","\xFB"}, {"ü","\xFC"}, {"è","\xE8"}, {"é","\xE9"}, {"ê","\xEA"}, {"ë","\xEB"}, {"ì","\xEC"}, {"í","\xED"}, {"î","\xEE"}, {"ï","\xEF"}, {"ç","\xE7"}, {"Ç","\xC7"} }; 118 | 119 | for(int i=0; i<24; i++){ 120 | while(origString.find(chars[i].character) !=string::npos){ 121 | origString = origString.substr(0,origString.find(chars[i].character)) + chars[i].code + origString.substr(origString.find(chars[i].character)+2); 122 | } 123 | }; 124 | } 125 | 126 | void _trimLineSpaces(); 127 | float _getWidthOfWords(); 128 | int _getLinedWords(); 129 | 130 | int _wrapTextX(float lineWidth); //Returns the number of lines it formed. 131 | bool _wrapTextForceLines(int linesN); 132 | 133 | void _forceScale(float _scale); 134 | 135 | vector words; 136 | vector lines; 137 | wordBlock blankSpaceWord; 138 | textFont font; 139 | 140 | horizontalAlignment hAlignment; 141 | verticalAlignment vAlignment; 142 | 143 | string rawText; 144 | }; 145 | 146 | #endif 147 | -------------------------------------------------------------------------------- /src/projectGenerator/src/baseProject.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // baseProject.cpp 3 | // projectGenerator 4 | // 5 | // Created by molmol on 3/12/12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #include "baseProject.h" 10 | 11 | void baseProject::setup(string _target){ 12 | target = _target; 13 | 14 | if (!bTemplateSet){ 15 | templatePath = ofFilePath::join(getOFRoot(),"scripts/" + target + "/template/"); 16 | } 17 | 18 | setup(); // call the inherited class setup(), now that target is set. 19 | } 20 | 21 | bool baseProject::create(string path){ 22 | 23 | addons.clear(); 24 | 25 | projectDir = ofFilePath::addTrailingSlash(path); 26 | projectName = ofFilePath::getFileName(path); 27 | bool bDoesDirExist = false; 28 | 29 | ofDirectory project(ofFilePath::join(projectDir,"src")); // this is a directory, really? 30 | if(project.exists()){ 31 | bDoesDirExist = true; 32 | }else{ 33 | ofDirectory project(projectDir); 34 | ofFile::copyFromTo(ofFilePath::join(templatePath,"src"),ofFilePath::join(projectDir,"src")); 35 | ofFile::copyFromTo(ofFilePath::join(templatePath,"bin"),ofFilePath::join(projectDir,"bin")); 36 | } 37 | 38 | // if overwrite then ask for permission... 39 | 40 | bool ret = createProjectFile(); 41 | if(!ret) return false; 42 | 43 | ret = loadProjectFile(); 44 | if(!ret) return false; 45 | 46 | if (bDoesDirExist){ 47 | vector < string > fileNames; 48 | getFilesRecursively(ofFilePath::join(projectDir , "src"), fileNames); 49 | 50 | for (int i = 0; i < (int)fileNames.size(); i++){ 51 | 52 | fileNames[i].erase(fileNames[i].begin(), fileNames[i].begin() + projectDir.length()); 53 | 54 | string first, last; 55 | #ifdef TARGET_WIN32 56 | splitFromLast(fileNames[i], "\\", first, last); 57 | #else 58 | splitFromLast(fileNames[i], "/", first, last); 59 | #endif 60 | if (fileNames[i] != "src/ofApp.cpp" && 61 | fileNames[i] != "src/ofApp.h" && 62 | fileNames[i] != "src/main.cpp" && 63 | fileNames[i] != "src/testApp.mm" && 64 | fileNames[i] != "src/main.mm"){ 65 | addSrc(fileNames[i], first); 66 | } 67 | } 68 | 69 | // if( target == "ios" ){ 70 | // getFilesRecursively(ofFilePath::join(projectDir , "bin/data"), fileNames); 71 | // 72 | // for (int i = 0; i < (int)fileNames.size(); i++){ 73 | // fileNames[i].erase(fileNames[i].begin(), fileNames[i].begin() + projectDir.length()); 74 | // 75 | // string first, last; 76 | // splitFromLast(fileNames[i], "/", first, last); 77 | // if (fileNames[i] != "Default.png" && 78 | // fileNames[i] != "src/testApp.h" && 79 | // fileNames[i] != "src/main.cpp" && 80 | // fileNames[i] != "src/testApp.mm" && 81 | // fileNames[i] != "src/main.mm"){ 82 | // addSrc(fileNames[i], first); 83 | // } 84 | // } 85 | // } 86 | 87 | #ifdef TARGET_LINUX 88 | parseAddons(); 89 | #endif 90 | // get a unique list of the paths that are needed for the includes. 91 | list < string > paths; 92 | vector < string > includePaths; 93 | for (int i = 0; i < (int)fileNames.size(); i++){ 94 | size_t found; 95 | #ifdef TARGET_WIN32 96 | found = fileNames[i].find_last_of("\\"); 97 | #else 98 | found = fileNames[i].find_last_of("/"); 99 | #endif 100 | paths.push_back(fileNames[i].substr(0,found)); 101 | } 102 | 103 | paths.sort(); 104 | paths.unique(); 105 | for (list::iterator it=paths.begin(); it!=paths.end(); ++it){ 106 | includePaths.push_back(*it); 107 | } 108 | 109 | for (int i = 0; i < includePaths.size(); i++){ 110 | addInclude(includePaths[i]); 111 | } 112 | } 113 | return true; 114 | } 115 | 116 | bool baseProject::save(bool createMakeFile){ 117 | 118 | // only save an addons.make file if requested on ANY platform 119 | // this way we don't thrash the git repo for our examples, but 120 | // we do make the addons.make file for any new projects...that 121 | // way it can be distributed and re-used by others with the PG 122 | 123 | if(createMakeFile){ 124 | ofFile addonsMake(ofFilePath::join(projectDir,"addons.make"), ofFile::WriteOnly); 125 | for(int i = 0; i < addons.size(); i++){ 126 | addonsMake << addons[i].name << endl; 127 | } 128 | } 129 | 130 | return saveProjectFile(); 131 | } 132 | 133 | void baseProject::addAddon(ofAddon & addon){ 134 | for(int i=0;i<(int)addons.size();i++){ 135 | if(addons[i].name==addon.name) return; 136 | } 137 | 138 | addons.push_back(addon); 139 | 140 | for(int i=0;i<(int)addon.includePaths.size();i++){ 141 | ofLogVerbose() << "adding addon include path: " << addon.includePaths[i]; 142 | addInclude(addon.includePaths[i]); 143 | } 144 | for(int i=0;i<(int)addon.libs.size();i++){ 145 | ofLogVerbose() << "adding addon libs: " << addon.libs[i]; 146 | addLibrary(addon.libs[i]); 147 | } 148 | for(int i=0;i<(int)addon.srcFiles.size(); i++){ 149 | ofLogVerbose() << "adding addon srcFiles: " << addon.srcFiles[i]; 150 | addSrc(addon.srcFiles[i],addon.filesToFolders[addon.srcFiles[i]]); 151 | } 152 | } 153 | 154 | void baseProject::parseAddons(){ 155 | ofFile addonsMake(ofFilePath::join(projectDir,"addons.make")); 156 | ofBuffer addonsMakeMem; 157 | addonsMake >> addonsMakeMem; 158 | while(!addonsMakeMem.isLastLine()){ 159 | ofAddon addon; 160 | cout << projectDir << endl; 161 | addon.pathToOF = getOFRelPath(projectDir); 162 | cout << addon.pathToOF << endl; 163 | addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addonsMakeMem.getNextLine()),target); 164 | addAddon(addon); 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /src/projectGenerator/src/ofAddon.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ofAddon.cpp 3 | * 4 | * Created on: 28/12/2011 5 | * Author: arturo 6 | */ 7 | 8 | #include "ofAddon.h" 9 | #include "pugixml.hpp" 10 | #include "ofUtils.h" 11 | #include "ofFileUtils.h" 12 | #include "Utils.h" 13 | #include 14 | 15 | ofAddon::ofAddon(){ 16 | pathToOF = "../../../"; 17 | } 18 | 19 | void ofAddon::fromFS(string path, string platform){ 20 | 21 | 22 | 23 | clear(); 24 | name = ofFilePath::getFileName(path); 25 | 26 | string filePath = path + "/src"; 27 | string ofRootPath = ofFilePath::addTrailingSlash(getOFRoot()); //we need to add a trailing slash for the erase to work properly 28 | 29 | ofLogVerbose() << "in fromFS, trying src " << filePath; 30 | 31 | 32 | ofSetLogLevel(OF_LOG_NOTICE); 33 | getFilesRecursively(filePath, srcFiles); 34 | //ofSetLogLevel(OF_LOG_VERBOSE); 35 | 36 | for(int i=0;i<(int)srcFiles.size();i++){ 37 | srcFiles[i].erase (srcFiles[i].begin(), srcFiles[i].begin()+ofRootPath.length()); 38 | //ofLogVerbose() << " srcFiles " << srcFiles[i]; 39 | int init = 0; 40 | #ifdef TARGET_WIN32 41 | int end = srcFiles[i].rfind("\\"); 42 | #else 43 | int end = srcFiles[i].rfind("/"); 44 | #endif 45 | string folder = srcFiles[i].substr(init,end); 46 | srcFiles[i] = pathToOF + srcFiles[i]; 47 | filesToFolders[srcFiles[i]] = folder; 48 | } 49 | 50 | string libsPath = path + "/libs"; 51 | vector < string > libFiles; 52 | 53 | 54 | //ofSetLogLevel(OF_LOG_NOTICE); 55 | if (ofDirectory::doesDirectoryExist(libsPath)){ 56 | getLibsRecursively(libsPath, libFiles, libs, platform); 57 | } 58 | //ofSetLogLevel(OF_LOG_VERBOSE); 59 | 60 | 61 | // I need to add libFiles to srcFiles 62 | for (int i = 0; i < (int)libFiles.size(); i++){ 63 | libFiles[i].erase (libFiles[i].begin(), libFiles[i].begin()+ofRootPath.length()); 64 | //ofLogVerbose() << " libFiles " << libFiles[i]; 65 | int init = 0; 66 | #ifdef TARGET_WIN32 67 | int end = libFiles[i].rfind("\\"); 68 | #else 69 | int end = libFiles[i].rfind("/"); 70 | #endif 71 | if (end > 0){ 72 | string folder = libFiles[i].substr(init,end); 73 | libFiles[i] = pathToOF + libFiles[i]; 74 | srcFiles.push_back(libFiles[i]); 75 | filesToFolders[libFiles[i]] = folder; 76 | } 77 | 78 | } 79 | 80 | for (int i = 0; i < (int)libs.size(); i++){ 81 | 82 | // does libs[] have any path ? let's fix if so. 83 | #ifdef TARGET_WIN32 84 | int end = libs[i].rfind("\\"); 85 | #else 86 | int end = libs[i].rfind("/"); 87 | #endif 88 | if (end > 0){ 89 | 90 | libs[i].erase (libs[i].begin(), libs[i].begin()+ofRootPath.length()); 91 | libs[i] = pathToOF + libs[i]; 92 | } 93 | 94 | } 95 | 96 | // get a unique list of the paths that are needed for the includes. 97 | list < string > paths; 98 | for (int i = 0; i < (int)srcFiles.size(); i++){ 99 | size_t found; 100 | #ifdef TARGET_WIN32 101 | found = srcFiles[i].find_last_of("\\"); 102 | #else 103 | found = srcFiles[i].find_last_of("/"); 104 | #endif 105 | paths.push_back(srcFiles[i].substr(0,found)); 106 | } 107 | 108 | // get every folder in addon/src and addon/libs 109 | 110 | vector < string > libFolders; 111 | ofLogVerbose() << "trying get folders recursively " << (path + "/libs"); 112 | 113 | // the dirList verbosity is crazy, so I'm setting this off for now. 114 | //ofSetLogLevel(OF_LOG_NOTICE); 115 | getFoldersRecursively(path + "/libs", libFolders, platform); 116 | vector < string > srcFolders; 117 | getFoldersRecursively(path + "/src", srcFolders, platform); 118 | //ofSetLogLevel(OF_LOG_VERBOSE); 119 | 120 | for (int i = 0; i < libFolders.size(); i++){ 121 | libFolders[i].erase (libFolders[i].begin(), libFolders[i].begin()+ofRootPath.length()); 122 | libFolders[i] = pathToOF + libFolders[i]; 123 | paths.push_back(libFolders[i]); 124 | } 125 | 126 | for (int i = 0; i < srcFolders.size(); i++){ 127 | srcFolders[i].erase (srcFolders[i].begin(), srcFolders[i].begin()+ofRootPath.length()); 128 | srcFolders[i] = pathToOF + srcFolders[i]; 129 | paths.push_back(srcFolders[i]); 130 | } 131 | 132 | paths.sort(); 133 | paths.unique(); 134 | for (list::iterator it=paths.begin(); it!=paths.end(); ++it){ 135 | includePaths.push_back(*it); 136 | } 137 | 138 | } 139 | 140 | void ofAddon::fromXML(string installXmlName){ 141 | clear(); 142 | pugi::xml_document doc; 143 | pugi::xml_parse_result result = doc.load_file(ofToDataPath(installXmlName).c_str()); 144 | 145 | // this is src to add: 146 | pugi::xpath_node_set add = doc.select_nodes("//add/src/folder/file"); 147 | for (pugi::xpath_node_set::const_iterator it = add.begin(); it != add.end(); ++it){ 148 | pugi::xpath_node node = *it; 149 | //std::cout << "folder name " << node.node().parent().attribute("name").value() << " : "; 150 | //std::cout << "src: " << node.node().child_value() << endl; 151 | } 152 | 153 | 154 | add = doc.select_nodes("//include/path"); 155 | for (pugi::xpath_node_set::const_iterator it = add.begin(); it != add.end(); ++it){ 156 | pugi::xpath_node node = *it; 157 | //std::cout << "include: " << node.node().child_value() << endl; 158 | } 159 | 160 | 161 | add = doc.select_nodes("//link/lib[@compiler='codeblocks']"); 162 | // this has to be smarter I guess... 163 | for (pugi::xpath_node_set::const_iterator it = add.begin(); it != add.end(); ++it){ 164 | pugi::xpath_node node = *it; 165 | //std::cout << "link: " << node.node().child_value() << endl; 166 | } 167 | 168 | 169 | } 170 | 171 | 172 | void ofAddon::clear(){ 173 | filesToFolders.clear(); 174 | srcFiles.clear(); 175 | libs.clear(); 176 | includePaths.clear(); 177 | name.clear(); 178 | } 179 | -------------------------------------------------------------------------------- /src/froebelGui/froebelContainer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // froebelContainer.cpp 3 | // OFPlay 4 | // 5 | // Created by Patricio Gonzalez Vivo on 12/5/12. 6 | // http://www.patriciogonzalezvivo.com 7 | // 8 | 9 | #include "froebelContainer.h" 10 | 11 | froebelContainer::froebelContainer(){ 12 | maxHeight = 200; 13 | 14 | totalBoxHeight = 0; 15 | totalLenght = 0; 16 | offsetY = 0.0; 17 | damp = 0.1; 18 | size = 30; 19 | 20 | slider.width = 5; 21 | sliderColor.setFromPalet(5); 22 | 23 | bEnable = false; 24 | bCheckList = false; 25 | bgColor.setFromPalet(0); 26 | } 27 | 28 | froebelContainer::~froebelContainer(){ 29 | for(int i = 0; i < elements.size(); i++){ 30 | delete elements[i]; 31 | } 32 | elements.clear(); 33 | } 34 | 35 | void froebelContainer::addElement( froebelTextBox *_newElement){ 36 | int lastY = 0; 37 | if (elements.size() > 0) 38 | lastY = elements[elements.size()-1]->y + elements[elements.size()-1]->height; 39 | 40 | _newElement->x = x; 41 | _newElement->y = lastY; 42 | 43 | elements.push_back(_newElement); 44 | 45 | adjustShape(); 46 | } 47 | 48 | void froebelContainer::adjustShape(){ 49 | width = 0; 50 | totalBoxHeight = 0; 51 | bool minWidthChange = false; 52 | for(int i = 0; i < elements.size(); i++){ 53 | 54 | if (totalBoxHeight < maxHeight) 55 | totalBoxHeight += elements[i]->height; 56 | 57 | float elementWidth = elements[i]->getTextBoundingBox().width; 58 | 59 | if (elementWidth > width){ 60 | width = elementWidth; 61 | minWidthChange = true; 62 | } 63 | } 64 | 65 | if (minWidthChange){ 66 | for(int i = 0; i < elements.size(); i++){ 67 | elements[i]->minWidth = width; 68 | } 69 | } 70 | } 71 | 72 | void froebelContainer::clear(){ 73 | for(int i = 0; i < elements.size(); i++){ 74 | delete elements[i]; 75 | } 76 | elements.clear(); 77 | width = 0; 78 | height = 0; 79 | } 80 | 81 | void froebelContainer::reset(){ 82 | for(int i = 0; i < elements.size(); i++){ 83 | elements[i]->reset(); 84 | } 85 | } 86 | 87 | bool froebelContainer::select(string _value){ 88 | for(int i = 0; i < elements.size(); i++){ 89 | if ( elements[i]->getText() == _value){ 90 | elements[i]->bSelected = true; 91 | return true; 92 | } 93 | } 94 | return false; 95 | } 96 | 97 | vector froebelContainer::getSelected(){ 98 | vector list; 99 | 100 | for(int i = 0; i < elements.size(); i++){ 101 | if ( elements[i]->bSelected ){ 102 | list.push_back( elements[i]->getText() ); 103 | } 104 | } 105 | 106 | return list; 107 | } 108 | 109 | void froebelContainer::update(){ 110 | bgColor.update(); 111 | 112 | slider.x = x; 113 | 114 | if (bEnable){ 115 | // Adjust the size 116 | // 117 | if (totalBoxHeight != height) 118 | height = ofLerp(height, totalBoxHeight, damp); 119 | 120 | // Recalculate the totalLenght of the elements 121 | // 122 | totalLenght = 0; 123 | for(int i = 0; i < elements.size(); i++){ 124 | totalLenght += elements[i]->height; 125 | } 126 | 127 | if (totalLenght > height){ 128 | ofPoint mouse = ofPoint(ofGetMouseX(),ofGetMouseY()); 129 | 130 | // Scrolling 131 | // 132 | if ( inside(mouse) ){ 133 | 134 | // if ( bCheckList || (getSelected().size() == 0) ){ 135 | 136 | float offsetPct = ofMap(mouse.y-y, 0,height,0.0,1.0,true); 137 | float diff = totalLenght - height; 138 | offsetY = ofLerp(offsetY, -diff * offsetPct, damp); 139 | 140 | // Slider Scrolling 141 | // 142 | slider.y = y + ofMap(offsetY,0,-totalLenght,0,height); 143 | slider.height = (height/totalLenght)*height; 144 | // } 145 | } 146 | 147 | } 148 | 149 | float previusY = 0; 150 | for(int i = 0; i < elements.size(); i++){ 151 | elements[i]->x = x ; 152 | elements[i]->y = y + previusY + offsetY; 153 | elements[i]->width = width; 154 | elements[i]->update(); 155 | 156 | previusY += elements[i]->height; 157 | } 158 | } else { 159 | if (totalBoxHeight != height) 160 | height = ofLerp(height, 0.0, damp); 161 | } 162 | } 163 | 164 | void froebelContainer::draw(){ 165 | 166 | ofFill(); 167 | ofSetColor(bgColor); 168 | ofRect( *this ); 169 | 170 | for(int i = 0; i < elements.size(); i++){ 171 | if (inside( elements[i]->getCenter() )){ 172 | elements[i]->draw(); 173 | } 174 | } 175 | 176 | if ( (totalLenght-5 >= maxHeight) ){ 177 | ofSetColor(sliderColor); 178 | ofRect(slider); 179 | } 180 | 181 | } 182 | 183 | bool froebelContainer::checkMousePressed(ofPoint _mouse){ 184 | bool rta = false; 185 | 186 | if (slider.inside(_mouse)){ 187 | rta = true; 188 | } else { 189 | 190 | int bClickedOn = -1; 191 | for(int i = 0; i < elements.size(); i++){ 192 | 193 | if ( inside( elements[i]->getCenter() )){ 194 | if (elements[i]->checkMousePressed(_mouse)){ 195 | bClickedOn = i; 196 | } 197 | } 198 | } 199 | 200 | if (bClickedOn != -1){ 201 | 202 | if ( !bCheckList ){ 203 | for(int i = 0; i < elements.size(); i++){ 204 | if ( i != bClickedOn ){ 205 | elements[i]->bSelected = false; 206 | } 207 | } 208 | } 209 | 210 | rta = true; 211 | } 212 | } 213 | 214 | return rta; 215 | } -------------------------------------------------------------------------------- /src/froebelGui/froebelFolderElement.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // froebelDirElement.cpp 3 | // OFPlay 4 | // 5 | // Created by Patricio Gonzalez Vivo on 12/5/12. 6 | // http://www.patriciogonzalezvivo.com 7 | // 8 | 9 | #include "froebelFolderElement.h" 10 | 11 | #include "Utils.h" 12 | 13 | froebelFolderElement::froebelFolderElement(){ 14 | subInfo = NULL; 15 | father = NULL; 16 | 17 | bLeftAlign = true; 18 | bChange = true; 19 | bEdge = false; 20 | bIcon = false; 21 | bSelected = false; 22 | bFixedSize = false; 23 | 24 | text = ""; 25 | prefix = ""; 26 | deliminater = "/"; 27 | rootPath = ""; 28 | 29 | minWidth = 0; 30 | maxWidth = 600; 31 | size = 40; 32 | nState = 0; 33 | 34 | containerBox.bCheckList = false; 35 | 36 | // STATE_PASSIVE 37 | // 38 | fgColor.addState(2); 39 | bgColor.addState(5); 40 | 41 | // STATE_HOVER 42 | // 43 | fgColor.addState(4); 44 | bgColor.addState(5); 45 | 46 | // STATE_ACTIVE 47 | // 48 | fgColor.addState(3); 49 | bgColor.addState(4); 50 | } 51 | 52 | void froebelFolderElement::reset(){ 53 | froebelTextBox::reset(); 54 | containerBox.reset(); 55 | } 56 | 57 | string froebelFolderElement::getText(){ 58 | string rta = text; 59 | 60 | for( int i = 0; i < containerBox.elements.size(); i++ ){ 61 | if ( containerBox.elements[i]->bSelected ){ 62 | rta += containerBox.elements[i]->getText(); 63 | break; 64 | } 65 | } 66 | 67 | return rta; 68 | } 69 | 70 | ofRectangle froebelFolderElement::getBoundingBox(){ 71 | ofRectangle rta; 72 | 73 | rta.set(*this); 74 | 75 | if (subInfo != NULL) 76 | rta.growToInclude(*subInfo); 77 | 78 | if (bSelected){ 79 | rta.growToInclude(containerBox); 80 | 81 | for (int i = 0; i < containerBox.elements.size(); i++){ 82 | if (inside(containerBox.elements[i]->getCenter())){ 83 | rta.growToInclude( containerBox.elements[i]->getBoundingBox() ); 84 | } 85 | } 86 | } 87 | 88 | return rta; 89 | } 90 | 91 | bool froebelFolderElement::checkMousePressed(ofPoint _mouse){ 92 | bool rta = false; 93 | 94 | if ( !bSelected ){ 95 | 96 | if ( inside(_mouse) ){ 97 | 98 | // Every time is clicked it re-populate it content 99 | // 100 | containerBox.clear(); 101 | ofDirectory folder(rootPath+text); 102 | folder.listDir(); 103 | for(int i=0; i < (int)folder.size();i++){ 104 | 105 | if (folder.getFile(i).isDirectory()){ 106 | 107 | string name = folder.getName(i); 108 | string path = rootPath+text+name; 109 | 110 | if (isAddonCore(name) || 111 | name == "build" || 112 | name == "bin" || 113 | name == "src" || 114 | name == "lib" || 115 | name == "libs" || 116 | name == "include" || 117 | name == "scripts" || 118 | name == "doc" || 119 | name == "docs"){ 120 | 121 | // Skip core addons folder because don't have a example inside 122 | // and src libs folders 123 | 124 | } else if ( isProjectFolder( path ) ){ 125 | froebelTextBox *newElement = new froebelTextBox(); 126 | newElement->font = font; 127 | newElement->setSizeAndShapes(size,3,5); 128 | newElement->setText(folder.getName(i)); 129 | 130 | newElement->fgColor.clear(); 131 | newElement->fgColor.addState(5); 132 | newElement->fgColor.addState(5); 133 | newElement->fgColor.addState(9); 134 | newElement->bgColor.clear(); 135 | newElement->bgColor.addState(0); 136 | newElement->bgColor.addState(1); 137 | newElement->bgColor.addState(5); 138 | 139 | newElement->update(); 140 | 141 | containerBox.addElement(newElement); 142 | 143 | } else { 144 | froebelFolderElement *newFolder = new froebelFolderElement(); 145 | newFolder->font = font; 146 | newFolder->setSizeAndShapes(size); 147 | newFolder->setText( folder.getName(i) + "/"); 148 | newFolder->rootPath = rootPath + text ; 149 | newFolder->fgColor.clear(); 150 | newFolder->fgColor.addState(5); 151 | newFolder->fgColor.addState(5); 152 | newFolder->fgColor.addState(9); 153 | newFolder->bgColor.clear(); 154 | newFolder->bgColor.addState(0); 155 | newFolder->bgColor.addState(1); 156 | newFolder->bgColor.addState(5); 157 | newFolder->containerBox.size = size; 158 | 159 | newFolder->father = &containerBox; 160 | 161 | newFolder->update(); 162 | 163 | containerBox.addElement(newFolder); 164 | } 165 | } 166 | } 167 | 168 | bSelected = true; 169 | bChange = true; 170 | rta = true; 171 | } 172 | 173 | } else { 174 | 175 | if ( containerBox.checkMousePressed(_mouse) ){ 176 | rta = true; 177 | } 178 | } 179 | 180 | return rta; 181 | } 182 | 183 | void froebelFolderElement::update(){ 184 | froebelTextBox::update(); 185 | 186 | containerBox.x = father->x + father->width; 187 | containerBox.y = father->y; 188 | containerBox.maxHeight = father->maxHeight; 189 | containerBox.bEnable = bSelected; 190 | 191 | containerBox.update(); 192 | } 193 | 194 | void froebelFolderElement::draw(){ 195 | 196 | if (bEdge) 197 | endingShape.color.set(bgColor); 198 | 199 | if (bIcon) 200 | iconShape.color.set(fgColor); 201 | 202 | 203 | // Render Elements 204 | // 205 | if ( bSelected ){ 206 | containerBox.draw(); 207 | } 208 | 209 | froebelTextBox::draw(); 210 | } -------------------------------------------------------------------------------- /config.make: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # CONFIGURE PROJECT MAKEFILE (optional) 3 | # This file is where we make project specific configurations. 4 | ################################################################################ 5 | 6 | ################################################################################ 7 | # OF ROOT 8 | # The location of your root openFrameworks installation 9 | # (default) OF_ROOT = ../../.. 10 | ################################################################################ 11 | # OF_ROOT = ../../.. 12 | 13 | ################################################################################ 14 | # PROJECT ROOT 15 | # The location of the project - a starting place for searching for files 16 | # (default) PROJECT_ROOT = . (this directory) 17 | # 18 | ################################################################################ 19 | # PROJECT_ROOT = . 20 | 21 | ################################################################################ 22 | # PROJECT SPECIFIC CHECKS 23 | # This is a project defined section to create internal makefile flags to 24 | # conditionally enable or disable the addition of various features within 25 | # this makefile. For instance, if you want to make changes based on whether 26 | # GTK is installed, one might test that here and create a variable to check. 27 | ################################################################################ 28 | # None 29 | 30 | ################################################################################ 31 | # PROJECT EXTERNAL SOURCE PATHS 32 | # These are fully qualified paths that are not within the PROJECT_ROOT folder. 33 | # Like source folders in the PROJECT_ROOT, these paths are subject to 34 | # exlclusion via the PROJECT_EXLCUSIONS list. 35 | # 36 | # (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) 37 | # 38 | # Note: Leave a leading space when adding list items with the += operator 39 | ################################################################################ 40 | # PROJECT_EXTERNAL_SOURCE_PATHS = 41 | 42 | ################################################################################ 43 | # PROJECT EXCLUSIONS 44 | # These makefiles assume that all folders in your current project directory 45 | # and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations 46 | # to look for source code. The any folders or files that match any of the 47 | # items in the PROJECT_EXCLUSIONS list below will be ignored. 48 | # 49 | # Each item in the PROJECT_EXCLUSIONS list will be treated as a complete 50 | # string unless teh user adds a wildcard (%) operator to match subdirectories. 51 | # GNU make only allows one wildcard for matching. The second wildcard (%) is 52 | # treated literally. 53 | # 54 | # (default) PROJECT_EXCLUSIONS = (blank) 55 | # 56 | # Will automatically exclude the following: 57 | # 58 | # $(PROJECT_ROOT)/bin% 59 | # $(PROJECT_ROOT)/obj% 60 | # $(PROJECT_ROOT)/%.xcodeproj 61 | # 62 | # Note: Leave a leading space when adding list items with the += operator 63 | ################################################################################ 64 | # PROJECT_EXCLUSIONS = 65 | 66 | ################################################################################ 67 | # PROJECT LINKER FLAGS 68 | # These flags will be sent to the linker when compiling the executable. 69 | # 70 | # (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs 71 | # 72 | # Note: Leave a leading space when adding list items with the += operator 73 | # 74 | # Currently, shared libraries that are needed are copied to the 75 | # $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to 76 | # add a runtime path to search for those shared libraries, since they aren't 77 | # incorporated directly into the final executable application binary. 78 | ################################################################################ 79 | # PROJECT_LDFLAGS=-Wl,-rpath=./libs 80 | 81 | ################################################################################ 82 | # PROJECT DEFINES 83 | # Create a space-delimited list of DEFINES. The list will be converted into 84 | # CFLAGS with the "-D" flag later in the makefile. 85 | # 86 | # (default) PROJECT_DEFINES = (blank) 87 | # 88 | # Note: Leave a leading space when adding list items with the += operator 89 | ################################################################################ 90 | # PROJECT_DEFINES = 91 | 92 | ################################################################################ 93 | # PROJECT CFLAGS 94 | # This is a list of fully qualified CFLAGS required when compiling for this 95 | # project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS 96 | # defined in your platform specific core configuration files. These flags are 97 | # presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. 98 | # 99 | # (default) PROJECT_CFLAGS = (blank) 100 | # 101 | # Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in 102 | # your platform specific configuration file will be applied by default and 103 | # further flags here may not be needed. 104 | # 105 | # Note: Leave a leading space when adding list items with the += operator 106 | ################################################################################ 107 | # PROJECT_CFLAGS = 108 | 109 | ################################################################################ 110 | # PROJECT OPTIMIZATION CFLAGS 111 | # These are lists of CFLAGS that are target-specific. While any flags could 112 | # be conditionally added, they are usually limited to optimization flags. 113 | # These flags are added BEFORE the PROJECT_CFLAGS. 114 | # 115 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. 116 | # 117 | # (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) 118 | # 119 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. 120 | # 121 | # (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) 122 | # 123 | # Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the 124 | # PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration 125 | # file will be applied by default and further optimization flags here may not 126 | # be needed. 127 | # 128 | # Note: Leave a leading space when adding list items with the += operator 129 | ################################################################################ 130 | # PROJECT_OPTIMIZATION_CFLAGS_RELEASE = 131 | # PROJECT_OPTIMIZATION_CFLAGS_DEBUG = 132 | 133 | ################################################################################ 134 | # PROJECT COMPILERS 135 | # Custom compilers can be set for CC and CXX 136 | # (default) PROJECT_CXX = (blank) 137 | # (default) PROJECT_CC = (blank) 138 | # Note: Leave a leading space when adding list items with the += operator 139 | ################################################################################ 140 | # PROJECT_CXX = 141 | # PROJECT_CC = 142 | -------------------------------------------------------------------------------- /src/ofApp.cpp: -------------------------------------------------------------------------------- 1 | #include "ofApp.h" 2 | 3 | //-------------------------------------------------------------- 4 | void testApp::setup(){ 5 | // ofEnableSmoothing(); 6 | ofEnableAlphaBlending(); 7 | ofSetVerticalSync(true); 8 | ofSetWindowShape(900,500); 9 | ofSetWindowTitle( "OFPlay" ); 10 | // ofSetLogLevel(OF_LOG_VERBOSE); 11 | ofSetDataPathRoot("../Resources/"); 12 | 13 | mScreen = NULL; 14 | logo.loadImage("OFPlay.png"); 15 | // textSeq.set(0,0,900,450); 16 | 17 | // First time?? 18 | // 19 | ofFile testFile("config.xml"); 20 | if (testFile.exists()){ 21 | searchForOF(); 22 | // } else { 23 | // textSeq.loadSequence("intro.xml"); 24 | } 25 | } 26 | 27 | 28 | //-------------------------------------------------------------- 29 | void testApp::update(){ 30 | 31 | if (mScreen != NULL){ 32 | mScreen->update(); 33 | } else { 34 | // textSeq.update(); 35 | // 36 | // if (textSeq.getLineNumber() == 3){ 37 | // ofDirectory testDir01("/Applications/Xcode.app"); 38 | // ofDirectory testDir02("/Developer/Applications/Xcode.app"); 39 | // 40 | // if (testDir01.exists() || testDir02.exists() ){ 41 | // textSeq.setLine(6); 42 | // } 43 | // } 44 | // 45 | // if (textSeq.getLineNumber() > 5){ 46 | // ofDirectory testDir01("/Applications/Xcode.app"); 47 | // ofDirectory testDir02("/Developer/Applications/Xcode.app"); 48 | // 49 | // if (testDir01.exists() || testDir02.exists() ){ 50 | // 51 | // } else { 52 | // textSeq.setLine(3); 53 | // } 54 | // } 55 | // 56 | // if (textSeq.getLineNumber() == 6){ 57 | // ofFile testFile("/usr/bin/git"); 58 | // if (testFile.exists()){ 59 | // textSeq.setLine(7); 60 | // } 61 | // } 62 | // 63 | // if (textSeq.bFinish) 64 | searchForOF(); 65 | } 66 | } 67 | 68 | void testApp::searchForOF(){ 69 | 70 | if (mScreen != NULL) 71 | delete mScreen; 72 | mScreen = NULL; 73 | 74 | // The XML will store basic information like the OF path 75 | // 76 | ofxXmlSettings XML; 77 | XML.loadFile("config.xml"); 78 | string appToRoot = XML.getValue("appToRoot", "../../../../"); 79 | string ofRoot = XML.getValue("ofRoot", "../../../"); 80 | string defaultLoc = XML.getValue("defaultNewProjectLocation", "apps/myApps"); 81 | 82 | string binPath; 83 | //------------------------------------- 84 | // calculate the bin path (../../../ on osx) and the sketch path (bin -> root - > defaultLoc) 85 | //------------------------------------- 86 | // if appToRoot is wrong, we have alot of issues. all these paths are used in this project: 87 | // 88 | #ifdef TARGET_OSX 89 | binPath = ofFilePath::getAbsolutePath(ofFilePath::join(ofFilePath::getCurrentWorkingDirectory(), "../../../")); 90 | #else 91 | binPath = ofFilePath::getCurrentExeDir(); 92 | #endif 93 | 94 | // Try to search using the appToRoot that by defaul search 4 levels down ( distance from a /bin ) 95 | // 96 | if ( !isOFFolder( ofFilePath::getAbsolutePath(ofFilePath::join( binPath, appToRoot)) ) ){ 97 | // Keep looping until found a OF path 98 | // 99 | while ( !isOFFolder(ofRoot)) { 100 | 101 | string command = ""; 102 | ofFileDialogResult res = ofSystemLoadDialog("OF project generator", "choose the folder of your OF install"); 103 | 104 | string result = res.filePath; 105 | convertWindowsToUnixPath(result); 106 | ofRoot = result + "/"; 107 | } 108 | 109 | } else { 110 | ofRoot = ofFilePath::getAbsolutePath( ofFilePath::join( binPath, appToRoot) ); 111 | } 112 | 113 | XML.setValue("appToRoot", appToRoot); 114 | XML.setValue("ofRoot", ofRoot ); 115 | XML.setValue("defaultNewProjectLocation", defaultLoc); 116 | XML.saveFile("config.xml"); 117 | 118 | // there's some issues internally in OF with non unix paths for OF root 119 | // 120 | setOFRoot( ofRoot ); 121 | 122 | mScreen = new mainScreenOFPlay(); 123 | mScreen->setup( ofRoot , defaultLoc, "newProject"); 124 | mScreen->update(); 125 | mScreen->resized(); 126 | } 127 | 128 | //-------------------------------------------------------------- 129 | void testApp::draw(){ 130 | ofBackground(230); 131 | 132 | if (mScreen != NULL){ 133 | mScreen->draw(); 134 | // } else { 135 | // ofSetColor(255); 136 | // textSeq.draw(); 137 | } 138 | } 139 | 140 | //-------------------------------------------------------------- 141 | void testApp::keyPressed(int key){ 142 | if (mScreen == NULL){ 143 | // if ( key == OF_KEY_RIGHT){ 144 | // textSeq.setNextLine(); 145 | // } else if ( key == OF_KEY_LEFT){ 146 | // textSeq.setPrevLine(); 147 | // } 148 | } else { 149 | mScreen->keyPressed(key); 150 | } 151 | } 152 | 153 | //-------------------------------------------------------------- 154 | void testApp::keyReleased(int key){ 155 | } 156 | 157 | //-------------------------------------------------------------- 158 | void testApp::mouseMoved(int x, int y ){ 159 | } 160 | 161 | //-------------------------------------------------------------- 162 | void testApp::mouseDragged(int x, int y, int button){ 163 | } 164 | 165 | //-------------------------------------------------------------- 166 | void testApp::mousePressed(int x, int y, int button){ 167 | ofPoint mouse = ofPoint(x, y); 168 | 169 | if (mScreen != NULL){ 170 | mScreen->mousePressed(mouse); 171 | } else { 172 | // int rta = -1; 173 | // 174 | // for (int i = 0; i < textSeq.size(); i++) { 175 | // if (textSeq.buttons[i].checkMousePressed(mouse)){ 176 | // rta = i; 177 | // } 178 | // } 179 | // 180 | // if (rta != -1){ 181 | // textSeq.setLine(rta); 182 | // } else if ( x > ofGetWidth()*0.5 ){ 183 | // textSeq.setNextLine(); 184 | // } else { 185 | // textSeq.setPrevLine(); 186 | // } 187 | } 188 | } 189 | 190 | //-------------------------------------------------------------- 191 | void testApp::mouseReleased(int x, int y, int button){ 192 | 193 | } 194 | 195 | //-------------------------------------------------------------- 196 | void testApp::windowResized(int w, int h){ 197 | if (mScreen != NULL) 198 | mScreen->resized(); 199 | } 200 | 201 | //-------------------------------------------------------------- 202 | void testApp::gotMessage(ofMessage msg){ 203 | 204 | } 205 | 206 | //-------------------------------------------------------------- 207 | void testApp::dragEvent(ofDragInfo dragInfo){ 208 | if (dragInfo.files.size() > 1){ 209 | 210 | } else if (dragInfo.files.size() == 1) { 211 | string open = dragInfo.files[0]; 212 | if (isProjectFolder(open)){ 213 | 214 | if (mScreen != NULL) 215 | mScreen->loadProject(open); 216 | } 217 | } 218 | } 219 | -------------------------------------------------------------------------------- /src/intro/SlideSequencer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // SlideSequencer.cpp 3 | // 4 | // Created by Patricio Gonzalez Vivo on 4/1/12. 5 | // Copyright (c) 2012 http://PatricioGonzalezVivo.com All rights reserved. 6 | // 7 | 8 | #include "SlideSequencer.h" 9 | 10 | SlideSequencer::SlideSequencer(){ 11 | currentLine = 0; 12 | desiredLine = 0; 13 | countDown = 0; 14 | 15 | set(0,0,ofGetWidth(),ofGetHeight()); 16 | 17 | imagePath = " "; 18 | 19 | text = NULL; 20 | textColor.addState(ofFloatColor(0.0,0.0)); 21 | textColor.addState(5); 22 | 23 | bFinish = false; 24 | } 25 | 26 | bool SlideSequencer::loadSequence(string _xmlFile){ 27 | bool success = false; 28 | 29 | ofxXmlSettings XML; 30 | if (XML.loadFile(_xmlFile)){ 31 | 32 | slides.clear(); 33 | buttons.clear(); 34 | 35 | float buttonSize = 15; 36 | 37 | XML.pushTag("sequence"); 38 | 39 | // DEFAULT VALUES 40 | // 41 | string defVerAlign = XML.getValue("default:vAlign", "MIDDLE"); 42 | if (defVerAlign == "TOP"){ 43 | defaultVertAlign = OF_TEXT_ALIGN_TOP; 44 | } else if ( defVerAlign == "BOTTOM"){ 45 | defaultVertAlign = OF_TEXT_ALIGN_BOTTOM; 46 | } else if ( defVerAlign == "MIDDLE"){ 47 | defaultVertAlign = OF_TEXT_ALIGN_MIDDLE; 48 | } 49 | string defHorAlign = XML.getValue("default:hAlign", "CENTER"); 50 | if (defHorAlign == "LEFT"){ 51 | defaultHoriAlign = OF_TEXT_ALIGN_LEFT; 52 | } else if ( defHorAlign == "RIGHT"){ 53 | defaultHoriAlign = OF_TEXT_ALIGN_RIGHT; 54 | } else if ( defHorAlign == "JUSTIFIED"){ 55 | defaultHoriAlign = OF_TEXT_ALIGN_JUSTIFIED; 56 | } else if ( defHorAlign == "CENTER"){ 57 | defaultHoriAlign = OF_TEXT_ALIGN_CENTER; 58 | } 59 | 60 | int totalSlides = XML.getNumTags("slide"); 61 | for(int i = 0; i < totalSlides; i++){ 62 | XML.pushTag("slide",i); 63 | Slide newSlide; 64 | 65 | // Image 66 | // 67 | newSlide.image = XML.getValue("image", "image.png"); 68 | 69 | // Text 70 | // 71 | int totalTextLines = XML.getNumTags("text"); 72 | for (int i = 0; i < totalTextLines; i++){ 73 | newSlide.text.push_back( XML.getValue("text", "NO TEXT FOUND", i) ); 74 | } 75 | string alignment = XML.getValue("hAlign", defHorAlign); 76 | if (alignment == "LEFT"){ 77 | newSlide.hAlign = OF_TEXT_ALIGN_LEFT; 78 | } else if ( alignment == "RIGHT"){ 79 | newSlide.hAlign = OF_TEXT_ALIGN_RIGHT; 80 | } else if ( alignment == "JUSTIFIED"){ 81 | newSlide.hAlign = OF_TEXT_ALIGN_JUSTIFIED; 82 | } else if ( alignment == "CENTER"){ 83 | newSlide.hAlign = OF_TEXT_ALIGN_CENTER; 84 | } 85 | alignment = XML.getValue("vAlign", defVerAlign); 86 | if (alignment == "TOP"){ 87 | newSlide.vAlign = OF_TEXT_ALIGN_TOP; 88 | } else if ( alignment == "BOTTOM"){ 89 | newSlide.vAlign = OF_TEXT_ALIGN_BOTTOM; 90 | } else if ( alignment == "MIDDLE"){ 91 | newSlide.vAlign = OF_TEXT_ALIGN_MIDDLE; 92 | } 93 | 94 | slides.push_back(newSlide); 95 | 96 | // Buttons 97 | // 98 | froebelShapeButton newButton; 99 | newButton.setShape(0, buttonSize); 100 | newButton.color.addState(ofColor(175)); 101 | newButton.color.addState(0); 102 | newButton.color.addState(5); 103 | newButton.textColor.set(0.0,0.0); 104 | buttons.push_back(newButton); 105 | 106 | XML.popTag(); 107 | } 108 | 109 | XML.popTag(); 110 | 111 | float totalWidth = buttons.size()*2.0*buttonSize; 112 | for(int i = 0; i < buttons.size(); i++){ 113 | buttons[i].x = x + width*0.5 - totalWidth*0.5 + buttonSize + buttonSize*i*2.0; 114 | buttons[i].y = 0;//y + height + buttonSize*0.5; 115 | } 116 | 117 | bFinish = false; 118 | setLine(0); 119 | 120 | } else { 121 | ofLog(OF_LOG_ERROR, "File " + ofToDataPath(_xmlFile) + " could not be opened" ); 122 | } 123 | 124 | return success; 125 | } 126 | 127 | void SlideSequencer::setNextPhrase(Slide &_slide ){ 128 | 129 | if (imagePath != _slide.image){ 130 | imagePath = _slide.image; 131 | image.loadImage(imagePath); 132 | } 133 | 134 | if (text != NULL) 135 | delete text; 136 | 137 | text = new TextBlock(); 138 | 139 | if (text != NULL){ 140 | float left = x+width*0.5-image.getWidth()*0.5; 141 | float top = y+height*0.5+image.getHeight()*0.5; 142 | 143 | text->set(left*0.5,top,width-left,height-top); 144 | text->loadFont("Inconsolata.otf", 15); 145 | text->setText( _slide.text ); 146 | text->setAlignment( _slide.hAlign, _slide.vAlign); 147 | } 148 | 149 | image.setAnchorPercent(0.5, 0.5); 150 | image.update(); 151 | } 152 | 153 | void SlideSequencer::setPrevLine(){ 154 | if ( currentLine > 0){ 155 | setLine(currentLine-1); 156 | } 157 | } 158 | 159 | void SlideSequencer::setNextLine(){ 160 | setLine(currentLine+1); 161 | } 162 | 163 | void SlideSequencer::setLine( unsigned int _nLine){ 164 | if ( _nLine < size() ){ 165 | 166 | if (_nLine != desiredLine ){ 167 | textColor.setState(0); 168 | desiredLine = _nLine; 169 | countDown = ofGetFrameRate(); 170 | 171 | for(int i = 0; i < buttons.size(); i++){ 172 | if (i == desiredLine){ 173 | buttons[i].bEnable = false; 174 | } else { 175 | buttons[i].bEnable = true; 176 | } 177 | } 178 | } 179 | 180 | } else { 181 | bFinish = true; 182 | } 183 | } 184 | 185 | void SlideSequencer::update(){ 186 | 187 | if ( slides.size() > 0 ){ 188 | textColor.update(); 189 | 190 | if (countDown == 0){ 191 | setNextPhrase( slides[desiredLine] ); 192 | currentLine = desiredLine; 193 | countDown = -1; 194 | textColor.setState(1); 195 | } else if ( countDown > 0){ 196 | countDown--; 197 | } 198 | 199 | for(int i = 0; i < buttons.size(); i++){ 200 | buttons[i].update(); 201 | } 202 | } 203 | } 204 | 205 | void SlideSequencer::draw(){ 206 | ofPushStyle(); 207 | if ( slides.size() > 0 ){ 208 | image.draw(x+width*0.5, y+height*0.5); 209 | 210 | if (text != NULL){ 211 | ofSetColor(textColor); 212 | text->draw(); 213 | } 214 | } 215 | 216 | ofPushMatrix(); 217 | ofTranslate(0, y+height); 218 | ofFill(); 219 | ofSetColor(255); 220 | for(int i = 0; i < buttons.size(); i++){ 221 | buttons[i].draw(); 222 | } 223 | 224 | ofPopMatrix(); 225 | 226 | ofPushStyle(); 227 | } -------------------------------------------------------------------------------- /src/froebelGui/froebelEditBox.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // froebelEditBox.cpp 3 | // OFPlay 4 | // 5 | // Created by Patricio Gonzalez Vivo on 12/2/12. 6 | // http://www.patriciogonzalezvivo.com 7 | // 8 | 9 | #include "froebelEditBox.h" 10 | 11 | froebelEditBox::froebelEditBox(){ 12 | subInfo = NULL; 13 | 14 | subInfo = NULL; 15 | 16 | bLeftAlign = true; 17 | bChange = true; 18 | bEdge = false; 19 | bIcon = false; 20 | bSelected = false; 21 | bFixedSize = false; 22 | 23 | text = ""; 24 | prefix = ""; 25 | deliminater = ""; 26 | 27 | maxWidth = 600; 28 | size = 40; 29 | nState = 0; 30 | 31 | bgColor.clear(); 32 | fgColor.clear(); 33 | 34 | // STATE_PASSIVE 35 | // 36 | fgColor.addState(2); 37 | bgColor.addState(5); 38 | 39 | // STATE_HOVER 40 | // 41 | fgColor.addState(9); 42 | bgColor.addState(5); 43 | 44 | // STATE_ACTIVE 45 | // 46 | fgColor.addState(5); 47 | bgColor.addState(4); 48 | 49 | // Specific 50 | // 51 | cursorPosition = 0; 52 | cursorx = 0; 53 | cursory = 0; 54 | bEnabled = false; 55 | bEditing = false; 56 | bDrawCursor = false; 57 | mouseDownInRect = false; 58 | } 59 | 60 | void froebelEditBox::enable(){ 61 | if(!bEnabled){ 62 | ofAddListener(ofEvents().mousePressed, this, &froebelEditBox::mousePressed); 63 | ofAddListener(ofEvents().mouseReleased, this, &froebelEditBox::mouseReleased); 64 | bEnabled = true; 65 | } 66 | } 67 | 68 | void froebelEditBox::disable(){ 69 | if(bEditing){ 70 | endEditing(); 71 | } 72 | 73 | if(bEnabled){ 74 | ofRemoveListener(ofEvents().mousePressed, this, &froebelEditBox::mousePressed); 75 | ofRemoveListener(ofEvents().mouseReleased, this, &froebelEditBox::mouseReleased); 76 | bEnabled = false; 77 | } 78 | 79 | } 80 | 81 | void froebelEditBox::beginEditing() { 82 | if(!bEditing){ 83 | ofAddListener(ofEvents().keyPressed, this, &froebelEditBox::keyPressed); 84 | ofSendMessage("textfieldIsActive"); 85 | bEditing = true; 86 | bDrawCursor = true; 87 | cursory = 0; 88 | cursorPosition = cursorx = text.size(); 89 | bSelected = true; 90 | } 91 | } 92 | 93 | void froebelEditBox::endEditing() { 94 | if(bEditing){ 95 | ofRemoveListener(ofEvents().keyPressed, this, &froebelEditBox::keyPressed); 96 | ofSendMessage("textfieldIsInactive"); 97 | ofNotifyEvent(textChanged, text, this); 98 | bEditing = false; 99 | bDrawCursor = false; 100 | bSelected = false; 101 | 102 | for (int i = 0; i < text.size(); i++){ 103 | int which = (int)text[i]; 104 | if ((which >= 48 && which <= 57) || 105 | (which >= 65 && which <= 90) || 106 | (which >= 97 && which <= 122)){ 107 | } else { 108 | text[i] = '_'; 109 | } 110 | } 111 | 112 | // Calculate the size of the text 113 | // 114 | ofRectangle textBox = font->getStringBoundingBox( displayText , 0, 0); 115 | 116 | if ( textBox.width + size >= width ){ 117 | 118 | if ( textBox.width + size <= maxWidth ){ 119 | 120 | // If it less that the max adjust the shape 121 | // 122 | width = size*0.5 + textBox.width + size; 123 | 124 | } else { 125 | 126 | // other wise break it baby 127 | // 128 | string _newText = displayText; 129 | vector < string > breakUp; 130 | breakUp = ofSplitString(_newText, deliminater); 131 | 132 | ofPoint pos; 133 | pos.set(0,0); 134 | 135 | displayText = ""; 136 | 137 | for (int i = 0; i < breakUp.size(); i++){ 138 | string text = breakUp[i]; 139 | if (i != breakUp.size() -1) text += deliminater; 140 | 141 | ofRectangle rect = font->getStringBoundingBox(text, pos.x, pos.y); 142 | 143 | if ((pos.x + rect.width) > maxWidth ){ 144 | displayText += "\n"; 145 | displayText += text; 146 | pos.x = rect.width; 147 | } else { 148 | displayText+= text; 149 | pos.x += rect.width; 150 | } 151 | } 152 | 153 | } 154 | 155 | textBox = font->getStringBoundingBox( displayText , 0, 0); 156 | width = size*0.5 + textBox.width + size; 157 | 158 | if ( textBox.height+size*0.5 > size ) { 159 | int nEdges = 0; 160 | while ( textBox.height+size > size*nEdges ) { 161 | nEdges++; 162 | height = size*nEdges; 163 | } 164 | } 165 | } else { 166 | width = textBox.width + size; 167 | height = size; 168 | } 169 | 170 | string returnText = getText(); 171 | ofNotifyEvent(focusLost, returnText); 172 | } 173 | } 174 | 175 | void froebelEditBox::draw(){ 176 | froebelTextBox::draw(); 177 | 178 | // Update Colors 179 | // 180 | fgColor.setState(nState); 181 | bgColor.setState(nState); 182 | fgColor.update(); 183 | bgColor.update(); 184 | 185 | if (bEdge) 186 | endingShape.color.set(bgColor); 187 | 188 | if (bIcon) 189 | iconShape.color.set(fgColor); 190 | 191 | ofPushMatrix(); 192 | ofPushStyle(); 193 | ofTranslate(x+size*0.5, y+size-13); 194 | 195 | if(bDrawCursor) { 196 | 197 | ofPushStyle(); 198 | float timeFrac = 0.5 * sin(3.0f * ofGetElapsedTimef()) + 0.5; 199 | 200 | ofColor col = fgColor; //ofGetStyle().color; 201 | 202 | ofSetColor(col.r * timeFrac, col.g * timeFrac, col.b * timeFrac); 203 | ofSetLineWidth(3.0f); 204 | 205 | float cursorPos = font->stringWidth(prefix + text.substr(0,cursorx) )+3; 206 | if ( bLeftAlign ){ 207 | ofLine(cursorPos, 13.7*cursory+2,cursorPos, 13.7*cursory-font->stringHeight("L")-2); 208 | } else { 209 | cursorPos = width - size + 3; 210 | 211 | if (bEdge) 212 | cursorPos -= size*0.5; 213 | 214 | if (bIcon) 215 | cursorPos -= size*0.5; 216 | 217 | ofLine(cursorPos, 13.7*cursory+2,cursorPos, 13.7*cursory-font->stringHeight("L")-2); 218 | } 219 | 220 | ofPopStyle(); 221 | } 222 | 223 | ofPopMatrix(); 224 | ofPopStyle(); 225 | 226 | } 227 | 228 | void froebelEditBox::mousePressed(ofMouseEventArgs& args){ 229 | mouseDownInRect = inside(args.x, args.y); 230 | } 231 | 232 | void froebelEditBox::mouseReleased(ofMouseEventArgs& args){ 233 | 234 | if( inside(args.x, args.y)) { 235 | if(!bEditing && mouseDownInRect){ 236 | beginEditing(); 237 | } 238 | } else if(bEditing){ 239 | endEditing(); 240 | } 241 | } 242 | 243 | void froebelEditBox::keyPressed(ofKeyEventArgs& args) { 244 | 245 | int key = args.key; 246 | if (key == OF_KEY_RETURN) { 247 | endEditing(); 248 | return; 249 | } 250 | 251 | if (key >=32 && key <=126) { 252 | text.insert(text.begin()+cursorPosition, key); 253 | cursorPosition++; 254 | } 255 | 256 | 257 | if (key==OF_KEY_BACKSPACE) { 258 | if (cursorPosition>0) { 259 | text.erase(text.begin()+cursorPosition-1); 260 | --cursorPosition; 261 | } 262 | } 263 | 264 | if (key==OF_KEY_DEL) { 265 | if (text.size() > cursorPosition) { 266 | text.erase(text.begin()+cursorPosition); 267 | } 268 | } 269 | 270 | if (key==OF_KEY_LEFT){ 271 | if (cursorPosition>0){ 272 | --cursorPosition; 273 | } 274 | } 275 | 276 | if (key==OF_KEY_RIGHT){ 277 | if (cursorPosition 0){ 285 | for (int i=0; ix = x; 69 | subInfo->y = y; 70 | subInfo->width = ofGetWidth() - size; 71 | subInfo->height = size; 72 | subInfo->font = font; 73 | subInfo->bFixedSize = true; 74 | subInfo->bLeftAlign = false; 75 | subInfo->setPrefix("<< "); 76 | subInfo->setText( _comment ); 77 | subInfo->setSizeAndShapes(size); 78 | subInfo->fgColor.clear(); 79 | subInfo->fgColor.addState(5); 80 | subInfo->fgColor.addState(5); 81 | subInfo->fgColor.addState(5); 82 | subInfo->bgColor.clear(); 83 | subInfo->bgColor.addState(0); 84 | subInfo->bgColor.addState(1); 85 | subInfo->bgColor.addState(0); 86 | } else { 87 | subInfo->setText( _comment ); 88 | } 89 | } 90 | 91 | void froebelTextBox::setPrefix( string _prefix ){ 92 | prefix = _prefix; 93 | bChange = true; 94 | } 95 | 96 | void froebelTextBox::setDivider( string _deliminater ){ 97 | deliminater = _deliminater; 98 | bChange = true; 99 | } 100 | 101 | void froebelTextBox::setText(string _text ){ 102 | text = _text; 103 | bChange = true; 104 | } 105 | 106 | void froebelTextBox::reset(){ 107 | bSelected = false; 108 | bChange = true; 109 | } 110 | 111 | string froebelTextBox::getText(){ 112 | return text; 113 | } 114 | 115 | ofRectangle froebelTextBox::getBoundingBox(){ 116 | ofRectangle rta; 117 | 118 | rta.set(*this); 119 | 120 | if (subInfo != NULL) 121 | rta.growToInclude(*subInfo); 122 | 123 | return rta; 124 | } 125 | 126 | float froebelTextBox::getVerticalMargins(){ 127 | float margins = size; 128 | 129 | if ( bEdge ) 130 | margins += size*0.5; 131 | 132 | if ( bIcon) 133 | margins += size*0.5; 134 | 135 | return margins; 136 | } 137 | 138 | ofRectangle froebelTextBox::getTextBoundingBox(){ 139 | return textBox; 140 | } 141 | 142 | void froebelTextBox::update(){ 143 | // Update dependences 144 | // 145 | if (subInfo != NULL){ 146 | subInfo->x = x; 147 | subInfo->y = y; 148 | subInfo->update(); 149 | } 150 | 151 | // Update STATE 152 | // 153 | if( bSelected ){ 154 | nState = STATE_ACTIVE; 155 | } else { 156 | if (inside(ofGetMouseX(), ofGetMouseY()) ){ 157 | nState= STATE_HOVER; 158 | } else { 159 | nState= STATE_PASIVE; 160 | } 161 | } 162 | 163 | // Update Colors 164 | // 165 | fgColor.setState(nState); 166 | bgColor.setState(nState); 167 | fgColor.update(); 168 | bgColor.update(); 169 | 170 | if (bEdge) 171 | endingShape.color.set(bgColor); 172 | 173 | if (bIcon) 174 | iconShape.color.set(fgColor); 175 | 176 | // Update Shape 177 | // 178 | if (bChange && font != NULL){ 179 | // Compose text 180 | // 181 | displayText = prefix + text; 182 | nEdges = 1; 183 | 184 | // Calculate the size of the text 185 | // 186 | textBox = font->getStringBoundingBox( displayText , 0, 0); 187 | textBox.width += getVerticalMargins(); 188 | 189 | bool doReScale = true; 190 | 191 | if ( bFixedSize){ 192 | if (textBox.width < width) 193 | doReScale = false; 194 | } 195 | 196 | if (doReScale){ 197 | 198 | if ( textBox.width <= maxWidth ){ 199 | 200 | // If it less that the max adjust the shape 201 | // 202 | if (textBox.width <= minWidth){ 203 | width = minWidth; 204 | } else { 205 | width = textBox.width; 206 | } 207 | 208 | height = size; 209 | 210 | } else { 211 | 212 | // other wise break 213 | // 214 | string _newText = displayText; 215 | vector < string > breakUp; 216 | breakUp = ofSplitString(_newText, deliminater); 217 | 218 | ofPoint pos; 219 | pos.set(0,0); 220 | 221 | displayText = ""; 222 | 223 | for (int i = 0; i < breakUp.size(); i++){ 224 | string text = breakUp[i]; 225 | if (i != breakUp.size() -1) text += deliminater; 226 | 227 | ofRectangle rect = font->getStringBoundingBox(text, pos.x, pos.y); 228 | 229 | if ((pos.x + rect.width) > maxWidth ){ 230 | displayText += "\n"; 231 | displayText += text; 232 | pos.x = rect.width; 233 | } else { 234 | displayText+= text; 235 | pos.x += rect.width; 236 | } 237 | } 238 | 239 | // Apply the breaking 240 | // 241 | textBox = font->getStringBoundingBox( displayText , 0, 0); 242 | textBox.width + getVerticalMargins(); 243 | width = textBox.width; 244 | height = size; 245 | if ( textBox.height+size*0.5 > size ) { 246 | while ( textBox.height+size > size*nEdges ) { 247 | nEdges++; 248 | height = size*nEdges; 249 | } 250 | } 251 | 252 | } 253 | } 254 | 255 | bChange = false; 256 | } 257 | } 258 | 259 | void froebelTextBox::draw(){ 260 | 261 | // If it have a sub textBox, draw it first 262 | // 263 | if (subInfo != NULL) 264 | subInfo->draw(); 265 | 266 | // Render 267 | // 268 | ofRectangle smallBox; 269 | smallBox.set(*this); 270 | smallBox.width = width; 271 | smallBox.height = height ; 272 | 273 | if ( bEdge ){ 274 | smallBox.width -= size*0.5; 275 | } 276 | 277 | ofPushMatrix(); 278 | ofPushStyle(); 279 | 280 | if(bFill) 281 | ofFill(); 282 | else 283 | ofNoFill(); 284 | 285 | ofSetColor(bgColor); 286 | ofRect(smallBox); 287 | ofTranslate(x, y); 288 | 289 | if ( bEdge ){ 290 | for(int i = 0; i < nEdges; i++){ 291 | endingShape.set(smallBox.width,size*0.5+size*i); 292 | endingShape.draw(); 293 | } 294 | } 295 | 296 | if ( bIcon ){ 297 | iconShape.set( width-size*0.5 ,size*0.5); 298 | iconShape.draw(); 299 | } 300 | 301 | if (font != NULL){ 302 | 303 | ofSetColor(fgColor); 304 | if (bLeftAlign){ 305 | font->drawString(displayText, size*0.5, size-13); 306 | } else { 307 | font->drawString(displayText, width-(-size*0.5)-textBox.width, size-13); 308 | } 309 | 310 | } 311 | 312 | ofPopMatrix(); 313 | ofPopStyle(); 314 | 315 | } 316 | 317 | bool froebelTextBox::checkMousePressed(ofPoint _mouse){ 318 | if (inside(_mouse)){ 319 | bSelected = !bSelected; 320 | nState = STATE_ACTIVE; 321 | return true; 322 | } 323 | return false; 324 | } -------------------------------------------------------------------------------- /src/projectGenerator/src/visualStudioProject.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #include "visualStudioProject.h" 5 | #include "Utils.h" 6 | 7 | string visualStudioProject::LOG_NAME = "visualStudioProjectFile"; 8 | 9 | void visualStudioProject::setup() { 10 | ; 11 | } 12 | 13 | bool visualStudioProject::createProjectFile(){ 14 | 15 | string project = ofFilePath::join(projectDir,projectName + ".vcxproj"); 16 | string user = ofFilePath::join(projectDir,projectName + ".vcxproj.user"); 17 | string solution = ofFilePath::join(projectDir,projectName + ".sln"); 18 | string filters = ofFilePath::join(projectDir, projectName + ".vcxproj.filters"); 19 | 20 | ofFile::copyFromTo(ofFilePath::join(templatePath,"emptyExample.vcxproj"),project,false, true); 21 | ofFile::copyFromTo(ofFilePath::join(templatePath,"emptyExample.vcxproj.user"),user, false, true); 22 | ofFile::copyFromTo(ofFilePath::join(templatePath,"emptyExample.sln"),solution, false, true); 23 | ofFile::copyFromTo(ofFilePath::join(templatePath,"emptyExample.vcxproj.filters"),filters, false, true); 24 | ofFile::copyFromTo(ofFilePath::join(templatePath,"icon.rc"), projectDir + "icon.rc", false, true); 25 | 26 | ofFile filterFile(filters); 27 | string temp = filterFile.readToBuffer(); 28 | pugi::xml_parse_result result = filterXmlDoc.load(temp.c_str()); 29 | if (result.status==pugi::status_ok) ofLogVerbose() << "loaded filter "; 30 | else ofLogVerbose() << "problem loading filter "; 31 | 32 | findandreplaceInTexfile(solution,"emptyExample",projectName); 33 | findandreplaceInTexfile(user,"emptyExample",projectName); 34 | findandreplaceInTexfile(project,"emptyExample",projectName); 35 | 36 | string relRoot = getOFRelPath(ofFilePath::removeTrailingSlash(projectDir)); 37 | if (relRoot != "../../../"){ 38 | 39 | string relRootWindows = relRoot; 40 | // let's make it windows friendly: 41 | for(int i = 0; i < relRootWindows.length(); i++) { 42 | if( relRootWindows[i] == '/' ) 43 | relRootWindows[i] = '\\'; 44 | } 45 | 46 | // sln has windows paths: 47 | findandreplaceInTexfile(solution, "..\\..\\..\\", relRootWindows); 48 | 49 | // vcx has unixy paths: 50 | //..\..\..\libs 51 | findandreplaceInTexfile(project, "../../../", relRoot); 52 | } 53 | 54 | return true; 55 | } 56 | 57 | 58 | bool visualStudioProject::loadProjectFile(){ 59 | 60 | ofFile project(projectDir + projectName + ".vcxproj"); 61 | if(!project.exists()){ 62 | ofLogError(LOG_NAME) << "error loading " << project.path() << " doesn't exist"; 63 | return false; 64 | } 65 | pugi::xml_parse_result result = doc.load(project); 66 | bLoaded = result.status==pugi::status_ok; 67 | return bLoaded; 68 | } 69 | 70 | 71 | bool visualStudioProject::saveProjectFile(){ 72 | 73 | string filters = projectDir + projectName + ".vcxproj.filters"; 74 | filterXmlDoc.save_file(filters.c_str()); 75 | 76 | 77 | return doc.save_file((projectDir + projectName + ".vcxproj").c_str()); 78 | } 79 | 80 | 81 | void visualStudioProject::appendFilter(string folderName){ 82 | 83 | 84 | fixSlashOrder(folderName); 85 | 86 | string uuid = generateUUID(folderName); 87 | 88 | string tag = "//ItemGroup[Filter]/Filter[@Include=\"" + folderName + "\"]"; 89 | pugi::xpath_node_set set = filterXmlDoc.select_nodes(tag.c_str()); 90 | if (set.size() > 0){ 91 | 92 | //pugi::xml_node node = set[0].node(); 93 | } else { 94 | 95 | 96 | pugi::xml_node node = filterXmlDoc.select_single_node("//ItemGroup[Filter]/Filter").node().parent(); 97 | pugi::xml_node nodeAdded = node.append_child("Filter"); 98 | nodeAdded.append_attribute("Include").set_value(folderName.c_str()); 99 | pugi::xml_node nodeAdded2 = nodeAdded.append_child("UniqueIdentifier"); 100 | 101 | uuid.insert(8,"-"); 102 | uuid.insert(8+4+1,"-"); 103 | uuid.insert(8+4+4+2,"-"); 104 | uuid.insert(8+4+4+4+3,"-"); 105 | 106 | //d8376475-7454-4a24-b08a-aac121d3ad6f 107 | 108 | string uuidAltered = "{" + uuid + "}"; 109 | nodeAdded2.append_child(pugi::node_pcdata).set_value(uuidAltered.c_str()); 110 | } 111 | } 112 | 113 | void visualStudioProject::addSrc(string srcFile, string folder){ 114 | 115 | fixSlashOrder(folder); 116 | fixSlashOrder(srcFile); 117 | 118 | vector < string > folderSubNames = ofSplitString(folder, "\\"); 119 | string folderName = ""; 120 | for (int i = 0; i < folderSubNames.size(); i++){ 121 | if (i != 0) folderName += "\\"; 122 | folderName += folderSubNames[i]; 123 | appendFilter(folderName); 124 | } 125 | 126 | if (ofIsStringInString(srcFile, ".h") || ofIsStringInString(srcFile, ".hpp")){ 127 | appendValue(doc, "ClInclude", "Include", srcFile); 128 | 129 | pugi::xml_node node = filterXmlDoc.select_single_node("//ItemGroup[ClInclude]").node(); 130 | pugi::xml_node nodeAdded = node.append_child("ClInclude"); 131 | nodeAdded.append_attribute("Include").set_value(srcFile.c_str()); 132 | nodeAdded.append_child("Filter").append_child(pugi::node_pcdata).set_value(folder.c_str()); 133 | 134 | } else { 135 | appendValue(doc, "ClCompile", "Include", srcFile); 136 | 137 | pugi::xml_node node = filterXmlDoc.select_single_node("//ItemGroup[ClCompile]").node(); 138 | pugi::xml_node nodeAdded = node.append_child("ClCompile"); 139 | nodeAdded.append_attribute("Include").set_value(srcFile.c_str()); 140 | nodeAdded.append_child("Filter").append_child(pugi::node_pcdata).set_value(folder.c_str()); 141 | 142 | } 143 | 144 | 145 | 146 | } 147 | 148 | void visualStudioProject::addInclude(string includeName){ 149 | 150 | 151 | fixSlashOrder(includeName); 152 | 153 | pugi::xpath_node_set source = doc.select_nodes("//ClCompile/AdditionalIncludeDirectories"); 154 | for (pugi::xpath_node_set::const_iterator it = source.begin(); it != source.end(); ++it){ 155 | pugi::xpath_node node = *it; 156 | string includes = node.node().first_child().value(); 157 | vector < string > strings = ofSplitString(includes, ";"); 158 | bool bAdd = true; 159 | for (int i = 0; i < (int)strings.size(); i++){ 160 | if (strings[i].compare(includeName) == 0){ 161 | bAdd = false; 162 | } 163 | } 164 | if (bAdd == true){ 165 | strings.push_back(includeName); 166 | string includesNew = unsplitString(strings, ";"); 167 | node.node().first_child().set_value(includesNew.c_str()); 168 | } 169 | 170 | } 171 | //appendValue(doc, "Add", "directory", includeName); 172 | } 173 | 174 | void visualStudioProject::addLibrary(string libraryName, LibType libType){ 175 | 176 | 177 | fixSlashOrder(libraryName); 178 | 179 | // ok first, split path and library name. 180 | size_t found = libraryName.find_last_of("\\"); 181 | string libFolder = libraryName.substr(0,found); 182 | string libName = libraryName.substr(found+1); 183 | 184 | // do the path, then the library 185 | 186 | // paths for libraries 187 | pugi::xpath_node_set source = doc.select_nodes("//Link/AdditionalLibraryDirectories"); 188 | for (pugi::xpath_node_set::const_iterator it = source.begin(); it != source.end(); ++it){ 189 | pugi::xpath_node node = *it; 190 | string includes = node.node().first_child().value(); 191 | vector < string > strings = ofSplitString(includes, ";"); 192 | bool bAdd = true; 193 | for (int i = 0; i < (int)strings.size(); i++){ 194 | if (strings[i].compare(libFolder) == 0){ 195 | bAdd = false; 196 | } 197 | } 198 | if (bAdd == true){ 199 | strings.push_back(libFolder); 200 | string libPathsNew = unsplitString(strings, ";"); 201 | node.node().first_child().set_value(libPathsNew.c_str()); 202 | } 203 | } 204 | 205 | // libs 206 | source = doc.select_nodes("//Link/AdditionalDependencies"); 207 | int platformCounter = 0; 208 | for (pugi::xpath_node_set::const_iterator it = source.begin(); it != source.end(); ++it){ 209 | 210 | // still ghetto, but getting better 211 | // TODO: iterate by 212 | // instead of making the weak assumption that VS projects do Debug|Win32 then Release|Win32 213 | 214 | if(libType != platformCounter){ 215 | platformCounter++; 216 | continue; 217 | } 218 | 219 | pugi::xpath_node node = *it; 220 | string includes = node.node().first_child().value(); 221 | vector < string > strings = ofSplitString(includes, ";"); 222 | bool bAdd = true; 223 | for (int i = 0; i < (int)strings.size(); i++){ 224 | if (strings[i].compare(libName) == 0){ 225 | bAdd = false; 226 | } 227 | } 228 | 229 | if (bAdd == true){ 230 | strings.push_back(libName); 231 | string libsNew = unsplitString(strings, ";"); 232 | node.node().first_child().set_value(libsNew.c_str()); 233 | } 234 | platformCounter++; 235 | 236 | } 237 | 238 | } 239 | 240 | void visualStudioProject::addAddon(ofAddon & addon){ 241 | for(int i=0;i<(int)addons.size();i++){ 242 | if(addons[i].name==addon.name) return; 243 | } 244 | 245 | addons.push_back(addon); 246 | 247 | for(int i=0;i<(int)addon.includePaths.size();i++){ 248 | ofLogVerbose() << "adding addon include path: " << addon.includePaths[i]; 249 | addInclude(addon.includePaths[i]); 250 | } 251 | 252 | // divide libs into debug and release libs 253 | // the most reliable would be to have seperate 254 | // folders for debug and release libs 255 | // i'm gonna start with a ghetto approach of just 256 | // looking for duplicate names except for a d.lib 257 | // at the end -> this is not great as many 258 | // libs compile with the d somewhere in the middle of the name... 259 | 260 | vector debugLibs; 261 | vector releaseLibs; 262 | 263 | vector possibleReleaseOrDebugOnlyLibs; 264 | 265 | for(int i = 0; i < addon.libs.size(); i++){ 266 | 267 | size_t found = 0; 268 | 269 | // get the full lib name 270 | #ifdef TARGET_WIN32 271 | found = addon.libs[i].find_last_of("\\"); 272 | #else 273 | found = addon.libs[i].find_last_of("/"); 274 | #endif 275 | 276 | string libName = addon.libs[i].substr(found+1); 277 | // get the first part of a lib name ie., libodd.lib -> libodd OR liboddd.lib -> liboddd 278 | found = libName.find_last_of("."); 279 | string firstPart = libName.substr(0,found); 280 | 281 | // check this lib name against every other lib name 282 | for(int j = 0; j < addon.libs.size(); j++){ 283 | // check if this lib name is contained within another lib name and is not the same name 284 | if(ofIsStringInString(addon.libs[j], firstPart) && addon.libs[i] != addon.libs[j]){ 285 | // if it is then add respecitive libs to debug and release 286 | if(!isInVector(addon.libs[j], debugLibs)){ 287 | //cout << "adding to DEBUG " << addon.libs[j] << endl; 288 | debugLibs.push_back(addon.libs[j]); 289 | } 290 | if(!isInVector(addon.libs[i], releaseLibs)){ 291 | //cout << "adding to RELEASE " << addon.libs[i] << endl; 292 | releaseLibs.push_back(addon.libs[i]); 293 | } 294 | // stop searching 295 | break; 296 | }else{ 297 | // if we only have a release or only have a debug lib 298 | // we'll want to add it to both releaseLibs and debugLibs 299 | // NB: all debug libs will get added to this vector, 300 | // but we catch that once all pairs have been added 301 | // since we cannot guarantee the order of parsing libs 302 | // although this is innefficient it fixes issues on linux 303 | if(!isInVector(addon.libs[i], possibleReleaseOrDebugOnlyLibs)){ 304 | possibleReleaseOrDebugOnlyLibs.push_back(addon.libs[i]); 305 | } 306 | // keep searching... 307 | } 308 | } 309 | } 310 | 311 | for(int i=0;i<(int)possibleReleaseOrDebugOnlyLibs.size();i++){ 312 | if(!isInVector(possibleReleaseOrDebugOnlyLibs[i], debugLibs) && !isInVector(possibleReleaseOrDebugOnlyLibs[i], releaseLibs)){ 313 | ofLogVerbose() << "RELEASE ONLY LIBS FOUND " << possibleReleaseOrDebugOnlyLibs[i] << endl; 314 | debugLibs.push_back(possibleReleaseOrDebugOnlyLibs[i]); 315 | releaseLibs.push_back(possibleReleaseOrDebugOnlyLibs[i]); 316 | } 317 | } 318 | 319 | for(int i=0;i<(int)debugLibs.size();i++){ 320 | ofLogVerbose() << "adding addon debug libs: " << debugLibs[i]; 321 | addLibrary(debugLibs[i], DEBUG_LIB); 322 | } 323 | 324 | for(int i=0;i<(int)releaseLibs.size();i++){ 325 | ofLogVerbose() << "adding addon release libs: " << releaseLibs[i]; 326 | addLibrary(releaseLibs[i], RELEASE_LIB); 327 | } 328 | 329 | for(int i=0;i<(int)addon.srcFiles.size(); i++){ 330 | ofLogVerbose() << "adding addon srcFiles: " << addon.srcFiles[i]; 331 | addSrc(addon.srcFiles[i],addon.filesToFolders[addon.srcFiles[i]]); 332 | } 333 | } 334 | -------------------------------------------------------------------------------- /OFPlay.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 304 | 305 | -------------------------------------------------------------------------------- /src/intro/TextBlock.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | 3 | Copyright (c) 2009, Luke Malcolm, www.lukemalcolm.com 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | ***********************************************************************/ 19 | 20 | #include "TextBlock.h" 21 | 22 | TextBlock::TextBlock(){ 23 | x = 0; 24 | y = 0; 25 | width = ofGetWidth(); 26 | height = ofGetHeight(); 27 | 28 | rawText = ""; 29 | 30 | hAlignment = OF_TEXT_ALIGN_CENTER; 31 | vAlignment = OF_TEXT_ALIGN_MIDDLE; 32 | } 33 | 34 | void TextBlock::loadFont(string _fontLocation, float _fontSize, int _dpi){ 35 | font.loadFont(_fontLocation, _fontSize, true, true); 36 | font.setGlobalDpi(_dpi); 37 | 38 | //Set up the blank space word 39 | // 40 | blankSpaceWord.rawWord = " "; 41 | blankSpaceWord.width = font.stringWidth ("x"); 42 | blankSpaceWord.height = font.stringHeight("i"); 43 | }; 44 | 45 | void TextBlock::setAlignment(horizontalAlignment _hAlignment , verticalAlignment _vAlignment){ 46 | hAlignment = _hAlignment; 47 | vAlignment = _vAlignment; 48 | }; 49 | 50 | void TextBlock::setText(string _inputText){ 51 | 52 | rawText = _inputText; 53 | 54 | // Process words extractint width in order to arrange the lines in the specify format 55 | // 56 | _subsChars(rawText); 57 | _loadWords(); 58 | 59 | _wrapTextX(width); 60 | } 61 | 62 | void TextBlock::setText(vector _inputText){ 63 | for (int i = 0; i < _inputText.size(); i++){ 64 | appendText( _inputText[i] ); 65 | } 66 | } 67 | 68 | void TextBlock::appendText(string _inputText){ 69 | 70 | if ( rawText == "" ){ 71 | rawText = _inputText; 72 | } else { 73 | string newLine = " NEWLINE " + _inputText; 74 | rawText.append(newLine); 75 | } 76 | 77 | _subsChars(rawText); 78 | _loadWords(); 79 | _wrapTextX(width); 80 | } 81 | 82 | // If the user specify a position and shape it will change the x, y, width and height of the based ofRectangle 83 | // variables. 84 | // 85 | void TextBlock::draw(float _x, float _y, float _w, float _h){ 86 | if (_h == -1){ 87 | _h = height; 88 | 89 | if (_w == -1) 90 | _w = width; 91 | } 92 | 93 | set(_x,_y,_w,_h); 94 | setText(rawText); 95 | 96 | draw(); 97 | } 98 | 99 | void TextBlock::draw(){ 100 | float yAlig = y; 101 | 102 | if (vAlignment == OF_TEXT_ALIGN_BOTTOM){ 103 | yAlig = y + height - getTextHeight(); 104 | } else if (vAlignment == OF_TEXT_ALIGN_MIDDLE){ 105 | yAlig = getCenter().y - getTextHeight()*0.5; 106 | } 107 | 108 | if (hAlignment == OF_TEXT_ALIGN_LEFT){ 109 | string strToDraw; 110 | int currentWordID; 111 | float drawX; 112 | float drawY; 113 | 114 | float currX = 0; 115 | 116 | if (words.size() > 0){ 117 | for(int l=0;l < lines.size(); l++){ 118 | for(int w=0;w < lines[l].wordsID.size(); w++){ 119 | 120 | currentWordID = lines[l].wordsID[w]; 121 | 122 | drawX = x + currX; 123 | drawY = yAlig + (font.getLineHeight() * (l + 1)); 124 | 125 | ofPushMatrix(); 126 | font.drawString(words[currentWordID].rawWord.c_str(), drawX, drawY); 127 | currX += words[currentWordID].width; 128 | ofPopMatrix(); 129 | 130 | } 131 | currX = 0; 132 | } 133 | } 134 | } else if (hAlignment == OF_TEXT_ALIGN_RIGHT){ 135 | string strToDraw; 136 | int currentWordID; 137 | float drawX; 138 | float drawY; 139 | 140 | float currX = 0; 141 | 142 | if (words.size() > 0) { 143 | 144 | for(int l=0;l < lines.size(); l++){ 145 | for(int w=lines[l].wordsID.size() - 1; w >= 0; w--){ 146 | 147 | currentWordID = lines[l].wordsID[w]; 148 | 149 | drawX = -currX - words[currentWordID].width; 150 | drawY = font.getLineHeight() * (l + 1); 151 | 152 | ofPushMatrix(); 153 | 154 | //Move to top left point using pre-scaled co-ordinates 155 | ofTranslate(x + width, yAlig, 0.0f); 156 | 157 | font.drawString(words[currentWordID].rawWord.c_str(), drawX, drawY); 158 | currX += words[currentWordID].width; 159 | 160 | ofPopMatrix(); 161 | 162 | } 163 | currX = 0; 164 | 165 | } 166 | } 167 | } else if (hAlignment == OF_TEXT_ALIGN_JUSTIFIED){ 168 | string strToDraw; 169 | int currentWordID; 170 | float drawX; 171 | float drawY; 172 | int spacesN; 173 | float nonSpaceWordWidth; 174 | float pixelsPerSpace; 175 | 176 | float currX = 0; 177 | 178 | if (words.size() > 0) { 179 | for(int l=0;l < lines.size(); l++){ 180 | //Find number of spaces and width of other words; 181 | spacesN = 0; 182 | nonSpaceWordWidth = 0; 183 | 184 | for(int w = 0; w < lines[l].wordsID.size(); w++){ 185 | currentWordID = lines[l].wordsID[w]; 186 | if (words[currentWordID].rawWord == " ") spacesN++; 187 | else nonSpaceWordWidth += words[currentWordID].width; 188 | } 189 | 190 | pixelsPerSpace = (width - x - nonSpaceWordWidth) / spacesN; 191 | 192 | for(int w=0;w < lines[l].wordsID.size(); w++){ 193 | currentWordID = lines[l].wordsID[w]; 194 | 195 | drawX = currX; 196 | drawY = font.getLineHeight() * (l + 1); 197 | 198 | ofPushMatrix(); 199 | //Move to top left point using pre-scaled co-ordinates 200 | ofTranslate(x, yAlig, 0.0f); 201 | 202 | if (words[currentWordID].rawWord != " ") { 203 | font.drawString(words[currentWordID].rawWord.c_str(), drawX, drawY); 204 | currX += words[currentWordID].width; 205 | } else { 206 | currX += pixelsPerSpace; 207 | } 208 | ofPopMatrix(); 209 | 210 | } 211 | currX = 0; 212 | 213 | } 214 | } 215 | } else if (hAlignment == OF_TEXT_ALIGN_CENTER ){ 216 | string strToDraw; 217 | int currentWordID; 218 | float drawX; 219 | float drawY; 220 | float lineWidth; 221 | 222 | float currX = 0; 223 | 224 | if (words.size() > 0) { 225 | for(int l=0;l < lines.size(); l++){ 226 | 227 | //Get the length of the line. 228 | lineWidth = 0; 229 | for(int w=0;w < lines[l].wordsID.size(); w++){ 230 | currentWordID = lines[l].wordsID[w]; 231 | lineWidth += words[currentWordID].width; 232 | } 233 | 234 | for(int w=0;w < lines[l].wordsID.size(); w++){ 235 | currentWordID = lines[l].wordsID[w]; 236 | 237 | drawX = -(lineWidth / 2) + currX; 238 | drawY = font.getLineHeight() * (l + 1); 239 | 240 | ofPushMatrix(); 241 | //Move to central point using pre-scaled co-ordinates 242 | ofTranslate(getCenter().x, yAlig, 0.0f); 243 | font.drawString(words[currentWordID].rawWord.c_str(), drawX, drawY); 244 | currX += words[currentWordID].width; 245 | ofPopMatrix(); 246 | 247 | } 248 | currX = 0; 249 | } 250 | } 251 | } 252 | } 253 | 254 | void TextBlock::_trimLineSpaces(){ 255 | if (words.size() > 0) { 256 | 257 | // Now delete all leading or ending spaces on each line 258 | // 259 | for(int l=0;l < lines.size(); l++){ 260 | 261 | // Delete the first word if it is a blank 262 | // 263 | if (lines[l].wordsID.size() > 0){ 264 | if (words[lines[l].wordsID[0]].rawWord == " ") lines[l].wordsID.erase(lines[l].wordsID.begin()); 265 | } 266 | 267 | // Delete the last word if it is a blank 268 | // 269 | if (lines[l].wordsID.size() > 0){ 270 | if (words[lines[l].wordsID[lines[l].wordsID.size() - 1]].rawWord == " ") lines[l].wordsID.erase(lines[l].wordsID.end() - 1); 271 | } 272 | } 273 | } 274 | 275 | } 276 | 277 | 278 | void TextBlock::_loadWords(){ 279 | 280 | istringstream iss(rawText); 281 | 282 | vector tokens; 283 | copy(istream_iterator(iss), 284 | istream_iterator(), 285 | back_inserter >(tokens)); 286 | 287 | words.clear(); 288 | wordBlock tmpWord; 289 | for(int i = 0; i < tokens.size(); i++){ 290 | tmpWord.rawWord = tokens.at(i); 291 | 292 | if ( "NEWLINE" == tmpWord.rawWord ){ 293 | tmpWord.rawWord = ""; 294 | tmpWord.width = width; 295 | tmpWord.height = 0.0;//font.stringHeight(tmpWord.rawWord)*0.5; 296 | } else { 297 | tmpWord.width = font.stringWidth(tmpWord.rawWord); 298 | tmpWord.height = font.stringHeight(tmpWord.rawWord); 299 | } 300 | words.push_back(tmpWord); 301 | 302 | // add spaces into the words vector if it is not the last word. 303 | // 304 | if (i != tokens.size()) 305 | words.push_back(blankSpaceWord); 306 | } 307 | 308 | for(int i=0;i < words.size(); i++){ 309 | ofLog(OF_LOG_VERBOSE, "Loaded word: %i, %s\n", i, words[i].rawWord.c_str()); 310 | } 311 | 312 | 313 | } 314 | 315 | int TextBlock::_getLinedWords(){ 316 | 317 | int wordCount = 0; 318 | 319 | if (words.size() > 0) { 320 | for(int l=0;l < lines.size(); l++){ 321 | wordCount += lines[l].wordsID.size(); 322 | } 323 | return wordCount; 324 | } 325 | else return 0; 326 | } 327 | 328 | bool TextBlock::_wrapTextForceLines(int linesN){ 329 | 330 | if (words.size() > 0) { 331 | 332 | if (linesN > words.size()) linesN = words.size(); 333 | 334 | float lineWidth = _getWidthOfWords() * (1.1f / (float)linesN); 335 | 336 | int curLines = 0; 337 | bool bGotLines; 338 | 339 | // keep increasing the line width until we get the desired number of lines. 340 | // 341 | while (!bGotLines){ 342 | curLines = _wrapTextX(lineWidth); 343 | if (curLines == linesN) return true; 344 | if (curLines > linesN) return false; 345 | lineWidth-=10; 346 | } 347 | } 348 | } 349 | 350 | int TextBlock::_wrapTextX(float lineWidth){ 351 | 352 | if (words.size() > 0) { 353 | 354 | lines.clear(); 355 | float runningWidth = 0.0f; 356 | bool newLine = true; 357 | lineBlock tmpLine; 358 | tmpLine.wordsID.clear(); 359 | int activeLine = 0; 360 | 361 | for(int i = 0; i < words.size(); i++){ 362 | 363 | // Add words to each line until it fills the total amount of width 364 | // available 365 | // 366 | runningWidth += words[i].width; 367 | 368 | if ((runningWidth <= lineWidth)){ 369 | newLine = false; 370 | } else { 371 | newLine = true; 372 | lines.push_back(tmpLine); 373 | tmpLine.wordsID.clear(); 374 | runningWidth = 0.0f + words[i].width;; 375 | activeLine++; 376 | } 377 | 378 | // Store in the line the id of the words 379 | // 380 | tmpLine.wordsID.push_back(i); 381 | } 382 | 383 | //Push in the final line. 384 | lines.push_back(tmpLine); 385 | _trimLineSpaces(); //Trim the leading and trailing spaces. 386 | 387 | } 388 | 389 | return lines.size(); 390 | 391 | } 392 | 393 | float TextBlock::_getWidthOfWords(){ 394 | float widthTotal = 0.0f; 395 | 396 | if (words.size() > 0) { 397 | for(int i=0;i < words.size(); i++) { 398 | widthTotal += words[i].width; 399 | } 400 | return widthTotal; 401 | } else { 402 | return 0.0f; 403 | } 404 | 405 | } 406 | 407 | float TextBlock::getTextWidth(){ 408 | int currentWordID; 409 | 410 | float currX = 0.0f; 411 | float maxWidth = 0.0f; 412 | 413 | if (words.size() > 0) { 414 | for(int l=0;l < lines.size(); l++){ 415 | for(int w=0;w < lines[l].wordsID.size(); w++){ 416 | currentWordID = lines[l].wordsID[w]; 417 | currX += words[currentWordID].width; 418 | } 419 | maxWidth = MAX(maxWidth, currX); 420 | currX = 0.0f; 421 | } 422 | return maxWidth ; 423 | } 424 | else return 0; 425 | } 426 | 427 | float TextBlock::getTextHeight(){ 428 | if (words.size() > 0) { 429 | return font.getLineHeight() * lines.size(); 430 | } 431 | else return 0; 432 | } -------------------------------------------------------------------------------- /src/mainScreenOFPlay.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // mainScreenOFPlay.cpp 3 | // OFPlay 4 | // 5 | // Created by Patricio Gonzalez Vivo on 12/7/12. 6 | // 7 | // 8 | 9 | #include "mainScreenOFPlay.h" 10 | 11 | mainScreenOFPlay::mainScreenOFPlay(){ 12 | project = NULL; 13 | statusEnergy = 0; 14 | } 15 | 16 | void mainScreenOFPlay::setup( string _ofRoot, string _defaultPath, string _name ){ 17 | 18 | ofRoot = _ofRoot; 19 | addonsPath = ofFilePath::getAbsolutePath(ofFilePath::join( ofRoot, "addons")); 20 | sketchPath = ofFilePath::getAbsolutePath(ofFilePath::join( ofRoot, _defaultPath)); 21 | 22 | convertWindowsToUnixPath( ofRoot ); 23 | convertWindowsToUnixPath( addonsPath ); 24 | convertWindowsToUnixPath( sketchPath ); 25 | 26 | //------------------------------------- GUI 27 | // 28 | defaultHeight = 34; 29 | logo.loadImage("OFPlay.png"); 30 | font.loadFont("Inconsolata.otf", 12, true,false,false,0.5,90); 31 | 32 | tab.set(0,0,ofGetWidth(),defaultHeight*2); 33 | tab.font.loadFont("Inconsolata.otf", 18, true,false,false,0.5,90); 34 | tab.addElement("MAKE"); 35 | tab.addElement("UPDATE"); 36 | tab.addElement("OPEN"); 37 | 38 | // PATH: 39 | // 40 | projectPath.x = defaultHeight; 41 | projectPath.y = tab.height + defaultHeight; 42 | projectPath.font = &font; 43 | projectPath.setSizeAndShapes(defaultHeight, 3); 44 | projectPath.setText( sketchPath ); 45 | projectPath.setPrefix("Path: "); 46 | projectPath.setDivider("/"); 47 | projectPath.setSubInfo("CHOOSE PATH"); 48 | projectPath.containerBox.bCheckList = false; 49 | ofAddListener(projectPath.focusLost, this, &mainScreenOFPlay::pathChange); 50 | 51 | loadFolder( "apps/" ); 52 | loadFolder( "examples/" ); 53 | loadFolder( "addons/" ); 54 | 55 | // NAME: 56 | // 57 | projectName.x = defaultHeight; 58 | projectName.y = projectPath.y + projectPath.height + defaultHeight*0.5; 59 | projectName.font = &font; 60 | projectName.setText( _name ); 61 | projectName.setPrefix("Name: "); 62 | projectName.setSizeAndShapes(defaultHeight, 3); 63 | projectName.setSubInfo("NEW PROJECT NAME"); 64 | 65 | projectName.enable(); 66 | ofAddListener(projectName.focusLost, this, &mainScreenOFPlay::nameChange); 67 | 68 | // LOAD PLATFORMS (check if it have the template) 69 | // 70 | platformsList.x = defaultHeight; 71 | platformsList.y = projectName.y + projectName.height + defaultHeight*0.5; 72 | platformsList.font = &font; 73 | platformsList.setSizeAndShapes(defaultHeight,3); 74 | platformsList.setPrefix("Platform: "); 75 | platformsList.setDivider(", "); 76 | platformsList.setSubInfo("TARGET PLATFORM"); 77 | platformsList.containerBox.maxHeight = 200; 78 | 79 | ofDirectory testDir(ofRoot+"scripts/win_cb"); 80 | if (testDir.exists()) 81 | platformsList.addElement("windows (codeblocks)",ofGetTargetPlatform()==OF_TARGET_WINGCC); 82 | 83 | testDir.open(ofRoot+"scripts/vs2010"); 84 | if (testDir.exists()) 85 | platformsList.addElement("windows (visualStudio)", ofGetTargetPlatform()==OF_TARGET_WINVS); 86 | 87 | testDir.open(ofRoot+"scripts/linux"); 88 | if (testDir.exists()){ 89 | platformsList.addElement("linux (codeblocks)",ofGetTargetPlatform()==OF_TARGET_LINUX); 90 | platformsList.addElement("linux64 (codeblocks)",ofGetTargetPlatform()==OF_TARGET_LINUX64); 91 | } 92 | 93 | testDir.open(ofRoot+"scripts/osx"); 94 | if (testDir.exists()) 95 | platformsList.addElement("osx (xcode)",ofGetTargetPlatform()==OF_TARGET_OSX); 96 | 97 | testDir.open(ofRoot+"scripts/ios"); 98 | if (testDir.exists()) 99 | platformsList.addElement("ios (xcode)",ofGetTargetPlatform()==OF_TARGET_IPHONE); 100 | 101 | platformsList.setText( platformsList.getSelectedAsString() ); 102 | 103 | // LOAD ADDONS 104 | // 105 | addonsList.x = defaultHeight; 106 | addonsList.y = platformsList.y + platformsList.height + defaultHeight*0.5; 107 | addonsList.maxWidth = 700; 108 | addonsList.font = &font; 109 | addonsList.setSizeAndShapes(defaultHeight,3); 110 | addonsList.setPrefix("Addons: "); 111 | addonsList.setDivider(", "); 112 | addonsList.setSubInfo("SELECTED ADDONS"); 113 | addonsList.containerBox.maxHeight = ofGetHeight() - addonsList.y - defaultHeight*3.0; 114 | loadAddons(); 115 | 116 | button.setShape(2, 76); 117 | button.color.set(0.0,0.0); 118 | button.font = &font; 119 | button.text = "NONE"; 120 | button.textColor.addState(3); 121 | button.textColor.addState(2); 122 | button.textColor.addState(4); 123 | 124 | // checkProjectState(); 125 | tab.setElement(0); 126 | } 127 | 128 | void mainScreenOFPlay::loadAddons(){ 129 | addonsList.containerBox.clear(); 130 | 131 | ofDirectory addonsFolder(addonsPath); 132 | addonsFolder.listDir(); 133 | for(int i=0; i < (int)addonsFolder.size();i++){ 134 | string addonName = addonsFolder.getName(i); 135 | 136 | if(addonName.find("ofx")==0){ 137 | if (isAddonCore(addonName)){ 138 | addonsList.addElement(addonName,false); 139 | } else { 140 | addonsList.addElement(addonName,false,4); 141 | } 142 | } 143 | } 144 | } 145 | 146 | void mainScreenOFPlay::loadFolder(string _path){ 147 | ofDirectory folder( ofFilePath::getAbsolutePath(ofFilePath::join(ofRoot,_path)) ); 148 | 149 | if (folder.exists()){ 150 | 151 | // Create Folder Element 152 | // 153 | froebelFolderElement *newFolder = new froebelFolderElement(); 154 | newFolder->font = &font; 155 | newFolder->setSizeAndShapes(defaultHeight); 156 | newFolder->setText(_path); 157 | newFolder->rootPath = ofRoot; 158 | newFolder->setPrefix(""); 159 | newFolder->fgColor.clear(); 160 | newFolder->fgColor.addState(5); 161 | newFolder->fgColor.addState(5); 162 | newFolder->fgColor.addState(9); 163 | newFolder->bgColor.clear(); 164 | newFolder->bgColor.addState(0); 165 | newFolder->bgColor.addState(0); 166 | newFolder->bgColor.addState(5); 167 | newFolder->containerBox.size = defaultHeight; 168 | 169 | newFolder->father = &projectPath.containerBox; 170 | 171 | newFolder->update(); 172 | 173 | // Added to the list 174 | // 175 | projectPath.containerBox.addElement( newFolder ); 176 | } 177 | } 178 | 179 | void mainScreenOFPlay::pathChange(string &_path){ 180 | 181 | string completePath = ofRoot + projectPath.getText(); 182 | 183 | addonsList.containerBox.reset(); 184 | addonsList.bChange = true; 185 | 186 | if (tab.getElementText() == "UPDATE" || tab.getElementText() == "OPEN"){ 187 | if ( isProjectFolder(completePath) ){ 188 | loadProject( completePath ); 189 | } else { 190 | projectPath.containerBox.reset(); 191 | projectPath.setText(ofRoot + projectPath.getText()); 192 | projectName.setText("newProject"); 193 | } 194 | } 195 | 196 | // checkProjectState(); 197 | } 198 | 199 | void mainScreenOFPlay::nameChange(string &_path){ 200 | addonsList.containerBox.reset(); 201 | addonsList.bChange = true; 202 | 203 | // checkProjectState(); 204 | } 205 | 206 | void mainScreenOFPlay::loadProject(string _path){ 207 | // Extract Name and Path 208 | // 209 | string folder = ""; 210 | 211 | extractFolderFromPath(_path,folder); 212 | // projectPath.containerBox.reset(); 213 | projectPath.setText(_path); 214 | projectName.setText(folder); 215 | 216 | setStatus("Project " + folder + " loaded "); 217 | 218 | // Extracting Addons ( from addons.make) 219 | // 220 | addonsList.containerBox.reset(); 221 | 222 | // Have addons.make?? 223 | // 224 | ofFile test; 225 | bool isAddons = test.open(_path + "/" + folder + "/addons.make"); 226 | if ( !isAddons ) 227 | return; 228 | 229 | // Add addons 230 | // 231 | ifstream fs( (_path + "/" + folder + "/addons.make").c_str()); 232 | int counter = 0; 233 | string line; 234 | string addonsAdded = ""; 235 | while(!(fs >> line).fail()){ 236 | 237 | if ( addonsList.select(line) ){ 238 | if (counter > 0) 239 | addonsAdded +=", "; 240 | addonsAdded += line; 241 | } else { 242 | cout << "Error: loading " << line << endl; 243 | } 244 | counter++; 245 | } 246 | fs.seekg(0,ios::beg); 247 | fs.clear(); 248 | fs.close(); 249 | 250 | addonsList.setText( addonsList.getSelectedAsString() ); 251 | } 252 | 253 | string mainScreenOFPlay::setTarget(int targ){ 254 | 255 | if(project){ 256 | delete project; 257 | } 258 | 259 | string target; 260 | switch(targ){ 261 | case OF_TARGET_OSX: 262 | project = new xcodeProject; 263 | target = "osx"; 264 | break; 265 | case OF_TARGET_WINGCC: 266 | project = new CBWinProject; 267 | target = "win_cb"; 268 | break; 269 | case OF_TARGET_WINVS: 270 | project = new visualStudioProject; 271 | target = "vs2010"; 272 | break; 273 | case OF_TARGET_IPHONE: 274 | project = new xcodeProject(); 275 | target = "ios"; 276 | break; 277 | case OF_TARGET_ANDROID: 278 | break; 279 | case OF_TARGET_LINUX: 280 | project = new CBLinuxProject; 281 | target = "linux"; 282 | break; 283 | case OF_TARGET_LINUX64: 284 | project = new CBLinuxProject; 285 | target = "linux64"; 286 | break; 287 | } 288 | 289 | project->setup(target); 290 | return target; 291 | } 292 | 293 | void mainScreenOFPlay::setStatus(string newStatus){ 294 | statusEnergy = 1; 295 | status = newStatus; 296 | statusSetTime = ofGetElapsedTimef(); 297 | } 298 | 299 | void mainScreenOFPlay::generateProject(){ 300 | 301 | vector targetsToMake; 302 | for(int i = 0; i < platformsList.containerBox.elements.size(); i++){ 303 | if ( platformsList.containerBox.elements[i]->bSelected == true ){ 304 | if (platformsList.containerBox.elements[i]->getText() == "windows (codeblocks)" ){ 305 | targetsToMake.push_back(OF_TARGET_WINGCC); 306 | } else if (platformsList.containerBox.elements[i]->getText() == "windows (visualStudio)"){ 307 | targetsToMake.push_back(OF_TARGET_WINVS); 308 | } else if (platformsList.containerBox.elements[i]->getText() == "linux (codeblocks)"){ 309 | targetsToMake.push_back(OF_TARGET_LINUX); 310 | } else if (platformsList.containerBox.elements[i]->getText() == "linux64 (codeblocks)"){ 311 | targetsToMake.push_back(OF_TARGET_LINUX64); 312 | } else if (platformsList.containerBox.elements[i]->getText() == "osx (xcode)"){ 313 | targetsToMake.push_back(OF_TARGET_OSX); 314 | } else if (platformsList.containerBox.elements[i]->getText() == "ios (xcode)"){ 315 | targetsToMake.push_back(OF_TARGET_IPHONE); 316 | } 317 | } 318 | } 319 | 320 | cout << targetsToMake.size() << endl; 321 | 322 | if( targetsToMake.size() == 0 ){ 323 | cout << "Error: makeNewProjectViaDialog - must specifiy a project to generate " <create(path)){ 341 | 342 | vector addons = addonsList.containerBox.getSelected(); 343 | for (int i = 0; i < addons.size(); i++){ 344 | ofAddon addon; 345 | addon.pathToOF = getOFRelPath(path); 346 | addon.fromFS(ofFilePath::join(addonsPath, addons[i]),target); 347 | project->addAddon(addon); 348 | } 349 | 350 | project->save(true); 351 | } 352 | 353 | setStatus("generated: " + projectPath.getText() + "/" + projectName.getText() + " for " + platformsList.containerBox.getSelected()[i]); 354 | } 355 | 356 | // checkProjectState(); 357 | printf("done with project generation \n"); 358 | } 359 | 360 | void mainScreenOFPlay::update(){ 361 | tab.x = 0; 362 | tab.y = 0; 363 | tab.update(); 364 | 365 | projectPath.x = defaultHeight; 366 | projectPath.y = tab.y + tab.height + defaultHeight; 367 | projectPath.update(); 368 | 369 | ofRectangle prev = projectPath.getBoundingBox(); 370 | 371 | if ( tab.getElementText() == "MAKE"){ 372 | projectPath.subInfo->setText("CHOOSE A DIRECTORY"); 373 | 374 | projectName.x = prev.x; 375 | projectName.y = ofLerp(projectName.y,prev.y + prev.height + defaultHeight*0.5,0.1); 376 | projectName.update(); 377 | projectName.enable(); 378 | projectName.subInfo->setText("NEW PROJECT NAME"); 379 | prev = projectName.getBoundingBox(); 380 | 381 | platformsList.x = prev.x; 382 | platformsList.y = ofLerp(platformsList.y, prev.y + prev.height + defaultHeight*0.5,0.1); 383 | platformsList.update(); 384 | 385 | prev = platformsList.getBoundingBox(); 386 | addonsList.x = prev.x; 387 | addonsList.y = ofLerp(addonsList.y, prev.y + prev.height + defaultHeight*0.5,0.1); 388 | addonsList.update(); 389 | 390 | } else if ( tab.getElementText() == "UPDATE"){ 391 | projectPath.subInfo->setText("CHOSE A PROJECT FOLDER OR DRAG ONE"); 392 | 393 | projectName.x = prev.x; 394 | projectName.y = ofLerp(projectName.y,prev.y + prev.height + defaultHeight*0.5,0.1); 395 | projectName.update(); 396 | projectName.disable(); 397 | projectName.subInfo->setText("PROJECT TO BE UPDATE"); 398 | prev = projectName.getBoundingBox(); 399 | 400 | platformsList.x = prev.x; 401 | platformsList.y = ofLerp(platformsList.y, prev.y + prev.height + defaultHeight*0.5,0.1); 402 | platformsList.update(); 403 | 404 | prev = platformsList.getBoundingBox(); 405 | addonsList.x = prev.x; 406 | addonsList.y = ofLerp(addonsList.y, prev.y + prev.height + defaultHeight*0.5,0.1); 407 | addonsList.update(); 408 | } else { 409 | projectPath.subInfo->setText("PICK A PROJECT"); 410 | 411 | projectName.x = prev.x; 412 | projectName.y = ofLerp(projectName.y,prev.y + prev.height + defaultHeight*0.5,0.1); 413 | projectName.update(); 414 | projectName.disable(); 415 | projectName.subInfo->setText("PROJECT TO BE OPEN"); 416 | prev = projectName.getBoundingBox(); 417 | } 418 | 419 | button.text = tab.getElementText(); 420 | button.update(); 421 | 422 | float diff = ofGetElapsedTimef()- statusSetTime; 423 | if (diff > 3){ 424 | statusEnergy *= 0.99;; 425 | } 426 | } 427 | 428 | void mainScreenOFPlay::draw(){ 429 | tab.draw(); 430 | 431 | projectPath.draw(); 432 | projectName.draw(); 433 | 434 | if ( tab.getElementText() == "MAKE" || tab.getElementText() == "UPDATE"){ 435 | addonsList.draw(); 436 | platformsList.draw(); 437 | } 438 | 439 | ofSetColor(255); 440 | logo.draw(ofGetWidth() - defaultHeight - logo.getWidth(),ofGetHeight() - defaultHeight - logo.getHeight()); 441 | button.draw(); 442 | 443 | ofFill(); 444 | ofSetColor(0 + 220 * (1-statusEnergy),0 + 220 * (1-statusEnergy),0 + 220 * (1-statusEnergy)); 445 | ofRect(0,ofGetHeight(), ofGetWidth(), -25); 446 | ofSetColor(255,255,255, 255 * statusEnergy); 447 | ofDrawBitmapString(status, 10,ofGetHeight()-8); 448 | } 449 | 450 | void mainScreenOFPlay::keyPressed(int key){ 451 | if ( key == OF_KEY_RIGHT){ 452 | if (tab.getElementText() == "MAKE"){ 453 | //string completePath = projectPath.getText() + "/" + projectName.getText(); 454 | //projectPath.setText(completePath); 455 | } 456 | tab.setNext(); 457 | } else if ( key == OF_KEY_LEFT){ 458 | tab.setPrev(); 459 | } 460 | } 461 | 462 | void mainScreenOFPlay::mousePressed(ofPoint _mouse){ 463 | if ( projectPath.checkMousePressed( _mouse ) ){ 464 | 465 | if (tab.getElementText() == "MAKE"){ 466 | projectPath.bSelected = false; 467 | 468 | string command = ""; 469 | ofDirectory dir(ofFilePath::join(getOFRoot(),sketchPath)); 470 | 471 | if (!dir.exists()){ 472 | dir.create(); 473 | } 474 | 475 | #ifdef TARGET_WIN32 476 | ofFileDialogResult res = ofSystemLoadDialog("please select sketch folder", true, windowsFromUnixPath(dir.path())); 477 | #else 478 | ofFileDialogResult res = ofSystemLoadDialog("please select sketch folder", true, dir.path()); 479 | #endif 480 | if (res.bSuccess){ 481 | string result = res.filePath; 482 | convertWindowsToUnixPath(result); 483 | projectPath.setText(result); 484 | setStatus("path set to: " + result); 485 | } 486 | } else { 487 | projectPath.bSelected = true; 488 | } 489 | 490 | 491 | projectName.bSelected = false; 492 | platformsList.bSelected = false; 493 | addonsList.bSelected = false; 494 | 495 | } else if ( addonsList.checkMousePressed(_mouse)){ 496 | projectPath.bSelected = false; 497 | projectName.bSelected = false; 498 | platformsList.bSelected = false; 499 | addonsList.bSelected = true; 500 | } else if ( platformsList.checkMousePressed(_mouse)){ 501 | projectPath.bSelected = false; 502 | projectName.bSelected = false; 503 | platformsList.bSelected = true; 504 | addonsList.bSelected = false; 505 | } else if ( button.checkMousePressed(_mouse)){ 506 | projectPath.bSelected = false; 507 | projectName.bSelected = false; 508 | platformsList.bSelected = false; 509 | addonsList.bSelected = false; 510 | 511 | if (tab.getElementText() == "MAKE" || tab.getElementText() == "UPDATE"){ 512 | generateProject(); 513 | } else { 514 | string path = "open " + projectPath.getText() + "/"+ projectName.getText() + "/" + projectName.getText() + ".xcodeproj"; 515 | system( path.c_str() ); 516 | } 517 | 518 | } else if (tab.checkMousePressed(_mouse)){ 519 | platformsList.bSelected = false; 520 | addonsList.bSelected = false; 521 | projectPath.bSelected = false; 522 | projectName.bSelected = false; 523 | } else { 524 | platformsList.bSelected = false; 525 | addonsList.bSelected = false; 526 | projectPath.bSelected = false; 527 | projectName.bSelected = false; 528 | } 529 | } 530 | 531 | void mainScreenOFPlay::resized(){ 532 | tab.width = ofGetWidth(); 533 | 534 | projectPath.subInfo->width = ofGetWidth() - defaultHeight * 2.0; 535 | 536 | projectName.subInfo->width = ofGetWidth() - defaultHeight * 2.0; 537 | 538 | platformsList.subInfo->width = ofGetWidth() - defaultHeight * 2.0; 539 | addonsList.subInfo->width = ofGetWidth() - defaultHeight * 2.0; 540 | 541 | addonsList.containerBox.maxHeight = ofGetHeight() - addonsList.y - defaultHeight*3.0; 542 | addonsList.containerBox.adjustShape(); 543 | 544 | button.x = ofGetWidth() - defaultHeight - logo.getWidth()*0.535 + button.size; 545 | button.y = ofGetHeight() - defaultHeight - logo.getHeight() + button.size*0.5 + 2; 546 | } -------------------------------------------------------------------------------- /src/projectGenerator/src/Utils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Utils.cpp 3 | * 4 | * Created on: 28/12/2011 5 | * Author: arturo 6 | */ 7 | 8 | #include "Utils.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include "Poco/HMACEngine.h" 23 | #include "Poco/MD5Engine.h" 24 | using Poco::DigestEngine; 25 | using Poco::HMACEngine; 26 | using Poco::MD5Engine; 27 | 28 | 29 | 30 | #ifdef TARGET_WIN32 31 | #include 32 | #define GetCurrentDir _getcwd 33 | #elif defined(TARGET_LINUX) 34 | #include 35 | #define GetCurrentDir getcwd 36 | #else 37 | #include /* _NSGetExecutablePath */ 38 | #include /* PATH_MAX */ 39 | #endif 40 | 41 | 42 | using namespace Poco; 43 | 44 | #include "ofUtils.h" 45 | 46 | 47 | string generateUUID(string input){ 48 | 49 | std::string passphrase("openFrameworks"); // HMAC needs a passphrase 50 | 51 | HMACEngine hmac(passphrase); // we'll compute a MD5 Hash 52 | hmac.update(input); 53 | 54 | const DigestEngine::Digest& digest = hmac.digest(); // finish HMAC computation and obtain digest 55 | std::string digestString(DigestEngine::digestToHex(digest)); // convert to a string of hexadecimal numbers 56 | 57 | return digestString; 58 | } 59 | 60 | 61 | 62 | 63 | 64 | void findandreplace( std::string& tInput, std::string tFind, std::string tReplace ) { 65 | size_t uPos = 0; 66 | size_t uFindLen = tFind.length(); 67 | size_t uReplaceLen = tReplace.length(); 68 | 69 | if( uFindLen == 0 ){ 70 | return; 71 | } 72 | 73 | for( ;(uPos = tInput.find( tFind, uPos )) != std::string::npos; ){ 74 | tInput.replace( uPos, uFindLen, tReplace ); 75 | uPos += uReplaceLen; 76 | } 77 | 78 | } 79 | 80 | 81 | std::string LoadFileAsString(const std::string & fn) 82 | { 83 | std::ifstream fin(fn.c_str()); 84 | 85 | if(!fin) 86 | { 87 | // throw exception 88 | } 89 | 90 | std::ostringstream oss; 91 | oss << fin.rdbuf(); 92 | 93 | return oss.str(); 94 | } 95 | 96 | void findandreplaceInTexfile (string fileName, std::string tFind, std::string tReplace ){ 97 | if( ofFile::doesFileExist(fileName) ){ 98 | 99 | std::ifstream t(ofToDataPath(fileName).c_str()); 100 | std::stringstream buffer; 101 | buffer << t.rdbuf(); 102 | string bufferStr = buffer.str(); 103 | t.close(); 104 | findandreplace(bufferStr, tFind, tReplace); 105 | ofstream myfile; 106 | myfile.open (ofToDataPath(fileName).c_str()); 107 | myfile << bufferStr; 108 | myfile.close(); 109 | 110 | /* 111 | std::ifstream ifile(ofToDataPath(fileName).c_str(),std::ios::binary); 112 | ifile.seekg(0,std::ios_base::end); 113 | long s=ifile.tellg(); 114 | char *buffer=new char[s]; 115 | ifile.seekg(0); 116 | ifile.read(buffer,s); 117 | ifile.close(); 118 | std::string txt(buffer,s); 119 | delete[] buffer; 120 | findandreplace(txt, tFind, tReplace); 121 | std::ofstream ofile(ofToDataPath(fileName).c_str()); 122 | ofile.write(txt.c_str(),txt.size()); 123 | */ 124 | //return 0; 125 | } else { 126 | ; // some error checking here would be good. 127 | } 128 | } 129 | 130 | 131 | 132 | 133 | bool doesTagAndAttributeExist(pugi::xml_document & doc, string tag, string attribute, string newValue){ 134 | char xpathExpressionExists[1024]; 135 | sprintf(xpathExpressionExists, "//%s[@%s='%s']", tag.c_str(), attribute.c_str(), newValue.c_str()); 136 | //cout < 0){ // for some reason we get nulls here? 153 | // ...delete the existing node 154 | cout << "DELETING: " << node.node().name() << ": " << " " << node.node().attribute(attribute.c_str()).value() << endl; 155 | node.node().parent().remove_child(node.node()); 156 | } 157 | } 158 | 159 | if (!doesTagAndAttributeExist(doc, tag, attribute, newValue)){ 160 | // otherwise, add it please: 161 | char xpathExpression[1024]; 162 | sprintf(xpathExpression, "//%s[@%s]", tag.c_str(), attribute.c_str()); 163 | //cout << xpathExpression << endl; 164 | pugi::xpath_node_set add = doc.select_nodes(xpathExpression); 165 | pugi::xml_node node = add[add.size()-1].node(); 166 | pugi::xml_node nodeAdded = node.parent().append_copy(node); 167 | nodeAdded.attribute(attribute.c_str()).set_value(newValue.c_str()); 168 | return nodeAdded; 169 | }else{ 170 | return pugi::xml_node(); 171 | } 172 | 173 | } 174 | 175 | // todo -- this doesn't use ofToDataPath -- so it's broken a bit. can we fix? 176 | void getFilesRecursively(const string & path, vector < string > & fileNames){ 177 | 178 | ofDirectory dir; 179 | 180 | //ofLogVerbose() << "in getFilesRecursively "<< path << endl; 181 | 182 | dir.listDir(path); 183 | for (int i = 0; i < dir.size(); i++){ 184 | ofFile temp(dir.getFile(i)); 185 | if (dir.getName(i) == ".svn") continue; // ignore svn 186 | if (temp.isFile()){ 187 | fileNames.push_back(dir.getPath(i)); 188 | } else if (temp.isDirectory()){ 189 | getFilesRecursively(dir.getPath(i), fileNames); 190 | } 191 | } 192 | //folderNames.push_back(path); 193 | 194 | } 195 | 196 | static vector platforms; 197 | bool isFolderNotCurrentPlatform(string folderName, string platform){ 198 | if( platforms.size() == 0 ){ 199 | platforms.push_back("osx"); 200 | platforms.push_back("win_cb"); 201 | platforms.push_back("vs2010"); 202 | platforms.push_back("ios"); 203 | platforms.push_back("linux"); 204 | platforms.push_back("linux64"); 205 | platforms.push_back("android"); 206 | platforms.push_back("iphone"); 207 | } 208 | 209 | for(int i = 0; i < platforms.size(); i++){ 210 | if( folderName == platforms[i] && folderName != platform ){ 211 | return true; 212 | } 213 | } 214 | 215 | return false; 216 | } 217 | 218 | void splitFromLast(string toSplit, string deliminator, string & first, string & second){ 219 | size_t found = toSplit.find_last_of(deliminator.c_str()); 220 | first = toSplit.substr(0,found); 221 | second = toSplit.substr(found+1); 222 | } 223 | 224 | void splitFromFirst(string toSplit, string deliminator, string & first, string & second){ 225 | size_t found = toSplit.find(deliminator.c_str()); 226 | first = toSplit.substr(0,found ); 227 | second = toSplit.substr(found+deliminator.size()); 228 | } 229 | 230 | 231 | void getFoldersRecursively(const string & path, vector < string > & folderNames, string platform){ 232 | ofDirectory dir; 233 | dir.listDir(path); 234 | for (int i = 0; i < dir.size(); i++){ 235 | ofFile temp(dir.getFile(i)); 236 | if (temp.isDirectory() && isFolderNotCurrentPlatform(temp.getFileName(), platform) == false ){ 237 | getFoldersRecursively(dir.getPath(i), folderNames, platform); 238 | } 239 | } 240 | folderNames.push_back(path); 241 | } 242 | 243 | 244 | 245 | void getLibsRecursively(const string & path, vector < string > & libFiles, vector < string > & libLibs, string platform ){ 246 | 247 | 248 | 249 | 250 | if (ofFile::doesFileExist(ofFilePath::join(path, "libsorder.make"))){ 251 | 252 | bool platformFound = false; 253 | 254 | #ifdef TARGET_WIN32 255 | vector splittedPath = ofSplitString(path,"\\"); 256 | #else 257 | vector splittedPath = ofSplitString(path,"/"); 258 | #endif 259 | 260 | 261 | if(platform!=""){ 262 | for(int j=0;j<(int)splittedPath.size();j++){ 263 | if(splittedPath[j]==platform){ 264 | platformFound = true; 265 | // break; 266 | } 267 | } 268 | } 269 | 270 | 271 | if (platformFound == true){ 272 | vector < string > libsInOrder; 273 | ofFile libsorderMake(ofFilePath::join(path, "libsorder.make")); 274 | ofBuffer libsorderMakeBuff; 275 | libsorderMake >> libsorderMakeBuff; 276 | while(!libsorderMakeBuff.isLastLine() && libsorderMakeBuff.size() > 0){ 277 | string line = libsorderMakeBuff.getNextLine(); 278 | if (ofFile::doesFileExist(ofFilePath::join(path , line))){ 279 | 280 | libLibs.push_back(ofFilePath::join(path , line) ); 281 | } else { 282 | libLibs.push_back(line); // this might be something like ws2_32 or other libs no in this project 283 | } 284 | } 285 | } 286 | 287 | } else { 288 | 289 | 290 | ofDirectory dir; 291 | dir.listDir(path); 292 | 293 | 294 | for (int i = 0; i < dir.size(); i++){ 295 | 296 | #ifdef TARGET_WIN32 297 | vector splittedPath = ofSplitString(dir.getPath(i),"\\"); 298 | #else 299 | vector splittedPath = ofSplitString(dir.getPath(i),"/"); 300 | #endif 301 | 302 | ofFile temp(dir.getFile(i)); 303 | 304 | if (temp.isDirectory()){ 305 | //getLibsRecursively(dir.getPath(i), folderNames); 306 | getLibsRecursively(dir.getPath(i), libFiles, libLibs, platform); 307 | 308 | } else { 309 | 310 | 311 | bool platformFound = false; 312 | 313 | if(platform!=""){ 314 | for(int j=0;j<(int)splittedPath.size();j++){ 315 | if(splittedPath[j]==platform){ 316 | platformFound = true; 317 | } 318 | } 319 | } 320 | 321 | 322 | 323 | 324 | //string ext = ofFilePath::getFileExt(temp.getFile(i)); 325 | string ext; 326 | string first; 327 | splitFromLast(dir.getPath(i), ".", first, ext); 328 | 329 | if (ext == "a" || ext == "lib" || ext == "dylib" || ext == "so" || ext == "dll"){ 330 | if (platformFound){ 331 | libLibs.push_back(dir.getPath(i)); 332 | 333 | //TODO: THEO hack 334 | if( platform == "ios" ){ //this is so we can add the osx libs for the simulator builds 335 | 336 | string currentPath = dir.getPath(i); 337 | 338 | //TODO: THEO double hack this is why we need install.xml - custom ignore ofxOpenCv 339 | if( currentPath.find("ofxOpenCv") == string::npos ){ 340 | ofStringReplace(currentPath, "ios", "osx"); 341 | if( ofFile::doesFileExist(currentPath) ){ 342 | libLibs.push_back(currentPath); 343 | } 344 | } 345 | } 346 | } 347 | } else if (ext == "h" || ext == "hpp" || ext == "c" || ext == "cpp" || ext == "cc"){ 348 | libFiles.push_back(dir.getPath(i)); 349 | } 350 | 351 | } 352 | } 353 | 354 | } 355 | 356 | 357 | 358 | //folderNames.push_back(path); 359 | 360 | 361 | 362 | // DirectoryIterator end; 363 | // for (DirectoryIterator it(path); it != end; ++it){ 364 | // if (!it->isDirectory()){ 365 | // string ext = ofFilePath::getFileExt(it->path()); 366 | // vector splittedPath = ofSplitString(ofFilePath::getEnclosingDirectory(it->path()),"/"); 367 | // 368 | // if (ext == "a" || ext == "lib" || ext == "dylib" || ext == "so"){ 369 | // 370 | // if(platform!=""){ 371 | // bool platformFound = false; 372 | // for(int i=0;i<(int)splittedPath.size();i++){ 373 | // if(splittedPath[i]==platform){ 374 | // platformFound = true; 375 | // break; 376 | // } 377 | // } 378 | // if(!platformFound){ 379 | // continue; 380 | // } 381 | // } 382 | // libLibs.push_back(it->path()); 383 | // } else if (ext == "h" || ext == "hpp" || ext == "c" || ext == "cpp" || ext == "cc"){ 384 | // libFiles.push_back(it->path()); 385 | // } 386 | // } 387 | // 388 | // if (it->isDirectory()){ 389 | // getLibsRecursively(it->path(), libFiles, libLibs, platform); 390 | // } 391 | // } 392 | 393 | } 394 | 395 | 396 | 397 | void fixSlashOrder(string & toFix){ 398 | std::replace(toFix.begin(), toFix.end(),'/', '\\'); 399 | } 400 | 401 | 402 | string unsplitString (vector < string > strings, string deliminator ){ 403 | string result; 404 | for (int i = 0; i < (int)strings.size(); i++){ 405 | if (i != 0) result += deliminator; 406 | result += strings[i]; 407 | } 408 | return result; 409 | } 410 | 411 | 412 | static string OFRoot = "../../.."; 413 | 414 | string getOFRoot(){ 415 | return ofFilePath::removeTrailingSlash(OFRoot); 416 | } 417 | 418 | string getAddonsRoot(){ 419 | return ofFilePath::join(getOFRoot(), "addons"); 420 | } 421 | 422 | void setOFRoot(string path){ 423 | OFRoot = path; 424 | } 425 | 426 | string getOFRelPath(string from){ 427 | from = ofFilePath::removeTrailingSlash(from); 428 | Poco::Path base(true); 429 | base.parse(from); 430 | 431 | Poco::Path path; 432 | path.parse( getOFRoot() ); 433 | path.makeAbsolute(); 434 | 435 | 436 | string relPath; 437 | if (path.toString() == base.toString()){ 438 | // do something. 439 | } 440 | 441 | int maxx = MAX(base.depth(), path.depth()); 442 | for (int i = 0; i <= maxx; i++){ 443 | 444 | bool bRunOut = false; 445 | bool bChanged = false; 446 | if (i <= base.depth() && i <= path.depth()){ 447 | if (base.directory(i) == path.directory(i)){ 448 | 449 | } else { 450 | bChanged = true; 451 | } 452 | } else { 453 | bRunOut = true; 454 | } 455 | 456 | 457 | if (bRunOut == true || bChanged == true){ 458 | for (int j = i; j <= base.depth(); j++){ 459 | relPath += "../"; 460 | } 461 | for (int j = i; j <= path.depth(); j++){ 462 | relPath += path.directory(j) + "/"; 463 | } 464 | break; 465 | } 466 | } 467 | 468 | ofLogVerbose() << " returning path " << relPath << endl; 469 | 470 | return relPath; 471 | } 472 | 473 | void parseAddonsDotMake(string path, vector < string > & addons){ 474 | 475 | addons.clear(); 476 | ofFile addonsmake(path); 477 | if(!addonsmake.exists()){ 478 | return; 479 | } 480 | ofBuffer addonsmakebuff; 481 | addonsmake >> addonsmakebuff; 482 | while(!addonsmakebuff.isLastLine() && addonsmakebuff.size() > 0){ 483 | string line = addonsmakebuff.getNextLine(); 484 | if(line!=""){ 485 | addons.push_back(line); 486 | } 487 | } 488 | } 489 | 490 | bool checkConfigExists(){ 491 | ofFile config(ofFilePath::join(ofFilePath::getUserHomeDir(),".ofprojectgenerator/config")); 492 | return config.exists(); 493 | } 494 | 495 | bool askOFRoot(){ 496 | ofFileDialogResult res = ofSystemLoadDialog("OF project generator", "choose the folder of your OF install"); 497 | if (res.fileName == "" || res.filePath == "") return false; 498 | 499 | ofDirectory config(ofFilePath::join(ofFilePath::getUserHomeDir(),".ofprojectgenerator")); 500 | config.create(true); 501 | ofFile configFile(ofFilePath::join(ofFilePath::getUserHomeDir(),".ofprojectgenerator/config"),ofFile::WriteOnly); 502 | configFile << res.filePath; 503 | return true; 504 | } 505 | 506 | string getOFRootFromConfig(){ 507 | if(!checkConfigExists()) return ""; 508 | ofFile configFile(ofFilePath::join(ofFilePath::getUserHomeDir(),".ofprojectgenerator/config"),ofFile::ReadOnly); 509 | ofBuffer filePath = configFile.readToBuffer(); 510 | return filePath.getFirstLine(); 511 | } 512 | 513 | void convertWindowsToUnixPath(string & path){ 514 | for (int i = 0; i < path.size(); i++){ 515 | if (path[i] == '\\') path[i] = '/'; 516 | } 517 | } 518 | 519 | string windowsFromUnixPath(string path){ 520 | for (int i = 0; i < path.size(); i++){ 521 | if (path[i] == '/') path[i] = '\\'; 522 | } 523 | return path; 524 | } 525 | 526 | void extractFolderFromPath(string &_path, string &_folder){ 527 | string completePath = _path; 528 | _folder = ""; 529 | _path = ""; 530 | 531 | int i; 532 | for (i = completePath.size()-1 ; completePath[i] != '/'; i--){ 533 | _folder.insert(_folder.begin(), completePath[i]); 534 | } 535 | for (i-- ; completePath[i] >= 0; i--){ 536 | _path.insert(_path.begin(), completePath[i]); 537 | } 538 | } 539 | 540 | void fixStringCharacters(string &toFix){ 541 | 542 | // replace all non alpha numeric (ascii) characters with _ 543 | for (int i = 0; i < toFix.size(); i++){ 544 | int which = (int)toFix[i]; 545 | if ((which >= 48 && which <= 57) || 546 | (which >= 65 && which <= 90) || 547 | (which >= 97 && which <= 122)){ 548 | } else { 549 | toFix[i] = '_'; 550 | } 551 | } 552 | } 553 | 554 | bool isProjectFolder(string &_projFolder){ 555 | // Return true or false if a project Folder structure it's found and change the _projFolder string 556 | // to become the correct path to a folder structure 557 | // 558 | 559 | // 1. If is a directory 560 | // 561 | ofDirectory dir; 562 | string searchFor = _projFolder; 563 | dir.open(searchFor); 564 | if (!dir.exists()){ 565 | return false; 566 | } 567 | 568 | if ( dir.isDirectory() ){ 569 | 570 | // Is a project directory or a src directory? 571 | // 572 | string folder; 573 | extractFolderFromPath(searchFor, folder); 574 | if ( (folder == "src") || (folder == "bin") || ( (int)folder.find(".xcodeproj") > 0) ){ 575 | _projFolder = searchFor; 576 | } else { 577 | searchFor = _projFolder; 578 | } 579 | 580 | } else { 581 | 582 | // If is a file it have something related to a project? 583 | // 584 | string name; 585 | extractFolderFromPath(searchFor, name); 586 | if (((int)name.find(".cbp") > 0) || 587 | ((int)name.find(".workspace") > 0) || 588 | ((int)name.find(".plist") > 0) || 589 | ((int)name.find(".xcodeproj") > 0) || 590 | ((int)name.find(".make") > 0) || 591 | ((int)name.find(".vcxproj") > 0 )){ 592 | _projFolder = searchFor; 593 | } else { 594 | return false; 595 | } 596 | } 597 | 598 | // 3. Have src/ 599 | // 600 | searchFor = searchFor+"/src"; 601 | dir.open( searchFor ); 602 | if (dir.exists()){ 603 | if (!dir.isDirectory()) 604 | return false; 605 | } else { 606 | return false; 607 | } 608 | 609 | // 4. Have main.cpp, testApp.h, testApp.cpp, ofApp.h, ofApp.cpp? 610 | // 611 | ofFile test; 612 | bool isMainCpp = test.open(searchFor+"/main.cpp"); 613 | bool isTestAppH = test.open(searchFor+"/testApp.h") || test.open(searchFor+"/ofApp.h"); 614 | bool isTestAppCpp = test.open(searchFor+"/testApp.cpp") || test.open(searchFor+"/ofApp.cpp"); 615 | 616 | if ( isTestAppH ){ 617 | if ( isMainCpp && isTestAppCpp ){ 618 | return true; 619 | } else { 620 | isMainCpp = test.open(searchFor+"/main.mm"); 621 | isTestAppCpp = test.open(searchFor+"/testApp.mm") || test.open(searchFor+"/ofApp.mm"); 622 | if ( isMainCpp && isTestAppCpp ){ 623 | return true; 624 | } else { 625 | return false; 626 | } 627 | } 628 | } else { 629 | return false; 630 | } 631 | } 632 | 633 | bool isProjectGenerated(string _path, string _name){ 634 | ofDirectory folder(_path+"/"+_name); 635 | 636 | if ( folder.exists() ){ 637 | if (folder.listDir() >= 2){ 638 | for (int i = 0; i < folder.getFiles().size(); i++) { 639 | if (folder.getName(i) == (_name + ".xcodeproj") ){ 640 | return true; 641 | } 642 | } 643 | } 644 | } 645 | 646 | return false; 647 | } 648 | 649 | bool isAddonCore(string addon){ 650 | // Pre define what's a core addon 651 | // 652 | vector coreAddons; 653 | coreAddons.push_back("ofx3DModelLoader"); 654 | coreAddons.push_back("ofxAccelerometer"); 655 | coreAddons.push_back("ofxAndroid"); 656 | coreAddons.push_back("ofxAssimpModelLoader"); 657 | coreAddons.push_back("ofxGui"); 658 | coreAddons.push_back("ofxMultiTouch"); 659 | coreAddons.push_back("ofxDirList"); 660 | coreAddons.push_back("ofxNetwork"); 661 | coreAddons.push_back("ofxOpenCv"); 662 | coreAddons.push_back("ofxOsc"); 663 | coreAddons.push_back("ofxThread"); 664 | coreAddons.push_back("ofxThreadedImageLoader"); 665 | coreAddons.push_back("ofxVectorGraphics"); 666 | coreAddons.push_back("ofxVectorMath"); 667 | coreAddons.push_back("ofxXmlSettings"); 668 | coreAddons.push_back("ofxSvg"); 669 | coreAddons.push_back("ofxSynth"); 670 | coreAddons.push_back("ofxiPhone"); 671 | 672 | for (int i = 0; i < coreAddons.size(); i++){ 673 | if (coreAddons[i] == addon){ 674 | return true; 675 | } 676 | } 677 | return false; 678 | } 679 | 680 | bool isOFFolder(string _path){ 681 | ofDirectory dir(_path); 682 | 683 | if (dir.exists()){ 684 | vector ofsubfolders; 685 | ofsubfolders.push_back("addons"); 686 | ofsubfolders.push_back("apps"); 687 | ofsubfolders.push_back("examples"); 688 | ofsubfolders.push_back("libs"); 689 | 690 | int check = 0; 691 | dir.listDir(); 692 | for (int i = 0; i < dir.getFiles().size(); i++) { 693 | for (int j = 0; j < ofsubfolders.size(); j++){ 694 | if ( ofsubfolders[j] == dir.getName(i) ){ 695 | check++; 696 | } 697 | } 698 | } 699 | 700 | if (check == ofsubfolders.size()) 701 | return true; 702 | else 703 | return false; 704 | } else 705 | return false; 706 | } --------------------------------------------------------------------------------