tactical whitespace bomb

Add return-type information to all methods, split up lines properly where
I could find them, and ran the whole thing through uncrustify. Looks purty
now. :)
This commit is contained in:
Jeff Teunissen 2010-09-29 16:09:11 -04:00
parent 77e6624de3
commit fb785c334b
47 changed files with 3544 additions and 3602 deletions

View file

@ -9,68 +9,68 @@
#include "render.h" #include "render.h"
extern id cameraview_i; extern id cameraview_i;
extern byte renderlist[1024 * 1024 * 4]; extern byte renderlist[1024 * 1024 * 4];
void CameraMoveto (vec3_t p); void CameraMoveto (vec3_t p);
void CameraLineto (vec3_t p); void CameraLineto (vec3_t p);
extern BOOL timedrawing; extern BOOL timedrawing;
@interface CameraView:NSView @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;
NSBezierPath *xycamera_aim; NSBezierPath *xycamera_aim;
NSBezierPath *zcamera; 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) - (id) setOrigin: (vec3_t)org
org angle: (float)angle;
angle:(float)angle;
-getOrigin:(vec3_t)org; - (id) getOrigin: (vec3_t)org;
-(float) yawAngle; - (float) yawAngle;
-matrixFromAngles; - (id) matrixFromAngles;
-_keyDown:(NSEvent *)theEvent; - (id) _keyDown: (NSEvent *)theEvent;
-drawMode:sender; - (id) drawMode: sender;
-setDrawMode:(drawmode_t) mode; - (id) setDrawMode: (drawmode_t)mode;
-homeView:sender; - (id) homeView: sender;
- (void) XYDrawSelf; // for drawing viewpoint in XY view - (void) XYDrawSelf; // for drawing viewpoint in XY view
- (void) ZDrawSelf; // for drawing viewpoint in XY view - (void) ZDrawSelf; // for drawing viewpoint in XY view
-(BOOL) XYmouseDown:(NSPoint *)pt flags:(int)flags;// return YES if brush handled - (BOOL) XYmouseDown: (NSPoint *)pt // return YES if brush handled
flags: (int)flags;
-(BOOL) ZmouseDown:(NSPoint *)pt flags:(int)flags;// return YES if brush handled - (BOOL) ZmouseDown: (NSPoint *)pt // return YES if brush handled
flags: (int)flags;
-upFloor:sender; - (id) upFloor: sender;
-downFloor:sender; - (id) downFloor: sender;
@end @end
#endif // CameraView_h #endif // CameraView_h

View file

@ -1,15 +1,16 @@
#include "QF/sys.h" #include "QF/sys.h"
#import <AppKit/NSEvent.h>
#include "CameraView.h" #include "CameraView.h"
#include "Map.h" #include "Map.h"
#include "QuakeEd.h" #include "QuakeEd.h"
#include "XYView.h" #include "XYView.h"
#include "ZView.h" #include "ZView.h"
id cameraview_i; id cameraview_i;
extern NSBezierPath *path; extern NSBezierPath *path;
BOOL timedrawing = 0; BOOL timedrawing = 0;
@implementation CameraView @implementation CameraView
/* /*
@ -17,9 +18,9 @@ BOOL timedrawing = 0;
initWithFrame: initWithFrame:
================== ==================
*/ */
- initWithFrame:(NSRect)frameRect - (id) initWithFrame: (NSRect)frameRect
{ {
int size; int size;
[super initWithFrame: frameRect]; [super initWithFrame: frameRect];
@ -42,9 +43,9 @@ initWithFrame:
return self; return self;
} }
-(void)awakeFromNib - (void) awakeFromNib
{ {
NSBezierPath *path; NSBezierPath *path;
path = zcamera = [NSBezierPath new]; path = zcamera = [NSBezierPath new];
[path setLineWidth: 0.3]; [path setLineWidth: 0.3];
@ -77,20 +78,21 @@ initWithFrame:
[path relativeLineToPoint: NSMakePoint (45, -45)]; [path relativeLineToPoint: NSMakePoint (45, -45)];
} }
-setXYOrigin:(NSPoint *)pt - (id) setXYOrigin: (NSPoint *)pt
{ {
origin[0] = pt->x; origin[0] = pt->x;
origin[1] = pt->y; origin[1] = pt->y;
return self; return self;
} }
-setZOrigin:(float)pt - (id) setZOrigin: (float)pt
{ {
origin[2] = pt; origin[2] = pt;
return self; return self;
} }
-setOrigin:(vec3_t)org angle:(float)angle - (id) setOrigin: (vec3_t)org
angle: (float)angle
{ {
VectorCopy (org, origin); VectorCopy (org, origin);
ya = angle; ya = angle;
@ -98,18 +100,18 @@ initWithFrame:
return self; return self;
} }
-getOrigin:(vec3_t)org - (id) getOrigin: (vec3_t)org
{ {
VectorCopy (origin, org); VectorCopy (origin, org);
return self; return self;
} }
-(float)yawAngle - (float) yawAngle
{ {
return ya; return ya;
} }
-upFloor:sender - (id) upFloor: sender
{ {
sb_floor_dir = 1; sb_floor_dir = 1;
sb_floor_dist = 99999; sb_floor_dist = 99999;
@ -124,7 +126,7 @@ initWithFrame:
return self; return self;
} }
-downFloor:sender - (id) downFloor: sender
{ {
sb_floor_dir = -1; sb_floor_dir = -1;
sb_floor_dist = -99999; sb_floor_dist = -99999;
@ -152,7 +154,7 @@ UI TARGETS
homeView homeView
============ ============
*/ */
-homeView:sender - (id) homeView: sender
{ {
xa = za = 0; xa = za = 0;
@ -165,14 +167,14 @@ homeView
return self; return self;
} }
-drawMode:sender - (id) drawMode: sender
{ {
drawmode =[sender selectedColumn]; drawmode = [sender selectedColumn];
[quakeed_i updateCamera]; [quakeed_i updateCamera];
return self; return self;
} }
-setDrawMode:(drawmode_t)mode - (id) setDrawMode: (drawmode_t)mode
{ {
drawmode = mode; drawmode = mode;
[mode_radio_i selectCellAtRow: 0 column: mode]; [mode_radio_i selectCellAtRow: 0 column: mode];
@ -188,39 +190,40 @@ TRANSFORMATION METHODS
=============================================================================== ===============================================================================
*/ */
-matrixFromAngles - (id) matrixFromAngles
{ {
if (xa > M_PI * 0.4) if (xa > M_PI * 0.4)
xa = M_PI * 0.4; xa = M_PI * 0.4;
if (xa < -M_PI * 0.4) if (xa < -M_PI * 0.4)
xa = -M_PI * 0.4; xa = -M_PI * 0.4;
// vpn // vpn
matrix[2][0] = cos (xa) * cos (ya); matrix[2][0] = cos (xa) * cos (ya);
matrix[2][1] = cos (xa) * sin (ya); matrix[2][1] = cos (xa) * sin (ya);
matrix[2][2] = sin (xa); matrix[2][2] = sin (xa);
// vup // vup
matrix[1][0] = cos (xa + M_PI / 2) * cos (ya); matrix[1][0] = cos (xa + M_PI / 2) * cos (ya);
matrix[1][1] = cos (xa + M_PI / 2) * sin (ya); matrix[1][1] = cos (xa + M_PI / 2) * sin (ya);
matrix[1][2] = sin (xa + M_PI / 2); matrix[1][2] = sin (xa + M_PI / 2);
// vright // vright
CrossProduct (matrix[2], matrix[1], matrix[0]); CrossProduct (matrix[2], matrix[1], matrix[0]);
return self; return self;
} }
- (id) inverseTransform: (vec_t *)invec
-inverseTransform:(vec_t *)invec to:(vec_t *)outvec to: (vec_t *)outvec
{ {
vec3_t inverse[3]; vec3_t inverse[3];
vec3_t temp; vec3_t temp;
int i, j; int i, j;
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
inverse[i][j] = matrix[j][i]; inverse[i][j] = matrix[j][i];
}
temp[0] = DotProduct (invec, inverse[0]); temp[0] = DotProduct (invec, inverse[0]);
temp[1] = DotProduct (invec, inverse[1]); temp[1] = DotProduct (invec, inverse[1]);
@ -231,44 +234,42 @@ TRANSFORMATION METHODS
return self; return self;
} }
/* /*
=============================================================================== ===============================================================================
DRAWING METHODS DRAWING METHODS
=============================================================================== ===============================================================================
*/ */
typedef struct { typedef struct {
vec3_t trans; vec3_t trans;
int clipflags; int clipflags;
vec3_t screen; // valid only if clipflags == 0 vec3_t screen; // valid only if clipflags == 0
} campt_t; } campt_t;
#define CLIP_RIGHT 1 #define CLIP_RIGHT 1
#define CLIP_LEFT 2 #define CLIP_LEFT 2
#define CLIP_TOP 4 #define CLIP_TOP 4
#define CLIP_BOTTOM 8 #define CLIP_BOTTOM 8
#define CLIP_FRONT 16 #define CLIP_FRONT 16
int cam_cur; int cam_cur;
campt_t campts[2]; campt_t campts[2];
vec3_t r_matrix[3]; vec3_t r_matrix[3];
vec3_t r_origin; vec3_t r_origin;
float mid_x, mid_y; float mid_x, mid_y;
float topscale = (240.0 / 3) / 160; float topscale = (240.0 / 3) / 160;
float bottomscale = (240.0 * 2 / 3) / 160; float bottomscale = (240.0 * 2 / 3) / 160;
extern plane_t rfrustum[5]; extern plane_t rfrustum[5];
void void
MakeCampt (vec3_t in, campt_t * pt) MakeCampt (vec3_t in, campt_t * pt)
{ {
vec3_t temp; vec3_t temp;
float scale; float scale;
// transform the points // transform the points
VectorSubtract (in, r_origin, temp); VectorSubtract (in, r_origin, temp);
@ -277,7 +278,7 @@ MakeCampt (vec3_t in, campt_t * pt)
pt->trans[1] = DotProduct (temp, r_matrix[1]); pt->trans[1] = DotProduct (temp, r_matrix[1]);
pt->trans[2] = DotProduct (temp, r_matrix[2]); pt->trans[2] = DotProduct (temp, r_matrix[2]);
// check clip flags // check clip flags
if (pt->trans[2] < 1) if (pt->trans[2] < 1)
pt->clipflags = CLIP_FRONT; pt->clipflags = CLIP_FRONT;
else else
@ -296,17 +297,16 @@ MakeCampt (vec3_t in, campt_t * pt)
if (pt->clipflags) if (pt->clipflags)
return; return;
// project // project
scale = mid_x / pt->trans[2]; scale = mid_x / pt->trans[2];
pt->screen[0] = mid_x + pt->trans[0] * scale; pt->screen[0] = mid_x + pt->trans[0] * scale;
pt->screen[1] = mid_y + pt->trans[1] * scale; pt->screen[1] = mid_y + pt->trans[1] * scale;
} }
void void
CameraMoveto (vec3_t p) CameraMoveto (vec3_t p)
{ {
campt_t *pt; campt_t *pt;
if ([path elementCount] > 2048) if ([path elementCount] > 2048)
lineflush (); lineflush ();
@ -314,9 +314,8 @@ CameraMoveto (vec3_t p)
pt = &campts[cam_cur]; pt = &campts[cam_cur];
cam_cur ^= 1; cam_cur ^= 1;
MakeCampt (p, pt); MakeCampt (p, pt);
if (!pt->clipflags) { if (!pt->clipflags) { // onscreen, so move there immediately
// onscreen, so move there immediately NSPoint point = {pt->screen[0], pt->screen[1]};
NSPoint point = { pt->screen[0], pt->screen[1] };
[path moveToPoint: point]; [path moveToPoint: point];
} }
} }
@ -326,12 +325,11 @@ ClipLine (vec3_t p1, vec3_t p2, int planenum)
{ {
float d, d2, frac; float d, d2, frac;
vec3_t new; vec3_t new;
plane_t *pl; plane_t *pl;
float scale; float scale;
NSPoint point; NSPoint point;
if (planenum == 5) { if (planenum == 5) { // draw it!
// draw it!
scale = mid_x / p1[2]; scale = mid_x / p1[2];
point.x = mid_x + p1[0] * scale; point.x = mid_x + p1[0] * scale;
point.y = mid_y + p1[1] * scale; point.y = mid_y + p1[1] * scale;
@ -348,11 +346,10 @@ ClipLine (vec3_t p1, vec3_t p2, int planenum)
d = DotProduct (p1, pl->normal) - pl->dist; d = DotProduct (p1, pl->normal) - pl->dist;
d2 = DotProduct (p2, pl->normal) - pl->dist; d2 = DotProduct (p2, pl->normal) - pl->dist;
if (d <= ON_EPSILON && d2 <= ON_EPSILON) { // off screen if (d <= ON_EPSILON && d2 <= ON_EPSILON) // off screen
return; return;
}
if (d >= 0 && d2 >= 0) { // on front if (d >= 0 && d2 >= 0) { // on front
ClipLine (p1, p2, planenum + 1); ClipLine (p1, p2, planenum + 1);
return; return;
} }
@ -368,12 +365,12 @@ ClipLine (vec3_t p1, vec3_t p2, int planenum)
ClipLine (new, p2, planenum + 1); ClipLine (new, p2, planenum + 1);
} }
int c_off, c_on, c_clip; int c_off, c_on, c_clip;
void void
CameraLineto (vec3_t p) CameraLineto (vec3_t p)
{ {
campt_t *p1, *p2; campt_t *p1, *p2;
int bits; int bits;
p2 = &campts[cam_cur]; p2 = &campts[cam_cur];
@ -381,36 +378,36 @@ CameraLineto (vec3_t p)
p1 = &campts[cam_cur]; p1 = &campts[cam_cur];
MakeCampt (p, p2); MakeCampt (p, p2);
if (p1->clipflags & p2->clipflags) { if (p1->clipflags & p2->clipflags) { // entirely off screen
c_off++; c_off++;
return; // entirely off screen return;
} }
bits = p1->clipflags | p2->clipflags; bits = p1->clipflags | p2->clipflags;
if (!bits) { // entirely on screen
NSPoint point1 = {p1->screen[0], p1->screen[1]};
NSPoint point2 = {p2->screen[0], p2->screen[1]};
if (!bits) {
NSPoint point1 = { p1->screen[0], p1->screen[1] };
NSPoint point2 = { p2->screen[0], p2->screen[1] };
c_on++; c_on++;
[path moveToPoint: point1]; [path moveToPoint: point1];
[path lineToPoint: point2]; [path lineToPoint: point2];
return; // entirely on screen return;
} }
// needs to be clipped
// needs to be clipped
c_clip++; c_clip++;
ClipLine (p1->trans, p2->trans, 0); ClipLine (p1->trans, p2->trans, 0);
} }
/* /*
============= =============
drawSolid drawSolid
============= =============
*/ */
-drawSolid - (id) drawSolid
{ {
unsigned char *planes[5]; unsigned char *planes[5];
// //
// draw it // draw it
@ -432,7 +429,7 @@ drawSolid
// //
// render the setbrushes // render the setbrushes
// //
[map_i makeAllPerform: @selector (CameraRenderSelf)]; [map_i makeAllPerform: @selector (CameraRenderSelf)];
// //
@ -442,25 +439,21 @@ drawSolid
planes[0] = (unsigned char *) imagebuffer; planes[0] = (unsigned char *) imagebuffer;
NSDrawBitmap (_bounds, r_width, r_height, 8, 3, 32, r_width * 4, NO, NO, NSDrawBitmap (_bounds, r_width, r_height, 8, 3, 32, r_width * 4, NO, NO,
NSCalibratedRGBColorSpace, NSCalibratedRGBColorSpace, (const unsigned char **) planes);
(const unsigned char **) planes);
[[self window] setBackingType: NSBackingStoreBuffered]; [[self window] setBackingType: NSBackingStoreBuffered];
return self; return self;
} }
/* /*
=================== ===================
drawWire drawWire
=================== ===================
*/ */
-drawWire:(NSRect)rect - (id) drawWire: (NSRect)rect
{ {
// copy current info to globals for the C callbacks // copy current info to globals for the C callbacks
mid_x = _bounds.size.width / 2; mid_x = _bounds.size.width / 2;
mid_y = 2 * _bounds.size.height / 3; mid_y = 2 * _bounds.size.height / 3;
@ -476,10 +469,10 @@ drawWire
REN_BeginCamera (); REN_BeginCamera ();
// erase window // erase window
NSEraseRect (rect); NSEraseRect (rect);
// draw all entities // draw all entities
linestart (0, 0, 0); linestart (0, 0, 0);
[map_i makeUnselectedPerform: @selector (CameraDrawSelf)]; [map_i makeUnselectedPerform: @selector (CameraDrawSelf)];
lineflush (); lineflush ();
@ -492,9 +485,9 @@ drawWire
drawSelf drawSelf
=================== ===================
*/ */
- (void) drawRect:(NSRect)rect - (void) drawRect: (NSRect)rect
{ {
float drawtime = 0; float drawtime = 0;
if (timedrawing) if (timedrawing)
drawtime = Sys_DoubleTime (); drawtime = Sys_DoubleTime ();
@ -513,7 +506,6 @@ drawSelf
} }
} }
/* /*
============= =============
XYDrawSelf XYDrawSelf
@ -521,8 +513,8 @@ XYDrawSelf
*/ */
- (void) XYDrawSelf - (void) XYDrawSelf
{ {
NSBezierPath *path; NSBezierPath *path;
NSAffineTransform *trans; NSAffineTransform *trans;
[[NSColor blueColor] set]; [[NSColor blueColor] set];
@ -549,8 +541,8 @@ ZDrawSelf
*/ */
- (void) ZDrawSelf - (void) ZDrawSelf
{ {
NSBezierPath *path; NSBezierPath *path;
NSAffineTransform *trans; NSAffineTransform *trans;
[[NSColor blueColor] set]; [[NSColor blueColor] set];
@ -563,11 +555,10 @@ ZDrawSelf
[path release]; [path release];
} }
/* /*
=============================================================================== ===============================================================================
XYZ mouse view methods XYZ mouse view methods
=============================================================================== ===============================================================================
*/ */
@ -577,10 +568,15 @@ ZDrawSelf
modalMoveLoop modalMoveLoop
================ ================
*/ */
-modalMoveLoop:(NSPoint *)basept :(vec3_t)movemod :converter - (id) modalMoveLoop: (NSPoint *)basept
: (vec3_t)movemod
: converter
{ {
vec3_t originbase; vec3_t originbase;
NSEvent *event = 0; NSEvent *event = 0;
unsigned eventMask = (NSLeftMouseUpMask | NSLeftMouseDraggedMask
| NSRightMouseUpMask | NSRightMouseDraggedMask
| NSApplicationDefinedMask);
NSPoint newpt; NSPoint newpt;
vec3_t delta; vec3_t delta;
int i; int i;
@ -592,74 +588,73 @@ modalMoveLoop
// modal event loop using instance drawing // modal event loop using instance drawing
goto drawentry; goto drawentry;
while ([event type] != NSLeftMouseUp &&[event type] != NSRightMouseUp) { while ([event type] != NSLeftMouseUp && [event type] != NSRightMouseUp) {
// calculate new point // calculate new point
newpt =[event locationInWindow]; newpt = [event locationInWindow];
newpt =[converter convertPoint: newpt fromView: NULL]; newpt = [converter convertPoint: newpt fromView: NULL];
delta[0] = newpt.x - basept->x; delta[0] = newpt.x - basept->x;
delta[1] = newpt.y - basept->y; delta[1] = newpt.y - basept->y;
delta[2] = delta[1]; // height change delta[2] = delta[1]; // height change
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
origin[i] = originbase[i] + movemod[i] * delta[i]; origin[i] = originbase[i] + movemod[i] * delta[i];
#if 0 // FIXME #if 0 // FIXME
// if command is down, look towards brush or entity // if command is down, look towards brush or entity
if (event->flags & NS_SHIFTMASK) { if (event->flags & NS_SHIFTMASK) {
NSPoint brushpt; NSPoint brushpt;
id ent; id ent;
vec3_t temp; vec3_t temp;
ent =[quakemap_i selectedEntity]; ent = [quakemap_i selectedEntity];
if (ent) { if (ent) {
[ent origin: temp]; [ent origin: temp];
brushpt.x = temp[0]; brushpt.x = temp[0];
brushpt.y = temp[1]; brushpt.y = temp[1];
} else } else {
brushpt =[brush_i centerPoint]; brushpt = [brush_i centerPoint];
ya = atan2 (brushpt.y - newpt.y, brushpt.x - newpt.x); } ya = atan2 (brushpt.y - newpt.y, brushpt.x - newpt.x);
[self matrixFromAngles]; [self matrixFromAngles];
} }
#endif #endif
drawentry: drawentry:
// instance draw new frame // instance draw new frame
[quakeed_i newinstance]; [quakeed_i newinstance];
[self display]; [self display];
event = [NSApp nextEventMatchingMask: NSLeftMouseUpMask event = [NSApp nextEventMatchingMask: eventMask
| NSLeftMouseDraggedMask | NSRightMouseUpMask untilDate: [NSDate distantFuture]
| NSRightMouseDraggedMask | NSApplicationDefinedMask inMode: NSEventTrackingRunLoopMode dequeue:
untilDate: [NSDate distantFuture] YES];
inMode: NSEventTrackingRunLoopMode dequeue: YES];
if ([event type] == NSKeyDown) { if ([event type] == NSKeyDown) {
[self _keyDown: event]; [self _keyDown: event];
[self display]; [self display];
goto drawentry; goto drawentry;
} }
} }
return self; return self;
} }
//============================================================================ // ============================================================================
/* /*
=============== ===============
XYmouseDown XYmouseDown
=============== ===============
*/ */
-(BOOL) XYmouseDown:(NSPoint *)pt flags:(int)flags - (BOOL) XYmouseDown: (NSPoint *)pt
flags: (int)flags
// return YES if brush handled // return YES if brush handled
{ {
vec3_t movemod; vec3_t movemod;
if (fabs (pt->x - origin[0]) > 16 || fabs (pt->y - origin[1]) > 16) if (fabs (pt->x - origin[0]) > 16 || fabs (pt->y - origin[1]) > 16)
return NO; return NO;
#if 0 #if 0
if (flags & NSAlternateKeyMask) { // up / down drag if (flags & NSAlternateKeyMask) { // up / down drag
movemod[0] = 0; movemod[0] = 0;
movemod[1] = 0; movemod[1] = 0;
movemod[2] = 1; movemod[2] = 1;
@ -671,21 +666,21 @@ XYmouseDown
movemod[2] = 0; movemod[2] = 0;
} }
[self modalMoveLoop: pt : movemod : xyview_i]; [self modalMoveLoop: pt: movemod: xyview_i];
return YES; return YES;
} }
/* /*
=============== ===============
ZmouseDown ZmouseDown
=============== ===============
*/ */
-(BOOL) ZmouseDown:(NSPoint *)pt flags:(int)flags - (BOOL) ZmouseDown: (NSPoint *)pt
flags: (int)flags
// return YES if brush handled // return YES if brush handled
{ {
vec3_t movemod; vec3_t movemod;
if (fabs (pt->y - origin[2]) > 16 || pt->x < -8 || pt->x > 8) if (fabs (pt->y - origin[2]) > 16 || pt->x < -8 || pt->x > 8)
return NO; return NO;
@ -694,23 +689,22 @@ ZmouseDown
movemod[1] = 0; movemod[1] = 0;
movemod[2] = 1; movemod[2] = 1;
[self modalMoveLoop: pt : movemod : zview_i]; [self modalMoveLoop: pt: movemod: zview_i];
return YES; return YES;
} }
// =============================================================================
//=============================================================================
/* /*
=================== ===================
viewDrag: viewDrag:
=================== ===================
*/ */
-viewDrag:(NSPoint *)pt - (id) viewDrag: (NSPoint *)pt
{ {
float dx, dy; float dx, dy;
NSEvent *event = 0; NSEvent *event = 0;
NSPoint newpt; NSPoint newpt;
// //
@ -719,11 +713,11 @@ viewDrag:
goto drawentry; goto drawentry;
while ([event type] != NSRightMouseUp) { while ([event type] != NSRightMouseUp) {
// //
// calculate new point // calculate new point
// //
newpt =[event locationInWindow]; newpt = [event locationInWindow];
newpt =[self convertPoint: newpt fromView: NULL]; newpt = [self convertPoint: newpt fromView: NULL];
dx = newpt.x - pt->x; dx = newpt.x - pt->x;
dy = newpt.y - pt->y; dy = newpt.y - pt->y;
@ -734,33 +728,32 @@ viewDrag:
[self matrixFromAngles]; [self matrixFromAngles];
drawentry: drawentry:
[quakeed_i newinstance]; [quakeed_i newinstance];
[self display]; [self display];
event = [NSApp nextEventMatchingMask: NSRightMouseUpMask event = [NSApp nextEventMatchingMask: NSRightMouseUpMask
| NSRightMouseDraggedMask | NSRightMouseDraggedMask
untilDate: [NSDate distantFuture] untilDate: [NSDate distantFuture]
inMode: NSEventTrackingRunLoopMode dequeue: YES]; inMode: NSEventTrackingRunLoopMode dequeue:
YES];
if ([event type] == NSKeyDown) { if ([event type] == NSKeyDown) {
[self _keyDown:event]; [self _keyDown: event];
[self display]; [self display];
goto drawentry; goto drawentry;
} }
} }
return self; return self;
} }
// =============================================================================
//=============================================================================
/* /*
=================== ===================
mouseDown mouseDown
=================== ===================
*/ */
-(void) mouseDown:(NSEvent *)theEvent - (void) mouseDown: (NSEvent *)theEvent
{ {
NSPoint pt; NSPoint pt;
int i; int i;
@ -768,23 +761,24 @@ mouseDown
float forward, right, up; float forward, right, up;
int flags; int flags;
pt =[theEvent locationInWindow]; pt = [theEvent locationInWindow];
pt =[self convertPoint: pt fromView: NULL]; pt = [self convertPoint: pt fromView: NULL];
VectorCopy (origin, p1); VectorCopy (origin, p1);
forward = 160; forward = 160;
right = pt.x - 160; right = pt.x - 160;
up = pt.y - 240 * 2 / 3; up = pt.y - 240 * 2 / 3;
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++) {
p2[i] = p2[i] =
forward * matrix[2][i] + up * matrix[1][i] + right * matrix[0][i]; forward * matrix[2][i] + up * matrix[1][i] + right * matrix[0][i];
}
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
p2[i] = p1[i] + 100 * p2[i]; p2[i] = p1[i] + 100 * p2[i];
flags = flags =
[theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask | [theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask |
NSAlternateKeyMask | NSCommandKeyMask); NSAlternateKeyMask | NSCommandKeyMask);
// //
// bare click to select a texture // bare click to select a texture
@ -835,7 +829,6 @@ mouseDown
return; return;
} }
Sys_Printf ("bad flags for click %x\n", flags); Sys_Printf ("bad flags for click %x\n", flags);
NopSound (); NopSound ();
@ -847,18 +840,18 @@ mouseDown
rightMouseDown rightMouseDown
=================== ===================
*/ */
-(void) rightMouseDown:(NSEvent *)theEvent - (void) rightMouseDown: (NSEvent *)theEvent
{ {
NSPoint pt; NSPoint pt;
int flags; int flags;
pt =[theEvent locationInWindow]; pt = [theEvent locationInWindow];
[self convertPoint: pt fromView: NULL]; [self convertPoint: pt fromView: NULL];
flags = flags = [theEvent modifierFlags]
[theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask | & (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask
NSAlternateKeyMask | NSCommandKeyMask); | NSCommandKeyMask);
// //
// click = drag camera // click = drag camera
@ -881,11 +874,10 @@ keyDown
=============== ===============
*/ */
- (id) _keyDown: (NSEvent *)theEvent
-_keyDown:(NSEvent *)theEvent
{ {
NSString *chars = [theEvent characters]; NSString *chars = [theEvent characters];
unichar c = [chars length] == 1 ? [chars characterAtIndex: 0] : '\0'; unichar c = ([chars length] == 1) ? [chars characterAtIndex: 0] : '\0';
switch (c) { switch (c) {
case 13: case 13:
@ -952,12 +944,9 @@ keyDown
origin[2] -= move; origin[2] -= move;
[quakeed_i updateCamera]; [quakeed_i updateCamera];
break; break;
} /* switch */
}
return self; return self;
} }
@end @end

View file

@ -7,22 +7,22 @@
#include "SetBrush.h" #include "SetBrush.h"
extern id clipper_i; extern id clipper_i;
@interface Clipper:NSObject @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;
- (void) flipNormal; - (void) flipNormal;
-(BOOL) getFace:(face_t *) pl; - (BOOL) getFace: (face_t *)pl;
- (void) cameraDrawSelf; - (void) cameraDrawSelf;
- (void) XYDrawSelf; - (void) XYDrawSelf;

View file

@ -7,21 +7,21 @@
#include "CameraView.h" #include "CameraView.h"
#include "QuakeEd.h" #include "QuakeEd.h"
id clipper_i; id clipper_i;
extern NSBezierPath *path; extern NSBezierPath *path;
@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;
@ -30,7 +30,7 @@ extern NSBezierPath *path;
- (void) flipNormal - (void) flipNormal
{ {
vec3_t temp; vec3_t temp;
if (num == 2) { if (num == 2) {
VectorCopy (pos[0], temp); VectorCopy (pos[0], temp);
@ -46,10 +46,10 @@ extern NSBezierPath *path;
} }
} }
-(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;
@ -72,7 +72,7 @@ extern NSBezierPath *path;
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;
} }
@ -82,28 +82,27 @@ extern NSBezierPath *path;
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
pos[i][2] =[map_i currentMinZ]; pos[i][2] = [map_i currentMinZ];
[quakeed_i updateAll]; [quakeed_i updateAll];
return self; return self;
} }
} }
if (num == 3) if (num == 3)
num = 0; num = 0;
@ -120,39 +119,36 @@ 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; continue; // drag this point
// drag this point
} }
return NO; return NO;
} }
-ZClick:(NSPoint) pt - (id) ZClick: (NSPoint)pt
{ {
return self; return self;
} }
//============================================================================= // =============================================================================
- (id) carve - (id) carve
{ {
[map_i makeSelectedPerform:@selector (carveByClipper)]; [map_i makeSelectedPerform: @selector (carveByClipper)];
num = 0; num = 0;
return self; return self;
} }
- (void) cameraDrawSelf - (void) cameraDrawSelf
{ {
vec3_t mid; vec3_t mid;
int i; int i;
linecolor (1, 0.5, 0); linecolor (1, 0.5, 0);
@ -177,8 +173,8 @@ XYDrag
- (void) XYDrawSelf - (void) XYDrawSelf
{ {
int i; int i;
NSMutableDictionary *attribs = [NSMutableDictionary dictionary]; NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
[[NSColor colorWithCalibratedRed: 1.0 green: 0.5 blue: 0.0 alpha: 1.0] [[NSColor colorWithCalibratedRed: 1.0 green: 0.5 blue: 0.0 alpha: 1.0]
set]; set];
@ -187,40 +183,38 @@ XYDrag
[path removeAllPoints]; [path removeAllPoints];
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
NSString *s = [NSString stringWithFormat: @"%i", i]; NSString *s = [NSString stringWithFormat: @"%i", i];
[s drawAtPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4) [s drawAtPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)
withAttributes: attribs]; withAttributes: attribs];
//[path moveToPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)]; // [path moveToPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)];
[path appendBezierPathWithArcWithCenter: NSMakePoint (pos[i][0], [path
pos[i][1]) appendBezierPathWithArcWithCenter: NSMakePoint (pos[i][0], pos[i][1])
radius: 10 radius: 10
startAngle: 0 startAngle: 0
endAngle: 360]; endAngle: 360];
} }
[path stroke]; [path stroke];
} }
- (void) ZDrawSelf - (void) ZDrawSelf
{ {
int i; int i;
NSMutableDictionary *attribs = [NSMutableDictionary dictionary]; NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
[[NSColor colorWithCalibratedRed: 1.0 green: 0.5 blue: 0.0 alpha: 1.0]
set];
[[NSColor colorWithCalibratedRed: 1. green: 0.5 blue: 0. alpha: 1.] set];
[[NSFont systemFontOfSize: 10 / [xyview_i currentScale]] set]; [[NSFont systemFontOfSize: 10 / [xyview_i currentScale]] set];
[path removeAllPoints]; [path removeAllPoints];
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
NSString *s = [NSString stringWithFormat: @"%i", i]; NSString *s = [NSString stringWithFormat: @"%i", i];
[s drawAtPoint: NSMakePoint (-28 + i * 8 - 4, pos[i][2] - 4) [s drawAtPoint: NSMakePoint (-28 + i * 8 - 4, pos[i][2] - 4)
withAttributes: attribs]; withAttributes: attribs];
//[path moveToPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)]; // [path moveToPoint: NSMakePoint (pos[i][0] - 4, pos[i][1] - 4)];
[path appendBezierPathWithArcWithCenter: NSMakePoint (-28 + i * 8, [path
pos[i][2]) appendBezierPathWithArcWithCenter: NSMakePoint (-28 + i * 8, pos[i][2])
radius: 10 radius: 10
startAngle: 0 startAngle: 0
endAngle: 360]; endAngle: 360];
} }
[path stroke]; [path stroke];
} }

