Merge Forge branch back into trunk.

This commit is contained in:
Jeff Teunissen 2010-11-28 02:55:01 -05:00
commit 1db9a4b5e8
87 changed files with 7664 additions and 9037 deletions

7
.gitignore vendored
View file

@ -3,6 +3,7 @@
*.la *.la
*.lo *.lo
*.obj *.obj
*.a
*.o *.o
*~ *~
autom4te.cache/ autom4te.cache/
@ -12,6 +13,7 @@ autom4te.cache/
ChangeLog ChangeLog
Makefile Makefile
Makefile.in Makefile.in
core
# / # /
/aclocal.m4 /aclocal.m4
@ -108,6 +110,7 @@ Makefile.in
# /libs/ # /libs/
# /libs/audio/ # /libs/audio/
/libs/audio/testsound
# /libs/audio/cd/ # /libs/audio/cd/
@ -185,7 +188,6 @@ Makefile.in
/nq/include/stamp-h /nq/include/stamp-h
# /nq/source/ # /nq/source/
/nq/source/*.a
/nq/source/*.d /nq/source/*.d
/nq/source/fbset_modes_l.c /nq/source/fbset_modes_l.c
/nq/source/fbset_modes_y.c /nq/source/fbset_modes_y.c
@ -212,7 +214,6 @@ Makefile.in
/qtv/include/config.h /qtv/include/config.h
# /qtv/source/ # /qtv/source/
/qtv/source/*.a
/qtv/source/*.d /qtv/source/*.d
/qtv/source/*.i /qtv/source/*.i
/qtv/source/*.s /qtv/source/*.s
@ -227,7 +228,6 @@ Makefile.in
/qw/include/config.h /qw/include/config.h
# /qw/source/ # /qw/source/
/qw/source/*.a
/qw/source/*.d /qw/source/*.d
/qw/source/*.i /qw/source/*.i
/qw/source/*.s /qw/source/*.s
@ -316,6 +316,7 @@ Makefile.in
/tools/Forge/Bundles/MapEdit/shared_profile_obj /tools/Forge/Bundles/MapEdit/shared_profile_obj
/tools/Forge/Bundles/MapEdit/obj /tools/Forge/Bundles/MapEdit/obj
/tools/Forge/Bundles/MapEdit/*.forgeb /tools/Forge/Bundles/MapEdit/*.forgeb
/tools/Forge/Bundles/MapEdit/*.app
# /tools/bsp2img/ # /tools/bsp2img/
/tools/bsp2img/bsp2img /tools/bsp2img/bsp2img

View file

@ -88,6 +88,11 @@ qboolean Script_GetToken (script_t *script, qboolean crossline);
*/ */
void Script_UngetToken (script_t *script); void Script_UngetToken (script_t *script);
/** Return a pointer to the current token.
\param script The script_t object being parsed
*/
const char *Script_Token (script_t *token);
//@} //@}
#endif//__QF_script_h #endif//__QF_script_h

View file

@ -56,20 +56,20 @@
#define TYP_MIPTEX 68 #define TYP_MIPTEX 68
typedef struct qpic_s { typedef struct qpic_s {
int width, height; int32_t width, height;
byte data[]; // variably sized byte data[]; // variably sized
} qpic_t; } qpic_t;
typedef struct wadinfo_s { typedef struct wadinfo_s {
char id[4]; // should be WAD2 or 2DAW char id[4]; // should be WAD2 or 2DAW
int numlumps; int32_t numlumps;
int infotableofs; int32_t infotableofs;
} wadinfo_t; } wadinfo_t;
typedef struct lumpinfo_s { typedef struct lumpinfo_s {
int filepos; int32_t filepos;
int disksize; int32_t disksize;
int size; // uncompressed int32_t size; // uncompressed
byte type; byte type;
byte compression; byte compression;
byte pad1, pad2; byte pad1, pad2;

View file

@ -157,9 +157,16 @@ Script_GetToken (script_t *script, qboolean crossline)
dstring_copysubstr (script->token, token_p, script->p - token_p); dstring_copysubstr (script->token, token_p, script->p - token_p);
script->p++; script->p++;
} else { } else {
const char *single = "{}()':";
token_p = script->p; token_p = script->p;
while (*script->p && !isspace ((unsigned char) *script->p)) if (strchr (single, *script->p)) {
script->p++; script->p++;
} else {
while (*script->p && !isspace ((unsigned char) *script->p)
&& !strchr (single, *script->p))
script->p++;
}
dstring_copysubstr (script->token, token_p, script->p - token_p); dstring_copysubstr (script->token, token_p, script->p - token_p);
} }
@ -171,3 +178,9 @@ Script_UngetToken (script_t *script)
{ {
script->unget = true; script->unget = true;
} }
VISIBLE const char *
Script_Token (script_t *script)
{
return script->token->str;
}

View file

@ -61,19 +61,20 @@ static __attribute__ ((used)) const char rcsid[] =
static uintptr_t static uintptr_t
wad_get_hash (void *l, void *unused) wad_get_hash (void *l, void *unused)
{ {
char name[16]; char name[17];
int i; int i;
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
name[i] = tolower (((lumpinfo_t *) l)->name[i]); name[i] = tolower (((lumpinfo_t *) l)->name[i]);
name[16] = 0;
return Hash_String (name); return Hash_String (name);
} }
static int static int
wad_compare (void *la, void *lb, void *unused) wad_compare (void *la, void *lb, void *unused)
{ {
return strcasecmp (((lumpinfo_t *) la)->name, return strncasecmp (((lumpinfo_t *) la)->name,
((lumpinfo_t *) lb)->name) == 0; ((lumpinfo_t *) lb)->name, 16) == 0;
} }
VISIBLE wad_t * VISIBLE wad_t *

View file

@ -38,6 +38,7 @@ static const char rcsid[] =
#include <Foundation/NSPathUtilities.h> #include <Foundation/NSPathUtilities.h>
#include <Foundation/NSUserDefaults.h> #include <Foundation/NSUserDefaults.h>
#include <Foundation/NSValue.h> #include <Foundation/NSValue.h>
#include <Foundation/NSDictionary.h>
#include <AppKit/NSButton.h> #include <AppKit/NSButton.h>
#include <AppKit/NSImage.h> #include <AppKit/NSImage.h>

View file

@ -1,58 +0,0 @@
#ifndef Brush_h
#define Brush_h
#include <AppKit/AppKit.h>
#include "SetBrush.h"
#include "EditWindow.h"
extern id brush_i;
extern BOOL brushdraw; // YES when drawing cutbrushes and ents
@interface Brush : SetBrush
{
id cutbrushes_i;
id cutentities_i;
boolean updatemask[MAXBRUSHVERTEX];
BOOL dontdraw; // for modal instance loops
BOOL deleted; // when not visible at all
}
- init;
- initFromSetBrush: br;
- deselect;
- (BOOL)isSelected;
- (BOOL)XYmouseDown: (NSPoint *)pt; // return YES if brush handled
- (BOOL)ZmouseDown: (NSPoint *)pt; // return YES if brush handled
- _keyDown:(NSEvent *)theEvent;
- (NSPoint)centerPoint; // for camera flyby mode
- InstanceSize;
- XYDrawSelf;
- ZDrawSelf;
- CameraDrawSelf;
- flipHorizontal: sender;
- flipVertical: sender;
- rotate90: sender;
- makeTall: sender;
- makeShort: sender;
- makeWide: sender;
- makeNarrow: sender;
- placeEntity: sender;
- cut: sender;
- copy: sender;
- addBrush;
@end
#define Brush_h

View file

@ -1,61 +1,76 @@
#ifndef CameraView_h
#define CameraView_h
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
#include "mathlib.h"
#include "QF/mathlib.h"
#include "SetBrush.h" #include "SetBrush.h"
extern id cameraview_i; #include "render.h"
extern byte renderlist[1024*1024*4]; extern id cameraview_i;
void CameraMoveto(vec3_t p); extern byte renderlist[1024 * 1024 * 4];
void CameraLineto(vec3_t p);
extern BOOL timedrawing; void CameraMoveto (vec3_t p);
void CameraLineto (vec3_t p);
@interface CameraView : NSView extern BOOL timedrawing;
@interface CameraView: NSView
{ {
float xa, ya, za; float xa, ya, za;
float move; float move;
float *zbuffer; float *zbuffer;
unsigned *imagebuffer; unsigned *imagebuffer;
BOOL angleChange; // JR 6.8.95 BOOL angleChange; // JR 6.8.95
vec3_t origin; vec3_t origin;
vec3_t matrix[3]; vec3_t matrix[3];
NSPoint dragspot; NSPoint dragspot;
drawmode_t drawmode; drawmode_t drawmode;
NSBezierPath *xycamera;
NSBezierPath *xycamera_aim;
NSBezierPath *zcamera;
// UI links // UI links
id mode_radio_i; id mode_radio_i;
} }
- setXYOrigin: (NSPoint *)pt; - (id) setXYOrigin: (NSPoint *)pt;
- setZOrigin: (float)pt; - (id) setZOrigin: (float)pt;
- setOrigin: (vec3_t)org angle: (float)angle; - (id) setOrigin: (vec3_t)org
- getOrigin: (vec3_t)org; angle: (float)angle;
- (float)yawAngle; - (id) getOrigin: (vec3_t)org;
- matrixFromAngles; - (float) yawAngle;
- _keyDown: (NSEvent *)theEvent;
- drawMode: sender; - (id) matrixFromAngles;
- setDrawMode: (drawmode_t)mode; - (id) _keyDown: (NSEvent *)theEvent;
- homeView: sender; - (id) drawMode: sender;
- (id) setDrawMode: (drawmode_t)mode;
- XYDrawSelf; // for drawing viewpoint in XY view - (id) homeView: sender;
- ZDrawSelf; // for drawing viewpoint in XY view
- (BOOL)XYmouseDown: (NSPoint *)pt flags:(int)flags; // return YES if brush handled
- (BOOL)ZmouseDown: (NSPoint *)pt flags:(int)flags; // return YES if brush handled
- upFloor:sender; - (void) XYDrawSelf; // for drawing viewpoint in XY view
- downFloor: sender; - (void) ZDrawSelf; // for drawing viewpoint in XY view
- (BOOL) XYmouseDown: (NSPoint *)pt // return YES if brush handled
flags: (int)flags;
- (BOOL) ZmouseDown: (NSPoint *)pt // return YES if brush handled
flags: (int)flags;
- (id) upFloor: sender;
- (id) downFloor: sender;
@end @end
#endif // CameraView_h

File diff suppressed because it is too large Load diff

View file

@ -1,24 +1,32 @@
#ifndef Clipper_h
#define Clipper_h
extern id clipper_i; #include <AppKit/AppKit.h>
@interface Clipper : Object #include "QF/mathlib.h"
#include "SetBrush.h"
extern id clipper_i;
@interface Clipper: NSObject
{ {
int num; int num;
vec3_t pos[3]; vec3_t pos[3];
plane_t plane; plane_t plane;
} }
- (BOOL)hide; - (BOOL) hide;
- XYClick: (NSPoint)pt; - (id) XYClick: (NSPoint)pt;
- (BOOL)XYDrag: (NSPoint *)pt; - (BOOL) XYDrag: (NSPoint *)pt;
- ZClick: (NSPoint)pt; - (id) ZClick: (NSPoint)pt;
- carve; - (id) carve;
- flipNormal; - (void) flipNormal;
- (BOOL)getFace: (face_t *)pl; - (BOOL) getFace: (face_t *)pl;
- cameraDrawSelf; - (void) cameraDrawSelf;
- XYDrawSelf; - (void) XYDrawSelf;
- ZDrawSelf; - (void) ZDrawSelf;
@end @end
#endif // Clipper_h

View file

@ -1,81 +1,77 @@
#include "QF/sys.h"
#include "qedefs.h" #include "Clipper.h"
#include "Map.h"
#include "XYView.h"
#include "ZView.h"
#include "CameraView.h"
#include "QuakeEd.h"
#include <AppKit/NSGraphics.h> id clipper_i;
#include <AppKit/DPSOperators.h> extern NSBezierPath *path;
id clipper_i;
@implementation Clipper @implementation Clipper
- init - (id) init
{ {
[super init]; [super init];
clipper_i = self; clipper_i = self;
return self; return self;
} }
- (BOOL)hide - (BOOL) hide
{ {
int oldnum; int oldnum;
oldnum = num; oldnum = num;
num = 0; num = 0;
return (oldnum > 0); return (oldnum > 0);
} }
- flipNormal - (void) flipNormal
{ {
vec3_t temp; vec3_t temp;
if (num == 2) if (num == 2) {
{
VectorCopy (pos[0], temp); VectorCopy (pos[0], temp);
VectorCopy (pos[1], pos[0]); VectorCopy (pos[1], pos[0]);
VectorCopy (temp, pos[1]); VectorCopy (temp, pos[1]);
} } else if (num == 3) {
else if (num == 3)
{
VectorCopy (pos[0], temp); VectorCopy (pos[0], temp);
VectorCopy (pos[2], pos[0]); VectorCopy (pos[2], pos[0]);
VectorCopy (temp, pos[2]); VectorCopy (temp, pos[2]);
} } else {
else Sys_Printf ("no clipplane\n");
{
qprintf ("no clipplane");
NSBeep (); NSBeep ();
} }
return self;
} }
- (BOOL)getFace: (face_t *)f - (BOOL) getFace: (face_t *)f
{ {
vec3_t v1, v2, norm; vec3_t v1, v2, norm;
int i; int i;
VectorCopy (vec3_origin, plane.normal); VectorCopy (vec3_origin, plane.normal);
plane.dist = 0; plane.dist = 0;
if (num < 2) if (num < 2)
return NO; return NO;
if (num == 2) if (num == 2) {
{
VectorCopy (pos[0], pos[2]); VectorCopy (pos[0], pos[2]);
pos[2][2] += 16; pos[2][2] += 16;
} }
for (i=0 ; i<3 ; i++) for (i = 0; i < 3; i++)
VectorCopy (pos[i], f->planepts[i]); VectorCopy (pos[i], f->planepts[i]);
VectorSubtract (pos[2], pos[0], v1); VectorSubtract (pos[2], pos[0], v1);
VectorSubtract (pos[1], pos[0], v2); VectorSubtract (pos[1], pos[0], v2);
CrossProduct (v1, v2, norm); CrossProduct (v1, v2, norm);
VectorNormalize (norm); VectorNormalize (norm);
if ( !norm[0] && !norm[1] && !norm[2] ) if (!norm[0] && !norm[1] && !norm[2])
return NO; return NO;
[texturepalette_i getTextureDef: &f->texture]; [texturepalette_i getTextureDef: &f->texture];
return YES; return YES;
@ -86,20 +82,18 @@ id clipper_i;
XYClick XYClick
================ ================
*/ */
- XYClick: (NSPoint)pt - (id) XYClick: (NSPoint)pt
{ {
int i; int i;
vec3_t new; vec3_t new;
new[0] = [xyview_i snapToGrid: pt.x]; new[0] = [xyview_i snapToGrid: pt.x];
new[1] = [xyview_i snapToGrid: pt.y]; new[1] = [xyview_i snapToGrid: pt.y];
new[2] = [map_i currentMinZ]; new[2] = [map_i currentMinZ];
// see if a point is allready there // see if a point is allready there
for (i=0 ; i<num ; i++) for (i = 0; i < num; i++) {
{ if (new[0] == pos[i][0] && new[1] == pos[i][1]) {
if (new[0] == pos[i][0] && new[1] == pos[i][1])
{
if (pos[i][2] == [map_i currentMinZ]) if (pos[i][2] == [map_i currentMinZ])
pos[i][2] = [map_i currentMaxZ]; pos[i][2] = [map_i currentMaxZ];
else else
@ -108,16 +102,15 @@ XYClick
return self; return self;
} }
} }
if (num == 3) if (num == 3)
num = 0; num = 0;
VectorCopy (new, pos[num]); VectorCopy (new, pos[num]);
num++; num++;
[quakeed_i updateAll]; [quakeed_i updateAll];
return self; return self;
} }
@ -126,45 +119,40 @@ XYClick
XYDrag XYDrag
================ ================
*/ */
- (BOOL)XYDrag: (NSPoint *)pt - (BOOL) XYDrag: (NSPoint *)pt
{ {
int i; int i;
for (i=0 ; i<3 ; i++) for (i = 0; i < 3; i++) {
{ if (fabs (pt->x - pos[i][0] > 10) || fabs (pt->y - pos[i][1] > 10))
if (fabs(pt->x - pos[i][0] > 10) || fabs(pt->y - pos[i][1] > 10) ) continue; // drag this point
continue;
// drag this point
} }
return NO; return NO;
} }
- ZClick: (NSPoint)pt - (id) ZClick: (NSPoint)pt
{ {
return self; return self;
} }
//============================================================================= // =============================================================================
- carve - (id) carve
{ {
[map_i makeSelectedPerform: @selector(carveByClipper)]; [map_i makeSelectedPerform: @selector (carveByClipper)];
num = 0; num = 0;
return self; return self;
} }
- (void) cameraDrawSelf
- cameraDrawSelf
{ {
vec3_t mid; vec3_t mid;
int i; int i;
linecolor (1,0.5,0);
for (i=0 ; i<num ; i++) linecolor (1, 0.5, 0);
{
for (i = 0; i < num; i++) {
VectorCopy (pos[i], mid); VectorCopy (pos[i], mid);
mid[0] -= 8; mid[0] -= 8;
mid[1] -= 8; mid[1] -= 8;
@ -172,7 +160,7 @@ XYDrag
mid[0] += 16; mid[0] += 16;
mid[1] += 16; mid[1] += 16;
CameraLineto (mid); CameraLineto (mid);
VectorCopy (pos[i], mid); VectorCopy (pos[i], mid);
mid[0] -= 8; mid[0] -= 8;
mid[1] += 8; mid[1] += 8;
@ -181,50 +169,54 @@ XYDrag
mid[1] -= 16; mid[1] -= 16;
CameraLineto (mid); CameraLineto (mid);
} }
return self;
} }
- XYDrawSelf - (void) XYDrawSelf
{ {
int i; int i;
char text[8]; NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
PSsetrgbcolor (1,0.5,0);
//XXX PSselectfont("Helvetica-Medium",10/[xyview_i currentScale]);
PSrotate(0);
for (i=0 ; i<num ; i++) [[NSColor colorWithCalibratedRed: 1.0 green: 0.5 blue: 0.0 alpha: 1.0]
{ set];
PSmoveto (pos[i][0]-4, pos[i][1]-4);
sprintf (text, "%i", i); [[NSFont systemFontOfSize: 10 / [xyview_i currentScale]] set];
PSshow (text);
PSstroke (); [path removeAllPoints];
PSarc ( pos[i][0], pos[i][1], 10, 0, 360); for (i = 0; i < num; i++) {
PSstroke (); NSString *s = [NSString stringWithFormat: @"%i", i];
[s drawAtPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)
withAttributes: attribs];
// [path moveToPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)];
[path
appendBezierPathWithArcWithCenter: NSMakePoint (pos[i][0], pos[i][1])
radius: 10
startAngle: 0
endAngle: 360];
} }
return self; [path stroke];
} }
- ZDrawSelf - (void) ZDrawSelf
{ {
int i; int i;
char text[8]; NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
PSsetrgbcolor (1,0.5,0);
//XXX PSselectfont("Helvetica-Medium",10/[zview_i currentScale]);
PSrotate(0);
for (i=0 ; i<num ; i++) [[NSColor colorWithCalibratedRed: 1. green: 0.5 blue: 0. alpha: 1.] set];
{ [[NSFont systemFontOfSize: 10 / [xyview_i currentScale]] set];
PSmoveto (-28+i*8 - 4, pos[i][2]-4);
sprintf (text, "%i", i); [path removeAllPoints];
PSshow (text); for (i = 0; i < num; i++) {
PSstroke (); NSString *s = [NSString stringWithFormat: @"%i", i];
PSarc ( -28+i*8, pos[i][2], 10, 0, 360); [s drawAtPoint: NSMakePoint (-28 + i * 8 - 4, pos[i][2] - 4)
PSstroke (); withAttributes: attribs];
// [path moveToPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)];
[path
appendBezierPathWithArcWithCenter: NSMakePoint (-28 + i * 8, pos[i][2])
radius: 10
startAngle: 0
endAngle: 360];
} }
return self; [path stroke];
} }
@end @end

View file

@ -1,47 +1,40 @@
#ifndef Dict_h
#define Dict_h
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
typedef struct #include "Storage.h"
{
char *key;
char *value;
} dict_t;
@interface Dict:Storage struct script_s;
@interface Dict: NSObject
{ {
struct plitem_s *plist;
} }
- initFromFile:(FILE *)fp; - (id) initFromFile: (FILE *)fp;
- (id) parseMultipleFrom:(char *)value; - (int) getValueUnits: (const char *)key;
- (int) getValueUnits:(char *)key;
- delString:(char *)string fromValue:(char *)key;
- addString:(char *)string toValue:(char *)key;
- (char *)convertListToString:(id)list;
- (char *)getStringFor:(char *)name;
- removeKeyword:(char *)key;
- (unsigned int)getValueFor:(char *)name;
- changeStringFor:(char *)key to:(char *)value;
- (dict_t *) findKeyword:(char *)key;
- writeBlockTo:(FILE *)fp; - (struct plitem_s *) getArrayFor: (const char *)name;
- writeFile:(char *)path; - (const char *) getStringFor: (const char *)name;
- (unsigned int) getValueFor: (const char *)name;
- (id) changeStringFor: (const char *)key to: (const char *)value;
// INTERNAL - (id) writeBlockTo: (FILE *)fp;
- init; - (id) writeFile: (const char *)path;
- (id) parseBraceBlock:(FILE *)fp;
- setupMultiple:(char *)value;
- (char *)getNextParameter;
@end @end
int GetNextChar(FILE *fp); int GetNextChar (FILE * fp);
void CopyUntilWhitespc(FILE *fp,char *buffer); void CopyUntilWhitespc (FILE * fp, char *buffer);
void CopyUntilQuote(FILE *fp,char *buffer); void CopyUntilQuote (FILE * fp, char *buffer);
int FindBrace(FILE *fp); int FindBrace (FILE * fp);
int FindQuote(FILE *fp); int FindQuote (FILE * fp);
int FindWhitespc(FILE *fp); int FindWhitespc (FILE * fp);
int FindNonwhitespc(FILE *fp); int FindNonwhitespc (FILE * fp);
char *FindWhitespcInBuffer(char *buffer); char *FindWhitespcInBuffer (char *buffer);
char *FindNonwhitespcInBuffer(char *buffer); char *FindNonwhitespcInBuffer (char *buffer);
#endif // Dict_h

View file

@ -1,29 +1,26 @@
#include "QF/dstring.h"
#include "QF/qfplist.h"
#include "QF/script.h"
#include "QF/sys.h"
#include "QF/va.h"
#include "qedefs.h" #include "Dict.h"
@implementation Dict @implementation Dict
- init /*
- (id) print
{ {
[super initCount:0 NSUInteger i;
elementSize:sizeof(dict_t) dict_t *d;
description:NULL];
return self;
}
- print for (i = 0; i < numElements; i++) {
{
int i;
dict_t *d;
for (i=0 ; i<numElements ; i++)
{
d = [self elementAt: i]; d = [self elementAt: i];
printf ("%s : %s\n",d->key, d->value); printf ("%s : %s\n", d->key, d->value);
} }
return self; return self;
} }
*/
/* /*
=========== ===========
copyFromZone copyFromZone
@ -31,553 +28,128 @@ copyFromZone
JDC JDC
=========== ===========
*/ */
- copyFromZone:(NSZone *)zone - (id) copy
{ {
id new; Sys_Printf ("Dict copy: not implemented\n");
int i;
dict_t *d;
char *old;
new = [super copyFromZone: zone];
for (i=0 ; i<numElements ; i++)
{
d = [self elementAt: i];
old = d->key;
d->key = malloc(strlen(old)+1);
strcpy (d->key, old);
old = d->value;
d->value = malloc(strlen(old)+1);
strcpy (d->value, old);
}
return new;
}
- initFromFile:(FILE *)fp
{
[self init];
return [self parseBraceBlock:fp];
}
//===============================================
//
// Dictionary pair functions
//
//===============================================
//
// Write a { } block out to a FILE*
//
- writeBlockTo:(FILE *)fp
{
int max;
int i;
dict_t *d;
fprintf(fp,"{\n");
max = [super count];
for (i = 0;i < max;i++)
{
d = [super elementAt:i];
fprintf(fp,"\t{\"%s\"\t\"%s\"}\n",d->key,d->value);
}
fprintf(fp,"}\n");
return self;
}
//
// Write a single { } block out
//
- writeFile:(char *)path
{
FILE *fp;
fp = fopen(path,"w+t");
if (fp != NULL)
{
printf("Writing dictionary file %s.\n",path);
fprintf(fp,"// QE_Project file %s\n",path);
[self writeBlockTo:fp];
fclose(fp);
}
else
{
printf("Error writing %s!\n",path);
return NULL;
}
return self;
}
//===============================================
//
// Utility methods
//
//===============================================
//
// Find a keyword in storage
// Returns * to dict_t, otherwise NULL
//
- (dict_t *) findKeyword:(char *)key
{
int max;
int i;
dict_t *d;
max = [super count];
for (i = 0;i < max;i++)
{
d = [super elementAt:i];
if (!strcmp(d->key,key))
return d;
}
return NULL;
}
//
// Change a keyword's string
//
- changeStringFor:(char *)key to:(char *)value
{
dict_t *d;
dict_t newd;
d = [self findKeyword:key];
if (d != NULL)
{
free(d->value);
d->value = malloc(strlen(value)+1);
strcpy(d->value,value);
}
else
{
newd.key = malloc(strlen(key)+1);
strcpy(newd.key,key);
newd.value = malloc(strlen(value)+1);
strcpy(newd.value,value);
[self addElement:&newd];
}
return self;
}
//
// Search for keyword, return the string *
//
- (char *)getStringFor:(char *)name
{
dict_t *d;
d = [self findKeyword:name];
if (d != NULL)
return d->value;
return "";
}
//
// Search for keyword, return the value
//
- (unsigned int)getValueFor:(char *)name
{
dict_t *d;
d = [self findKeyword:name];
if (d != NULL)
return atol(d->value);
return 0; return 0;
} }
// - (id) initFromFile: (FILE *)fp
// Return # of units in keyword's value
//
- (int) getValueUnits:(char *)key
{ {
id temp; dstring_t *text = dstring_newstr ();
int count; char *str;
size_t read;
temp = [self parseMultipleFrom:key]; const size_t readsize = 1024;
count = [temp count];
[temp free];
return count;
}
// [self init];
// Convert List to string
//
- (char *)convertListToString:(id)list
{
int i;
int max;
char tempstr[4096];
char *s;
char *newstr;
max = [list count];
tempstr[0] = 0;
for (i = 0;i < max;i++)
{
s = [list elementAt:i];
strcat(tempstr,s);
strcat(tempstr," ");
}
newstr = malloc(strlen(tempstr)+1);
strcpy(newstr,tempstr);
return newstr;
}
// do {
// JDC: I wrote this to simplify removing vectors str = dstring_reservestr (text, readsize);
// read = fread (str, 1, readsize, fp);
- removeKeyword:(char *)key if (read)
{ str[read] = 0;
dict_t *d; } while (read == readsize);
d = [self findKeyword:key];
if (d == NULL) plist = PL_GetPropertyList (text->str);
return self; dstring_delete (text);
[self removeElementAt:d - (dict_t*)dataPtr]; if (!plist)
return 0;
return self; return self;
} }
// - (void) dealloc
// Delete string from keyword's value
//
- delString:(char *)string fromValue:(char *)key
{ {
id temp; if (plist)
int count; PL_Free (plist);
int i; [super dealloc];
char *s; }
dict_t *d;
// ===============================================
d = [self findKeyword:key]; //
if (d == NULL) // Dictionary pair functions
return NULL; //
temp = [self parseMultipleFrom:key]; // ===============================================
count = [temp count];
for (i = 0;i < count;i++) - (id) writeBlockTo: (FILE *)fp
{ {
s = [temp elementAt:i]; char *data;
if (!strcmp(s,string))
{ data = PL_WritePropertyList (plist);
[temp removeElementAt:i]; fputs (data, fp);
free(d->value); free (data);
d->value = [self convertListToString:temp];
[temp free];
break;
}
}
return self; return self;
} }
// - (id) writeFile: (const char *)path
// Add string to keyword's value
//
- addString:(char *)string toValue:(char *)key
{ {
char *newstr; FILE *fp;
char spacing[] = "\t";
dict_t *d; fp = fopen (path, "w+t");
if (fp != NULL) {
d = [self findKeyword:key]; printf ("Writing dictionary file %s.\n", path);
if (d == NULL) fprintf (fp, "// QE_Project file %s\n", path);
[self writeBlockTo: fp];
fclose (fp);
} else {
printf ("Error writing %s!\n", path);
return NULL; return NULL;
newstr = malloc(strlen(string) + strlen(d->value) + strlen(spacing) + 1); }
strcpy(newstr,d->value);
strcat(newstr,spacing);
strcat(newstr,string);
free(d->value);
d->value = newstr;
return self; return self;
} }
//=============================================== // ===============================================
// //
// Use these for multiple parameters in a keyword value // Utility methods
// //
//=============================================== // ===============================================
char *searchStr;
char item[4096];
- setupMultiple:(char *)value // Change a keyword's string
- (id) changeStringFor: (const char *)key to: (const char *)value
{ {
searchStr = value; PL_D_AddObject (plist, key, PL_NewString (value));
return self; return self;
} }
- (char *)getNextParameter - (plitem_t *) getArrayFor: (const char *)name
{ {
char *s; plitem_t *item;
item = PL_ObjectForKey (plist, name);
if (!searchStr) if (item && PL_Type (item) == QFArray)
return NULL; return item;
strcpy(item,searchStr); return 0;
s = FindWhitespcInBuffer(item);
if (!*s)
searchStr = NULL;
else
{
*s = 0;
searchStr = FindNonwhitespcInBuffer(s+1);
}
return item;
} }
// // Search for keyword, return the string *
// Parses a keyvalue string & returns a Storage full of those items - (const char *) getStringFor: (const char *)name
//
- (id) parseMultipleFrom:(char *)key
{ {
#define ITEMSIZE 128 plitem_t *item;
id stuff; const char *str;
char string[ITEMSIZE];
char *s; item = PL_ObjectForKey (plist, name);
if (item && (str = PL_String (item)))
s = [self getStringFor:key]; return str;
if (s == NULL) return "";
return NULL;
stuff = [[Storage alloc]
initCount:0
elementSize:ITEMSIZE
description:NULL];
[self setupMultiple:s];
while((s = [self getNextParameter]))
{
bzero(string,ITEMSIZE);
strcpy(string,s);
[stuff addElement:string];
}
return stuff;
} }
//=============================================== // Search for keyword, return the value
// - (unsigned int) getValueFor: (const char *)name
// Dictionary pair parsing
//
//===============================================
//
// parse all keyword/value pairs within { } 's
//
- (id) parseBraceBlock:(FILE *)fp
{ {
int c; return atol ([self getStringFor: name]);
dict_t pair; }
char string[1024];
c = FindBrace(fp);
if (c == -1)
return NULL;
while((c = FindBrace(fp)) != '}')
{
if (c == -1)
return NULL;
// c = FindNonwhitespc(fp);
// if (c == -1)
// return NULL;
// CopyUntilWhitespc(fp,string);
// JDC: fixed to allow quoted keys // Return # of units in keyword's value
c = FindNonwhitespc(fp); - (int) getValueUnits: (const char *)key
if (c == -1) {
return NULL; plitem_t *item;
c = fgetc(fp);
if ( c == '\"')
CopyUntilQuote(fp,string);
else
{
ungetc (c,fp);
CopyUntilWhitespc(fp,string);
}
pair.key = malloc(strlen(string)+1); item = PL_ObjectForKey (plist, key);
strcpy(pair.key,string); if (!item || PL_Type (item) != QFArray)
return 0;
c = FindQuote(fp);
CopyUntilQuote(fp,string); return PL_A_NumObjects (item);
pair.value = malloc(strlen(string)+1);
strcpy(pair.value,string);
[super addElement:&pair];
c = FindBrace(fp);
}
return self;
} }
@end @end
//===============================================
//
// C routines for string parsing
//
//===============================================
int GetNextChar(FILE *fp)
{
int c;
int c2;
c = getc(fp);
if (c == EOF)
return -1;
if (c == '/') // parse comments
{
c2 = getc(fp);
if (c2 == '/')
{
while((c2 = getc(fp)) != '\n');
c = getc(fp);
}
else
ungetc(c2,fp);
}
return c;
}
void CopyUntilWhitespc(FILE *fp,char *buffer)
{
int count = 800;
int c;
while(count--)
{
c = GetNextChar(fp);
if (c == EOF)
return;
if (c <= ' ')
{
*buffer = 0;
return;
}
*buffer++ = c;
}
}
void CopyUntilQuote(FILE *fp,char *buffer)
{
int count = 800;
int c;
while(count--)
{
c = GetNextChar(fp);
if (c == EOF)
return;
if (c == '\"')
{
*buffer = 0;
return;
}
*buffer++ = c;
}
}
int FindBrace(FILE *fp)
{
int count = 800;
int c;
while(count--)
{
c = GetNextChar(fp);
if (c == EOF)
return -1;
if (c == '{' ||
c == '}')
return c;
}
return -1;
}
int FindQuote(FILE *fp)
{
int count = 800;
int c;
while(count--)
{
c = GetNextChar(fp);
if (c == EOF)
return -1;
if (c == '\"')
return c;
}
return -1;
}
int FindWhitespc(FILE *fp)
{
int count = 800;
int c;
while(count--)
{
c = GetNextChar(fp);
if (c == EOF)
return -1;
if (c <= ' ')
{
ungetc(c,fp);
return c;
}
}
return -1;
}
int FindNonwhitespc(FILE *fp)
{
int count = 800;
int c;
while(count--)
{
c = GetNextChar(fp);
if (c == EOF)
return -1;
if (c > ' ')
{
ungetc(c,fp);
return c;
}
}
return -1;
}
char *FindWhitespcInBuffer(char *buffer)
{
int count = 1000;
char *b = buffer;
while(count--)
if (*b <= ' ')
return b;
else
b++;
return NULL;
}
char *FindNonwhitespcInBuffer(char *buffer)
{
int count = 1000;
char *b = buffer;
while(count--)
if (*b > ' ')
return b;
else
b++;
return NULL;
}

