2
0

PolycodeProjectManager.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "PolycodeProjectManager.h"
  2. PolycodeProjectManager::PolycodeProjectManager() {
  3. }
  4. PolycodeProjectManager::~PolycodeProjectManager() {
  5. }
  6. void PolycodeProjectManager::openProject(string path) {
  7. printf("Opening project %s\n", path.c_str());
  8. vector<std::string> bits = StringUtil::split(path, "/.");
  9. string projectPath = "";
  10. for(int i=0; i < bits.size() - 2; i++) {
  11. projectPath += "/"+bits[i];
  12. }
  13. string projectName = bits[bits.size()-2];
  14. PolycodeProject* newProject = new PolycodeProject(projectName, projectPath);
  15. projects.push_back(newProject);
  16. projectBrowser->addProject(newProject);
  17. }
  18. void PolycodeProjectManager::createNewProject(string templateFolder, wstring projectName, wstring projectLocation) {
  19. string _projectName;
  20. _projectName.assign(projectName.begin(),projectName.end());
  21. string _projectLocation;
  22. _projectLocation.assign(projectLocation.begin(),projectLocation.end());
  23. CoreServices::getInstance()->getCore()->createFolder(_projectLocation);
  24. CoreServices::getInstance()->getCore()->copyDiskItem(templateFolder, _projectLocation+"/"+_projectName);
  25. CoreServices::getInstance()->getCore()->moveDiskItem(_projectLocation+"/"+_projectName+"/template.polyproject", _projectLocation+"/"+_projectName+"/"+_projectName+".polyproject");
  26. openProject(_projectLocation+"/"+_projectName+"/"+_projectName+".polyproject");
  27. }