View file

@ -5,39 +5,39 @@
#include "Storage.h" #include "Storage.h"
typedef struct { typedef struct {
char *key; char *key;
char *value; char *value;
} dict_t; } dict_t;
@interface Dict:Storage @interface Dict: Storage
{ {
} }
-initFromFile:(FILE *) fp; - (id) initFromFile: (FILE *)fp;
-(id) parseMultipleFrom:(const char *) value; - (id) parseMultipleFrom: (const char *)value;
-(int) getValueUnits:(const char *) key; - (int) getValueUnits: (const char *)key;
-delString:(const char *)string fromValue:(const char *) key; - (id) delString: (const char *)string fromValue: (const char *)key;
-addString:(const char *)string toValue:(const char *) key; - (id) addString: (const char *)string toValue: (const char *)key;
-(char *) convertListToString:(id) list; - (char *) convertListToString: (id)list;
- (const char *) getStringFor:(const char *) name; - (const char *) getStringFor: (const char *)name;
-removeKeyword:(const char *) key; - (id) removeKeyword: (const char *)key;
-(unsigned int) getValueFor:(const char *) name; - (unsigned int) getValueFor: (const char *)name;
-changeStringFor:(const char *)key to:(const char *) value; - (id) changeStringFor: (const char *)key to: (const char *)value;
-(dict_t *) findKeyword:(const char *) key; - (dict_t *) findKeyword: (const char *)key;
-writeBlockTo:(FILE *) fp; - (id) writeBlockTo: (FILE *)fp;
-writeFile:(const char *) path; - (id) writeFile: (const char *)path;
// INTERNAL // INTERNAL
-init; - (id) init;
-(id) parseBraceBlock:(FILE *) fp; - (id) parseBraceBlock: (FILE *)fp;
-setupMultiple:(const char *) value; - (id) setupMultiple: (const char *)value;
-(char *) getNextParameter; - (char *) getNextParameter;
@end @end

View file