View file

@ -1,12 +0,0 @@
#include <AppKit/AppKit.h>
@interface DictList:List
{
}
- initListFromFile:(FILE *)fp;
- writeListFile:(char *)filename;
- (id) findDictKeyword:(char *)key;
@end

View file

@ -1,69 +0,0 @@
#include "qedefs.h"
@implementation DictList
//
// Read in variable # of objects from FILE *
//
- initListFromFile:(FILE *)fp
{
id d;
[super init];
do
{
d = [(Dict *)[Dict alloc] initFromFile:fp];
if (d != NULL)
[self addObject:d];
} while(d != NULL);
[d free];
return self;
}
//
// Write out list file
//
- writeListFile:(char *)filename
{
FILE *fp;
int i;
id obj;
fp = fopen(filename,"w+t");
if (fp == NULL)
return NULL;
fprintf(fp,"// Object List written by QuakeEd\n");
for (i = 0;i < maxElements;i++)
{
obj = [self objectAt:i];
[obj writeBlockTo:fp];
}
fclose(fp);
return self;
}
//
// Find the keyword in all the Dict objects
//
- (id) findDictKeyword:(char *)key
{
int i;
dict_t *d;
id dict;
for (i = 0;i < maxElements;i++)
{
dict = [self objectAt:i];
d = [(Dict *)dict findKeyword:key];
if (d != NULL)
return dict;
}
return NULL;
}
@end

View file

@ -1,40 +1,46 @@
#ifndef Entity_h
#define Entity_h
#define MAX_KEY 64 #include <AppKit/AppKit.h>
#define MAX_VALUE 128
typedef struct epair_s #include "QF/mathlib.h"
{
struct epair_s *next; typedef struct epair_s {
char key[MAX_KEY]; struct epair_s *next;
char value[MAX_VALUE]; char *key;
char *value;
} epair_t; } epair_t;
// an Entity is a list of brush objects, with additional key / value info // an Entity is a list of brush objects, with additional key / value info
@interface Entity : NSObject <NSCopying, NSMutableCopying> @interface Entity: NSMutableArray
{ {
epair_t *epairs; NSMutableArray *array;
BOOL modifiable; epair_t *epairs;
BOOL modifiable;
} }
- initClass: (char *)classname; - (Entity *) initClass: (const char *)classname;
- initFromTokens; - (Entity *) initFromScript: (struct script_s *)script;
- free; - (oneway void) dealloc;
- (BOOL)modifiable; - (BOOL) modifiable;
- setModifiable: (BOOL)m; - (void) setModifiable: (BOOL)m;
- (char *)targetname; - (const char *) targetname;
- writeToFILE: (FILE *)f region:(BOOL)reg; - (void) writeToFILE: (FILE *)f region: (BOOL)reg;
- (char *)valueForQKey: (char *)k; - (const char *) valueForQKey: (const char *)k;
- getVector: (vec3_t)v forKey: (char *)k; - (void) getVector: (vec3_t)v forKey: (const char *)k;
- setKey:(char *)k toValue:(char *)v;
- (int)numPairs; - (void) setKey: (const char *)k
- (epair_t *)epairs; toValue: (const char *)v;
- removeKeyPair: (char *)key;
- (int) numPairs;
- (epair_t *) epairs;
- (void) removeKeyPair: (const char *)key;
@end @end
#endif // Entity_h

View file

@ -1,27 +1,36 @@
#include "QF/dstring.h"
#include "QF/script.h"
#include "QF/sys.h"
#include "QF/va.h"
#include "qedefs.h" #include "Entity.h"
#include "EntityClass.h"
#include "TexturePalette.h"
#include "SetBrush.h"
#include "Map.h"
#include "CameraView.h"
#define THING Entity
#include "THING+NSArray.m"
@implementation Entity @implementation Entity
vec3_t bad_mins = {-8, -8, -8}; vec3_t bad_mins = {-8, -8, -8};
vec3_t bad_maxs = {8, 8, 8}; vec3_t bad_maxs = {8, 8, 8};
- createFixedBrush: (vec3_t)org - (id) createFixedBrush: (vec3_t)org
{ {
vec3_t emins, emaxs; vec3_t emins, emaxs;
float *v, *v2, *color; float *v, *v2, *color;
id new; id new;
texturedef_t td; texturedef_t td;
// get class // get class
new = [entity_classes_i classForName: [self valueForQKey: "classname"]]; new = [entity_classes_i classForName: [self valueForQKey: "classname"]];
if (new) if (new) {
{
v = [new mins]; v = [new mins];
v2 = [new maxs]; v2 = [new maxs];
} } else {
else
{
v = bad_mins; v = bad_mins;
v2 = bad_maxs; v2 = bad_maxs;
} }
@ -29,239 +38,227 @@ vec3_t bad_maxs = {8, 8, 8};
color = [new drawColor]; color = [new drawColor];
modifiable = NO; modifiable = NO;
memset(&td,0,sizeof(td)); memset (&td, 0, sizeof (td));
strcpy (td.texture,"entity"); strcpy (td.texture, "entity");
VectorAdd (org, v, emins); VectorAdd (org, v, emins);
VectorAdd (org, v2, emaxs); VectorAdd (org, v2, emaxs);
new = [[SetBrush alloc] initOwner: self mins:emins maxs:emaxs new = [[SetBrush alloc] initOwner: self mins: emins maxs: emaxs texture: &td];
texture: &td];
[new setEntityColor: color]; [new setEntityColor: color];
[self addObject: new]; [self addObject: new];
return self; return self;
} }
- copyWithZone:(NSZone *)zone - (id) copyWithZone: (NSZone *) zone
{ {
id new, nb; id new, nb;
epair_t *e; epair_t *e;
int i; int i, c;
new = [[Entity alloc] init]; new = [[Entity allocWithZone: zone] init];
[new setModifiable: modifiable]; [new setModifiable: modifiable];
for (e=epairs ; e ; e=e->next) for (e = epairs; e; e = e->next) {
{ // don't copy target and targetname fields // don't copy target and targetname fields
if (strncmp(e->key,"target",6)) if (strncmp (e->key, "target", 6))
[new setKey: e->key toValue: e->value]; [new setKey: e->key toValue: e->value];
} }
for (i=0 ; i<numElements ; i++) c = [self count];
{ for (i = 0; i < c; i++) {
nb = [[self objectAt: i] copy]; nb = [[self objectAtIndex: i] copy];
[nb setParent: new]; [nb setParent: new];
[new addObject: nb]; [new addObject: nb];
} }
return new; return new;
} }
- initClass: (char *)classname - (Entity *) initClass: (const char *)classname
{ {
id new; id new;
esize_t esize; esize_t esize;
char value[80]; vec3_t min, max;
vec3_t min, max; int org[3];
float *v; float *v;
[super init]; self = [super init];
array = [[NSMutableArray alloc] init];
modifiable = YES; modifiable = YES;
[self setKey: "classname" toValue:classname]; [self setKey: "classname" toValue: classname];
// get class // get class
new = [entity_classes_i classForName: [self valueForQKey: "classname"]]; new = [entity_classes_i classForName: [self valueForQKey: "classname"]];
if (!new) if (!new)
esize = esize_model; esize = esize_model;
else else
esize = [new esize]; esize = [new esize];
// create a brush if needed // create a brush if needed
if (esize == esize_fixed) if (esize == esize_fixed) {
{
v = [new mins]; v = [new mins];
[[map_i selectedBrush] getMins: min maxs: max]; [[map_i selectedBrush] getMins: min maxs: max];
VectorSubtract (min, v, min); VectorSubtract (min, v, min);
VectorCopy (min, org);
sprintf (value, "%i %i %i",(int)min[0], (int)min[1], (int)min[2]);
[self setKey:"origin" toValue: value]; // convert to integer
[self setKey: "origin" toValue: va ("%i %i %i", org[0], org[1], org[2])];
[self createFixedBrush: min]; [self createFixedBrush: min];
} } else {
else
modifiable = YES; modifiable = YES;
}
return self; return self;
} }
- (oneway void) dealloc
- free
{ {
epair_t *e, *n; epair_t *e, *n;
for (e=epairs ; e ; e=n) for (e = epairs; e; e = n) {
{
n = e->next; n = e->next;
free (e->key);
free (e->value);
free (e); free (e);
} }
return [super free]; [array release];
[super dealloc];
} }
- (BOOL)modifiable - (BOOL) modifiable
{ {
return modifiable; return modifiable;
} }
- setModifiable: (BOOL)m - (void) setModifiable: (BOOL)m
{ {
modifiable = m; modifiable = m;
return self; return;
} }
- removeObject: o - (void) removeObject: (id)o
{ {
o = [super removeObject: o]; [super removeObject: o];
if (numElements) if ([self count])
return o; return;
// the entity is empty, so remove the entire thing
if ( self == [map_i objectAt: 0]) // the entity is empty, so remove the entire thing
return o; // never remove the world if (self == [map_i objectAtIndex: 0]) // unless it's the world...
return;
[map_i removeObject: self]; [map_i removeObject: self];
[self free]; [self release];
return o;
} }
- (const char *) valueForQKey: (const char *)k
- (char *)valueForQKey: (char *)k
{ {
epair_t *e; epair_t *e;
static char ret[64];
for (e = epairs; e; e = e->next) {
for (e=epairs ; e ; e=e->next) if (!strcmp (k, e->key))
if (!strcmp(k,e->key)) return e->value;
{ }
strcpy (ret, e->value);
return ret;
}
return ""; return "";
} }
- getVector: (vec3_t)v forKey: (char *)k - (void) getVector: (vec3_t)v
forKey: (const char *)k
{ {
char *c; const char *c;
c = [self valueForQKey: k]; c = [self valueForQKey: k];
v[0] = v[1] = v[2] = 0; v[0] = v[1] = v[2] = 0;
sscanf (c, "%f %f %f", &v[0], &v[1], &v[2]); sscanf (c, "%f %f %f", &v[0], &v[1], &v[2]);
}
- (id) print
{
epair_t *e;
for (e = epairs; e; e = e->next)
printf ("%20s : %20s\n", e->key, e->value);
return self; return self;
} }
- print - (void) setKey: (const char *)k
toValue: (const char *)v
{ {
epair_t *e; epair_t *e;
for (e=epairs ; e ; e=e->next)
printf ("%20s : %20s\n",e->key, e->value);
return self;
}
- setKey:(char *)k toValue:(char *)v
{
epair_t *e;
if (strlen(k) > MAX_KEY)
Error ("setKey: %s > MAX_KEY", k);
if (strlen(v) > MAX_VALUE)
Error ("setKey: %s > MAX_VALUE", v);
while (*k && *k <= ' ') while (*k && *k <= ' ')
k++; k++;
if (!*k)
return self; // don't set NULL values
for (e=epairs ; e ; e=e->next)
if (!strcmp(k,e->key))
{
memset (e->value, 0, sizeof(e->value));
strcpy (e->value, v);
return self;
}
e = malloc (sizeof(epair_t)); // don't set NULL values
memset (e, 0, sizeof(epair_t)); if (!*k)
return;
strcpy (e->key, k);
strcpy (e->value, v); for (e = epairs; e; e = e->next) {
if (!strcmp (k, e->key)) {
if (e->value == v)
return;
free (e->value);
e->value = strdup (v);
return;
}
}
e = malloc (sizeof (epair_t));
e->key = strdup (k);
e->value = strdup (v);
e->next = epairs; e->next = epairs;
epairs = e; epairs = e;
return self;
} }
- (int)numPairs - (int) numPairs
{ {
int i; int i;
epair_t *e; epair_t *e;
i=0; i = 0;
for (e=epairs ; e ; e=e->next) for (e = epairs; e; e = e->next)
i++; i++;
return i; return i;
} }
- (epair_t *)epairs - (epair_t *) epairs
{ {
return epairs; return epairs;
} }
- removeKeyPair: (char *)key - (void) removeKeyPair: (char *)key
{ {
epair_t *e, *e2; epair_t *e, *e2;
if (!epairs) if (!epairs)
return self; return;
e = epairs; e = epairs;
if (!strcmp(e->key, key)) if (!strcmp (e->key, key)) {
{
epairs = e->next; epairs = e->next;
free (e); free (e);
return self; return;
} }
for (; e ; e=e->next) for ( ; e; e = e->next) {
{ if (e->next && !strcmp (e->next->key, key)) {
if (e->next && !strcmp(e->next->key, key))
{
e2 = e->next; e2 = e->next;
e->next = e2->next; e->next = e2->next;
free (e2); free (e2);
return self; return;
} }
} }
printf ("WARNING: removeKeyPair: %s not found\n", key);
return self;
}
printf ("WARNING: removeKeyPair: %s not found\n", key);
return;
}
/* /*
============= =============
@ -270,37 +267,33 @@ targetname
If the entity does not have a "targetname" key, a unique one is generated If the entity does not have a "targetname" key, a unique one is generated
============= =============
*/ */
- (char *)targetname - (const char *) targetname
{ {
char *t; const char *t;
int i, count; int i, count;
id ent; id ent;
int tval, maxt; int tval, maxt;
char name[20];
t = [self valueForQKey: "targetname"]; t = [self valueForQKey: "targetname"];
if (t && t[0]) if (t && t[0])
return t; return t;
// make a unique name of the form t<number> // make a unique name of the form t<number>
count = [map_i count]; count = [map_i count];
maxt = 0; maxt = 0;
for (i=1 ; i<count ; i++) for (i = 1; i < count; i++) {
{ ent = [map_i objectAtIndex: i];
ent = [map_i objectAt: i];
t = [ent valueForQKey: "targetname"]; t = [ent valueForQKey: "targetname"];
if (!t || t[0] != 't') if (!t || t[0] != 't')
continue; continue;
tval = atoi (t+1); tval = atoi (t + 1);
if (tval > maxt) if (tval > maxt)
maxt = tval; maxt = tval;
} }
sprintf (name,"t%i",maxt+1); [self setKey: "targetname" toValue: va ("t%i", maxt + 1)];
[self setKey: "targetname" toValue: name]; return [self valueForQKey: "targetname"];
return [self valueForQKey: "targetname"]; // so it's not on the stack
} }
/* /*
@ -311,167 +304,159 @@ FILE METHODS
============================================================================== ==============================================================================
*/ */
int nument; int nument;
- initFromTokens - (Entity *) initFromScript: (script_t *)script
{ {
char key[MAXTOKEN]; char *key;
id eclass, brush; id eclass, brush;
char *spawn; const char *spawn;
vec3_t emins, emaxs; vec3_t emins, emaxs;
vec3_t org; vec3_t org;
texturedef_t td; texturedef_t td;
esize_t esize; esize_t esize;
int i, c; int i, c;
float *color; float *color;
[self init];
if (!GetToken (true)) self = [super init];
{ array = [[NSMutableArray alloc] init];
[self free];
if (!Script_GetToken (script, true)) {
[self dealloc];
return nil; return nil;
} }
if (strcmp (token, "{") ) if (strcmp (Script_Token (script), "{"))
Error ("initFromFileP: { not found"); Sys_Error ("initFromScript: { not found");
do do {
{ if (!Script_GetToken (script, true))
if (!GetToken (true))
break; break;
if (!strcmp (token, "}") ) if (!strcmp (Script_Token (script), "}"))
break; break;
if (!strcmp (token, "{") ) if (!strcmp (Script_Token (script), "{")) {
{ // read a brush // read a brush
brush = [[SetBrush alloc] initFromTokens: self]; brush = [[SetBrush alloc] initFromScript: script owner: self];
[self addObject: brush]; [self addObject: brush];
} } else {
else // read a key / value pair
{ // read a key / value pair key = strdup (Script_Token (script));
strcpy (key, token); Script_GetToken (script, false);
GetToken (false); [self setKey: key toValue: Script_Token (script)];
[self setKey: key toValue:token]; free (key);
} }
} while (1); } while (1);
nument++; nument++;
// get class // get class
spawn = [self valueForQKey: "classname"]; spawn = [self valueForQKey: "classname"];
eclass = [entity_classes_i classForName: spawn]; eclass = [entity_classes_i classForName: spawn];
esize = [eclass esize]; esize = [eclass esize];
[self getVector: org forKey: "origin"]; [self getVector: org forKey: "origin"];
if ([self count] && esize != esize_model) if ([self count] && esize != esize_model) {
{ printf ("WARNING:Entity with brushes and wrong model type\n");
printf ("WARNING:Entity with brushes and wrong model type\n"); [self removeAllObjects];
[self empty];
} }
if (![self count] && esize == esize_model) if (![self count] && esize == esize_model) {
{ printf ("WARNING:Entity with no brushes and esize_model: %s\n",
printf ("WARNING:Entity with no brushes and esize_model\n"); [self valueForQKey: "classname"]);
[texturepalette_i getTextureDef: &td]; [texturepalette_i getTextureDef: &td];
for (i=0 ; i<3 ; i++) for (i = 0; i < 3; i++) {
{
emins[i] = org[i] - 8; emins[i] = org[i] - 8;
emaxs[i] = org[i] + 8; emaxs[i] = org[i] + 8;
} }
brush = [[SetBrush alloc] initOwner: self mins:emins maxs:emaxs brush =
texture: &td]; [[SetBrush alloc] initOwner: self mins: emins maxs: emaxs texture: &td];
[self addObject: brush]; [self addObject: brush];
} }
// create a brush if needed // create a brush if needed
if (esize == esize_fixed) if (esize == esize_fixed)
[self createFixedBrush: org]; [self createFixedBrush: org];
else else
modifiable = YES; modifiable = YES;
// set all the brush colors // set all the brush colors
color = [eclass drawColor]; color = [eclass drawColor];
c = [self count]; c = [self count];
for (i=0 ; i<c ; i++) for (i = 0; i < c; i++) {
{ brush = [self objectAtIndex: i];
brush = [self objectAt: i];
[brush setEntityColor: color]; [brush setEntityColor: color];
} }
return self; return self;
} }
- (void) writeToFILE: (FILE *)f
- writeToFILE: (FILE *)f region:(BOOL)reg; region: (BOOL)reg;
{ {
epair_t *e; epair_t *e;
int i; int ang;
id new; unsigned int i;
char value[80]; id new;
vec3_t mins, maxs, org; vec3_t mins, maxs;
float *v; int org[3];
BOOL temporg; const vec_t *v;
char oldang[80]; char *oldang = 0;
temporg = NO;
if (reg)
{
if ( !strcmp ([self valueForQKey: "classname"], "info_player_start") )
{ // move the playerstart temporarily to the camera position
temporg = YES;
strcpy (oldang, [self valueForQKey: "angle"]);
sprintf (value, "%i", (int)([cameraview_i yawAngle]*180/M_PI));
[self setKey: "angle" toValue: value];
}
else if ( self != [map_i objectAt: 0]
&& [[self objectAt: 0] regioned] )
return self; // skip the entire entity definition
}
fprintf (f,"{\n");
// set an origin epair if (reg) {
if (!modifiable) if (!strcmp ([self valueForQKey: "classname"], "info_player_start")) {
{ // move the playerstart temporarily to the camera position
[[self objectAt: 0] getMins: mins maxs: maxs]; oldang = strdup ([self valueForQKey: "angle"]);
if (temporg) ang = (int) ([cameraview_i yawAngle] * 180 / M_PI);
{ [self setKey: "angle" toValue: va ("%i", ang)];
} else if (self != [map_i objectAtIndex: 0]
&& [[self objectAtIndex: 0] regioned]) {
return; // skip the entire entity definition
}
}
fprintf (f, "{\n");
// set an origin epair
if (!modifiable) {
[[self objectAtIndex: 0] getMins: mins maxs: maxs];
if (oldang) {
[cameraview_i getOrigin: mins]; [cameraview_i getOrigin: mins];
mins[0] -= 16; mins[0] -= 16;
mins[1] -= 16; mins[1] -= 16;
mins[2] -= 48; mins[2] -= 48;
} }
new = [entity_classes_i classForName: new = [entity_classes_i classForName:
[self valueForQKey: "classname"]]; [self valueForQKey: "classname"]];
if (new) if (new)
v = [new mins]; v = [new mins];
else else
v = vec3_origin; v = vec3_origin;
VectorSubtract (mins, v, org);
sprintf (value, "%i %i %i",(int)org[0], (int)org[1], (int)org[2]);
[self setKey:"origin" toValue: value];
}
for (e=epairs ; e ; e=e->next)
fprintf (f,"\"%s\"\t\"%s\"\n", e->key, e->value);
// fixed size entities don't save out brushes
if ( modifiable )
{
for (i=0 ; i<numElements ; i++)
[[self objectAt: i] writeToFILE: f region: reg];
}
fprintf (f,"}\n");
if (temporg)
[self setKey: "angle" toValue: oldang];
return self; VectorSubtract (mins, v, org);
[self setKey: "origin"
toValue: va ("%i %i %i", org[0], org[1], org[2])];
}
for (e = epairs; e; e = e->next)
fprintf (f, "\"%s\"\t\"%s\"\n", e->key, e->value);
// fixed size entities don't save out brushes
if (modifiable) {
for (i = 0; i < [self count]; i++)
[[self objectAtIndex: i] writeToFILE: f region: reg];
}
fprintf (f, "}\n");
if (oldang) {
[self setKey: "angle" toValue: oldang];
free (oldang);
}
return;
} }
/* /*

View file

@ -1,42 +1,46 @@
#ifndef EntityClass_h
#define EntityClass_h
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
#include "mathlib.h"
typedef enum {esize_model, esize_fixed} esize_t; #include "QF/mathlib.h"
#define MAX_FLAGS 8 typedef enum {esize_model, esize_fixed} esize_t;
@interface EntityClass : Object #define MAX_FLAGS 8
@interface EntityClass: NSObject
{ {
char *name; char *name;
esize_t esize; esize_t esize;
vec3_t mins, maxs; vec3_t mins, maxs;
vec3_t color; vec3_t color;
char *comments; char *comments;
char flagnames[MAX_FLAGS][32]; char *flagnames[MAX_FLAGS];
} }
- initFromText: (char *)text; - (id) initFromText: (const char *)text source: (const char *)filename;
- (char *)classname;
- (esize_t)esize;
- (float *)mins; // only for esize_fixed
- (float *)maxs; // only for esize_fixed
- (float *)drawColor;
- (char *)comments;
- (char *)flagName: (unsigned)flagnum;
@end - (const char *) classname;
- (esize_t) esize;
- (float *) mins; // only for esize_fixed
- (float *) maxs; // only for esize_fixed
- (float *) drawColor;
- (const char *) comments;
- (const char *) flagName: (unsigned)flagnum;
extern id entity_classes_i; @end extern id entity_classes_i;
@interface EntityClassList : NSMutableArray @interface EntityClassList: NSMutableArray
{ {
id nullclass; NSMutableArray *array;
char *source_path; id nullclass;
char *source_path;
} }
- initForSourceDirectory: (char *)path; - (id) initForSourceDirectory: (const char *)path;
- (id)classForName: (char *)name; - (id) classForName: (const char *)name;
- (void)scanDirectory; - (void) scanDirectory;
@end @end
#endif // EntityClass_h

View file

@ -1,8 +1,33 @@
#include <dirent.h>
#include "qedefs.h" #include "QF/quakeio.h"
#include "QF/script.h"
#include "QF/sys.h"
#include "QF/va.h"
#include "EntityClass.h"
@implementation EntityClass @implementation EntityClass
static int
parse_vector (script_t * script, vec3_t vec)
{
int r;
if (!Script_GetToken (script, 0))
return 0;
if (strcmp (Script_Token (script), "("))
return 0;
r = sscanf (script->p, "%f %f %f)", &vec[0], &vec[1], &vec[2]);
if (r != 3)
return 0;
while (strcmp (Script_Token (script), ")")) {
if (!Script_GetToken (script, 0))
return 0;
}
return 1;
}
// the classname, color triple, and bounding box are parsed out of comments // the classname, color triple, and bounding box are parsed out of comments
// A ? size means take the exact brush size. // A ? size means take the exact brush size.
// //
@ -11,255 +36,235 @@
// //
// Flag names can follow the size description: // Flag names can follow the size description:
// //
// /*QUAKED func_door (0 .5 .8) ? START_OPEN STONE_SOUND DOOR_DONT_LINK GOLD_KEY SILVER_KEY // /*QUAKED func_door (0 .5 .8) ? START_OPEN STONE_SOUND DOOR_DONT_LINK GOLD_KEY
// SILVER_KEY
char *debugname; - (id) initFromText: (const char *)text source: (const char *)filename
- initFromText: (char *)text
{ {
char *t; const char *t;
int len; size_t len;
int r, i; int i;
char parms[256], *p; script_t *script;
[super init]; [super init];
text += strlen("/*QUAKED "); text += strlen ("/*QUAKED ");
// grab the name script = Script_New ();
text = COM_Parse (text); Script_Start (script, filename, text);
name = malloc (strlen(com_token)+1);
strcpy (name, com_token); // grab the name
debugname = name; if (!Script_GetToken (script, 0))
return 0;
// grab the color if (!strcmp (Script_Token (script), "*/"))
r = sscanf (text," (%f %f %f)", &color[0], &color[1], &color[2]); return 0;
if (r != 3) name = strdup (Script_Token (script));
return NULL;
// grab the color
while (*text != ')') if (!parse_vector (script, color))
{ return 0;
if (!*text) // get the size
return NULL; if (!Script_GetToken (script, 0))
text++; return 0;
} if (!strcmp (Script_Token (script), "(")) {
text++; Script_UngetToken (script);
if (!parse_vector (script, mins))
// get the size return 0;
text = COM_Parse (text); if (!parse_vector (script, maxs))
if (com_token[0] == '(') return 0;
{ // parse the size as two vectors
esize = esize_fixed; esize = esize_fixed;
r = sscanf (text,"%f %f %f) (%f %f %f)", &mins[0], &mins[1], &mins[2], &maxs[0], &maxs[1], &maxs[2]); } else if (!strcmp (Script_Token (script), "?")) {
if (r != 6) // use the brushes
return NULL;
for (i=0 ; i<2 ; i++)
{
while (*text != ')')
{
if (!*text)
return NULL;
text++;
}
text++;
}
}
else
{ // use the brushes
esize = esize_model; esize = esize_model;
} else {
return 0;
} }
// get the flags
// get the flags // any remaining words on the line are parm flags
for (i = 0; i < MAX_FLAGS; i++) {
if (!Script_TokenAvailable (script, 0))
// copy to the first /n
p = parms;
while (*text && *text != '\n')
*p++ = *text++;
*p = 0;
text++;
// any remaining words are parm flags
p = parms;
for (i=0 ; i<8 ; i++)
{
p = COM_Parse (p);
if (!p)
break; break;
strcpy (flagnames[i], com_token); Script_GetToken (script, 0);
} flagnames[i] = strdup (Script_Token (script));
}
while (Script_TokenAvailable (script, 0))
Script_GetToken (script, 0);
// find the length until close comment // find the length until close comment
for (t=text ; t[0] && !(t[0]=='*' && t[1]=='/') ; t++) for (t = script->p; t[0] && !(t[0] == '*' && t[1] == '/'); t++)
; ;
// copy the comment block out // copy the comment block out
len = t-text; len = t - text;
comments = malloc (len+1); comments = malloc (len + 1);
memcpy (comments, text, len); memcpy (comments, text, len);
comments[len] = 0; comments[len] = 0;
return self; return self;
} }
- (esize_t)esize - (esize_t) esize
{ {
return esize; return esize;
} }
- (char *)classname - (const char *) classname
{ {
return name; return name;
} }
- (float *)mins - (float *) mins
{ {
return mins; return mins;
} }
- (float *)maxs - (float *) maxs
{ {
return maxs; return maxs;
} }
- (float *)drawColor - (float *) drawColor
{ {
return color; return color;
} }
- (char *)comments - (const char *) comments
{ {
return comments; return comments;
} }
- (const char *) flagName: (unsigned)flagnum
- (char *)flagName: (unsigned)flagnum
{ {
if (flagnum >= MAX_FLAGS) if (flagnum >= MAX_FLAGS)
Error ("EntityClass flagName: bad number"); Sys_Error ("EntityClass flagName: bad number");
return flagnames[flagnum]; return flagnames[flagnum];
} }
@end @end
// ===========================================================================
//=========================================================================== #define THING EntityClassList
#include "THING+NSArray.m"
@implementation EntityClassList @implementation EntityClassList
/* /*
================= =================
insertEC: insertEC:
================= =================
*/ */
- (void)insertEC: ec - (void) insertEC: ec
{ {
char *name; const char *name;
int i; unsigned int i;
name = [ec classname]; name = [ec classname];
for (i=0 ; i<[self count] ; i++) for (i = 0; i < [self count]; i++) {
{ if (strcasecmp (name, [[self objectAtIndex: i] classname]) < 0) {
if (strcasecmp (name, [[self objectAtIndex: i] classname]) < 0) [self insertObject: ec atIndex: i];
{
[self insertObject: ec atIndex:i];
return; return;
} }
} }
[self addObject: ec]; [self addObject: ec];
} }
/* /*
================= =================
scanFile scanFile
================= =================
*/ */
- (void)scanFile: (char *)filename - (void) scanFile: (const char *)filename
{ {
int size; int size, line;
char *data; char *data;
id cl; id cl;
int i; int i;
char path[1024]; const char *path;
QFile *file;
sprintf (path,"%s/%s", source_path, filename);
path = va ("%s/%s", source_path, filename);
size = LoadFile (path, (void *)&data);
file = Qopen (path, "rt");
for (i=0 ; i<size ; i++) if (!file)
if (!strncmp(data+i, "/*QUAKED",8)) return;
{ size = Qfilesize (file);
cl = [[EntityClass alloc] initFromText: data+i]; data = malloc (size + 1);
size = Qread (file, data, size);
data[size] = 0;
Qclose (file);
line = 1;
for (i = 0; i < size; i++) {
if (!strncmp (data + i, "/*QUAKED", 8)) {
cl = [[EntityClass alloc]
initFromText: (data + i)
source: va ("%s:%d", filename, line)];
if (cl) if (cl)
[self insertEC: cl]; [self insertEC: cl];
else } else if (data[i] == '\n') {
printf ("Error parsing: %s in %s\n",debugname, filename); line++;
} }
}
free (data); free (data);
} }
/* /*
================= =================
scanDirectory scanDirectory
================= =================
*/ */
- (void)scanDirectory - (void) scanDirectory
{ {
int count, i; int count, i;
struct direct **namelist, *ent; struct dirent **namelist, *ent;
[self removeAllObjects]; [self removeAllObjects];
count = scandir(source_path, &namelist, NULL, NULL); count = scandir (source_path, &namelist, NULL, NULL);
for (i=0 ; i<count ; i++) for (i = 0; i < count; i++) {
{ int len;
int len;
ent = namelist[i]; ent = namelist[i];
len = strlen (ent->d_name); len = strlen (ent->d_name);
if (len <= 3) if (len <= 3)
continue; continue;
if (!strcmp (ent->d_name+len-3,".qc")) if (!strcmp (ent->d_name + len - 3, ".qc"))
[self scanFile: ent->d_name]; [self scanFile: ent->d_name];
} }
} }
id entity_classes_i;
id entity_classes_i; - (id) initForSourceDirectory: (const char *)path
- initForSourceDirectory: (char *)path
{ {
[super init]; self = [super init];
array = [[NSMutableArray alloc] init];
source_path = path;
source_path = strdup (path); // FIXME leak?
[self scanDirectory]; [self scanDirectory];
entity_classes_i = self; entity_classes_i = self;
nullclass = [[EntityClass alloc] initFromText: nullclass = [[EntityClass alloc]
"/*QUAKED UNKNOWN_CLASS (0 0.5 0) ?"]; initFromText: "/*QUAKED UNKNOWN_CLASS (0 0.5 0) ?*/"
source: va ("%s:%d", __FILE__, __LINE__ - 1)];
return self; return self;
} }
- (id)classForName: (char *)name - (id) classForName: (const char *)name
{ {
int i; unsigned int i;
id o; id o;
for (i=0 ; i<[self count] ; i++) for (i = 0; i < [self count]; i++) {
{
o = [self objectAtIndex: i]; o = [self objectAtIndex: i];
if (!strcmp (name,[o classname]) ) if (!strcmp (name, [o classname]))
return o; return o;
} }
return nullclass; return nullclass;
} }
@end @end

