mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
More conversions to NSString
This commit is contained in:
parent
fd000b880d
commit
12d79ba28d
4 changed files with 31 additions and 35 deletions
|
@ -15,8 +15,8 @@ extern float lightaxis[3];
|
||||||
id bspSound_i; // actual sound object
|
id bspSound_i; // actual sound object
|
||||||
|
|
||||||
// internal state
|
// internal state
|
||||||
char projectpath[1024];
|
NSString *projectpath;
|
||||||
char bspSound[1024];
|
NSString *bspSound;
|
||||||
|
|
||||||
BOOL brushOffset;
|
BOOL brushOffset;
|
||||||
BOOL showBSP;
|
BOOL showBSP;
|
||||||
|
@ -50,7 +50,7 @@ extern float lightaxis[3];
|
||||||
// validate and set methods called by UI or defaults
|
// validate and set methods called by UI or defaults
|
||||||
//
|
//
|
||||||
- (id) setProjectPath: (const char *)path;
|
- (id) setProjectPath: (const char *)path;
|
||||||
- (id) setBspSoundPath: (const char *)path; // set the path of the soundfile
|
- (id) setBspSoundPath: (NSString *)path; // set the path of the soundfile
|
||||||
- (id) setShowBSP: (int)state; // set the state of ShowBSP
|
- (id) setShowBSP: (int)state; // set the state of ShowBSP
|
||||||
- (id) setBrushOffset: (int)state; // set the state of BrushOffset
|
- (id) setBrushOffset: (int)state; // set the state of BrushOffset
|
||||||
- (id) setStartWad: (int)value; // set start wad (0-2)
|
- (id) setStartWad: (int)value; // set start wad (0-2)
|
||||||
|
@ -70,7 +70,7 @@ extern float lightaxis[3];
|
||||||
//
|
//
|
||||||
- (id) playBspSound;
|
- (id) playBspSound;
|
||||||
|
|
||||||
- (const char *) getProjectPath;
|
- (NSString *) getProjectPath;
|
||||||
- (int) getBrushOffset; // get the state
|
- (int) getBrushOffset; // get the state
|
||||||
- (int) getShowBSP; // get the state
|
- (int) getShowBSP; // get the state
|
||||||
|
|
||||||
|
|
|
@ -81,8 +81,7 @@ _atof (const char *c)
|
||||||
string = [[prefs stringForKey: @"ProjectPath"] cString];
|
string = [[prefs stringForKey: @"ProjectPath"] cString];
|
||||||
[self setProjectPath: string];
|
[self setProjectPath: string];
|
||||||
|
|
||||||
string = [[prefs stringForKey: @"BspSoundPath"] cString];
|
[self setBspSoundPath: [prefs stringForKey: @"BspSoundPath"]];
|
||||||
[self setBspSoundPath: string];
|
|
||||||
|
|
||||||
string = [[prefs stringForKey: @"ShowBSPOutput"] cString];
|
string = [[prefs stringForKey: @"ShowBSPOutput"] cString];
|
||||||
value = _atoi (string);
|
value = _atoi (string);
|
||||||
|
@ -116,8 +115,8 @@ _atof (const char *c)
|
||||||
if (!path)
|
if (!path)
|
||||||
path = "";
|
path = "";
|
||||||
|
|
||||||
strcpy (projectpath, path);
|
projectpath = [NSString stringWithCString: path];
|
||||||
[startproject_i setStringValue: [NSString stringWithCString: path]];
|
[startproject_i setStringValue: projectpath];
|
||||||
WriteStringDefault (prefs, "ProjectPath", path);
|
WriteStringDefault (prefs, "ProjectPath", path);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -129,7 +128,7 @@ _atof (const char *c)
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (const char *) getProjectPath
|
- (NSString *) getProjectPath
|
||||||
{
|
{
|
||||||
return projectpath;
|
return projectpath;
|
||||||
}
|
}
|
||||||
|
@ -147,24 +146,21 @@ _atof (const char *c)
|
||||||
NSString *types[] = {@"snd"};
|
NSString *types[] = {@"snd"};
|
||||||
int rtn;
|
int rtn;
|
||||||
NSArray *filenames;
|
NSArray *filenames;
|
||||||
char path[1024], file[64];
|
NSString *path, *file;
|
||||||
|
|
||||||
panel = [NSOpenPanel new];
|
panel = [NSOpenPanel new];
|
||||||
|
|
||||||
// XXX ExtractFilePath (bspSound, path);
|
path = [bspSound stringByDeletingLastPathComponent];
|
||||||
// XXX ExtractFileBase (bspSound, file);
|
file = [bspSound lastPathComponent];
|
||||||
|
|
||||||
rtn = [panel runModalForDirectory: [NSString stringWithCString: path]
|
rtn = [panel runModalForDirectory: path file: file
|
||||||
file: [NSString stringWithCString: file]
|
types: [NSArray arrayWithObjects: types
|
||||||
types: [NSArray arrayWithObjects: types count: 1]
|
count: 1]
|
||||||
];
|
];
|
||||||
|
|
||||||
if (rtn) {
|
if (rtn) {
|
||||||
filenames = [panel filenames];
|
filenames = [panel filenames];
|
||||||
strcpy (bspSound, [[panel directory] cString]);
|
[self setBspSoundPath: [filenames objectAtIndex: 0]];
|
||||||
strcat (bspSound, "/");
|
|
||||||
strcat (bspSound, [[filenames objectAtIndex: 0] cString]);
|
|
||||||
[self setBspSoundPath: bspSound];
|
|
||||||
[self playBspSound];
|
[self playBspSound];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,27 +179,27 @@ _atof (const char *c)
|
||||||
//
|
//
|
||||||
// Set the bspSound path
|
// Set the bspSound path
|
||||||
//
|
//
|
||||||
- (id) setBspSoundPath: (const char *)path
|
- (id) setBspSoundPath: (NSString *)path
|
||||||
{
|
{
|
||||||
if (!path)
|
|
||||||
path = "";
|
[path retain];
|
||||||
strcpy (bspSound, path);
|
[bspSound release];
|
||||||
|
bspSound = path;
|
||||||
|
|
||||||
if (bspSound_i) {
|
if (bspSound_i) {
|
||||||
[bspSound_i release];
|
[bspSound_i release];
|
||||||
bspSound_i = nil;
|
bspSound_i = nil;
|
||||||
}
|
}
|
||||||
if (path[0] && access (path, R_OK)) {
|
if (access ([path cString], R_OK)) {
|
||||||
bspSound_i =
|
bspSound_i = [[NSSound alloc] initWithContentsOfFile: bspSound
|
||||||
[[NSSound alloc] initWithContentsOfFile: [NSString stringWithCString:
|
byReference: YES];
|
||||||
bspSound] byReference: YES];
|
|
||||||
}
|
}
|
||||||
if (!bspSound_i)
|
if (!bspSound_i)
|
||||||
return self;
|
return self;
|
||||||
|
|
||||||
[bspSoundField_i setStringValue: [NSString stringWithCString: bspSound]];
|
[bspSoundField_i setStringValue: bspSound];
|
||||||
|
|
||||||
WriteStringDefault (prefs, "BspSoundPath", bspSound);
|
WriteStringDefault (prefs, "BspSoundPath", [bspSound cString]);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -345,7 +341,7 @@ Grab all the current UI state
|
||||||
Sys_Printf ("defaults updated\n");
|
Sys_Printf ("defaults updated\n");
|
||||||
|
|
||||||
[self setProjectPath: [[startproject_i stringValue] cString]];
|
[self setProjectPath: [[startproject_i stringValue] cString]];
|
||||||
[self setBspSoundPath: [[bspSoundField_i stringValue] cString]];
|
[self setBspSoundPath: [bspSoundField_i stringValue]];
|
||||||
[self setShowBSP: [showBSP_i intValue]];
|
[self setShowBSP: [showBSP_i intValue]];
|
||||||
[self setBrushOffset: [brushOffset_i intValue]];
|
[self setBrushOffset: [brushOffset_i intValue]];
|
||||||
[self setStartWad: [startwad_i selectedRow]];
|
[self setStartWad: [startwad_i selectedRow]];
|
||||||
|
|
|
@ -39,7 +39,7 @@ id project_i;
|
||||||
{
|
{
|
||||||
NSString *ts;
|
NSString *ts;
|
||||||
|
|
||||||
ts = [NSString stringWithCString: [preferences_i getProjectPath]];
|
ts = [preferences_i getProjectPath];
|
||||||
ts = path_basepath = [[ts stringByDeletingLastPathComponent] retain];
|
ts = path_basepath = [[ts stringByDeletingLastPathComponent] retain];
|
||||||
|
|
||||||
path_progdir = [[ts stringByAppendingPathComponent: SUBDIR_ENT] retain];
|
path_progdir = [[ts stringByAppendingPathComponent: SUBDIR_ENT] retain];
|
||||||
|
@ -266,11 +266,11 @@ id project_i;
|
||||||
//
|
//
|
||||||
- (id) parseProjectFile
|
- (id) parseProjectFile
|
||||||
{
|
{
|
||||||
const char *path;
|
NSString *path;
|
||||||
int rtn;
|
int rtn;
|
||||||
|
|
||||||
path = [preferences_i getProjectPath];
|
path = [preferences_i getProjectPath];
|
||||||
if (!path || !path[0] || access (path, 0)) {
|
if (![path length] || access ([path cString], 0)) {
|
||||||
rtn = NSRunAlertPanel (@"Project Error!",
|
rtn = NSRunAlertPanel (@"Project Error!",
|
||||||
@"A default project has not been found.\n",
|
@"A default project has not been found.\n",
|
||||||
@"Open Project", NULL, NULL);
|
@"Open Project", NULL, NULL);
|
||||||
|
@ -281,7 +281,7 @@ id project_i;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self openProjectFile: [NSString stringWithCString: path]];
|
[self openProjectFile: path];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -191,7 +191,7 @@ TEX_InitFromWad (const char *path)
|
||||||
|
|
||||||
start = Sys_DoubleTime ();
|
start = Sys_DoubleTime ();
|
||||||
|
|
||||||
newpath = [preferences_i getProjectPath];
|
newpath = [[preferences_i getProjectPath] cString];
|
||||||
newpath = va ("%s%s%s", newpath, newpath[0] ? "/" : "", path);
|
newpath = va ("%s%s%s", newpath, newpath[0] ? "/" : "", path);
|
||||||
|
|
||||||
// free any textures
|
// free any textures
|
||||||
|
|
Loading…
Reference in a new issue