hotKey = altL, text = $"Location";
typeExpected = directory, browseDialog = fileDialog;
- //NotifyUpdate = EditBoxUpdate;
-
- bool NotifyModified(PathBox pathBox)
- {
- char location[MAX_LOCATION];
- char lastPart[MAX_FILENAME];
- char * text = pathBox.slashPath;
-
- //replacing this: NotifyUpdate = EditBoxUpdate;
- okBtn.disabled = !(text[0] && projectName.contents[0]);
-
- GetWorkingDir(location, sizeof(location) - 1);
- PathCatSlash(location, text);
-
- GetLastDirectory(path, lastPart);
- /*if(text[0] && (!name[0] || !strcmp(lastPart, name)))
- {
- char newName[MAX_FILENAME];
- GetLastDirectory(location, newName);
- if(strcmp(newName, location))
- {
- strcpy(name, newName);
- projectName.contents = name;
- }
- }*/
- strcpy(path, location);
- pathBox.path = path;
- return true;
- }
+ NotifyModified = NotifyModifiedLocation;
};
Label { this, position = { 10, 60 }, labeledWindow = locationEditBox };
okBtn.disabled = !(locationEditBox.path[0] && projectName.contents[0]);
}
+ bool NotifyModifiedLocation(PathBox pathBox)
+ {
+ char location[MAX_LOCATION];
+ char lastPart[MAX_FILENAME];
+ char * text = pathBox.slashPath;
+
+ //replacing this: NotifyUpdate = EditBoxUpdate;
+ okBtn.disabled = !(text[0] && projectName.contents[0]);
+
+ GetWorkingDir(location, sizeof(location) - 1);
+ PathCatSlash(location, text);
+
+ GetLastDirectory(path, lastPart);
+ /*if(text[0] && (!name[0] || !strcmp(lastPart, name)))
+ {
+ char newName[MAX_FILENAME];
+ GetLastDirectory(location, newName);
+ if(strcmp(newName, location))
+ {
+ strcpy(name, newName);
+ projectName.contents = name;
+ }
+ }*/
+ strcpy(path, location);
+ pathBox.path = path;
+ return true;
+ }
+
NewProjectDialog()
{
char location[MAX_LOCATION];
for(c = 1; c<app.argc; c++)
{
char fullPath[MAX_LOCATION];
+ char parentPath[MAX_LOCATION];
+ char ext[MAX_EXTENSION];
+ bool isProject;
+ FileAttribs dirAttribs;
GetWorkingDir(fullPath, MAX_LOCATION);
PathCat(fullPath, app.argv[c]);
- if(FileExists(fullPath))
- ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
+ StripLastDirectory(fullPath, parentPath);
+ GetExtension(app.argv[c], ext);
+ isProject = !strcmpi(ext, "epj");
+
+ if(isProject && c > 1) continue;
+
+ // Create directory for projects (only)
+ if(((dirAttribs = FileExists(parentPath)) && dirAttribs.isDirectory) || isProject)
+ {
+ if(isProject && !FileExists(fullPath))
+ {
+ // The NewProject will handle directory creation
+ /*if(!dirAttribs.isDirectory)
+ {
+ MakeDir(parentPath);
+ dirAttribs = FileExists(parentPath);
+ }
+ if(dirAttribs.isDirectory)*/
+ {
+ char name[MAX_LOCATION];
+ NewProjectDialog newProjectDialog;
+
+ if(projectView)
+ {
+ projectView.visible = false;
+ if(!projectView.Destroy(0))
+ return true;
+ }
+
+ newProjectDialog = { master = this };
+
+ strcpy(name, app.argv[c]);
+ StripExtension(name);
+ GetLastDirectory(name, name);
+ newProjectDialog.projectName.contents = name;
+ newProjectDialog.projectName.NotifyModified(newProjectDialog, newProjectDialog.projectName);
+ newProjectDialog.locationEditBox.path = parentPath;
+ newProjectDialog.NotifyModifiedLocation(newProjectDialog.locationEditBox);
+
+ newProjectDialog.Modal();
+ if(projectView)
+ {
+ ideSettings.AddRecentProject(projectView.fileName);
+ ide.UpdateRecentMenus();
+ settingsContainer.Save();
+ }
+ }
+ // Open only one project
+ break;
+ }
+ else
+ ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
+ }
}
return true;
}