View file

@ -1,27 +1,80 @@
include GNUmakefile.find-makefiles
include $(GNUSTEP_MAKEFILES)/common.make include $(GNUSTEP_MAKEFILES)/common.make
BUNDLE_NAME= MapEdit
BUNDLE_EXTENSION= .forgeb
# #
# We don't install this bundle, it goes inside the app. # Subprojects
# #
BUNDLE_INSTALL_DIR= none SUBPROJECTS=
MapEdit_STANDARD_INSTALL= no
MapEdit_RESOURCE_FILES= \ #
MapEdit.gorm # Main application
#
PACKAGE_NAME= QuakeEd
APP_NAME= QuakeEd
QuakeEd_PRINCIPAL_CLASS= QuakeEdApp
QuakeEd_APPLICATION_ICON=
MapEdit_OBJC_FILES= \ #
CameraView.m Clipper.m EntityClass.m KeypairView.m PopScrollView.m ZView.m misc.m render.m # Additional libraries
#
ADDITIONAL_GUI_LIBS +=
MapEdit_HEADERS= \ #
EntityClass.h # Resource files
#
QuakeEd_MAIN_MODEL_FILE= MapEdit.gorm
QuakeEd_RESOURCE_FILES= \
MapEdit.gorm \
help.txt \
../../Images/DownArrow.tiff \
../../Images/UpArrow.tiff \
../../Images/i_90d.tiff \
../../Images/i_add.tiff \
../../Images/i_brushes.tiff \
../../Images/i_fliph.tiff \
../../Images/i_flipv.tiff \
../../Images/i_quakeed.tiff \
../../Images/i_sub.tiff \
../../Images/short.tiff \
../../Images/tall.tiff
MapEdit_PRINCIPAL_CLASS= \ QuakeEd_LOCALIZED_RESOURCE_FILES=
MapEdit
# Languages we're localized for
QuakeEd_LANGUAGES= \
English
#
# Header files
#
QuakeEd_HEADERS= \
CameraView.h Clipper.h Dict.h Entity.h EntityClass.h \
InspectorControl.h KeypairView.h Map.h PopScrollView.h Preferences.h \
Project.h QuakeEd.h SetBrush.h Storage.h TexturePalette.h TextureView.h \
Things.h XYView.h ZScrollView.h ZView.h render.h \
\
THING+NSArray.m
#
# Class files
#
QuakeEd_OBJC_FILES= \
CameraView.m Clipper.m Dict.m Entity.m EntityClass.m \
InspectorControl.m KeypairView.m Map.m PopScrollView.m Preferences.m \
Project.m QuakeEd.m QuakeEd_main.m SetBrush.m Storage.m TexturePalette.m \
TextureView.m Things.m XYView.m ZScrollView.m ZView.m render.m
#
# C files
#
QuakeEd_C_FILES=
-include GNUmakefile.preamble -include GNUmakefile.preamble
-include GNUmakefile.local
include $(GNUSTEP_MAKEFILES)/bundle.make include $(GNUSTEP_MAKEFILES)/aggregate.make
include $(GNUSTEP_MAKEFILES)/application.make
-include GNUmakefile.postamble -include GNUmakefile.postamble

View file

@ -0,0 +1,29 @@
include GNUmakefile.find-makefiles
include $(GNUSTEP_MAKEFILES)/common.make
BUNDLE_NAME= MapEdit
BUNDLE_EXTENSION= .forgeb
#
# We don't install this bundle, it goes inside the app.
#
BUNDLE_INSTALL_DIR= none
MapEdit_STANDARD_INSTALL= no
MapEdit_RESOURCE_FILES= \
MapEdit.gorm
MapEdit_OBJC_FILES= \
CameraView.m Clipper.m Dict.m DictList.m Entity.m EntityClass.m InspectorControl.m KeypairView.m Map.m PopScrollView.m Preferences.m Project.m QuakeEd.m QuakeEd_main.m SetBrush.m Storage.m TexturePalette.m TextureView.m Things.m XYView.m ZScrollView.m ZView.m render.m
MapEdit_HEADERS= \
EntityClass.h
MapEdit_PRINCIPAL_CLASS= \
MapEdit
-include GNUmakefile.preamble
include $(GNUSTEP_MAKEFILES)/bundle.make
-include GNUmakefile.postamble

View file

@ -0,0 +1,13 @@
# Make sure that GNUSTEP_MAKEFILES is set.
# First, try the "gnustep-config" program which should be in the path somewhere.
# If that fails, try sourcing the GNUstep.conf file (which should be a legal Make fragment).
# Finally, just give up and assume the default value.
ifeq ($(GNUSTEP_MAKEFILES),)
GNUSTEP_MAKEFILES=$(shell gnustep-config --variable=GNUSTEP_MAKEFILES)
ifeq ($(GNUSTEP_MAKEFILES),)
-include /etc/GNUstep/GNUstep.conf
ifeq ($(GNUSTEP_MAKEFILES),)
GNUSTEP_MAKEFILES=/usr/GNUstep/Library/Makefiles
endif
endif
endif

View file

@ -2,16 +2,16 @@
ADDITIONAL_CPPFLAGS += ADDITIONAL_CPPFLAGS +=
# Additional flags to pass to the Objective-C compiler # Additional flags to pass to the Objective-C compiler
ADDITIONAL_OBJCFLAGS += -DUSING_NIBS -Wall -Werror ADDITIONAL_OBJCFLAGS += -DUSING_NIBS -Wall -Werror -Wsign-compare -Wwrite-strings #-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
# Additional flags to pass to the C compiler # Additional flags to pass to the C compiler
ADDITIONAL_CFLAGS += -Wall -Werror ADDITIONAL_CFLAGS += -Wall -Werror -Wsign-compare -Wwrite-strings #-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
# Additional include directories the compiler should search # Additional include directories the compiler should search
ADDITIONAL_INCLUDE_DIRS += -I ../.. ADDITIONAL_INCLUDE_DIRS += -I ../.. -I ../../../../include
# Additional LDFLAGS to pass to the linker # Additional LDFLAGS to pass to the linker
ADDITIONAL_LDFLAGS += ADDITIONAL_LDFLAGS += -lQFutil
# Additional library directories the linker should search # Additional library directories the linker should search
ADDITIONAL_LIB_DIRS += ADDITIONAL_LIB_DIRS +=

View file

@ -1,10 +1,11 @@
#ifndef InspectorControl_h
#define InspectorControl_h
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
#define MINIWINICON "DoomEdIcon" #define MINIWINICON "DoomEdIcon"
typedef enum typedef enum {
{
i_project, i_project,
i_textures, i_textures,
i_things, i_things,
@ -13,59 +14,69 @@ typedef enum
i_output, i_output,
i_help, i_help,
i_end i_end
} insp_e; } insp_e;
extern id inspcontrol_i; @class InspectorControl;
@interface InspectorControl:Object extern InspectorControl *inspcontrol_i;
@interface InspectorControl: NSObject
{ {
id inspectorView_i; // inspector view IBOutlet NSView *inspectorView_i; // inspector view
id inspectorSubview_i; // inspector view's current subview (gets replaced) IBOutlet NSView *inspectorSubview_i; // inspector view's current subview
// (gets replaced)
id contentList; // List of contentviews (corresponds to id contentList; // List of contentviews (corresponds to
// insp_e enum order) // insp_e enum order)
id windowList; // List of Windows (corresponds to
// insp_e enum order)
id obj_textures_i; // TexturePalette object (for delegating) id windowList; // List of Windows (corresponds to
id obj_genkeypair_i; // GenKeyPair object // insp_e enum order)
id obj_textures_i; // TexturePalette object (for
// delegating)
id obj_genkeypair_i; // GenKeyPair object
NSPopUpButton *popUpButton_i; // PopUpList title button
NSMatrix *popUpMatrix_i; // PopUpList matrix
NSMutableArray *itemList; // List of popUp buttons
IBOutlet NSTextView *helpView;
insp_e currentInspectorType; // keep track of current inspector
id popUpButton_i; // PopUpList title button
id popUpMatrix_i; // PopUpList matrix
id itemList; // List of popUp buttons
insp_e currentInspectorType; // keep track of current inspector
// //
// Add id's here for new inspectors // Add id's here for new inspectors
// **NOTE: Make sure PopUpList has correct TAG value that // **NOTE: Make sure PopUpList has correct TAG value that
// corresponds to the enums above! // corresponds to the enums above!
// Windows // Windows
id win_project_i; // project IBOutlet NSWindow *win_project_i; // project
id win_textures_i; // textures IBOutlet NSWindow *win_textures_i; // textures
id win_things_i; // things IBOutlet NSWindow *win_things_i; // things
id win_prefs_i; // preferences IBOutlet NSWindow *win_prefs_i; // preferences
id win_settings_i; // project settings IBOutlet NSWindow *win_settings_i; // project settings
id win_output_i; // bsp output IBOutlet NSWindow *win_output_i; // bsp output
id win_help_i; // documentation IBOutlet NSWindow *win_help_i; // documentation
// PopUpList objs // PopUpList objs
id itemProject_i; // project IBOutlet id <NSMenuItem> itemProject_i; // project
id itemTextures_i; // textures IBOutlet id <NSMenuItem> itemTextures_i; // textures
id itemThings_i; // things IBOutlet id <NSMenuItem> itemThings_i; // things
id itemPrefs_i; // preferences IBOutlet id <NSMenuItem> itemPrefs_i; // preferences
id itemSettings_i; // project settings IBOutlet id <NSMenuItem> itemSettings_i; // project settings
id itemOutput_i; // bsp output IBOutlet id <NSMenuItem> itemOutput_i; // bsp output
id itemHelp_i; // docs IBOutlet id <NSMenuItem> itemHelp_i; // docs
} }
- awakeFromNib; - (IBAction) changeInspector: (id)sender;
- changeInspector:sender;
- changeInspectorTo:(insp_e)which; - (void) setCurrentInspector: (insp_e)which;
- (insp_e)getCurrentInspector; - (insp_e) currentInspector;
@end @end
@protocol InspectorControl @protocol InspectorControl
- windowResized; - (void) windowResized;
@end @end
#endif // InspectorControl_h

View file