@ -5,20 +5,20 @@
@implementation Dict @implementation Dict
-init - (id) init
{ {
[super initCount: 0 elementSize:sizeof (dict_t) [super initCount: 0 elementSize: sizeof (dict_t)
description:NULL]; description: NULL];
return self; return self;
} }
-print - (id) print
{ {
NSUInteger i; NSUInteger i;
dict_t *d; dict_t *d;
for (i = 0; i < numElements; i++) { 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;
@ -31,16 +31,16 @@ copyFromZone
JDC JDC
=========== ===========
*/ */
-copy - (id) copy
{ {
id new; id new;
NSUInteger i; NSUInteger i;
dict_t *d; dict_t *d;
char *old; char *old;
new =[super copy]; new = [super copy];
for (i = 0; i < numElements; i++) { for (i = 0; i < numElements; i++) {
d =[self elementAt:i]; d = [self elementAt: i];
old = d->key; old = d->key;
d->key = malloc (strlen (old) + 1); d->key = malloc (strlen (old) + 1);
strcpy (d->key, old); strcpy (d->key, old);
@ -53,31 +53,31 @@ JDC
return new; return new;
} }
-initFromFile:(FILE *) fp - (id) initFromFile: (FILE *)fp
{ {
[self init]; [self init];
return[self parseBraceBlock:fp]; return [self parseBraceBlock: fp];
} }
//=============================================== // ===============================================
// //
// Dictionary pair functions // Dictionary pair functions
// //
//=============================================== // ===============================================
// //
// Write a { } block out to a FILE* // Write a { } block out to a FILE*
// //
-writeBlockTo:(FILE *) fp - (id) writeBlockTo: (FILE *)fp
{ {
int max; int max;
int i; int i;
dict_t *d; dict_t *d;
fprintf (fp, "{\n"); fprintf (fp, "{\n");
max =[super count]; max = [super count];
for (i = 0; i < max; i++) { for (i = 0; i < max; i++) {
d =[super elementAt:i]; d = [super elementAt: i];
fprintf (fp, "\t{\"%s\"\t\"%s\"}\n", d->key, d->value); fprintf (fp, "\t{\"%s\"\t\"%s\"}\n", d->key, d->value);
} }
fprintf (fp, "}\n"); fprintf (fp, "}\n");
@ -88,15 +88,15 @@ JDC
// //
// Write a single { } block out // Write a single { } block out
// //
-writeFile:(const char *) path - (id) writeFile: (const char *)path
{ {
FILE *fp; FILE *fp;
fp = fopen (path, "w+t"); fp = fopen (path, "w+t");
if (fp != NULL) { if (fp != NULL) {
printf ("Writing dictionary file %s.\n", path); printf ("Writing dictionary file %s.\n", path);
fprintf (fp, "// QE_Project file %s\n", path); fprintf (fp, "// QE_Project file %s\n", path);
[self writeBlockTo:fp]; [self writeBlockTo: fp];
fclose (fp); fclose (fp);
} else { } else {
printf ("Error writing %s!\n", path); printf ("Error writing %s!\n", path);
@ -106,25 +106,25 @@ JDC
return self; return self;
} }
//=============================================== // ===============================================
// //
// Utility methods // Utility methods
// //
//=============================================== // ===============================================
// //
// Find a keyword in storage // Find a keyword in storage
// Returns * to dict_t, otherwise NULL // Returns * to dict_t, otherwise NULL
// //
-(dict_t *) findKeyword:(const char *) key - (dict_t *) findKeyword: (const char *)key
{ {
int max; int max;
int i; int i;
dict_t *d; dict_t *d;
max =[super count]; max = [super count];
for (i = 0; i < max; i++) { for (i = 0; i < max; i++) {
d =[super elementAt:i]; d = [super elementAt: i];
if (!strcmp (d->key, key)) if (!strcmp (d->key, key))
return d; return d;
} }
@ -135,12 +135,12 @@ JDC
// //
// Change a keyword's string // Change a keyword's string
// //
-changeStringFor:(const char *) key to:(const char *) value - (id) changeStringFor: (const char *)key to: (const char *)value
{ {
dict_t *d; dict_t *d;
dict_t newd; dict_t newd;
d =[self findKeyword:key]; d = [self findKeyword: key];
if (d != NULL) { if (d != NULL) {
free (d->value); free (d->value);
d->value = malloc (strlen (value) + 1); d->value = malloc (strlen (value) + 1);
@ -150,7 +150,7 @@ JDC
strcpy (newd.key, key); strcpy (newd.key, key);
newd.value = malloc (strlen (value) + 1); newd.value = malloc (strlen (value) + 1);
strcpy (newd.value, value); strcpy (newd.value, value);
[self addElement:&newd]; [self addElement: &newd];
} }
return self; return self;
} }
@ -158,41 +158,39 @@ JDC
// //
// Search for keyword, return the string * // Search for keyword, return the string *
// //
-(const char *) getStringFor:(const char *) name - (const char *) getStringFor: (const char *)name
{ {
dict_t *d; dict_t *d;
d =[self findKeyword:name]; d = [self findKeyword: name];
if (d != NULL) if (d != NULL)
return d->value; return d->value;
return (char *) ""; return (char *) "";
} }
// //
// Search for keyword, return the value // Search for keyword, return the value
// //
-(unsigned int) getValueFor:(const char *) name - (unsigned int) getValueFor: (const char *)name
{ {
dict_t *d; dict_t *d;
d =[self findKeyword:name]; d = [self findKeyword: name];
if (d != NULL) if (d != NULL)
return atol (d->value); return atol (d->value);
return 0; return 0;
} }
// //
// Return # of units in keyword's value // Return # of units in keyword's value
// //
-(int) getValueUnits:(const char *) key - (int) getValueUnits: (const char *)key
{ {
id temp; id temp;
int count; int count;
temp =[self parseMultipleFrom:key]; temp = [self parseMultipleFrom: key];
count =[temp count]; count = [temp count];
[temp release]; [temp release];
return count; return count;
@ -201,17 +199,17 @@ JDC
// //
// Convert List to string // Convert List to string
// //
-(char *) convertListToString:(id) list - (char *) convertListToString: (id)list
{ {
int i; int i;
int max; int max;
dstring_t *tempstr; dstring_t *tempstr;
char *s; char *s;
max =[list count]; max = [list count];
tempstr = dstring_newstr (); tempstr = dstring_newstr ();
for (i = 0; i < max; i++) { for (i = 0; i < max; i++) {
s =[list elementAt:i]; s = [list elementAt: i];
dstring_appendstr (tempstr, s); dstring_appendstr (tempstr, s);
dstring_appendstr (tempstr, " "); dstring_appendstr (tempstr, " ");
} }
@ -222,39 +220,39 @@ JDC
// //
// JDC: I wrote this to simplify removing vectors // JDC: I wrote this to simplify removing vectors
// //
-removeKeyword:(const char *) key - (id) removeKeyword: (const char *)key
{ {
dict_t *d; dict_t *d;
d =[self findKeyword:key]; d = [self findKeyword: key];
if (d == NULL) if (d == NULL)
return self; return self;
[self removeElementAt:d - (dict_t *) dataPtr]; [self removeElementAt: d - (dict_t *) dataPtr];
return self; return self;
} }
// //
// Delete string from keyword's value // Delete string from keyword's value
// //
-delString:(const char *) string fromValue:(const char *) key - (id) delString: (const char *)string fromValue: (const char *)key
{ {
id temp; id temp;
int count; int count;
int i; int i;
char *s; char *s;
dict_t *d; dict_t *d;
d =[self findKeyword:key]; d = [self findKeyword: key];
if (d == NULL) if (d == NULL)
return NULL; return NULL;
temp =[self parseMultipleFrom:key]; temp = [self parseMultipleFrom: key];
count =[temp count]; count = [temp count];
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
s =[temp elementAt:i]; s = [temp elementAt: i];
if (!strcmp (s, string)) { if (!strcmp (s, string)) {
[temp removeElementAt:i]; [temp removeElementAt: i];
free (d->value); free (d->value);
d->value =[self convertListToString:temp]; d->value = [self convertListToString: temp];
[temp release]; [temp release];
break; break;
@ -266,12 +264,12 @@ JDC
// //
// Add string to keyword's value // Add string to keyword's value
// //
-addString:(const char *) string toValue:(const char *) key - (id) addString: (const char *)string toValue: (const char *)key
{ {
char *newstr; char *newstr;
dict_t *d; dict_t *d;
d =[self findKeyword:key]; d = [self findKeyword: key];
if (d == NULL) if (d == NULL)
return NULL; return NULL;
newstr = nva ("%s\t%s", d->value, string); newstr = nva ("%s\t%s", d->value, string);
@ -281,31 +279,31 @@ JDC
return self; return self;
} }
//=============================================== // ===============================================
// //
// Use these for multiple parameters in a keyword value // Use these for multiple parameters in a keyword value
// //
//=============================================== // ===============================================
const char *searchStr; const char *searchStr;
char item[4096]; char item[4096];
-setupMultiple:(const char *) value - (id) setupMultiple: (const char *)value
{ {
searchStr = value; searchStr = value;
return self; return self;
} }
-(char *) getNextParameter - (char *) getNextParameter
{ {
char *s; char *s;
if (!searchStr) if (!searchStr)
return NULL; return NULL;
strcpy (item, searchStr); strcpy (item, searchStr);
s = FindWhitespcInBuffer (item); s = FindWhitespcInBuffer (item);
if (!*s) if (!*s) {
searchStr = NULL; searchStr = NULL;
else { } else {
*s = 0; *s = 0;
searchStr = FindNonwhitespcInBuffer (s + 1); searchStr = FindNonwhitespcInBuffer (s + 1);
} }
@ -315,65 +313,66 @@ char item[4096];
// //
// Parses a keyvalue string & returns a Storage full of those items // Parses a keyvalue string & returns a Storage full of those items
// //
-(id) parseMultipleFrom:(const char *) key - (id) parseMultipleFrom: (const char *)key
{ {
#define ITEMSIZE 128 #define ITEMSIZE 128
id stuff; id stuff;
char string[ITEMSIZE]; char string[ITEMSIZE];
const char *s; const char *s;
s =[self getStringFor:key]; s = [self getStringFor: key];
if (s == NULL) if (s == NULL)
return NULL; return NULL;
stuff = [[Storage alloc]
initCount: 0 elementSize: ITEMSIZE description: NULL];
stuff =[[Storage alloc] [self setupMultiple: s];
initCount: 0 elementSize: ITEMSIZE description:NULL]; while ((s = [self getNextParameter])) {
[self setupMultiple:s];
while ((s =[self getNextParameter])) {
bzero (string, ITEMSIZE); bzero (string, ITEMSIZE);
strcpy (string, s); strcpy (string, s);
[stuff addElement:string]; [stuff addElement: string];
} }
return stuff; return stuff;
} }
//=============================================== // ===============================================
// //
// Dictionary pair parsing // Dictionary pair parsing
// //
//=============================================== // ===============================================
// //
// parse all keyword/value pairs within { } 's // parse all keyword/value pairs within { } 's
// //
-(id) parseBraceBlock:(FILE *) fp - (id) parseBraceBlock: (FILE *)fp
{ {
int c; int c;
dict_t pair; dict_t pair;
char string[1024]; char string[1024];
c = FindBrace (fp); c = FindBrace (fp);
if (c == -1) if (c == -1)
return NULL; return NULL;
while ((c = FindBrace (fp)) != '}') { while ((c = FindBrace (fp)) != '}') {
if (c == -1) if (c == -1)
return NULL; return NULL;
// c = FindNonwhitespc(fp);
// if (c == -1) #if 0
// return NULL; c = FindNonwhitespc (fp);
// CopyUntilWhitespc(fp,string); if (c == -1)
return NULL;
CopyUntilWhitespc (fp, string);
#endif
// JDC: fixed to allow quoted keys // JDC: fixed to allow quoted keys
c = FindNonwhitespc (fp); c = FindNonwhitespc (fp);
if (c == -1) if (c == -1)
return NULL; return NULL;
c = fgetc (fp); c = fgetc (fp);
if (c == '\"') if (c == '\"') {
CopyUntilQuote (fp, string); CopyUntilQuote (fp, string);
else { } else {
ungetc (c, fp); ungetc (c, fp);
CopyUntilWhitespc (fp, string); CopyUntilWhitespc (fp, string);
} }
@ -386,7 +385,7 @@ char item[4096];
pair.value = malloc (strlen (string) + 1); pair.value = malloc (strlen (string) + 1);
strcpy (pair.value, string); strcpy (pair.value, string);
[super addElement:&pair]; [super addElement: &pair];
c = FindBrace (fp); c = FindBrace (fp);
} }
@ -394,28 +393,32 @@ char item[4096];
} }
@end @end
//===============================================
// ===============================================
// //
// C routines for string parsing // C routines for string parsing
// //
//=============================================== // ===============================================
int int
GetNextChar (FILE * fp) GetNextChar (FILE * fp)
{ {
int c; int c;
int c2; int c2;
c = getc (fp); c = getc (fp);
if (c == EOF) if (c == EOF)
return -1; return -1;
if (c == '/') // parse comments
{ if (c == '/') { // parse comments
c2 = getc (fp); c2 = getc (fp);
if (c2 == '/') { if (c2 == '/') {
while ((c2 = getc (fp)) != '\n'); while ((c2 = getc (fp)) != '\n')
;
c = getc (fp); c = getc (fp);
} else } else {
ungetc (c2, fp); ungetc (c2, fp);
}
} }
return c; return c;
} }
@ -423,13 +426,14 @@ GetNextChar (FILE * fp)
void void
CopyUntilWhitespc (FILE * fp, char *buffer) CopyUntilWhitespc (FILE * fp, char *buffer)
{ {
int count = 800; int count = 800;
int c; int c;
while (count--) { while (count--) {
c = GetNextChar (fp); c = GetNextChar (fp);
if (c == EOF) if (c == EOF)
return; return;
if (c <= ' ') { if (c <= ' ') {
*buffer = 0; *buffer = 0;
return; return;
@ -441,17 +445,19 @@ CopyUntilWhitespc (FILE * fp, char *buffer)
void void
CopyUntilQuote (FILE * fp, char *buffer) CopyUntilQuote (FILE * fp, char *buffer)
{ {
int count = 800; int count = 800;
int c; int c;
while (count--) { while (count--) {
c = GetNextChar (fp); c = GetNextChar (fp);
if (c == EOF) if (c == EOF)
return; return;
if (c == '\"') { if (c == '\"') {
*buffer = 0; *buffer = 0;
return; return;
} }
*buffer++ = c; *buffer++ = c;
} }
} }
@ -459,13 +465,14 @@ CopyUntilQuote (FILE * fp, char *buffer)
int int
FindBrace (FILE * fp) FindBrace (FILE * fp)
{ {
int count = 800; int count = 800;
int c; int c;
while (count--) { while (count--) {
c = GetNextChar (fp); c = GetNextChar (fp);
if (c == EOF) if (c == EOF)
return -1; return -1;
if (c == '{' || c == '}') if (c == '{' || c == '}')
return c; return c;
} }
@ -475,13 +482,15 @@ FindBrace (FILE * fp)
int int
FindQuote (FILE * fp) FindQuote (FILE * fp)
{ {
int count = 800; int count = 800;
int c; int c;
while (count--) { while (count--) {
c = GetNextChar (fp); c = GetNextChar (fp);
if (c == EOF) if (c == EOF)
return -1; return -1;
if (c == '\"') if (c == '\"')
return c; return c;
} }
@ -491,8 +500,8 @@ FindQuote (FILE * fp)
int int
FindWhitespc (FILE * fp) FindWhitespc (FILE * fp)
{ {
int count = 800; int count = 800;
int c; int c;
while (count--) { while (count--) {
c = GetNextChar (fp); c = GetNextChar (fp);
@ -509,8 +518,8 @@ FindWhitespc (FILE * fp)
int int
FindNonwhitespc (FILE * fp) FindNonwhitespc (FILE * fp)
{ {
int count = 800; int count = 800;
int c; int c;
while (count--) { while (count--) {
c = GetNextChar (fp); c = GetNextChar (fp);
@ -527,27 +536,29 @@ FindNonwhitespc (FILE * fp)
char * char *
FindWhitespcInBuffer (char *buffer) FindWhitespcInBuffer (char *buffer)
{ {
int count = 1000; int count = 1000;
char *b = buffer; char *b = buffer;
while (count--) while (count--) {
if (*b <= ' ') if (*b <= ' ')
return b; return b;
else else
b++; b++;
}
return NULL; return NULL;
} }
char * char *
FindNonwhitespcInBuffer (char *buffer) FindNonwhitespcInBuffer (char *buffer)
{ {
int count = 1000; int count = 1000;
char *b = buffer; char *b = buffer;
while (count--) while (count--) {
if (*b > ' ') if (*b > ' ')
return b; return b;
else else
b++; b++;
}
return NULL; return NULL;
} }

View file

@ -3,14 +3,14 @@
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
@interface DictList:NSMutableArray @interface DictList: NSMutableArray
{ {
NSMutableArray *array; NSMutableArray *array;
} }
-initListFromFile:(FILE *) fp; - (id) initListFromFile: (FILE *)fp;
-writeListFile:(const char *) filename; - (id) writeListFile: (const char *)filename;
-(id) findDictKeyword:(const char *) key; - (id) findDictKeyword: (const char *)key;
@end @end
#endif // DictList_h #endif // DictList_h

View file

@ -1,4 +1,3 @@
#include "DictList.h" #include "DictList.h"
#include "Dict.h" #include "Dict.h"
@ -9,16 +8,16 @@
// //
// Read in variable # of objects from FILE * // Read in variable # of objects from FILE *
// //
- initListFromFile:(FILE *) fp - (id) initListFromFile: (FILE *)fp
{ {
id d; id d;
self = [super init]; self = [super init];
array = [[NSMutableArray alloc] init]; array = [[NSMutableArray alloc] init];
do { do {
d =[(Dict *)[Dict alloc] initFromFile:fp]; d = [(Dict *)[Dict alloc] initFromFile: fp];
if (d != NULL) if (d != NULL)
[self addObject:d]; [self addObject: d];
} while (d != NULL); } while (d != NULL);
[d release]; [d release];
@ -28,21 +27,20 @@
// //
// Write out list file // Write out list file
// //
-writeListFile:(const char *) filename - (id) writeListFile: (const char *)filename
{ {
FILE *fp; FILE *fp;
NSUInteger i; NSUInteger i;
id obj; id obj;
fp = fopen (filename, "w+t"); fp = fopen (filename, "w+t");
if (fp == NULL) if (fp == NULL)
return NULL; return NULL;
fprintf (fp, "// Object List written by QuakeEd\n"); fprintf (fp, "// Object List written by QuakeEd\n");
for (i = 0; i <[self count]; i++) { for (i = 0; i < [self count]; i++) {
obj =[self objectAtIndex:i]; obj = [self objectAtIndex: i];
[obj writeBlockTo:fp]; [obj writeBlockTo: fp];
} }
fclose (fp); fclose (fp);
@ -52,15 +50,15 @@
// //
// Find the keyword in all the Dict objects // Find the keyword in all the Dict objects
// //
-(id) findDictKeyword:(const char *) key - (id) findDictKeyword: (const char *)key
{ {
NSUInteger i; NSUInteger i;
dict_t *d; dict_t *d;
id dict; id dict;
for (i = 0; i <[self count]; i++) { for (i = 0; i < [self count]; i++) {
dict =[self objectAtIndex:i]; dict = [self objectAtIndex: i];
d =[(Dict *) dict findKeyword:key]; d = [(Dict *) dict findKeyword: key];
if (d != NULL) if (d != NULL)
return dict; return dict;
} }

View file

@ -5,42 +5,42 @@
#include "QF/mathlib.h" #include "QF/mathlib.h"
typedef struct epair_s { typedef struct epair_s {
struct epair_s *next; struct epair_s *next;
char *key; char *key;
char *value; 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:NSMutableArray @interface Entity: NSMutableArray
{ {
NSMutableArray *array; NSMutableArray *array;
epair_t *epairs; epair_t *epairs;
BOOL modifiable; BOOL modifiable;
} }
- (Entity *) initClass:(const char *) classname; - (Entity *) initClass: (const char *)classname;
- (Entity *) initFromScript: (struct script_s *) script; - (Entity *) initFromScript: (struct script_s *)script;
- (oneway void) dealloc; - (oneway void) dealloc;
-(BOOL) modifiable; - (BOOL) modifiable;
- (void) setModifiable:(BOOL) m; - (void) setModifiable: (BOOL)m;
-(const char *) targetname; - (const char *) targetname;
- (void) writeToFILE:(FILE *)f region:(BOOL) reg; - (void) writeToFILE: (FILE *)f region: (BOOL)reg;
-(const char *) valueForQKey:(const char *) k; - (const char *) valueForQKey: (const char *)k;
- (void) getVector:(vec3_t)v forKey:(const char *) k; - (void) getVector: (vec3_t)v forKey: (const char *)k;
- (void) setKey:(const char *)k - (void) setKey: (const char *)k
toValue:(const char *)v; toValue: (const char *)v;
-(int) numPairs; - (int) numPairs;
-(epair_t *) epairs; - (epair_t *) epairs;
- (void) removeKeyPair:(const char *) key; - (void) removeKeyPair: (const char *)key;
@end @end
#endif // Entity_h #endif // Entity_h

View file

@ -15,27 +15,27 @@
@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;
} }
color =[new drawColor]; color = [new drawColor];
modifiable = NO; modifiable = NO;
memset (&td, 0, sizeof (td)); memset (&td, 0, sizeof (td));
@ -43,10 +43,10 @@ vec3_t bad_maxs = { 8, 8, 8 };
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 texture:&td]; new = [[SetBrush alloc] initOwner: self mins: emins maxs: emaxs texture: &td];
[new setEntityColor:color]; [new setEntityColor: color];
[self addObject:new]; [self addObject: new];
return self; return self;
} }
@ -57,7 +57,7 @@ vec3_t bad_maxs = { 8, 8, 8 };
esize_t esize; esize_t esize;
vec3_t min, max; vec3_t min, max;
int org[3]; int org[3];
float *v; float *v;
self = [super init]; self = [super init];
array = [[NSMutableArray alloc] init]; array = [[NSMutableArray alloc] init];
@ -67,7 +67,7 @@ vec3_t bad_maxs = { 8, 8, 8 };
[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
@ -76,22 +76,23 @@ vec3_t bad_maxs = { 8, 8, 8 };
// 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); // convert to integer VectorCopy (min, org);
[self setKey:"origin" toValue:va ("%i %i %i", org[0], org[1], org[2])]; // 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 - (oneway void) dealloc
{ {
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;
@ -103,7 +104,7 @@ vec3_t bad_maxs = { 8, 8, 8 };
[super dealloc]; [super dealloc];
} }
-(BOOL) modifiable - (BOOL) modifiable
{ {
return modifiable; return modifiable;
} }
@ -114,45 +115,45 @@ vec3_t bad_maxs = { 8, 8, 8 };
return; return;
} }
-(void) removeObject: (id)o - (void) removeObject: (id)o
{ {
[super removeObject:o]; [super removeObject: o];
if ([self count]) if ([self count])
return; return;
// the entity is empty, so remove the entire thing
if (self ==[map_i objectAtIndex:0])
return; // never remove the world
[map_i removeObject:self]; // the entity is empty, so remove the entire thing
if (self == [map_i objectAtIndex: 0]) // unless it's the world...
return;
[map_i removeObject: self];
[self release]; [self release];
} }
- (const char *) valueForQKey: (const char *)k
-(const char *) valueForQKey:(const char *) k
{ {
epair_t *e; epair_t *e;
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; return e->value;
}
return ""; return "";
} }
- (void) getVector: (vec3_t)v - (void) getVector: (vec3_t)v
forKey: (const char *)k forKey: (const char *)k
{ {
const 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]);
} }
-print - (id) print
{ {
epair_t *e; epair_t *e;
for (e = epairs; e; e = e->next) for (e = epairs; e; e = e->next)
printf ("%20s : %20s\n", e->key, e->value); printf ("%20s : %20s\n", e->key, e->value);
@ -160,15 +161,17 @@ vec3_t bad_maxs = { 8, 8, 8 };
return self; return self;
} }
- (void) setKey:(const char *)k - (void) setKey: (const char *)k
toValue:(const char *) v toValue: (const char *)v
{ {
epair_t *e; epair_t *e;
while (*k && *k <= ' ') while (*k && *k <= ' ')
k++; k++;
// don't set NULL values
if (!*k) if (!*k)
return; // don't set NULL values return;
for (e = epairs; e; e = e->next) { for (e = epairs; e; e = e->next) {
if (!strcmp (k, e->key)) { if (!strcmp (k, e->key)) {
@ -185,25 +188,26 @@ vec3_t bad_maxs = { 8, 8, 8 };
epairs = e; epairs = e;
} }
-(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;
} }
- (void) removeKeyPair:(char *) key - (void) removeKeyPair: (char *)key
{ {
epair_t *e, *e2; epair_t *e, *e2;
if (!epairs) if (!epairs)
return; return;
@ -215,7 +219,7 @@ vec3_t bad_maxs = { 8, 8, 8 };
return; 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;
@ -228,7 +232,6 @@ vec3_t bad_maxs = { 8, 8, 8 };
return; return;
} }
/* /*
============= =============
targetname targetname
@ -236,23 +239,23 @@ 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
============= =============
*/ */
-(const char *) targetname - (const char *) targetname
{ {
const char *t; const char *t;
int i, count; int i, count;
id ent; id ent;
int tval, maxt; int tval, maxt;
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 objectAtIndex: 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);
@ -260,9 +263,9 @@ If the entity does not have a "targetname" key, a unique one is generated
maxt = tval; maxt = tval;
} }
[self setKey: "targetname" toValue:va ("t%i", maxt + 1)]; [self setKey: "targetname" toValue: va ("t%i", maxt + 1)];
return [self valueForQKey:"targetname"]; return [self valueForQKey: "targetname"];
} }
/* /*
@ -273,19 +276,19 @@ FILE METHODS
============================================================================== ==============================================================================
*/ */
int nument; int nument;
- (Entity *) initFromScript:(script_t *) script - (Entity *) initFromScript: (script_t *)script
{ {
char *key; char *key;
id eclass, brush; id eclass, brush;
const 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 = [super init]; self = [super init];
array = [[NSMutableArray alloc] init]; array = [[NSMutableArray alloc] init];
@ -305,13 +308,13 @@ int nument;
break; break;
if (!strcmp (Script_Token (script), "{")) { if (!strcmp (Script_Token (script), "{")) {
// read a brush // read a brush
brush =[[SetBrush alloc] initFromScript: script owner: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)); key = strdup (Script_Token (script));
Script_GetToken (script, false); Script_GetToken (script, false);
[self setKey: key toValue:Script_Token (script)]; [self setKey: key toValue: Script_Token (script)];
free (key); free (key);
} }
} while (1); } while (1);
@ -319,12 +322,12 @@ int nument;
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");
@ -332,94 +335,96 @@ int nument;
} }
if (![self count] && esize == esize_model) { if (![self count] && esize == esize_model) {
printf ("WARNING:Entity with no brushes and esize_model: %s\n", [self valueForQKey:"classname"]); printf ("WARNING:Entity with no brushes and esize_model: %s\n",
[texturepalette_i getTextureDef:&td]; [self valueForQKey: "classname"]);
[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 texture:&td]; brush =
[self addObject:brush]; [[SetBrush alloc] initOwner: self mins: emins maxs: emaxs texture: &td];
[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 objectAtIndex: i];
[brush setEntityColor:color]; [brush setEntityColor: color];
} }
return self; return self;
} }
- (void) writeToFILE: (FILE *)f
- (void) writeToFILE:(FILE *)f region: (BOOL)reg;
region:(BOOL) reg;
{ {
epair_t *e; epair_t *e;
int ang; int ang;
unsigned int i; unsigned int i;
id new; id new;
vec3_t mins, maxs; vec3_t mins, maxs;
int org[3]; int org[3];
const vec_t *v; const vec_t *v;
char *oldang = 0; char *oldang = 0;
if (reg) { if (reg) {
if (!strcmp ([self valueForQKey:"classname"], "info_player_start")) { if (!strcmp ([self valueForQKey: "classname"], "info_player_start")) {
// move the playerstart temporarily to the camera position // move the playerstart temporarily to the camera position
oldang = strdup ([self valueForQKey:"angle"]); oldang = strdup ([self valueForQKey: "angle"]);
ang = (int) ([cameraview_i yawAngle] * 180 / M_PI); ang = (int) ([cameraview_i yawAngle] * 180 / M_PI);
[self setKey: "angle" toValue: va ("%i", ang)]; [self setKey: "angle" toValue: va ("%i", ang)];
} else if (self != [map_i objectAtIndex:0] } else if (self != [map_i objectAtIndex: 0]
&& [[self objectAtIndex:0] regioned]) { && [[self objectAtIndex: 0] regioned]) {
return; // skip the entire entity definition return; // skip the entire entity definition
} }
} }
fprintf (f, "{\n"); fprintf (f, "{\n");
// set an origin epair // set an origin epair
if (!modifiable) { if (!modifiable) {
[[self objectAtIndex: 0] getMins: mins maxs:maxs]; [[self objectAtIndex: 0] getMins: mins maxs: maxs];
if (oldang) { 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); VectorSubtract (mins, v, org);
[self setKey: "origin" [self setKey: "origin"
toValue: va ("%i %i %i", org[0], org[1], org[2])]; toValue: va ("%i %i %i", org[0], org[1], org[2])];
} }
for (e = epairs; e; e = e->next) for (e = epairs; e; e = e->next)
fprintf (f, "\"%s\"\t\"%s\"\n", e->key, e->value); fprintf (f, "\"%s\"\t\"%s\"\n", e->key, e->value);
// fixed size entities don't save out brushes // fixed size entities don't save out brushes
if (modifiable) { if (modifiable) {
for (i = 0; i <[self count]; i++) for (i = 0; i < [self count]; i++)
[[self objectAtIndex: i] writeToFILE: f region:reg]; [[self objectAtIndex: i] writeToFILE: f region: reg];
} }
fprintf (f, "}\n"); fprintf (f, "}\n");
if (oldang) { if (oldang) {
[self setKey: "angle" toValue:oldang]; [self setKey: "angle" toValue: oldang];
free (oldang); free (oldang);
} }

View file

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

View file

@ -12,17 +12,15 @@
static int static int
parse_vector (script_t * script, vec3_t vec) parse_vector (script_t * script, vec3_t vec)
{ {
int r; int r;
if (!Script_GetToken (script, 0)) if (!Script_GetToken (script, 0))
return 0; return 0;
if (strcmp (Script_Token (script), "(")) if (strcmp (Script_Token (script), "("))
return 0; return 0;
r = sscanf (script->p, "%f %f %f)", &vec[0], &vec[1], &vec[2]); r = sscanf (script->p, "%f %f %f)", &vec[0], &vec[1], &vec[2]);
if (r != 3) if (r != 3)
return 0; return 0;
while (strcmp (Script_Token (script), ")")) { while (strcmp (Script_Token (script), ")")) {
if (!Script_GetToken (script, 0)) if (!Script_GetToken (script, 0))
return 0; return 0;
@ -38,14 +36,15 @@ parse_vector (script_t * script, vec3_t vec)
// //
// 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
-initFromText:(const char *) text source:(const char *) filename - (id) initFromText: (const char *)text source: (const char *)filename
{ {
const char *t; const char *t;
size_t len; size_t len;
int i; int i;
script_t *script; script_t *script;
[super init]; [super init];
@ -64,7 +63,7 @@ parse_vector (script_t * script, vec3_t vec)
// grab the color // grab the color
if (!parse_vector (script, color)) if (!parse_vector (script, color))
return 0; return 0;
// get the size // get the size
if (!Script_GetToken (script, 0)) if (!Script_GetToken (script, 0))
return 0; return 0;
if (!strcmp (Script_Token (script), "(")) { if (!strcmp (Script_Token (script), "(")) {
@ -80,7 +79,6 @@ parse_vector (script_t * script, vec3_t vec)
} else { } else {
return 0; return 0;
} }
// get the flags // get the flags
// any remaining words on the line are parm flags // any remaining words on the line are parm flags
for (i = 0; i < MAX_FLAGS; i++) { for (i = 0; i < MAX_FLAGS; i++) {
@ -105,38 +103,37 @@ parse_vector (script_t * script, vec3_t vec)
return self; return self;
} }
-(esize_t) esize - (esize_t) esize
{ {
return esize; return esize;
} }
-(const 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;
} }
-(const char *) comments - (const char *) comments
{ {
return comments; return comments;
} }
- (const char *) flagName: (unsigned)flagnum
-(const char *) flagName:(unsigned) flagnum
{ {
if (flagnum >= MAX_FLAGS) if (flagnum >= MAX_FLAGS)
Sys_Error ("EntityClass flagName: bad number"); Sys_Error ("EntityClass flagName: bad number");
@ -144,7 +141,7 @@ parse_vector (script_t * script, vec3_t vec)
} }
@end @end
//=========================================================================== // ===========================================================================
#define THING EntityClassList #define THING EntityClassList
#include "THING+NSArray.m" #include "THING+NSArray.m"
@ -155,35 +152,34 @@ parse_vector (script_t * script, vec3_t vec)
insertEC: insertEC:
================= =================
*/ */
- (void) insertEC:ec - (void) insertEC: ec
{ {
const char *name; const char *name;
unsigned 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:(const char *) filename - (void) scanFile: (const char *)filename
{ {
int size, line; int size, line;
char *data; char *data;
id cl; id cl;
int i; int i;
const char *path; const char *path;
QFile *file; QFile *file;
path = va ("%s/%s", source_path, filename); path = va ("%s/%s", source_path, filename);
@ -199,10 +195,11 @@ scanFile
line = 1; line = 1;
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
if (!strncmp (data + i, "/*QUAKED", 8)) { if (!strncmp (data + i, "/*QUAKED", 8)) {
cl =[[EntityClass alloc] initFromText:(data + i) cl = [[EntityClass alloc]
source:va ("%s:%d", filename, line)]; initFromText: (data + i)
source: va ("%s:%d", filename, line)];
if (cl) if (cl)
[self insertEC:cl]; [self insertEC: cl];
} else if (data[i] == '\n') { } else if (data[i] == '\n') {
line++; line++;
} }
@ -211,68 +208,63 @@ scanFile
free (data); free (data);
} }
/* /*
================= =================
scanDirectory scanDirectory
================= =================
*/ */
-(void) scanDirectory - (void) scanDirectory
{ {
int count, i; int count, i;
struct dirent **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:(const char *) path
{ {
self = [super init]; self = [super init];
array = [[NSMutableArray alloc] init]; array = [[NSMutableArray alloc] init];
source_path = strdup (path); //FIXME leak? source_path = strdup (path); // FIXME leak?
[self scanDirectory]; [self scanDirectory];
entity_classes_i = self; entity_classes_i = self;
nullclass =[[EntityClass alloc] nullclass = [[EntityClass alloc]
initFromText: "/*QUAKED UNKNOWN_CLASS (0 0.5 0) ?*/" source:va ("%s:%d", __FILE__, initFromText: "/*QUAKED UNKNOWN_CLASS (0 0.5 0) ?*/"
__LINE__ - source: va ("%s:%d", __FILE__, __LINE__ - 1)];
1)];
return self; return self;
} }
-(id) classForName:(const char *) name - (id) classForName: (const char *)name
{ {
unsigned 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

@ -24,25 +24,25 @@ extern InspectorControl *inspcontrol_i;
{ {
IBOutlet NSView *inspectorView_i; // inspector view IBOutlet NSView *inspectorView_i; // inspector view
IBOutlet NSView *inspectorSubview_i; // inspector view's current subview IBOutlet NSView *inspectorSubview_i; // inspector view's current subview
// (gets replaced) // (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 id windowList; // List of Windows (corresponds to
// insp_e enum order) // insp_e enum order)
id obj_textures_i; // TexturePalette object (for id obj_textures_i; // TexturePalette object (for
// delegating) // delegating)
id obj_genkeypair_i; // GenKeyPair object id obj_genkeypair_i; // GenKeyPair object
NSPopUpButton *popUpButton_i; // PopUpList title button NSPopUpButton *popUpButton_i; // PopUpList title button
NSMatrix *popUpMatrix_i; // PopUpList matrix NSMatrix *popUpMatrix_i; // PopUpList matrix
NSMutableArray *itemList; // List of popUp buttons NSMutableArray *itemList; // List of popUp buttons
IBOutlet NSTextView *helpView; IBOutlet NSTextView *helpView;
insp_e currentInspectorType; // keep track of current inspector insp_e currentInspectorType; // keep track of current inspector
// //
// Add id's here for new inspectors // Add id's here for new inspectors
@ -65,7 +65,7 @@ extern InspectorControl *inspcontrol_i;
IBOutlet id <NSMenuItem> itemPrefs_i; // preferences IBOutlet id <NSMenuItem> itemPrefs_i; // preferences
IBOutlet id <NSMenuItem> itemSettings_i; // project settings IBOutlet id <NSMenuItem> itemSettings_i; // project settings
IBOutlet id <NSMenuItem> itemOutput_i; // bsp output IBOutlet id <NSMenuItem> itemOutput_i; // bsp output
IBOutlet id <NSMenuItem> itemHelp_i; // docs IBOutlet id <NSMenuItem> itemHelp_i; // docs
} }
- (IBAction) changeInspector: (id)sender; - (IBAction) changeInspector: (id)sender;

View file

@ -7,7 +7,7 @@
#include "TexturePalette.h" #include "TexturePalette.h"
#include "Preferences.h" #include "Preferences.h"
InspectorControl *inspcontrol_i; InspectorControl *inspcontrol_i;
@interface CustomView: NSView @interface CustomView: NSView
@end @end
@ -100,10 +100,8 @@ InspectorControl *inspcontrol_i;
NSRect r; NSRect r;
NSRect f; NSRect f;
if (which == currentInspectorType) { if (which == currentInspectorType)
return; return;
}
currentInspectorType = which; currentInspectorType = which;
newView = [contentList objectAtIndex: which]; newView = [contentList objectAtIndex: which];

View file

@ -3,19 +3,19 @@
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
extern id keypairview_i; extern id keypairview_i;
@interface KeypairView:NSView @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

View file

@ -1,10 +1,9 @@
#include "KeypairView.h" #include "KeypairView.h"
#include "Map.h" #include "Map.h"
#include "Entity.h" #include "Entity.h"
#include "Things.h" #include "Things.h"
id keypairview_i; id keypairview_i;
@implementation KeypairView @implementation KeypairView
/* /*
@ -12,20 +11,19 @@ id keypairview_i;
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 - (BOOL) isFlipped
{ {
return YES; return YES;
} }
- (id) calcViewSize
-calcViewSize
{ {
NSRect b; NSRect b;
NSPoint pt; NSPoint pt;
@ -37,17 +35,17 @@ initWithFrame:
b = [[self superview] bounds]; b = [[self superview] bounds];
b.size.height = LINEHEIGHT * count + SPACING; b.size.height = LINEHEIGHT * count + SPACING;
[self setFrameSize:b.size]; [self setFrameSize: b.size];
pt.x = pt.y = 0; pt.x = pt.y = 0;
[self scrollPoint:pt]; [self scrollPoint: pt];
return self; return self;
} }
-drawRect: (NSRect) rects - (id) drawRect: (NSRect)rects
{ {
epair_t *pair; epair_t *pair;
int y; int y;
NSMutableDictionary *attribs = [NSMutableDictionary dictionary]; NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
[[NSColor lightGrayColor] set]; [[NSColor lightGrayColor] set];
NSRectFill (NSMakeRect (0, 0, _bounds.size.width, _bounds.size.height)); NSRectFill (NSMakeRect (0, 0, _bounds.size.width, _bounds.size.height));
@ -55,11 +53,12 @@ initWithFrame:
[[NSFont systemFontOfSize: FONTSIZE] set]; [[NSFont systemFontOfSize: FONTSIZE] set];
[[NSColor blackColor] set]; [[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]; NSString *key = [NSString stringWithCString: pair->key];
NSString *value = [NSString stringWithCString: pair->value]; NSString *value = [NSString stringWithCString: pair->value];
[key drawAtPoint: NSMakePoint (SPACING, y) withAttributes: attribs]; [key drawAtPoint: NSMakePoint (SPACING, y) withAttributes: attribs];
[value drawAtPoint: NSMakePoint (100, y) withAttributes: attribs]; [value drawAtPoint: NSMakePoint (100, y) withAttributes: attribs];
y -= LINEHEIGHT; y -= LINEHEIGHT;
@ -68,18 +67,18 @@ initWithFrame:
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)
@ -87,7 +86,7 @@ initWithFrame:
i--; i--;
} }
if (p) if (p)
[things_i setSelectedKey:p]; [things_i setSelectedKey: p];
return; return;
} }

View file

@ -7,70 +7,70 @@
// 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
{ {
NSMutableArray *array; NSMutableArray *array;
id currentEntity; id currentEntity;
id oldselection; // temp when loading a new map id oldselection; // temp when loading a new map
float minz, maxz; float minz, maxz;
} }
-newMap; - (id) newMap;
-writeStats; - (id) writeStats;
-readMapFile:(const char *) fname; - (id) readMapFile: (const char *)fname;
-writeMapFile:(const 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

File diff suppressed because it is too large Load diff

View file

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

View file

@ -1,4 +1,3 @@
#include "PopScrollView.h" #include "PopScrollView.h"
@implementation PopScrollView @implementation PopScrollView
@ -9,23 +8,26 @@ 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
==================== ====================
*/ */
- initWithFrame:(NSRect) - (id) initWithFrame: (NSRect)frameRect
frameRect button1:b1 button2:b2 { button1: b1
[super initWithFrame:frameRect]; button2: b2
{
[super initWithFrame: frameRect];
[self addSubview:b1]; [self addSubview: b1];
[self addSubview:b2]; [self addSubview: b2];
button1 = b1; button1 = b1;
button2 = b2; button2 = b2;
[self setHasHorizontalScroller:YES]; [self setHasHorizontalScroller: YES];
[self setHasVerticalScroller:YES]; [self setHasVerticalScroller: YES];
[self setBorderType:NSBezelBorder]; [self setBorderType: NSBezelBorder];
return self; return self;
} }
/* /*
================ ================
tile tile
@ -33,49 +35,48 @@ tile
Adjust the size for the pop up scale menu Adjust the size for the pop up scale menu
================= =================
*/ */
-tile - (id) 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.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;
[button1 setFrame:newframe]; [button1 setFrame: newframe];
newframe.size.width = buttonframe2.size.width; newframe.size.width = buttonframe2.size.width;
newframe.origin.x -= newframe.size.width; newframe.origin.x -= newframe.size.width;
[button2 setFrame:newframe]; [button2 setFrame: newframe];
scrollerframe.size.width -= newframe.size.width; scrollerframe.size.width -= newframe.size.width;
[_horizScroller setFrame:scrollerframe]; [_horizScroller setFrame: scrollerframe];
return self; return self;
} }
/* /*
- 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

@ -3,84 +3,82 @@
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
extern id preferences_i; extern id preferences_i;
extern float lightaxis[3]; 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:NSObject @interface Preferences: NSObject
{ {
id bspSound_i; // actual sound object id bspSound_i; // actual sound object
// internal state // internal state
char projectpath[1024]; char projectpath[1024];
char bspSound[1024]; char bspSound[1024];
BOOL brushOffset; BOOL brushOffset;
BOOL showBSP; BOOL showBSP;
float xlight; float xlight;
float ylight; float ylight;
float zlight; // 0.0 - 1.0 float zlight; // 0.0 - 1.0
int startwad; // 0 - 2 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 startwad_i; // which wad to load at startup
id xlight_i; // X-side lighting id xlight_i; // X-side lighting
id ylight_i; // Y-side lighting id ylight_i; // Y-side lighting
id zlight_i; // Z-side lighting id zlight_i; // Z-side lighting
NSUserDefaults *prefs; NSUserDefaults *prefs;
} }
-readDefaults; - (id) readDefaults;
// //
// validate and set methods called by UI or defaults // validate and set methods called by UI or defaults
// //
-setProjectPath:(const char *) path; - (id) setProjectPath: (const char *)path;
-setBspSoundPath:(const char *) path; // set the path of the soundfile - (id) setBspSoundPath: (const char *)path; // set the path of the soundfile
// externally - (id) setShowBSP: (int)state; // set the state of ShowBSP
-setShowBSP:(int) state; // set the state of ShowBSP - (id) setBrushOffset: (int)state; // set the state of BrushOffset
-setBrushOffset:(int) state; // set the state of BrushOffset - (id) setStartWad: (int)value; // set start wad (0-2)
-setStartWad:(int) value; // set start wad (0-2) - (id) setXlight: (float)value; // set Xlight value for CameraView
-setXlight:(float) value; // set Xlight value for CameraView - (id) setYlight: (float)value; // set Ylight value for CameraView
-setYlight:(float) value; // set Ylight value for CameraView - (id) setZlight: (float)value; // set Zlight value for CameraView
-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;
-(const char *) getProjectPath; - (const char *) 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 #endif // Preferences_h

View file

@ -8,20 +8,21 @@
#include "QuakeEd.h" #include "QuakeEd.h"
#include "Project.h" #include "Project.h"
id preferences_i; id preferences_i;
#define DEFOWNER "QuakeEd2" #define DEFOWNER "QuakeEd2"
float lightaxis[3] = { 1, 0.6, 0.75 }; float lightaxis[3] = {1, 0.6, 0.75};
@implementation Preferences @implementation Preferences
void void
WriteStringDefault (id prefs, const char *name, const char *value) WriteStringDefault (id prefs, const char *name, const char *value)
{ {
NSString *key = [NSString stringWithCString: name]; NSString *key = [NSString stringWithCString: name];
NSString *val = [NSString stringWithCString: value]; NSString *val = [NSString stringWithCString: value];
[prefs setObject:val forKey:key];
[prefs setObject: val forKey: key];
} }
void void
@ -30,12 +31,12 @@ WriteNumericDefault (id prefs, const char *name, float value)
WriteStringDefault (prefs, name, va ("%f", value)); WriteStringDefault (prefs, name, va ("%f", value));
} }
-init - (id) init
{ {
[super init]; [super init];
preferences_i = self; preferences_i = self;
NSMutableDictionary *defaults = [NSMutableDictionary dictionary]; NSMutableDictionary *defaults = [NSMutableDictionary dictionary];
WriteStringDefault (defaults, "ProjectPath", ""); WriteStringDefault (defaults, "ProjectPath", "");
WriteStringDefault (defaults, "BspSoundPath", ""); WriteStringDefault (defaults, "BspSoundPath", "");
@ -47,7 +48,7 @@ WriteNumericDefault (id prefs, const char *name, float value)
WriteNumericDefault (defaults, "Zlight", 0); WriteNumericDefault (defaults, "Zlight", 0);
prefs = [[NSUserDefaults standardUserDefaults] retain]; prefs = [[NSUserDefaults standardUserDefaults] retain];
[prefs registerDefaults:defaults]; [prefs registerDefaults: defaults];
return self; return self;
} }
@ -56,6 +57,7 @@ _atoi (const char *c)
{ {
if (!c) if (!c)
return 0; return 0;
return atoi (c); return atoi (c);
} }
@ -64,88 +66,89 @@ _atof (const char *c)
{ {
if (!c) if (!c)
return 0; return 0;
return atof (c); return atof (c);
} }
// //
// Read in at start of program // Read in at start of program
// //
-readDefaults - (id) readDefaults
{ {
const char *string; const char *string;
float value = 0; float value = 0;
string = [[prefs stringForKey: @"ProjectPath"] cString]; string = [[prefs stringForKey: @"ProjectPath"] cString];
[self setProjectPath:string]; [self setProjectPath: string];
string = [[prefs stringForKey: @"BspSoundPath"] cString]; string = [[prefs stringForKey: @"BspSoundPath"] cString];
[self setBspSoundPath:string]; [self setBspSoundPath: string];
string = [[prefs stringForKey: @"ShowBSPOutput"] cString]; string = [[prefs stringForKey: @"ShowBSPOutput"] cString];
value = _atoi (string); value = _atoi (string);
[self setShowBSP:value]; [self setShowBSP: value];
string = [[prefs stringForKey: @"OffsetBrushCopy"] cString]; string = [[prefs stringForKey: @"OffsetBrushCopy"] cString];
value = _atoi (string); value = _atoi (string);
[self setBrushOffset:value]; [self setBrushOffset: value];
string = [[prefs stringForKey: @"StartWad"] cString]; string = [[prefs stringForKey: @"StartWad"] cString];
value = _atoi (string); value = _atoi (string);
[self setStartWad:value]; [self setStartWad: value];
string = [[prefs stringForKey: @"Xlight"] cString]; string = [[prefs stringForKey: @"Xlight"] cString];
value = _atof (string); value = _atof (string);
[self setXlight:value]; [self setXlight: value];
string = [[prefs stringForKey: @"Ylight"] cString]; string = [[prefs stringForKey: @"Ylight"] cString];
value = _atof (string); value = _atof (string);
[self setYlight:value]; [self setYlight: value];
string = [[prefs stringForKey: @"Zlight"] cString]; string = [[prefs stringForKey: @"Zlight"] cString];
value = _atof (string); value = _atof (string);
[self setZlight:value]; [self setZlight: value];
return self; return self;
} }
- (id) setProjectPath: (const char *)path
-setProjectPath:(const char *) path
{ {
if (!path) if (!path)
path = ""; path = "";
strcpy (projectpath, path); strcpy (projectpath, path);
[startproject_i setStringValue: [NSString stringWithCString:path]]; [startproject_i setStringValue: [NSString stringWithCString: path]];
WriteStringDefault (prefs, "ProjectPath", path); WriteStringDefault (prefs, "ProjectPath", path);
return self; return self;
} }
-setCurrentProject:sender - (id) setCurrentProject: sender
{ {
[startproject_i setStringValue: [NSString stringWithCString:[project_i [startproject_i setStringValue: [NSString stringWithCString: [project_i
currentProjectFile]]]; currentProjectFile
[self UIChanged:self]; ]]];
[self UIChanged: self];
return self; return self;
} }
-(const char *) getProjectPath - (const char *) getProjectPath
{ {
return projectpath; return projectpath;
} }
// //
//=============================================== // ===============================================
// BSP sound stuff // BSP sound stuff
//=============================================== // ===============================================
// //
// Set the BSP sound using an OpenPanel // Set the BSP sound using an OpenPanel
// //
-setBspSound:sender - (id) setBspSound: sender
{ {
id panel; id panel;
NSString *types[] = { @"snd" }; NSString *types[] = {@"snd"};
int rtn; int rtn;
NSArray *filenames; NSArray *filenames;
char path[1024], file[64]; char path[1024], file[64];
panel = [NSOpenPanel new]; panel = [NSOpenPanel new];
@ -153,37 +156,36 @@ _atof (const char *c)
// XXX ExtractFilePath (bspSound, path); // XXX ExtractFilePath (bspSound, path);
// XXX ExtractFileBase (bspSound, file); // XXX ExtractFileBase (bspSound, file);
rtn = [panel runModalForDirectory: [NSString stringWithCString:path] rtn = [panel runModalForDirectory: [NSString stringWithCString: path]
file: [NSString stringWithCString:file] file: [NSString stringWithCString: file]
types: [NSArray arrayWithObjects: types count:1]]; types: [NSArray arrayWithObjects: types count: 1]
];
if (rtn) { if (rtn) {
filenames =[panel filenames]; filenames = [panel filenames];
strcpy (bspSound,[[panel directory] cString]); strcpy (bspSound, [[panel directory] cString]);
strcat (bspSound, "/"); strcat (bspSound, "/");
strcat (bspSound,[[filenames objectAtIndex:0] cString]); strcat (bspSound, [[filenames objectAtIndex: 0] cString]);
[self setBspSoundPath:bspSound]; [self setBspSoundPath: bspSound];
[self playBspSound]; [self playBspSound];
} }
return self; return self;
} }
// //
// Play the BSP sound // Play the BSP sound
// //
-playBspSound - (id) playBspSound
{ {
[bspSound_i play]; [bspSound_i play];
return self; return self;
} }
// //
// Set the bspSound path // Set the bspSound path
// //
-setBspSoundPath:(const char *) path - (id) setBspSoundPath: (const char *)path
{ {
if (!path) if (!path)
path = ""; path = "";
@ -193,30 +195,32 @@ _atof (const char *c)
[bspSound_i release]; [bspSound_i release];
bspSound_i = nil; bspSound_i = nil;
} }
if (path[0] && access (path, R_OK)) if (path[0] && access (path, R_OK)) {
bspSound_i =[[NSSound alloc] initWithContentsOfFile: [NSString stringWithCString:bspSound] byReference: YES]; bspSound_i =
if (!bspSound_i) { [[NSSound alloc] initWithContentsOfFile: [NSString stringWithCString:
return self; bspSound] byReference: YES];
} }
if (!bspSound_i)
return self;
[bspSoundField_i setStringValue: [NSString stringWithCString:bspSound]]; [bspSoundField_i setStringValue: [NSString stringWithCString: bspSound]];
WriteStringDefault (prefs, "BspSoundPath", bspSound); WriteStringDefault (prefs, "BspSoundPath", bspSound);
return self; return self;
} }
//=============================================== // ===============================================
// Show BSP Output management // Show BSP Output management
//=============================================== // ===============================================
// //
// Set the state // Set the state
// //
-setShowBSP:(int) state - (id) setShowBSP: (int)state
{ {
showBSP = state; showBSP = state;
[showBSP_i setIntValue:state]; [showBSP_i setIntValue: state];
WriteNumericDefault (prefs, "ShowBSPOutput", showBSP); WriteNumericDefault (prefs, "ShowBSPOutput", showBSP);
return self; return self;
@ -225,23 +229,22 @@ _atof (const char *c)
// //
// Get the state // Get the state
// //
-(int) getShowBSP - (int) getShowBSP
{ {
return showBSP; return showBSP;
} }
// ===============================================
//===============================================
// "Offset Brush ..." management // "Offset Brush ..." management
//=============================================== // ===============================================
// //
// Set the state // Set the state
// //
-setBrushOffset:(int) state - (id) setBrushOffset: (int)state
{ {
brushOffset = state; brushOffset = state;
[brushOffset_i setIntValue:state]; [brushOffset_i setIntValue: state];
WriteNumericDefault (prefs, "OffsetBrushCopy", state); WriteNumericDefault (prefs, "OffsetBrushCopy", state);
return self; return self;
} }
@ -249,68 +252,67 @@ _atof (const char *c)
// //
// 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 selectCellAtRow: startwad column:0]; [startwad_i selectCellAtRow: startwad column: 0];
WriteNumericDefault (prefs, "StartWad", value); 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
// //
-setXlight:(float) value - (id) 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 (prefs, "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 (prefs, "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 (prefs, "Zlight", zlight); WriteNumericDefault (prefs, "Zlight", zlight);
return self; return self;
} }
@ -318,23 +320,21 @@ _atof (const char *c)
// //
// 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
@ -342,24 +342,23 @@ UIChanged
Grab all the current UI state Grab all the current UI state
============ ============
*/ */
-UIChanged:sender - (id) UIChanged: sender
{ {
Sys_Printf ("defaults updated\n"); Sys_Printf ("defaults updated\n");
[self setProjectPath:[[startproject_i stringValue] cString]]; [self setProjectPath: [[startproject_i stringValue] cString]];
[self setBspSoundPath:[[bspSoundField_i stringValue] cString]]; [self setBspSoundPath: [[bspSoundField_i stringValue] cString]];
[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]];
[self setXlight:[xlight_i floatValue]]; [self setXlight: [xlight_i floatValue]];
[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

@ -4,111 +4,114 @@
#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:NSObject @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) id mapList; // list of map names (Storage)
id descList; // list of map descriptions (Storage) id descList; // list of map descriptions (Storage)
id wadList; // list of wad names (Storage) id wadList; // list of wad names (Storage)
id pis_panel_i; // outlet to Project Info Settings id pis_panel_i; // outlet to Project Info Settings (PIS)
// (PIS) panel // panel
id pis_basepath_i; // outlet to PIS->base path id pis_basepath_i; // outlet to PIS->base path
id pis_wads_i; // outlet to PIS->wad browser id pis_wads_i; // outlet to PIS->wad browser
id pis_fullvis_i; // outlet to PIS->full vis command id pis_fullvis_i; // outlet to PIS->full vis command
id pis_fastvis_i; // outlet to PIS->fast vis command id pis_fastvis_i; // outlet to PIS->fast vis command
id pis_novis_i; // outlet to PIS->no vis command id pis_novis_i; // outlet to PIS->no vis command
id pis_relight_i; // outlet to PIS->relight command id pis_relight_i; // outlet to PIS->relight command
id pis_leaktest_i; // outlet to PIS->leak test command id pis_leaktest_i; // outlet to PIS->leak test command
id BSPoutput_i; // outlet to Text id BSPoutput_i; // outlet to Text
char path_projectinfo[128]; // path of QE_Project file char path_projectinfo[128]; // path of QE_Project file
char path_basepath[128]; // base path of heirarchy char path_basepath[128]; // base path of heirarchy
char path_progdir[128]; // derived from basepath char path_progdir[128]; // derived from basepath
char path_mapdirectory[128]; // derived from basepath char path_mapdirectory[128]; // derived from basepath
char path_finalmapdir[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_wad8[128]; // path of texture WAD for cmd-8 key
char path_wad9[128]; // path of texture WAD for cmd-9 key char path_wad9[128]; // path of texture WAD for cmd-9 key
char path_wad0[128]; // path of texture WAD for cmd-0 key char path_wad0[128]; // path of texture WAD for cmd-0 key
char string_fullvis[1024]; // cmd-line parm char string_fullvis[1024]; // cmd-line parm
char string_fastvis[1024]; // cmd-line parm char string_fastvis[1024]; // cmd-line parm
char string_novis[1024]; // cmd-line parm char string_novis[1024]; // cmd-line parm
char string_relight[1024]; // cmd-line parm char string_relight[1024]; // cmd-line parm
char string_leaktest[1024]; // cmd-line parm char string_leaktest[1024]; // cmd-line parm
char string_entities[1024]; // cmd-line parm char string_entities[1024]; // cmd-line parm
int showDescriptions; // 1 = show map descs in browser int showDescriptions; // 1 = show map descs in browser
time_t lastModified; // last time project file was modified time_t lastModified; // last time project file was modified
} }
-initProject; - (id) initProject;
-initVars; - (id) initVars;
-(const char *) currentProjectFile; - (const char *) currentProjectFile;
-setTextureWad:(const char *) wf; - (id) setTextureWad: (const char *)wf;
-addToOutput:(const 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; - (id) changeChar: (char)f
to: (char)t
in: (id)obj;
-(int) searchForString:(const char *) str in:(id) obj; - (int) searchForString: (const char *)str
in: (id)obj;
-parseProjectFile; // read defaultsdatabase for project - (id) parseProjectFile; // read defaultsdatabase for project path
// path - (id) openProjectFile: (const char *)path; // called by openProject, newProject
-openProjectFile:(const char *) path; // called by openProject and newProject - (id) openProject;
-openProject; - (id) clickedOnMap: sender; // called if clicked on map in browser
-clickedOnMap:sender; // called if clicked on map in browser - (id) clickedOnWad: sender; // called if clicked on wad in browser
-clickedOnWad:sender; // called if clicked on wad in browser
// methods to querie the project file //
// methods to query the project file
//
- (const char *) getMapDirectory;
- (const char *) getFinalMapDirectory;
- (const char *) getProgDirectory;
-(const char *) getMapDirectory; - (const char *) getWAD8;
-(const char *) getFinalMapDirectory; - (const char *) getWAD9;
-(const char *) getProgDirectory; - (const char *) getWAD0;
-(const char *) getWAD8; - (const char *) getFullVisCmd;
-(const char *) getWAD9; - (const char *) getFastVisCmd;
-(const char *) getWAD0; - (const char *) getNoVisCmd;
- (const char *) getRelightCmd;
- (const char *) getLeaktestCmd;
- (const char *) getEntitiesCmd;
-(const char *) getFullVisCmd; @end
-(const char *) getFastVisCmd;
-(const char *) getNoVisCmd;
-(const char *) getRelightCmd;
-(const char *) getLeaktestCmd;
-(const char *) getEntitiesCmd;
@end void
changeString (char cf, char ct, char *string);
void changeString (char cf, char ct, char *string);
#endif // Project_h #endif // Project_h

View file

@ -1,8 +1,8 @@
//====================================== // ======================================
// //
// QuakeEd Project Management // QuakeEd Project Management
// //
//====================================== // ======================================
#include <unistd.h> #include <unistd.h>
@ -18,28 +18,27 @@
#include "Things.h" #include "Things.h"
#include "TexturePalette.h" #include "TexturePalette.h"
id project_i;
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
{ {
const char *s; const char *s;
const char *pe; const char *pe;
char *ts; char *ts;
ts = strdup ([preferences_i getProjectPath]); ts = strdup ([preferences_i getProjectPath]);
pe = QFS_SkipPath (ts); pe = QFS_SkipPath (ts);
@ -50,68 +49,67 @@ id project_i;
strcat (path_progdir, SUBDIR_ENT); strcat (path_progdir, SUBDIR_ENT);
strcpy (path_mapdirectory, ts); strcpy (path_mapdirectory, ts);
strcat (path_mapdirectory, SUBDIR_MAPS); // source dir strcat (path_mapdirectory, SUBDIR_MAPS); // source dir
strcpy (path_finalmapdir, ts); strcpy (path_finalmapdir, ts);
strcat (path_finalmapdir, SUBDIR_MAPS); // dest dir strcat (path_finalmapdir, SUBDIR_MAPS); // dest dir
[basepathinfo_i setStringValue: [NSString stringWithCString:ts]]; // in Project Inspector
// in Project Inspector [basepathinfo_i setStringValue: [NSString stringWithCString: ts]];
#if 0 // FIXME: for "out-of-tree" projects #if 0 // FIXME: for "out-of-tree" projects ?
if ((s =[projectInfo getStringFor:BASEPATHKEY])) { if ((s = [projectInfo getStringFor: BASEPATHKEY])) {
strcpy (path_basepath, s); strcpy (path_basepath, s);
strcpy (path_progdir, s); strcpy (path_progdir, s);
strcat (path_progdir, "/" SUBDIR_ENT); strcat (path_progdir, "/" SUBDIR_ENT);
strcpy (path_mapdirectory, s); strcpy (path_mapdirectory, s);
strcat (path_mapdirectory, "/" SUBDIR_MAPS); // source dir strcat (path_mapdirectory, "/" SUBDIR_MAPS); // source dir
strcpy (path_finalmapdir, s); strcpy (path_finalmapdir, s);
strcat (path_finalmapdir, "/" SUBDIR_MAPS); // dest dir strcat (path_finalmapdir, "/" SUBDIR_MAPS); // dest dir
[basepathinfo_i setStringValue:s]; [basepathinfo_i setStringValue: s]; // in Project Inspector
// in Project Inspector
} }
#endif #endif
if ((s =[projectInfo getStringFor:BSPFULLVIS])) { if ((s = [projectInfo getStringFor: BSPFULLVIS])) {
strcpy (string_fullvis, s); strcpy (string_fullvis, s);
changeString ('@', '\"', string_fullvis); changeString ('@', '\"', string_fullvis);
} }
if ((s =[projectInfo getStringFor:BSPFASTVIS])) { if ((s = [projectInfo getStringFor: BSPFASTVIS])) {
strcpy (string_fastvis, s); strcpy (string_fastvis, s);
changeString ('@', '\"', string_fastvis); changeString ('@', '\"', string_fastvis);
} }
if ((s =[projectInfo getStringFor:BSPNOVIS])) { if ((s = [projectInfo getStringFor: BSPNOVIS])) {
strcpy (string_novis, s); strcpy (string_novis, s);
changeString ('@', '\"', string_novis); changeString ('@', '\"', string_novis);
} }
if ((s =[projectInfo getStringFor:BSPRELIGHT])) { if ((s = [projectInfo getStringFor: BSPRELIGHT])) {
strcpy (string_relight, s); strcpy (string_relight, s);
changeString ('@', '\"', string_relight); changeString ('@', '\"', string_relight);
} }
if ((s =[projectInfo getStringFor:BSPLEAKTEST])) { if ((s = [projectInfo getStringFor: BSPLEAKTEST])) {
strcpy (string_leaktest, s); strcpy (string_leaktest, s);
changeString ('@', '\"', string_leaktest); changeString ('@', '\"', string_leaktest);
} }
if ((s =[projectInfo getStringFor:BSPENTITIES])) { if ((s = [projectInfo getStringFor: BSPENTITIES])) {
strcpy (string_entities, s); strcpy (string_entities, s);
changeString ('@', '\"', string_entities); changeString ('@', '\"', string_entities);
} }
// Build list of wads // Build list of wads
wadList =[projectInfo parseMultipleFrom:WADSKEY]; wadList = [projectInfo parseMultipleFrom: WADSKEY];
// Build list of maps & descriptions // Build list of maps & descriptions
mapList =[projectInfo parseMultipleFrom:MAPNAMESKEY]; mapList = [projectInfo parseMultipleFrom: MAPNAMESKEY];
descList =[projectInfo parseMultipleFrom:DESCKEY]; descList = [projectInfo parseMultipleFrom: DESCKEY];
[self changeChar: '_' to: ' ' in:descList]; [self changeChar: '_' to: ' ' in: descList];
[self initProjSettings]; [self initProjSettings];
@ -121,14 +119,14 @@ id project_i;
// //
// Init Project Settings fields // Init Project Settings fields
// //
-initProjSettings - (id) initProjSettings
{ {
[pis_basepath_i setStringValue: [NSString stringWithCString:path_basepath]]; [pis_basepath_i setStringValue: [NSString stringWithCString: path_basepath]];
[pis_fullvis_i setStringValue: [NSString stringWithCString:string_fullvis]]; [pis_fullvis_i setStringValue: [NSString stringWithCString: string_fullvis]];
[pis_fastvis_i setStringValue: [NSString stringWithCString:string_fastvis]]; [pis_fastvis_i setStringValue: [NSString stringWithCString: string_fastvis]];
[pis_novis_i setStringValue: [NSString stringWithCString:string_novis]]; [pis_novis_i setStringValue: [NSString stringWithCString: string_novis]];
[pis_relight_i setStringValue: [NSString stringWithCString:string_relight]]; [pis_relight_i setStringValue: [NSString stringWithCString: string_relight]];
[pis_leaktest_i setStringValue: [NSString stringWithCString:string_leaktest]]; [pis_leaktest_i setStringValue: [NSString stringWithCString: string_leaktest]];
return self; return self;
} }
@ -136,46 +134,46 @@ id project_i;
// //
// Add text to the BSP Output window // Add text to the BSP Output window
// //
-addToOutput:(const char *) string - (id) addToOutput: (const char *)string
{ {
int end; int end;
end =[BSPoutput_i textLength]; end = [BSPoutput_i textLength];
[BSPoutput_i replaceCharactersInRange: NSMakeRange (end, 0) withString: [NSString stringWithCString:string]]; [BSPoutput_i replaceCharactersInRange: NSMakeRange (end, 0)
withString: [NSString stringWithCString: string]];
end =[BSPoutput_i textLength]; end = [BSPoutput_i textLength];
[BSPoutput_i setSelectedRange:NSMakeRange (end, 0)]; [BSPoutput_i setSelectedRange: NSMakeRange (end, 0)];
// XXX [BSPoutput_i scrollSelToVisible]; // XXX [BSPoutput_i scrollSelToVisible];
return self; return self;
} }
-clearBspOutput:sender - (id) clearBspOutput: sender
{ {
int end; int end;
end =[BSPoutput_i textLength]; end = [BSPoutput_i textLength];
[BSPoutput_i replaceCharactersInRange: NSMakeRange (0, end) withString:@""]; [BSPoutput_i replaceCharactersInRange: NSMakeRange (0, end) withString: @""];
return self; return self;
} }
-print - (id) print
{ {
// XXX [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 setReusesColumns:YES]; [mapbrowse_i setReusesColumns: YES];
[mapbrowse_i loadColumnZero]; [mapbrowse_i loadColumnZero];
[pis_wads_i setReusesColumns:YES]; [pis_wads_i setReusesColumns: YES];
[pis_wads_i loadColumnZero]; [pis_wads_i loadColumnZero];
[things_i initEntities]; [things_i initEntities];
@ -186,15 +184,15 @@ id project_i;
// //
// Change a character to another in a Storage list of strings // Change a character to another in a Storage list of strings
// //
-changeChar:(char) f to:(char) t in:(id) obj - (id) changeChar: (char)f to: (char)t in: (id)obj
{ {
int i; int i;
int max; int max;
char *string; char *string;
max =[obj count]; max = [obj count];
for (i = 0; i < max; i++) { for (i = 0; i < max; i++) {
string =[obj elementAt:i]; string = [obj elementAt: i];
changeString (f, t, string); changeString (f, t, string);
} }
return self; return self;
@ -204,56 +202,56 @@ id project_i;
// Fill the QuakeEd Maps or wads browser // Fill the QuakeEd Maps or wads browser
// (Delegate method - delegated in Interface Builder) // (Delegate method - delegated in Interface Builder)
// //
-(void) browser: sender createRowsForColumn:(int) column inMatrix: matrix - (void) browser: sender createRowsForColumn: (int)column inMatrix: matrix
{ {
id cell, list; id cell, list;
int max; int max;
char *name; char *name;
int i; int i;
if (sender == mapbrowse_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 = nil; list = nil;
Sys_Error ("Project: unknown browser to fill"); Sys_Error ("Project: unknown browser to fill");
} }
max =[list count]; max = [list count];
for (i = 0; i < max; i++) { for (i = 0; i < max; i++) {
name =[list elementAt:i]; name = [list elementAt: i];
[matrix addRow]; [matrix addRow];
cell =[matrix cellAtRow: i column:0]; cell = [matrix cellAtRow: i column: 0];
[cell setStringValue: [NSString stringWithCString:name]]; [cell setStringValue: [NSString stringWithCString: name]];
[cell setLeaf:YES]; [cell setLeaf: YES];
[cell setLoaded:YES]; [cell setLoaded: YES];
} }
} }
// //
// Clicked on a map name or description! // Clicked on a map name or description!
// //
-clickedOnMap:sender - (id) clickedOnMap: sender
{ {
id matrix; id matrix;
int row; int row;
const char *fname; const char *fname;
id panel; id panel;
NSModalSession session; NSModalSession session;
matrix =[sender matrixInColumn:0]; matrix = [sender matrixInColumn: 0];
row =[matrix selectedRow]; row = [matrix selectedRow];
fname = va ("%s/%s.map", path_mapdirectory, fname = va ("%s/%s.map", path_mapdirectory,
(const char *) [mapList elementAt:row]); //XXX Storage (const char *) [mapList elementAt: row]); // XXX Storage
panel = NSGetAlertPanel (@"Loading...", panel = NSGetAlertPanel (@"Loading...",
@"Loading map. Please wait.", NULL, NULL, NULL); @"Loading map. Please wait.", NULL, NULL, NULL);
session = [NSApp beginModalSessionForWindow: panel]; session = [NSApp beginModalSessionForWindow: panel];
[NSApp runModalSession: session]; [NSApp runModalSession: session];
[quakeed_i doOpen:fname]; [quakeed_i doOpen: fname];
[NSApp endModalSession: session]; [NSApp endModalSession: session];
[panel close]; [panel close];
@ -261,27 +259,26 @@ id project_i;
return self; return self;
} }
- (id) setTextureWad: (const char *)wf
-setTextureWad:(const char *) wf
{ {
int i, c; int i, c;
const char *name; const char *name;
Sys_Printf ("loading %s\n", wf); Sys_Printf ("loading %s\n", wf);
// set the row in the settings inspector wad browser // set the row in the settings inspector wad browser
c =[wadList count]; c = [wadList count];
for (i = 0; i < c; i++) { for (i = 0; i < c; i++) {
name = (const char *)[wadList elementAt:i]; // XXX Storage name = (const char *) [wadList elementAt: i]; // XXX Storage
if (!strcmp (name, wf)) { if (!strcmp (name, wf)) {
[[pis_wads_i matrixInColumn: 0] selectCellAtRow: i column: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 objectAtIndex: 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];
@ -292,53 +289,54 @@ id project_i;
// //
// Clicked on a wad name // Clicked on a wad name
// //
-clickedOnWad:sender - (id) clickedOnWad: sender
{ {
id matrix; id matrix;
int row; int row;
char *name; char *name;
matrix =[sender matrixInColumn:0]; matrix = [sender matrixInColumn: 0];
row =[matrix selectedRow]; row = [matrix selectedRow];
name = (char *)[wadList elementAt:row]; // XXX Storage name = (char *) [wadList elementAt: row]; // XXX Storage
[self setTextureWad:name]; [self setTextureWad: name];
return self; return self;
} }
// //
// Read in the <name>.QE_Project file // Read in the <name>.QE_Project file
// //
-parseProjectFile - (id) parseProjectFile
{ {
const char *path; const char *path;
int rtn; int rtn;
path =[preferences_i getProjectPath]; path = [preferences_i getProjectPath];
if (!path || !path[0] || access (path, 0)) { if (!path || !path[0] || access (path, 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) // can't run without a project while (1)
[NSApp terminate:self]; [NSApp terminate: self]; // can't run without a project
}
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
// //
-openProjectFile:(const char *) path - (id) openProjectFile: (const char *)path
{ {
FILE *fp; FILE *fp;
struct stat s; struct stat s;
Sys_Printf ("openProjectFile: %s\n", path);
Sys_Printf ("openProjectFile: %s\n", path);
strcpy (path_projectinfo, path); strcpy (path_projectinfo, path);
projectInfo = NULL; projectInfo = NULL;
@ -349,13 +347,13 @@ Sys_Printf ("openProjectFile: %s\n", path);
stat (path, &s); stat (path, &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;
} }
-(const char *) currentProjectFile - (const char *) currentProjectFile
{ {
return path_projectinfo; return path_projectinfo;
} }
@ -363,167 +361,177 @@ Sys_Printf ("openProjectFile: %s\n", path);
// //
// Open a project file // Open a project file
// //
-openProject - (id) openProject
{ {
const char *path; const char *path;
id openpanel; id openpanel;
int rtn; int rtn;
NSString *projtypes[] = { @"qpr" }; NSString *projtypes[] = {@"qpr"};
NSArray *filenames; NSArray *filenames;
const char *dir; const char *dir;
openpanel =[NSOpenPanel new]; openpanel = [NSOpenPanel new];
// [openpanel allowMultipleFiles:NO]; // [openpanel allowMultipleFiles:NO];
// [openpanel chooseDirectories:NO]; // [openpanel chooseDirectories:NO];
rtn =[openpanel runModalForTypes: [NSArray arrayWithObjects: projtypes count:1]]; rtn = [openpanel runModalForTypes: [NSArray arrayWithObjects: projtypes
count: 1]];
if (rtn == NSOKButton) { if (rtn == NSOKButton) {
filenames =[openpanel filenames]; filenames = [openpanel filenames];
dir =[[openpanel directory] cString]; dir = [[openpanel directory] cString];
dir = ""; dir = "";
path = va ("%s/%s", dir,[[filenames objectAtIndex:0] cString]); path = va ("%s/%s", dir, [[filenames objectAtIndex: 0] cString]);
strcpy (path_projectinfo, path); strcpy (path_projectinfo, path);
[self openProjectFile:path]; [self openProjectFile: path];
return self; return self;
} }
return nil; return nil;
} }
// //
// Search for a string in a List of strings // Search for a string in a List of strings
// //
-(int) searchForString:(const char *) str in:(id) obj - (int) searchForString: (const char *)str in: (id)obj
{ {
int i; int i;
int max; int max;
const char *s; const char *s;
max =[obj count]; max = [obj count];
for (i = 0; i < max; i++) { for (i = 0; i < max; i++) {
s = (const char *)[obj elementAt:i]; // XXX Storage? s = (const char *) [obj elementAt: i]; // XXX Storage?
if (!strcmp (s, str)) if (!strcmp (s, str))
return 1; return 1;
} }
return 0; return 0;
} }
-(const char *) getMapDirectory - (const char *) getMapDirectory
{ {
return path_mapdirectory; return path_mapdirectory;
} }
-(const char *) getFinalMapDirectory - (const char *) getFinalMapDirectory
{ {
return path_finalmapdir; return path_finalmapdir;
} }
-(const char *) getProgDirectory - (const char *) getProgDirectory
{ {
return path_progdir; return path_progdir;
} }
// //
// Return the WAD name for cmd-8 // Return the WAD name for cmd-8
// //
-(const char *) getWAD8 - (const 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 - (const 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 - (const 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 - (const 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 - (const 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 - (const 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 - (const 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 - (const char *) getLeaktestCmd
{ {
if (!string_leaktest[0]) if (!string_leaktest[0])
return NULL; return NULL;
return string_leaktest; return string_leaktest;
} }
-(const 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 // C Functions
//==================================================== // ====================================================
// //
// Change a character to a different char in a string // Change a character to a different char in a string
// //
void void
changeString (char cf, char ct, char *string) changeString (char cf, char ct, char *string)
{ {
unsigned int j; unsigned int j;
for (j = 0; j < strlen (string); j++) for (j = 0; j < strlen (string); j++) {
if (string[j] == cf) if (string[j] == cf)
string[j] = ct; string[j] = ct;
}
} }

View file

@ -3,106 +3,108 @@
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
extern id quakeed_i; extern id quakeed_i;
extern BOOL filter_light, filter_path, filter_entities; extern BOOL filter_light, filter_path, filter_entities;
extern BOOL filter_clip_brushes, filter_water_brushes, filter_world; 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);
@interface QuakeEd:NSWindow @interface QuakeEd: NSWindow
{ {
BOOL dirty; BOOL dirty;
char filename[1024]; // full path with .map extension char filename[1024]; // full path with .map extension
NSBitmapImageRep *cache[3]; NSBitmapImageRep *cache[3];
NSRect cache_rect[3]; NSRect cache_rect[3];
BOOL no_restore[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;
-(const char *) currentFilename; - (const char *) 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;
-(void)cameraNoRestore: (NSRect) rect; - (void) cameraNoRestore: (NSRect)rect;
-(void)xyNoRestore: (NSRect) rect; - (void) xyNoRestore: (NSRect)rect;
-(void)zNoRestore: (NSRect) rect; - (void) zNoRestore: (NSRect)rect;
-newinstance; // force next flushwindow to clear all - (id) newinstance; // force next flushwindow to clear all
// instance drawing // instance drawing
-redrawInstance; // erase and redraw all instance now - (id) redrawInstance; // erase and redraw all instance now
-appWillTerminate:sender; - (id) appWillTerminate: sender;
-openProject:sender; - (id) openProject: sender;
-textCommand:sender; - (id) textCommand: sender;
-applyRegion:sender; - (id) applyRegion: sender;
-(BOOL) dirty; - (BOOL) dirty;
-clear:sender; - (id) clear: sender;
-centerCamera:sender; - (id) centerCamera: sender;
-centerZChecker:sender; - (id) centerZChecker: sender;
-changeXYLookUp:sender; - (id) changeXYLookUp: sender;
-setBrushRegion:sender; - (id) setBrushRegion: sender;
-setXYRegion:sender; - (id) setXYRegion: sender;
-open:sender; - (id) open: sender;
-save:sender; - (id) save: sender;
-saveAs:sender; - (id) saveAs: sender;
-doOpen:(const char *) fname; - (id) doOpen: (const char *)fname;
-saveBSP:(const char *)cmdline dialog:(BOOL)wt; - (id) saveBSP: (const char *)cmdline dialog: (BOOL)wt;
-BSP_Full:sender; - (id) BSP_Full: sender;
-BSP_FastVis:sender; - (id) BSP_FastVis: sender;
-BSP_NoVis:sender; - (id) BSP_NoVis: sender;
-BSP_relight:sender; - (id) BSP_relight: sender;
-BSP_stop:sender; - (id) BSP_stop: sender;
-BSP_entities:sender; - (id) BSP_entities: sender;
-applicationDefined:(NSEvent *) theEvent; - (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 #endif // QuakeEd_h

File diff suppressed because it is too large Load diff

View file

@ -4,19 +4,18 @@
#include "QuakeEd.h" #include "QuakeEd.h"
@interface QuakeEdApp:NSApplication @interface QuakeEdApp: NSApplication
-(void)sendEvent:(NSEvent *) evt; - (void) sendEvent: (NSEvent *)evt;
@end @end
@implementation QuakeEdApp @implementation QuakeEdApp
-(void)sendEvent:(NSEvent *) evt; - (void) sendEvent: (NSEvent *)evt;
{ {
if ([evt type] == NSApplicationDefined) { if ([evt type] == NSApplicationDefined)
[quakeed_i applicationDefined: evt]; [quakeed_i applicationDefined: evt];
} else { else
[super sendEvent:evt]; [super sendEvent: evt];
}
} }
@end @end

View file

@ -7,96 +7,96 @@
#include "TexturePalette.h" #include "TexturePalette.h"
#define MAX_FACES 16 #define MAX_FACES 16
typedef struct { typedef struct {
int numpoints; int numpoints;
vec5_t points[8]; // variable sized 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_BACK 1
#define SIDE_ON 2
#define SIDE_FRONT 0
#define SIDE_BACK 1
#define SIDE_ON 2
winding_t *ClipWinding (winding_t * in, plane_t *split); winding_t *ClipWinding (winding_t * in, plane_t *split);
winding_t *CopyWinding (winding_t * w); winding_t *CopyWinding (winding_t * w);
winding_t *NewWinding (int points); winding_t *NewWinding (int points);
@interface SetBrush: NSObject
@interface SetBrush:NSObject
{ {
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 - (SetBrush *) initOwner: (id)own
texture:(texturedef_t *)tex; mins: (float *)mins
maxs: (float *)maxs
texture: (texturedef_t *)tex;
-initFromScript:(struct script_s *)script owner:own; - (id) initFromScript: (struct script_s *)script
owner: (id)own;
-setMins:(float *)mins maxs:(float *)maxs; - (id) setMins: (float *)mins maxs: (float *)maxs;
-parent; - (id) parent;
-setParent:(id) p; - (id) setParent: (id)p;
-setEntityColor:(vec3_t) color; - (id) setEntityColor: (vec3_t)color;
-calcWindings; - (id) calcWindings;
- (void) writeToFILE:(FILE *)f region:(BOOL)reg; - (void) writeToFILE: (FILE *)f region: (BOOL)reg;
-(BOOL) selected; - (BOOL) selected;
-(BOOL) regioned; - (BOOL) regioned;
- (void) setSelected: (BOOL)s; - (void) setSelected: (BOOL)s;
- (void) setRegioned: (BOOL)s; - (void) setRegioned: (BOOL)s;
- (void) getMins: (vec3_t)mins maxs: (vec3_t)maxs; - (void) getMins: (vec3_t)mins maxs: (vec3_t)maxs;
-(BOOL) containsPoint:(vec3_t) pt; - (BOOL) containsPoint: (vec3_t)pt;
- (void) freeWindings; - (void) freeWindings;
-removeIfInvalid; - (id) removeIfInvalid;
extern vec3_t region_min, region_max; extern vec3_t region_min, region_max;
-newRegion; - (id) newRegion;
-(texturedef_t *) texturedef; - (texturedef_t *) texturedef;
-(texturedef_t *) texturedefForFace:(int) f; - (texturedef_t *) texturedefForFace: (int)f;
- (void) setTexturedef:(texturedef_t *) tex; - (void) setTexturedef: (texturedef_t *)tex;
- (void) setTexturedef:(texturedef_t *) tex forFace:(int) f; - (void) setTexturedef: (texturedef_t *)tex forFace: (int)f;
- (void) XYDrawSelf; - (void) XYDrawSelf;
- (void) ZDrawSelf; - (void) ZDrawSelf;
@ -109,59 +109,59 @@ extern vec3_t region_min, region_max;
// //
// single brush actions // single brush actions
// //
extern int numcontrolpoints; extern int numcontrolpoints;
extern float *controlpoints[MAX_FACES * 3]; extern float *controlpoints[MAX_FACES * 3];
- (void) getZdragface: (vec3_t)dragpoint; - (void) getZdragface: (vec3_t)dragpoint;
- (void) getXYdragface: (vec3_t)dragpoint; - (void) getXYdragface: (vec3_t)dragpoint;
- (void) getXYShearPoints: (vec3_t)dragpoint; - (void) getXYShearPoints: (vec3_t)dragpoint;
-addFace:(face_t *) f; - (id) addFace: (face_t *)f;
// //
// multiple brush actions // multiple brush actions
// //
- (void) carveByClipper; - (void) carveByClipper;
extern vec3_t sb_translate; extern vec3_t sb_translate;
- (void) translate; - (void) translate;
extern id carve_in, carve_out; extern id carve_in, carve_out;
- (void) select; - (void) select;
- (void) deselect; - (void) deselect;
- (void) remove; - (void) remove;
- (void) flushTextures; - (void) flushTextures;
extern vec3_t sb_mins, sb_maxs; extern vec3_t sb_mins, sb_maxs;
- (void) addToBBox; - (void) addToBBox;
extern vec3_t sel_x, sel_y, sel_z; extern vec3_t sel_x, sel_y, sel_z;
extern vec3_t sel_org; extern vec3_t sel_org;
- (void) transform; - (void) transform;
- (void) flipNormals; - (void) flipNormals;
-carve; - (id) carve;
- (void) setCarveVars; - (void) setCarveVars;
extern id sb_newowner; extern id sb_newowner;
- (void) moveToEntity; - (void) moveToEntity;
- (void) takeCurrentTexture; - (void) takeCurrentTexture;
extern vec3_t select_min, select_max; extern vec3_t select_min, select_max;
- (void) selectPartial; - (void) selectPartial;
- (void) selectComplete; - (void) selectComplete;
- (void) regionPartial; - (void) regionPartial;
- (void) regionComplete; - (void) regionComplete;
extern float sb_floor_dir, sb_floor_dist; extern float sb_floor_dir, sb_floor_dist;
- (void) feetToFloor; - (void) feetToFloor;

File diff suppressed because it is too large Load diff

View file

@ -10,7 +10,7 @@
modify it under the terms of the GNU Library General Public modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version. version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@ -31,47 +31,50 @@
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
@interface Storage:NSObject @interface Storage: NSObject
{ {
@public void *dataPtr; /* data of the Storage object */ @public
const char *description; /* Element description */ void *dataPtr; /* data of the Storage object */
NSUInteger numElements; /* Actual number of elements */ const char *description; /* Element description */
NSUInteger maxElements; /* Total allocated elements */ NSUInteger numElements; /* Actual number of elements */
NSUInteger elementSize; /* Element size */ NSUInteger maxElements; /* Total allocated elements */
NSUInteger elementSize; /* Element size */
} }
/* Creating, freeing, initializing, and emptying */ /* Creating, freeing, initializing, and emptying */
-init; - (id) init;
-initCount:(NSUInteger) numSlots elementSize:(NSUInteger) sizeInBytes - (id) initCount: (NSUInteger)numSlots
description:(const char *) elemDesc; elementSize: (NSUInteger)sizeInBytes
-(void) dealloc; description: (const char *)elemDesc;
-empty; - (void) dealloc;
-copy; - (id) empty;
- (id) copy;
/* Manipulating the elements */ /* Manipulating the elements */
-(BOOL) isEqual:anObject; - (BOOL) isEqual: anObject;
-(const char *) description; - (const char *) description;
-(NSUInteger) count; - (NSUInteger) count;
-(void *) elementAt:(NSUInteger) index; - (void *) elementAt: (NSUInteger)index;
-replaceElementAt:(NSUInteger) index with:(void *) anElement; - (id) replaceElementAt: (NSUInteger)index
with: (void *)anElement;
-setNumSlots:(NSUInteger) numSlots;
-setAvailableCapacity:(NSUInteger) numSlots;
-addElement:(void *) anElement;
-removeLastElement;
-insertElement:(void *) anElement at:(NSUInteger) index;
-removeElementAt:(NSUInteger) index;
- (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 */ /* old-style creation */
+new; + (id) new;
+newCount:(NSUInteger) count elementSize:(NSUInteger) sizeInBytes + (id) newCount: (NSUInteger)count
description:(const char *) descriptor; elementSize: (NSUInteger)sizeInBytes
description: (const char *)descriptor;
@end @end
@ -79,5 +82,4 @@ typedef struct {
@defs (Storage) @defs (Storage)
} NXStorageId; } NXStorageId;
#endif /* __Storage_h_INCLUDE_GNU */ #endif /* __Storage_h_INCLUDE_GNU */

View file

@ -1,24 +1,24 @@
/* Implementation of Objective C NeXT-compatible Storage object /* Implementation of Objective C NeXT-compatible Storage object
Copyright (C) 1993,1994, 1996 Free Software Foundation, Inc. Copyright (C) 1993,1994, 1996 Free Software Foundation, Inc.
Written by: Kresten Krab Thorup <krab@iesd.auc.dk> Written by: Kresten Krab Thorup <krab@iesd.auc.dk>
Dept. of Mathematics and Computer Science, Aalborg U., Denmark Dept. of Mathematics and Computer Science, Aalborg U., Denmark
This file is part of the GNUstep Base Library. This file is part of the GNUstep Base Library.
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version. 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 This library is distributed in the hope that it will be useful,
License along with this library; if not, write to the Free but WITHOUT ANY WARRANTY; without even the implied warranty of
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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 <config.h> */
@ -26,29 +26,29 @@
#include <string.h> #include <string.h>
#include <strings.h> #include <strings.h>
#define GNU_STORAGE_NTH(x, N) \
#define GNU_STORAGE_NTH(x,N) \ ({GNUStorageId* __s = (GNUStorageId*) (x); \
({ GNUStorageId* __s=(GNUStorageId*)(x); \ (void*) (((char*) __s->dataPtr) + (__s->elementSize * (N))); })
(void*)(((char*)__s->dataPtr)+(__s->elementSize*(N))); })
#define STORAGE_NTH(N) GNU_STORAGE_NTH (self, N) #define STORAGE_NTH(N) GNU_STORAGE_NTH (self, N)
typedef struct { typedef struct {
@defs (Storage) @defs (Storage)
} GNUStorageId; } GNUStorageId;
@implementation Storage @implementation Storage
+initialize + (id) initialize
{ {
if (self ==[Storage class]) if (self == [Storage class])
[self setVersion:0]; /* beta release */ [self setVersion: 0]; /* beta release */
return self; return self;
} }
// INITIALIZING, FREEING; // INITIALIZING, FREEING;
-initCount: (NSUInteger) numSlots elementSize: (NSUInteger) sizeInBytes description:(const char *) - (id) initCount: (NSUInteger)numSlots elementSize: (NSUInteger)sizeInBytes
elemDesc; description: (const char *)
elemDesc;
{ {
[super init]; [super init];
numElements = numSlots; numElements = numSlots;
@ -60,31 +60,29 @@ typedef struct {
return self; return self;
} }
-init - (id) init
{ {
return[self initCount: 1 elementSize:sizeof (id) return [self initCount: 1 elementSize: sizeof (id)
description:@encode (id)]; description: @encode (id)];
} }
- (void) dealloc
-(void) dealloc
{ {
if (dataPtr) if (dataPtr)
free (dataPtr); free (dataPtr);
[super dealloc]; [super dealloc];
} }
-(const char *) description - (const char *) description
{ {
return description; return description;
} }
// COPYING; // COPYING;
-copy - (id) copy
{ {
Storage *c =[super copy]; Storage *c = [super copy];
c->dataPtr = (void *) objc_malloc (maxElements * elementSize); c->dataPtr = (void *) objc_malloc (maxElements * elementSize);
memcpy (c->dataPtr, dataPtr, numElements * elementSize); memcpy (c->dataPtr, dataPtr, numElements * elementSize);
@ -93,12 +91,12 @@ typedef struct {
// COMPARING TWO STORAGES; // COMPARING TWO STORAGES;
-(BOOL) isEqual:anObject - (BOOL) isEqual: anObject
{ {
if ([anObject isKindOfClass:[Storage class]] if ([anObject isKindOfClass: [Storage class]]
&&[anObject count] ==[self count] && [anObject count] == [self count]
&& !memcmp (((GNUStorageId *) anObject)->dataPtr, && !memcmp (((GNUStorageId *) anObject)->dataPtr,
dataPtr, numElements * elementSize)) dataPtr, numElements * elementSize))
return YES; return YES;
else else
return NO; return NO;
@ -112,7 +110,8 @@ _makeRoomForAnotherIfNecessary (Storage * self)
if (self->numElements == self->maxElements) { if (self->numElements == self->maxElements) {
self->maxElements *= 2; self->maxElements *= 2;
self->dataPtr = (void *) self->dataPtr = (void *)
objc_realloc (self->dataPtr, self->maxElements * self->elementSize); objc_realloc (self->dataPtr,
self->maxElements * self->elementSize);
} }
} }
@ -122,11 +121,12 @@ _shrinkIfDesired (Storage * self)
if (self->numElements < (self->maxElements / 2)) { if (self->numElements < (self->maxElements / 2)) {
self->maxElements /= 2; self->maxElements /= 2;
self->dataPtr = (void *) self->dataPtr = (void *)
objc_realloc (self->dataPtr, self->maxElements * self->elementSize); objc_realloc (self->dataPtr,
self->maxElements * self->elementSize);
} }
} }
-setAvailableCapacity:(NSUInteger) numSlots - (id) setAvailableCapacity: (NSUInteger)numSlots
{ {
if (numSlots > numElements) { if (numSlots > numElements) {
maxElements = numSlots; maxElements = numSlots;
@ -135,13 +135,13 @@ _shrinkIfDesired (Storage * self)
return self; return self;
} }
-setNumSlots:(NSUInteger) numSlots - (id) setNumSlots: (NSUInteger)numSlots
{ {
if (numSlots > numElements) { if (numSlots > numElements) {
maxElements = numSlots; maxElements = numSlots;
dataPtr = (void *) objc_realloc (dataPtr, maxElements * elementSize); dataPtr = (void *) objc_realloc (dataPtr, maxElements * elementSize);
bzero (STORAGE_NTH (numElements), bzero (STORAGE_NTH (numElements),
(maxElements - numElements) * elementSize); (maxElements - numElements) * elementSize);
} else if (numSlots < numElements) { } else if (numSlots < numElements) {
numElements = numSlots; numElements = numSlots;
_shrinkIfDesired (self); _shrinkIfDesired (self);
@ -151,20 +151,20 @@ _shrinkIfDesired (Storage * self)
/* Manipulating objects by index */ /* Manipulating objects by index */
#define CHECK_INDEX(IND) if (IND >= numElements) return 0 #define CHECK_INDEX(IND) if (IND >= numElements) return 0
-(NSUInteger) count - (NSUInteger) count
{ {
return numElements; return numElements;
} }
-(void *) elementAt:(NSUInteger) index - (void *) elementAt: (NSUInteger)index
{ {
CHECK_INDEX (index); CHECK_INDEX (index);
return STORAGE_NTH (index); return STORAGE_NTH (index);
} }
-addElement:(void *) anElement - (id) addElement: (void *)anElement
{ {
_makeRoomForAnotherIfNecessary (self); _makeRoomForAnotherIfNecessary (self);
memcpy (STORAGE_NTH (numElements), anElement, elementSize); memcpy (STORAGE_NTH (numElements), anElement, elementSize);
@ -172,43 +172,45 @@ _shrinkIfDesired (Storage * self)
return self; return self;
} }
-insertElement:(void *) - (id) insertElement: (void *)
anElement at:(NSUInteger) index anElement at: (NSUInteger)index
{ {
NSUInteger i; NSUInteger i;
CHECK_INDEX (index); CHECK_INDEX (index);
_makeRoomForAnotherIfNecessary (self); _makeRoomForAnotherIfNecessary (self);
#ifndef STABLE_MEMCPY #ifndef STABLE_MEMCPY
for (i = numElements; i >= index; i--) for (i = numElements; i >= index; i--)
memcpy (STORAGE_NTH (i + 1), STORAGE_NTH (i), elementSize); memcpy (STORAGE_NTH (i + 1), STORAGE_NTH (i), elementSize);
#else #else
memcpy (STORAGE_NTH (index + 1), memcpy (STORAGE_NTH (index + 1),
STORAGE_NTH (index), elementSize * (numElements - index)); STORAGE_NTH (index), elementSize * (numElements - index));
#endif #endif
memcpy (STORAGE_NTH (i), anElement, elementSize); memcpy (STORAGE_NTH (i), anElement, elementSize);
numElements++; numElements++;
return self; return self;
} }
-removeElementAt:(NSUInteger) index - (id) removeElementAt: (NSUInteger)index
{ {
NSUInteger i; NSUInteger i;
CHECK_INDEX (index); CHECK_INDEX (index);
numElements--; numElements--;
#ifndef STABLE_MEMCPY #ifndef STABLE_MEMCPY
for (i = index; i < numElements; i++) for (i = index; i < numElements; i++)
memcpy (STORAGE_NTH (i), STORAGE_NTH (i + 1), elementSize); memcpy (STORAGE_NTH (i), STORAGE_NTH (i + 1), elementSize);
#else #else
memcpy (STORAGE_NTH (index), memcpy (STORAGE_NTH (index),
STORAGE_NTH (index + 1), elementSize * (numElements - index - 1)); STORAGE_NTH (index + 1), elementSize * (numElements - index - 1));
#endif #endif
_shrinkIfDesired (self); _shrinkIfDesired (self);
return self; return self;
} }
-removeLastElement - (id) removeLastElement
{ {
if (numElements) { if (numElements) {
numElements--; numElements--;
@ -217,8 +219,8 @@ anElement at:(NSUInteger) index
return self; return self;
} }
-replaceElementAt:(NSUInteger) - (id) replaceElementAt: (NSUInteger)
index with:(void *) newElement index with: (void *)newElement
{ {
CHECK_INDEX (index); CHECK_INDEX (index);
memcpy (STORAGE_NTH (index), newElement, elementSize); memcpy (STORAGE_NTH (index), newElement, elementSize);
@ -227,7 +229,7 @@ index with:(void *) newElement
/* Emptying the Storage */ /* Emptying the Storage */
-empty - (id) empty
{ {
numElements = 0; numElements = 0;
maxElements = 1; maxElements = 1;
@ -235,16 +237,17 @@ index with:(void *) newElement
return self; return self;
} }
+new + (id) new
{ {
return[[self alloc] init]; return [[self alloc] init];
} }
+newCount:(NSUInteger) + (id) newCount: (NSUInteger)
count elementSize:(NSUInteger) sizeInBytes count elementSize: (NSUInteger)sizeInBytes
description:(const char *) descriptor description: (const char *)descriptor
{ {
return[[self alloc] initCount: count elementSize: sizeInBytes description:descriptor]; return [[self alloc] initCount: count elementSize: sizeInBytes description:
descriptor];
} }
@end @end

View file

@ -5,110 +5,109 @@
#include "QF/qtypes.h" #include "QF/qtypes.h"
typedef union { typedef union {
byte chan[4]; byte chan[4];
unsigned p; unsigned p;
} pixel32_t; } pixel32_t;
typedef struct {
typedef struct { char texture[16];
char texture[16]; float rotate;
float rotate; float shift[2];
float shift[2]; float scale[2];
float scale[2];
} texturedef_t; } texturedef_t;
typedef struct {
char name[16];
typedef struct { int width;
char name[16]; int height;
NSBitmapImageRep *rep;
int width; void *data;
int height; pixel32_t flatcolor;
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];
qtexture_t *TEX_ForName (const char *name); qtexture_t *TEX_ForName (const char *name);
typedef struct { typedef struct {
NSImageRep *image; NSImageRep *image;
NSRect r; NSRect r;
char *name; char *name;
int index; int index;
int display; // flag (on/off) 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:NSObject @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;
} }
-(const char *) currentWad; - (const char *) currentWad;
-initPaletteFromWadfile:(const 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
-(const char *) getSelTextureName; - (const char *) getSelTextureName;
-setTextureByName:(const 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:(const 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 #endif // TexturePalette_h

View file

@ -15,63 +15,61 @@
#include "Storage.h" #include "Storage.h"
id texturepalette_i; id texturepalette_i;
int tex_count; int tex_count;
qtexture_t qtextures[MAX_TEXTURES]; qtexture_t qtextures[MAX_TEXTURES];
typedef struct { typedef struct {
char name[16]; char name[16];
unsigned width, height; unsigned width, height;
unsigned offsets[4]; // four mip maps stored unsigned offsets[4]; // four mip maps stored
} miptex_t; } miptex_t;
unsigned tex_palette[256]; unsigned tex_palette[256];
unsigned badtex_d[] = { unsigned badtex_d[] = {
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
}; };
qtexture_t badtex = qtexture_t badtex = {"notexture", 16, 16, NULL, badtex_d, {{0, 0, 255, 255}}};
{ "notexture", 16, 16, NULL, badtex_d, {{0, 0, 255, 255}} };
void void
CleanupName (const char *in, char *out) CleanupName (const char *in, char *out)
{ {
int i; int i;
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
if (!in[i]) if (!in[i])
@ -90,9 +88,9 @@ TEX_InitPalette
void void
TEX_InitPalette (wad_t *wad, lumpinfo_t *pallump) TEX_InitPalette (wad_t *wad, lumpinfo_t *pallump)
{ {
byte *pal, *opal; byte *pal, *opal;
int r, g, b, v; int r, g, b, v;
int i; int i;
opal = pal = malloc (pallump->size); opal = pal = malloc (pallump->size);
Qseek (wad->handle, pallump->filepos, SEEK_SET); Qseek (wad->handle, pallump->filepos, SEEK_SET);
@ -112,7 +110,6 @@ TEX_InitPalette (wad_t *wad, lumpinfo_t *pallump)
free (opal); free (opal);
} }
/* /*
================= =================
TEX_ImageFromMiptex TEX_ImageFromMiptex
@ -121,13 +118,13 @@ TEX_ImageFromMiptex
void void
TEX_ImageFromMiptex (wad_t *wad, lumpinfo_t *qtexlump) TEX_ImageFromMiptex (wad_t *wad, lumpinfo_t *qtexlump)
{ {
miptex_t *qtex; miptex_t *qtex;
NSBitmapImageRep *bm; NSBitmapImageRep *bm;
byte *source; byte *source;
unsigned *dest; unsigned *dest;
int width, height, i, count; int width, height, i, count;
qtexture_t *q; qtexture_t *q;
int tr, tg, tb; int tr, tg, tb;
qtex = malloc (qtexlump->size); qtex = malloc (qtexlump->size);
Qseek (wad->handle, qtexlump->filepos, SEEK_SET); Qseek (wad->handle, qtexlump->filepos, SEEK_SET);
@ -136,10 +133,19 @@ TEX_ImageFromMiptex (wad_t *wad, lumpinfo_t *qtexlump)
width = LittleLong (qtex->width); width = LittleLong (qtex->width);
height = LittleLong (qtex->height); height = LittleLong (qtex->height);
bm =[[NSBitmapImageRep alloc] bm = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes: NULL pixelsWide: width pixelsHigh: height bitsPerSample: 8 samplesPerPixel: 3 hasAlpha: NO isPlanar: NO colorSpaceName: NSCalibratedRGBColorSpace bytesPerRow: width * 4 bitsPerPixel:32]; initWithBitmapDataPlanes: NULL
pixelsWide: width
pixelsHigh: height
bitsPerSample: 8
samplesPerPixel: 3
hasAlpha: NO
isPlanar: NO
colorSpaceName: NSCalibratedRGBColorSpace
bytesPerRow: width * 4
bitsPerPixel: 32];
dest = (unsigned *)[bm bitmapData]; dest = (unsigned *) [bm bitmapData];
count = width * height; count = width * height;
source = (byte *) qtex + LittleLong (qtex->offsets[0]); source = (byte *) qtex + LittleLong (qtex->offsets[0]);
@ -155,9 +161,9 @@ TEX_ImageFromMiptex (wad_t *wad, lumpinfo_t *qtexlump)
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
dest[i] = tex_palette[source[i]]; dest[i] = tex_palette[source[i]];
tr += ((pixel32_t *) & dest[i])->chan[0]; tr += ((pixel32_t *) &dest[i])->chan[0];
tg += ((pixel32_t *) & dest[i])->chan[1]; tg += ((pixel32_t *) &dest[i])->chan[1];
tb += ((pixel32_t *) & dest[i])->chan[2]; tb += ((pixel32_t *) &dest[i])->chan[2];
} }
q->flatcolor.chan[0] = tr / count; q->flatcolor.chan[0] = tr / count;
@ -167,7 +173,7 @@ TEX_ImageFromMiptex (wad_t *wad, lumpinfo_t *qtexlump)
free (qtex); free (qtex);
} }
//============================================================================= // =============================================================================
/* /*
================= =================
@ -178,10 +184,10 @@ int
TEX_InitFromWad (const char *path) TEX_InitFromWad (const char *path)
{ {
int i; int i;
const char *newpath; const char *newpath;
float start, stop; float start, stop;
wad_t *wad; wad_t *wad;
lumpinfo_t *lumpinfo; lumpinfo_t *lumpinfo;
start = Sys_DoubleTime (); start = Sys_DoubleTime ();
@ -191,25 +197,26 @@ TEX_InitFromWad (const char *path)
// free any textures // free any textures
for (i = 0; i < tex_count; i++) for (i = 0; i < tex_count; i++)
[qtextures[i].rep release]; [qtextures[i].rep release];
tex_count = 0; tex_count = 0;
// try to use the cached wadfile // try to use the cached wadfile
Sys_Printf ("TEX_InitFromWad %s\n", newpath); Sys_Printf ("TEX_InitFromWad %s\n", newpath);
wad = wad_open (newpath); wad = wad_open (newpath);
if (!wad) { if (!wad) {
NSRunAlertPanel (@"Wad Error!", NSRunAlertPanel (@"Wad Error!",
[NSString stringWithFormat:@"Failed to open '%s'", [NSString stringWithFormat: @"Failed to open '%s'",
newpath], newpath],
@"OK", nil, nil); @"OK", nil,
nil);
return 0; return 0;
} }
lumpinfo = wad->lumps; lumpinfo = wad->lumps;
if (strcmp (lumpinfo->name, "PALETTE")) { if (strcmp (lumpinfo->name, "PALETTE"))
Sys_Error ("TEX_InitFromWad: %s doesn't have palette as 0", path); Sys_Error ("TEX_InitFromWad: %s doesn't have palette as 0", path);
}
TEX_InitPalette (wad, lumpinfo); TEX_InitPalette (wad, lumpinfo);
@ -217,7 +224,7 @@ TEX_InitFromWad (const char *path)
for (i = 1; i < wad->numlumps; i++, lumpinfo++) { for (i = 1; i < wad->numlumps; i++, lumpinfo++) {
if (lumpinfo->type != TYP_MIPTEX) if (lumpinfo->type != TYP_MIPTEX)
Sys_Error ("TEX_InitFromWad: %s is not a miptex!", lumpinfo->name); Sys_Error ("TEX_InitFromWad: %s is not a miptex!", lumpinfo->name);
CleanupName (lumpinfo->name,qtextures[tex_count].name); CleanupName (lumpinfo->name, qtextures[tex_count].name);
TEX_ImageFromMiptex (wad, lumpinfo); TEX_ImageFromMiptex (wad, lumpinfo);
} }
@ -239,7 +246,7 @@ TEX_ForName (const char *name)
{ {
char newname[16]; char newname[16];
int i; int i;
qtexture_t *q; qtexture_t *q;
CleanupName (name, newname); CleanupName (name, newname);
@ -251,12 +258,10 @@ TEX_ForName (const char *name)
return &badtex; return &badtex;
} }
// ===========================================================================
//===========================================================================
@implementation TexturePalette @implementation TexturePalette
-init - (id) init
{ {
[super init]; [super init];
texturepalette_i = self; texturepalette_i = self;
@ -264,25 +269,24 @@ TEX_ForName (const char *name)
return self; return self;
} }
-(void) display - (void) display
{ {
[[textureView_i superview] display]; [[textureView_i superview] display];
} }
- (const char *) currentWad
-(const char *) currentWad
{ {
return currentwad; return currentwad;
} }
-initPaletteFromWadfile:(const char *) wf - (id) initPaletteFromWadfile: (const char *)wf
{ {
int i; int i;
texpal_t t; texpal_t t;
qtexture_t *q; qtexture_t *q;
strcpy (currentwad, wf); strcpy (currentwad, wf);
[map_i makeGlobalPerform:@selector (flushTextures)]; [map_i makeGlobalPerform: @selector (flushTextures)];
selectedTexture = -1; selectedTexture = -1;
// Init textures WAD // Init textures WAD
@ -290,67 +294,65 @@ TEX_ForName (const char *name)
return self; return self;
// Create STORAGE // Create STORAGE
if (textureList_i) if (textureList_i) {
[textureList_i empty]; [textureList_i empty];
else } else {
textureList_i = [[Storage alloc] initCount: 0 textureList_i = [[Storage alloc] initCount: 0
elementSize: sizeof (texpal_t) elementSize: sizeof (texpal_t)
description: NULL]; description: NULL];
}
// Init STORAGE // Init STORAGE
for (i = 0, q = qtextures; i < tex_count; i++, q++) { for (i = 0, q = qtextures; i < tex_count; i++, q++) {
t.image = q->rep; t.image = q->rep;
t.r.size.width =[t.image pixelsWide]; t.r.size.width = [t.image pixelsWide];
if (t.r.size.width < 64) if (t.r.size.width < 64)
t.r.size.width = 64; t.r.size.width = 64;
t.r.size.height =[t.image pixelsHigh] + TEX_SPACING; t.r.size.height = [t.image pixelsHigh] + TEX_SPACING;
t.name = q->name; t.name = q->name;
t.index = i; t.index = i;
t.display = 1; t.display = 1;
[textureList_i addElement:&t]; [textureList_i addElement: &t];
} }
// Calculate size of TextureView // Calculate size of TextureView
[self alphabetize]; [self alphabetize];
[self computeTextureViewSize]; [self computeTextureViewSize];
[textureView_i setParent:self]; [textureView_i setParent: self];
[self setSelectedTexture:0]; [self setSelectedTexture: 0];
return self; return self;
} }
// Return texture STORAGE list // Return texture STORAGE list
-getList - (id) getList
{ {
return textureList_i; return textureList_i;
} }
// Alphabetize texture list - reverse order! // Alphabetize texture list - reverse order!
-alphabetize - (id) alphabetize
{ {
int i; int i;
int max; int max;
texpal_t *t1p; texpal_t *t1p;
texpal_t *t2p; texpal_t *t2p;
texpal_t t1; texpal_t t1;
texpal_t t2; texpal_t t2;
int found; int found;
max =[textureList_i count]; max = [textureList_i count];
found = 1; found = 1;
while (found) { while (found) {
found = 0; found = 0;
for (i = 0; i < max - 1; i++) { for (i = 0; i < max - 1; i++) {
t1p =[textureList_i elementAt:i]; t1p = [textureList_i elementAt: i];
t2p =[textureList_i elementAt:i + 1]; t2p = [textureList_i elementAt: i + 1];
if (strcmp (t1p->name, t2p->name) < 0) { if (strcmp (t1p->name, t2p->name) < 0) {
t1 = *t1p; t1 = *t1p;
t2 = *t2p; t2 = *t2p;
[textureList_i replaceElementAt: i with:&t2]; [textureList_i replaceElementAt: i with: &t2];
[textureList_i replaceElementAt: i + 1 with:&t1]; [textureList_i replaceElementAt: i + 1 with: &t1];
found = 1; found = 1;
} }
} }
@ -358,12 +360,12 @@ TEX_ForName (const char *name)
return self; return self;
} }
-computeTextureViewSize - (id) computeTextureViewSize
{ {
int i; int i;
int max; int max;
int x; int x;
texpal_t *t; texpal_t *t;
int y; int y;
id view; id view;
NSRect b; NSRect b;
@ -371,17 +373,17 @@ TEX_ForName (const char *name)
int maxheight; int maxheight;
NSPoint pt; NSPoint pt;
max =[textureList_i count]; max = [textureList_i count];
y = 0; y = 0;
maxheight = 0; maxheight = 0;
x = TEX_INDENT; x = TEX_INDENT;
view =[textureView_i superview]; view = [textureView_i superview];
b =[view bounds]; b = [view bounds];
maxwidth = b.size.width; maxwidth = b.size.width;
for (i = 0; i < max; i++) { for (i = 0; i < max; i++) {
t =[textureList_i elementAt:i]; t = [textureList_i elementAt: i];
if (x + t->r.size.width + TEX_INDENT > maxwidth) { if (x + t->r.size.width + TEX_INDENT > maxwidth) {
x = TEX_INDENT; x = TEX_INDENT;
y += maxheight; y += maxheight;
@ -398,42 +400,43 @@ TEX_ForName (const char *name)
viewWidth = maxwidth; viewWidth = maxwidth;
viewHeight = y + TEX_SPACING; viewHeight = y + TEX_SPACING;
[textureView_i setFrameSize:NSMakeSize (viewWidth, viewHeight)]; [textureView_i setFrameSize: NSMakeSize (viewWidth, viewHeight)];
pt.x = pt.y = 0; pt.x = pt.y = 0;
[textureView_i scrollPoint:pt]; [textureView_i scrollPoint: pt];
return self; return self;
} }
-windowResized - (id) windowResized
{ {
[self computeTextureViewSize]; [self computeTextureViewSize];
return self; return self;
} }
-texturedefChanged:sender - (id) texturedefChanged: sender
{ {
if ([map_i numSelected]) { if ([map_i numSelected]) {
if ([[map_i currentEntity] modifiable]) { if ([[map_i currentEntity] modifiable]) {
[map_i makeSelectedPerform:@selector [map_i makeSelectedPerform: @selector
(takeCurrentTexture)]; (takeCurrentTexture)];
[quakeed_i updateAll]; [quakeed_i updateAll];
} else } else {
Sys_Printf ("can't modify spawned entities\n"); Sys_Printf ("can't modify spawned entities\n");
}
} }
[quakeed_i makeFirstResponder:quakeed_i]; [quakeed_i makeFirstResponder: quakeed_i];
return self; return self;
} }
-clearTexinfo:sender - (id) clearTexinfo: sender
{ {
[field_Xshift_i setFloatValue:0]; [field_Xshift_i setFloatValue: 0];
[field_Yshift_i setFloatValue:0]; [field_Yshift_i setFloatValue: 0];
[field_Xscale_i setFloatValue:1]; [field_Xscale_i setFloatValue: 1];
[field_Yscale_i setFloatValue:1]; [field_Yscale_i setFloatValue: 1];
[field_Rotate_i setFloatValue:0]; [field_Rotate_i setFloatValue: 0];
[self texturedefChanged:self]; [self texturedefChanged: self];
return self; return self;
} }
@ -441,32 +444,32 @@ TEX_ForName (const char *name)
// //
// Set the selected texture // Set the selected texture
// //
-setSelectedTexture:(int) which - (id) setSelectedTexture: (int)which
{ {
texpal_t *t; texpal_t *t;
NSRect r; NSRect r;
// wipe the fields // wipe the fields
[self clearTexinfo:self]; [self clearTexinfo: self];
if (which != selectedTexture) { if (which != selectedTexture) {
[textureView_i deselect]; [textureView_i deselect];
selectedTexture = which; selectedTexture = which;
t =[textureList_i elementAt:which]; t = [textureList_i elementAt: which];
r = t->r; r = t->r;
r.size.width += TEX_INDENT * 2; r.size.width += TEX_INDENT * 2;
r.size.height += TEX_INDENT * 2; r.size.height += TEX_INDENT * 2;
r.origin.x -= TEX_INDENT; r.origin.x -= TEX_INDENT;
r.origin.y -= TEX_INDENT; r.origin.y -= TEX_INDENT;
[textureView_i scrollRectToVisible:r]; [textureView_i scrollRectToVisible: r];
[textureView_i display]; [textureView_i display];
[sizeField_i setStringValue: [sizeField_i setStringValue:
[NSString stringWithFormat:@"%d x %d", [NSString stringWithFormat: @"%d x %d",
(int) t->r.size.width, (int) t->r.size.width,
(int) t->r.size.height - TEX_SPACING]]; (int) t->r.size.height - TEX_SPACING]];
} }
[self texturedefChanged:self]; [self texturedefChanged: self];
return self; return self;
} }
@ -474,7 +477,7 @@ TEX_ForName (const char *name)
// //
// Return the selected texture index // Return the selected texture index
// //
-(int) getSelectedTexture - (int) getSelectedTexture
{ {
return selectedTexture; return selectedTexture;
} }
@ -483,46 +486,46 @@ TEX_ForName (const char *name)
// Return the original tex_ index of the selected texture // Return the original tex_ index of the selected texture
// so the texture info can be indexed from tex_images, etc. // so the texture info can be indexed from tex_images, etc.
// //
-(int) getSelectedTexIndex - (int) getSelectedTexIndex
{ {
texpal_t *t; texpal_t *t;
if (selectedTexture == -1) if (selectedTexture == -1)
return -1; return -1;
t =[textureList_i elementAt:selectedTexture]; t = [textureList_i elementAt: selectedTexture];
return t->index; return t->index;
} }
// //
// Return the name of the selected texture // Return the name of the selected texture
// //
-(const char *) getSelTextureName - (const char *) getSelTextureName
{ {
texpal_t *t; texpal_t *t;
if (selectedTexture == -1) if (selectedTexture == -1)
return NULL; return NULL;
t =[textureList_i elementAt:selectedTexture]; t = [textureList_i elementAt: selectedTexture];
return t->name; return t->name;
} }
// //
// Set selected texture by texture name // Set selected texture by texture name
// //
-setTextureByName:(const char *) name - (id) setTextureByName: (const char *)name
{ {
texpal_t *t; texpal_t *t;
int i; int i;
int max; int max;
char *nm = strdup (name); char *nm = strdup (name);
max =[textureList_i count]; max = [textureList_i count];
CleanupName(nm,nm); CleanupName (nm, nm);
for (i = 0; i < max; i++) { for (i = 0; i < max; i++) {
t =[textureList_i elementAt:i]; t = [textureList_i elementAt: i];
if (!strcmp (t->name, nm)) { if (!strcmp (t->name, nm)) {
free (nm); free (nm);
[self setSelectedTexture:i]; [self setSelectedTexture: i];
return self; return self;
} }
} }
@ -530,24 +533,23 @@ TEX_ForName (const char *name)
return self; return self;
} }
//=================================================== // ===================================================
// //
// Action methods // Action methods
// //
//=================================================== // ===================================================
// //
// Search for texture named in searchField // Search for texture named in searchField
// //
-searchForTexture:sender - (id) searchForTexture: sender
{ {
int i; int i;
int max; int max;
int len; int len;
NSMutableString *strname; NSMutableString *strname;
const char *name; const char *name;
texpal_t *t; texpal_t *t;
if (selectedTexture == -1) if (selectedTexture == -1)
return self; return self;
@ -560,43 +562,43 @@ TEX_ForName (const char *name)
len = strlen (name); len = strlen (name);
for (i = selectedTexture - 1; i >= 0; i--) { for (i = selectedTexture - 1; i >= 0; i--) {
t =[textureList_i elementAt:i]; t = [textureList_i elementAt: i];
if (!strncmp (t->name, name, len)) { if (!strncmp (t->name, name, len)) {
[self setTextureByName:t->name]; [self setTextureByName: t->name];
[sender selectText:sender]; [sender selectText: sender];
[self texturedefChanged:self]; [self texturedefChanged: self];
return self; return self;
} }
} }
for (i = max - 1; i >= selectedTexture; i--) { for (i = max - 1; i >= selectedTexture; i--) {
t =[textureList_i elementAt:i]; t = [textureList_i elementAt: i];
if (!strncmp (t->name, name, len)) { if (!strncmp (t->name, name, len)) {
[self setTextureByName:t->name]; [self setTextureByName: t->name];
[sender selectText:sender]; [sender selectText: sender];
[self texturedefChanged:self]; [self texturedefChanged: self];
return self; return self;
} }
} }
[self texturedefChanged:self]; [self texturedefChanged: self];
return self; return self;
} }
// //
// Set texture def from outside TexturePalette // Set texture def from outside TexturePalette
// //
-setTextureDef:(texturedef_t *) td - (id) setTextureDef: (texturedef_t *)td
{ {
[self setTextureByName:td->texture]; [self setTextureByName: td->texture];
[field_Xshift_i setFloatValue:td->shift[0]]; [field_Xshift_i setFloatValue: td->shift[0]];
[field_Yshift_i setFloatValue:td->shift[1]]; [field_Yshift_i setFloatValue: td->shift[1]];
[field_Xscale_i setFloatValue:td->scale[0]]; [field_Xscale_i setFloatValue: td->scale[0]];
[field_Yscale_i setFloatValue:td->scale[1]]; [field_Yscale_i setFloatValue: td->scale[1]];
[field_Rotate_i setFloatValue:td->rotate]; [field_Rotate_i setFloatValue: td->rotate];
[self texturedefChanged:self]; [self texturedefChanged: self];
return self; return self;
} }
@ -604,7 +606,7 @@ TEX_ForName (const char *name)
// //
// Return the current texture def to passed * // Return the current texture def to passed *
// //
-getTextureDef:(texturedef_t *) td - (id) getTextureDef: (texturedef_t *)td
{ {
if (selectedTexture == -1) { if (selectedTexture == -1) {
memset (td, 0, sizeof (*td)); memset (td, 0, sizeof (*td));
@ -612,32 +614,32 @@ TEX_ForName (const char *name)
return self; return self;
} }
strncpy (td->texture,[self getSelTextureName], 16); strncpy (td->texture, [self getSelTextureName], 16);
td->shift[0] =[field_Xshift_i floatValue]; td->shift[0] = [field_Xshift_i floatValue];
td->shift[1] =[field_Yshift_i floatValue]; td->shift[1] = [field_Yshift_i floatValue];
td->scale[0] =[field_Xscale_i floatValue]; td->scale[0] = [field_Xscale_i floatValue];
td->scale[1] =[field_Yscale_i floatValue]; td->scale[1] = [field_Yscale_i floatValue];
td->rotate =[field_Rotate_i floatValue]; td->rotate = [field_Rotate_i floatValue];
return self; return self;
} }
//============================================================================ // ============================================================================
// //
// Change value in a field // Change value in a field
// //
-changeField:(id) - (id) changeField: (id)
field by:(int) amount field by: (int)amount
{ {
int val; int val;
val =[field intValue]; val = [field intValue];
val += amount; val += amount;
[field setIntValue:val]; [field setIntValue: val];
[self texturedefChanged:self]; [self texturedefChanged: self];
return self; return self;
} }
@ -645,103 +647,101 @@ field by:(int) amount
// //
// Inc/Dec the XShift field // Inc/Dec the XShift field
// //
-incXShift:sender - (id) incXShift: sender
{ {
[self changeField: field_Xshift_i by:8]; [self changeField: field_Xshift_i by: 8];
return self; return self;
} }
-decXShift:sender - (id) decXShift: sender
{ {
[self changeField: field_Xshift_i by:-8]; [self changeField: field_Xshift_i by: -8];
return self; return self;
} }
// //
// Inc/Dec the YShift field // Inc/Dec the YShift field
// //
-incYShift:sender - (id) incYShift: sender
{ {
[self changeField: field_Yshift_i by:8]; [self changeField: field_Yshift_i by: 8];
return self; return self;
} }
-decYShift:sender - (id) decYShift: sender
{ {
[self changeField: field_Yshift_i by:-8]; [self changeField: field_Yshift_i by: -8];
return self; return self;
} }
// //
// Inc/Dec the Rotate field // Inc/Dec the Rotate field
// //
-incRotate:sender - (id) incRotate: sender
{ {
[self changeField: field_Rotate_i by:90]; [self changeField: field_Rotate_i by: 90];
return self; return self;
} }
-decRotate:sender - (id) decRotate: sender
{ {
[self changeField: field_Rotate_i by:-90]; [self changeField: field_Rotate_i by: -90];
return self; return self;
} }
// //
// Inc/Dec the Xscale field // Inc/Dec the Xscale field
// //
-incXScale:sender - (id) incXScale: sender
{ {
[field_Xscale_i setIntValue:1]; [field_Xscale_i setIntValue: 1];
[self texturedefChanged:self]; [self texturedefChanged: self];
return self; return self;
} }
-decXScale:sender - (id) decXScale: sender
{ {
[field_Xscale_i setIntValue:-1]; [field_Xscale_i setIntValue: -1];
[self texturedefChanged:self]; [self texturedefChanged: self];
return self; return self;
} }
// //
// Inc/Dec the Yscale field // Inc/Dec the Yscale field
// //
-incYScale:sender - (id) incYScale: sender
{ {
[field_Yscale_i setIntValue:1]; [field_Yscale_i setIntValue: 1];
[self texturedefChanged:self]; [self texturedefChanged: self];
return self; return self;
} }
-decYScale:sender - (id) decYScale: sender
{ {
[field_Yscale_i setIntValue:-1]; [field_Yscale_i setIntValue: -1];
[self texturedefChanged:self]; [self texturedefChanged: self];
return self; return self;
} }
// ============================================================================
//============================================================================
// //
// Search for texture in entire palette // Search for texture in entire palette
// Return index of texturedef, or -1 if unsuccessful // Return index of texturedef, or -1 if unsuccessful
// //
-(int) searchForTextureInPalette:(const char *) texture - (int) searchForTextureInPalette: (const char *)texture
{ {
int i; int i;
int max; int max;
texpal_t *t; texpal_t *t;
if (selectedTexture == -1) if (selectedTexture == -1)
return -1; return -1;
max =[textureList_i count]; max = [textureList_i count];
for (i = 0; i < max; i++) { for (i = 0; i < max; i++) {
t =[textureList_i elementAt:i]; t = [textureList_i elementAt: i];
if (!strcmp (t->name, texture)) if (!strcmp (t->name, texture))
return i; return i;
} }
@ -751,42 +751,42 @@ field by:(int) amount
// //
// Scan thru map & display only textures that are in map // Scan thru map & display only textures that are in map
// //
-onlyShowMapTextures:sender - (id) onlyShowMapTextures: sender
{ {
int max; int max;
int i; int i;
int j; int j;
id brushes; id brushes;
SetBrush *b; SetBrush *b;
int numfaces; int numfaces;
face_t *f; face_t *f;
int index; int index;
// Turn 'em off // Turn 'em off
if ([sender intValue]) { if ([sender intValue]) {
max =[textureList_i count]; max = [textureList_i count];
for (i = 0; i < max; i++) for (i = 0; i < max; i++)
[self setDisplayFlag: i to:0]; [self setDisplayFlag: i to: 0];
brushes =[map_i objectAtIndex:0]; brushes = [map_i objectAtIndex: 0];
max =[brushes count]; max = [brushes count];
for (i = 0; i < max; i++) { for (i = 0; i < max; i++) {
b = (SetBrush *)[brushes objectAtIndex:i]; b = (SetBrush *) [brushes objectAtIndex: i];
numfaces =[b getNumBrushFaces]; numfaces = [b getNumBrushFaces];
for (j = 0; j < numfaces; j++) { for (j = 0; j < numfaces; j++) {
f =[b getBrushFace:j]; f = [b getBrushFace: j];
index =[self searchForTextureInPalette:f->texture. index = [self searchForTextureInPalette: f->texture.
texture]; texture];
if (index >= 0) if (index >= 0)
[self setDisplayFlag: index to:1]; [self setDisplayFlag: index to: 1];
} }
} }
} }
// Turn 'em on // Turn 'em on
else { else {
max =[textureList_i count]; max = [textureList_i count];
for (i = 0; i < max; i++) for (i = 0; i < max; i++)
[self setDisplayFlag: i to:1]; [self setDisplayFlag: i to: 1];
} }
[textureView_i display]; [textureView_i display];
@ -794,12 +794,12 @@ field by:(int) amount
return self; return self;
} }
-setDisplayFlag:(int) - (id) setDisplayFlag: (int)
index to:(int) value index to: (int)value
{ {
texpal_t *tp; texpal_t *tp;
tp =[textureList_i elementAt:index]; tp = [textureList_i elementAt: index];
tp->display = value; tp->display = value;
return self; return self;
}; };

View file

@ -3,14 +3,14 @@
#include <AppKit/AppKit.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 #endif // TextureView_h

View file

@ -14,48 +14,47 @@ 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 - (id) setParent: (id)from
{ {
parent_i = from; parent_i = from;
return self; return self;
} }
-(BOOL) acceptsFirstMouse - (BOOL) acceptsFirstMouse
{ {
return YES; return YES;
} }
-drawRect: (NSRect) rects - (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]; NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
selected =[parent_i getSelectedTexture]; selected = [parent_i getSelectedTexture];
list_i =[parent_i getList]; list_i = [parent_i getList];
[[NSFont systemFontOfSize: FONTSIZE] set]; [[NSFont systemFontOfSize: FONTSIZE] set];
[[NSColor lightGrayColor] set]; [[NSColor lightGrayColor] set];
NSRectFill (rects); NSRectFill (rects);
if (!list_i) // WADfile didn't init 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;
@ -71,15 +70,15 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
x = t->r.origin.x; x = t->r.origin.x;
y = t->r.origin.y + 7; y = t->r.origin.y + 7;
[[NSString stringWithCString: t->name] [[NSString stringWithCString: t->name]
drawAtPoint: NSMakePoint (x, y) withAttributes: attribs]; drawAtPoint: NSMakePoint (x, y) withAttributes: attribs];
deselectIndex = -1; deselectIndex = -1;
} }
max =[list_i count]; max = [list_i count];
[[NSColor blackColor] set]; [[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;
@ -89,7 +88,7 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
[[NSColor whiteColor] set]; [[NSColor whiteColor] set];
NSRectFill (r); NSRectFill (r);
[[NSColor redColor] set]; [[NSColor redColor] set];
NSFrameRect(r); NSFrameRect (r);
[[NSColor blackColor] set]; [[NSColor blackColor] set];
} }
@ -99,41 +98,41 @@ NOTE: I am specifically not using cached image reps, because the data is also ne
x = t->r.origin.x; x = t->r.origin.x;
y = t->r.origin.y + 7; y = t->r.origin.y + 7;
[[NSString stringWithCString: t->name] [[NSString stringWithCString: t->name]
drawAtPoint: NSMakePoint (x, y) withAttributes: attribs]; drawAtPoint: NSMakePoint (x, y) withAttributes: attribs];
} }
} }
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; // int oldwindowmask;
texpal_t *t; texpal_t *t;
id list; id list;
NSRect r; NSRect r;
// oldwindowmask = [window addToEventMask:NSLeftMouseDraggedMask]; // oldwindowmask = [window addToEventMask:NSLeftMouseDraggedMask];
loc =[theEvent locationInWindow]; loc = [theEvent locationInWindow];
[self convertPoint: loc fromView:NULL]; [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;
} }
} }

View file

@ -5,43 +5,42 @@
#include "Entity.h" #include "Entity.h"
extern id things_i; extern id things_i;
#define ENTITYNAMEKEY "spawn" #define ENTITYNAMEKEY "spawn"
@interface Things:NSObject @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; id prog_path_i;
int lastSelected; // last row selected in browser int lastSelected; // last row selected in browser
id keyInput_i; id keyInput_i;
id valueInput_i; id valueInput_i;
id flags_i; id flags_i;
} }
-initEntities; - (id) initEntities;
-newCurrentEntity; - (id) newCurrentEntity;
-setSelectedKey:(epair_t *) ep; - (id) setSelectedKey: (epair_t *)ep;
-clearInputs; - (id) clearInputs;
-(const 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 #endif // Things_h

View file

@ -8,11 +8,11 @@
#include "KeypairView.h" #include "KeypairView.h"
#include "Project.h" #include "Project.h"
id things_i; id things_i;
@implementation Things @implementation Things
-init - (id) init
{ {
[super init]; [super init];
@ -22,9 +22,9 @@ id things_i;
return self; return self;
} }
-(void)awakeFromNib - (void) awakeFromNib
{ {
//FIXME this should not be needed (bug in gnustep?) // FIXME this should not be needed (bug in gnustep?)
[flags_i selectAll: self]; [flags_i selectAll: self];
[flags_i deselectAllCells]; [flags_i deselectAllCells];
} }
@ -32,143 +32,141 @@ id things_i;
// //
// Load the TEXT object with the entity comment // Load the TEXT object with the entity comment
// //
-loadEntityComment:(id) obj - (id) loadEntityComment: (id)obj
{ {
[entity_comment_i selectAll:self]; [entity_comment_i selectAll: self];
[entity_comment_i replaceCharactersInRange: [entity_comment_i selectedRange] withString: [NSString stringWithCString:[obj [entity_comment_i
comments]]]; replaceCharactersInRange: [entity_comment_i selectedRange]
withString: [NSString stringWithCString: [obj comments]]];
return self; return self;
} }
- (id) initEntities
-initEntities
{ {
const char *path; const char *path;
path =[project_i getProgDirectory]; path = [project_i getProgDirectory];
[prog_path_i setStringValue: [NSString stringWithCString:path]]; [prog_path_i setStringValue: [NSString stringWithCString: path]];
[[EntityClassList alloc] initForSourceDirectory:path]; [[EntityClassList alloc] initForSourceDirectory: path];
[self loadEntityComment: [entity_classes_i objectAtIndex:lastSelected]]; [self loadEntityComment: [entity_classes_i objectAtIndex: lastSelected]];
[entity_browser_i loadColumnZero]; [entity_browser_i loadColumnZero];
[[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column: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 objectAtIndex: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;
} }
-(const char *) spawnName - (const char *) spawnName
{ {
return[[entity_classes_i objectAtIndex:lastSelected] classname]; return [[entity_classes_i objectAtIndex: lastSelected] classname];
} }
// //
// Flush entity classes & reload them! // Flush entity classes & reload them!
// //
-reloadEntityClasses:sender - (id) reloadEntityClasses: sender
{ {
EntityClass *ent; EntityClass *ent;
const char *path; const char *path;
path = [[prog_path_i stringValue] cString]; path = [[prog_path_i stringValue] cString];
if (!path || !path[0]) { if (!path || !path[0]) {
path =[project_i getProgDirectory]; path = [project_i getProgDirectory];
[prog_path_i setStringValue: [NSString stringWithCString:path]]; [prog_path_i setStringValue: [NSString stringWithCString: path]];
} }
// Free all entity info in memory... // Free all entity info in memory...
[entity_classes_i removeAllObjects]; [entity_classes_i removeAllObjects];
[entity_classes_i release]; [entity_classes_i release];
// Now, RELOAD! // Now, RELOAD!
[[EntityClassList alloc] initForSourceDirectory:path]; [[EntityClassList alloc] initForSourceDirectory: path];
lastSelected = 0; lastSelected = 0;
ent =[entity_classes_i objectAtIndex:lastSelected]; ent = [entity_classes_i objectAtIndex: lastSelected];
[self loadEntityComment: [entity_classes_i objectAtIndex:lastSelected]]; [self loadEntityComment: [entity_classes_i objectAtIndex: lastSelected]];
[entity_browser_i loadColumnZero]; [entity_browser_i loadColumnZero];
[[entity_browser_i matrixInColumn: 0] selectCellAtRow: lastSelected column: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:(const 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 indexOfObject: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] selectCellAtRow: lastSelected column:0]; [[entity_browser_i matrixInColumn: 0] scrollCellToVisibleAtRow: lastSelected
[[entity_browser_i matrixInColumn: 0] scrollCellToVisibleAtRow: lastSelected column:0]; column: 0];
return self; return self;
} }
- (id) newCurrentEntity
-newCurrentEntity
{ {
id ent, classent, cell; id ent, classent, cell;
const char *classname; const char *classname;
int r, c; int r, c;
const 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 objectAtIndex: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 cellAtRow: r column: c];
if (c < 2) { if (c < 2) {
flagname =[classent flagName:c * 4 + r]; flagname = [classent flagName: c * 4 + r];
[cell setTitle: [NSString stringWithCString:flagname]]; [cell setTitle: [NSString stringWithCString: 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: ""];
@ -177,27 +175,27 @@ id things_i;
[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
// //
-setSelectedKey:(epair_t *) ep; - (id) setSelectedKey: (epair_t *)ep;
{ {
[keyInput_i setStringValue: [NSString stringWithCString:ep->key]]; [keyInput_i setStringValue: [NSString stringWithCString: ep->key]];
[valueInput_i setStringValue: [NSString stringWithCString: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;
} }
@ -205,14 +203,14 @@ id things_i;
// Action methods // Action methods
// //
-addPair:sender - (id) addPair: sender
{ {
const char *key, *value; const char *key, *value;
key = [[keyInput_i stringValue] cString]; key = [[keyInput_i stringValue] cString];
value = [[valueInput_i stringValue] cString]; 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];
@ -223,11 +221,11 @@ id things_i;
return self; return self;
} }
-delPair:sender - (id) delPair: sender
{ {
[quakeed_i makeFirstResponder:quakeed_i]; [quakeed_i makeFirstResponder: quakeed_i];
[[map_i currentEntity] removeKeyPair:[[keyInput_i stringValue] cString]]; [[map_i currentEntity] removeKeyPair: [[keyInput_i stringValue] cString]];
[keypairview_i calcViewSize]; [keypairview_i calcViewSize];
[keypairview_i display]; [keypairview_i display];
@ -239,23 +237,22 @@ id things_i;
return self; return self;
} }
// //
// Set the key/value fields to "angle <button value>" // Set the key/value fields to "angle <button value>"
// //
-setAngle:sender - (id) setAngle: sender
{ {
NSString *value; NSString *value;
value = [[sender selectedCell] title]; value = [[sender selectedCell] title];
if (![value compare:@"Up"]) if (![value compare: @"Up"])
value = @"-1"; value = @"-1";
else if (![value compare:@"Dn"]) else if (![value compare: @"Dn"])
value = @"-2"; value = @"-2";
[keyInput_i setStringValue:@"angle"]; [keyInput_i setStringValue: @"angle"];
[valueInput_i setStringValue: value]; [valueInput_i setStringValue: value];
[self addPair:NULL]; [self addPair: NULL];
[self clearInputs]; [self clearInputs];
@ -264,26 +261,27 @@ id things_i;
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;
[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 cellAtRow: r column: 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)]; [[map_i currentEntity] setKey: "spawnflags" toValue: va ("%i", flags)];
[keypairview_i calcViewSize]; [keypairview_i calcViewSize];
[keypairview_i display]; [keypairview_i display];
@ -291,28 +289,29 @@ id things_i;
return self; return self;
} }
// //
// Fill the Entity browser // Fill the Entity browser
// (Delegate method - delegated in Interface Builder) // (Delegate method - delegated in Interface Builder)
// //
-(void) browser: sender createRowsForColumn:(int) column inMatrix: matrix - (void) browser: sender
createRowsForColumn: (int)column
inMatrix: matrix
{ {
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 objectAtIndex: i];
[matrix addRow]; [matrix addRow];
cell =[matrix cellAtRow: i++ column:0]; cell = [matrix cellAtRow: i++ column: 0];
[cell setStringValue: [NSString stringWithCString:[object [cell setStringValue: [NSString
classname]]]; stringWithCString: [object classname]]];
[cell setLeaf:YES]; [cell setLeaf: YES];
[cell setLoaded:YES]; [cell setLoaded: YES];
} }
} }

View file

@ -9,16 +9,15 @@
#include "render.h" #include "render.h"
extern id xyview_i; extern id xyview_i;
#define MINSCALE 0.125 #define MINSCALE 0.125
#define MAXSCALE 2.0 #define MAXSCALE 2.0
extern vec3_t xy_viewnormal; // v_forward for xy view
extern float xy_viewdist; // clip behind this plane
extern vec3_t xy_viewnormal; // v_forward for xy view extern NSRect xy_draw_rect;
extern float xy_viewdist; // clip behind this plane
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);
@ -27,51 +26,57 @@ 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);
@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; int xywidth, xyheight;
float *xyzbuffer; float *xyzbuffer;
unsigned *xypicbuffer; 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; - (id) setOrigin: (NSPoint)pt scale: (float)sc;
-drawMode:sender; - (id) centerOn: (vec3_t)org;
-superviewChanged; - (id) drawMode: sender;
-(int) gridsize; - (id) superviewChanged;
-(float) snapToGrid:(float) f;
- (int) gridsize;
- (float) snapToGrid: (float)f;
@end @end
@interface NSView(XYView) @interface NSView (XYView)
-(void) setFrame:(NSRect) frame bounds:(NSRect) bounds scale:(NSSize) scale; - (void) setFrame: (NSRect)frame
bounds: (NSRect)bounds
scale: (NSSize)scale;
@end @end
#endif // XYView_h #endif // XYView_h

File diff suppressed because it is too large Load diff

View file

@ -3,14 +3,15 @@
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
@interface ZScrollView:NSScrollView @interface ZScrollView: NSScrollView
{ {
id button1; id button1;
} }
-initWithFrame:(NSRect) frameRect button1:b1; - (id) initWithFrame: (NSRect)frameRect
button1: b1;
-tile; - (id) tile;
@end @end
#endif // ZScrollView_h #endif // ZScrollView_h

View file

@ -8,21 +8,23 @@ 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
==================== ====================
*/ */
- initWithFrame:(NSRect) frameRect button1:b1 - (id) initWithFrame: (NSRect)frameRect
button1: b1
{ {
[super initWithFrame:frameRect]; [super initWithFrame: frameRect];
[self addSubview:b1]; [self addSubview: b1];
button1 = b1; button1 = b1;
[self setHasHorizontalScroller:YES]; [self setHasHorizontalScroller: YES];
[self setHasVerticalScroller:YES]; [self setHasVerticalScroller: YES];
[self setBorderType:NSBezelBorder]; [self setBorderType: NSBezelBorder];
return self; return self;
} }
/* /*
================ ================
tile tile
@ -30,38 +32,36 @@ tile
Adjust the size for the pop up scale menu Adjust the size for the pop up scale menu
================= =================
*/ */
-tile - (id) tile
{ {
NSRect scrollerframe; NSRect scrollerframe;
[super tile]; [super tile];
scrollerframe =[_horizScroller frame]; 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]; [_horizScroller setHidden: YES];
return self; return self;
} }
- (BOOL) acceptsFirstResponder
-(BOOL) acceptsFirstResponder
{ {
return YES; return YES;
} }
/* #if 0
- superviewSizeChanged:(const NSSize *)oldSize - (id) superviewSizeChanged: (const NSSize *)oldSize
{ {
[super superviewSizeChanged: oldSize]; [super superviewSizeChanged: oldSize];
[[self documentView] newSuperBounds]; [[self documentView] newSuperBounds];
return self; return self;
} }
*/
#endif
@end @end

View file

@ -7,43 +7,44 @@
#include "render.h" #include "render.h"
extern id zview_i; 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; 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 #endif // ZView_h

View file

@ -7,14 +7,14 @@
#include "XYView.h" #include "XYView.h"
#include "CameraView.h" #include "CameraView.h"
id zview_i; id zview_i;
id zscrollview_i, zscalemenu_i, zscalebutton_i; id zscrollview_i, zscalemenu_i, zscalebutton_i;
float zplane; float zplane;
float zplanedir; float zplanedir;
extern NSBezierPath *path; extern NSBezierPath *path;
@implementation ZView @implementation ZView
/* /*
@ -22,10 +22,10 @@ extern NSBezierPath *path;
initWithFrame: initWithFrame:
================== ==================
*/ */
- (id) initWithFrame:(NSRect) frameRect - (id) initWithFrame: (NSRect)frameRect
{ {
NSPoint pt; NSPoint pt;
NSBezierPath *path; NSBezierPath *path;
path = checker = [NSBezierPath new]; path = checker = [NSBezierPath new];
[path setLineWidth: 0.3]; [path setLineWidth: 0.3];
@ -37,36 +37,37 @@ initWithFrame:
origin[0] = 0.333; origin[0] = 0.333;
origin[1] = 0.333; origin[1] = 0.333;
[super initWithFrame:frameRect]; [super initWithFrame: frameRect];
[self allocateGState]; [self allocateGState];
[self clearBounds]; [self clearBounds];
zview_i = self; zview_i = self;
scale = 1; scale = 1;
// //
// initialize the pop up menus // initialize the pop up menus
// //
zscalebutton_i =[[NSPopUpButton alloc] init]; zscalebutton_i = [[NSPopUpButton alloc] init];
[zscalebutton_i setTarget:self]; [zscalebutton_i setTarget: self];
[zscalebutton_i setAction: @selector (scaleMenuTarget:)]; [zscalebutton_i setAction: @selector (scaleMenuTarget:)];
[zscalebutton_i addItemWithTitle:@"12.5%"]; [zscalebutton_i addItemWithTitle: @"12.5%"];
[zscalebutton_i addItemWithTitle:@"25%"]; [zscalebutton_i addItemWithTitle: @"25%"];
[zscalebutton_i addItemWithTitle:@"50%"]; [zscalebutton_i addItemWithTitle: @"50%"];
[zscalebutton_i addItemWithTitle:@"75%"]; [zscalebutton_i addItemWithTitle: @"75%"];
[zscalebutton_i addItemWithTitle:@"100%"]; [zscalebutton_i addItemWithTitle: @"100%"];
[zscalebutton_i addItemWithTitle:@"200%"]; [zscalebutton_i addItemWithTitle: @"200%"];
[zscalebutton_i addItemWithTitle:@"300%"]; [zscalebutton_i addItemWithTitle: @"300%"];
[zscalebutton_i selectItemAtIndex:4]; [zscalebutton_i selectItemAtIndex: 4];
// initialize the scroll view // initialize the scroll view
zscrollview_i =[[ZScrollView alloc] initWithFrame: frameRect zscrollview_i = [[ZScrollView alloc]
button1: zscalebutton_i]; initWithFrame: frameRect
[zscrollview_i setAutoresizingMask:NSViewWidthSizable | button1: zscalebutton_i];
NSViewHeightSizable]; [zscrollview_i setAutoresizingMask: NSViewWidthSizable |
NSViewHeightSizable];
[zscrollview_i setDocumentView:self]; [zscrollview_i setDocumentView: self];
[_super_view setBoundsOrigin: NSMakePoint (0, 0)]; [_super_view setBoundsOrigin: NSMakePoint (0, 0)];
@ -78,19 +79,19 @@ initWithFrame:
[self newRealBounds]; [self newRealBounds];
[self setOrigin: pt scale:1]; [self setOrigin: pt scale: 1];
return zscrollview_i; return zscrollview_i;
} }
-setXYOrigin:(NSPoint *) pt - (id) setXYOrigin: (NSPoint *)pt
{ {
origin[0] = pt->x + 0.333; origin[0] = pt->x + 0.333;
origin[1] = pt->y + 0.333; origin[1] = pt->y + 0.333;
return self; return self;
} }
-(float) currentScale - (float) currentScale
{ {
return scale; return scale;
} }
@ -100,16 +101,16 @@ initWithFrame:
setOrigin:scale: setOrigin:scale:
=================== ===================
*/ */
-setOrigin:(NSPoint) pt scale:(float) sc - (id) setOrigin: (NSPoint)pt scale: (float)sc
{ {
NSRect sframe; NSRect sframe;
NSRect bounds; NSRect bounds;
NSRect size; NSRect size;
// calculate the area visible in the cliprect // calculate the area visible in the cliprect
scale = sc; scale = sc;
bounds =[_super_view bounds]; bounds = [_super_view bounds];
bounds.origin = pt; bounds.origin = pt;
bounds.size.width /= 1; bounds.size.width /= 1;
bounds.size.height /= scale; bounds.size.height /= scale;
@ -118,7 +119,7 @@ setOrigin:scale:
// union with the realbounds // union with the realbounds
bounds = NSUnionRect (size, bounds); bounds = NSUnionRect (size, bounds);
// redisplay everything // redisplay everything
bounds.origin = NSMakePoint (-bounds.size.width/2, bounds.origin.y); bounds.origin = NSMakePoint (-bounds.size.width / 2, bounds.origin.y);
sframe = bounds; sframe = bounds;
sframe.origin.x *= 1; sframe.origin.x *= 1;
sframe.origin.y *= scale; sframe.origin.y *= scale;
@ -127,7 +128,7 @@ setOrigin:scale:
// size this view // size this view
[quakeed_i disableFlushWindow]; [quakeed_i disableFlushWindow];
[self setFrame:sframe bounds:bounds scale:NSMakeSize (1, scale)]; [self setFrame: sframe bounds: bounds scale: NSMakeSize (1, scale)];
// scroll and scale the clip view // scroll and scale the clip view
pt.x *= 1; pt.x *= 1;
@ -140,7 +141,6 @@ setOrigin:scale:
return self; return self;
} }
/* /*
==================== ====================
scaleMenuTarget: scaleMenuTarget:
@ -148,22 +148,21 @@ scaleMenuTarget:
Called when the scaler popup on the window is used Called when the scaler popup on the window is used
==================== ====================
*/ */
-scaleMenuTarget:sender - (id) scaleMenuTarget: sender
{ {
char const *item; char const *item;
NSRect rect; NSRect rect;
NSPoint mid, org, orig; NSPoint mid, org, orig;
float nscale; float nscale;
item =[[sender titleOfSelectedItem] cString]; item = [[sender titleOfSelectedItem] cString];
sscanf (item, "%f", &nscale); sscanf (item, "%f", &nscale);
nscale /= 100; nscale /= 100;
if (nscale == scale) if (nscale == scale)
return NULL; return NULL;
// keep the center of the view constant
// keep the center of the view constant rect = [_super_view bounds];
rect =[_super_view bounds];
mid.x = rect.size.width / 2; mid.x = rect.size.width / 2;
mid.y = rect.size.height / 2; mid.y = rect.size.height / 2;
@ -173,13 +172,12 @@ Called when the scaler popup on the window is used
orig.x = org.x - mid.x / 1; orig.x = org.x - mid.x / 1;
orig.y = org.y - mid.y / nscale; orig.y = org.y - mid.y / nscale;
[self setOrigin: orig scale:nscale]; [self setOrigin: orig scale: nscale];
return self; return self;
} }
- (id) clearBounds
-clearBounds
{ {
topbound = 999999; topbound = 999999;
bottombound = -999999; bottombound = -999999;
@ -187,20 +185,19 @@ Called when the scaler popup on the window is used
return self; return self;
} }
-getBounds: (float *) top:(float *) bottom; - (id) getBounds: (float *)top: (float *)bottom;
{ {
*top = topbound; *top = topbound;
*bottom = bottombound; *bottom = bottombound;
return self; return self;
} }
/* /*
================== ==================
addToHeightRange: addToHeightRange:
================== ==================
*/ */
-addToHeightRange:(float) height - (id) addToHeightRange: (float)height
{ {
if (height < minheight) if (height < minheight)
minheight = height; minheight = height;
@ -209,7 +206,6 @@ addToHeightRange:
return self; return self;
} }
/* /*
================== ==================
newSuperBounds newSuperBounds
@ -217,7 +213,7 @@ newSuperBounds
When _super_view is resized When _super_view is resized
================== ==================
*/ */
-newSuperBounds - (id) newSuperBounds
{ {
oldminheight++; oldminheight++;
[self newRealBounds]; [self newRealBounds];
@ -225,7 +221,6 @@ When _super_view is resized
return self; return self;
} }
/* /*
=================== ===================
newRealBounds newRealBounds
@ -234,17 +229,16 @@ Should only change the scroll bars, not cause any redraws.
If realbounds has shrunk, nothing will change. If realbounds has shrunk, nothing will change.
=================== ===================
*/ */
-newRealBounds - (id) newRealBounds
{ {
NSRect bounds; NSRect bounds;
NSRect sframe; NSRect sframe;
NSRect size; NSRect size;
NSClipView *cv = (NSClipView *) _super_view; NSClipView *cv = (NSClipView *) _super_view;
if (minheight == oldminheight && maxheight == oldmaxheight) if (minheight == oldminheight && maxheight == oldmaxheight)
return self; return self;
oldminheight = minheight; oldminheight = minheight;
oldmaxheight = maxheight; oldmaxheight = maxheight;
@ -252,7 +246,7 @@ If realbounds has shrunk, nothing will change.
maxheight += 16; maxheight += 16;
// calculate the area visible in the cliprect // calculate the area visible in the cliprect
bounds =[cv bounds]; bounds = [cv bounds];
bounds.size.width /= 1; bounds.size.width /= 1;
bounds.size.height /= scale; bounds.size.height /= scale;
@ -266,7 +260,7 @@ If realbounds has shrunk, nothing will change.
// size this view // size this view
[quakeed_i disableFlushWindow]; [quakeed_i disableFlushWindow];
[self setFrame:sframe bounds:bounds scale:NSMakeSize (1, scale)]; [self setFrame: sframe bounds: bounds scale: NSMakeSize (1, scale)];
[[_super_view superview] reflectScrolledClipView: cv]; [[_super_view superview] reflectScrolledClipView: cv];
@ -276,8 +270,6 @@ If realbounds has shrunk, nothing will change.
return self; return self;
} }
/* /*
============ ============
drawGrid drawGrid
@ -289,29 +281,30 @@ Rect is in global world (unscaled) coordinates
============ ============
*/ */
-drawGrid:(NSRect) rect - (id) drawGrid: (NSRect)rect
{ {
int y, stopy; int y, stopy;
float top, bottom; float top, bottom;
int left, right; int left, right;
int gridsize; int gridsize;
BOOL showcoords; BOOL showcoords;
NSMutableDictionary *attribs = [NSMutableDictionary dictionary]; NSMutableDictionary *attribs = [NSMutableDictionary dictionary];
showcoords =[quakeed_i showCoordinates]; showcoords = [quakeed_i showCoordinates];
gridsize =[xyview_i gridsize]; gridsize = [xyview_i gridsize];
left = _bounds.origin.x; left = _bounds.origin.x;
right = 24; right = 24;
bottom = rect.origin.y - 1; bottom = rect.origin.y - 1;
top = rect.origin.y + rect.size.height + 2; top = rect.origin.y + rect.size.height + 2;
// //
// grid // grid
// //
// can't just divide by grid size because of negetive coordinate
// truncating direction // can't just divide by grid size because of negetive coordinate
// // truncating direction
if (gridsize >= 4 / scale) { if (gridsize >= 4 / scale) {
y = floor (bottom / gridsize); y = floor (bottom / gridsize);
stopy = floor (top / gridsize); stopy = floor (top / gridsize);
@ -320,19 +313,23 @@ Rect is in global world (unscaled) coordinates
stopy *= gridsize; stopy *= gridsize;
if (y < bottom) if (y < bottom)
y += gridsize; y += gridsize;
[path removeAllPoints]; [path removeAllPoints];
for (; y <= stopy; y += gridsize) for ( ; y <= stopy; y += gridsize) {
if (y & 31) { if (y & 31) {
[path moveToPoint:NSMakePoint (left, y)]; [path moveToPoint: NSMakePoint (left, y)];
[path lineToPoint:NSMakePoint (right, y)]; [path lineToPoint: NSMakePoint (right, y)];
} }
// endUserPath (upath, dps_ustroke); }
[[NSColor colorWithCalibratedRed: 0.8 green: 0.8 blue: 1.0 alpha: 1.0]
set]; // thin grid color // endUserPath (upath, dps_ustroke);
[[NSColor colorWithCalibratedRed: 0.8
green: 0.8
blue: 1.0
alpha: 1.0] set]; // thin grid color
[path stroke]; [path stroke];
} }
// //
// half tiles // half tiles
// //
@ -345,12 +342,11 @@ Rect is in global world (unscaled) coordinates
stopy *= 32; stopy *= 32;
if (stopy >= top) if (stopy >= top)
stopy -= 32; stopy -= 32;
[path removeAllPoints]; [path removeAllPoints];
for (; y <= stopy; y += 64) { for ( ; y <= stopy; y += 64) {
[path moveToPoint:NSMakePoint (left, y)]; [path moveToPoint: NSMakePoint (left, y)];
[path lineToPoint:NSMakePoint (right, y)]; [path lineToPoint: NSMakePoint (right, y)];
} }
// endUserPath (upath, dps_ustroke); // endUserPath (upath, dps_ustroke);
@ -370,36 +366,32 @@ Rect is in global world (unscaled) coordinates
y += 64; y += 64;
if (stopy >= top) if (stopy >= top)
stopy -= 64; stopy -= 64;
[path removeAllPoints]; [path removeAllPoints];
[[NSColor colorWithCalibratedWhite: 0.0 / 16.0 alpha: 1.0]
set]; // for text [[NSColor colorWithCalibratedWhite: 0.0 / 16.0 alpha: 1.0] set]; // for text
[[NSFont systemFontOfSize: 10] set]; [[NSFont systemFontOfSize: 10] set];
for (; y <= stopy; y += 64) { for ( ; y <= stopy; y += 64) {
if (showcoords) { if (showcoords) {
NSString *s = [NSString stringWithFormat: @"%i", y]; NSString *s = [NSString stringWithFormat: @"%i", y];
[s drawAtPoint: NSMakePoint (left, y) withAttributes: attribs]; [s drawAtPoint: NSMakePoint (left, y) withAttributes: attribs];
} }
[path moveToPoint:NSMakePoint (left + 24, y)]; [path moveToPoint: NSMakePoint (left + 24, y)];
[path lineToPoint:NSMakePoint (right, y)]; [path lineToPoint: NSMakePoint (right, y)];
} }
// divider // divider
[path moveToPoint:NSMakePoint (0, _bounds.origin.y)]; [path moveToPoint: NSMakePoint (0, _bounds.origin.y)];
[path lineToPoint:NSMakePoint (0, [path lineToPoint: NSMakePoint (0, _bounds.origin.y + _bounds.size.height)];
_bounds.origin.y + _bounds.size.height)];
// endUserPath (upath, dps_ustroke); // endUserPath (upath, dps_ustroke);
[[NSColor colorWithCalibratedWhite: 10.0 / 16.0 alpha: 1.0] [[NSColor colorWithCalibratedWhite: 10.0 / 16.0 alpha: 1.0] set];
set];
[path stroke]; [path stroke];
// //
// origin // origin
// //
[[NSColor colorWithCalibratedWhite: 4.0 / 16.0 alpha: 1.0] [[NSColor colorWithCalibratedWhite: 4.0 / 16.0 alpha: 1.0] set];
set];
[path removeAllPoints]; [path removeAllPoints];
[path setLineWidth: 5]; [path setLineWidth: 5];
[path moveToPoint: NSMakePoint (right, 0)]; [path moveToPoint: NSMakePoint (right, 0)];
@ -410,15 +402,13 @@ Rect is in global world (unscaled) coordinates
return self; return self;
} }
- (id) drawZplane
-drawZplane
{ {
[[NSColor colorWithCalibratedRed: 0.2 green: 0.2 blue: 0.0 alpha: 1.0] [[NSColor colorWithCalibratedRed: 0.2 green: 0.2 blue: 0.0 alpha: 1.0] set];
set]; [path appendBezierPathWithArcWithCenter: NSMakePoint (0, zplane)
[path appendBezierPathWithArcWithCenter: NSMakePoint (0, zplane) radius: 4
radius: 4 startAngle: 0
startAngle: 0 endAngle: 180];
endAngle: 180];
[path fill]; [path fill];
return self; return self;
} }
@ -429,15 +419,15 @@ drawSelf
=============================================================================== ===============================================================================
*/ */
- (void) drawRect: (NSRect) rect - (void) drawRect: (NSRect)rect
{ {
//NSRect visRect; // NSRect visRect;
//Sys_Printf("ZView:drawRect\n"); // Sys_Printf("ZView:drawRect\n");
minheight = 999999; minheight = 999999;
maxheight = -999999; maxheight = -999999;
// allways draw the entire bar // allways draw the entire bar
//visRect =[self visibleRect]; // visRect =[self visibleRect];
rect = [self visibleRect]; rect = [self visibleRect];
[quakeed_i zNoRestore: rect]; [quakeed_i zNoRestore: rect];
@ -446,13 +436,13 @@ drawSelf
NSEraseRect (rect); NSEraseRect (rect);
// draw grid // draw grid
[self drawGrid:rect]; [self drawGrid: rect];
// draw zplane // draw zplane
// [self drawZplane]; FIXME zplane doesn't do anything yet // [self drawZplane]; FIXME zplane doesn't do anything yet
// draw all entities // draw all entities
[map_i makeUnselectedPerform:@selector (ZDrawSelf)]; [map_i makeUnselectedPerform: @selector (ZDrawSelf)];
// possibly resize the view // possibly resize the view
[self newRealBounds]; [self newRealBounds];
@ -465,8 +455,8 @@ XYDrawSelf
*/ */
- (void) XYDrawSelf - (void) XYDrawSelf
{ {
NSBezierPath *path; NSBezierPath *path;
NSAffineTransform *trans; NSAffineTransform *trans;
[[NSColor colorWithCalibratedRed: 0 green: 0.5 blue: 1.0 alpha: 1.0] set]; [[NSColor colorWithCalibratedRed: 0 green: 0.5 blue: 1.0 alpha: 1.0] set];
@ -479,27 +469,25 @@ XYDrawSelf
[path release]; [path release];
} }
/* /*
============== ==============
getPoint: (NSPoint *)pt getPoint: (NSPoint *)pt
============== ==============
*/ */
-getPoint:(NSPoint *) pt - (id) getPoint: (NSPoint *)pt
{ {
pt->x = origin[0] + 0.333; // offset a bit to avoid edge cases pt->x = origin[0] + 0.333; // offset a bit to avoid edge cases
pt->y = origin[1] + 0.333; pt->y = origin[1] + 0.333;
return self; return self;
} }
-setPoint:(NSPoint *) pt - (id) setPoint: (NSPoint *)pt
{ {
origin[0] = pt->x; origin[0] = pt->x;
origin[1] = pt->y; origin[1] = pt->y;
return self; return self;
} }
/* /*
============================================================================== ==============================================================================
@ -508,53 +496,51 @@ MOUSE CLICKING
============================================================================== ==============================================================================
*/ */
/* /*
================ ================
dragLoop: dragLoop:
================ ================
*/ */
static NSPoint oldreletive; static NSPoint oldreletive;
-dragFrom: (NSEvent *) startevent useGrid: (BOOL) ug callback:(void (*)(float dy)) callback - (id) dragFrom: (NSEvent *)startevent
useGrid: (BOOL)ug
callback: (void (*)(float dy))callback
{ {
NSEvent *event; NSEvent *event;
NSPoint startpt, newpt; NSPoint startpt, newpt;
NSPoint reletive, delta; NSPoint reletive, delta;
int gridsize; int gridsize;
gridsize =[xyview_i gridsize]; gridsize = [xyview_i gridsize];
startpt =[startevent locationInWindow]; startpt = [startevent locationInWindow];
startpt =[self convertPoint: startpt fromView:NULL]; startpt = [self convertPoint: startpt fromView: NULL];
oldreletive.x = oldreletive.y = 0; oldreletive.x = oldreletive.y = 0;
reletive.x = 0; reletive.x = 0;
while (1) { while (1) {
unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask
| NSRightMouseUpMask | NSRightMouseDraggedMask | NSRightMouseUpMask | NSRightMouseDraggedMask
| NSApplicationDefinedMask; | NSApplicationDefinedMask;
event =[NSApp nextEventMatchingMask: eventMask untilDate:[NSDate event = [NSApp nextEventMatchingMask: eventMask untilDate: [NSDate
distantFuture] distantFuture]
inMode: NSEventTrackingRunLoopMode dequeue:YES]; inMode: NSEventTrackingRunLoopMode dequeue:
YES];
if ([event type] == NSLeftMouseUp ||[event type] == NSRightMouseUp) if ([event type] == NSLeftMouseUp || [event type] == NSRightMouseUp)
break; break;
newpt = [event locationInWindow];
newpt =[event locationInWindow]; newpt = [self convertPoint: newpt fromView: NULL];
newpt =[self convertPoint: newpt fromView:NULL];
reletive.y = newpt.y - startpt.y; reletive.y = newpt.y - startpt.y;
if (ug) { // we want truncate towards 0 behavior if (ug) // we want truncate-towards-0 behavior here
// here
reletive.y = gridsize * (int) (reletive.y / gridsize); reletive.y = gridsize * (int) (reletive.y / gridsize);
}
if (reletive.y == oldreletive.y) if (reletive.y == oldreletive.y)
continue; continue;
delta.y = reletive.y - oldreletive.y; delta.y = reletive.y - oldreletive.y;
oldreletive = reletive; oldreletive = reletive;
callback (delta.y); callback (delta.y);
@ -563,8 +549,7 @@ static NSPoint oldreletive;
return self; return self;
} }
//============================================================================ // ============================================================================
void void
ZDragCallback (float dy) ZDragCallback (float dy)
@ -573,21 +558,20 @@ ZDragCallback (float dy)
sb_translate[1] = 0; sb_translate[1] = 0;
sb_translate[2] = dy; sb_translate[2] = dy;
[map_i makeSelectedPerform:@selector (translate)]; [map_i makeSelectedPerform: @selector (translate)];
[quakeed_i redrawInstance]; [quakeed_i redrawInstance];
} }
-selectionDragFrom:(NSEvent *) theEvent - (id) selectionDragFrom: (NSEvent *)theEvent
{ {
Sys_Printf ("dragging selection\n"); Sys_Printf ("dragging selection\n");
[self dragFrom: theEvent useGrid: YES callback:ZDragCallback]; [self dragFrom: theEvent useGrid: YES callback: ZDragCallback];
[quakeed_i updateCamera]; [quakeed_i updateCamera];
return self; return self;
} }
//============================================================================ // ============================================================================
void void
ZScrollCallback (float dy) ZScrollCallback (float dy)
@ -596,31 +580,31 @@ ZScrollCallback (float dy)
NSPoint neworg; NSPoint neworg;
float scale; float scale;
basebounds =[[zview_i superview] bounds]; basebounds = [[zview_i superview] bounds];
basebounds =[zview_i convertRect: basebounds fromView:[zview_i basebounds = [zview_i convertRect: basebounds fromView: [zview_i
superview]]; superview]];
neworg.y = basebounds.origin.y - dy; neworg.y = basebounds.origin.y - dy;
scale =[zview_i currentScale]; scale = [zview_i currentScale];
oldreletive.y -= dy; oldreletive.y -= dy;
[zview_i setOrigin: neworg scale:scale]; [zview_i setOrigin: neworg scale: scale];
} }
-scrollDragFrom:(NSEvent *) theEvent - (id) scrollDragFrom: (NSEvent *)theEvent
{ {
Sys_Printf ("scrolling view\n"); Sys_Printf ("scrolling view\n");
[self dragFrom: theEvent useGrid: YES callback:ZScrollCallback]; [self dragFrom: theEvent useGrid: YES callback: ZScrollCallback];
return self; return self;
} }
//============================================================================ // ============================================================================
void void
ZControlCallback (float dy) ZControlCallback (float dy)
{ {
int i; int i;
for (i = 0; i < numcontrolpoints; i++) for (i = 0; i < numcontrolpoints; i++)
controlpoints[i][2] += dy; controlpoints[i][2] += dy;
@ -629,31 +613,29 @@ ZControlCallback (float dy)
[quakeed_i redrawInstance]; [quakeed_i redrawInstance];
} }
-(BOOL) planeDragFrom:(NSEvent *) theEvent - (BOOL) planeDragFrom: (NSEvent *)theEvent
{ {
NSPoint pt; NSPoint pt;
vec3_t dragpoint; vec3_t dragpoint;
if ([map_i numSelected] != 1) if ([map_i numSelected] != 1)
return NO; return NO;
pt = [theEvent locationInWindow];
pt =[theEvent locationInWindow]; pt = [self convertPoint: pt fromView: NULL];
pt =[self convertPoint: pt fromView:NULL];
dragpoint[0] = origin[0]; dragpoint[0] = origin[0];
dragpoint[1] = origin[1]; dragpoint[1] = origin[1];
dragpoint[2] = pt.y; dragpoint[2] = pt.y;
[[map_i selectedBrush] getZdragface:dragpoint]; [[map_i selectedBrush] getZdragface: dragpoint];
if (!numcontrolpoints) if (!numcontrolpoints)
return NO; return NO;
Sys_Printf ("dragging brush plane\n"); Sys_Printf ("dragging brush plane\n");
pt =[theEvent locationInWindow]; pt = [theEvent locationInWindow];
pt =[self convertPoint: pt fromView:NULL]; pt = [self convertPoint: pt fromView: NULL];
[self dragFrom: theEvent useGrid: YES callback:ZControlCallback]; [self dragFrom: theEvent useGrid: YES callback: ZControlCallback];
[[map_i selectedBrush] removeIfInvalid]; [[map_i selectedBrush] removeIfInvalid];
@ -661,52 +643,51 @@ ZControlCallback (float dy)
return YES; return YES;
} }
// ============================================================================
//============================================================================
/* /*
=================== ===================
mouseDown mouseDown
=================== ===================
*/ */
-(void) mouseDown:(NSEvent *) theEvent - (void) mouseDown: (NSEvent *)theEvent
{ {
NSPoint pt; NSPoint pt;
int flags; int flags;
vec3_t p1; vec3_t p1;
pt =[theEvent locationInWindow]; pt = [theEvent locationInWindow];
pt =[self convertPoint: pt fromView:NULL]; pt = [self convertPoint: pt fromView: NULL];
p1[0] = origin[0]; p1[0] = origin[0];
p1[1] = origin[1]; p1[1] = origin[1];
p1[2] = pt.y; p1[2] = pt.y;
flags = flags =
[theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask | [theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask |
NSAlternateKeyMask | NSCommandKeyMask); NSAlternateKeyMask | NSCommandKeyMask);
// //
// shift click to select / deselect a brush from the world // shift click to select / deselect a brush from the world
// //
if (flags == NSShiftKeyMask) { if (flags == NSShiftKeyMask) {
[map_i selectRay: p1: p1:NO]; [map_i selectRay: p1: p1: NO];
return; return;
} }
// //
// alt click = set entire brush texture // alt click = set entire brush texture
// //
if (flags == NSAlternateKeyMask) { if (flags == NSAlternateKeyMask) {
[map_i setTextureRay: p1: p1:YES]; [map_i setTextureRay: p1: p1: YES];
return; return;
} }
// //
// control click = position view // control click = position view
// //
if (flags == NSControlKeyMask) { if (flags == NSControlKeyMask) {
[cameraview_i setZOrigin:pt.y]; [cameraview_i setZOrigin: pt.y];
[quakeed_i updateAll]; [quakeed_i updateAll];
[cameraview_i ZmouseDown: &pt flags:[theEvent modifierFlags]]; [cameraview_i ZmouseDown: &pt flags: [theEvent modifierFlags]];
return; return;
} }
// //
@ -714,18 +695,16 @@ mouseDown
// //
if (flags == 0) { if (flags == 0) {
// check eye // check eye
if ([cameraview_i ZmouseDown: &pt flags:[theEvent modifierFlags]]) if ([cameraview_i ZmouseDown: &pt flags: [theEvent modifierFlags]])
return; return;
if ([map_i numSelected]) { if ([map_i numSelected]) {
if (pt.x > 0) { if (pt.x > 0) {
if ([self planeDragFrom:theEvent]) if ([self planeDragFrom: theEvent])
return; return;
} }
[self selectionDragFrom:theEvent]; [self selectionDragFrom: theEvent];
return; return;
} }
} }
Sys_Printf ("bad flags for click %x %g %g\n", flags, pt.x, pt.y); Sys_Printf ("bad flags for click %x %g %g\n", flags, pt.x, pt.y);
@ -738,35 +717,31 @@ mouseDown
rightMouseDown rightMouseDown
=================== ===================
*/ */
-(void) rightMouseDown:(NSEvent *) theEvent - (void) rightMouseDown: (NSEvent *)theEvent
{ {
NSPoint pt; NSPoint pt;
int flags; int flags;
pt =[theEvent locationInWindow]; pt = [theEvent locationInWindow];
pt =[self convertPoint: pt fromView:NULL]; pt = [self convertPoint: pt fromView: NULL];
flags = flags =
[theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask | [theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask |
NSAlternateKeyMask | NSCommandKeyMask); NSAlternateKeyMask | NSCommandKeyMask);
// //
// click = scroll view // click = scroll view
// //
if (flags == 0) { if (flags == 0)
[self scrollDragFrom:theEvent]; [self scrollDragFrom: theEvent];
}
Sys_Printf ("bad flags for click\n"); Sys_Printf ("bad flags for click\n");
NopSound (); NopSound ();
} }
/* /*
=============================================================================== ===============================================================================
XY mouse view methods XY mouse view methods
=============================================================================== ===============================================================================
*/ */
@ -776,14 +751,16 @@ rightMouseDown
modalMoveLoop modalMoveLoop
================ ================
*/ */
-modalMoveLoop: (NSPoint *) basept: (vec3_t) movemod:converter - (id) modalMoveLoop: (NSPoint *)basept
: (vec3_t)movemod
: converter
{ {
vec3_t originbase; vec3_t originbase;
NSEvent *event; NSEvent *event;
NSPoint newpt; NSPoint newpt;
vec3_t delta; vec3_t delta;
int i; int i;
VectorCopy (origin, originbase); VectorCopy (origin, originbase);
@ -792,27 +769,27 @@ modalMoveLoop
while ([event type] != NSLeftMouseUp) { while ([event type] != NSLeftMouseUp) {
// calculate new point // calculate new point
newpt =[event locationInWindow]; newpt = [event locationInWindow];
newpt =[converter convertPoint: newpt fromView:NULL]; newpt = [converter convertPoint: newpt fromView: NULL];
delta[0] = newpt.x - basept->x; delta[0] = newpt.x - basept->x;
delta[1] = newpt.y - basept->y; delta[1] = newpt.y - basept->y;
delta[2] = delta[1]; // height change delta[2] = delta[1]; // height change
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
origin[i] = originbase[i] + movemod[i] * delta[i]; origin[i] = originbase[i] + movemod[i] * delta[i];
drawentry: drawentry:
// instance draw new frame // instance draw new frame
[quakeed_i newinstance]; [quakeed_i newinstance];
[self display]; [self display];
unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask; unsigned eventMask = NSLeftMouseUpMask | NSLeftMouseDraggedMask;
event =[NSApp nextEventMatchingMask: eventMask untilDate:[NSDate event = [NSApp nextEventMatchingMask: eventMask untilDate: [NSDate
distantFuture] distantFuture]
inMode: NSEventTrackingRunLoopMode dequeue:YES]; inMode: NSEventTrackingRunLoopMode dequeue:
YES];
} }
// draw the brush back into the window buffer // draw the brush back into the window buffer
@ -826,18 +803,17 @@ modalMoveLoop
XYmouseDown XYmouseDown
=============== ===============
*/ */
-(BOOL) XYmouseDown:(NSPoint *) pt - (BOOL) XYmouseDown: (NSPoint *)pt
{ {
vec3_t movemod; vec3_t movemod;
if (fabs (pt->x - origin[0]) > 16 || fabs (pt->y - origin[1]) > 16) if (fabs (pt->x - origin[0]) > 16 || fabs (pt->y - origin[1]) > 16)
return NO; return NO;
movemod[0] = 1; movemod[0] = 1;
movemod[1] = 1; movemod[1] = 1;
movemod[2] = 0; movemod[2] = 0;
[self modalMoveLoop: pt: movemod:xyview_i]; [self modalMoveLoop: pt: movemod: xyview_i];
return YES; return YES;
} }

View file

@ -1,9 +1,6 @@
char token[MAXTOKEN]; char token[MAXTOKEN];
boolean unget; boolean unget;
char *script_p; char *script_p;
int scriptline; int scriptline;
void void
@ -17,38 +14,42 @@ StartTokenParsing (char *data)
boolean boolean
GetToken (boolean crossline) GetToken (boolean crossline)
{ {
char *token_p; char *token_p;
if (unget) // is a token allready waiting? if (unget) // is a token allready waiting?
return true; return true;
// //
// skip space // skip space
// //
skipspace: skipspace:
while (*script_p <= 32) { while (*script_p <= 32) {
if (!*script_p) { if (!*script_p) {
if (!crossline) if (!crossline)
Error ("Line %i is incomplete", scriptline); Error ("Line %i is incomplete", scriptline);
return false; return false;
} }
if (*script_p++ == '\n') { if (*script_p++ == '\n') {
if (!crossline) if (!crossline)
Error ("Line %i is incomplete", scriptline); Error ("Line %i is incomplete", scriptline);
scriptline++; scriptline++;
} }
} }
if (script_p[0] == '/' && script_p[1] == '/') // comment field if (script_p[0] == '/' && script_p[1] == '/') { // comment field
{
if (!crossline) if (!crossline)
Error ("Line %i is incomplete\n", scriptline); Error ("Line %i is incomplete\n", scriptline);
while (*script_p++ != '\n')
while (*script_p++ != '\n') {
if (!*script_p) { if (!*script_p) {
if (!crossline) if (!crossline)
Error ("Line %i is incomplete", scriptline); Error ("Line %i is incomplete", scriptline);
return false; return false;
} }
}
goto skipspace; goto skipspace;
} }
// //
@ -61,17 +62,19 @@ GetToken (boolean crossline)
while (*script_p != '"') { while (*script_p != '"') {
if (!*script_p) if (!*script_p)
Error ("EOF inside quoted token"); Error ("EOF inside quoted token");
*token_p++ = *script_p++; *token_p++ = *script_p++;
if (token_p == &token[MAXTOKEN]) if (token_p == &token[MAXTOKEN])
Error ("Token too large on line %i", scriptline); Error ("Token too large on line %i", scriptline);
} }
script_p++; script_p++;
} else } else {
while (*script_p > 32) { while (*script_p > 32) {
*token_p++ = *script_p++; *token_p++ = *script_p++;
if (token_p == &token[MAXTOKEN]) if (token_p == &token[MAXTOKEN])
Error ("Token too large on line %i", scriptline); Error ("Token too large on line %i", scriptline);
} }
}
*token_p = 0; *token_p = 0;
@ -84,27 +87,22 @@ UngetToken ()
unget = true; unget = true;
} }
void void
qprintf (char *fmt, ...) // prints text to cmd_out_i qprintf (char *fmt, ...) // prints text to cmd_out_i
{ {
va_list argptr; va_list argptr;
static char string[1024]; static char string[1024];
va_start (argptr, fmt); va_start (argptr, fmt);
vsprintf (string, fmt, argptr); vsprintf (string, fmt, argptr);
va_end (argptr); va_end (argptr);
[g_cmd_out_i setStringValue: [NSString stringWithCString:string]]; [g_cmd_out_i setStringValue: [NSString stringWithCString: string]];
// NSPing (); // NSPing ();
return; return;
} }
/* /*
================= =================
Error Error
@ -112,15 +110,16 @@ Error
For abnormal program terminations For abnormal program terminations
================= =================
*/ */
BOOL in_error; BOOL in_error;
void void
Error (char *error, ...) Error (char *error, ...)
{ {
va_list argptr; va_list argptr;
static char string[1024]; static char string[1024];
if (in_error) if (in_error)
[NSApp terminate:NULL]; [NSApp terminate: NULL];
in_error = YES; in_error = YES;
va_start (argptr, error); va_start (argptr, error);
@ -129,19 +128,16 @@ Error (char *error, ...)
strcat (string, "\nmap saved to " FN_CRASHSAVE); strcat (string, "\nmap saved to " FN_CRASHSAVE);
[map_i writeMapFile: FN_CRASHSAVE useRegion:NO]; [map_i writeMapFile: FN_CRASHSAVE useRegion: NO];
NSRunAlertPanel (@"Error",[NSString stringWithCString:string], NULL, NULL, NSRunAlertPanel (@"Error", [NSString stringWithCString: string],
NULL); NULL, NULL, NULL);
[NSApp terminate: NULL];
[NSApp terminate:NULL];
} }
void void
CleanupName (char *in, char *out) CleanupName (char *in, char *out)
{ {
int i; int i;
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
if (!in[i]) if (!in[i])
@ -150,20 +146,18 @@ CleanupName (char *in, char *out)
out[i] = toupper (in[i]); out[i] = toupper (in[i]);
} }
for (; i < 16; i++) for ( ; i < 16; i++)
out[i] = 0; out[i] = 0;
} }
void void
PrintRect (NSRect * r) PrintRect (NSRect * r)
{ {
printf ("(%4.0f, %4.0f) + (%4.0f, %4.0f) = (%4.0f,%4.0f)\n", r->origin.x, 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.y, r->size.width, r->size.height,
r->origin.x + r->size.width, r->origin.y + r->size.height); r->origin.x + r->size.width, r->origin.y + r->size.height);
} }
/* /*
============ ============
FileTime FileTime
@ -174,7 +168,7 @@ returns -1 if not present
int int
FileTime (char *path) FileTime (char *path)
{ {
struct stat buf; struct stat buf;
if (stat (path, &buf) == -1) if (stat (path, &buf) == -1)
return -1; return -1;
@ -190,10 +184,10 @@ CreatePath
void void
CreatePath (char *path) CreatePath (char *path)
{ {
char *ofs; char *ofs;
for (ofs = path + 1; *ofs; ofs++) { for (ofs = path + 1; *ofs; ofs++) {
if (*ofs == '/') { // create the directory if (*ofs == '/') { // create the directory
*ofs = 0; *ofs = 0;
mkdir (path, 0777); mkdir (path, 0777);
*ofs = '/'; *ofs = '/';
@ -204,9 +198,8 @@ CreatePath (char *path)
int int
I_FileOpenRead (char *path, int *handle) I_FileOpenRead (char *path, int *handle)
{ {
int h; int h;
struct stat fileinfo; struct stat fileinfo;
h = open (path, O_RDONLY, 0666); h = open (path, O_RDONLY, 0666);
*handle = h; *handle = h;
@ -222,7 +215,7 @@ I_FileOpenRead (char *path, int *handle)
int int
I_FileOpenWrite (char *path) I_FileOpenWrite (char *path)
{ {
int handle; int handle;
umask (0); umask (0);
@ -244,28 +237,28 @@ Copies a more recent net file to the local drive
void void
Sys_UpdateFile (char *path, char *netpath) Sys_UpdateFile (char *path, char *netpath)
{ {
int ltime, ntime; int ltime, ntime;
int in, out, size; int in, out, size;
char *buf; char *buf;
ltime = FileTime (path); ltime = FileTime (path);
ntime = FileTime (netpath); ntime = FileTime (netpath);
if (ntime <= ltime) if (ntime <= ltime)
return; // up to date return; // up to date
// copy the file // copy the file
printf ("UpdateFile: copying %s to %s...\n", netpath, path); printf ("UpdateFile: copying %s to %s...\n", netpath, path);
size = I_FileOpenRead (netpath, &in); size = I_FileOpenRead (netpath, &in);
buf = malloc (size); buf = malloc (size);
if (read (in, buf, size) != size) if (read (in, buf, size) != size)
Error ("UpdateFile: couldn't read all of %s", netpath); Error ("UpdateFile: couldn't read all of %s", netpath);
close (in); close (in);
CreatePath (path); CreatePath (path);
out = I_FileOpenWrite (path); out = I_FileOpenWrite (path);
write (out, buf, size); write (out, buf, size);
close (out); close (out);
} }

View file

@ -14,7 +14,7 @@
#include "mathlib.h" #include "mathlib.h"
#include "EntityClass.h" #include "EntityClass.h"
#include "Project.h" #include "Project.h"
#include "QuakeEd.h" #include "QuakeEd.h"
#include "Map.h" #include "Map.h"
#include "TexturePalette.h" #include "TexturePalette.h"
@ -26,35 +26,34 @@
#include "CameraView.h" #include "CameraView.h"
#include "ZView.h" #include "ZView.h"
#include "ZScrollView.h" #include "ZScrollView.h"
#include "Preferences.h" #include "Preferences.h"
#include "InspectorControl.h" #include "InspectorControl.h"
#include "PopScrollView.h" #include "PopScrollView.h"
#include "KeypairView.h" #include "KeypairView.h"
#include "Things.h" #include "Things.h"
#include "TextureView.h" #include "TextureView.h"
#include "Clipper.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);
void PrintRect (NSRect * r); extern BOOL in_error;
int FileTime (char *path); void Error (char *error, ...);
void Sys_UpdateFile (char *path, char *netpath);
void CleanupName (char *in, char *out);
extern BOOL in_error; #define MAXTOKEN 128
void Error (char *error, ...); extern char token[MAXTOKEN];
extern int scriptline;
#define MAXTOKEN 128 void StartTokenParsing (char *data);
extern char token[MAXTOKEN]; boolean GetToken (boolean crossline); // returns false at eof
extern int scriptline; void UngetToken ();
void StartTokenParsing (char *data);
boolean GetToken (boolean crossline); // returns false at eof
void UngetToken ();
#define FN_CMDOUT "/tmp/QuakeEdCmd.txt"
#define FN_CMDOUT "/tmp/QuakeEdCmd.txt" #define FN_TEMPSAVE "/qcache/temp.map"
#define FN_TEMPSAVE "/qcache/temp.map" #define FN_AUTOSAVE "/qcache/AutoSaveMap.map"
#define FN_AUTOSAVE "/qcache/AutoSaveMap.map" #define FN_CRASHSAVE "/qcache/ErrorSaveMap.map"
#define FN_CRASHSAVE "/qcache/ErrorSaveMap.map" #define FN_DEVLOG "/qcache/devlog"
#define FN_DEVLOG "/qcache/devlog"
#endif // qedefs_h #endif // qedefs_h

View file

@ -3,19 +3,19 @@
#include "SetBrush.h" #include "SetBrush.h"
typedef enum { dr_wire, dr_flat, dr_texture } drawmode_t; typedef enum {dr_wire, dr_flat, dr_texture} drawmode_t;
extern int r_width, r_height; extern int r_width, r_height;
extern unsigned *r_picbuffer; extern unsigned *r_picbuffer;
extern float *r_zbuffer; extern float *r_zbuffer;
extern vec3_t r_origin, r_matrix[3]; extern vec3_t r_origin, r_matrix[3];
extern BOOL r_drawflat; 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 #endif // render_h

View file

@ -1,30 +1,29 @@
#include "render.h" #include "render.h"
extern vec3_t xy_viewnormal; extern vec3_t xy_viewnormal;
//define NOLIGHT // define NOLIGHT
vec3_t r_origin, r_matrix[3]; vec3_t r_origin, r_matrix[3];
int t_width, t_height; int t_width, t_height;
unsigned *t_data; unsigned *t_data;
int t_widthmask, t_heightmask, t_widthshift; int t_widthmask, t_heightmask, t_widthshift;
float t_widthadd, t_heightadd; float t_widthadd, t_heightadd;
int r_width, r_height; int r_width, r_height;
float *r_zbuffer; float *r_zbuffer;
unsigned *r_picbuffer; unsigned *r_picbuffer;
vec5_t rightside, leftside, rightstep, leftstep; vec5_t rightside, leftside, rightstep, leftstep;
face_t *r_face; face_t *r_face;
BOOL r_drawflat; BOOL r_drawflat;
pixel32_t r_flatcolor; pixel32_t r_flatcolor;
int sy[20]; int sy[20];
/* /*
==================== ====================
@ -34,7 +33,7 @@ REN_ClearBuffers
void void
REN_ClearBuffers (void) REN_ClearBuffers (void)
{ {
int size; int size;
size = r_width * r_height * 4; size = r_width * r_height * 4;
@ -42,22 +41,20 @@ REN_ClearBuffers (void)
memset (r_picbuffer, 0, size); memset (r_picbuffer, 0, size);
} }
/* /*
==================== ====================
REN_SetTexture REN_SetTexture
==================== ====================
*/ */
void void
REN_SetTexture (face_t * face) REN_SetTexture (face_t * face)
{ {
int i; int i;
int t_heightshift; int t_heightshift;
qtexture_t *q; qtexture_t *q;
if (!face->qtexture) if (!face->qtexture)
face->qtexture = TEX_ForName (face->texture.texture); // try to load face->qtexture = TEX_ForName (face->texture.texture); // try to load
q = face->qtexture; q = face->qtexture;
t_width = q->width; t_width = q->width;
@ -90,7 +87,7 @@ REN_SetTexture (face_t * face)
} }
if ((1 << t_widthshift) != t_width || (1 << t_heightshift) != t_height) if ((1 << t_widthshift) != t_width || (1 << t_heightshift) != t_height)
t_widthshift = t_heightshift = 0; // non power of two t_widthshift = t_heightshift = 0; // non power of two
} }
/* /*
@ -106,7 +103,7 @@ REN_DrawSpan (int y)
int tx, ty; int tx, ty;
int x1, x2; int x1, x2;
float ufrac, vfrac, zfrac, lightfrac, ustep, vstep, zstep; float ufrac, vfrac, zfrac, lightfrac, ustep, vstep, zstep;
pixel32_t *in, *out; pixel32_t *in, *out;
float scale; float scale;
if (y < 0 || y >= r_height) if (y < 0 || y >= r_height)
@ -142,7 +139,6 @@ REN_DrawSpan (int y)
if (x2 > r_width) if (x2 > r_width)
x2 = r_width; x2 = r_width;
ofs = y * r_width + x1; ofs = y * r_width + x1;
// this should be specialized for 1.0 / 0.5 / 0.75 light levels // this should be specialized for 1.0 / 0.5 / 0.75 light levels
@ -155,14 +151,14 @@ REN_DrawSpan (int y)
if (t_widthshift) { if (t_widthshift) {
tx = (int) ((ufrac * scale)) & t_widthmask; tx = (int) ((ufrac * scale)) & t_widthmask;
ty = (int) ((vfrac * scale)) & t_heightmask; ty = (int) ((vfrac * scale)) & t_heightmask;
in = (pixel32_t *) & t_data[(ty << t_widthshift) + tx]; in = (pixel32_t *) &t_data[(ty << t_widthshift) + tx];
} else { } else {
tx = (int) ((ufrac * scale) + t_widthadd) % t_width; tx = (int) ((ufrac * scale) + t_widthadd) % t_width;
ty = (int) ((vfrac * scale) + t_heightadd) % t_height; ty = (int) ((vfrac * scale) + t_heightadd) % t_height;
in = (pixel32_t *) & t_data[ty * t_width + tx]; in = (pixel32_t *) &t_data[ty * t_width + tx];
} }
out = (pixel32_t *) & r_picbuffer[ofs]; out = (pixel32_t *) &r_picbuffer[ofs];
#ifdef NOLIGHT #ifdef NOLIGHT
*out = *in; *out = *in;
#else #else
@ -177,7 +173,6 @@ REN_DrawSpan (int y)
zfrac += zstep; zfrac += zstep;
ofs++; ofs++;
} }
} }
/* /*
@ -188,11 +183,11 @@ REN_DrawFlatSpan
void void
REN_DrawFlatSpan (int y) REN_DrawFlatSpan (int y)
{ {
int x, count; int x, count;
int ofs; int ofs;
int x1, x2; int x1, x2;
float zfrac, zstep; float zfrac, zstep;
int *out; int *out;
if (y < 0 || y >= r_height) if (y < 0 || y >= r_height)
return; return;
@ -228,7 +223,6 @@ REN_DrawFlatSpan (int y)
zfrac += zstep; zfrac += zstep;
ofs++; ofs++;
} }
} }
/* /*
@ -240,12 +234,12 @@ REN_RasterizeFace
void void
REN_RasterizeFace (winding_t * w) REN_RasterizeFace (winding_t * w)
{ {
int y; int y;
int i; int i;
int top, bot; int top, bot;
int leftv, rightv; int leftv, rightv;
int count; int count;
int numvertex; int numvertex;
// //
// find top vertex // find top vertex
@ -271,7 +265,7 @@ REN_RasterizeFace (winding_t * w)
rightv = leftv; rightv = leftv;
if (top < 0 || bot > r_height || top > bot) if (top < 0 || bot > r_height || top > bot)
return; // shouldn't have to have this... return; // shouldn't have to have this...
// //
// render a trapezoid // render a trapezoid
@ -283,6 +277,7 @@ REN_RasterizeFace (winding_t * w)
do { do {
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
leftside[i] = w->points[leftv][i]; leftside[i] = w->points[leftv][i];
leftv--; leftv--;
if (leftv == -1) if (leftv == -1)
leftv = numvertex - 1; leftv = numvertex - 1;
@ -295,6 +290,7 @@ REN_RasterizeFace (winding_t * w)
do { do {
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
rightside[i] = w->points[rightv][i]; rightside[i] = w->points[rightv][i];
rightv++; rightv++;
if (rightv == numvertex) if (rightv == numvertex)
rightv = 0; rightv = 0;
@ -318,7 +314,7 @@ REN_RasterizeFace (winding_t * w)
} }
} }
//============================================================================= // =============================================================================
/* /*
================== ==================
@ -333,7 +329,7 @@ REN_DrawSpanLinear (int y)
int tx, ty; int tx, ty;
int x1, x2; int x1, x2;
float ufrac, vfrac, zfrac, ustep, vstep, zstep; float ufrac, vfrac, zfrac, ustep, vstep, zstep;
pixel32_t *in, *out; pixel32_t *in, *out;
float scale; float scale;
if (y < 0 || y >= r_height) if (y < 0 || y >= r_height)
@ -359,7 +355,6 @@ REN_DrawSpanLinear (int y)
ustep = (rightside[3] - ufrac) * scale; ustep = (rightside[3] - ufrac) * scale;
vstep = (rightside[4] - vfrac) * scale; vstep = (rightside[4] - vfrac) * scale;
if (x1 < 0) { if (x1 < 0) {
ufrac -= x1 * ustep; ufrac -= x1 * ustep;
vfrac -= x1 * vstep; vfrac -= x1 * vstep;
@ -379,14 +374,14 @@ REN_DrawSpanLinear (int y)
if (t_widthshift) { if (t_widthshift) {
tx = (int) ufrac & t_widthmask; tx = (int) ufrac & t_widthmask;
ty = (int) vfrac & t_heightmask; ty = (int) vfrac & t_heightmask;
in = (pixel32_t *) & t_data[(ty << t_widthshift) + tx]; in = (pixel32_t *) &t_data[(ty << t_widthshift) + tx];
} else { } else {
tx = (int) (ufrac + t_widthadd) % t_width; tx = (int) (ufrac + t_widthadd) % t_width;
ty = (int) (vfrac + t_heightadd) % t_height; ty = (int) (vfrac + t_heightadd) % t_height;
in = (pixel32_t *) & t_data[ty * t_width + tx]; in = (pixel32_t *) &t_data[ty * t_width + tx];
} }
out = (pixel32_t *) & r_picbuffer[ofs]; out = (pixel32_t *) &r_picbuffer[ofs];
*out = *in; *out = *in;
} }
ufrac += ustep; ufrac += ustep;
@ -394,7 +389,6 @@ REN_DrawSpanLinear (int y)
zfrac += zstep; zfrac += zstep;
ofs++; ofs++;
} }
} }
/* /*
@ -406,12 +400,12 @@ REN_RasterizeFaceLinear
void void
REN_RasterizeFaceLinear (winding_t * w) REN_RasterizeFaceLinear (winding_t * w)
{ {
int y; int y;
int i; int i;
int top, bot; int top, bot;
int leftv, rightv; int leftv, rightv;
int count; int count;
int numvertex; int numvertex;
// //
// find top vertex // find top vertex
@ -434,7 +428,7 @@ REN_RasterizeFaceLinear (winding_t * w)
rightv = leftv; rightv = leftv;
if (top < 0 || bot > r_height || top > bot) if (top < 0 || bot > r_height || top > bot)
return; // shouldn't have to have this... return; // shouldn't have to have this...
// //
// render a trapezoid // render a trapezoid
@ -446,6 +440,7 @@ REN_RasterizeFaceLinear (winding_t * w)
do { do {
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
leftside[i] = w->points[leftv][i]; leftside[i] = w->points[leftv][i];
leftv--; leftv--;
if (leftv == -1) if (leftv == -1)
leftv = numvertex - 1; leftv = numvertex - 1;
@ -458,6 +453,7 @@ REN_RasterizeFaceLinear (winding_t * w)
do { do {
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
rightside[i] = w->points[rightv][i]; rightside[i] = w->points[rightv][i];
rightv++; rightv++;
if (rightv == numvertex) if (rightv == numvertex)
rightv = 0; rightv = 0;
@ -478,7 +474,7 @@ REN_RasterizeFaceLinear (winding_t * w)
} }
} }
//============================================================================ // ============================================================================
/* /*
================== ==================
@ -494,39 +490,37 @@ REN_BeginCamera (void)
r_width_2 = (float) r_width / 2; r_width_2 = (float) r_width / 2;
r_height_3 = (float) r_height / 3; r_height_3 = (float) r_height / 3;
// clip to right side
// clip to right side
rfrustum[0].normal[0] = -1; rfrustum[0].normal[0] = -1;
rfrustum[0].normal[1] = 0; rfrustum[0].normal[1] = 0;
rfrustum[0].normal[2] = 1; rfrustum[0].normal[2] = 1;
rfrustum[0].dist = 0; rfrustum[0].dist = 0;
// clip to left side // clip to left side
rfrustum[1].normal[0] = 1; rfrustum[1].normal[0] = 1;
rfrustum[1].normal[1] = 0; rfrustum[1].normal[1] = 0;
rfrustum[1].normal[2] = 1; rfrustum[1].normal[2] = 1;
rfrustum[1].dist = 0; rfrustum[1].dist = 0;
// clip to top side // clip to top side
rfrustum[2].normal[0] = 0; rfrustum[2].normal[0] = 0;
rfrustum[2].normal[1] = -1; rfrustum[2].normal[1] = -1;
rfrustum[2].normal[2] = r_height_3 / r_width_2; rfrustum[2].normal[2] = r_height_3 / r_width_2;
rfrustum[2].dist = 0; rfrustum[2].dist = 0;
// clip to bottom side // clip to bottom side
rfrustum[3].normal[0] = 0; rfrustum[3].normal[0] = 0;
rfrustum[3].normal[1] = 1; rfrustum[3].normal[1] = 1;
rfrustum[3].normal[2] = 2 * r_height_3 / r_width_2; rfrustum[3].normal[2] = 2 * r_height_3 / r_width_2;
rfrustum[3].dist = 0; rfrustum[3].dist = 0;
// near Z // near Z
rfrustum[4].normal[0] = 0; rfrustum[4].normal[0] = 0;
rfrustum[4].normal[1] = 0; rfrustum[4].normal[1] = 0;
rfrustum[4].normal[2] = 1; rfrustum[4].normal[2] = 1;
rfrustum[4].dist = 1; rfrustum[4].dist = 1;
} }
void void
REN_BeginXY (void) REN_BeginXY (void)
{ {
@ -562,11 +556,11 @@ REN_DrawCameraFace (face_t * idpol)
int i; int i;
float scale; float scale;
int numvertex; int numvertex;
winding_t *w, *in; winding_t *w, *in;
vec3_t temp; vec3_t temp;
if (!idpol->w) if (!idpol->w)
return; // overconstrained plane return; // overconstrained plane
r_face = idpol; r_face = idpol;
@ -614,7 +608,6 @@ REN_DrawCameraFace (face_t * idpol)
w->points[i][2] = scale; w->points[i][2] = scale;
} }
// //
// draw it // draw it
// //
@ -624,7 +617,6 @@ REN_DrawCameraFace (face_t * idpol)
free (w); free (w);
} }
/* /*
===================== =====================
REN_DrawXYFace REN_DrawXYFace
@ -634,14 +626,14 @@ void
REN_DrawXYFace (face_t * idpol) REN_DrawXYFace (face_t * idpol)
{ {
int i, j, numvertex; int i, j, numvertex;
winding_t *w, *in; winding_t *w, *in;
float *dest, *source; float *dest, *source;
float temp; float temp;
if (!idpol->w) if (!idpol->w)
return; // overconstrained plane return; // overconstrained plane
w = idpol->w;
w = idpol->w;
r_face = idpol; r_face = idpol;
// //
@ -663,7 +655,7 @@ REN_DrawXYFace (face_t * idpol)
// using Z as a scale for the 2D projection // using Z as a scale for the 2D projection
w->points[i][0] = (in->points[i][0] - r_origin[0]) * r_origin[2]; w->points[i][0] = (in->points[i][0] - r_origin[0]) * r_origin[2];
w->points[i][1] = w->points[i][1] =
r_height - (in->points[i][1] - r_origin[1]) * r_origin[2]; r_height - (in->points[i][1] - r_origin[1]) * r_origin[2];
w->points[i][2] = in->points[i][2] + 3000; w->points[i][2] = in->points[i][2] + 3000;
w->points[i][3] = in->points[i][3]; w->points[i][3] = in->points[i][3];
w->points[i][4] = in->points[i][4]; w->points[i][4] = in->points[i][4];
@ -695,7 +687,7 @@ REN_DrawXYFace (face_t * idpol)
dest[2] = 4096 - dest[2]; dest[2] = 4096 - dest[2];
} }
if (xy_viewnormal[2] > 0) { // flip order when upside down if (xy_viewnormal[2] > 0) { // flip order when upside down
for (i = 0; i < w->numpoints / 2; i++) { for (i = 0; i < w->numpoints / 2; i++) {
dest = w->points[i]; dest = w->points[i];
source = w->points[w->numpoints - 1 - i]; source = w->points[w->numpoints - 1 - i];
@ -709,7 +701,6 @@ REN_DrawXYFace (face_t * idpol)
REN_SetTexture (idpol); REN_SetTexture (idpol);
// //
// draw it // draw it
// //