diff --git a/tools/Forge/Bundles/MapEdit/Preferences.m b/tools/Forge/Bundles/MapEdit/Preferences.m index d86ed7480..b1d8a4b35 100644 --- a/tools/Forge/Bundles/MapEdit/Preferences.m +++ b/tools/Forge/Bundles/MapEdit/Preferences.m @@ -124,9 +124,7 @@ _atof (const char *c) - (id) setCurrentProject: sender { - [startproject_i setStringValue: [NSString stringWithCString: [project_i - currentProjectFile - ]]]; + [startproject_i setStringValue: [project_i currentProjectFile]]; [self UIChanged: self]; return self; } diff --git a/tools/Forge/Bundles/MapEdit/Project.h b/tools/Forge/Bundles/MapEdit/Project.h index fdd1b4e97..555700534 100644 --- a/tools/Forge/Bundles/MapEdit/Project.h +++ b/tools/Forge/Bundles/MapEdit/Project.h @@ -45,7 +45,7 @@ extern id project_i; id BSPoutput_i; // outlet to Text - char path_projectinfo[128]; // path of QE_Project file + NSString *path_projectinfo; // path of QE_Project file char path_basepath[128]; // base path of heirarchy @@ -72,7 +72,7 @@ extern id project_i; - (id) initProject; - (id) initVars; -- (const char *) currentProjectFile; +- (NSString *) currentProjectFile; - (id) setTextureWad: (const char *)wf; @@ -81,7 +81,7 @@ extern id project_i; - (id) initProjSettings; - (id) parseProjectFile; // read defaultsdatabase for project path -- (id) openProjectFile: (const char *)path; // called by openProject, newProject +- (id) openProjectFile: (NSString *)path; // called by openProject, newProject - (id) openProject; - (id) clickedOnMap: sender; // called if clicked on map in browser - (id) clickedOnWad: sender; // called if clicked on wad in browser diff --git a/tools/Forge/Bundles/MapEdit/Project.m b/tools/Forge/Bundles/MapEdit/Project.m index 37bba9d47..b7908f898 100644 --- a/tools/Forge/Bundles/MapEdit/Project.m +++ b/tools/Forge/Bundles/MapEdit/Project.m @@ -285,27 +285,29 @@ id project_i; return self; } - [self openProjectFile: path]; + [self openProjectFile: [NSString stringWithCString: path]]; return self; } // // Loads and parses a project file // -- (id) openProjectFile: (const char *)path +- (id) openProjectFile: (NSString *)path { FILE *fp; struct stat s; - Sys_Printf ("openProjectFile: %s\n", path); - strcpy (path_projectinfo, path); + Sys_Printf ("openProjectFile: %s\n", [path cString]); + [path retain]; + [path_projectinfo release]; + path_projectinfo = path; projectInfo = NULL; - fp = fopen (path, "r+t"); + fp = fopen ([path cString], "r+t"); if (fp == NULL) return self; - stat (path, &s); + stat ([path cString], &s); lastModified = s.st_mtime; projectInfo = [(Dict *)[Dict alloc] initFromFile: fp]; @@ -314,7 +316,7 @@ id project_i; return self; } -- (const char *) currentProjectFile +- (NSString *) currentProjectFile { return path_projectinfo; } @@ -324,24 +326,21 @@ id project_i; // - (id) openProject { - const char *path; id openpanel; int rtn; NSString *projtypes[] = {@"qpr"}; + NSArray *projtypes_array; NSArray *filenames; - const char *dir; + NSString *path; openpanel = [NSOpenPanel new]; -// [openpanel allowMultipleFiles:NO]; -// [openpanel chooseDirectories:NO]; - rtn = [openpanel runModalForTypes: [NSArray arrayWithObjects: projtypes - count: 1]]; + [openpanel setAllowsMultipleSelection:NO]; + [openpanel setCanChooseDirectories:NO]; + projtypes_array = [NSArray arrayWithObjects: projtypes count: 1]; + rtn = [openpanel runModalForTypes: projtypes_array]; if (rtn == NSOKButton) { filenames = [openpanel filenames]; - dir = [[openpanel directory] cString]; - dir = ""; - path = va ("%s/%s", dir, [[filenames objectAtIndex: 0] cString]); - strcpy (path_projectinfo, path); + path = [filenames objectAtIndex: 0]; [self openProjectFile: path]; return self; }