@ -1,128 +1,128 @@
#include "QF/sys.h"
#include "qedefs.h" #include "InspectorControl.h"
// Add .h-files here for new inspectors // Add .h-files here for new inspectors
#include "Things.h" #include "Things.h"
#include "TexturePalette.h" #include "TexturePalette.h"
#include "Preferences.h" #include "Preferences.h"
id inspcontrol_i; InspectorControl *inspcontrol_i;
@interface CustomView: NSView
@end
@implementation CustomView
@end
@implementation InspectorControl @implementation InspectorControl
- awakeFromNib - (void) awakeFromNib
{ {
NSBundle *mainBundle = [NSBundle mainBundle];
NSString *path = [mainBundle pathForResource: @"help" ofType: @"txt"
inDirectory: nil];
NSString *help = [NSString stringWithContentsOfFile: path];
[helpView setString: help];
inspcontrol_i = self; inspcontrol_i = self;
currentInspectorType = -1; currentInspectorType = -1;
contentList = [[List alloc] init]; contentList = [[NSMutableArray alloc] init];
windowList = [[List alloc] init]; windowList = [[NSMutableArray alloc] init];
itemList = [[List alloc] init]; itemList = [[NSMutableArray alloc] init];
// ADD NEW INSPECTORS HERE... // ADD NEW INSPECTORS HERE...
[windowList addObject:win_project_i]; [windowList addObject: win_project_i];
[contentList addObject:[win_project_i contentView]]; [contentList addObject: [win_project_i contentView]];
[itemProject_i setKeyEquivalent:'1']; [itemProject_i setKeyEquivalent: @"1"];
[itemList addObject:itemProject_i]; [itemList addObject: itemProject_i];
[windowList addObject:win_textures_i]; [windowList addObject: win_textures_i];
[contentList addObject:[win_textures_i contentView]]; [contentList addObject: [win_textures_i contentView]];
[itemTextures_i setKeyEquivalent:'2']; [itemTextures_i setKeyEquivalent: @"2"];
[itemList addObject:itemTextures_i]; [itemList addObject: itemTextures_i];
[windowList addObject:win_things_i]; [windowList addObject: win_things_i];
[contentList addObject:[win_things_i contentView]]; [contentList addObject: [win_things_i contentView]];
[itemThings_i setKeyEquivalent:'3']; [itemThings_i setKeyEquivalent: @"3"];
[itemList addObject:itemThings_i]; [itemList addObject: itemThings_i];
[windowList addObject:win_prefs_i];
[contentList addObject:[win_prefs_i contentView]];
[itemPrefs_i setKeyEquivalent:'4'];
[itemList addObject:itemPrefs_i];
[windowList addObject:win_settings_i]; [windowList addObject: win_prefs_i];
[contentList addObject:[win_settings_i contentView]]; [contentList addObject: [win_prefs_i contentView]];
[itemSettings_i setKeyEquivalent:'5']; [itemPrefs_i setKeyEquivalent: @"4"];
[itemList addObject:itemSettings_i]; [itemList addObject: itemPrefs_i];
[windowList addObject:win_output_i]; [windowList addObject: win_settings_i];
[contentList addObject:[win_output_i contentView]]; [contentList addObject: [win_settings_i contentView]];
[itemOutput_i setKeyEquivalent:'6']; [itemSettings_i setKeyEquivalent: @"5"];
[itemList addObject:itemOutput_i]; [itemList addObject: itemSettings_i];
[windowList addObject:win_help_i]; [windowList addObject: win_output_i];
[contentList addObject:[win_help_i contentView]]; [contentList addObject: [win_output_i contentView]];
[itemHelp_i setKeyEquivalent:'7']; [itemOutput_i setKeyEquivalent: @"6"];
[itemList addObject:itemHelp_i]; [itemList addObject: itemOutput_i];
[windowList addObject: win_help_i];
[contentList addObject: [win_help_i contentView]];
[itemHelp_i setKeyEquivalent: @"7"];
[itemList addObject: itemHelp_i];
// Setup inspector window with project subview first // Setup inspector window with project subview first
[inspectorView_i setAutoresizeSubviews:YES]; [inspectorView_i setAutoresizesSubviews: YES];
inspectorSubview_i = [contentList objectAt:i_project]; inspectorSubview_i = [contentList objectAtIndex: i_project];
[inspectorView_i addSubview:inspectorSubview_i];
[inspectorView_i addSubview: inspectorSubview_i];
currentInspectorType = -1; currentInspectorType = -1;
[self changeInspectorTo:i_project]; [self setCurrentInspector: i_project];
return self;
} }
// Sent by the PopUpList in the Inspector
// // Each cell in the PopUpList must have the correct tag
// Sent by the PopUpList in the Inspector - (IBAction) changeInspector: sender
// Each cell in the PopUpList must have the correct tag
//
- changeInspector:sender
{ {
id cell; [self setCurrentInspector: [sender selectedTag]];
cell = [sender selectedCell];
[self changeInspectorTo:[cell tag]];
return self;
} }
// // Change to specific Inspector
// Change to specific Inspector - (void) setCurrentInspector: (insp_e)which
//
- changeInspectorTo:(insp_e)which
{ {
id newView; id newView;
NSRect r; NSRect r;
id cell; NSRect f;
NSRect f;
if (which == currentInspectorType) if (which == currentInspectorType)
return self; return;
currentInspectorType = which; currentInspectorType = which;
newView = [contentList objectAt:which]; newView = [contentList objectAtIndex: which];
cell = [itemList objectAt:which]; // set PopUpButton title [popUpButton_i selectItemAtIndex: which];
[popUpButton_i setTitle:[cell title]];
[inspectorView_i replaceSubview: inspectorSubview_i with: newView];
[inspectorView_i replaceSubview:inspectorSubview_i with:newView]; r = [inspectorView_i frame];
[inspectorView_i getFrame:&r];
inspectorSubview_i = newView; inspectorSubview_i = newView;
[inspectorSubview_i setAutosizing:NS_WIDTHSIZABLE | NS_HEIGHTSIZABLE]; [inspectorSubview_i setAutoresizingMask: NSViewWidthSizable |
[inspectorSubview_i sizeTo:r.size.width - 4 :r.size.height - 4]; NSViewHeightSizable];
r.size.width -= 4;
r.size.height -= 4;
[inspectorSubview_i setFrameSize: r.size];
[inspectorSubview_i lockFocus]; [inspectorSubview_i lockFocus];
[inspectorSubview_i getBounds:&f]; f = [inspectorSubview_i bounds];
PSsetgray(NS_LTGRAY); [[NSColor windowBackgroundColor] set];
NSRectFill(&f); NSRectFill (f);
[inspectorSubview_i unlockFocus]; [inspectorSubview_i unlockFocus];
[inspectorView_i display]; [inspectorView_i setNeedsDisplay: YES];
return self;
} }
- (insp_e)getCurrentInspector - (insp_e) currentInspector
{ {
return currentInspectorType; return currentInspectorType;
} }
@end @end

View file

@ -1,16 +1,22 @@
#ifndef KeypairView_h
#define KeypairView_h
extern id keypairview_i; #include <AppKit/AppKit.h>
@interface KeypairView:NSView extern id keypairview_i;
@interface KeypairView: NSView
{ {
} }
- calcViewSize; - (id) calcViewSize;
#define SPACING 4 #define SPACING 4
#define FONTSIZE 12 #define FONTSIZE 12
#define EXTRASPC 2 #define EXTRASPC 2
#define LINEHEIGHT 16 #define LINEHEIGHT 16
@end @end
#endif // KeypairView_h

View file

@ -1,92 +1,98 @@
#include "KeypairView.h"
#include "Map.h"
#include "Entity.h"
#include "Things.h"
#include "qedefs.h" id keypairview_i;
id keypairview_i;
@implementation KeypairView @implementation KeypairView
/* /*
================== ==================
initWithFrame: initWithFrame:
================== ==================
*/ */
- initWithFrame:(NSRect)frameRect - (id) initWithFrame: (NSRect)frameRect
{ {
[super initWithFrame:frameRect]; [super initWithFrame: frameRect];
keypairview_i = self; keypairview_i = self;
return self; return self;
} }
- (BOOL) isFlipped
- calcViewSize
{ {
NSRect b; return YES;
NSPoint pt; }
int count;
id ent; - (BOOL) isOpaque
{
return YES;
}
- (id) calcViewSize
{
NSRect b;
NSPoint pt;
int count;
id ent;
ent = [map_i currentEntity]; ent = [map_i currentEntity];
count = [ent numPairs]; count = [ent numPairs];
//XXX[_super_view setFlipped: YES]; b = [[self superview] bounds];
b.size.height = LINEHEIGHT * count + SPACING;
b = [_super_view bounds]; [self setFrameSize: b.size];
b.size.height = LINEHEIGHT*count + SPACING;
[self setBounds: b];
pt.x = pt.y = 0; pt.x = pt.y = 0;
[self scrollPoint: pt]; [self scrollPoint: pt];
return self; return self;
} }
- drawSelf:(const NSRect *)rects :(int)rectCount - (id) drawRect: (NSRect)rects
{ {
epair_t *pair; epair_t *pair;
int y; int y;
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
//XXX PSsetgray(NSGrayComponent(NS_COLORLTGRAY));
PSrectfill(0,0,_bounds.size.width,_bounds.size.height); [[NSColor lightGrayColor] set];
NSRectFill (NSMakeRect (0, 0, _bounds.size.width, _bounds.size.height));
//XXX PSselectfont("Helvetica-Bold",FONTSIZE);
PSrotate(0); [[NSFont systemFontOfSize: FONTSIZE] set];
PSsetgray(0); [[NSColor blackColor] set];
pair = [[map_i currentEntity] epairs]; pair = [[map_i currentEntity] epairs];
y = _bounds.size.height - LINEHEIGHT; y = _bounds.size.height - LINEHEIGHT;
for ( ; pair ; pair=pair->next) for ( ; pair; pair = pair->next) {
{ NSString *key = [NSString stringWithCString: pair->key];
PSmoveto(SPACING, y); NSString *value = [NSString stringWithCString: pair->value];
PSshow(pair->key);
PSmoveto(100, y); [key drawAtPoint: NSMakePoint (SPACING, y) withAttributes: attribs];
PSshow(pair->value); [value drawAtPoint: NSMakePoint (100, y) withAttributes: attribs];
y -= LINEHEIGHT; y -= LINEHEIGHT;
} }
PSstroke();
return self; return self;
} }
- (void)mouseDown:(NSEvent *)theEvent - (void) mouseDown: (NSEvent *)theEvent
{ {
NSPoint loc; NSPoint loc;
int i; int i;
epair_t *p; epair_t *p;
loc = [theEvent locationInWindow]; loc = [theEvent locationInWindow];
loc = [self convertPoint:loc fromView:NULL]; loc = [self convertPoint: loc fromView: NULL];
i = (_bounds.size.height - loc.y - 4) / LINEHEIGHT; i = (_bounds.size.height - loc.y - 4) / LINEHEIGHT;
p = [[map_i currentEntity] epairs]; p = [[map_i currentEntity] epairs];
while ( i ) while (i) {
{ p = p->next;
p=p->next;
if (!p) if (!p)
return; return;
i--; i--;
} }
if (p) if (p)
[things_i setSelectedKey: p]; [things_i setSelectedKey: p];
return; return;
} }

View file

@ -1,68 +1,77 @@
#ifndef Map_h
#define Map_h
#include <AppKit/AppKit.h>
#include "QF/mathlib.h"
// Map is a list of Entity objects // Map is a list of Entity objects
extern id map_i; extern id map_i;
@interface Map : NSMutableArray @interface Map: NSMutableArray
{ {
id currentEntity; NSMutableArray *array;
id oldselection; // temp when loading a new map id currentEntity;
float minz, maxz; id oldselection; // temp when loading a new map
float minz, maxz;
} }
- newMap; - (id) newMap;
- writeStats; - (id) writeStats;
- readMapFile: (char *)fname; - (id) readMapFile: (const char *)fname;
- writeMapFile: (char *)fname useRegion: (BOOL)reg; - (id) writeMapFile: (const char *)fname useRegion: (BOOL)reg;
- entityConnect: (vec3_t)p1 : (vec3_t)p2; - (id) entityConnect: (vec3_t)p1: (vec3_t)p2;
- selectRay: (vec3_t)p1 : (vec3_t)p2 : (BOOL)ef; - (id) selectRay: (vec3_t)p1: (vec3_t)p2: (BOOL)ef;
- grabRay: (vec3_t)p1 : (vec3_t)p2; - (id) grabRay: (vec3_t)p1: (vec3_t)p2;
- setTextureRay: (vec3_t)p1 : (vec3_t)p2 : (BOOL)allsides; - (id) setTextureRay: (vec3_t)p1: (vec3_t)p2: (BOOL)allsides;
- getTextureRay: (vec3_t)p1 : (vec3_t)p2; - (id) getTextureRay: (vec3_t)p1: (vec3_t)p2;
- currentEntity; - (id) currentEntity;
- setCurrentEntity: ent; - (id) setCurrentEntity: ent;
- (float)currentMinZ; - (float) currentMinZ;
- setCurrentMinZ: (float)m; - (id) setCurrentMinZ: (float)m;
- (float)currentMaxZ; - (float) currentMaxZ;
- setCurrentMaxZ: (float)m; - (id) setCurrentMaxZ: (float)m;
- (int)numSelected; - (int) numSelected;
- selectedBrush; // returns the first selected brush - (id) selectedBrush; // returns the first selected brush
// //
// operations on current selection // operations on current selection
// //
- makeSelectedPerform: (SEL)sel; - (id) makeSelectedPerform: (SEL)sel;
- makeUnselectedPerform: (SEL)sel; - (id) makeUnselectedPerform: (SEL)sel;
- makeAllPerform: (SEL)sel; - (id) makeAllPerform: (SEL)sel;
- makeGlobalPerform: (SEL)sel; // in and out of region - (id) makeGlobalPerform: (SEL)sel; // in and out of region
- cloneSelection: sender; - (id) cloneSelection: sender;
- makeEntity: sender; - (id) makeEntity: sender;
- subtractSelection: sender; - (id) subtractSelection: sender;
- selectCompletelyInside: sender; - (id) selectCompletelyInside: sender;
- selectPartiallyInside: sender; - (id) selectPartiallyInside: sender;
- tallBrush: sender; - (id) tallBrush: sender;
- shortBrush: sender; - (id) shortBrush: sender;
- rotate_x: sender; - (id) rotate_x: sender;
- rotate_y: sender; - (id) rotate_y: sender;
- rotate_z: sender; - (id) rotate_z: sender;
- flip_x: sender; - (id) flip_x: sender;
- flip_y: sender; - (id) flip_y: sender;
- flip_z: sender; - (id) flip_z: sender;
- selectCompleteEntity: sender; - (id) selectCompleteEntity: sender;
@end @end
#endif // Map_h

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -0,0 +1,316 @@
{
"## Comment" = "Do NOT change this file, Gorm maintains it";
CameraView = {
Actions = (
"drawMode:",
"homeView:",
"upFloor:",
"downFloor:"
);
Outlets = (
mode_radio_i
);
Super = NSView;
};
Clipper = {
Actions = (
);
Outlets = (
);
Super = NSObject;
};
FirstResponder = {
Actions = (
"BSP_FastVis:",
"BSP_Full:",
"BSP_NoVis:",
"BSP_entities:",
"BSP_relight:",
"BSP_stop:",
"UIChanged:",
"addPair:",
"appDidInit:",
"appWillTerminate:",
"applyRegion:",
"centerCamera:",
"centerZChecker:",
"changeInspector:",
"changeXYLookUp:",
"clear:",
"clearBspOutput:",
"clearTexinfo:",
"clickedOnMap:",
"clickedOnWad:",
"cloneSelection:",
"decRotate:",
"decXScale:",
"decXShift:",
"decYScale:",
"decYShift:",
"delPair:",
"doubleClickEntity:",
"downFloor:",
"drawMode:",
"flip_x:",
"flip_y:",
"flip_z:",
"homeView:",
"incRotate:",
"incXScale:",
"incXShift:",
"incYScale:",
"incYShift:",
"makeEntity:",
"onlyShowMapTextures:",
"openProject:",
"reloadEntityClasses:",
"rotate_x:",
"rotate_y:",
"rotate_z:",
"save:",
"saveAs:",
"searchForTexture:",
"selectCompleteEntity:",
"selectCompletelyInside:",
"selectEntity:",
"selectPartiallyInside:",
"setAngle:",
"setBrushRegion:",
"setBspSound:",
"setCurrentEntity:",
"setCurrentProject:",
"setFlags:",
"setModeRadio:",
"setParent:",
"setXYRegion:",
"shortBrush:",
"subtractSelection:",
"tallBrush:",
"textCommand:",
"texturedefChanged:",
"upFloor:",
"updateAll:"
);
Super = NSObject;
};
InspectorControl = {
Actions = (
"changeInspector:"
);
Outlets = (
inspectorView_i,
inspectorSubview_i,
contentList,
windowList,
obj_textures_i,
obj_genkeypair_i,
popUpButton_i,
popUpMatrix_i,
itemList,
helpView,
win_project_i,
win_textures_i,
win_things_i,
win_prefs_i,
win_settings_i,
win_output_i,
win_help_i,
itemProject_i,
itemTextures_i,
itemThings_i,
itemPrefs_i,
itemSettings_i,
itemOutput_i,
itemHelp_i
);
Super = NSObject;
};
Map = {
Actions = (
"setCurrentEntity:",
"cloneSelection:",
"makeEntity:",
"subtractSelection:",
"selectCompletelyInside:",
"selectPartiallyInside:",
"tallBrush:",
"shortBrush:",
"rotate_x:",
"rotate_y:",
"rotate_z:",
"flip_x:",
"flip_y:",
"flip_z:",
"selectCompleteEntity:"
);
Outlets = (
currentEntity,
oldselection
);
Super = NSMutableArray;
};
Preferences = {
Actions = (
"setBspSound:",
"setCurrentProject:",
"UIChanged:"
);
Outlets = (
bspSound_i,
startproject_i,
bspSoundField_i,
brushOffset_i,
showBSP_i,
startwad_i,
xlight_i,
ylight_i,
zlight_i
);
Super = NSObject;
};
Project = {
Actions = (
"clearBspOutput:",
"clickedOnMap:",
"clickedOnWad:"
);
Outlets = (
projectInfo,
basepathinfo_i,
mapbrowse_i,
currentmap_i,
mapList,
descList,
wadList,
pis_panel_i,
pis_basepath_i,
pis_wads_i,
pis_fullvis_i,
pis_fastvis_i,
pis_novis_i,
pis_relight_i,
pis_leaktest_i,
BSPoutput_i
);
Super = NSObject;
};
QuakeEd = {
Actions = (
"updateAll:",
"appDidInit:",
"appWillTerminate:",
"openProject:",
"textCommand:",
"applyRegion:",
"clear:",
"centerCamera:",
"centerZChecker:",
"changeXYLookUp:",
"setBrushRegion:",
"setXYRegion:",
"open:",
"save:",
"saveAs:",
"BSP_Full:",
"BSP_FastVis:",
"BSP_NoVis:",
"BSP_relight:",
"BSP_stop:",
"BSP_entities:"
);
Outlets = (
brushcount_i,
entitycount_i,
regionbutton_i,
show_coordinates_i,
show_names_i,
filter_light_i,
filter_path_i,
filter_entities_i,
filter_clip_i,
filter_water_i,
filter_world_i,
cmd_in_i,
cmd_out_i,
xy_drawmode_i
);
Super = NSWindow;
};
TexturePalette = {
Actions = (
"searchForTexture:",
"clearTexinfo:",
"incXShift:",
"decXShift:",
"incYShift:",
"decYShift:",
"incRotate:",
"decRotate:",
"incXScale:",
"decXScale:",
"incYScale:",
"decYScale:",
"texturedefChanged:",
"onlyShowMapTextures:"
);
Outlets = (
textureList_i,
textureView_i,
searchField_i,
sizeField_i,
field_Xshift_i,
field_Yshift_i,
field_Xscale_i,
field_Yscale_i,
field_Rotate_i
);
Super = NSObject;
};
TextureView = {
Actions = (
"setParent:"
);
Outlets = (
parent_i
);
Super = NSView;
};
Things = {
Actions = (
"reloadEntityClasses:",
"selectEntity:",
"doubleClickEntity:",
"addPair:",
"delPair:",
"setAngle:",
"setFlags:"
);
Outlets = (
entity_browser_i,
entity_comment_i,
prog_path_i,
keyInput_i,
valueInput_i,
flags_i
);
Super = NSObject;
};
XYView = {
Actions = (
"setModeRadio:",
"drawMode:",
"drawMode:"
);
Outlets = (
mode_radio_i
);
Super = NSView;
};
ZView = {
Actions = (
);
Outlets = (
);
Super = NSView;
};
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,11 +1,18 @@
#ifndef PopScrollView_h
#define PopScrollView_h
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
@interface PopScrollView : NSScrollView @interface PopScrollView: NSScrollView
{ {
id button1, button2; id button1, button2;
} }
- initWithFrame:(NSRect)frameRect button1: b1 button2: b2; - (id) initWithFrame: (NSRect)frameRect
- tile; button1: b1
button2: b2;
- (id) tile;
@end @end
#endif // PopScrollView_h

View file

@ -1,8 +1,6 @@
#include "PopScrollView.h"
#include "qedefs.h"
@implementation PopScrollView @implementation PopScrollView
/* /*
==================== ====================
initWithFrame: button: initWithFrame: button:
@ -10,10 +8,11 @@ initWithFrame: button:
Initizes a scroll view with a button at it's lower right corner Initizes a scroll view with a button at it's lower right corner
==================== ====================
*/ */
- (id) initWithFrame: (NSRect)frameRect
- initWithFrame:(NSRect)frameRect button1:b1 button2:b2 button1: b1
button2: b2
{ {
[super initWithFrame: frameRect]; [super initWithFrame: frameRect];
[self addSubview: b1]; [self addSubview: b1];
[self addSubview: b2]; [self addSubview: b2];
@ -25,10 +24,14 @@ Initizes a scroll view with a button at it's lower right corner
[self setHasVerticalScroller: YES]; [self setHasVerticalScroller: YES];
[self setBorderType: NSBezelBorder]; [self setBorderType: NSBezelBorder];
return self; return self;
} }
- (BOOL) isOpaque
{
return YES;
}
/* /*
================ ================
@ -37,20 +40,20 @@ tile
Adjust the size for the pop up scale menu Adjust the size for the pop up scale menu
================= =================
*/ */
- (id) tile
- tile
{ {
NSRect scrollerframe; NSRect scrollerframe;
NSRect buttonframe, buttonframe2; NSRect buttonframe, buttonframe2;
NSRect newframe; NSRect newframe;
[super tile]; [super tile];
buttonframe = [button1 frame]; buttonframe = [button1 frame];
buttonframe2 = [button2 frame]; buttonframe2 = [button2 frame];
scrollerframe = [_horizScroller frame]; scrollerframe = [_horizScroller frame];
newframe.origin.y = scrollerframe.origin.y; newframe.origin.y = scrollerframe.origin.y;
newframe.origin.x = scrollerframe.size.width - buttonframe.size.width; newframe.origin.x = scrollerframe.origin.x + scrollerframe.size.width -
buttonframe.size.width;
newframe.size.width = buttonframe.size.width; newframe.size.width = buttonframe.size.width;
newframe.size.height = scrollerframe.size.height; newframe.size.height = scrollerframe.size.height;
scrollerframe.size.width -= newframe.size.width; scrollerframe.size.width -= newframe.size.width;
@ -66,22 +69,19 @@ Adjust the size for the pop up scale menu
} }
/* /*
- superviewSizeChanged:(const NSSize *)oldSize - (id) superviewSizeChanged: (const NSSize *)oldSize
{ {
[super superviewSizeChanged: oldSize]; [super superviewSizeChanged: oldSize];
[[self docView] newSuperBounds]; [[self docView] newSuperBounds];
return self; return self;
} }
*/ */
-(BOOL) acceptsFirstResponder - (BOOL) acceptsFirstResponder
{ {
return YES; return YES;
} }
@end @end

View file

@ -1,78 +1,84 @@
#ifndef Preferences_h
#define Preferences_h
extern id preferences_i; #include <AppKit/AppKit.h>
extern float lightaxis[3]; extern id preferences_i;
extern float lightaxis[3];
// these are personal preferences saved in NeXT defaults, not project // these are personal preferences saved in NeXT defaults, not project
// parameters saved in the quake.qe_project file // parameters saved in the quake.qe_project file
@interface Preferences:Object @interface Preferences: NSObject
{ {
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;
float xlight;
float ylight;
float zlight; // 0.0 - 1.0
int startwad; // 0 - 2
float xlight;
float ylight;
float zlight; // 0.0 - 1.0
int startwad; // 0 - 2
// UI targets // UI targets
id startproject_i; // TextField id startproject_i; // TextField
id bspSoundField_i; // TextField of bspSound id bspSoundField_i; // TextField of bspSound
id brushOffset_i; // Brush Offset checkbox id brushOffset_i; // Brush Offset checkbox
id showBSP_i; // Show BSP Output checkbox id showBSP_i; // Show BSP Output checkbox
id startwad_i; // which wad to load at startup
id xlight_i; // X-side lighting id startwad_i; // which wad to load at startup
id ylight_i; // Y-side lighting
id zlight_i; // Z-side lighting id xlight_i; // X-side lighting
id ylight_i; // Y-side lighting
id zlight_i; // Z-side lighting
NSUserDefaults *prefs;
} }
- readDefaults; - (id) readDefaults;
// //
// validate and set methods called by UI or defaults // validate and set methods called by UI or defaults
// //
- setProjectPath:(char *)path; - (id) setProjectPath: (NSString *)path;
- setBspSoundPath:(char *)path; // set the path of the soundfile externally - (id) setBspSoundPath: (NSString *)path; // set the path of the soundfile
- setShowBSP:(int)state; // set the state of ShowBSP - (id) setShowBSP: (int)state; // set the state of ShowBSP
- setBrushOffset:(int)state; // set the state of BrushOffset - (id) setBrushOffset: (int)state; // set the state of BrushOffset
- setStartWad:(int)value; // set start wad (0-2) - (id) setStartWad: (int)value; // set start wad (0-2)
- setXlight:(float)value; // set Xlight value for CameraView - (id) setXlight: (float)value; // set Xlight value for CameraView
- setYlight:(float)value; // set Ylight value for CameraView - (id) setYlight: (float)value; // set Ylight value for CameraView
- setZlight:(float)value; // set Zlight value for CameraView - (id) setZlight: (float)value; // set Zlight value for CameraView
// //
// UI targets // UI targets
// //
- setBspSound:sender; // use OpenPanel to select sound - (id) setBspSound: sender; // use OpenPanel to select sound
- setCurrentProject:sender; // make current roject the default - (id) setCurrentProject: sender; // make current project the default
- UIChanged: sender; // target for all checks and fields - (id) UIChanged: sender; // target for all checks and fields
// //
// methods used by other objects to retreive defaults // methods used by other objects to retreive defaults
// //
- playBspSound; - (id) playBspSound;
- (char *)getProjectPath; - (NSString *) getProjectPath;
- (int)getBrushOffset; // get the state - (int) getBrushOffset; // get the state
- (int)getShowBSP; // get the state - (int) getShowBSP; // get the state
- (float)getXlight; // get Xlight value - (float) getXlight; // get Xlight value
- (float)getYlight; // get Ylight value - (float) getYlight; // get Ylight value
- (float)getZlight; // get Zlight value - (float) getZlight; // get Zlight value
- (int)getStartWad;
- (int) getStartWad;
@end @end
#endif // Preferences_h

View file

@ -1,305 +1,272 @@
#include <unistd.h>
#include "qedefs.h" #include "QF/sys.h"
#include "QF/va.h"
id preferences_i; #include "Preferences.h"
#include "Map.h"
#include "QuakeEd.h"
#include "Project.h"
#define DEFOWNER "QuakeEd2" id preferences_i;
float lightaxis[3] = {1, 0.6, 0.75}; #define DEFOWNER "QuakeEd2"
float lightaxis[3] = {1, 0.6, 0.75};
@implementation Preferences @implementation Preferences
- init void
WriteStringDefault (id prefs, NSString *name, NSString *value)
{
[prefs setObject: value forKey: name];
}
void
WriteNumericDefault (id prefs, NSString *name, float value)
{
WriteStringDefault (prefs, name, [NSString stringWithFormat: @"%f", value]);
}
- (id) init
{ {
[super init]; [super init];
preferences_i = self; preferences_i = self;
NSMutableDictionary *defaults = [NSMutableDictionary dictionary];
WriteStringDefault (defaults, @"ProjectPath", @"");
WriteStringDefault (defaults, @"BspSoundPath", @"");
WriteNumericDefault (defaults, @"ShowBSPOutput", NO);
WriteNumericDefault (defaults, @"OffsetBrushCopy", NO);
WriteNumericDefault (defaults, @"StartWad", 0);
WriteNumericDefault (defaults, @"Xlight", 0);
WriteNumericDefault (defaults, @"Ylight", 0);
WriteNumericDefault (defaults, @"Zlight", 0);
prefs = [[NSUserDefaults standardUserDefaults] retain];
[prefs registerDefaults: defaults];
return self; return self;
} }
int _atoi (char *c) // Read in at start of program
- (id) readDefaults
{ {
if (!c) [self setProjectPath: [prefs stringForKey: @"ProjectPath"]];
return 0; [self setBspSoundPath: [prefs stringForKey: @"BspSoundPath"]];
return atoi(c);
}
int _atof (char *c) [self setShowBSP: [[prefs stringForKey: @"ShowBSPOutput"] intValue]];
{ [self setBrushOffset: [[prefs stringForKey: @"OffsetBrushCopy"] intValue]];
if (!c) [self setStartWad: [[prefs stringForKey: @"StartWad"] intValue]];
return 0;
return atof(c);
}
void WriteNumericDefault (char *name, float value) [self setXlight: [[prefs stringForKey: @"Xlight"] floatValue]];
{ [self setYlight: [[prefs stringForKey: @"Ylight"] floatValue]];
char str[128]; [self setZlight: [[prefs stringForKey: @"Zlight"] floatValue]];
sprintf (str,"%f", value);
NSWriteDefault (DEFOWNER, name, str);
}
void WriteStringDefault (char *name, char *value)
{
NSWriteDefault (DEFOWNER, name, value);
}
//
// Read in at start of program
//
- readDefaults
{
char *string;
float value;
string = (char *)NSGetDefaultValue(DEFOWNER,"ProjectPath");
[self setProjectPath: string];
string = (char *)NSGetDefaultValue(DEFOWNER,"BspSoundPath");
[self setBspSoundPath:string];
value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"ShowBSPOutput"));
[self setShowBSP:value];
value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"OffsetBrushCopy"));
[self setBrushOffset:value];
value = _atoi((char *)NSGetDefaultValue(DEFOWNER,"StartWad"));
[self setStartWad:value];
value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Xlight"));
[self setXlight:value];
value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Ylight"));
[self setYlight:value];
value = _atof((char *)NSGetDefaultValue(DEFOWNER,"Zlight"));
[self setZlight:value];
return self; return self;
} }
- (id) setProjectPath: (NSString *)path
- setProjectPath:(char *)path
{ {
if (!path) [path retain];
path = ""; [projectpath release];
strcpy (projectpath, path); projectpath = path;
[startproject_i setStringValue: path]; [startproject_i setStringValue: projectpath];
WriteStringDefault ("ProjectPath", path); WriteStringDefault (prefs, @"ProjectPath", projectpath);
return self; return self;
} }
- setCurrentProject:sender - (id) setCurrentProject: sender
{ {
[startproject_i setStringValue: [project_i currentProjectFile]]; [startproject_i setStringValue: [project_i currentProjectFile]];
[self UIChanged: self]; [self UIChanged: self];
return self; return self;
} }
- (char *)getProjectPath - (NSString *) getProjectPath
{ {
return projectpath; return projectpath;
} }
// ===============================================
// BSP sound stuff
// ===============================================
// //
//=============================================== // Set the BSP sound using an OpenPanel
// BSP sound stuff - (id) setBspSound: sender
//===============================================
//
// Set the BSP sound using an OpenPanel
//
- setBspSound:sender
{ {
id panel; id panel;
char *types[]={"snd",NULL}; NSString *types[] = {@"snd"};
int rtn; int rtn;
char **filename; NSArray *filenames;
char path[1024], file[64]; NSString *path, *file;
panel = [OpenPanel new];
ExtractFilePath (bspSound, path); panel = [NSOpenPanel new];
ExtractFileBase (bspSound, file);
rtn = [panel
runModalForDirectory:path
file: file
types: types];
if (rtn) path = [bspSound stringByDeletingLastPathComponent];
{ file = [bspSound lastPathComponent];
filename = (char **)[panel filenames];
strcpy(bspSound,[panel directory]); rtn = [panel runModalForDirectory: path file: file
strcat(bspSound,"/"); types: [NSArray arrayWithObjects: types
strcat(bspSound,filename[0]); count: 1]
[self setBspSoundPath:bspSound]; ];
if (rtn) {
filenames = [panel filenames];
[self setBspSoundPath: [filenames objectAtIndex: 0]];
[self playBspSound]; [self playBspSound];
} }
return self; return self;
} }
// Play the BSP sound
// - (id) playBspSound
// Play the BSP sound
//
- playBspSound
{ {
[bspSound_i play]; [bspSound_i play];
return self; return self;
} }
// Set the bspSound path
// - (id) setBspSoundPath: (NSString *)path
// Set the bspSound path
//
- setBspSoundPath:(char *)path
{ {
if (!path)
path = ""; [path retain];
strcpy(bspSound,path); [bspSound release];
bspSound = path;
if (bspSound_i) if (bspSound_i) {
[bspSound_i free]; [bspSound_i release];
bspSound_i = [[Sound alloc] initFromSoundfile:bspSound]; bspSound_i = nil;
if (!bspSound_i)
{
strcpy (bspSound, "/NextLibrary/Sounds/Funk.snd");
bspSound_i = [[Sound alloc] initFromSoundfile:bspSound];
} }
if (access ([path cString], R_OK)) {
bspSound_i = [[NSSound alloc] initWithContentsOfFile: bspSound
byReference: YES];
}
if (!bspSound_i)
return self;
[bspSoundField_i setStringValue: bspSound];
WriteStringDefault (prefs, @"BspSoundPath", bspSound);
[bspSoundField_i setStringValue:bspSound];
WriteStringDefault ("BspSoundPath", bspSound);
return self; return self;
} }
//=============================================== // ===============================================
// Show BSP Output management // Show BSP Output management
//=============================================== // ===============================================
// // Set the state
// Set the state - (id) setShowBSP: (int)state
//
- setShowBSP:(int)state
{ {
showBSP = state; showBSP = state;
[showBSP_i setIntValue:state]; [showBSP_i setIntValue: state];
WriteNumericDefault ("ShowBSPOutput", showBSP); WriteNumericDefault (prefs, @"ShowBSPOutput", showBSP);
return self; return self;
} }
// // Get the state
// Get the state - (int) getShowBSP
//
- (int)getShowBSP
{ {
return showBSP; return showBSP;
} }
// ===============================================
// "Offset Brush ..." management
// ===============================================
//=============================================== // Set the state
// "Offset Brush ..." management - (id) setBrushOffset: (int)state
//===============================================
//
// Set the state
//
- setBrushOffset:(int)state
{ {
brushOffset = state; brushOffset = state;
[brushOffset_i setIntValue:state]; [brushOffset_i setIntValue: state];
WriteNumericDefault ("OffsetBrushCopy", state); WriteNumericDefault (prefs, @"OffsetBrushCopy", state);
return self; return self;
} }
// // Get the state
// Get the state - (int) getBrushOffset
//
- (int)getBrushOffset
{ {
return brushOffset; return brushOffset;
} }
//=============================================== // ===============================================
// StartWad // StartWad
//=============================================== // ===============================================
- setStartWad:(int)value // set start wad (0-2) - (id) setStartWad: (int)value // set start wad (0-2)
{ {
startwad = value; startwad = value;
if (startwad<0 || startwad>2) if (startwad < 0 || startwad > 2)
startwad = 0; startwad = 0;
[startwad_i selectCellAt:startwad : 0];
WriteNumericDefault ("StartWad", value); [startwad_i selectCellAtRow: startwad column: 0];
WriteNumericDefault (prefs, @"StartWad", value);
return self; return self;
} }
- (int)getStartWad - (int) getStartWad
{ {
return startwad; return startwad;
} }
// ===============================================
//=============================================== // X,Y,Z light values
// X,Y,Z light values // ===============================================
//===============================================
// //
// Set the state // Set the state
// - (id) setXlight: (float)value
- setXlight:(float)value
{ {
xlight = value; xlight = value;
if (xlight < 0.25 || xlight > 1) if (xlight < 0.25 || xlight > 1)
xlight = 0.6; xlight = 0.6;
lightaxis[1] = xlight; lightaxis[1] = xlight;
[xlight_i setFloatValue:xlight]; [xlight_i setFloatValue: xlight];
WriteNumericDefault ("Xlight", xlight); WriteNumericDefault (prefs, @"Xlight", xlight);
return self; return self;
} }
- setYlight:(float)value
- (id) setYlight: (float)value
{ {
ylight = value; ylight = value;
if (ylight < 0.25 || ylight > 1) if (ylight < 0.25 || ylight > 1)
ylight = 0.75; ylight = 0.75;
lightaxis[2] = ylight; lightaxis[2] = ylight;
[ylight_i setFloatValue:ylight]; [ylight_i setFloatValue: ylight];
WriteNumericDefault ("Ylight", ylight); WriteNumericDefault (prefs, @"Ylight", ylight);
return self; return self;
} }
- setZlight:(float)value
- (id) setZlight: (float)value
{ {
zlight = value; zlight = value;
if (zlight < 0.25 || zlight > 1) if (zlight < 0.25 || zlight > 1)
zlight = 1; zlight = 1;
lightaxis[0] = zlight; lightaxis[0] = zlight;
[zlight_i setFloatValue:zlight]; [zlight_i setFloatValue: zlight];
WriteNumericDefault ("Zlight", zlight); WriteNumericDefault (prefs, @"Zlight", zlight);
return self; return self;
} }
// // Get the state
// Get the state - (float) getXlight
//
- (float)getXlight
{ {
return [xlight_i floatValue]; return [xlight_i floatValue];
} }
- (float)getYlight
- (float) getYlight
{ {
return [ylight_i floatValue]; return [ylight_i floatValue];
} }
- (float)getZlight
- (float) getZlight
{ {
return [zlight_i floatValue]; return [zlight_i floatValue];
} }
/* /*
============ ============
UIChanged UIChanged
@ -307,12 +274,12 @@ UIChanged
Grab all the current UI state Grab all the current UI state
============ ============
*/ */
-UIChanged: sender - (id) UIChanged: sender
{ {
qprintf ("defaults updated"); Sys_Printf ("defaults updated\n");
[self setProjectPath: (char *)[startproject_i stringValue]]; [self setProjectPath: [startproject_i stringValue]];
[self setBspSoundPath: (char *)[bspSoundField_i stringValue]]; [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]];
@ -320,11 +287,10 @@ Grab all the current UI state
[self setYlight: [ylight_i floatValue]]; [self setYlight: [ylight_i floatValue]];
[self setZlight: [zlight_i floatValue]]; [self setZlight: [zlight_i floatValue]];
[map_i makeGlobalPerform: @selector(flushTextures)]; [map_i makeGlobalPerform: @selector (flushTextures)];
[quakeed_i updateAll]; [quakeed_i updateAll];
return self; return self;
} }
@end @end

