mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
Do a lot of conversions to NSString.
This commit is contained in:
parent
2ac2f5fab5
commit
fd000b880d
5 changed files with 80 additions and 85 deletions
|
@ -15,9 +15,9 @@
|
|||
#define BSPLEAKTEST "bspleaktest"
|
||||
#define BSPENTITIES "bspentities"
|
||||
|
||||
#define SUBDIR_ENT "progs" // subdir names in heirarchy
|
||||
#define SUBDIR_MAPS "maps"
|
||||
#define SUBDIR_GFX "gfx"
|
||||
#define SUBDIR_ENT @"progs" // subdir names in heirarchy
|
||||
#define SUBDIR_MAPS @"maps"
|
||||
#define SUBDIR_GFX @"gfx"
|
||||
|
||||
extern id project_i;
|
||||
|
||||
|
@ -47,11 +47,11 @@ extern id project_i;
|
|||
|
||||
NSString *path_projectinfo; // path of QE_Project file
|
||||
|
||||
char path_basepath[128]; // base path of heirarchy
|
||||
NSString *path_basepath; // base path of heirarchy
|
||||
|
||||
char path_progdir[128]; // derived from basepath
|
||||
char path_mapdirectory[128]; // derived from basepath
|
||||
char path_finalmapdir[128]; // derived from basepath
|
||||
NSString *path_progdir; // derived from basepath
|
||||
NSString *path_mapdirectory; // derived from basepath
|
||||
NSString *path_finalmapdir; // derived from basepath
|
||||
|
||||
char path_wad8[128]; // path of texture WAD for cmd-8 key
|
||||
char path_wad9[128]; // path of texture WAD for cmd-9 key
|
||||
|
@ -89,9 +89,9 @@ extern id project_i;
|
|||
//
|
||||
// methods to query the project file
|
||||
//
|
||||
- (const char *) getMapDirectory;
|
||||
- (const char *) getFinalMapDirectory;
|
||||
- (const char *) getProgDirectory;
|
||||
- (NSString *) getMapDirectory;
|
||||
- (NSString *) getFinalMapDirectory;
|
||||
- (NSString *) getProgDirectory;
|
||||
|
||||
- (const char *) getWAD8;
|
||||
- (const char *) getWAD9;
|
||||
|
|
|
@ -37,25 +37,18 @@ id project_i;
|
|||
// ===========================================================
|
||||
- (id) initVars
|
||||
{
|
||||
const char *pe;
|
||||
char *ts;
|
||||
NSString *ts;
|
||||
|
||||
ts = strdup ([preferences_i getProjectPath]);
|
||||
pe = QFS_SkipPath (ts);
|
||||
ts[pe - ts] = 0;
|
||||
strcpy (path_basepath, ts);
|
||||
ts = [NSString stringWithCString: [preferences_i getProjectPath]];
|
||||
ts = path_basepath = [[ts stringByDeletingLastPathComponent] retain];
|
||||
|
||||
strcpy (path_progdir, ts);
|
||||
strcat (path_progdir, SUBDIR_ENT);
|
||||
path_progdir = [[ts stringByAppendingPathComponent: SUBDIR_ENT] retain];
|
||||
|
||||
strcpy (path_mapdirectory, ts);
|
||||
strcat (path_mapdirectory, SUBDIR_MAPS); // source dir
|
||||
|
||||
strcpy (path_finalmapdir, ts);
|
||||
strcat (path_finalmapdir, SUBDIR_MAPS); // dest dir
|
||||
path_mapdirectory = [[ts stringByAppendingPathComponent: SUBDIR_MAPS] retain];
|
||||
path_finalmapdir = [[ts stringByAppendingPathComponent: SUBDIR_MAPS] retain];
|
||||
|
||||
// in Project Inspector
|
||||
[basepathinfo_i setStringValue: [NSString stringWithCString: ts]];
|
||||
[basepathinfo_i setStringValue: ts];
|
||||
|
||||
#if 0 // FIXME: for "out-of-tree" projects ?
|
||||
if ((s = [projectInfo getStringFor: BASEPATHKEY])) {
|
||||
|
@ -98,7 +91,7 @@ id project_i;
|
|||
//
|
||||
- (id) initProjSettings
|
||||
{
|
||||
[pis_basepath_i setStringValue: [NSString stringWithCString: path_basepath]];
|
||||
[pis_basepath_i setStringValue: path_basepath];
|
||||
[pis_fullvis_i setStringValue: [NSString stringWithCString: string_fullvis]];
|
||||
[pis_fastvis_i setStringValue: [NSString stringWithCString: string_fastvis]];
|
||||
[pis_novis_i setStringValue: [NSString stringWithCString: string_novis]];
|
||||
|
@ -197,14 +190,17 @@ id project_i;
|
|||
{
|
||||
id matrix;
|
||||
int row;
|
||||
const char *fname;
|
||||
NSString *mapname;
|
||||
NSString *fname;
|
||||
id panel;
|
||||
NSModalSession session;
|
||||
|
||||
matrix = [sender matrixInColumn: 0];
|
||||
row = [matrix selectedRow];
|
||||
fname = va ("%s/%s.map", path_mapdirectory,
|
||||
PL_String (PL_ObjectAtIndex (mapList, row)));
|
||||
mapname = [NSString stringWithCString:
|
||||
PL_String (PL_ObjectAtIndex (mapList, row))];
|
||||
fname = [[path_mapdirectory stringByAppendingPathComponent: mapname]
|
||||
stringByAppendingPathExtension: @"map"];
|
||||
|
||||
panel = NSGetAlertPanel (@"Loading...",
|
||||
@"Loading map. Please wait.", NULL, NULL, NULL);
|
||||
|
@ -348,17 +344,17 @@ id project_i;
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (const char *) getMapDirectory
|
||||
- (NSString *) getMapDirectory
|
||||
{
|
||||
return path_mapdirectory;
|
||||
}
|
||||
|
||||
- (const char *) getFinalMapDirectory
|
||||
- (NSString *) getFinalMapDirectory
|
||||
{
|
||||
return path_finalmapdir;
|
||||
}
|
||||
|
||||
- (const char *) getProgDirectory
|
||||
- (NSString *) getProgDirectory
|
||||
{
|
||||
return path_progdir;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ void NopSound (void);
|
|||
@interface QuakeEd: NSWindow
|
||||
{
|
||||
BOOL dirty;
|
||||
char filename[1024]; // full path with .map extension
|
||||
NSString *filename; // full path with .map extension
|
||||
|
||||
NSBitmapImageRep *cache[3];
|
||||
NSRect cache_rect[3];
|
||||
|
@ -47,7 +47,7 @@ void NopSound (void);
|
|||
}
|
||||
|
||||
- (id) setDefaultFilename;
|
||||
- (const char *) currentFilename;
|
||||
- (NSString *) currentFilename;
|
||||
|
||||
- (id) updateAll; // when a model has been changed
|
||||
- (id) updateCamera; // when the camera has moved
|
||||
|
@ -87,7 +87,7 @@ void NopSound (void);
|
|||
- (id) save: sender;
|
||||
- (id) saveAs: sender;
|
||||
|
||||
- (id) doOpen: (const char *)fname;
|
||||
- (id) doOpen: (NSString *)fname;
|
||||
|
||||
- (id) saveBSP: (const char *)cmdline dialog: (BOOL)wt;
|
||||
|
||||
|
|
|
@ -139,11 +139,12 @@ Every five minutes, save a modified map
|
|||
[map_i writeStats];
|
||||
}
|
||||
|
||||
#define FN_TEMPSAVE "/qcache/temp.map"
|
||||
#define FN_TEMPSAVE @"/qcache/temp.map"
|
||||
- (id) setDefaultFilename
|
||||
{
|
||||
strcpy (filename, FN_TEMPSAVE);
|
||||
[self setTitleWithRepresentedFilename: [NSString stringWithCString: filename]];
|
||||
filename = FN_TEMPSAVE;
|
||||
[filename retain];
|
||||
[self setTitleWithRepresentedFilename: filename];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -634,7 +635,7 @@ BSP PROCESSING
|
|||
==============================================================================
|
||||
*/
|
||||
void
|
||||
ExpandCommand (const char *in, char *out, char *src, char *dest)
|
||||
ExpandCommand (const char *in, char *out, const char *src, const char *dest)
|
||||
{
|
||||
while (*in) {
|
||||
if (in[0] == '$') {
|
||||
|
@ -661,11 +662,11 @@ saveBSP
|
|||
- (id) saveBSP: (const char *)cmdline dialog: (BOOL)wt
|
||||
{
|
||||
char expandedcmd[1024];
|
||||
char mappath[1024];
|
||||
char bsppath[1024];
|
||||
NSString *mappath;
|
||||
NSString *bsppath;
|
||||
int oldLightFilter;
|
||||
int oldPathFilter;
|
||||
const char *destdir;
|
||||
NSString *destdir;
|
||||
|
||||
if (bsppid) {
|
||||
NSBeep ();
|
||||
|
@ -681,13 +682,12 @@ saveBSP
|
|||
[self applyRegion: self];
|
||||
|
||||
if ([regionbutton_i intValue]) {
|
||||
strcpy (mappath, filename);
|
||||
// XXX StripExtension (mappath);
|
||||
strcat (mappath, ".reg");
|
||||
[map_i writeMapFile: mappath useRegion: YES];
|
||||
mappath = [[filename stringByDeletingPathExtension]
|
||||
stringByAppendingPathExtension: @"reg"];
|
||||
[map_i writeMapFile: [mappath cString] useRegion: YES];
|
||||
wt = YES; // allways pop the dialog on region ops
|
||||
} else {
|
||||
strcpy (mappath, filename);
|
||||
mappath = filename;
|
||||
}
|
||||
// save the entire thing, just in case there is a problem
|
||||
[self save: self];
|
||||
|
@ -701,12 +701,11 @@ saveBSP
|
|||
//
|
||||
destdir = [project_i getFinalMapDirectory];
|
||||
|
||||
strcpy (bsppath, destdir);
|
||||
strcat (bsppath, "/");
|
||||
// XXX ExtractFileBase (mappath, bsppath + strlen(bsppath));
|
||||
strcat (bsppath, ".bsp");
|
||||
bsppath = [destdir stringByAppendingPathComponent:
|
||||
[[[mappath lastPathComponent] stringByDeletingPathExtension]
|
||||
stringByAppendingPathExtension: @"bsp"]];
|
||||
|
||||
ExpandCommand (cmdline, expandedcmd, mappath, bsppath);
|
||||
ExpandCommand (cmdline, expandedcmd, [mappath cString], [bsppath cString]);
|
||||
|
||||
strcat (expandedcmd, " > ");
|
||||
strcat (expandedcmd, FN_CMDOUT);
|
||||
|
@ -793,17 +792,19 @@ doOpen:
|
|||
Called by open or the project panel
|
||||
==============
|
||||
*/
|
||||
- (id) doOpen: (const char *)fname;
|
||||
- (id) doOpen: (NSString *)fname;
|
||||
{
|
||||
strcpy (filename, fname);
|
||||
[fname retain];
|
||||
[filename release];
|
||||
filename = fname;
|
||||
|
||||
[map_i readMapFile: filename];
|
||||
[map_i readMapFile: [filename cString]];
|
||||
|
||||
[regionbutton_i setIntValue: 0];
|
||||
[self setTitleWithRepresentedFilename: [NSString stringWithCString: fname]];
|
||||
[self setTitleWithRepresentedFilename: fname];
|
||||
[self updateAll];
|
||||
|
||||
Sys_Printf ("%s loaded\n", fname);
|
||||
Sys_Printf ("%s loaded\n", [fname cString]);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -817,17 +818,16 @@ open
|
|||
{
|
||||
id openpanel;
|
||||
NSString *suffixlist[] = {@"map"};
|
||||
NSArray *types = [NSArray arrayWithObjects: suffixlist count: 1];
|
||||
|
||||
openpanel = [NSOpenPanel new];
|
||||
|
||||
if ([openpanel
|
||||
runModalForDirectory: [NSString stringWithCString: [project_i
|
||||
getMapDirectory]]
|
||||
runModalForDirectory: [project_i getMapDirectory]
|
||||
file: @""
|
||||
types: [NSArray arrayWithObjects: suffixlist count: 1]]
|
||||
!= NSOKButton)
|
||||
types: types] != NSOKButton)
|
||||
return self;
|
||||
[self doOpen: [[openpanel filename] cString]];
|
||||
[self doOpen: [openpanel filename]];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -839,19 +839,18 @@ save:
|
|||
*/
|
||||
- (id) save: sender;
|
||||
{
|
||||
char backup[1024];
|
||||
NSString *backup;
|
||||
|
||||
// force a name change if using tempname
|
||||
if (!strcmp (filename, FN_TEMPSAVE))
|
||||
if (![filename compare: FN_TEMPSAVE])
|
||||
return [self saveAs: self];
|
||||
dirty = autodirty = NO;
|
||||
|
||||
strcpy (backup, filename);
|
||||
// XXX StripExtension (backup);
|
||||
strcat (backup, ".bak");
|
||||
rename (filename, backup); // copy old to .bak
|
||||
backup = [[filename stringByDeletingPathExtension]
|
||||
stringByAppendingPathExtension: @"bak"];
|
||||
rename ([filename cString], [backup cString]); // copy old to .bak
|
||||
|
||||
[map_i writeMapFile: filename useRegion: NO];
|
||||
[map_i writeMapFile: [filename cString] useRegion: NO];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -864,20 +863,20 @@ saveAs
|
|||
- (id) saveAs: sender;
|
||||
{
|
||||
id panel_i;
|
||||
char dir[1024];
|
||||
NSString *dir;
|
||||
NSString *fname;
|
||||
|
||||
panel_i = [NSSavePanel new];
|
||||
// XXX ExtractFileBase (filename, dir);
|
||||
dir = [filename stringByDeletingLastPathComponent];
|
||||
[panel_i setRequiredFileType: @"map"];
|
||||
if ([panel_i
|
||||
runModalForDirectory: [NSString stringWithCString: [project_i
|
||||
getMapDirectory]]
|
||||
file: [NSString stringWithCString: dir]]
|
||||
if ([panel_i runModalForDirectory: [project_i getMapDirectory] file: dir]
|
||||
!= NSOKButton)
|
||||
return self;
|
||||
strcpy (filename, [[panel_i filename] cString]);
|
||||
fname = [[panel_i filename] retain];
|
||||
[filename release];
|
||||
filename = fname;
|
||||
|
||||
[self setTitleWithRepresentedFilename: [NSString stringWithCString: filename]];
|
||||
[self setTitleWithRepresentedFilename: filename];
|
||||
|
||||
[self save: self];
|
||||
|
||||
|
@ -895,7 +894,7 @@ saveAs
|
|||
//
|
||||
// AJR - added this for Project info
|
||||
//
|
||||
- (const char *) currentFilename
|
||||
- (NSString *) currentFilename
|
||||
{
|
||||
return filename;
|
||||
}
|
||||
|
|
|
@ -44,13 +44,13 @@ id things_i;
|
|||
|
||||
- (id) initEntities
|
||||
{
|
||||
const char *path;
|
||||
NSString *path;
|
||||
|
||||
path = [project_i getProgDirectory];
|
||||
|
||||
[prog_path_i setStringValue: [NSString stringWithCString: path]];
|
||||
[prog_path_i setStringValue: path];
|
||||
|
||||
[[EntityClassList alloc] initForSourceDirectory: path];
|
||||
[[EntityClassList alloc] initForSourceDirectory: [path cString]];
|
||||
|
||||
[self loadEntityComment: [entity_classes_i objectAtIndex: lastSelected]];
|
||||
[entity_browser_i loadColumnZero];
|
||||
|
@ -91,19 +91,19 @@ id things_i;
|
|||
- (id) reloadEntityClasses: sender
|
||||
{
|
||||
EntityClass *ent;
|
||||
const char *path;
|
||||
NSString *path;
|
||||
|
||||
path = [[prog_path_i stringValue] cString];
|
||||
if (!path || !path[0]) {
|
||||
path = [prog_path_i stringValue];
|
||||
if (!path || ![path length]) {
|
||||
path = [project_i getProgDirectory];
|
||||
[prog_path_i setStringValue: [NSString stringWithCString: path]];
|
||||
[prog_path_i setStringValue: path];
|
||||
}
|
||||
// Free all entity info in memory...
|
||||
[entity_classes_i removeAllObjects];
|
||||
[entity_classes_i release];
|
||||
|
||||
// Now, RELOAD!
|
||||
[[EntityClassList alloc] initForSourceDirectory: path];
|
||||
[[EntityClassList alloc] initForSourceDirectory: [path cString]];
|
||||
|
||||
lastSelected = 0;
|
||||
ent = [entity_classes_i objectAtIndex: lastSelected];
|
||||
|
|
Loading…
Reference in a new issue