2010-09-29 20:09:11 +00:00
|
|
|
// ======================================
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
|
|
|
// QuakeEd Project Management
|
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
// ======================================
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 08:35:25 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2010-10-04 10:43:33 +00:00
|
|
|
#include "QF/qfplist.h"
|
2010-09-12 09:12:02 +00:00
|
|
|
#include "QF/quakefs.h"
|
2010-09-11 08:35:25 +00:00
|
|
|
#include "QF/sys.h"
|
2010-09-28 12:40:11 +00:00
|
|
|
#include "QF/va.h"
|
2010-09-11 08:35:25 +00:00
|
|
|
|
|
|
|
#include "Project.h"
|
|
|
|
#include "Map.h"
|
|
|
|
#include "QuakeEd.h"
|
|
|
|
#include "Preferences.h"
|
|
|
|
#include "Dict.h"
|
|
|
|
#include "Things.h"
|
|
|
|
#include "TexturePalette.h"
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
id project_i;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
@implementation Project
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) init
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
project_i = self;
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
// ===========================================================
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// Project code
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
// ===========================================================
|
|
|
|
- (id) initVars
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
const char *s;
|
|
|
|
const char *pe;
|
|
|
|
char *ts;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-28 09:41:38 +00:00
|
|
|
ts = strdup ([preferences_i getProjectPath]);
|
|
|
|
pe = QFS_SkipPath (ts);
|
|
|
|
ts[pe - ts] = 0;
|
|
|
|
strcpy (path_basepath, ts);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-28 09:41:38 +00:00
|
|
|
strcpy (path_progdir, ts);
|
2010-09-12 09:12:02 +00:00
|
|
|
strcat (path_progdir, SUBDIR_ENT);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-28 09:41:38 +00:00
|
|
|
strcpy (path_mapdirectory, ts);
|
2010-09-29 20:09:11 +00:00
|
|
|
strcat (path_mapdirectory, SUBDIR_MAPS); // source dir
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-28 09:41:38 +00:00
|
|
|
strcpy (path_finalmapdir, ts);
|
2010-09-29 20:09:11 +00:00
|
|
|
strcat (path_finalmapdir, SUBDIR_MAPS); // dest dir
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
// in Project Inspector
|
|
|
|
[basepathinfo_i setStringValue: [NSString stringWithCString: ts]];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
#if 0 // FIXME: for "out-of-tree" projects ?
|
|
|
|
if ((s = [projectInfo getStringFor: BASEPATHKEY])) {
|
2010-09-11 10:03:41 +00:00
|
|
|
strcpy (path_basepath, s);
|
|
|
|
|
|
|
|
strcpy (path_progdir, s);
|
|
|
|
strcat (path_progdir, "/" SUBDIR_ENT);
|
|
|
|
|
|
|
|
strcpy (path_mapdirectory, s);
|
2010-09-29 20:09:11 +00:00
|
|
|
strcat (path_mapdirectory, "/" SUBDIR_MAPS); // source dir
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
strcpy (path_finalmapdir, s);
|
2010-09-29 20:09:11 +00:00
|
|
|
strcat (path_finalmapdir, "/" SUBDIR_MAPS); // dest dir
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[basepathinfo_i setStringValue: s]; // in Project Inspector
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
#endif
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
if ((s = [projectInfo getStringFor: BSPFULLVIS])) {
|
2010-09-11 10:03:41 +00:00
|
|
|
strcpy (string_fullvis, s);
|
|
|
|
changeString ('@', '\"', string_fullvis);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
if ((s = [projectInfo getStringFor: BSPFASTVIS])) {
|
2010-09-11 10:03:41 +00:00
|
|
|
strcpy (string_fastvis, s);
|
|
|
|
changeString ('@', '\"', string_fastvis);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
if ((s = [projectInfo getStringFor: BSPNOVIS])) {
|
2010-09-11 10:03:41 +00:00
|
|
|
strcpy (string_novis, s);
|
|
|
|
changeString ('@', '\"', string_novis);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
if ((s = [projectInfo getStringFor: BSPRELIGHT])) {
|
2010-09-11 10:03:41 +00:00
|
|
|
strcpy (string_relight, s);
|
|
|
|
changeString ('@', '\"', string_relight);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
if ((s = [projectInfo getStringFor: BSPLEAKTEST])) {
|
2010-09-11 10:03:41 +00:00
|
|
|
strcpy (string_leaktest, s);
|
|
|
|
changeString ('@', '\"', string_leaktest);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
if ((s = [projectInfo getStringFor: BSPENTITIES])) {
|
2010-09-11 10:03:41 +00:00
|
|
|
strcpy (string_entities, s);
|
|
|
|
changeString ('@', '\"', string_entities);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-29 20:09:11 +00:00
|
|
|
// Build list of wads
|
2010-10-04 10:43:33 +00:00
|
|
|
wadList = [projectInfo getArrayFor: WADSKEY];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// Build list of maps & descriptions
|
2010-10-04 10:43:33 +00:00
|
|
|
mapList = [projectInfo getArrayFor: MAPNAMESKEY];
|
|
|
|
descList = [projectInfo getArrayFor: DESCKEY];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
[self initProjSettings];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// Init Project Settings fields
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) initProjSettings
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
[pis_basepath_i setStringValue: [NSString stringWithCString: 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]];
|
|
|
|
[pis_relight_i setStringValue: [NSString stringWithCString: string_relight]];
|
|
|
|
[pis_leaktest_i setStringValue: [NSString stringWithCString: string_leaktest]];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// Add text to the BSP Output window
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) addToOutput: (const char *)string
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int end;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
end = [BSPoutput_i textLength];
|
|
|
|
[BSPoutput_i replaceCharactersInRange: NSMakeRange (end, 0)
|
|
|
|
withString: [NSString stringWithCString: string]];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
end = [BSPoutput_i textLength];
|
|
|
|
[BSPoutput_i setSelectedRange: NSMakeRange (end, 0)];
|
2010-09-11 10:03:41 +00:00
|
|
|
// XXX [BSPoutput_i scrollSelToVisible];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) clearBspOutput: sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int end;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
end = [BSPoutput_i textLength];
|
|
|
|
[BSPoutput_i replaceCharactersInRange: NSMakeRange (0, end) withString: @""];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) print
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
// XXX [BSPoutput_i printPSCode:self];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) initProject
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
[self parseProjectFile];
|
|
|
|
if (projectInfo == NULL)
|
|
|
|
return self;
|
|
|
|
[self initVars];
|
2010-09-29 20:09:11 +00:00
|
|
|
[mapbrowse_i setReusesColumns: YES];
|
2003-03-18 19:48:24 +00:00
|
|
|
[mapbrowse_i loadColumnZero];
|
2010-09-29 20:09:11 +00:00
|
|
|
[pis_wads_i setReusesColumns: YES];
|
2003-03-18 19:48:24 +00:00
|
|
|
[pis_wads_i loadColumnZero];
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
[things_i initEntities];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// Change a character to another in a Storage list of strings
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) changeChar: (char)f to: (char)t in: (id)obj
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i;
|
|
|
|
int max;
|
|
|
|
char *string;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
max = [obj count];
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < max; i++) {
|
2010-09-29 20:09:11 +00:00
|
|
|
string = [obj elementAt: i];
|
2010-09-11 10:03:41 +00:00
|
|
|
changeString (f, t, string);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// Fill the QuakeEd Maps or wads browser
|
|
|
|
// (Delegate method - delegated in Interface Builder)
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) browser: sender createRowsForColumn: (int)column inMatrix: matrix
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-10-04 10:43:33 +00:00
|
|
|
id cell;
|
|
|
|
plitem_t *list;
|
|
|
|
int max;
|
|
|
|
const char *name;
|
|
|
|
int i;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
if (sender == mapbrowse_i) {
|
2003-03-18 19:48:24 +00:00
|
|
|
list = mapList;
|
2010-09-29 20:09:11 +00:00
|
|
|
} else if (sender == pis_wads_i) {
|
2003-03-18 19:48:24 +00:00
|
|
|
list = wadList;
|
2010-09-29 20:09:11 +00:00
|
|
|
} else {
|
2010-10-04 10:43:33 +00:00
|
|
|
list = 0;
|
2010-09-11 08:35:25 +00:00
|
|
|
Sys_Error ("Project: unknown browser to fill");
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-10-04 10:43:33 +00:00
|
|
|
max = list ? PL_A_NumObjects (list) : 0;
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < max; i++) {
|
2010-10-04 10:43:33 +00:00
|
|
|
name = PL_String (PL_ObjectAtIndex (list, i));
|
2003-03-18 19:48:24 +00:00
|
|
|
[matrix addRow];
|
2010-09-29 20:09:11 +00:00
|
|
|
cell = [matrix cellAtRow: i column: 0];
|
|
|
|
[cell setStringValue: [NSString stringWithCString: name]];
|
|
|
|
[cell setLeaf: YES];
|
|
|
|
[cell setLoaded: YES];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// Clicked on a map name or description!
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) clickedOnMap: sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
id matrix;
|
|
|
|
int row;
|
|
|
|
const char *fname;
|
|
|
|
id panel;
|
|
|
|
NSModalSession session;
|
|
|
|
|
|
|
|
matrix = [sender matrixInColumn: 0];
|
|
|
|
row = [matrix selectedRow];
|
2010-09-28 12:40:11 +00:00
|
|
|
fname = va ("%s/%s.map", path_mapdirectory,
|
2010-10-04 10:43:33 +00:00
|
|
|
PL_String (PL_ObjectAtIndex (mapList, row)));
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
panel = NSGetAlertPanel (@"Loading...",
|
2010-09-29 20:09:11 +00:00
|
|
|
@"Loading map. Please wait.", NULL, NULL, NULL);
|
2010-09-19 08:05:34 +00:00
|
|
|
|
|
|
|
session = [NSApp beginModalSessionForWindow: panel];
|
|
|
|
[NSApp runModalSession: session];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[quakeed_i doOpen: fname];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-19 08:05:34 +00:00
|
|
|
[NSApp endModalSession: session];
|
|
|
|
[panel close];
|
|
|
|
NSReleaseAlertPanel (panel);
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) setTextureWad: (const char *)wf
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
int i, c;
|
2010-09-29 20:09:11 +00:00
|
|
|
const char *name;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-12 02:13:35 +00:00
|
|
|
Sys_Printf ("loading %s\n", wf);
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
// set the row in the settings inspector wad browser
|
2010-10-04 10:43:33 +00:00
|
|
|
c = PL_A_NumObjects (wadList);
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < c; i++) {
|
2010-10-04 10:43:33 +00:00
|
|
|
name = PL_String (PL_ObjectAtIndex (wadList, i));
|
2010-09-11 10:03:41 +00:00
|
|
|
if (!strcmp (name, wf)) {
|
2010-09-29 20:09:11 +00:00
|
|
|
[[pis_wads_i matrixInColumn: 0] selectCellAtRow: i column: 0];
|
2003-03-18 19:48:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// update the texture inspector
|
2010-09-29 20:09:11 +00:00
|
|
|
[texturepalette_i initPaletteFromWadfile: wf];
|
|
|
|
[[map_i objectAtIndex: 0] setKey: "wad" toValue: wf];
|
2010-09-11 10:03:41 +00:00
|
|
|
// [inspcontrol_i changeInspectorTo:i_textures];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
[quakeed_i updateAll];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// Clicked on a wad name
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) clickedOnWad: sender
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-10-04 10:43:33 +00:00
|
|
|
id matrix;
|
|
|
|
int row;
|
|
|
|
const char *name;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
matrix = [sender matrixInColumn: 0];
|
|
|
|
row = [matrix selectedRow];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-10-04 10:43:33 +00:00
|
|
|
name = PL_String (PL_ObjectAtIndex (wadList, row));
|
2010-09-29 20:09:11 +00:00
|
|
|
[self setTextureWad: name];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// Read in the <name>.QE_Project file
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) parseProjectFile
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
const char *path;
|
2010-09-11 10:03:41 +00:00
|
|
|
int rtn;
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
path = [preferences_i getProjectPath];
|
2010-09-11 10:03:41 +00:00
|
|
|
if (!path || !path[0] || access (path, 0)) {
|
|
|
|
rtn = NSRunAlertPanel (@"Project Error!",
|
2010-09-29 20:09:11 +00:00
|
|
|
@"A default project has not been found.\n",
|
|
|
|
@"Open Project", NULL, NULL);
|
|
|
|
if ([self openProject] == nil) {
|
|
|
|
while (1)
|
|
|
|
[NSApp terminate: self]; // can't run without a project
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
return self;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[self openProjectFile: path];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// Loads and parses a project file
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) openProjectFile: (const char *)path
|
2010-09-11 10:03:41 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
FILE *fp;
|
|
|
|
struct stat s;
|
|
|
|
|
|
|
|
Sys_Printf ("openProjectFile: %s\n", path);
|
2010-09-11 10:03:41 +00:00
|
|
|
strcpy (path_projectinfo, path);
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
projectInfo = NULL;
|
2010-09-11 10:03:41 +00:00
|
|
|
fp = fopen (path, "r+t");
|
2003-03-18 19:48:24 +00:00
|
|
|
if (fp == NULL)
|
|
|
|
return self;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
stat (path, &s);
|
2003-03-18 19:48:24 +00:00
|
|
|
lastModified = s.st_mtime;
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
projectInfo = [(Dict *)[Dict alloc] initFromFile: fp];
|
2010-09-11 10:03:41 +00:00
|
|
|
fclose (fp);
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (const char *) currentProjectFile
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return path_projectinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// Open a project file
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) openProject
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
const char *path;
|
2010-09-11 10:03:41 +00:00
|
|
|
id openpanel;
|
|
|
|
int rtn;
|
2010-09-29 20:09:11 +00:00
|
|
|
NSString *projtypes[] = {@"qpr"};
|
|
|
|
NSArray *filenames;
|
|
|
|
const char *dir;
|
|
|
|
|
|
|
|
openpanel = [NSOpenPanel new];
|
|
|
|
// [openpanel allowMultipleFiles:NO];
|
|
|
|
// [openpanel chooseDirectories:NO];
|
|
|
|
rtn = [openpanel runModalForTypes: [NSArray arrayWithObjects: projtypes
|
|
|
|
count: 1]];
|
2010-09-11 10:03:41 +00:00
|
|
|
if (rtn == NSOKButton) {
|
2010-09-29 20:09:11 +00:00
|
|
|
filenames = [openpanel filenames];
|
|
|
|
dir = [[openpanel directory] cString];
|
2010-09-12 09:12:02 +00:00
|
|
|
dir = "";
|
2010-09-29 20:09:11 +00:00
|
|
|
path = va ("%s/%s", dir, [[filenames objectAtIndex: 0] cString]);
|
2010-09-11 10:03:41 +00:00
|
|
|
strcpy (path_projectinfo, path);
|
2010-09-29 20:09:11 +00:00
|
|
|
[self openProjectFile: path];
|
2010-09-11 10:03:41 +00:00
|
|
|
return self;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// Search for a string in a List of strings
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
- (int) searchForString: (const char *)str in: (id)obj
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
int i;
|
|
|
|
int max;
|
2010-09-29 20:09:11 +00:00
|
|
|
const char *s;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
max = [obj count];
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < max; i++) {
|
2010-09-29 20:09:11 +00:00
|
|
|
s = (const char *) [obj elementAt: i]; // XXX Storage?
|
2010-09-11 10:03:41 +00:00
|
|
|
if (!strcmp (s, str))
|
2003-03-18 19:48:24 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (const char *) getMapDirectory
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return path_mapdirectory;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (const char *) getFinalMapDirectory
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return path_finalmapdir;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (const char *) getProgDirectory
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return path_progdir;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// Return the WAD name for cmd-8
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
- (const char *) getWAD8
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
if (!path_wad8[0])
|
|
|
|
return NULL;
|
2010-09-29 20:09:11 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return path_wad8;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// Return the WAD name for cmd-9
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
- (const char *) getWAD9
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
if (!path_wad9[0])
|
|
|
|
return NULL;
|
2010-09-29 20:09:11 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return path_wad9;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// Return the WAD name for cmd-0
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
- (const char *) getWAD0
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
if (!path_wad0[0])
|
|
|
|
return NULL;
|
2010-09-29 20:09:11 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return path_wad0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// Return the FULLVIS cmd string
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
- (const char *) getFullVisCmd
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
if (!string_fullvis[0])
|
|
|
|
return NULL;
|
2010-09-29 20:09:11 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return string_fullvis;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// Return the FASTVIS cmd string
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
- (const char *) getFastVisCmd
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
if (!string_fastvis[0])
|
|
|
|
return NULL;
|
2010-09-29 20:09:11 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return string_fastvis;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// Return the NOVIS cmd string
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
- (const char *) getNoVisCmd
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
if (!string_novis[0])
|
|
|
|
return NULL;
|
2010-09-29 20:09:11 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return string_novis;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// Return the RELIGHT cmd string
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
- (const char *) getRelightCmd
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
if (!string_relight[0])
|
|
|
|
return NULL;
|
2010-09-29 20:09:11 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return string_relight;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2010-09-11 10:03:41 +00:00
|
|
|
// Return the LEAKTEST cmd string
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
- (const char *) getLeaktestCmd
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
if (!string_leaktest[0])
|
|
|
|
return NULL;
|
2010-09-29 20:09:11 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return string_leaktest;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (const char *) getEntitiesCmd
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
if (!string_entities[0])
|
|
|
|
return NULL;
|
2010-09-29 20:09:11 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return string_entities;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
2010-09-29 20:09:11 +00:00
|
|
|
|
|
|
|
// ====================================================
|
2003-03-18 19:48:24 +00:00
|
|
|
// C Functions
|
2010-09-29 20:09:11 +00:00
|
|
|
// ====================================================
|
2003-03-18 19:48:24 +00:00
|
|
|
//
|
|
|
|
// Change a character to a different char in a string
|
|
|
|
//
|
2010-09-29 20:09:11 +00:00
|
|
|
void
|
2010-09-11 10:03:41 +00:00
|
|
|
changeString (char cf, char ct, char *string)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-27 18:01:07 +00:00
|
|
|
unsigned int j;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
for (j = 0; j < strlen (string); j++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
if (string[j] == cf)
|
|
|
|
string[j] = ct;
|
2010-09-29 20:09:11 +00:00
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|