View file

@ -1,108 +1,110 @@
#ifndef Project_h
#define Project_h
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
#include <sys/stat.h> #include <sys/stat.h>
#define BASEPATHKEY "basepath" #define BASEPATHKEY "basepath"
#define MAPNAMESKEY "maps" #define MAPNAMESKEY "maps"
#define DESCKEY "desc" #define DESCKEY "desc"
#define WADSKEY "wads" #define WADSKEY "wads"
#define BSPFULLVIS "bspfullvis" #define BSPFULLVIS "bspfullvis"
#define BSPFASTVIS "bspfastvis" #define BSPFASTVIS "bspfastvis"
#define BSPNOVIS "bspnovis" #define BSPNOVIS "bspnovis"
#define BSPRELIGHT "bsprelight" #define BSPRELIGHT "bsprelight"
#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;
@interface Project:Object @interface Project: NSObject
{ {
id projectInfo; // dictionary storage of project info id projectInfo; // dictionary storage of project info
id basepathinfo_i; // outlet to base path info textfield id basepathinfo_i; // outlet to base path info textfield
id mapbrowse_i; // outlet to QuakeEd Maps browser id mapbrowse_i; // outlet to QuakeEd Maps browser
id currentmap_i; // outlet to current map textfield id currentmap_i; // outlet to current map textfield
id mapList; // list of map names (Storage) struct plitem_s *mapList; // list of map names
id descList; // list of map descriptions (Storage) struct plitem_s *descList; // list of map descriptions
id wadList; // list of wad names (Storage) struct plitem_s *wadList; // list of wad names
id pis_panel_i; // outlet to Project Info Settings (PIS) panel
id pis_basepath_i; // outlet to PIS->base path id pis_panel_i; // outlet to Project Info Settings (PIS)
id pis_wads_i; // outlet to PIS->wad browser // panel
id pis_fullvis_i; // outlet to PIS->full vis command
id pis_fastvis_i; // outlet to PIS->fast vis command
id pis_novis_i; // outlet to PIS->no vis command
id pis_relight_i; // outlet to PIS->relight command
id pis_leaktest_i; // outlet to PIS->leak test command
id BSPoutput_i; // outlet to Text id pis_basepath_i; // outlet to PIS->base path
id pis_wads_i; // outlet to PIS->wad browser
char path_projectinfo[128]; // path of QE_Project file id pis_fullvis_i; // outlet to PIS->full vis command
id pis_fastvis_i; // outlet to PIS->fast vis command
id pis_novis_i; // outlet to PIS->no vis command
id pis_relight_i; // outlet to PIS->relight command
id pis_leaktest_i; // outlet to PIS->leak test command
char path_basepath[128]; // base path of heirarchy id BSPoutput_i; // outlet to Text
char path_progdir[128]; // derived from basepath NSString *path_projectinfo; // path of QE_Project file
char path_mapdirectory[128]; // derived from basepath
char path_finalmapdir[128]; // 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
char path_wad0[128]; // path of texture WAD for cmd-0 key
char string_fullvis[1024]; // cmd-line parm NSString *path_basepath; // base path of heirarchy
char string_fastvis[1024]; // cmd-line parm
char string_novis[1024]; // cmd-line parm
char string_relight[1024]; // cmd-line parm
char string_leaktest[1024]; // cmd-line parm
char string_entities[1024]; // cmd-line parm
int showDescriptions; // 1 = show map descs in browser NSString *path_progdir; // derived from basepath
NSString *path_mapdirectory; // derived from basepath
NSString *path_finalmapdir; // derived from basepath
time_t lastModified; // last time project file was modified 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_wad0[128]; // path of texture WAD for cmd-0 key
const char *string_fullvis; // cmd-line parm
const char *string_fastvis; // cmd-line parm
const char *string_novis; // cmd-line parm
const char *string_relight; // cmd-line parm
const char *string_leaktest; // cmd-line parm
const char *string_entities; // cmd-line parm
int showDescriptions; // 1 = show map descs in browser
time_t lastModified; // last time project file was modified
} }
- initProject; - (id) initProject;
- initVars; - (id) initVars;
- (char *)currentProjectFile; - (NSString *) currentProjectFile;
- setTextureWad: (char *)wf; - (id) setTextureWad: (const char *)wf;
- addToOutput:(char *)string; - (id) addToOutput: (const char *)string;
- clearBspOutput:sender; - (id) clearBspOutput: (id)sender;
- initProjSettings; - (id) initProjSettings;
- changeChar:(char)f to:(char)t in:(id)obj;
- (int)searchForString:(char *)str in:(id)obj;
- parseProjectFile; // read defaultsdatabase for project path - (id) parseProjectFile; // read defaultsdatabase for project path
- openProjectFile:(char *)path; // called by openProject and newProject - (id) openProjectFile: (NSString *)path; // called by openProject, newProject
- openProject; - (id) openProject;
- clickedOnMap:sender; // called if clicked on map in browser - (id) clickedOnMap: sender; // called if clicked on map in browser
- clickedOnWad:sender; // called if clicked on wad in browser - (id) clickedOnWad: sender; // called if clicked on wad in browser
// methods to querie the project file //
// methods to query the project file
//
- (NSString *) baseDirectoryPath;
- (NSString *) getMapDirectory;
- (NSString *) getFinalMapDirectory;
- (NSString *) getProgDirectory;
- (char *)getMapDirectory; - (const char *) getWAD8;
- (char *)getFinalMapDirectory; - (const char *) getWAD9;
- (char *)getProgDirectory; - (const char *) getWAD0;
- (char *)getWAD8; - (const char *) getFullVisCmd;
- (char *)getWAD9; - (const char *) getFastVisCmd;
- (char *)getWAD0; - (const char *) getNoVisCmd;
- (const char *) getRelightCmd;
- (char *)getFullVisCmd; - (const char *) getLeaktestCmd;
- (char *)getFastVisCmd; - (const char *) getEntitiesCmd;
- (char *)getNoVisCmd;
- (char *)getRelightCmd;
- (char *)getLeaktestCmd;
- (char *)getEntitiesCmd;
@end @end
void changeString(char cf,char ct,char *string); #endif // Project_h

View file

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

View file

@ -1,98 +1,110 @@
#ifndef QuakeEd_h
#define QuakeEd_h
extern id quakeed_i; #include <AppKit/AppKit.h>
extern BOOL filter_light, filter_path, filter_entities; extern id quakeed_i;
extern BOOL filter_clip_brushes, filter_water_brushes, filter_world;
extern UserPath *upath; extern BOOL filter_light, filter_path, filter_entities;
extern BOOL filter_clip_brushes, filter_water_brushes, filter_world;
extern id g_cmd_out_i; extern id g_cmd_out_i;
double I_FloatTime (void); double I_FloatTime (void);
void NopSound (void); void NopSound (void);
void qprintf (char *fmt, ...); // prints text to cmd_out_i @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];
NSRect cache_rect[3];
BOOL no_restore[3];
//
// UI objects // UI objects
id brushcount_i; //
id entitycount_i; id brushcount_i;
id regionbutton_i; id entitycount_i;
id regionbutton_i;
id show_coordinates_i; id show_coordinates_i;
id show_names_i; id show_names_i;
id filter_light_i; id filter_light_i;
id filter_path_i; id filter_path_i;
id filter_entities_i; id filter_entities_i;
id filter_clip_i; id filter_clip_i;
id filter_water_i; id filter_water_i;
id filter_world_i; id filter_world_i;
id cmd_in_i; // text fields id cmd_in_i; // text fields
id cmd_out_i; id cmd_out_i;
id xy_drawmode_i; // passed over to xyview after init id xy_drawmode_i; // passed over to xyview after init
} }
- setDefaultFilename; - (id) setDefaultFilename;
- (char *)currentFilename; - (NSString *) currentFilename;
- updateAll; // when a model has been changed - (id) updateAll; // when a model has been changed
- updateCamera; // when the camera has moved - (id) updateCamera; // when the camera has moved
- updateXY; - (id) updateXY;
- updateZ; - (id) updateZ;
- updateAll:sender; - (id) updateAll: sender;
- newinstance; // force next flushwindow to clear all instance drawing - (void) cameraNoRestore: (NSRect)rect;
- redrawInstance; // erase and redraw all instance now - (void) xyNoRestore: (NSRect)rect;
- (void) zNoRestore: (NSRect)rect;
- appDidInit:sender; - (id) newinstance; // force next flushwindow to clear all
- appWillTerminate:sender; // instance drawing
- (id) redrawInstance; // erase and redraw all instance now
- openProject:sender; - (id) appWillTerminate: sender;
- textCommand: sender; - (id) openProject: sender;
- applyRegion: sender; - (id) textCommand: sender;
- (BOOL)dirty; - (id) applyRegion: sender;
- clear: sender; - (BOOL) dirty;
- centerCamera: sender;
- centerZChecker: sender;
- changeXYLookUp: sender; - (id) clear: sender;
- (id) centerCamera: sender;
- (id) centerZChecker: sender;
- setBrushRegion: sender; - (id) changeXYLookUp: sender;
- setXYRegion: sender;
- open: sender; - (id) setBrushRegion: sender;
- save: sender; - (id) setXYRegion: sender;
- saveAs: sender;
- doOpen: (char *)fname; - (id) open: sender;
- (id) save: sender;
- (id) saveAs: sender;
- saveBSP:(char *)cmdline dialog:(BOOL)wt; - (id) doOpen: (NSString *)fname;
- BSP_Full: sender; - (id) saveBSP: (const char *)cmdline dialog: (BOOL)wt;
- BSP_FastVis: sender;
- BSP_NoVis: sender; - (id) BSP_Full: sender;
- BSP_relight: sender; - (id) BSP_FastVis: sender;
- BSP_stop: sender; - (id) BSP_NoVis: sender;
- BSP_entities: sender; - (id) BSP_relight: sender;
- (id) BSP_stop: sender;
- (id) BSP_entities: sender;
- (id) applicationDefined: (NSEvent *)theEvent;
// //
// UI querie for other objects // UI query for other objects
// //
- (BOOL)showCoordinates; - (BOOL) showCoordinates;
- (BOOL)showNames; - (BOOL) showNames;
@end @end
#endif // QuakeEd_h

File diff suppressed because it is too large Load diff

View file

@ -1,15 +1,27 @@
/* Generated by the NeXT Project Builder #include <AppKit/AppKit.h>
NOTE: Do NOT change this file -- Project Builder maintains it.
*/
#include <appkit/appkit.h> #include "QF/sys.h"
void main(int argc, char *argv[]) { #include "QuakeEd.h"
[Application new]; @interface QuakeEdApp: NSApplication
if ([NSApp loadNibSection:"QuakeEd.nib" owner:NSApp withNames:NO]) - (void) sendEvent: (NSEvent *)evt;
[NSApp run]; @end
[NSApp free]; @implementation QuakeEdApp
exit(0);
- (void) sendEvent: (NSEvent *)evt;
{
if ([evt type] == NSApplicationDefined)
[quakeed_i applicationDefined: evt];
else
[super sendEvent: evt];
}
@end
int
main (int argc, const char *argv[])
{
return NSApplicationMain (argc, argv);
} }

View file

@ -1,158 +1,172 @@
#ifndef SetBrush_h
#define SetBrush_h
#include <AppKit/AppKit.h>
#define MAX_FACES 16 #include "QF/mathlib.h"
typedef float vec5_t[5]; #include "TexturePalette.h"
typedef struct #define MAX_FACES 16
{
int numpoints; typedef struct {
vec5_t points[8]; // variable sized int numpoints;
vec5_t points[8]; // variable sized
} winding_t; } winding_t;
#define MAX_POINTS_ON_WINDING 64 #define MAX_POINTS_ON_WINDING 64
typedef struct typedef struct {
{ vec3_t normal;
vec3_t normal; float dist;
float dist;
} plane_t; } plane_t;
typedef struct typedef struct {
{
// implicit rep // implicit rep
vec3_t planepts[3]; vec3_t planepts[3];
texturedef_t texture; texturedef_t texture;
// cached rep // cached rep
plane_t plane; plane_t plane;
qtexture_t *qtexture; qtexture_t *qtexture;
float light; // 0 - 1.0 float light; // 0 - 1.0
winding_t *w; winding_t *w;
} face_t; } face_t;
#define ON_EPSILON 0.1 #define ON_EPSILON 0.1
#define FP_EPSILON 0.01 #define FP_EPSILON 0.01
#define VECTOR_EPSILON 0.0001 #define VECTOR_EPSILON 0.0001
#define SIDE_FRONT 0 #define SIDE_FRONT 0
#define SIDE_BACK 1 #define SIDE_BACK 1
#define SIDE_ON 2 #define SIDE_ON 2
winding_t *ClipWinding (winding_t * in, plane_t *split);
winding_t *CopyWinding (winding_t * w);
winding_t *NewWinding (int points);
winding_t *ClipWinding (winding_t *in, plane_t *split); @interface SetBrush: NSObject
winding_t *CopyWinding (winding_t *w);
winding_t *NewWinding (int points);
@interface SetBrush : Object
{ {
BOOL regioned; // not active BOOL regioned; // not active
BOOL selected; BOOL selected;
BOOL invalid; // not a proper polyhedron
BOOL invalid; // not a proper polyhedron id parent; // the entity this brush is in
vec3_t bmins, bmaxs;
id parent; // the entity this brush is in vec3_t entitycolor;
vec3_t bmins, bmaxs; int numfaces;
vec3_t entitycolor; face_t faces[MAX_FACES];
int numfaces;
face_t faces[MAX_FACES];
} }
- initOwner: own mins:(float *)mins maxs:(float *)maxs texture:(texturedef_t *)tex; - (SetBrush *) initOwner: (id)own
- initFromTokens: own; mins: (float *)mins
- setMins:(float *)mins maxs:(float *)maxs; maxs: (float *)maxs
texture: (texturedef_t *)tex;
- parent; - (id) initFromScript: (struct script_s *)script
- setParent: (id)p; owner: (id)own;
- setEntityColor: (vec3_t)color; - (id) setMins: (float *)mins maxs: (float *)maxs;
- calcWindings; - (id) parent;
- (id) setParent: (id)p;
- writeToFILE: (FILE *)f region: (BOOL)reg; - (id) setEntityColor: (vec3_t)color;
- (BOOL)selected; - (id) calcWindings;
- (BOOL)regioned;
- setSelected: (BOOL)s;
- setRegioned: (BOOL)s;
- getMins: (vec3_t)mins maxs: (vec3_t)maxs; - (void) writeToFILE: (FILE *)f region: (BOOL)reg;
- (BOOL)containsPoint: (vec3_t)pt; - (BOOL) selected;
- (BOOL) regioned;
- (void) setSelected: (BOOL)s;
- (void) setRegioned: (BOOL)s;
- freeWindings; - (void) getMins: (vec3_t)mins maxs: (vec3_t)maxs;
- removeIfInvalid;
extern vec3_t region_min, region_max; - (BOOL) containsPoint: (vec3_t)pt;
- newRegion;
- (texturedef_t *)texturedef; - (void) freeWindings;
- (texturedef_t *)texturedefForFace: (int)f; - (id) removeIfInvalid;
- setTexturedef: (texturedef_t *)tex;
- setTexturedef: (texturedef_t *)tex forFace:(int)f;
- XYDrawSelf; extern vec3_t region_min, region_max;
- ZDrawSelf;
- CameraDrawSelf;
- XYRenderSelf;
- CameraRenderSelf;
- hitByRay: (vec3_t)p1 : (vec3_t) p2 : (float *)time : (int *)face; - (id) newRegion;
- (texturedef_t *) texturedef;
- (texturedef_t *) texturedefForFace: (int)f;
- (void) setTexturedef: (texturedef_t *)tex;
- (void) setTexturedef: (texturedef_t *)tex forFace: (int)f;
- (void) XYDrawSelf;
- (void) ZDrawSelf;
- (void) CameraDrawSelf;
- (void) XYRenderSelf;
- (void) CameraRenderSelf;
- (void) hitByRay: (vec3_t)p1: (vec3_t)p2: (float *)time: (int *)face;
// //
// single brush actions // single brush actions
// //
extern int numcontrolpoints; extern int numcontrolpoints;
extern float *controlpoints[MAX_FACES*3]; extern float *controlpoints[MAX_FACES * 3];
- getZdragface: (vec3_t)dragpoint;
- getXYdragface: (vec3_t)dragpoint;
- getXYShearPoints: (vec3_t)dragpoint;
- addFace: (face_t *)f; - (void) getZdragface: (vec3_t)dragpoint;
- (void) getXYdragface: (vec3_t)dragpoint;
- (void) getXYShearPoints: (vec3_t)dragpoint;
- (id) addFace: (face_t *)f;
// //
// multiple brush actions // multiple brush actions
// //
- carveByClipper; - (void) carveByClipper;
extern vec3_t sb_translate; extern vec3_t sb_translate;
- translate;
extern id carve_in, carve_out; - (void) translate;
- select;
- deselect;
- remove;
- flushTextures;
extern vec3_t sb_mins, sb_maxs; extern id carve_in, carve_out;
- addToBBox;
extern vec3_t sel_x, sel_y, sel_z; - (void) select;
extern vec3_t sel_org; - (void) deselect;
- transform; - (void) remove;
- (void) flushTextures;
- flipNormals; extern vec3_t sb_mins, sb_maxs;
- carve; - (void) addToBBox;
- setCarveVars;
extern id sb_newowner; extern vec3_t sel_x, sel_y, sel_z;
- moveToEntity; extern vec3_t sel_org;
- takeCurrentTexture; - (void) transform;
extern vec3_t select_min, select_max; - (void) flipNormals;
- selectPartial;
- selectComplete;
- regionPartial;
- regionComplete;
extern float sb_floor_dir, sb_floor_dist; - (id) carve;
- feetToFloor; - (void) setCarveVars;
extern id sb_newowner;
- (void) moveToEntity;
- (void) takeCurrentTexture;
extern vec3_t select_min, select_max;
- (void) selectPartial;
- (void) selectComplete;
- (void) regionPartial;
- (void) regionComplete;
extern float sb_floor_dir, sb_floor_dist;
- (void) feetToFloor;
- (int) getNumBrushFaces; - (int) getNumBrushFaces;
- (face_t *)getBrushFace: (int)which; - (face_t *) getBrushFace: (int)which;
@end @end
#endif // SetBrush_h

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,85 @@
/* Interface for Objective C NeXT-compatible Storage object
Copyright (C) 1993,1994 Free Software Foundation, Inc.
Written by: Kresten Krab Thorup <krab@iesd.auc.dk>
Dept. of Mathematics and Computer Science, Aalborg U., Denmark
This file is part of the Gnustep Base Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/******************************************************************
TODO:
Does not implement methods for archiving itself.
******************************************************************/
#ifndef __Storage_h_INCLUDE_GNU
#define __Storage_h_INCLUDE_GNU
#include <AppKit/AppKit.h>
@interface Storage: NSObject
{
@public
void *dataPtr; /* data of the Storage object */
const char *description; /* Element description */
NSUInteger numElements; /* Actual number of elements */
NSUInteger maxElements; /* Total allocated elements */
NSUInteger elementSize; /* Element size */
}
/* Creating, freeing, initializing, and emptying */
- (id) init;
- (id) initCount: (NSUInteger)numSlots
elementSize: (NSUInteger)sizeInBytes
description: (const char *)elemDesc;
- (void) dealloc;
- (id) empty;
- (id) copy;
/* Manipulating the elements */
- (BOOL) isEqual: anObject;
- (const char *) description;
- (NSUInteger) count;
- (void *) elementAt: (NSUInteger)index;
- (id) replaceElementAt: (NSUInteger)index
with: (void *)anElement;
- (id) setNumSlots: (NSUInteger)numSlots;
- (id) setAvailableCapacity: (NSUInteger)numSlots;
- (id) addElement: (void *)anElement;
- (id) removeLastElement;
- (id) insertElement: (void *)anElement
at: (NSUInteger)index;
- (id) removeElementAt: (NSUInteger)index;
/* old-style creation */
+ (id) new;
+ (id) newCount: (NSUInteger)count
elementSize: (NSUInteger)sizeInBytes
description: (const char *)descriptor;
@end
typedef struct {
@defs (Storage)
} NXStorageId;
#endif /* __Storage_h_INCLUDE_GNU */

