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