View file

@ -0,0 +1,253 @@
/* Implementation of Objective C NeXT-compatible Storage object
Copyright (C) 1993,1994, 1996 Free Software Foundation, Inc.
Written by: Kresten Krab Thorup <krab@iesd.auc.dk>
Dept. of Mathematics and Computer Science, Aalborg U., Denmark
This file is part of the GNUstep Base Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* #include <config.h> */
#include "Storage.h"
#include <string.h>
#include <strings.h>
#define GNU_STORAGE_NTH(x, N) \
({GNUStorageId* __s = (GNUStorageId*) (x); \
(void*) (((char*) __s->dataPtr) + (__s->elementSize * (N))); })
#define STORAGE_NTH(N) GNU_STORAGE_NTH (self, N)
typedef struct {
@defs (Storage)
} GNUStorageId;
@implementation Storage
+ (id) initialize
{
if (self == [Storage class])
[self setVersion: 0]; /* beta release */
return self;
}
// INITIALIZING, FREEING;
- (id) initCount: (NSUInteger)numSlots elementSize: (NSUInteger)sizeInBytes
description: (const char *)
elemDesc;
{
[super init];
numElements = numSlots;
maxElements = (numSlots > 0) ? numSlots : 1;
elementSize = sizeInBytes;
description = elemDesc;
dataPtr = (void *) objc_malloc (maxElements * elementSize);
bzero (dataPtr, numElements * elementSize);
return self;
}
- (id) init
{
return [self initCount: 1 elementSize: sizeof (id)
description: @encode (id)];
}
- (void) dealloc
{
if (dataPtr)
free (dataPtr);
[super dealloc];
}
- (const char *) description
{
return description;
}
// COPYING;
- (id) copy
{
Storage *c = [super copy];
c->dataPtr = (void *) objc_malloc (maxElements * elementSize);
memcpy (c->dataPtr, dataPtr, numElements * elementSize);
return c;
}
// COMPARING TWO STORAGES;
- (BOOL) isEqual: anObject
{
if ([anObject isKindOfClass: [Storage class]]
&& [anObject count] == [self count]
&& !memcmp (((GNUStorageId *) anObject)->dataPtr,
dataPtr, numElements * elementSize))
return YES;
else
return NO;
}
// MANAGING THE STORAGE CAPACITY;
static inline void
_makeRoomForAnotherIfNecessary (Storage * self)
{
if (self->numElements == self->maxElements) {
self->maxElements *= 2;
self->dataPtr = (void *)
objc_realloc (self->dataPtr,
self->maxElements * self->elementSize);
}
}
static inline void
_shrinkIfDesired (Storage * self)
{
if (self->numElements < (self->maxElements / 2)) {
self->maxElements /= 2;
self->dataPtr = (void *)
objc_realloc (self->dataPtr,
self->maxElements * self->elementSize);
}
}
- (id) setAvailableCapacity: (NSUInteger)numSlots
{
if (numSlots > numElements) {
maxElements = numSlots;
dataPtr = (void *) objc_realloc (dataPtr, maxElements * elementSize);
}
return self;
}
- (id) setNumSlots: (NSUInteger)numSlots
{
if (numSlots > numElements) {
maxElements = numSlots;
dataPtr = (void *) objc_realloc (dataPtr, maxElements * elementSize);
bzero (STORAGE_NTH (numElements),
(maxElements - numElements) * elementSize);
} else if (numSlots < numElements) {
numElements = numSlots;
_shrinkIfDesired (self);
}
return self;
}
/* Manipulating objects by index */
#define CHECK_INDEX(IND) if (IND >= numElements) return 0
- (NSUInteger) count
{
return numElements;
}
- (void *) elementAt: (NSUInteger)index
{
CHECK_INDEX (index);
return STORAGE_NTH (index);
}
- (id) addElement: (void *)anElement
{
_makeRoomForAnotherIfNecessary (self);
memcpy (STORAGE_NTH (numElements), anElement, elementSize);
numElements++;
return self;
}
- (id) insertElement: (void *)
anElement at: (NSUInteger)index
{
NSUInteger i;
CHECK_INDEX (index);
_makeRoomForAnotherIfNecessary (self);
#ifndef STABLE_MEMCPY
for (i = numElements; i >= index; i--)
memcpy (STORAGE_NTH (i + 1), STORAGE_NTH (i), elementSize);
#else
memcpy (STORAGE_NTH (index + 1),
STORAGE_NTH (index), elementSize * (numElements - index));
#endif
memcpy (STORAGE_NTH (i), anElement, elementSize);
numElements++;
return self;
}
- (id) removeElementAt: (NSUInteger)index
{
NSUInteger i;
CHECK_INDEX (index);
numElements--;
#ifndef STABLE_MEMCPY
for (i = index; i < numElements; i++)
memcpy (STORAGE_NTH (i), STORAGE_NTH (i + 1), elementSize);
#else
memcpy (STORAGE_NTH (index),
STORAGE_NTH (index + 1), elementSize * (numElements - index - 1));
#endif
_shrinkIfDesired (self);
return self;
}
- (id) removeLastElement
{
if (numElements) {
numElements--;
_shrinkIfDesired (self);
}
return self;
}
- (id) replaceElementAt: (NSUInteger)
index with: (void *)newElement
{
CHECK_INDEX (index);
memcpy (STORAGE_NTH (index), newElement, elementSize);
return self;
}
/* Emptying the Storage */
- (id) empty
{
numElements = 0;
maxElements = 1;
dataPtr = (void *) objc_realloc (dataPtr, maxElements * elementSize);
return self;
}
+ (id) new
{
return [[self alloc] init];
}
+ (id) newCount: (NSUInteger)
count elementSize: (NSUInteger)sizeInBytes
description: (const char *)descriptor
{
return [[self alloc] initCount: count elementSize: sizeInBytes description:
descriptor];
}
@end

View file

@ -0,0 +1,35 @@
@implementation THING (NSArray)
- (NSUInteger) count
{
return [array count];
}
- (id) objectAtIndex: (NSUInteger)index
{
if (index >= [self count])
return 0;
return [array objectAtIndex: index];
}
- (void) addObject: (id)anObject
{
[array addObject: anObject];
}
- (void) insertObject: (id)anObject atIndex: (NSUInteger)index
{
[array insertObject: anObject atIndex: index];
}
- (void) removeObjectAtIndex: (NSUInteger)index
{
[array removeObjectAtIndex: index];
}
- (void) replaceObjectAtIndex: (NSUInteger)index withObject: (id)anObject
{
[array replaceObjectAtIndex: index withObject: anObject];
}
@end

View file

@ -1,113 +1,113 @@
#ifndef TexturePalette_h
#define TexturePalette_h
typedef union #include <AppKit/AppKit.h>
{
byte chan[4]; #include "QF/qtypes.h"
unsigned p;
typedef union {
byte chan[4];
unsigned p;
} pixel32_t; } pixel32_t;
typedef struct {
typedef struct char texture[16];
{ float rotate;
char texture[16]; float shift[2];
float rotate; float scale[2];
float shift[2];
float scale[2];
} texturedef_t; } texturedef_t;
typedef struct {
char name[16];
typedef struct int width;
{ int height;
char name[16]; NSBitmapImageRep *rep;
void *data;
int width; pixel32_t flatcolor;
int height;
NSBitmapImageRep *rep;
void *data;
pixel32_t flatcolor;
} qtexture_t; } qtexture_t;
#define MAX_TEXTURES 1024 #define MAX_TEXTURES 1024
extern int tex_count; extern int tex_count;
extern qtexture_t qtextures[MAX_TEXTURES]; extern qtexture_t qtextures[MAX_TEXTURES];
void TEX_InitFromWad (char *path); qtexture_t *TEX_ForName (const char *name);
qtexture_t *TEX_ForName (char *name);
typedef struct {
typedef struct NSImageRep *image;
{ NSRect r;
id image; // NSImage char *name;
NSRect r; int index;
char *name; int display; // flag (on/off)
int index;
int display; // flag (on/off)
} texpal_t; } texpal_t;
#define TEX_INDENT 10 #define TEX_INDENT 10
#define TEX_SPACING 16 #define TEX_SPACING 16
extern id texturepalette_i; extern id texturepalette_i;
@interface TexturePalette:Object @interface TexturePalette: NSObject
{ {
char currentwad[1024]; char currentwad[1024];
id textureList_i; id textureList_i;
id textureView_i; id textureView_i;
id searchField_i; id searchField_i;
id sizeField_i; id sizeField_i;
id field_Xshift_i; id field_Xshift_i;
id field_Yshift_i; id field_Yshift_i;
id field_Xscale_i; id field_Xscale_i;
id field_Yscale_i; id field_Yscale_i;
id field_Rotate_i; id field_Rotate_i;
int viewWidth; int viewWidth;
int viewHeight; int viewHeight;
int selectedTexture; int selectedTexture;
} }
- (char*)currentWad; - (const char *) currentWad;
- initPaletteFromWadfile:(char *)wf; - (id) initPaletteFromWadfile: (const char *)wf;
- computeTextureViewSize; - (id) computeTextureViewSize;
- alphabetize; - (id) alphabetize;
- getList; - (id) getList;
- (int)getSelectedTexture; - (int) getSelectedTexture;
- setSelectedTexture:(int)which; - (id) setSelectedTexture: (int)which;
- (int)getSelectedTexIndex; - (int) getSelectedTexIndex;
// Called externally // Called externally
- (char *)getSelTextureName; - (const char *) getSelTextureName;
- setTextureByName:(char *)name; - (id) setTextureByName: (const char *)name;
// New methods to replace the 2 above ones // New methods to replace the 2 above ones
- setTextureDef:(texturedef_t *)td; - (id) setTextureDef: (texturedef_t *)td;
- getTextureDef:(texturedef_t *)td; - (id) getTextureDef: (texturedef_t *)td;
// Action methods // Action methods
- searchForTexture:sender; - (id) searchForTexture: sender;
- clearTexinfo: sender; - (id) clearTexinfo: sender;
- incXShift:sender; - (id) incXShift: sender;
- decXShift:sender; - (id) decXShift: sender;
- incYShift:sender; - (id) incYShift: sender;
- decYShift:sender; - (id) decYShift: sender;
- incRotate: sender; - (id) incRotate: sender;
- decRotate: sender; - (id) decRotate: sender;
- incXScale:sender; - (id) incXScale: sender;
- decXScale:sender; - (id) decXScale: sender;
- incYScale:sender; - (id) incYScale: sender;
- decYScale:sender; - (id) decYScale: sender;
- texturedefChanged: sender; - (id) texturedefChanged: sender;
- onlyShowMapTextures:sender; - (id) onlyShowMapTextures: sender;
- (int) searchForTextureInPalette:(char *)texture; - (int) searchForTextureInPalette: (const char *)texture;
- setDisplayFlag:(int)index to:(int)value; - (id) setDisplayFlag: (int)index
to: (int)value;
@end @end
#endif // TexturePalette_h

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,16 @@
#ifndef TextureView_h
#define TextureView_h
#include <AppKit/AppKit.h>
@interface TextureView:NSView @interface TextureView: NSView
{ {
id parent_i; id parent_i;
int deselectIndex; int deselectIndex;
} }
- setParent:(id)from; - (id) setParent: (id)from;
- deselect; - (id) deselect;
@end @end
#endif // TextureView_h

View file

@ -1,5 +1,10 @@
#include "QF/sys.h"
#include "qedefs.h" #include "KeypairView.h"
#include "TextureView.h"
#include "TexturePalette.h"
#include "Storage.h"
/* /*
@ -9,143 +14,135 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
@implementation TextureView @implementation TextureView
- init - (id) init
{ {
deselectIndex = -1; deselectIndex = -1;
return self; return self;
} }
- setParent:(id)from - (BOOL) isOpaque
{
return YES;
}
- (id) setParent: (id)from
{ {
parent_i = from; parent_i = from;
return self; return self;
} }
- (BOOL)acceptsFirstMouse - (BOOL) acceptsFirstMouse
{ {
return YES; return YES;
} }
- drawSelf:(const NSRect *)rects :(int)rectCount - (id) drawRect: (NSRect)rects
{ {
int i; int i;
int max; int max;
id list_i; id list_i;
texpal_t *t; texpal_t *t;
int x; int x;
int y; int y;
NSPoint p; NSPoint p;
NSRect r; NSRect r;
int selected; int selected;
NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
selected = [parent_i getSelectedTexture]; selected = [parent_i getSelectedTexture];
list_i = [parent_i getList]; list_i = [parent_i getList];
PSselectfont("Helvetica-Medium",FONTSIZE); [[NSFont systemFontOfSize: FONTSIZE] set];
PSrotate(0);
PSsetgray(NS_LTGRAY);
PSrectfill(rects->origin.x, rects->origin.y,
rects->size.width, rects->size.height);
if (!list_i) // WADfile didn't init [[NSColor lightGrayColor] set];
NSRectFill (rects);
if (!list_i) // WADfile didn't init
return self; return self;
if (deselectIndex != -1) {
if (deselectIndex != -1) t = [list_i elementAt: deselectIndex];
{
t = [list_i elementAt:deselectIndex];
r = t->r; r = t->r;
r.origin.x -= TEX_INDENT; r.origin.x -= TEX_INDENT;
r.origin.y -= TEX_INDENT; r.origin.y -= TEX_INDENT;
r.size.width += TEX_INDENT*2; r.size.width += TEX_INDENT * 2;
r.size.height += TEX_INDENT*2; r.size.height += TEX_INDENT * 2;
PSsetgray(NSGrayComponent(NS_COLORLTGRAY)); [[NSColor lightGrayColor] set];
PSrectfill(r.origin.x, r.origin.y, NSRectFill (r);
r.size.width, r.size.height);
p = t->r.origin; p = t->r.origin;
p.y += TEX_SPACING; p.y += TEX_SPACING;
[t->image drawAt:&p]; [t->image drawAtPoint: p];
PSsetgray(0); [[NSColor blackColor] set];
x = t->r.origin.x; x = t->r.origin.x;
y = t->r.origin.y + 7; y = t->r.origin.y + 7;
PSmoveto(x,y); [[NSString stringWithCString: t->name]
PSshow(t->name); drawAtPoint: NSMakePoint (x, y) withAttributes: attribs];
PSstroke();
deselectIndex = -1; deselectIndex = -1;
} }
max = [list_i count]; max = [list_i count];
PSsetgray(0); [[NSColor blackColor] set];
for (i = 0;i < max; i++) for (i = 0; i < max; i++) {
{ t = [list_i elementAt: i];
t = [list_i elementAt:i];
r = t->r; r = t->r;
r.origin.x -= TEX_INDENT/2; r.origin.x -= TEX_INDENT / 2;
r.size.width += TEX_INDENT; r.size.width += TEX_INDENT;
r.origin.y += 4; r.origin.y += 4;
if (NSIntersectsRect(&rects[0],&r) == YES && if (NSIntersectsRect (rects, r) == YES && t->display) {
t->display) if (selected == i) {
{ [[NSColor whiteColor] set];
if (selected == i) NSRectFill (r);
{ [[NSColor redColor] set];
PSsetgray(1); NSFrameRect (r);
PSrectfill(r.origin.x,r.origin.y, [[NSColor blackColor] set];
r.size.width,r.size.height);
PSsetrgbcolor(1,0,0);
PSrectstroke(r.origin.x, r.origin.y,
r.size.width, r.size.height);
PSsetgray(0);
} }
p = t->r.origin; p = t->r.origin;
p.y += TEX_SPACING; p.y += TEX_SPACING;
[t->image drawAt:&p]; [t->image drawAtPoint: p];
x = t->r.origin.x; x = t->r.origin.x;
y = t->r.origin.y + 7; y = t->r.origin.y + 7;
PSmoveto(x,y); [[NSString stringWithCString: t->name]
PSshow(t->name); drawAtPoint: NSMakePoint (x, y) withAttributes: attribs];
} }
} }
PSstroke();
return self; return self;
} }
- deselect - (id) deselect
{ {
deselectIndex = [parent_i getSelectedTexture]; deselectIndex = [parent_i getSelectedTexture];
return self; return self;
} }
- mouseDown:(NSEvent *)theEvent - (id) mouseDown: (NSEvent *)theEvent
{ {
NSPoint loc; NSPoint loc;
int i; int i;
int max; int max;
int oldwindowmask;
texpal_t *t; // int oldwindowmask;
id list; texpal_t *t;
NSRect r; id list;
NSRect r;
// oldwindowmask = [window addToEventMask:NSLeftMouseDraggedMask];
loc = [theEvent locationInWindow];
loc = [self convertPoint: loc fromView: NULL];
oldwindowmask = [window addToEventMask:NS_LMOUSEDRAGGEDMASK];
loc = theEvent->location;
[self convertPoint:&loc fromView:NULL];
list = [parent_i getList]; list = [parent_i getList];
max = [list count]; max = [list count];
for (i = 0;i < max; i++) for (i = 0; i < max; i++) {
{ t = [list elementAt: i];
t = [list elementAt:i];
r = t->r; r = t->r;
if (NSPointInRect(&loc,&r) == YES) if (NSPointInRect (loc, r) == YES) {
{ [self deselect];
[self deselect]; [parent_i setSelectedTexture: i];
[parent_i setSelectedTexture:i];
break; break;
} }
} }
[window setEventMask:oldwindowmask]; // [window setEventMask:oldwindowmask];
return self; return self;
} }

View file

@ -1,42 +1,46 @@
#ifndef Things_h
#define Things_h
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
extern id things_i; #include "Entity.h"
#define ENTITYNAMEKEY "spawn" extern id things_i;
@interface Things:Object #define ENTITYNAMEKEY "spawn"
@interface Things: NSObject
{ {
id entity_browser_i; // browser id entity_browser_i; // browser
id entity_comment_i; // scrolling text window id entity_comment_i; // scrolling text window
id prog_path_i;
int lastSelected; // last row selected in browser
id keyInput_i; id prog_path_i;
id valueInput_i;
id flags_i; int lastSelected; // last row selected in browser
id keyInput_i;
id valueInput_i;
id flags_i;
} }
- initEntities; - (id) initEntities;
- newCurrentEntity; - (id) newCurrentEntity;
- setSelectedKey:(epair_t *)ep; - (id) setSelectedKey: (epair_t *)ep;
- clearInputs; - (id) clearInputs;
- (char *)spawnName; - (const char *) spawnName;
// UI targets // UI targets
- reloadEntityClasses: sender; - (id) reloadEntityClasses: sender;
- selectEntity: sender; - (id) selectEntity: sender;
- doubleClickEntity: sender; - (id) doubleClickEntity: sender;
// Action methods // Action methods
- addPair:sender; - (id) addPair: sender;
- delPair:sender; - (id) delPair: sender;
- setAngle:sender; - (id) setAngle: sender;
- setFlags:sender; - (id) setFlags: sender;
@end @end
#endif // Things_h

View file

@ -1,222 +1,223 @@
#include "QF/sys.h"
#include "QF/va.h"
#include "qedefs.h" #include "Things.h"
#include "QuakeEd.h"
#include "Map.h"
#include "EntityClass.h"
#include "KeypairView.h"
#include "Project.h"
id things_i; id things_i;
@implementation Things @implementation Things
- init - (id) init
{ {
[super init]; [super init];
things_i = self; things_i = self;
lastSelected = 0; lastSelected = 0;
return self; return self;
} }
// - (void) awakeFromNib
// Load the TEXT object with the entity comment
//
- loadEntityComment:(id)obj
{ {
[entity_comment_i selectAll:self]; // FIXME this should not be needed (bug in gnustep?)
[entity_comment_i replaceSel:[obj comments]]; [flags_i selectAll: self];
[flags_i deselectAllCells];
}
// Load the TEXT object with the entity comment
- (id) loadEntityComment: (id)obj
{
[entity_comment_i selectAll: self];
[entity_comment_i
replaceCharactersInRange: [entity_comment_i selectedRange]
withString: [NSString stringWithCString: [obj comments]]];
return self; return self;
} }
- (id) initEntities
- initEntities {
{ NSString *path;
char *path;
path = [project_i getProgDirectory]; path = [project_i getProgDirectory];
[prog_path_i setStringValue: path]; [prog_path_i setStringValue: path];
[[EntityClassList alloc] initForSourceDirectory: path];
[self loadEntityComment:[entity_classes_i objectAt:lastSelected]]; [[EntityClassList alloc] initForSourceDirectory: [path cString]];
[self loadEntityComment: [entity_classes_i objectAtIndex: lastSelected]];
[entity_browser_i loadColumnZero]; [entity_browser_i loadColumnZero];
[[entity_browser_i matrixInColumn:0] selectCellAt:lastSelected :0]; [[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column: 0];
[entity_browser_i setDoubleAction: @selector (doubleClickEntity:)];
[entity_browser_i setDoubleAction: @selector(doubleClickEntity:)];
return self; return self;
} }
- selectEntity: sender - (id) selectEntity: sender
{ {
id matr; id matr;
matr = [sender matrixInColumn: 0]; matr = [sender matrixInColumn: 0];
lastSelected = [matr selectedRow]; lastSelected = [matr selectedRow];
[self loadEntityComment:[entity_classes_i objectAt:lastSelected]]; [self loadEntityComment: [entity_classes_i objectAtIndex: lastSelected]];
[quakeed_i makeFirstResponder: quakeed_i]; [quakeed_i makeFirstResponder: quakeed_i];
return self; return self;
} }
- doubleClickEntity: sender - (id) doubleClickEntity: sender
{ {
[map_i makeEntity: sender]; [map_i makeEntity: sender];
[quakeed_i makeFirstResponder: quakeed_i]; [quakeed_i makeFirstResponder: quakeed_i];
return self; return self;
} }
- (char *)spawnName - (const char *) spawnName
{ {
return [[entity_classes_i objectAt:lastSelected] classname]; return [[entity_classes_i objectAtIndex: lastSelected] classname];
} }
// Flush entity classes & reload them!
// - (id) reloadEntityClasses: sender
// Flush entity classes & reload them!
//
- reloadEntityClasses: sender
{ {
EntityClass *ent; EntityClass *ent;
char *path; NSString *path;
path = (char *)[prog_path_i stringValue]; 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: 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 freeObjects]; [entity_classes_i release];
[entity_classes_i free];
// Now, RELOAD!
// Now, RELOAD! [[EntityClassList alloc] initForSourceDirectory: [path cString]];
[[EntityClassList alloc] initForSourceDirectory: path];
lastSelected = 0; lastSelected = 0;
ent = [entity_classes_i objectAt:lastSelected]; ent = [entity_classes_i objectAtIndex: lastSelected];
[self loadEntityComment:[entity_classes_i objectAt:lastSelected]]; [self loadEntityComment: [entity_classes_i objectAtIndex: lastSelected]];
[entity_browser_i loadColumnZero]; [entity_browser_i loadColumnZero];
[[entity_browser_i matrixInColumn:0] selectCellAt:lastSelected :0]; [[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column: 0];
[self newCurrentEntity]; // in case flags changed
[self newCurrentEntity]; // in case flags changed
return self; return self;
} }
- (id) selectClass: (const char *)class
- selectClass: (char *)class
{ {
id classent; id classent;
classent = [entity_classes_i classForName:class]; classent = [entity_classes_i classForName: class];
if (!classent) if (!classent)
return self; return self;
lastSelected = [entity_classes_i indexOf: classent]; lastSelected = [entity_classes_i indexOfObject: classent];
if (lastSelected < 0) if (lastSelected < 0)
lastSelected = 0; lastSelected = 0;
[self loadEntityComment: classent];
[self loadEntityComment:classent]; [[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column: 0];
[[entity_browser_i matrixInColumn:0] selectCellAt:lastSelected :0]; [[entity_browser_i matrixInColumn: 0] scrollCellToVisibleAtRow: lastSelected
[[entity_browser_i matrixInColumn:0] scrollCellToVisible:lastSelected :0]; column: 0];
return self; return self;
} }
- (id) newCurrentEntity
- newCurrentEntity
{ {
id ent, classent, cell; id ent, classent, cell;
char *classname; const char *classname;
int r, c; int r, c;
char *flagname; const char *flagname;
int flags; int flags;
ent = [map_i currentEntity]; ent = [map_i currentEntity];
classname = [ent valueForQKey: "classname"]; classname = [ent valueForQKey: "classname"];
if (ent != [map_i objectAt: 0]) if (ent != [map_i objectAtIndex: 0])
[self selectClass: classname]; // don't reset for world [self selectClass: classname]; // don't reset for world
classent = [entity_classes_i classForName:classname]; classent = [entity_classes_i classForName: classname];
flagname = [ent valueForQKey: "spawnflags"]; flagname = [ent valueForQKey: "spawnflags"];
if (!flagname) if (!flagname)
flags = 0; flags = 0;
else else
flags = atoi(flagname); flags = atoi (flagname);
[flags_i setAutodisplay: NO]; // [flags_i setAutodisplay:NO];
for (r=0 ; r<4 ; r++) for (r = 0; r < 4; r++) {
for (c=0 ; c<3 ; c++) for (c = 0; c < 3; c++) {
{ cell = [flags_i cellAtRow: r column: c];
cell = [flags_i cellAt: r : c]; if (c < 2) {
if (c < 2) flagname = [classent flagName: c * 4 + r];
{ [cell setTitle: [NSString stringWithCString: flagname]];
flagname = [classent flagName: c*4 + r];
[cell setTitle: flagname];
} }
[cell setIntValue: (flags & (1<< ((c*4)+r)) ) > 0]; [cell setIntValue: (flags & (1 << ((c * 4) + r))) > 0];
} }
[flags_i setAutodisplay: YES]; }
// [flags_i setAutodisplay:YES];
[flags_i display]; [flags_i display];
// [keyInput_i setStringValue: ""]; // [keyInput_i setStringValue: ""];
// [valueInput_i setStringValue: ""]; // [valueInput_i setStringValue: ""];
[keypairview_i calcViewSize]; [keypairview_i calcViewSize];
[keypairview_i display]; [keypairview_i display];
[quakeed_i makeFirstResponder: quakeed_i]; [quakeed_i makeFirstResponder: quakeed_i];
return self; return self;
} }
// // Clicked in the Keypair view - set as selected
// Clicked in the Keypair view - set as selected - (id) setSelectedKey: (epair_t *)ep;
//
- setSelectedKey:(epair_t *)ep;
{ {
[keyInput_i setStringValue:ep->key]; [keyInput_i setStringValue: [NSString stringWithCString: ep->key]];
[valueInput_i setStringValue:ep->value]; [valueInput_i setStringValue: [NSString stringWithCString: ep->value]];
[valueInput_i selectText:self]; [valueInput_i selectText: self];
return self; return self;
} }
- clearInputs - (id) clearInputs
{ {
// [keyInput_i setStringValue: ""]; // [keyInput_i setStringValue: ""];
// [valueInput_i setStringValue: ""]; // [valueInput_i setStringValue: ""];
[quakeed_i makeFirstResponder: quakeed_i]; [quakeed_i makeFirstResponder: quakeed_i];
return self; return self;
} }
// // Action methods
// Action methods
//
-addPair:sender - (id) addPair: sender
{ {
char *key, *value; const char *key, *value;
key = (char *)[keyInput_i stringValue]; key = [[keyInput_i stringValue] cString];
value = (char *)[valueInput_i stringValue]; value = [[valueInput_i stringValue] cString];
[ [map_i currentEntity] setKey: key toValue: value ]; [[map_i currentEntity] setKey: key toValue: value];
[keypairview_i calcViewSize]; [keypairview_i calcViewSize];
[keypairview_i display]; [keypairview_i display];
[self clearInputs]; [self clearInputs];
[quakeed_i updateXY]; [quakeed_i updateXY];
return self; return self;
} }
-delPair:sender - (id) delPair: sender
{ {
[quakeed_i makeFirstResponder: quakeed_i]; [quakeed_i makeFirstResponder: quakeed_i];
[ [map_i currentEntity] removeKeyPair: (char *)[keyInput_i stringValue] ]; [[map_i currentEntity] removeKeyPair: [[keyInput_i stringValue] cString]];
[keypairview_i calcViewSize]; [keypairview_i calcViewSize];
[keypairview_i display]; [keypairview_i display];
@ -228,90 +229,78 @@ id things_i;
return self; return self;
} }
// Set the key/value fields to "angle <button value>"
// - (id) setAngle: sender
// Set the key/value fields to "angle <button value>"
//
- setAngle:sender
{ {
const char *title; NSString *value;
char value[10];
value = [[sender selectedCell] title];
title = [[sender selectedCell] title]; if (![value compare: @"Up"])
if (!strcmp(title,"Up")) value = @"-1";
strcpy (value, "-1"); else if (![value compare: @"Dn"])
else if (!strcmp(title,"Dn")) value = @"-2";
strcpy (value, "-2");
else [keyInput_i setStringValue: @"angle"];
strcpy (value, title); [valueInput_i setStringValue: value];
[self addPair: NULL];
[keyInput_i setStringValue:"angle"];
[valueInput_i setStringValue:value];
[self addPair:NULL];
[self clearInputs]; [self clearInputs];
[quakeed_i updateXY]; [quakeed_i updateXY];
return self; return self;
} }
- setFlags:sender - (id) setFlags: sender
{ {
int flags; int flags;
int r, c, i; int r, c, i;
id cell; id cell;
char str[20];
[self clearInputs]; [self clearInputs];
flags = 0; flags = 0;
for (r=0 ; r<4 ; r++) for (r = 0; r < 4; r++) {
for (c=0 ; c<3 ; c++) for (c = 0; c < 3; c++) {
{ cell = [flags_i cellAtRow: r column: c];
cell = [flags_i cellAt: r : c];
i = ([cell intValue] > 0); i = ([cell intValue] > 0);
flags |= (i<< ((c*4)+r)); flags |= (i << ((c * 4) + r));
} }
}
if (!flags) if (!flags)
[[map_i currentEntity] removeKeyPair: "spawnflags"]; [[map_i currentEntity] removeKeyPair: "spawnflags"];
else else
{ [[map_i currentEntity] setKey: "spawnflags" toValue: va ("%i", flags)];
sprintf (str, "%i", flags);
[[map_i currentEntity] setKey: "spawnflags" toValue: str];
}
[keypairview_i calcViewSize]; [keypairview_i calcViewSize];
[keypairview_i display]; [keypairview_i display];
return self; return self;
} }
// Fill the Entity browser
// // (Delegate method - delegated in Interface Builder)
// Fill the Entity browser - (void) browser: sender
// (Delegate method - delegated in Interface Builder) createRowsForColumn: (int)column
// inMatrix: matrix
- (int)browser:sender fillMatrix:matrix inColumn:(int)column
{ {
id cell; id cell;
int max; int max;
int i; int i;
id object; id object;
max = [entity_classes_i count]; max = [entity_classes_i count];
i = 0; i = 0;
while(max--) while (max--) {
{ object = [entity_classes_i objectAtIndex: i];
object = [entity_classes_i objectAt:i];
[matrix addRow]; [matrix addRow];
cell = [matrix cellAt:i++ :0]; cell = [matrix cellAtRow: i++ column: 0];
[cell setStringValue:[object classname]]; [cell setStringValue: [NSString
[cell setLeaf:YES]; stringWithCString: [object classname]]];
[cell setLoaded:YES]; [cell setLeaf: YES];
[cell setLoaded: YES];
} }
return i;
} }
@end @end

View file

@ -1,72 +0,0 @@
/*
* UserPath.h by Bruce Blumberg, NeXT Computer, Inc.
*
* You may freely copy,distribute and re-use the code in this example. NeXT
* disclaims any warranty of any kind, expressed or implied, as to its fitness
* for any particular purpose
*
* This file and its associated .m file define a data structure and set of
* functions aimed at facilitating the use of user paths. Here is a simple
* example:
*
* UserPath *arect;
* arect = newUserPath(); // creates an empty user path
* beginUserPath(arect,YES); // initialize user path and cache
* UPmoveto(arect,0.0,0.0); // add moveto to userpath; update bounding box
* UPrlineto(arect,0.0,100.0); // add rlineto to path; update bounding box
* UPrlineto(arect,100.0,0.0); // add rlineto to path; update bounding box
* UPrlineto(arect,0.0,-100.0); // add rlineto to path; update bounding box
* closePath(arect); // close path
* endUserPath(arect,dps_stroke); // close user path and specify operator
* sendUserPath(arect);
*
* As you will note, the set of routines manage the allocation and growth of
* the operator and operand arrays, as well as the calculation of the bounding
* box. A user path created via these functions may be optionally cached down
* at the window server, or repeatedly sent down. The user paths created by
* this set of functions are all allocated in a unique zone.
*
* Note: the associated file is a .m file because it pulls in some .h files
* which reference objective C methods.
*/
#include <objc/objc.h>
#include <AppKit/NSGraphicsContext.h>
typedef struct _UP {
float *points;
int numberOfPoints;
char *ops;
NSPoint cp;
int numberOfOps;
int max;
float bbox[4];
int opForUserPath;
BOOL ping;
} UserPath;
/* UserPath functions */
NSZone *userPathZone();
UserPath *newUserPath();
void freeUserPath(UserPath *up);
void debugUserPath(UserPath *up, BOOL shouldPing);
void growUserPath(UserPath *up);
void beginUserPath(UserPath *up, BOOL cache);
void endUserPath(UserPath *up, int op);
int sendUserPath(UserPath *up);
void UPmoveto(UserPath *up, float x, float y);
void UPrmoveto(UserPath *up, float x, float y);
void UPlineto(UserPath *up, float x, float y);
void UPrlineto(UserPath *up, float x, float y);
void UPcurveto(UserPath *up, float x1, float y1, float x2, float y2, float x3,
float y3);
void UPrcurveto(UserPath *up, float dx1, float dy1, float dx2, float dy2,
float dx3, float dy3);
void UParc(UserPath *up, float x, float y, float r, float ang1, float ang2);
void UParcn(UserPath *up, float x, float y, float r, float ang1, float ang2);
void UParct(UserPath *up, float x1, float y1, float x2, float y2, float r);
void closePath(UserPath *up);
void addPts(UserPath *up, float x, float y);
void addOp(UserPath *up, int op);
void add(UserPath *up, int op, float x, float y);
void checkBBox(UserPath *up, float x, float y);

View file

@ -1,209 +0,0 @@
/*
* UserPath.m by Bruce Blumberg, NeXT Computer, Inc.
*
* You may freely copy,distribute and re-use the code in this example. NeXT
* disclaims any warranty of any kind, expressed or implied, as to its fitness
* for any particular purpose
*
*/
#include "UserPath.h"
#include <mach/mach_init.h>
#include <appkit/graphics.h>
#include <appkit/errors.h>
#include <math.h>
#include <libc.h>
static NSZone *upZone = NULL;
NSZone *userPathZone()
/* Creates a unique zone for use by all user paths */
{
if (!upZone) {
upZone = NSCreateZone(vm_page_size, vm_page_size, 1);
}
return upZone;
}
UserPath *newUserPath()
/* Creates a new User Path in the zone returned by userPathZone */
{
UserPath *up;
up = (UserPath *)NSZoneMalloc(userPathZone(), sizeof(UserPath));
up->max = 8192; // JDC
up->points = (float *)NSZoneMalloc(userPathZone(),
sizeof(float) * up->max);
up->ops = (char *)NSZoneMalloc(userPathZone(),
(2 + (up->max / 2)) * sizeof(char));
up->ping = NO;
return up;
}
void freeUserPath(UserPath *up)
/* Frees User Path and its associated buffers */
{
free(up->points);
free(up->ops);
free(up);
return;
}
void growUserPath(UserPath *up)
/*
* grows the associated buffers as necessary. buffer size doubles on each
* call. You never need to call grow directly as it is called as needed by the
* methods and functions which add elements into the buffer
*/
{
/* double the size of the internal buffers */
printf ("growUserPath\n");
up->max *= 2;
up->points = (float *)NSZoneRealloc(userPathZone(), up->points,
sizeof(float) * up->max);
up->ops = (char *)NSZoneRealloc(userPathZone(), up->ops,
(2 + (up->max / 2)) * sizeof(char));
return;
}
void beginUserPath(UserPath *up, BOOL cache)
/*
* Call this to start generating a user path. The cache argument specifies if
* you want the user path cached at the server (i.e. dps_ucache). In either
* case, the UserPath object will automatically calculate the bounding box for
* the path and add the dps_setbbox operator.
*/
{
up->numberOfPoints = up->numberOfOps = 0;
up->cp.x = up->cp.y = 0;
up->bbox[0] = up->bbox[1] = 1.0e6;
up->bbox[2] = up->bbox[3] = -1.0e6;
if (cache) {
up->ops[up->numberOfOps++] = dps_ucache;
}
up->ops[up->numberOfOps++] = dps_setbbox;
up->opForUserPath = 0;
return;
}
void endUserPath(UserPath *up, int op)
/*
* Call this to stop filling the path. Note this does not send the userpath to
* the server -- use sendUserPath. The op argument should be one of the
* following:
* dps_uappend, dps_ufill ,dps_ueofill, dps_ustroke, dps_ustrokepath,
* dps_inufill, dps_inueofill, dps_inustroke, dps_def, dps_put.
* These are defined in <dpsclient/dpsNext.h.
*/
{
up->opForUserPath = op;
return;
}
void UPdebug(UserPath *up, BOOL shouldPing)
/*
* Sets ping to YES so that after each time a user path is sent down to the
* window server, an NSPing() is sent after. The purpose is to catch PostScript
* errors that may be generated by the user path. sendUserPath brackets the
* download and the NSPing() in an NS_DURING... NS_HANDLER construct. Normally
* ping is NO.
*/
{
up->ping = shouldPing;
return;
}
int sendUserPath(UserPath *up)
/*
* Call this to send the path down to the server. If ping==YES (set via
* debug:), the function will send an NSPing() after the Path. In any event,
* code is bracketed by a NS_DURING ... NS_HANDLER construct which will try to
* catch postscript errors. If ping==NO (the default) it is unlikely to catch
* errors, with ping==YES it will. Whether you can recover or not is another
* matter. sendUserPath returns 0 on success and -1 on failure. If no previous
* endUserPath: has been sent, will return -2 and will not send the path to the
* server.
*/
{
NSHandler exception;
exception.code = 0;
if (up->opForUserPath != 0) {
NS_DURING
DPSDoUserPath(up->points, up->numberOfPoints, dps_float, up->ops,
up->numberOfOps, up->bbox, up->opForUserPath);
if (up->ping) {
NSPing();
}
NS_HANDLER
exception = NSLocalHandler;
NS_ENDHANDLER
if (exception.code) {
NSReportError(&exception);
if (exception.code == dps_err_ps) {
return -1;
}
} else {
return 0;
}
}
return -1;
}
void UPmoveto(UserPath *up, float x, float y)
/* adds <x y moveto> to user path and updates bounding box */
{
up->ops[up->numberOfOps++] = dps_moveto;
up->points[up->numberOfPoints++] = x;
up->points[up->numberOfPoints++] = y;
if (x < up->bbox[0]) {
up->bbox[0] = x;
}
if (y < up->bbox[1]) {
up->bbox[1] = y;
}
if (x > up->bbox[2]) {
up->bbox[2] = x;
}
if (y > up->bbox[3]) {
up->bbox[3] = y;
}
return;
}
void UPlineto(UserPath *up, float x, float y)
/* adds <x y lineto> to user path and updates bounding box */
{
up->ops[up->numberOfOps++] = dps_lineto;
up->points[up->numberOfPoints++] = x;
up->points[up->numberOfPoints++] = y;
if (x < up->bbox[0]) {
up->bbox[0] = x;
}
if (y < up->bbox[1]) {
up->bbox[1] = y;
}
if (x > up->bbox[2]) {
up->bbox[2] = x;
}
if (y > up->bbox[3]) {
up->bbox[3] = y;
}
return;
}

View file

@ -1,66 +1,82 @@
#ifndef XYView_h
#define XYView_h
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
#include "mathlib.h"
#include "QF/mathlib.h"
#include "SetBrush.h" #include "SetBrush.h"
extern id xyview_i; #include "render.h"
#define MINSCALE 0.125 extern id xyview_i;
#define MAXSCALE 2.0
#define MINSCALE 0.125
#define MAXSCALE 2.0
extern vec3_t xy_viewnormal; // v_forward for xy view extern vec3_t xy_viewnormal; // v_forward for xy view
extern float xy_viewdist; // clip behind this plane extern float xy_viewdist; // clip behind this plane
extern NSRect xy_draw_rect; extern NSRect xy_draw_rect;
void linestart (float r, float g, float b); void linestart (float r, float g, float b);
void lineflush (void); void lineflush (void);
void linecolor (float r, float g, float b); void linecolor (float r, float g, float b);
void XYmoveto (vec3_t pt); void XYmoveto (vec3_t pt);
void XYlineto (vec3_t pt); void XYlineto (vec3_t pt);
typedef enum {dr_wire, dr_flat, dr_texture} drawmode_t; @interface XYView: NSView
@interface XYView : NSView
{ {
NSRect realbounds, newrect, combinedrect; NSRect realbounds, newrect, combinedrect;
NSPoint midpoint; NSPoint midpoint;
int gridsize; int gridsize;
float scale; float scale;
//
// for textured view // for textured view
int xywidth, xyheight; //
float *xyzbuffer; int xywidth, xyheight;
unsigned *xypicbuffer; float *xyzbuffer;
unsigned *xypicbuffer;
drawmode_t drawmode; drawmode_t drawmode;
//
// UI links // UI links
id mode_radio_i; //
id mode_radio_i;
} }
- (float)currentScale; - (float) currentScale;
- setModeRadio: m; - (id) setModeRadio: m;
- drawMode: sender; - (id) drawMode: sender;
- setDrawMode: (drawmode_t)mode; - (id) setDrawMode: (drawmode_t)mode;
- newSuperBounds; - (id) newSuperBounds;
- newRealBounds: (NSRect *)nb; - (id) newRealBounds: (NSRect)nb;
- addToScrollRange: (float)x :(float)y; - (id) addToScrollRange: (float)x
- setOrigin: (NSPoint *)pt scale: (float)sc; : (float)y;
- centerOn: (vec3_t)org;
- drawMode: sender; - (id) setOrigin: (NSPoint)pt scale: (float)sc;
- superviewChanged; - (id) centerOn: (vec3_t)org;
- (int)gridsize; - (id) drawMode: sender;
- (float)snapToGrid: (float)f;
- (id) superviewChanged;
- (int) gridsize;
- (float) snapToGrid: (float)f;
@end @end
@interface NSView (XYView)
- (void) setFrame: (NSRect)frame
bounds: (NSRect)bounds
scale: (NSSize)scale;
@end
#endif // XYView_h

File diff suppressed because it is too large Load diff

View file

@ -1,11 +1,17 @@
#ifndef ZScrollView_h
#define ZScrollView_h
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
@interface ZScrollView : NSScrollView @interface ZScrollView: NSScrollView
{ {
id button1; id button1;
} }
- initFrame:(NSRect)frameRect button1: b1; - (id) initWithFrame: (NSRect)frameRect
- tile; button1: b1;
- (id) tile;
@end @end
#endif // ZScrollView_h

View file

@ -1,7 +1,6 @@
#include "qedefs.h" #include "ZScrollView.h"
@implementation ZScrollView @implementation ZScrollView
/* /*
==================== ====================
initWithFrame: button: initWithFrame: button:
@ -9,23 +8,27 @@ initWithFrame: button:
Initizes a scroll view with a button at it's lower right corner Initizes a scroll view with a button at it's lower right corner
==================== ====================
*/ */
- (id) initWithFrame: (NSRect)frameRect
- initWithFrame:(const NSRect *)frameRect button1:b1 button1: b1
{ {
[super initWithFrame: frameRect]; [super initWithFrame: frameRect];
[self addSubview: b1]; [self addSubview: b1];
button1 = b1; button1 = b1;
[self setHorizScrollerRequired: YES]; [self setHasHorizontalScroller: YES];
[self setVertScrollerRequired: YES]; [self setHasVerticalScroller: YES];
[self setBorderType: NSBezelBorder];
[self setBorderType: NS_BEZEL];
return self; return self;
} }
- (BOOL) isOpaque
{
return YES;
}
/* /*
================ ================
@ -34,38 +37,36 @@ tile
Adjust the size for the pop up scale menu Adjust the size for the pop up scale menu
================= =================
*/ */
- (id) tile
- tile
{ {
NSRect scrollerframe; NSRect scrollerframe;
[super tile]; [super tile];
[_horizScroller getFrame: &scrollerframe]; scrollerframe = [_horizScroller frame];
[button1 setFrame: &scrollerframe]; [button1 setFrame: scrollerframe];
scrollerframe.size.width = 0; scrollerframe.size.width = 0;
[_horizScroller setFrame: &scrollerframe]; [_horizScroller setFrame: scrollerframe];
[_horizScroller setHidden: YES];
return self; return self;
} }
- (BOOL) acceptsFirstResponder
-(BOOL) acceptsFirstResponder
{ {
return YES; return YES;
} }
- superviewSizeChanged:(const NSSize *)oldSize #if 0
- (id) superviewSizeChanged: (const NSSize *)oldSize
{ {
[super superviewSizeChanged: oldSize]; [super superviewSizeChanged: oldSize];
[[self docView] newSuperBounds]; [[self documentView] newSuperBounds];
return self; return self;
} }
#endif
@end @end

View file

@ -1,42 +1,50 @@
#ifndef ZView_h
#define ZView_h
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
#include "mathlib.h"
extern id zview_i; #include "QF/mathlib.h"
#include "render.h"
extern id zview_i;
// zplane controls the objects displayed in the xyview // zplane controls the objects displayed in the xyview
extern float zplane; extern float zplane;
extern float zplanedir; extern float zplanedir;
@interface ZView : NSView @interface ZView: NSView
{ {
float minheight, maxheight; float minheight, maxheight;
float oldminheight, oldmaxheight; float oldminheight, oldmaxheight;
float topbound, bottombound; // for floor clipping float topbound, bottombound; // for floor clipping
float scale; float scale;
vec3_t origin; vec3_t origin;
NSBezierPath *checker;
} }
- clearBounds; - (id) clearBounds;
- getBounds: (float *)top :(float *)bottom; - (id) getBounds: (float *)top
: (float *)bottom;
- getPoint: (NSPoint *)pt; - (id) getPoint: (NSPoint *)pt;
- setPoint: (NSPoint *)pt; - (id) setPoint: (NSPoint *)pt;
- addToHeightRange: (float)height; - (id) addToHeightRange: (float)height;
- newRealBounds; - (id) newRealBounds;
- newSuperBounds; - (id) newSuperBounds;
- XYDrawSelf; - (void) XYDrawSelf;
- (BOOL)XYmouseDown: (NSPoint *)pt; - (BOOL) XYmouseDown: (NSPoint *)pt;
- setXYOrigin: (NSPoint *)pt; - (id) setXYOrigin: (NSPoint *)pt;
- setOrigin: (NSPoint *)pt scale: (float)sc; - (id) setOrigin: (NSPoint)pt scale: (float)sc;
@end @end
#endif // ZView_h

File diff suppressed because it is too large Load diff

View file

@ -1,611 +0,0 @@
// cmdlib.c
#include "cmdlib.h"
#define PATHSEPERATOR '/'
/*
================
I_FloatTime
================
*/
double I_FloatTime (void)
{
struct timeval tp;
struct timezone tzp;
static int secbase;
gettimeofday(&tp, &tzp);
if (!secbase)
{
secbase = tp.tv_sec;
return tp.tv_usec/1000000.0;
}
return (tp.tv_sec - secbase) + tp.tv_usec/1000000.0;
}
char com_token[1024];
boolean com_eof;
/*
==============
COM_Parse
Parse a token out of a string
==============
*/
char *COM_Parse (char *data)
{
int c;
int len;
com_eof = false;
len = 0;
com_token[0] = 0;
if (!data)
return NULL;
// skip whitespace
skipwhite:
while ( (c = *data) <= ' ')
{
if (c == 0)
{
com_eof = true;
return NULL; // end of file;
}
data++;
}
// skip // comments
if (c=='/' && data[1] == '/')
{
while (*data && *data != '\n')
data++;
goto skipwhite;
}
// handle quoted strings specially
if (c == '\"')
{
data++;
do
{
c = *data++;
if (c=='\"')
{
com_token[len] = 0;
return data;
}
com_token[len] = c;
len++;
} while (1);
}
// parse single characters
if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c==':')
{
com_token[len] = c;
len++;
com_token[len] = 0;
return data+1;
}
// parse a regular word
do
{
com_token[len] = c;
data++;
len++;
c = *data;
if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c==':')
break;
} while (c>32);
com_token[len] = 0;
return data;
}
/*
================
=
= filelength
=
================
*/
int filelength (int handle)
{
struct stat fileinfo;
if (fstat (handle,&fileinfo) == -1)
{
fprintf (stderr,"Error fstating");
exit (1);
}
return fileinfo.st_size;
}
int tell (int handle)
{
return lseek (handle, 0, L_INCR);
}
char *strupr (char *start)
{
char *in;
in = start;
while (*in)
{
*in = toupper(*in);
in++;
}
return start;
}
char *strlower (char *start)
{
char *in;
in = start;
while (*in)
{
*in = tolower(*in);
in++;
}
return start;
}
char *getcwd (char *path, int length)
{
return getwd(path);
}
/* globals for command line args */
extern int NXArgc;
extern char **NXArgv;
#define myargc NXArgc
#define myargv NXArgv
/*
=============================================================================
MISC FUNCTIONS
=============================================================================
*/
/*
=================
=
= CheckParm
=
= Checks for the given parameter in the program's command line arguments
=
= Returns the argument number (1 to argc-1) or 0 if not present
=
=================
*/
int CheckParm (char *check)
{
int i;
for (i = 1;i<myargc;i++)
{
if ( !stricmp(check, myargv[i]) )
return i;
}
return 0;
}
int SafeOpenWrite (char *filename)
{
int handle;
umask (0);
handle = open(filename,O_RDWR | O_CREAT | O_TRUNC
, 0666);
if (handle == -1)
Error ("Error opening %s: %s",filename,strerror(errno));
return handle;
}
int SafeOpenRead (char *filename)
{
int handle;
handle = open(filename,O_RDONLY);
if (handle == -1)
Error ("Error opening %s: %s",filename,strerror(errno));
return handle;
}
void SafeRead (int handle, void *buffer, long count)
{
int iocount;
iocount = read (handle,buffer,count);
if (iocount != count)
Error ("File read failure");
}
void SafeWrite (int handle, void *buffer, long count)
{
int iocount;
iocount = write (handle,buffer,count);
if (iocount != count)
Error ("File write failure");
}
void *SafeMalloc (long size)
{
void *ptr;
ptr = malloc (size);
if (!ptr)
Error ("Malloc failure for %lu bytes",size);
return ptr;
}
/*
==============
=
= LoadFile
=
= appends a 0 byte
==============
*/
long LoadFile (char *filename, void **bufferptr)
{
int handle;
long length;
void *buffer;
handle = SafeOpenRead (filename);
length = filelength (handle);
buffer = SafeMalloc (length+1);
((char *)buffer)[length] = 0;
SafeRead (handle, buffer, length);
close (handle);
*bufferptr = buffer;
return length;
}
/*
==============
=
= SaveFile
=
==============
*/
void SaveFile (char *filename, void *buffer, long count)
{
int handle;
handle = SafeOpenWrite (filename);
SafeWrite (handle, buffer, count);
close (handle);
}
void DefaultExtension (char *path, char *extension)
{
char *src;
//
// if path doesn't have a .EXT, append extension
// (extension should include the .)
//
src = path + strlen(path) - 1;
while (*src != PATHSEPERATOR && src != path)
{
if (*src == '.')
return; // it has an extension
src--;
}
strcat (path, extension);
}
void DefaultPath (char *path, char *basepath)
{
char temp[128];
if (path[0] == PATHSEPERATOR)
return; // absolute path location
strcpy (temp,path);
strcpy (path,basepath);
strcat (path,temp);
}
void StripFilename (char *path)
{
int length;
length = strlen(path)-1;
while (length > 0 && path[length] != PATHSEPERATOR)
length--;
path[length] = 0;
}
void StripExtension (char *path)
{
int length;
length = strlen(path)-1;
while (length > 0 && path[length] != '.')
length--;
if (length)
path[length] = 0;
}
/*
====================
=
= Extract file parts
=
====================
*/
void ExtractFilePath (char *path, char *dest)
{
char *src;
src = path + strlen(path) - 1;
//
// back up until a \ or the start
//
while (src != path && *(src-1) != PATHSEPERATOR)
src--;
memcpy (dest, path, src-path);
dest[src-path] = 0;
}
void ExtractFileBase (char *path, char *dest)
{
char *src;
src = path + strlen(path) - 1;
//
// back up until a \ or the start
//
while (src != path && *(src-1) != PATHSEPERATOR)
src--;
while (*src && *src != '.')
{
*dest++ = *src++;
}
*dest = 0;
}
void ExtractFileExtension (char *path, char *dest)
{
char *src;
src = path + strlen(path) - 1;
//
// back up until a . or the start
//
while (src != path && *(src-1) != '.')
src--;
if (src == path)
{
*dest = 0; // no extension
return;
}
strcpy (dest,src);
}
/*
==============
=
= ParseNum / ParseHex
=
==============
*/
long ParseHex (char *hex)
{
char *str;
long num;
num = 0;
str = hex;
while (*str)
{
num <<= 4;
if (*str >= '0' && *str <= '9')
num += *str-'0';
else if (*str >= 'a' && *str <= 'f')
num += 10 + *str-'a';
else if (*str >= 'A' && *str <= 'F')
num += 10 + *str-'A';
else
Error ("Bad hex number: %s",hex);
str++;
}
return num;
}
long ParseNum (char *str)
{
if (str[0] == '$')
return ParseHex (str+1);
if (str[0] == '0' && str[1] == 'x')
return ParseHex (str+2);
return atol (str);
}
int GetKey (void)
{
return getchar ();
}
/*
============================================================================
BYTE ORDER FUNCTIONS
============================================================================
*/
#ifdef __BIG_ENDIAN__
short LittleShort (short l)
{
byte b1,b2;
b1 = l&255;
b2 = (l>>8)&255;
return (b1<<8) + b2;
}
short BigShort (short l)
{
return l;
}
long LittleLong (long l)
{
byte b1,b2,b3,b4;
b1 = l&255;
b2 = (l>>8)&255;
b3 = (l>>16)&255;
b4 = (l>>24)&255;
return ((long)b1<<24) + ((long)b2<<16) + ((long)b3<<8) + b4;
}
long BigLong (long l)
{
return l;
}
float LittleFloat (float l)
{
union {byte b[4]; float f;} in, out;
in.f = l;
out.b[0] = in.b[3];
out.b[1] = in.b[2];
out.b[2] = in.b[1];
out.b[3] = in.b[0];
return out.f;
}
float BigFloat (float l)
{
return l;
}
#else
short BigShort (short l)
{
byte b1,b2;
b1 = l&255;
b2 = (l>>8)&255;
return (b1<<8) + b2;
}
short LittleShort (short l)
{
return l;
}
long BigLong (long l)
{
byte b1,b2,b3,b4;
b1 = l&255;
b2 = (l>>8)&255;
b3 = (l>>16)&255;
b4 = (l>>24)&255;
return ((long)b1<<24) + ((long)b2<<16) + ((long)b3<<8) + b4;
}
long LittleLong (long l)
{
return l;
}
float BigFloat (float l)
{
union {byte b[4]; float f;} in, out;
in.f = l;
out.b[0] = in.b[3];
out.b[1] = in.b[2];
out.b[2] = in.b[1];
out.b[3] = in.b[0];
return out.f;
}
float LittleFloat (float l)
{
return l;
}
#endif

View file

@ -1,62 +0,0 @@
// cmdlib.h
#ifndef __CMDLIB__
#define __CMDLIB__
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
#define strcmpi strcasecmp
#define stricmp strcasecmp
char *strupr (char *in);
char *strlower (char *in);
int filelength (int handle);
int tell (int handle);
#ifndef __BYTEBOOL__
#define __BYTEBOOL__
typedef enum {false, true} boolean;
typedef unsigned char byte;
#endif
double I_FloatTime (void);
int GetKey (void);
void Error (char *error, ...);
int CheckParm (char *check);
int SafeOpenWrite (char *filename);
int SafeOpenRead (char *filename);
void SafeRead (int handle, void *buffer, long count);
void SafeWrite (int handle, void *buffer, long count);
void *SafeMalloc (long size);
long LoadFile (char *filename, void **bufferptr);
void SaveFile (char *filename, void *buffer, long count);
void DefaultExtension (char *path, char *extension);
void DefaultPath (char *path, char *basepath);
void StripFilename (char *path);
void StripExtension (char *path);
void ExtractFilePath (char *path, char *dest);
void ExtractFileBase (char *path, char *dest);
void ExtractFileExtension (char *path, char *dest);
long ParseNum (char *str);
short BigShort (short l);
short LittleShort (short l);
long BigLong (long l);
long LittleLong (long l);
float BigFloat (float l);
float LittleFloat (float l);
extern char com_token[1024];
extern boolean com_eof;
char *COM_Parse (char *data);
#endif

View file

@ -1,93 +0,0 @@
// mathlib.c -- math primitives
#include "mathlib.h"
#include <math.h>
vec3_t vec3_origin = {0,0,0};
double VectorLength(vec3_t v)
{
int i;
double length;
length = 0;
for (i=0 ; i< 3 ; i++)
length += v[i]*v[i];
length = sqrt (length); // FIXME
return length;
}
void VectorMA (vec3_t va, double scale, vec3_t vb, vec3_t vc)
{
vc[0] = va[0] + scale*vb[0];
vc[1] = va[1] + scale*vb[1];
vc[2] = va[2] + scale*vb[2];
}
boolean VectorCompare (vec3_t v1, vec3_t v2)
{
int i;
for (i=0 ; i<3 ; i++)
if (v1[i] != v2[i])
return false;
return true;
}
void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross)
{
cross[0] = v1[1]*v2[2] - v1[2]*v2[1];
cross[1] = v1[2]*v2[0] - v1[0]*v2[2];
cross[2] = v1[0]*v2[1] - v1[1]*v2[0];
}
vec_t _DotProduct (vec3_t v1, vec3_t v2)
{
return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
}
void _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out)
{
out[0] = va[0]-vb[0];
out[1] = va[1]-vb[1];
out[2] = va[2]-vb[2];
}
void _VectorAdd (vec3_t va, vec3_t vb, vec3_t out)
{
out[0] = va[0]+vb[0];
out[1] = va[1]+vb[1];
out[2] = va[2]+vb[2];
}
void _VectorCopy (vec3_t in, vec3_t out)
{
out[0] = in[0];
out[1] = in[1];
out[2] = in[2];
}
void VectorNormalize (vec3_t v)
{
int i;
float length;
length = 0;
for (i=0 ; i< 3 ; i++)
length += v[i]*v[i];
length = sqrt (length);
for (i=0 ; i< 3 ; i++)
v[i] /= length;
}
void VectorScale (vec3_t v, vec_t scale, vec3_t out)
{
out[0] = v[0] * scale;
out[1] = v[1] * scale;
out[2] = v[2] * scale;
}

View file

@ -1,31 +0,0 @@
#ifndef __MATHLIB__
#define __MATHLIB__
#include "cmdlib.h"
// mathlib.h
typedef float vec_t;
typedef vec_t vec3_t[3];
extern vec3_t vec3_origin;
boolean VectorCompare (vec3_t v1, vec3_t v2);
#define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])
#define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];}
#define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];}
#define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];}
vec_t _DotProduct (vec3_t v1, vec3_t v2);
void _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out);
void _VectorAdd (vec3_t va, vec3_t vb, vec3_t out);
void _VectorCopy (vec3_t in, vec3_t out);
void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross);
void VectorNormalize (vec3_t v);
void VectorScale (vec3_t v, vec_t scale, vec3_t out);
double VectorLength(vec3_t v);
void VectorMA (vec3_t va, double scale, vec3_t vb, vec3_t vc);
#endif

View file

@ -1,274 +0,0 @@
#include "qedefs.h"
char token[MAXTOKEN];
boolean unget;
char *script_p;
int scriptline;
void StartTokenParsing (char *data)
{
scriptline = 1;
script_p = data;
unget = false;
}
boolean GetToken (boolean crossline)
{
char *token_p;
if (unget) // is a token allready waiting?
return true;
//
// skip space
//
skipspace:
while (*script_p <= 32)
{
if (!*script_p)
{
if (!crossline)
Error ("Line %i is incomplete",scriptline);
return false;
}
if (*script_p++ == '\n')
{
if (!crossline)
Error ("Line %i is incomplete",scriptline);
scriptline++;
}
}
if (script_p[0] == '/' && script_p[1] == '/') // comment field
{
if (!crossline)
Error ("Line %i is incomplete\n",scriptline);
while (*script_p++ != '\n')
if (!*script_p)
{
if (!crossline)
Error ("Line %i is incomplete",scriptline);
return false;
}
goto skipspace;
}
//
// copy token
//
token_p = token;
if (*script_p == '"')
{
script_p++;
while ( *script_p != '"' )
{
if (!*script_p)
Error ("EOF inside quoted token");
*token_p++ = *script_p++;
if (token_p == &token[MAXTOKEN])
Error ("Token too large on line %i",scriptline);
}
script_p++;
}
else while ( *script_p > 32 )
{
*token_p++ = *script_p++;
if (token_p == &token[MAXTOKEN])
Error ("Token too large on line %i",scriptline);
}
*token_p = 0;
return true;
}
void UngetToken ()
{
unget = true;
}
void qprintf (char *fmt, ...) // prints text to cmd_out_i
{
va_list argptr;
static char string[1024];
va_start (argptr, fmt);
vsprintf (string, fmt,argptr);
va_end (argptr);
[g_cmd_out_i setStringValue: [NSString stringWithCString: string]];
//NSPing ();
return;
}
/*
=================
Error
For abnormal program terminations
=================
*/
BOOL in_error;
void Error (char *error, ...)
{
va_list argptr;
static char string[1024];
if (in_error)
[NSApp terminate: NULL];
in_error = YES;
va_start (argptr,error);
vsprintf (string,error,argptr);
va_end (argptr);
strcat (string, "\nmap saved to "FN_CRASHSAVE);
[map_i writeMapFile: FN_CRASHSAVE useRegion: NO];
NSRunAlertPanel (@"Error", [NSString stringWithCString: string],NULL,NULL,NULL);
[NSApp terminate: NULL];
}
void CleanupName (char *in, char *out)
{
int i;
for (i=0 ; i< 16 ; i++ )
{
if (!in[i])
break;
out[i] = toupper(in[i]);
}
for ( ; i< 16 ; i++ )
out[i] = 0;
}
void PrintRect (NSRect *r)
{
printf ("(%4.0f, %4.0f) + (%4.0f, %4.0f) = (%4.0f,%4.0f)\n"
,r->origin.x,r->origin.y,
r->size.width, r->size.height, r->origin.x+r->size.width,
r->origin.y+r->size.height);
}
/*
============
FileTime
returns -1 if not present
============
*/
int FileTime (char *path)
{
struct stat buf;
if (stat (path,&buf) == -1)
return -1;
return buf.st_mtime;
}
/*
============
CreatePath
============
*/
void CreatePath (char *path)
{
char *ofs;
for (ofs = path+1 ; *ofs ; ofs++)
{
if (*ofs == '/')
{ // create the directory
*ofs = 0;
mkdir (path,0777);
*ofs = '/';
}
}
}
int I_FileOpenRead (char *path, int *handle)
{
int h;
struct stat fileinfo;
h = open (path, O_RDONLY, 0666);
*handle = h;
if (h == -1)
return -1;
if (fstat (h,&fileinfo) == -1)
Error ("Error fstating %s", path);
return fileinfo.st_size;
}
int I_FileOpenWrite (char *path)
{
int handle;
umask (0);
handle = open(path,O_RDWR | O_CREAT | O_TRUNC
, 0666);
if (handle == -1)
Error ("Error opening %s: %s", path,strerror(errno));
return handle;
}
/*
============
Sys_UpdateFile
Copies a more recent net file to the local drive
============
*/
void Sys_UpdateFile (char *path, char *netpath)
{
int ltime, ntime;
int in, out, size;
char *buf;
ltime = FileTime (path);
ntime = FileTime (netpath);
if (ntime <= ltime)
return; // up to date
// copy the file
printf ("UpdateFile: copying %s to %s...\n", netpath, path);
size = I_FileOpenRead (netpath, &in);
buf = malloc (size);
if (read (in, buf, size) != size)
Error ("UpdateFile: couldn't read all of %s", netpath);
close (in);
CreatePath (path);
out = I_FileOpenWrite (path);
write (out, buf, size);
close (out);
}

View file

@ -1,57 +0,0 @@
#include <AppKit/AppKit.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/dir.h>
#include <math.h>
#include <unistd.h>
#include <sys/fcntl.h>
#include "UserPath.h"
#include "cmdlib.h"
#include "mathlib.h"
#include "EntityClass.h"
#include "Project.h"
#include "QuakeEd.h"
#include "Map.h"
#include "TexturePalette.h"
#include "SetBrush.h"
#include "render.h"
#include "Entity.h"
#include "XYView.h"
#include "CameraView.h"
#include "ZView.h"
#include "ZScrollView.h"
#include "Preferences.h"
#include "InspectorControl.h"
#include "PopScrollView.h"
#include "KeypairView.h"
#include "Things.h"
#include "TextureView.h"
#include "Clipper.h"
void PrintRect (NSRect *r);
int FileTime (char *path);
void Sys_UpdateFile (char *path, char *netpath);
void CleanupName (char *in, char *out);
extern BOOL in_error;
void Error (char *error, ...);
#define MAXTOKEN 128
extern char token[MAXTOKEN];
extern int scriptline;
void StartTokenParsing (char *data);
boolean GetToken (boolean crossline); // returns false at eof
void UngetToken ();
#define FN_CMDOUT "/tmp/QuakeEdCmd.txt"
#define FN_TEMPSAVE "/qcache/temp.map"
#define FN_AUTOSAVE "/qcache/AutoSaveMap.map"
#define FN_CRASHSAVE "/qcache/ErrorSaveMap.map"
#define FN_DEVLOG "/qcache/devlog"

View file

@ -1,13 +1,83 @@
{ {
{"basepath" "/raid/quake/id1"} "basepath" = "/raid/quake/id1";
{"maps" "jrbase1 jrbase2 jrbase4 jrwiz1 jrwiz2 jrdungn jrmed1 jrmed2 jrstart tim4 tim5 tim6 tim7 tim9 tboss amtest98 ammap2 amtest1 amdm3 amdem1 ammet2 amlev13 ammech3 schurch smotte sramp2 scath sally spit stemple"} "maps" = (
{"desc" "jrbase1 jrbase2 jrbase4 jrwiz1 jrwiz2 jrdungn jrmed1 jrmed2 jrstart tim4 tim5 tim6 tim7 tim9 tboss amtest98 ammap2 amtest1 amdm3 amdem1 ammet2 amlev13 ammech3 schurch smotte sramp2 scath sally spit stemple"} "jrbase1",
{"wads" "gfx/medieval.wad gfx/base.wad gfx/wizard.wad gfx/metal.wad gfx/tim.wad gfx/items.wad gfx/start.wad"} "jrbase2",
"jrbase4",
"jrwiz1",
"jrwiz2",
"jrdungn",
"jrmed1",
"jrmed2",
"jrstart",
"tim4",
"tim5",
"tim6",
"tim7",
"tim9",
"tboss",
"amtest98",
"ammap2",
"amtest1",
"amdm3",
"amdem1",
"ammet2",
"amlev13",
"ammech3",
"schurch",
"smotte",
"sramp2",
"scath",
"sally",
"spit",
"stemple"
);
"desc" = (
"jrbase1",
"jrbase2",
"jrbase4",
"jrwiz1",
"jrwiz2",
"jrdungn",
"jrmed1",
"jrmed2",
"jrstart",
"tim4",
"tim5",
"tim6",
"tim7",
"tim9",
"tboss",
"amtest98",
"ammap2",
"amtest1",
"amdm3",
"amdem1",
"ammet2",
"amlev13",
"ammech3",
"schurch",
"smotte",
"sramp2",
"scath",
"sally",
"spit",
"stemple"
);
"wads" = (
"gfx/medieval.wad",
"gfx/base.wad",
"gfx/wizard.wad",
"gfx/metal.wad",
"gfx/tim.wad",
"gfx/items.wad",
"gfx/start.wad"
);
{"bspfullvis" "rsh satan @/LocalApps/qbsp $1 $2 ; /LocalApps/light -extra $2 ; /LocalApps/vis $2@"} "bspfullvis" = "rsh satan \"/LocalApps/qbsp $1 $2 ; /LocalApps/light -extra $2 ; /LocalApps/vis $2\"";
{"bspfastvis" "rsh satan @/LocalApps/qbsp $1 $2 ; /LocalApps/light $2 ; /LocalApps/vis -fast $2@"} "bspfastvis" = "rsh satan \"/LocalApps/qbsp $1 $2 ; /LocalApps/light $2 ; /LocalApps/vis -fast $2\"";
{"bspnovis" "rsh satan @/LocalApps/qbsp $1 $2 ; /LocalApps/light $2@"} "bspnovis" = "rsh satan \"/LocalApps/qbsp $1 $2 ; /LocalApps/light $2\"";
{"bsprelight" "rsh satan @/LocalApps/qbsp -onlyents $1 $2 ; /LocalApps/light -extra $2@"} "bsprelight" = "rsh satan \"/LocalApps/qbsp -onlyents $1 $2 ; /LocalApps/light -extra $2\"";
{"bspleaktest" "rsh satan @/LocalApps/qbsp -mark -notjunc $1 $2 ; /LocalApps/light $2@"} "bspleaktest" = "rsh satan \"/LocalApps/qbsp -mark -notjunc $1 $2 ; /LocalApps/light $2\"";
{"bspentities" "rsh satan @/LocalApps/qbsp -onlyents $1 $2@"} "bspentities" = "rsh satan \"/LocalApps/qbsp -onlyents $1 $2\"";
} }

View file

@ -1,13 +1,21 @@
#ifndef render_h
#define render_h
extern int r_width, r_height; #include "SetBrush.h"
extern unsigned *r_picbuffer;
extern float *r_zbuffer;
extern vec3_t r_origin, r_matrix[3]; typedef enum {dr_wire, dr_flat, dr_texture} drawmode_t;
extern BOOL r_drawflat;
extern int r_width, r_height;
extern unsigned *r_picbuffer;
extern float *r_zbuffer;
extern vec3_t r_origin, r_matrix[3];
extern BOOL r_drawflat;
void REN_ClearBuffers (void); void REN_ClearBuffers (void);
void REN_DrawCameraFace (face_t *idpol); void REN_DrawCameraFace (face_t * idpol);
void REN_DrawXYFace (face_t *idpol); void REN_DrawXYFace (face_t * idpol);
void REN_BeginCamera (void); void REN_BeginCamera (void);
void REN_BeginXY (void); void REN_BeginXY (void);
#endif // render_h

File diff suppressed because it is too large Load diff

View file

@ -204,7 +204,7 @@ static const char rcsid[] =
return; return;
} }
[[(id <ForgeBundle>) [aBundle principalClass] alloc] initWithOwner: self]; [(id <ForgeBundle>) [[aBundle principalClass] alloc] initWithOwner: self];
} }
- (PrefsController *) prefsController; - (PrefsController *) prefsController;

View file

@ -37,6 +37,7 @@ ADDITIONAL_WO_LIBS +=
# Additional directories to be created during installation # Additional directories to be created during installation
ADDITIONAL_INSTALL_DIRS += \ ADDITIONAL_INSTALL_DIRS += \
$(GNUSTEP_LOCAL_DIR)/Library/Forge \ $(GNUSTEP_USER_DIR)/$(GNUSTEP_USER_DIR_LIBRARY)/Forge \
$(GNUSTEP_NETWORK_DIR)/Library/Forge \ $(GNUSTEP_LOCAL_LIBRARY)/Forge \
$(GNUSTEP_SYSTEM_DIR)/Library/Forge $(GNUSTEP_NETWORK_LIBRARY)/Forge \
$(GNUSTEP_SYSTEM_LIBRARY)/Forge

View file

@ -191,7 +191,8 @@ ParseVerts (int *n_verts)
if (map_script->token->str[0] != ':') if (map_script->token->str[0] != ':')
map_error ("parsing brush"); map_error ("parsing brush");
*n_verts = atoi (map_script->token->str + 1); Script_GetToken (map_script, false);
*n_verts = atoi (map_script->token->str);
verts = malloc (sizeof (vec3_t) * *n_verts); verts = malloc (sizeof (vec3_t) * *n_verts);
for (i = 0; i < *n_verts; i++) { for (i = 0; i < *n_verts; i++) {

View file

@ -834,7 +834,8 @@ progs_src_compile (void)
else else
dsprintf (qc_filename, "%s", script->token->str); dsprintf (qc_filename, "%s", script->token->str);
if (options.verbosity >= 2) if (options.verbosity >= 2)
printf ("%s:%d: compiling %s\n", script->file, script->line, qc_filename->str); printf ("%s:%d: compiling %s\n", script->file, script->line,
qc_filename->str);
if (single) { if (single) {
fprintf (single, "$frame_reset\n"); fprintf (single, "$frame_reset\n");

View file

@ -186,8 +186,8 @@ LoadEntities (void)
// go through all the entities // go through all the entities
while (Script_GetToken (script, 1)) { while (Script_GetToken (script, 1)) {
// parse the opening brace // parse the opening brace
if (script->token->str[0] != '{') if (strcmp (script->token->str, "{"))
fprintf (stderr, "LoadEntities: found %s when expecting {", fprintf (stderr, "LoadEntities: found %s when expecting {\n",
script->token->str); script->token->str);
if (num_entities == max_entities) { if (num_entities == max_entities) {
@ -220,7 +220,7 @@ LoadEntities (void)
// FIXME shouldn't cross line // FIXME shouldn't cross line
if (!Script_GetToken (script, 1)) if (!Script_GetToken (script, 1))
fprintf (stderr, "LoadEntities: EOF without closing brace"); fprintf (stderr, "LoadEntities: EOF without closing brace");
if (script->token->str[0] == '}') if (!strcmp (script->token->str, "}"))
fprintf (stderr, "LoadEntities: closing brace without data"); fprintf (stderr, "LoadEntities: closing brace without data");
epair = calloc (1, sizeof (epair_t)); epair = calloc (1, sizeof (epair_t));
@ -248,8 +248,9 @@ LoadEntities (void)
} }
} }
if (entity->targetname) if (options.verbosity > 1 && entity->targetname)
printf ("%s %d %d\n", entity->targetname, entity->light, entity->style); printf ("%s %d %d\n", entity->targetname, entity->light,
entity->style);
// all fields have been parsed // all fields have been parsed
if (entity->classname && !strncmp (entity->classname, "light", 5)) { if (entity->classname && !strncmp (entity->classname, "light", 5)) {

View file

@ -73,8 +73,8 @@ SurfaceBBox (dface_t *s, vec3_t mins, vec3_t maxs)
int vi, e, i, j; int vi, e, i, j;
float *v; float *v;
mins[0] = mins[1] = 999999; mins[0] = mins[1] = mins[2] = 999999;
maxs[0] = maxs[1] = -99999; maxs[0] = maxs[1] = maxs[2] = -99999;
for (i = 0; i < s->numedges; i++) { for (i = 0; i < s->numedges; i++) {
e = bsp->surfedges[s->firstedge + i]; e = bsp->surfedges[s->firstedge + i];

View file

@ -305,7 +305,7 @@ wad_extract (wad_t *wad, lumpinfo_t *pf)
width = LittleLong (miptex->width); width = LittleLong (miptex->width);
height = LittleLong (miptex->height); height = LittleLong (miptex->height);
if (width > (unsigned) pf->size || height > (unsigned) pf->size if (width > (unsigned) pf->size || height > (unsigned) pf->size
|| (width * height * 3 / 2 || (width * height * 85 / 64
+ sizeof (miptex_t)) > (unsigned) pf->size) { + sizeof (miptex_t)) > (unsigned) pf->size) {
if (options.verbosity) if (options.verbosity)
fprintf (stderr, "bogus MIPTEX. treating as raw data\n"); fprintf (stderr, "bogus MIPTEX. treating as raw data\n");